2
0

ramfb-standalone.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "qemu/osdep.h"
  2. #include "qapi/error.h"
  3. #include "qemu/module.h"
  4. #include "hw/loader.h"
  5. #include "hw/qdev-properties.h"
  6. #include "hw/display/ramfb.h"
  7. #include "ui/console.h"
  8. #define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
  9. typedef struct RAMFBStandaloneState {
  10. SysBusDevice parent_obj;
  11. QemuConsole *con;
  12. RAMFBState *state;
  13. } RAMFBStandaloneState;
  14. static void display_update_wrapper(void *dev)
  15. {
  16. RAMFBStandaloneState *ramfb = RAMFB(dev);
  17. if (0 /* native driver active */) {
  18. /* non-standalone device would run native display update here */;
  19. } else {
  20. ramfb_display_update(ramfb->con, ramfb->state);
  21. }
  22. }
  23. static const GraphicHwOps wrapper_ops = {
  24. .gfx_update = display_update_wrapper,
  25. };
  26. static void ramfb_realizefn(DeviceState *dev, Error **errp)
  27. {
  28. RAMFBStandaloneState *ramfb = RAMFB(dev);
  29. ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
  30. ramfb->state = ramfb_setup(errp);
  31. }
  32. static void ramfb_class_initfn(ObjectClass *klass, void *data)
  33. {
  34. DeviceClass *dc = DEVICE_CLASS(klass);
  35. set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
  36. dc->realize = ramfb_realizefn;
  37. dc->desc = "ram framebuffer standalone device";
  38. dc->user_creatable = true;
  39. }
  40. static const TypeInfo ramfb_info = {
  41. .name = TYPE_RAMFB_DEVICE,
  42. .parent = TYPE_SYS_BUS_DEVICE,
  43. .instance_size = sizeof(RAMFBStandaloneState),
  44. .class_init = ramfb_class_initfn,
  45. };
  46. static void ramfb_register_types(void)
  47. {
  48. type_register_static(&ramfb_info);
  49. }
  50. type_init(ramfb_register_types)