mambo.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright 2008 by Nathan Whitehorn. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  20. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  22. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. * SUCH DAMAGE.
  26. *
  27. */
  28. #include <sys/cdefs.h>
  29. __FBSDID("$FreeBSD$");
  30. #include <sys/param.h>
  31. #include <sys/systm.h>
  32. #include <sys/module.h>
  33. #include <sys/bus.h>
  34. #include <sys/conf.h>
  35. #include <sys/kernel.h>
  36. #include <dev/ofw/ofw_bus.h>
  37. #include <dev/ofw/openfirm.h>
  38. #include <machine/bus.h>
  39. #include <vm/vm.h>
  40. #include <vm/pmap.h>
  41. #include <sys/rman.h>
  42. /*
  43. * Mambo interface
  44. */
  45. static int mambobus_probe(device_t);
  46. static int mambobus_attach(device_t);
  47. static device_method_t mambobus_methods[] = {
  48. /* Device interface */
  49. DEVMETHOD(device_probe, mambobus_probe),
  50. DEVMETHOD(device_attach, mambobus_attach),
  51. /* Bus interface */
  52. DEVMETHOD(bus_add_child, bus_generic_add_child),
  53. DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
  54. DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
  55. DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
  56. DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
  57. DEVMETHOD(bus_release_resource, bus_generic_release_resource),
  58. DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
  59. DEVMETHOD_END
  60. };
  61. static driver_t mambobus_driver = {
  62. "mambo",
  63. mambobus_methods,
  64. 0
  65. };
  66. static devclass_t mambobus_devclass;
  67. DRIVER_MODULE(mambo, ofwbus, mambobus_driver, mambobus_devclass, 0, 0);
  68. static int
  69. mambobus_probe(device_t dev)
  70. {
  71. const char *name = ofw_bus_get_name(dev);
  72. if (name && !strcmp(name, "mambo")) {
  73. device_set_desc(dev, "Mambo Simulator");
  74. return (0);
  75. }
  76. return (ENXIO);
  77. }
  78. static int
  79. mambobus_attach(device_t dev)
  80. {
  81. bus_generic_probe(dev);
  82. return (bus_generic_attach(dev));
  83. }