if_le_tc.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* $OpenBSD: if_le_tc.c,v 1.12 2014/12/22 02:28:52 tedu Exp $ */
  2. /* $NetBSD: if_le_tc.c,v 1.12 2001/11/13 06:26:10 lukem Exp $ */
  3. /*
  4. * Copyright (c) 1996 Carnegie-Mellon University.
  5. * All rights reserved.
  6. *
  7. * Author: Chris G. Demetriou
  8. *
  9. * Permission to use, copy, modify and distribute this software and
  10. * its documentation is hereby granted, provided that both the copyright
  11. * notice and this permission notice appear in all copies of the
  12. * software, derivative works or modified versions, and any portions
  13. * thereof, and that both notices appear in supporting documentation.
  14. *
  15. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  16. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
  17. * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  18. *
  19. * Carnegie Mellon requests users of this software to return to
  20. *
  21. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  22. * School of Computer Science
  23. * Carnegie Mellon University
  24. * Pittsburgh PA 15213-3890
  25. *
  26. * any improvements or extensions that they make and grant Carnegie the
  27. * rights to redistribute these changes.
  28. */
  29. /*
  30. * LANCE on TurboChannel.
  31. */
  32. #include <sys/param.h>
  33. #include <sys/systm.h>
  34. #include <sys/mbuf.h>
  35. #include <sys/syslog.h>
  36. #include <sys/socket.h>
  37. #include <sys/device.h>
  38. #include <net/if.h>
  39. #include <net/if_media.h>
  40. #include <netinet/in.h>
  41. #include <netinet/if_ether.h>
  42. #include <dev/ic/lancereg.h>
  43. #include <dev/ic/lancevar.h>
  44. #include <dev/ic/am7990reg.h>
  45. #include <dev/ic/am7990var.h>
  46. #include <dev/tc/if_levar.h>
  47. #include <dev/tc/tcvar.h>
  48. int le_tc_match(struct device *, void *, void *);
  49. void le_tc_attach(struct device *, struct device *, void *);
  50. struct cfattach le_tc_ca = {
  51. sizeof(struct le_softc), le_tc_match, le_tc_attach
  52. };
  53. #define LE_OFFSET_RAM 0x0
  54. #define LE_OFFSET_LANCE 0x100000
  55. #define LE_OFFSET_ROM 0x1c0000
  56. int
  57. le_tc_match(struct device *parent, void *match, void *aux)
  58. {
  59. struct tc_attach_args *d = aux;
  60. if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) != 0)
  61. return (0);
  62. return (1);
  63. }
  64. void
  65. le_tc_attach(struct device *parent, struct device *self, void *aux)
  66. {
  67. struct le_softc *lesc = (void *)self;
  68. struct lance_softc *sc = &lesc->sc_am7990.lsc;
  69. struct tc_attach_args *d = aux;
  70. /*
  71. * It's on the turbochannel proper, or a kn02
  72. * baseboard implementation of a TC option card.
  73. */
  74. lesc->sc_r1 = (struct lereg1 *)
  75. TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->ta_addr + LE_OFFSET_LANCE));
  76. sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
  77. sc->sc_copytodesc = lance_copytobuf_contig;
  78. sc->sc_copyfromdesc = lance_copyfrombuf_contig;
  79. sc->sc_copytobuf = lance_copytobuf_contig;
  80. sc->sc_copyfrombuf = lance_copyfrombuf_contig;
  81. sc->sc_zerobuf = lance_zerobuf_contig;
  82. /*
  83. * TC lance boards have onboard SRAM buffers. DMA
  84. * between the onbard RAM and main memory is not possible,
  85. * so DMA setup is not required.
  86. */
  87. dec_le_common_attach(&lesc->sc_am7990,
  88. (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2));
  89. tc_intr_establish(parent, d->ta_cookie, IPL_NET, am7990_intr, sc,
  90. self->dv_xname);
  91. }