if_ep_isapnp.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* $OpenBSD: if_ep_isapnp.c,v 1.14 2014/08/11 12:45:45 mpi Exp $ */
  2. /* $NetBSD: if_ep_isapnp.c,v 1.5 1996/05/12 23:52:36 mycroft Exp $ */
  3. /*
  4. * Copyright (c) 1996 Jason R. Thorpe <thorpej@beer.org>
  5. * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org>
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. All advertising materials mentioning features or use of this software
  17. * must display the following acknowledgement:
  18. * This product includes software developed by Herb Peyerl.
  19. * 4. The name of Herb Peyerl may not be used to endorse or promote products
  20. * derived from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  23. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. * Note: Most of the code here was written by Theo de Raadt originally,
  34. * ie. all the mechanics of probing for all cards on first call and then
  35. * searching for matching devices on subsequent calls.
  36. */
  37. #include "bpfilter.h"
  38. #include <sys/param.h>
  39. #include <sys/systm.h>
  40. #include <sys/mbuf.h>
  41. #include <sys/socket.h>
  42. #include <sys/ioctl.h>
  43. #include <sys/errno.h>
  44. #include <sys/syslog.h>
  45. #include <sys/selinfo.h>
  46. #include <sys/device.h>
  47. #include <sys/timeout.h>
  48. #include <sys/queue.h>
  49. #include <net/if.h>
  50. #include <net/if_dl.h>
  51. #include <net/if_types.h>
  52. #include <net/netisr.h>
  53. #include <net/if_media.h>
  54. #include <netinet/in.h>
  55. #include <netinet/if_ether.h>
  56. #if NBPFILTER > 0
  57. #include <net/bpf.h>
  58. #endif
  59. #include <machine/cpu.h>
  60. #include <machine/bus.h>
  61. #include <machine/intr.h>
  62. #include <dev/mii/mii.h>
  63. #include <dev/mii/miivar.h>
  64. #include <dev/ic/elink3var.h>
  65. #include <dev/ic/elink3reg.h>
  66. #include <dev/isa/isavar.h>
  67. #include <dev/isa/elink.h>
  68. int ep_isapnp_match(struct device *, void *, void *);
  69. void ep_isapnp_attach(struct device *, struct device *, void *);
  70. struct cfattach ep_isapnp_ca = {
  71. sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach
  72. };
  73. /*
  74. * 3c509 cards on the ISA bus are probed in ethernet address order.
  75. * The probe sequence requires careful orchestration, and we'd like
  76. * to allow the irq and base address to be wildcarded. So, we
  77. * probe all the cards the first time epprobe() is called. On subsequent
  78. * calls we look for matching cards.
  79. */
  80. int
  81. ep_isapnp_match(struct device *parent, void *match, void *aux)
  82. {
  83. /* XXX This should be more intelligent */
  84. return 1;
  85. }
  86. void
  87. ep_isapnp_attach(struct device *parent, struct device *self, void *aux)
  88. {
  89. struct ep_softc *sc = (void *)self;
  90. struct isa_attach_args *ia = aux;
  91. bus_space_tag_t iot = ia->ia_iot;
  92. bus_space_handle_t ioh;
  93. sc->sc_iot = iot = ia->ia_iot;
  94. sc->sc_ioh = ioh = ia->ipa_io[0].h;
  95. sc->bustype = EP_BUS_ISA;
  96. printf(":");
  97. /* Should look at ia->ia_devident... */
  98. epconfig(sc, EP_CHIPSET_3C509, NULL);
  99. sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
  100. IPL_NET, epintr, sc, sc->sc_dev.dv_xname);
  101. }