qapi/error: Check format string argument in error_*prepend()
[qemu/armbru.git] / hw / misc / debugexit.c
blob99a814f10c38d4bcbac0153481a1192b69d40a36
1 /*
2 * debug exit port emulation
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 or
7 * (at your option) any later version.
8 */
10 #include "qemu/osdep.h"
11 #include "hw/isa/isa.h"
12 #include "hw/qdev-properties.h"
13 #include "qemu/module.h"
15 #define TYPE_ISA_DEBUG_EXIT_DEVICE "isa-debug-exit"
16 #define ISA_DEBUG_EXIT_DEVICE(obj) \
17 OBJECT_CHECK(ISADebugExitState, (obj), TYPE_ISA_DEBUG_EXIT_DEVICE)
19 typedef struct ISADebugExitState {
20 ISADevice parent_obj;
22 uint32_t iobase;
23 uint32_t iosize;
24 MemoryRegion io;
25 } ISADebugExitState;
27 static uint64_t debug_exit_read(void *opaque, hwaddr addr, unsigned size)
29 return 0;
32 static void debug_exit_write(void *opaque, hwaddr addr, uint64_t val,
33 unsigned width)
35 exit((val << 1) | 1);
38 static const MemoryRegionOps debug_exit_ops = {
39 .read = debug_exit_read,
40 .write = debug_exit_write,
41 .valid.min_access_size = 1,
42 .valid.max_access_size = 4,
43 .endianness = DEVICE_LITTLE_ENDIAN,
46 static void debug_exit_realizefn(DeviceState *d, Error **errp)
48 ISADevice *dev = ISA_DEVICE(d);
49 ISADebugExitState *isa = ISA_DEBUG_EXIT_DEVICE(d);
51 memory_region_init_io(&isa->io, OBJECT(dev), &debug_exit_ops, isa,
52 TYPE_ISA_DEBUG_EXIT_DEVICE, isa->iosize);
53 memory_region_add_subregion(isa_address_space_io(dev),
54 isa->iobase, &isa->io);
57 static Property debug_exit_properties[] = {
58 DEFINE_PROP_UINT32("iobase", ISADebugExitState, iobase, 0x501),
59 DEFINE_PROP_UINT32("iosize", ISADebugExitState, iosize, 0x02),
60 DEFINE_PROP_END_OF_LIST(),
63 static void debug_exit_class_initfn(ObjectClass *klass, void *data)
65 DeviceClass *dc = DEVICE_CLASS(klass);
67 dc->realize = debug_exit_realizefn;
68 device_class_set_props(dc, debug_exit_properties);
69 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
72 static const TypeInfo debug_exit_info = {
73 .name = TYPE_ISA_DEBUG_EXIT_DEVICE,
74 .parent = TYPE_ISA_DEVICE,
75 .instance_size = sizeof(ISADebugExitState),
76 .class_init = debug_exit_class_initfn,
79 static void debug_exit_register_types(void)
81 type_register_static(&debug_exit_info);
84 type_init(debug_exit_register_types)