arm_integrator_debug.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * LED, Switch and Debug control registers for ARM Integrator Boards
  3. *
  4. * This is currently a stub for this functionality but at least
  5. * ensures something other than unassigned_mem_read() handles access
  6. * to this area.
  7. *
  8. * The real h/w is described at:
  9. * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0159b/Babbfijf.html
  10. *
  11. * Copyright (c) 2013 Alex Bennée <alex@bennee.com>
  12. *
  13. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  14. * See the COPYING file in the top-level directory.
  15. */
  16. #include "qemu/osdep.h"
  17. #include "hw/hw.h"
  18. #include "hw/sysbus.h"
  19. #include "exec/address-spaces.h"
  20. #include "hw/misc/arm_integrator_debug.h"
  21. #include "qemu/log.h"
  22. #define INTEGRATOR_DEBUG(obj) \
  23. OBJECT_CHECK(IntegratorDebugState, (obj), TYPE_INTEGRATOR_DEBUG)
  24. typedef struct {
  25. SysBusDevice parent_obj;
  26. MemoryRegion iomem;
  27. } IntegratorDebugState;
  28. static uint64_t intdbg_control_read(void *opaque, hwaddr offset,
  29. unsigned size)
  30. {
  31. switch (offset >> 2) {
  32. case 0: /* ALPHA */
  33. case 1: /* LEDS */
  34. case 2: /* SWITCHES */
  35. qemu_log_mask(LOG_UNIMP,
  36. "%s: returning zero from %" HWADDR_PRIx ":%u\n",
  37. __func__, offset, size);
  38. return 0;
  39. default:
  40. qemu_log_mask(LOG_GUEST_ERROR,
  41. "%s: Bad offset %" HWADDR_PRIx,
  42. __func__, offset);
  43. return 0;
  44. }
  45. }
  46. static void intdbg_control_write(void *opaque, hwaddr offset,
  47. uint64_t value, unsigned size)
  48. {
  49. switch (offset >> 2) {
  50. case 1: /* ALPHA */
  51. case 2: /* LEDS */
  52. case 3: /* SWITCHES */
  53. /* Nothing interesting implemented yet. */
  54. qemu_log_mask(LOG_UNIMP,
  55. "%s: ignoring write of %" PRIu64
  56. " to %" HWADDR_PRIx ":%u\n",
  57. __func__, value, offset, size);
  58. break;
  59. default:
  60. qemu_log_mask(LOG_GUEST_ERROR,
  61. "%s: write of %" PRIu64
  62. " to bad offset %" HWADDR_PRIx "\n",
  63. __func__, value, offset);
  64. }
  65. }
  66. static const MemoryRegionOps intdbg_control_ops = {
  67. .read = intdbg_control_read,
  68. .write = intdbg_control_write,
  69. .endianness = DEVICE_NATIVE_ENDIAN,
  70. };
  71. static void intdbg_control_init(Object *obj)
  72. {
  73. SysBusDevice *sd = SYS_BUS_DEVICE(obj);
  74. IntegratorDebugState *s = INTEGRATOR_DEBUG(obj);
  75. memory_region_init_io(&s->iomem, obj, &intdbg_control_ops,
  76. NULL, "dbg-leds", 0x1000000);
  77. sysbus_init_mmio(sd, &s->iomem);
  78. }
  79. static const TypeInfo intdbg_info = {
  80. .name = TYPE_INTEGRATOR_DEBUG,
  81. .parent = TYPE_SYS_BUS_DEVICE,
  82. .instance_size = sizeof(IntegratorDebugState),
  83. .instance_init = intdbg_control_init,
  84. };
  85. static void intdbg_register_types(void)
  86. {
  87. type_register_static(&intdbg_info);
  88. }
  89. type_init(intdbg_register_types)