e500: fix memory leak
[qemu.git] / hw / misc / arm_integrator_debug.c
blob99b720fbb923eedd3a3cb19e5cb55d34b3703deb
1 /*
2 * LED, Switch and Debug control registers for ARM Integrator Boards
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.
8 * The real h/w is described at:
9 * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0159b/Babbfijf.html
11 * Copyright (c) 2013 Alex Bennée <alex@bennee.com>
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.
17 #include "hw/hw.h"
18 #include "hw/sysbus.h"
19 #include "exec/address-spaces.h"
20 #include "hw/misc/arm_integrator_debug.h"
22 #define INTEGRATOR_DEBUG(obj) \
23 OBJECT_CHECK(IntegratorDebugState, (obj), TYPE_INTEGRATOR_DEBUG)
25 typedef struct {
26 SysBusDevice parent_obj;
28 MemoryRegion iomem;
29 } IntegratorDebugState;
31 static uint64_t intdbg_control_read(void *opaque, hwaddr offset,
32 unsigned size)
34 switch (offset >> 2) {
35 case 0: /* ALPHA */
36 case 1: /* LEDS */
37 case 2: /* SWITCHES */
38 qemu_log_mask(LOG_UNIMP,
39 "%s: returning zero from %" HWADDR_PRIx ":%u\n",
40 __func__, offset, size);
41 return 0;
42 default:
43 qemu_log_mask(LOG_GUEST_ERROR,
44 "%s: Bad offset %" HWADDR_PRIx,
45 __func__, offset);
46 return 0;
50 static void intdbg_control_write(void *opaque, hwaddr offset,
51 uint64_t value, unsigned size)
53 switch (offset >> 2) {
54 case 1: /* ALPHA */
55 case 2: /* LEDS */
56 case 3: /* SWITCHES */
57 /* Nothing interesting implemented yet. */
58 qemu_log_mask(LOG_UNIMP,
59 "%s: ignoring write of %" PRIu64
60 " to %" HWADDR_PRIx ":%u\n",
61 __func__, value, offset, size);
62 break;
63 default:
64 qemu_log_mask(LOG_GUEST_ERROR,
65 "%s: write of %" PRIu64
66 " to bad offset %" HWADDR_PRIx "\n",
67 __func__, value, offset);
71 static const MemoryRegionOps intdbg_control_ops = {
72 .read = intdbg_control_read,
73 .write = intdbg_control_write,
74 .endianness = DEVICE_NATIVE_ENDIAN,
77 static void intdbg_control_init(Object *obj)
79 SysBusDevice *sd = SYS_BUS_DEVICE(obj);
80 IntegratorDebugState *s = INTEGRATOR_DEBUG(obj);
82 memory_region_init_io(&s->iomem, NULL, &intdbg_control_ops,
83 NULL, "dbg-leds", 0x1000000);
84 sysbus_init_mmio(sd, &s->iomem);
87 static const TypeInfo intdbg_info = {
88 .name = TYPE_INTEGRATOR_DEBUG,
89 .parent = TYPE_SYS_BUS_DEVICE,
90 .instance_size = sizeof(IntegratorDebugState),
91 .instance_init = intdbg_control_init,
94 static void intdbg_register_types(void)
96 type_register_static(&intdbg_info);
99 type_init(intdbg_register_types)