* [PATCH 0/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
@ 2022-02-20 19:25 Liav Albani
2022-02-20 19:25 ` [PATCH 1/2] hw/isa: add function to check for existence of device by its type Liav Albani
2022-02-20 19:25 ` [PATCH 2/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
0 siblings, 2 replies; 4+ messages in thread
From: Liav Albani @ 2022-02-20 19:25 UTC (permalink / raw)
To: qemu-devel; +Cc: ani, imammedo, Liav Albani, mst
This can allow the guest OS to determine more easily if i8042 controller
is present in the system or not, so it doesn't need to do probing of the
controller, but just initialize it immediately, before enumerating the
ACPI AML namespace.
To allow "flexible" indication, I don't hardcode the bit at location 1
as on in the IA-PC boot flags, but try to search for i8042 on the ISA
bus to verify it exists in the system.
Why this is useful you might ask - this patch allows the guest OS to
probe and use the i8042 controller without decoding the ACPI AML blob
at all. For example, as a developer of the SerenityOS kernel, I might
want to allow people to not try to decode the ACPI AML namespace (for
now, we still don't support ACPI AML as it's a work in progress), but
still to not probe for the i8042 but just use it after looking in the
IA-PC boot flags in the ACPI FADT table.
Liav Albani (2):
hw/isa: add function to check for existence of device by its type
hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT
table
hw/acpi/aml-build.c | 7 ++++++-
hw/i386/acpi-build.c | 5 +++++
hw/i386/acpi-microvm.c | 5 +++++
hw/isa/isa-bus.c | 17 +++++++++++++++++
include/hw/acpi/acpi-defs.h | 1 +
include/hw/isa/isa.h | 1 +
6 files changed, 35 insertions(+), 1 deletion(-)
--
2.35.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] hw/isa: add function to check for existence of device by its type
2022-02-20 19:25 [PATCH 0/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
@ 2022-02-20 19:25 ` Liav Albani
2022-02-21 11:12 ` Ani Sinha
2022-02-20 19:25 ` [PATCH 2/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
1 sibling, 1 reply; 4+ messages in thread
From: Liav Albani @ 2022-02-20 19:25 UTC (permalink / raw)
To: qemu-devel; +Cc: ani, imammedo, Liav Albani, mst
Signed-off-by: Liav Albani <liavalb@gmail.com>
---
hw/isa/isa-bus.c | 17 +++++++++++++++++
include/hw/isa/isa.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index 6c31398dda..39d1768797 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -222,6 +222,23 @@ void isa_build_aml(ISABus *bus, Aml *scope)
}
}
+bool isa_check_device_existence(const char *typename)
+{
+ assert(isabus != NULL);
+
+ BusChild *kid;
+ ISADevice *dev;
+
+ QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) {
+ dev = ISA_DEVICE(kid->child);
+ const char *object_type = object_get_typename(OBJECT(dev));
+ if (object_type && strcmp(object_type, typename) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
ISADevice *d = ISA_DEVICE(dev);
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index d4417b34b6..65f0c7e28c 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -99,6 +99,7 @@ IsaDma *isa_get_dma(ISABus *bus, int nchan);
MemoryRegion *isa_address_space(ISADevice *dev);
MemoryRegion *isa_address_space_io(ISADevice *dev);
ISADevice *isa_new(const char *name);
+bool isa_check_device_existence(const char *typename);
ISADevice *isa_try_new(const char *name);
bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
ISADevice *isa_create_simple(ISABus *bus, const char *name);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
2022-02-20 19:25 [PATCH 0/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
2022-02-20 19:25 ` [PATCH 1/2] hw/isa: add function to check for existence of device by its type Liav Albani
@ 2022-02-20 19:25 ` Liav Albani
1 sibling, 0 replies; 4+ messages in thread
From: Liav Albani @ 2022-02-20 19:25 UTC (permalink / raw)
To: qemu-devel; +Cc: ani, imammedo, Liav Albani, mst
This can allow the guest OS to determine more easily if i8042 controller
is present in the system or not, so it doesn't need to do probing of the
controller, but just initialize it immediately, before enumerating the
ACPI AML namespace.
Signed-off-by: Liav Albani <liavalb@gmail.com>
---
hw/acpi/aml-build.c | 7 ++++++-
hw/i386/acpi-build.c | 5 +++++
hw/i386/acpi-microvm.c | 5 +++++
include/hw/acpi/acpi-defs.h | 1 +
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 8966e16320..ef5f4cad87 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -2152,7 +2152,12 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
build_append_int_noprefix(tbl, 0, 1); /* DAY_ALRM */
build_append_int_noprefix(tbl, 0, 1); /* MON_ALRM */
build_append_int_noprefix(tbl, f->rtc_century, 1); /* CENTURY */
- build_append_int_noprefix(tbl, 0, 2); /* IAPC_BOOT_ARCH */
+ /* IAPC_BOOT_ARCH */
+ if (f->rev == 1) {
+ build_append_int_noprefix(tbl, 0, 2);
+ } else {
+ build_append_int_noprefix(tbl, f->iapc_boot_arch, 2);
+ }
build_append_int_noprefix(tbl, 0, 1); /* Reserved */
build_append_int_noprefix(tbl, f->flags, 4); /* Flags */
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index ebd47aa26f..5dc625b8d8 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -192,6 +192,11 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
.address = object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK, NULL)
},
};
+ if (isa_check_device_existence("i8042")) {
+ /* Indicates if i8042 is present or not */
+ fadt.iapc_boot_arch = (1 << 1);
+ }
+
*data = fadt;
}
diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index 68ca7e7fc2..756c69b3b0 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -189,6 +189,11 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
.reset_val = ACPI_GED_RESET_VALUE,
};
+ if (isa_check_device_existence("i8042")) {
+ /* Indicates if i8042 is present or not */
+ pmfadt.iapc_boot_arch = (1 << 1);
+ }
+
table_offsets = g_array_new(false, true /* clear */,
sizeof(uint32_t));
bios_linker_loader_alloc(tables->linker,
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index c97e8633ad..2b42e4192b 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -77,6 +77,7 @@ typedef struct AcpiFadtData {
uint16_t plvl2_lat; /* P_LVL2_LAT */
uint16_t plvl3_lat; /* P_LVL3_LAT */
uint16_t arm_boot_arch; /* ARM_BOOT_ARCH */
+ uint16_t iapc_boot_arch; /* IAPC_BOOT_ARCH */
uint8_t minor_ver; /* FADT Minor Version */
/*
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] hw/isa: add function to check for existence of device by its type
2022-02-20 19:25 ` [PATCH 1/2] hw/isa: add function to check for existence of device by its type Liav Albani
@ 2022-02-21 11:12 ` Ani Sinha
0 siblings, 0 replies; 4+ messages in thread
From: Ani Sinha @ 2022-02-21 11:12 UTC (permalink / raw)
To: Liav Albani; +Cc: imammedo, qemu-devel, mst
On Mon, Feb 21, 2022 at 12:57 AM Liav Albani <liavalb@gmail.com> wrote:
This patch has no description. Please provide a description.
>
> Signed-off-by: Liav Albani <liavalb@gmail.com>
> ---
> hw/isa/isa-bus.c | 17 +++++++++++++++++
> include/hw/isa/isa.h | 1 +
> 2 files changed, 18 insertions(+)
>
> diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
> index 6c31398dda..39d1768797 100644
> --- a/hw/isa/isa-bus.c
> +++ b/hw/isa/isa-bus.c
> @@ -222,6 +222,23 @@ void isa_build_aml(ISABus *bus, Aml *scope)
> }
> }
>
> +bool isa_check_device_existence(const char *typename)
> +{
> + assert(isabus != NULL);
> +
> + BusChild *kid;
> + ISADevice *dev;
> +
> + QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) {
> + dev = ISA_DEVICE(kid->child);
> + const char *object_type = object_get_typename(OBJECT(dev));
> + if (object_type && strcmp(object_type, typename) == 0) {
> + return true;
> + }
> + }
> + return false;
> +}
> +
> static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
> {
> ISADevice *d = ISA_DEVICE(dev);
> diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
> index d4417b34b6..65f0c7e28c 100644
> --- a/include/hw/isa/isa.h
> +++ b/include/hw/isa/isa.h
> @@ -99,6 +99,7 @@ IsaDma *isa_get_dma(ISABus *bus, int nchan);
> MemoryRegion *isa_address_space(ISADevice *dev);
> MemoryRegion *isa_address_space_io(ISADevice *dev);
> ISADevice *isa_new(const char *name);
> +bool isa_check_device_existence(const char *typename);
> ISADevice *isa_try_new(const char *name);
> bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
> ISADevice *isa_create_simple(ISABus *bus, const char *name);
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-21 11:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-20 19:25 [PATCH 0/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
2022-02-20 19:25 ` [PATCH 1/2] hw/isa: add function to check for existence of device by its type Liav Albani
2022-02-21 11:12 ` Ani Sinha
2022-02-20 19:25 ` [PATCH 2/2] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Liav Albani
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.