arm_integrator_debug.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "hw/misc/arm_integrator_debug.h"
  20. #include "qemu/log.h"
  21. #define INTEGRATOR_DEBUG(obj) \
  22. OBJECT_CHECK(IntegratorDebugState, (obj), TYPE_INTEGRATOR_DEBUG)
  23. typedef struct {
  24. SysBusDevice parent_obj;
  25. MemoryRegion iomem;
  26. } IntegratorDebugState;
  27. static uint64_t intdbg_control_read(void *opaque, hwaddr offset,
  28. unsigned size)
  29. {
  30. switch (offset >> 2) {
  31. case 0: /* ALPHA */
  32. case 1: /* LEDS */
  33. case 2: /* SWITCHES */
  34. qemu_log_mask(LOG_UNIMP,
  35. "%s: returning zero from %" HWADDR_PRIx ":%u\n",
  36. __func__, offset, size);
  37. return 0;
  38. default:
  39. qemu_log_mask(LOG_GUEST_ERROR,
  40. "%s: Bad offset %" HWADDR_PRIx,
  41. __func__, offset);
  42. return 0;
  43. }
  44. }
  45. static void intdbg_control_write(void *opaque, hwaddr offset,
  46. uint64_t value, unsigned size)
  47. {
  48. switch (offset >> 2) {
  49. case 1: /* ALPHA */
  50. case 2: /* LEDS */
  51. case 3: /* SWITCHES */
  52. /* Nothing interesting implemented yet. */
  53. qemu_log_mask(LOG_UNIMP,
  54. "%s: ignoring write of %" PRIu64
  55. " to %" HWADDR_PRIx ":%u\n",
  56. __func__, value, offset, size);
  57. break;
  58. default:
  59. qemu_log_mask(LOG_GUEST_ERROR,
  60. "%s: write of %" PRIu64
  61. " to bad offset %" HWADDR_PRIx "\n",
  62. __func__, value, offset);
  63. }
  64. }
  65. static const MemoryRegionOps intdbg_control_ops = {
  66. .read = intdbg_control_read,
  67. .write = intdbg_control_write,
  68. .endianness = DEVICE_NATIVE_ENDIAN,
  69. };
  70. static void intdbg_control_init(Object *obj)
  71. {
  72. SysBusDevice *sd = SYS_BUS_DEVICE(obj);
  73. IntegratorDebugState *s = INTEGRATOR_DEBUG(obj);
  74. memory_region_init_io(&s->iomem, obj, &intdbg_control_ops,
  75. NULL, "dbg-leds", 0x1000000);
  76. sysbus_init_mmio(sd, &s->iomem);
  77. }
  78. static const TypeInfo intdbg_info = {
  79. .name = TYPE_INTEGRATOR_DEBUG,
  80. .parent = TYPE_SYS_BUS_DEVICE,
  81. .instance_size = sizeof(IntegratorDebugState),
  82. .instance_init = intdbg_control_init,
  83. };
  84. static void intdbg_register_types(void)
  85. {
  86. type_register_static(&intdbg_info);
  87. }
  88. type_init(intdbg_register_types)