debugexit.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * debug exit port emulation
  3. *
  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. */
  9. #include "hw/hw.h"
  10. #include "hw/isa/isa.h"
  11. #define TYPE_ISA_DEBUG_EXIT_DEVICE "isa-debug-exit"
  12. #define ISA_DEBUG_EXIT_DEVICE(obj) \
  13. OBJECT_CHECK(ISADebugExitState, (obj), TYPE_ISA_DEBUG_EXIT_DEVICE)
  14. typedef struct ISADebugExitState {
  15. ISADevice parent_obj;
  16. uint32_t iobase;
  17. uint32_t iosize;
  18. MemoryRegion io;
  19. } ISADebugExitState;
  20. static void debug_exit_write(void *opaque, hwaddr addr, uint64_t val,
  21. unsigned width)
  22. {
  23. exit((val << 1) | 1);
  24. }
  25. static const MemoryRegionOps debug_exit_ops = {
  26. .write = debug_exit_write,
  27. .valid.min_access_size = 1,
  28. .valid.max_access_size = 4,
  29. .endianness = DEVICE_LITTLE_ENDIAN,
  30. };
  31. static void debug_exit_realizefn(DeviceState *d, Error **errp)
  32. {
  33. ISADevice *dev = ISA_DEVICE(d);
  34. ISADebugExitState *isa = ISA_DEBUG_EXIT_DEVICE(d);
  35. memory_region_init_io(&isa->io, OBJECT(dev), &debug_exit_ops, isa,
  36. TYPE_ISA_DEBUG_EXIT_DEVICE, isa->iosize);
  37. memory_region_add_subregion(isa_address_space_io(dev),
  38. isa->iobase, &isa->io);
  39. }
  40. static Property debug_exit_properties[] = {
  41. DEFINE_PROP_UINT32("iobase", ISADebugExitState, iobase, 0x501),
  42. DEFINE_PROP_UINT32("iosize", ISADebugExitState, iosize, 0x02),
  43. DEFINE_PROP_END_OF_LIST(),
  44. };
  45. static void debug_exit_class_initfn(ObjectClass *klass, void *data)
  46. {
  47. DeviceClass *dc = DEVICE_CLASS(klass);
  48. dc->realize = debug_exit_realizefn;
  49. dc->props = debug_exit_properties;
  50. set_bit(DEVICE_CATEGORY_MISC, dc->categories);
  51. }
  52. static const TypeInfo debug_exit_info = {
  53. .name = TYPE_ISA_DEBUG_EXIT_DEVICE,
  54. .parent = TYPE_ISA_DEVICE,
  55. .instance_size = sizeof(ISADebugExitState),
  56. .class_init = debug_exit_class_initfn,
  57. };
  58. static void debug_exit_register_types(void)
  59. {
  60. type_register_static(&debug_exit_info);
  61. }
  62. type_init(debug_exit_register_types)