1 #include "qemu/osdep.h"
2 #include "qapi/error.h"
4 #include "hw/isa/isa.h"
5 #include "hw/display/ramfb.h"
6 #include "ui/console.h"
7 #include "sysemu/sysemu.h"
9 #define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
11 typedef struct RAMFBStandaloneState
{
12 SysBusDevice parent_obj
;
15 } RAMFBStandaloneState
;
17 static void display_update_wrapper(void *dev
)
19 RAMFBStandaloneState
*ramfb
= RAMFB(dev
);
21 if (0 /* native driver active */) {
22 /* non-standalone device would run native display update here */;
24 ramfb_display_update(ramfb
->con
, ramfb
->state
);
28 static const GraphicHwOps wrapper_ops
= {
29 .gfx_update
= display_update_wrapper
,
32 static void ramfb_realizefn(DeviceState
*dev
, Error
**errp
)
34 RAMFBStandaloneState
*ramfb
= RAMFB(dev
);
36 ramfb
->con
= graphic_console_init(dev
, 0, &wrapper_ops
, dev
);
37 ramfb
->state
= ramfb_setup(errp
);
40 static void ramfb_class_initfn(ObjectClass
*klass
, void *data
)
42 DeviceClass
*dc
= DEVICE_CLASS(klass
);
44 set_bit(DEVICE_CATEGORY_DISPLAY
, dc
->categories
);
45 dc
->realize
= ramfb_realizefn
;
46 dc
->desc
= "ram framebuffer standalone device";
47 dc
->user_creatable
= true;
50 static const TypeInfo ramfb_info
= {
51 .name
= TYPE_RAMFB_DEVICE
,
52 .parent
= TYPE_SYS_BUS_DEVICE
,
53 .instance_size
= sizeof(RAMFBStandaloneState
),
54 .class_init
= ramfb_class_initfn
,
57 static void ramfb_register_types(void)
59 type_register_static(&ramfb_info
);
62 type_init(ramfb_register_types
)