2018-06-13 14:29:46 +02:00
|
|
|
#include "qemu/osdep.h"
|
2023-10-09 08:32:46 +02:00
|
|
|
#include "migration/vmstate.h"
|
2018-06-13 14:29:46 +02:00
|
|
|
#include "qapi/error.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2018-06-13 14:29:46 +02:00
|
|
|
#include "hw/loader.h"
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2018-06-13 14:29:46 +02:00
|
|
|
#include "hw/display/ramfb.h"
|
|
|
|
#include "ui/console.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2018-06-13 14:29:46 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
typedef struct RAMFBStandaloneState RAMFBStandaloneState;
|
2020-08-31 23:07:33 +02:00
|
|
|
DECLARE_INSTANCE_CHECKER(RAMFBStandaloneState, RAMFB,
|
|
|
|
TYPE_RAMFB_DEVICE)
|
2018-06-13 14:29:46 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct RAMFBStandaloneState {
|
2018-06-13 14:29:46 +02:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
QemuConsole *con;
|
|
|
|
RAMFBState *state;
|
2023-10-09 08:32:46 +02:00
|
|
|
bool migrate;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2018-06-13 14:29:46 +02:00
|
|
|
|
|
|
|
static void display_update_wrapper(void *dev)
|
|
|
|
{
|
|
|
|
RAMFBStandaloneState *ramfb = RAMFB(dev);
|
|
|
|
|
|
|
|
if (0 /* native driver active */) {
|
|
|
|
/* non-standalone device would run native display update here */;
|
|
|
|
} else {
|
|
|
|
ramfb_display_update(ramfb->con, ramfb->state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GraphicHwOps wrapper_ops = {
|
|
|
|
.gfx_update = display_update_wrapper,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ramfb_realizefn(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
RAMFBStandaloneState *ramfb = RAMFB(dev);
|
|
|
|
|
|
|
|
ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
|
2020-04-29 13:52:31 +02:00
|
|
|
ramfb->state = ramfb_setup(errp);
|
2018-06-13 14:29:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-09 08:32:46 +02:00
|
|
|
static bool migrate_needed(void *opaque)
|
|
|
|
{
|
|
|
|
RAMFBStandaloneState *ramfb = RAMFB(opaque);
|
|
|
|
|
|
|
|
return ramfb->migrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription ramfb_dev_vmstate = {
|
|
|
|
.name = "ramfb-dev",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = migrate_needed,
|
2023-12-21 04:16:07 +01:00
|
|
|
.fields = (const VMStateField[]) {
|
2023-10-09 08:32:46 +02:00
|
|
|
VMSTATE_STRUCT_POINTER(state, RAMFBStandaloneState, ramfb_vmstate, RAMFBState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Property ramfb_properties[] = {
|
|
|
|
DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate, true),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
2018-06-13 14:29:46 +02:00
|
|
|
static void ramfb_class_initfn(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
|
|
|
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
2023-10-09 08:32:46 +02:00
|
|
|
dc->vmsd = &ramfb_dev_vmstate;
|
2018-06-13 14:29:46 +02:00
|
|
|
dc->realize = ramfb_realizefn;
|
|
|
|
dc->desc = "ram framebuffer standalone device";
|
|
|
|
dc->user_creatable = true;
|
2023-10-09 08:32:46 +02:00
|
|
|
device_class_set_props(dc, ramfb_properties);
|
2018-06-13 14:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo ramfb_info = {
|
|
|
|
.name = TYPE_RAMFB_DEVICE,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(RAMFBStandaloneState),
|
|
|
|
.class_init = ramfb_class_initfn,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ramfb_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&ramfb_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(ramfb_register_types)
|