mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw/loongarch/virt: Allow user to customize OEM ID and OEM table ID
On LoongArch virt machine, the default OEM ID and OEM table ID is "BOCHS " and "BXPC ". Here property x-oem-id and x-oem-table-id is added on virt machine to set customized OEM ID and OEM table ID. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
@@ -773,6 +773,48 @@ static void virt_set_acpi(Object *obj, Visitor *v, const char *name,
|
||||
visit_type_OnOffAuto(v, name, &lvms->acpi, errp);
|
||||
}
|
||||
|
||||
static char *virt_get_oem_id(Object *obj, Error **errp)
|
||||
{
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
|
||||
|
||||
return g_strdup(lvms->oem_id);
|
||||
}
|
||||
|
||||
static void virt_set_oem_id(Object *obj, const char *value, Error **errp)
|
||||
{
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
|
||||
size_t len = strlen(value);
|
||||
|
||||
if (len > 6) {
|
||||
error_setg(errp,
|
||||
"User specified oem-id value is bigger than 6 bytes in size");
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(lvms->oem_id, value, 6);
|
||||
}
|
||||
|
||||
static char *virt_get_oem_table_id(Object *obj, Error **errp)
|
||||
{
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
|
||||
|
||||
return g_strdup(lvms->oem_table_id);
|
||||
}
|
||||
|
||||
static void virt_set_oem_table_id(Object *obj, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
|
||||
size_t len = strlen(value);
|
||||
|
||||
if (len > 8) {
|
||||
error_setg(errp,
|
||||
"User specified oem-table-id value is bigger than 8 bytes in size");
|
||||
return;
|
||||
}
|
||||
strncpy(lvms->oem_table_id, value, 8);
|
||||
}
|
||||
|
||||
static void virt_initfn(Object *obj)
|
||||
{
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
|
||||
@@ -1177,6 +1219,22 @@ static void virt_class_init(ObjectClass *oc, const void *data)
|
||||
#ifdef CONFIG_TPM
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
|
||||
#endif
|
||||
object_class_property_add_str(oc, "x-oem-id",
|
||||
virt_get_oem_id,
|
||||
virt_set_oem_id);
|
||||
object_class_property_set_description(oc, "x-oem-id",
|
||||
"Override the default value of field OEMID "
|
||||
"in ACPI table header."
|
||||
"The string may be up to 6 bytes in size");
|
||||
|
||||
|
||||
object_class_property_add_str(oc, "x-oem-table-id",
|
||||
virt_get_oem_table_id,
|
||||
virt_set_oem_table_id);
|
||||
object_class_property_set_description(oc, "x-oem-table-id",
|
||||
"Override the default value of field OEM Table ID "
|
||||
"in ACPI table header."
|
||||
"The string may be up to 8 bytes in size");
|
||||
}
|
||||
|
||||
static const TypeInfo virt_machine_types[] = {
|
||||
|
||||
Reference in New Issue
Block a user