com_commulti.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* $OpenBSD: com_commulti.c,v 1.4 2008/04/27 09:25:26 kettenis Exp $ */
  2. /*
  3. * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name(s) of the author(s) nor the name OpenBSD
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
  18. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
  21. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. /*-
  30. * Copyright (c) 1993, 1994, 1995, 1996
  31. * Charles M. Hannum. All rights reserved.
  32. * Copyright (c) 1991 The Regents of the University of California.
  33. * All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. * 1. Redistributions of source code must retain the above copyright
  39. * notice, this list of conditions and the following disclaimer.
  40. * 2. Redistributions in binary form must reproduce the above copyright
  41. * notice, this list of conditions and the following disclaimer in the
  42. * documentation and/or other materials provided with the distribution.
  43. * 3. Neither the name of the University nor the names of its contributors
  44. * may be used to endorse or promote products derived from this software
  45. * without specific prior written permission.
  46. *
  47. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  48. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  51. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  53. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  54. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  55. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  56. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  57. * SUCH DAMAGE.
  58. *
  59. * @(#)com.c 7.5 (Berkeley) 5/16/91
  60. */
  61. #include <sys/param.h>
  62. #include <sys/systm.h>
  63. #include <sys/tty.h>
  64. #include <sys/device.h>
  65. #include <machine/intr.h>
  66. #include <machine/bus.h>
  67. #include <dev/ic/comreg.h>
  68. #include <dev/ic/comvar.h>
  69. #include <dev/isa/isavar.h>
  70. int com_commulti_probe(struct device *, void *, void *);
  71. void com_commulti_attach(struct device *, struct device *, void *);
  72. struct cfattach com_commulti_ca = {
  73. sizeof(struct com_softc), com_commulti_probe, com_commulti_attach
  74. };
  75. int
  76. com_commulti_probe(struct device *parent, void *match, void *aux)
  77. {
  78. struct commulti_attach_args *ca = aux;
  79. struct cfdata *cf = match;
  80. bus_space_handle_t ioh;
  81. bus_space_tag_t iot;
  82. int iobase;
  83. if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
  84. return (0);
  85. iot = ca->ca_iot;
  86. iobase = ca->ca_iobase;
  87. ioh = ca->ca_ioh;
  88. #ifdef KGDB
  89. if (iobase == com_kgdb_addr)
  90. return (1);
  91. #endif
  92. /* if it's in use as console, it's there. */
  93. if (iobase == comconsaddr && !comconsattached)
  94. return (1);
  95. return (comprobe1(iot, ioh));
  96. }
  97. void
  98. com_commulti_attach(struct device *parent, struct device *self, void *aux)
  99. {
  100. struct commulti_attach_args *ca = aux;
  101. struct com_softc *sc = (void *)self;
  102. sc->sc_hwflags = 0;
  103. sc->sc_swflags = 0;
  104. sc->sc_iot = ca->ca_iot;
  105. sc->sc_ioh = ca->ca_ioh;
  106. sc->sc_iobase = ca->ca_iobase;
  107. sc->sc_frequency = COM_FREQ;
  108. if (ca->ca_noien)
  109. SET(sc->sc_hwflags, COM_HW_NOIEN);
  110. com_attach_subr(sc);
  111. }