Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20161028-1' into staging
[qemu/ar7.git] / hw / misc / debugexit.c
blob84fa1a5b9d550a298283924d2710b5a65f887558
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/hw.h"
12 #include "hw/isa/isa.h"
14 #define TYPE_ISA_DEBUG_EXIT_DEVICE "isa-debug-exit"
15 #define ISA_DEBUG_EXIT_DEVICE(obj) \
16 OBJECT_CHECK(ISADebugExitState, (obj), TYPE_ISA_DEBUG_EXIT_DEVICE)
18 typedef struct ISADebugExitState {
19 ISADevice parent_obj;
21 uint32_t iobase;
22 uint32_t iosize;
23 MemoryRegion io;
24 } ISADebugExitState;
26 static void debug_exit_write(void *opaque, hwaddr addr, uint64_t val,
27 unsigned width)
29 exit((val << 1) | 1);
32 static const MemoryRegionOps debug_exit_ops = {
33 .write = debug_exit_write,
34 .valid.min_access_size = 1,
35 .valid.max_access_size = 4,
36 .endianness = DEVICE_LITTLE_ENDIAN,
39 static void debug_exit_realizefn(DeviceState *d, Error **errp)
41 ISADevice *dev = ISA_DEVICE(d);
42 ISADebugExitState *isa = ISA_DEBUG_EXIT_DEVICE(d);
44 memory_region_init_io(&isa->io, OBJECT(dev), &debug_exit_ops, isa,
45 TYPE_ISA_DEBUG_EXIT_DEVICE, isa->iosize);
46 memory_region_add_subregion(isa_address_space_io(dev),
47 isa->iobase, &isa->io);
50 static Property debug_exit_properties[] = {
51 DEFINE_PROP_UINT32("iobase", ISADebugExitState, iobase, 0x501),
52 DEFINE_PROP_UINT32("iosize", ISADebugExitState, iosize, 0x02),
53 DEFINE_PROP_END_OF_LIST(),
56 static void debug_exit_class_initfn(ObjectClass *klass, void *data)
58 DeviceClass *dc = DEVICE_CLASS(klass);
60 dc->realize = debug_exit_realizefn;
61 dc->props = debug_exit_properties;
62 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
65 static const TypeInfo debug_exit_info = {
66 .name = TYPE_ISA_DEBUG_EXIT_DEVICE,
67 .parent = TYPE_ISA_DEVICE,
68 .instance_size = sizeof(ISADebugExitState),
69 .class_init = debug_exit_class_initfn,
72 static void debug_exit_register_types(void)
74 type_register_static(&debug_exit_info);
77 type_init(debug_exit_register_types)