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