hw_iobus.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _HW_IOBUS_C_
  15. #define _HW_IOBUS_C_
  16. #ifndef STATIC_INLINE_HW_IOBUS
  17. #define STATIC_INLINE_HW_IOBUS STATIC_INLINE
  18. #endif
  19. #include "device_table.h"
  20. /* DEVICE
  21. iobus - simple bus for attaching devices
  22. DESCRIPTION
  23. IOBUS provides a simple `local' bus for attaching (hanging)
  24. programmed IO devices from. All child devices are directly mapped
  25. into this devices parent address space (after checking that the
  26. attach address lies within the <<iobus>> address range. address).
  27. PROPERTIES
  28. None.
  29. */
  30. static void
  31. hw_iobus_attach_address_callback(device *me,
  32. attach_type type,
  33. int space,
  34. unsigned_word addr,
  35. unsigned nr_bytes,
  36. access_type access,
  37. device *client) /*callback/default*/
  38. {
  39. int attach_space;
  40. unsigned_word attach_address;
  41. /* sanity check */
  42. if (space != 0)
  43. device_error(me, "invalid space (%d) specified by %s",
  44. space, device_path(client));
  45. /* get the bus address */
  46. device_address_to_attach_address(device_parent(me),
  47. device_unit_address(me),
  48. &attach_space,
  49. &attach_address,
  50. me);
  51. if (addr < attach_address)
  52. device_error(me, "Invalid attach address 0x%lx", (unsigned long)addr);
  53. device_attach_address(device_parent(me),
  54. type,
  55. attach_space,
  56. addr,
  57. nr_bytes,
  58. access,
  59. client);
  60. }
  61. static device_callbacks const hw_iobus_callbacks = {
  62. { NULL, },
  63. { hw_iobus_attach_address_callback, },
  64. { NULL, }, /* IO */
  65. { NULL, }, /* DMA */
  66. { NULL, }, /* interrupt */
  67. { generic_device_unit_decode,
  68. generic_device_unit_encode,
  69. generic_device_address_to_attach_address,
  70. generic_device_size_to_attach_size }
  71. };
  72. const device_descriptor hw_iobus_device_descriptor[] = {
  73. { "iobus", NULL, &hw_iobus_callbacks },
  74. { NULL, },
  75. };
  76. #endif /* _HW_IOBUS_ */