ramfb-standalone.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "qom/object.h"
  9. typedef struct RAMFBStandaloneState RAMFBStandaloneState;
  10. DECLARE_INSTANCE_CHECKER(RAMFBStandaloneState, RAMFB,
  11. TYPE_RAMFB_DEVICE)
  12. struct RAMFBStandaloneState {
  13. SysBusDevice parent_obj;
  14. QemuConsole *con;
  15. RAMFBState *state;
  16. };
  17. static void display_update_wrapper(void *dev)
  18. {
  19. RAMFBStandaloneState *ramfb = RAMFB(dev);
  20. if (0 /* native driver active */) {
  21. /* non-standalone device would run native display update here */;
  22. } else {
  23. ramfb_display_update(ramfb->con, ramfb->state);
  24. }
  25. }
  26. static const GraphicHwOps wrapper_ops = {
  27. .gfx_update = display_update_wrapper,
  28. };
  29. static void ramfb_realizefn(DeviceState *dev, Error **errp)
  30. {
  31. RAMFBStandaloneState *ramfb = RAMFB(dev);
  32. ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
  33. ramfb->state = ramfb_setup(errp);
  34. }
  35. static void ramfb_class_initfn(ObjectClass *klass, void *data)
  36. {
  37. DeviceClass *dc = DEVICE_CLASS(klass);
  38. set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
  39. dc->realize = ramfb_realizefn;
  40. dc->desc = "ram framebuffer standalone device";
  41. dc->user_creatable = true;
  42. }
  43. static const TypeInfo ramfb_info = {
  44. .name = TYPE_RAMFB_DEVICE,
  45. .parent = TYPE_SYS_BUS_DEVICE,
  46. .instance_size = sizeof(RAMFBStandaloneState),
  47. .class_init = ramfb_class_initfn,
  48. };
  49. static void ramfb_register_types(void)
  50. {
  51. type_register_static(&ramfb_info);
  52. }
  53. type_init(ramfb_register_types)