hw/i386/acpi-build: Explain bits in OSC method
PATCH 1/1 hw/i386/acpi-build: Explain bits in OSC method
Provide a better explanation for the enabled bits in the _OSC control field. Base it on the latest specification due to new bits 5 and 6.
Signed-off-by Julia Suvorova <[email protected]>
--- hw/i386/acpi-build.h | 11 +++++++++++ hw/i386/acpi-build.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +11 -0
@@ -5,6 +5,17 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; +/* PCI Firmware Specification 3.2, Table 4-5 */ +typedef enum { +ACPI_OSC_NATIVE_HP_EN =0 , +ACPI_OSC_SHPC_EN =1 , +ACPI_OSC_PME_EN =2 , +ACPI_OSC_AER_EN =3 , +ACPI_OSC_PCIE_CAP_EN =4 , +ACPI_OSC_LTR_EN =5 , +ACPI_OSC_ALLONES_INVALID =6 , +}AcpiOSCField ; +void acpi_setup (void );#endif
hw/i386/acpi-build.c +6 -1
@@ -1417,6 +1417,7 @@ static Aml *build_q35_osc_method(void)Aml *method;Aml *a_cwd1 =aml_name ("CDW1" );Aml *a_ctrl =aml_local (0 ); +unsigned osc_ctrl; method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));
@@ -1432,7 +1433,11 @@ static Aml *build_q35_osc_method(void)* Always allow native PME, AER (no dependencies) * Allow SHPC (PCI bridges can have SHPC controller) */ -aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1F ), a_ctrl)); + osc_ctrl =BIT (ACPI_OSC_PME_EN ) |BIT (ACPI_OSC_AER_EN ) | +BIT (ACPI_OSC_PCIE_CAP_EN ) |BIT (ACPI_OSC_NATIVE_HP_EN ) | +BIT (ACPI_OSC_SHPC_EN ); + +aml_append (if_ctx,aml_and (a_ctrl,aml_int (osc_ctrl), a_ctrl)); if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 ))));/* Unknown revision */
Signature · 1 line
2.25.4
Quoted 44 lines · Julia Suvorova
Provide a better explanation for the enabled bits in the
_OSCcontrol field. Base it on the latest specification due to new bits 5 and 6.Signed-off-by Julia Suvorova <[email protected]>--- hw/i386/acpi-build.h | 11 +++++++++++ hw/i386/acpi-build.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-)hw/i386/acpi-build.h +11
-0@@ -5,6 +5,17 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; +/* PCI Firmware Specification 3.2, Table 4-5 */ +typedef enum { +ACPI_OSC_NATIVE_HP_EN =0 , +ACPI_OSC_SHPC_EN =1 , +ACPI_OSC_PME_EN =2 , +ACPI_OSC_AER_EN =3 , +ACPI_OSC_PCIE_CAP_EN =4 , +ACPI_OSC_LTR_EN =5 , +ACPI_OSC_ALLONES_INVALID =6 , +}AcpiOSCField ; +void acpi_setup (void );#endif hw/i386/acpi-build.c +1
-0@@ -1417,6 +1417,7 @@ static Aml *build_q35_osc_method(void)Aml *method;Aml *a_cwd1 =aml_name ("CDW1" );Aml *a_ctrl =aml_local (0 ); +unsigned osc_ctrl; method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));
hw/i386/acpi-build.c static Aml *build_q35_osc_method(void) · line 1440
Quoted 9 lines
hw/i386/acpi-build.c +5
-1@@ -1432,7 +1433,11 @@ static Aml *build_q35_osc_method(void)* Always allow native PME, AER (no dependencies) * Allow SHPC (PCI bridges can have SHPC controller) */ -aml_append (if_ctx,aml_and (a_ctrl,aml_int (0x1F ), a_ctrl)); + osc_ctrl =BIT (ACPI_OSC_PME_EN ) |BIT (ACPI_OSC_AER_EN ) | +BIT (ACPI_OSC_PCIE_CAP_EN ) |BIT (ACPI_OSC_NATIVE_HP_EN ) | +BIT (ACPI_OSC_SHPC_EN ); + +aml_append (if_ctx,aml_and (a_ctrl,aml_int (osc_ctrl), a_ctrl));
Now the comment above somewhat duplicates the enums. And decoding what does each value mean is a head scratcher. As long as there's a single use, we prefer comments to an enum, they can match spec exactly:
BIT(0) /* PCI Express Native Hotplug control */ |
BIT(4) /* SHPC Native Hotplug control */ |
etc ...
Quoted 4 lines
hw/i386/acpi-build.c +0
-0if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 ))));/* Unknown revision */ Signature · 1 line
2.25.4