pc: acpi: convert DSDT to AML API and drop ASL templates support
cover pc: acpi: convert DSDT to AML API and drop ASL templates support
Due to huge size, CCing only cover letter instead of individual patches.
Series consist of 2 parts the 1st part prefixed 'acpi:' adds necessary AML API functions and the second part converts DSDT using existing and new AML API.
Series does exact byte by byte conversion and passes ACPI tables 'make check' tests.
The conversion first moves common for PIIX4/Q35 parts, getting rid of *.dsl includes and then converts PIIX4 and Q35 parts of DSDT.
Diff-stat looks nice but actual code base is reduced by ~2000LOC while the rest of 10000 removals is dropping precompiled AML templates from tree.
There are some AML parts that could be optimized/simplified and shared between PIIX4/Q35/ARM but doing it will break exact match with original tests, hence it's left out of the scope of this series.
Igor Mammedov (70):
tests: acpi: print ASL diff in verbose mode
acpi: add aml_lgreater_equal()
acpi: add aml_create_qword_field()
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
acpi: extend aml_add() to accept target argument
acpi: add aml_decrement() and aml_subtract()
acpi: add aml_call0() helper
acpi: add aml_to_integer()
acpi: extend aml_shiftright() to accept target argument
acpi: add aml_alias()
acpi: add aml_sleep()
acpi: add aml_lor()
acpi: add aml_lgreater()
acpi: extend aml_field() to support LockRule
acpi: add aml_to_hexstring()
acpi: add aml_to_buffer()
acpi add aml_dma()
acpi: extend aml_or() to accept target argument
acpi: extend aml_and() to accept target argument
acpi: extend aml_interrupt() to support multiple irqs
pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
pc: acpi: memhp: move MHPD._STA method into SSDT
pc: acpi: memhp: move MHPD.MLCK mutex into SSDT
pc: acpi: memhp: move MHPD.MSCN method into SSDT
pc: acpi: memhp: move MHPD.MRST method into SSDT
pc: acpi: memhp: move MHPD.MPXM method into SSDT
pc: acpi: memhp: move MHPD.MOST method into SSDT
pc: acpi: memhp: move MHPD.MEJ0 method into SSDT
pc: acpi: memhp: move MHPD.MCRS method into SSDT
pc: acpi: memhp: move MHPD Device into SSDT
pc: acpi: factor out memhp code from build_ssdt() into separate
function
pc: acpi: memhp: move \_GPE._E03 into SSDT
pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage
pc: acpi: drop unused CPU_STATUS_LEN from DSDT
pc: acpi: cpuhp: move CPEJ() method to SSDT
pc: acpi: cpuhp: move CPMA() method into SSDT
pc: acpi: cpuhp: move CPST() method into SSDT
pc: acpi: cpuhp: move PRSC() method into SSDT
pc: acpi: cpuhp: move \_GPE._E02() into SSDT
pc: acpi: factor out cpu hotplug code from build_ssdt() into separate
function
pc: acpi: move HPET from DSDT to SSDT
pc: acpi: move DBUG() from DSDT to SSDT
pc: acpi: move RTC device from DSDT to SSDT
pc: acpi: move KBD device from DSDT to SSDT
pc: acpi: move MOU device from DSDT to SSDT
pc: acpi: move FDC0 device from DSDT to SSDT
pc: acpi: move LPT device from DSDT to SSDT
pc: acpi: move COM devices from DSDT to SSDT
pc: acpi: move PIIX4 isa-bridge and pm devices into SSDT
pc: acpi: move remaining GPE handlers into SSDT
pc: acpi: pci: move link devices into SSDT
pc: acpi: piix4: move IQCR() into SSDT
pc: acpi: piix4: move IQST() into SSDT
pc: acpi: piix4: move PCI0._PRT() into SSDT
pc: acpi: piix4: move remaining PCI hotplug bits into SSDT
pc: acpi: piix4: acpi move PCI0 device to SSDT
pc: acpi: q35: move GSI links to SSDT
pc: acpi: q35: move link devices to SSDT
pc: acpi: q35: move IQCR() into SSDT
pc: acpi: q35: move IQST() into SSDT
pc: acpi: q35: move ISA bridge into SSDT
pc: acpi: q35: move _PRT() into SSDT
pc: acpi: q35: move PRTA routing table into SSDT
pc: acpi: q35: move PRTP routing table into SSDT
pc: acpi: q35: move _PIC() method into SSDT
pc: acpi: q35: move PCI0._OSC() method into SSDT
pc: acpi: q35: move PCI0 device definition into SSDT
pc: acpi: q35: PCST, PCSB opregions and PCIB field into SSDT
pc: acpi: switch to AML API composed DSDT
pc: acpi: remove unused ASL templates and related blobs/utils
Xiao Guangrong (4):
acpi: add aml_derefof
acpi: add aml_sizeof
acpi: add aml_mutex(), aml_acquire(), aml_release()
acpi: support serialized method
hw/acpi/Makefile.objs | 4 +- hw/acpi/aml-build.c | 294 +- hw/acpi/cpu_hotplug_acpi_table.c | 124 + hw/acpi/memory_hotplug_acpi_table.c | 249 ++ hw/arm/virt-acpi-build.c | 41 +- hw/i386/Makefile.objs | 31 +- hw/i386/acpi-build.c | 1329 ++++-- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 90 - hw/i386/acpi-dsdt-dbug.dsl | 41 - hw/i386/acpi-dsdt-hpet.dsl | 48 - hw/i386/acpi-dsdt-isa.dsl | 117 - hw/i386/acpi-dsdt-mem-hotplug.dsl | 171 - hw/i386/acpi-dsdt.dsl | 303 -- hw/i386/acpi-dsdt.hex.generated | 2972 -------------- hw/i386/q35-acpi-dsdt.dsl | 436 -- hw/i386/q35-acpi-dsdt.hex.generated | 7610 ----------------------------------- hw/timer/hpet.c | 2 +- include/hw/acpi/aml-build.h | 66 +- include/hw/acpi/cpu_hotplug.h | 10 + include/hw/acpi/memory_hotplug.h | 9 + include/hw/acpi/pc-hotplug.h | 44 +- include/hw/timer/hpet.h | 1 + scripts/acpi_extract.py | 367 -- scripts/acpi_extract_preprocess.py | 51 - scripts/update-acpi.sh | 4 - tests/bios-tables-test.c | 7 + 26 files changed, 1848 insertions(+), 12573 deletions(-) create mode 100644 hw/acpi/cpu_hotplug_acpi_table.c create mode 100644 hw/acpi/memory_hotplug_acpi_table.c delete mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl delete mode 100644 hw/i386/acpi-dsdt-isa.dsl delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl delete mode 100644 hw/i386/acpi-dsdt.dsl delete mode 100644 hw/i386/acpi-dsdt.hex.generated delete mode 100644 hw/i386/q35-acpi-dsdt.dsl delete mode 100644 hw/i386/q35-acpi-dsdt.hex.generated delete mode 100755 scripts/acpi_extract.py delete mode 100755 scripts/acpi_extract_preprocess.py delete mode 100644 scripts/update-acpi.sh
Signature · 1 line
1.8.3.1
PATCH 1/74 tests: acpi: print ASL diff in verbose mode
--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/bios-tables-test.c +7 -0
@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) { + int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file); + ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 14 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)tests/bios-tables-test.c +0
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file);
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 592
Quoted 10 lines
tests/bios-tables-test.c +7
-0+if (getenv ("V" )) { + int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file); + ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
In reply to Igor MammedovQuoted 10 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)tests/bios-tables-test.c +0
-0
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 4 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {
How do you test? make check V=1?
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 3 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);
This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.
Quoted 9 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 check
Quoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.
usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
Quoted 11 lines
Quoted 11 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 31 lines · Igor Mammedov
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 checkQuoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.
Quoted 8 lines
usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
Well for one, I want make check to pass before I commit a new expected, not afterwards. Add another variable to specify which diff to use, install colordiff and use that.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 36 lines · On Tue, 22 Dec 2015 18:18:53 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 35 lines · Igor Mammedov
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 checkQuoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
Quoted 7 lines
Quoted 4 lines
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
Well for one, I want make check to pass before
I commit a new expected, not afterwards.
'make check' and even 'make V=1 check' passes fine the point of this patch is to show user difference if there is any and one doesn't need to commit new expected if there aren't any changes (i.e. make check passes without diff/warning)
Quoted 2 lines
Add another variable to specify which diff to use, install colordiff and use that.
adding variable could work however it reduces usability as user will have to be aware of it and has to set it, I'll probably forget it and will have to dig it out every time it's needed.
maybe if V=1 try
1. 'git diff' first if not
2. fallback to 'diff' if not
3. print warning to install git or diff
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
In reply to Igor MammedovQuoted 31 lines · Igor Mammedov
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 checkQuoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.
Quoted 8 lines
usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
I just do vimdiff on the two files it prints.
Not sure all this is worth it.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 36 lines · On Tue, 22 Dec 2015 18:59:30 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 35 lines · Igor Mammedov
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 checkQuoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
Quoted 7 lines
Quoted 4 lines
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
I just do vimdiff on the two files it prints.
Not sure all this is worth it.
yep, it's something that I was doing manually as well, but after 50th or so times it was taking too much time, hence a patch that saves my and hopefully others time.
Alternative solution if V=1:
1. use variable to specify diff command
2. if variable is not defined, print warning to set it
that way user will be informed about diff option when 'make V=1 check' is run and diff is not specified.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode
Quoted 53 lines · Igor Mammedov
Quoted 36 lines · On Tue, 22 Dec 2015 18:59:30 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 35 lines · Igor Mammedov
Quoted 6 lines · On Tue, 22 Dec 2015 17:28:42 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 11 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 583
Quoted 9 lines
tests/bios-tables-test.c +1
-0@@ -580,6 +580,13 @@ static void test_acpi_asl(test_data *data) (gchar *)&signature, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file); +if (getenv ("V" )) {How do you test? make check V=1?
yep
make V=1 checkQuoted 8 lines
tests/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 586
Quoted 4 lines
tests/bios-tables-test.c +3
-0+ int ret G_GNUC_UNUSED; +char *diff =g_strdup_printf ("git diff --exit-code %s %s" , + exp_sdt->asl_file, sdt->asl_file);This assumes running under git which is generally wrong e.g. people build from tarballs.
git is also not a build dependency.usually only developers use V=1 as they care about verbose output and they probably use/have git so it doesn't have to builddep, if they don't they won't get any useful output here.
Quoted 7 lines
Quoted 4 lines
my choice of 'git diff' was dictated by the fact that it produces nice colored diff of ASL while usual diff doesn't. And that helps a lot (to me) as that diff is intended for human consumption.
I just do vimdiff on the two files it prints.
Not sure all this is worth it.yep, it's something that I was doing manually as well, but after 50th or so times it was taking too much time, hence a patch that saves my and hopefully others time. Alternative solution if V=1:
1. use variable to specify diff command
2. if variable is not defined, print warning to set it
Quoted 2 lines
that way user will be informed about diff option when 'make V=1 check' is run and diff is not specified.
OK.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
tests/bios-tables-test.c +3
-0+ ret =system (diff) ; +g_free (diff); + } } }g_string_free (asl, true);Signature · 1 line
1.8.3.1
PATCH 2/74 acpi: add aml_derefof
In reply to Igor MammedovFrom: Xiao Guangrong <[email protected]>
Implement DeRefOf term which is used by NVDIMM _DSM method in later patch
--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)
hw/acpi/aml-build.c +8 -0
@@ -1135,6 +1135,14 @@ Aml *aml_unicode(const char *str)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefDerefOf */ +Aml *aml_derefof (Aml *arg) +{ +Aml *var =aml_opcode (0x83 /* DerefOfOp */ ); +aml_append (var, arg); +return var; +} +void build_header (GArray *linker,GArray *table_data,AcpiTableHeader *h,const char *sig,int len,uint8_t rev)
include/hw/acpi/aml-build.h +1 -0
@@ -274,6 +274,7 @@ Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);Aml *aml_varpackage (uint32_t num_elements);Aml *aml_touuid (const char *uuid);Aml *aml_unicode (const char *str); +Aml *aml_derefof (Aml *arg); void build_header(GArray *linker, GArray *table_data,
Signature · 1 line
1.8.3.1
PATCH 3/74 acpi: add aml_sizeof
In reply to Igor MammedovFrom: Xiao Guangrong <[email protected]>
Implement SizeOf term which is used by NVDIMM _DSM method in later patch
--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)
hw/acpi/aml-build.c +8 -0
@@ -1143,6 +1143,14 @@ Aml *aml_derefof(Aml *arg)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefSizeOf */ +Aml *aml_sizeof (Aml *arg) +{ +Aml *var =aml_opcode (0x87 /* SizeOfOp */ ); +aml_append (var, arg); +return var; +} +void build_header (GArray *linker,GArray *table_data,AcpiTableHeader *h,const char *sig,int len,uint8_t rev)
include/hw/acpi/aml-build.h +1 -0
@@ -275,6 +275,7 @@ Aml *aml_varpackage(uint32_t num_elements);Aml *aml_touuid (const char *uuid);Aml *aml_unicode (const char *str);Aml *aml_derefof (Aml *arg); +Aml *aml_sizeof (Aml *arg); void build_header(GArray *linker, GArray *table_data,
Signature · 1 line
1.8.3.1
PATCH 4/74 acpi: add aml_lgreater_equal()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 11 +++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 12 insertions(+)
hw/acpi/aml-build.c +11 -0
@@ -672,6 +672,17 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */ +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2) +{ +/* LGreaterEqualOp := LNotOp LLessOp */ +Aml *var =aml_opcode (0x92 /* LNotOp */ ); +build_append_byte (var->buf,0x95 /* LLessOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ Aml *aml_if (Aml *predicate) {
include/hw/acpi/aml-build.h +1 -0
@@ -229,6 +229,7 @@ Aml *aml_local(int num);Aml *aml_string (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_lnot (Aml *arg);Aml *aml_equal (Aml *arg1,Aml *arg2); +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2);Aml *aml_processor (uint8_t proc_id,uint32_t pblk_addr,uint8_t pblk_len,const char *name_format, ...)GCC_FMT_ATTR (4 ,5 );Aml *aml_eisaid (const char *str);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 04/74] acpi: add aml_lgreater_equal()
Quoted 34 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 11 +++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 12 insertions(+)hw/acpi/aml-build.c +11
-0@@ -672,6 +672,17 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */ +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2) +{ +/* LGreaterEqualOp := LNotOp LLessOp */ +Aml *var =aml_opcode (0x92 /* LNotOp */ ); +build_append_byte (var->buf,0x95 /* LLessOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ Aml *aml_if (Aml *predicate) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_local(int num); · line 235
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -229,6 +229,7 @@ Aml *aml_local(int num);Aml *aml_string (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_lnot (Aml *arg);Aml *aml_equal (Aml *arg1,Aml *arg2); +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2);Aml *aml_processor (uint8_t proc_id,uint32_t pblk_addr,uint8_t pblk_len,const char *name_format, ...)GCC_FMT_ATTR (4 ,5 );Aml *aml_eisaid (const char *str);
Re: [Qemu-devel] [PATCH 04/74] acpi: add aml_lgreater_equal()
In reply to Igor MammedovQuoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
Quoted 40 lines
--- hw/acpi/aml-build.c | 11 +++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 12 insertions(+)hw/acpi/aml-build.c +11
-0@@ -672,6 +672,17 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */ +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2) +{ +/* LGreaterEqualOp := LNotOp LLessOp */ +Aml *var =aml_opcode (0x92 /* LNotOp */ ); +build_append_byte (var->buf,0x95 /* LLessOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ Aml *aml_if (Aml *predicate) {include/hw/acpi/aml-build.h +1
-0@@ -229,6 +229,7 @@ Aml *aml_local(int num);Aml *aml_string (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_lnot (Aml *arg);Aml *aml_equal (Aml *arg1,Aml *arg2); +Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2);Aml *aml_processor (uint8_t proc_id,uint32_t pblk_addr,uint8_t pblk_len,const char *name_format, ...)GCC_FMT_ATTR (4 ,5 );Aml *aml_eisaid (const char *str);
Signature · 1 line
Shannon
PATCH 5/74 acpi: add aml_mutex(), aml_acquire(), aml_release()
In reply to Igor MammedovFrom: Xiao Guangrong <[email protected]>
--- hw/acpi/aml-build.c | 33 +++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 3 +++ 2 files changed, 36 insertions(+)
hw/acpi/aml-build.c +33 -0
@@ -1162,6 +1162,39 @@ Aml *aml_sizeof(Aml *arg)return var; } +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMutex */ +Aml *aml_mutex (const char *name,uint8_t sync_level) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x01 );/* MutexOp */ +build_append_namestring (var->buf,"%s" , name); +assert (!(sync_level &0xF0 )); +build_append_byte (var->buf, sync_level); +return var; +} + +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAcquire */ +Aml *aml_acquire (Aml *mutex,uint16_t timeout) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x23 );/* AcquireOp */ +aml_append (var, mutex); +build_append_int_noprefix (var->buf, timeout,sizeof (timeout)); +return var; +} + +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefRelease */ +Aml *aml_release (Aml *mutex) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x27 );/* ReleaseOp */ +aml_append (var, mutex); +return var; +} +void build_header (GArray *linker,GArray *table_data,AcpiTableHeader *h,const char *sig,int len,uint8_t rev)
include/hw/acpi/aml-build.h +3 -0
@@ -271,6 +271,9 @@ Aml *aml_package(uint8_t num_elements);Aml *aml_buffer (int buffer_size,uint8_t *byte_list);Aml *aml_resource_template (void );Aml *aml_field (const char *name,AmlAccessType type,AmlUpdateRule rule); +Aml *aml_mutex (const char *name,uint8_t sync_level); +Aml *aml_acquire (Aml *mutex,uint16_t timeout); +Aml *aml_release (Aml *mutex);Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_varpackage (uint32_t num_elements);Aml *aml_touuid (const char *uuid);
Signature · 1 line
1.8.3.1
PATCH 6/74 acpi: add aml_create_qword_field()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 21 +++++++++++++++++---- include/hw/acpi/aml-build.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
hw/acpi/aml-build.c +17 -4
@@ -805,17 +805,30 @@ Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule)return var; } -/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */ -Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name) +static +Aml *create_field_common (int opcode,Aml *srcbuf,Aml *index,const char *name) { -Aml *var =aml_alloc (); -build_append_byte (var->buf,0x8A );/* CreateDWordFieldOp */ +Aml *var =aml_opcode (opcode);aml_append (var, srcbuf);aml_append (var, index);build_append_namestring (var->buf,"%s" , name);return var; } +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */ +Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name) +{ +return create_field_common (0x8A /* CreateDWordFieldOp */ , + srcbuf, index, name); +} + +/* ACPI 2.0a: 17.2.4.2 Named Objects Encoding: DefCreateQWordField */ +Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name) +{ +return create_field_common (0x8F /* CreateQWordFieldOp */ , + srcbuf, index, name); +} +/* ACPI 1.0b: 16.2.3 Data Objects Encoding: String */ Aml *aml_string (const char *name_format, ...) {
include/hw/acpi/aml-build.h +1 -0
@@ -275,6 +275,7 @@ Aml *aml_mutex(const char *name, uint8_t sync_level);Aml *aml_acquire (Aml *mutex,uint16_t timeout);Aml *aml_release (Aml *mutex);Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name); +Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_varpackage (uint32_t num_elements);Aml *aml_touuid (const char *uuid);Aml *aml_unicode (const char *str);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/74] acpi: add aml_create_qword_field()
Quoted 51 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 21 +++++++++++++++++---- include/hw/acpi/aml-build.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)hw/acpi/aml-build.c +17
-4@@ -805,17 +805,30 @@ Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule)return var; } -/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */ -Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name) +static +Aml *create_field_common (int opcode,Aml *srcbuf,Aml *index,const char *name) { -Aml *var =aml_alloc (); -build_append_byte (var->buf,0x8A );/* CreateDWordFieldOp */ +Aml *var =aml_opcode (opcode);aml_append (var, srcbuf);aml_append (var, index);build_append_namestring (var->buf,"%s" , name);return var; } +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */ +Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name) +{ +return create_field_common (0x8A /* CreateDWordFieldOp */ , + srcbuf, index, name); +} + +/* ACPI 2.0a: 17.2.4.2 Named Objects Encoding: DefCreateQWordField */ +Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name) +{ +return create_field_common (0x8F /* CreateQWordFieldOp */ , + srcbuf, index, name); +} +/* ACPI 1.0b: 16.2.3 Data Objects Encoding: String */ Aml *aml_string (const char *name_format, ...) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_mutex(const char *name, uint8_t sync_level); · line 281
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -275,6 +275,7 @@ Aml *aml_mutex(const char *name, uint8_t sync_level);Aml *aml_acquire (Aml *mutex,uint16_t timeout);Aml *aml_release (Aml *mutex);Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name); +Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_varpackage (uint32_t num_elements);Aml *aml_touuid (const char *uuid);Aml *aml_unicode (const char *str);
PATCH 7/74 acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
In reply to Igor MammedovCurrently AML API doesn't compose terms in form of following pattern:
Opcode Arg2 Arg2 [Dst]
but ASL used in piix4/q35 DSDT ACPI tables uses that form, so for clean conversion of it, AML API should be able to handle an optional 'Dst' argumet used there.
Since above pattern is used by arithmetic/bit ops, introduce helper that they could reuse.
It reduces code duplication in existing 5 aml_foo() functions and also will prevent more duplication when exiting functions are extended to support optional 'Dst' argument.
--- hw/acpi/aml-build.c | 61 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-)
hw/acpi/aml-build.c +32 -29
@@ -436,44 +436,55 @@ Aml *aml_store(Aml *val, Aml *target)return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +/** +* build_opcode_2arg_dst: +* @op: 1-byte opcode +* @arg1: 1st operand +* @arg2: 2nd operand +* @dst: optional target to store to, set to NULL if it's not required +* +* An internal helper to compose AML terms that have +* "Op Operand Operand Target" +* pattern. +* +* Returns: The newly allocated and composed according to patter Aml object. +*/ +static Aml * +build_opcode_2arg_dst (uint8_t op,Aml *arg1,Aml *arg2,Aml *dst) { -Aml *var =aml_opcode (0x7B /* AndOp */ ); +Aml *var =aml_opcode (op);aml_append (var, arg1);aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + }return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ +Aml *aml_and (Aml *arg1,Aml *arg2) +{ +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2,NULL ); +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ Aml *aml_or (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x7D /* OrOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftLeft */ Aml *aml_shiftleft (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x79 /* ShiftLeftOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x79 /* ShiftLeftOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftRight */ Aml *aml_shiftright (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x7A /* ShiftRightOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLLess */
@@ -488,11 +499,7 @@ Aml *aml_lless(Aml *arg1, Aml *arg2)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAdd */ Aml *aml_add (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x72 /* AddOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */
@@ -506,11 +513,7 @@ Aml *aml_increment(Aml *arg)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */ Aml *aml_index (Aml *arg1,Aml *idx) { -Aml *var =aml_opcode (0x88 /* IndexOp */ ); -aml_append (var, arg1); -aml_append (var, idx); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x88 /* IndexOp */ , arg1, idx,NULL ); }/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefNotify */
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 07/74] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
Quoted 50 lines · Igor Mammedov
Currently AML API doesn't compose terms in form of following pattern:
Opcode Arg2 Arg2 [Dst]
but ASL used in piix4/q35 DSDT ACPI tables uses that form, so for clean conversion of it, AML API should be able to handle an optional 'Dst' argumet used there.
Since above pattern is used by arithmetic/bit ops, introduce helper that they could reuse.
It reduces code duplication in existing 5aml_foo()functions and also will prevent more duplication when exiting functions are extended to support optional 'Dst' argument.Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 61 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-)hw/acpi/aml-build.c +16
-3@@ -436,44 +436,55 @@ Aml *aml_store(Aml *val, Aml *target)return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +/** +* build_opcode_2arg_dst: +* @op: 1-byte opcode +* @arg1: 1st operand +* @arg2: 2nd operand +* @dst: optional target to store to, set to NULL if it's not required +* +* An internal helper to compose AML terms that have +* "Op Operand Operand Target" +* pattern. +* +* Returns: The newly allocated and composed according to patter Aml object. +*/ +static Aml * +build_opcode_2arg_dst (uint8_t op,Aml *arg1,Aml *arg2,Aml *dst) { -Aml *var =aml_opcode (0x7B /* AndOp */ ); +Aml *var =aml_opcode (op);aml_append (var, arg1);
hw/acpi/aml-build.c Aml *aml_store(Aml *val, Aml *target) · line 465
Quoted 10 lines
hw/acpi/aml-build.c +5
-1aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + }return var; }
This looks good. Maybe you could add a helper like build_opcode_2arg(), then aml_lor() and aml_lgreater() could use this.
Signature · 1 line
Shannon
Re: [Qemu-devel] [PATCH 07/74] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
Quoted 60 lines · On Thu, 10 Dec 2015 09:59:16 +0800 Shannon Zhao <[email protected]>…
Quoted 57 lines · Igor Mammedov
Currently AML API doesn't compose terms in form of following pattern:
Opcode Arg2 Arg2 [Dst]
but ASL used in piix4/q35 DSDT ACPI tables uses that form, so for clean conversion of it, AML API should be able to handle an optional 'Dst' argumet used there.
Since above pattern is used by arithmetic/bit ops, introduce helper that they could reuse.
It reduces code duplication in existing 5aml_foo()functions and also will prevent more duplication when exiting functions are extended to support optional 'Dst' argument.Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 61++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-)
hw/acpi/aml-build.c +6
-2@@ -436,44 +436,55 @@ Aml *aml_store(Aml *val, Aml *target)return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +/** +* build_opcode_2arg_dst: +* @op: 1-byte opcode +* @arg1: 1st operand +* @arg2: 2nd operand +* @dst: optional target to store to, set to NULL if it's not required
+ *
+ * An internal helper to compose AML terms that have
+ * "Op Operand Operand Target"
+ * pattern.
+ *
+ * Returns: The newly allocated and composed according to patter Aml object.
+ */hw/acpi/aml-build.c +5
-2+static Aml * +build_opcode_2arg_dst (uint8_t op,Aml *arg1,Aml *arg2,Aml *dst) { -Aml *var =aml_opcode (0x7B /* AndOp */ ); +Aml *var =aml_opcode (op);aml_append (var, arg1);aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); +if (dst) { +aml_append (var, dst);
Quoted 8 lines
hw/acpi/aml-build.c Aml *aml_store(Aml *val, Aml *target) · line 464
Quoted 6 lines
hw/acpi/aml-build.c +3
-0+ }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + }return var; }This looks good. Maybe you could add a helper like
build_opcode_2arg(), thenaml_lor()andaml_lgreater()could use this.
If it reduces number code size, it could be made on top of this series.
If AML API patches ('acpi:' prefixed) would have 'Reviewed-by:' we could merge them first, before the PC:DSTD conversion patches are reviewed so that AML API could be improved/extendend further without conflicts.
That would also make series smaller on respin.
Re: [Qemu-devel] [PATCH 07/74] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
In reply to Igor MammedovQuoted 117 lines · Igor Mammedov
Currently AML API doesn't compose terms in form of following pattern:
Opcode Arg2 Arg2 [Dst]
but ASL used in piix4/q35 DSDT ACPI tables uses that form, so for clean conversion of it, AML API should be able to handle an optional 'Dst' argumet used there.
Since above pattern is used by arithmetic/bit ops, introduce helper that they could reuse.
It reduces code duplication in existing 5aml_foo()functions and also will prevent more duplication when exiting functions are extended to support optional 'Dst' argument.Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 61 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-)hw/acpi/aml-build.c +31
-24@@ -436,44 +436,55 @@ Aml *aml_store(Aml *val, Aml *target)return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +/** +* build_opcode_2arg_dst: +* @op: 1-byte opcode +* @arg1: 1st operand +* @arg2: 2nd operand +* @dst: optional target to store to, set to NULL if it's not required +* +* An internal helper to compose AML terms that have +* "Op Operand Operand Target" +* pattern. +* +* Returns: The newly allocated and composed according to patter Aml object. +*/ +static Aml * +build_opcode_2arg_dst (uint8_t op,Aml *arg1,Aml *arg2,Aml *dst) { -Aml *var =aml_opcode (0x7B /* AndOp */ ); +Aml *var =aml_opcode (op);aml_append (var, arg1);aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + }return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ +Aml *aml_and (Aml *arg1,Aml *arg2) +{ +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2,NULL ); +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ Aml *aml_or (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x7D /* OrOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftLeft */ Aml *aml_shiftleft (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x79 /* ShiftLeftOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x79 /* ShiftLeftOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftRight */ Aml *aml_shiftright (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x7A /* ShiftRightOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLLess */ @@ -488,11 +499,7 @@ Aml *aml_lless(Aml *arg1, Aml *arg2)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAdd */ Aml *aml_add (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x72 /* AddOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */ @@ -506,11 +513,7 @@ Aml *aml_increment(Aml *arg)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */ Aml *aml_index (Aml *arg1,Aml *idx)
hw/acpi/aml-build.c Aml *aml_increment(Aml *arg) · line 519
Quoted 10 lines
hw/acpi/aml-build.c +1
-5{ -Aml *var =aml_opcode (0x88 /* IndexOp */ ); -aml_append (var, arg1); -aml_append (var, idx); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x88 /* IndexOp */ , arg1, idx,NULL ); }/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefNotify */
Re: [Qemu-devel] [PATCH 07/74] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
In reply to Igor MammedovQuoted 9 lines · Igor Mammedov
Currently AML API doesn't compose terms in form of following pattern:
Opcode Arg2 Arg2 [Dst]
but ASL used in piix4/q35 DSDT ACPI tables uses that form, so for clean conversion of it, AML API should be able to handle an optional 'Dst' argumet used there.
Quoted 8 lines
Since above pattern is used by arithmetic/bit ops, introduce helper that they could reuse.
It reduces code duplication in existing 5aml_foo()functions and also will prevent more duplication when exiting functions are extended to support optional 'Dst' argument.Signed-off-by Igor Mammedov <[email protected]>
Quoted 110 lines
--- hw/acpi/aml-build.c | 61 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-)hw/acpi/aml-build.c +32
-29@@ -436,44 +436,55 @@ Aml *aml_store(Aml *val, Aml *target)return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +/** +* build_opcode_2arg_dst: +* @op: 1-byte opcode +* @arg1: 1st operand +* @arg2: 2nd operand +* @dst: optional target to store to, set to NULL if it's not required +* +* An internal helper to compose AML terms that have +* "Op Operand Operand Target" +* pattern. +* +* Returns: The newly allocated and composed according to patter Aml object. +*/ +static Aml * +build_opcode_2arg_dst (uint8_t op,Aml *arg1,Aml *arg2,Aml *dst) { -Aml *var =aml_opcode (0x7B /* AndOp */ ); +Aml *var =aml_opcode (op);aml_append (var, arg1);aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + }return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ +Aml *aml_and (Aml *arg1,Aml *arg2) +{ +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2,NULL ); +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ Aml *aml_or (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x7D /* OrOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftLeft */ Aml *aml_shiftleft (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x79 /* ShiftLeftOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x79 /* ShiftLeftOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftRight */ Aml *aml_shiftright (Aml *arg1,Aml *count) { -Aml *var =aml_opcode (0x7A /* ShiftRightOp */ ); -aml_append (var, arg1); -aml_append (var, count); -build_append_byte (var->buf,0x00 );/* NullNameOp */ -return var; +return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLLess */ @@ -488,11 +499,7 @@ Aml *aml_lless(Aml *arg1, Aml *arg2)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAdd */ Aml *aml_add (Aml *arg1,Aml *arg2) { -Aml *var =aml_opcode (0x72 /* AddOp */ ); -aml_append (var, arg1); -aml_append (var, arg2); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2,NULL ); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */ @@ -506,11 +513,7 @@ Aml *aml_increment(Aml *arg)/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */ Aml *aml_index (Aml *arg1,Aml *idx) { -Aml *var =aml_opcode (0x88 /* IndexOp */ ); -aml_append (var, arg1); -aml_append (var, idx); -build_append_byte (var->buf,0x00 /* NullNameOp */ ); -return var; +return build_opcode_2arg_dst (0x88 /* IndexOp */ , arg1, idx,NULL ); }/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefNotify */
Signature · 1 line
Shannon
PATCH 8/74 acpi: extend aml_add() to accept target argument
In reply to Igor Mammedovit allows to express following ASL expression:
Add(arg1, arg2, result)
usecases that do not need to store result
should pass NULL as 3rd arg that would express
Add(arg1, arg2,)
construct.
--- hw/acpi/aml-build.c | 4 ++-- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/aml-build.c +2 -2
@@ -497,9 +497,9 @@ Aml *aml_lless(Aml *arg1, Aml *arg2) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAdd */ -Aml *aml_add (Aml *arg1,Aml *arg2) +Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */
hw/i386/acpi-build.c +1 -1
@@ -669,7 +669,7 @@ static Aml *build_prt(void) aml_store(aml_shiftright(pin, aml_int(2)), slot));/* lnk_idx = (slot + pin) & 3 */ aml_append (while_ctx, -aml_store (aml_and (aml_add (pin, slot),aml_int (3 )), lnk_idx)); +aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 )), lnk_idx));/* route[2] = "LNK[D|A|B|C]", selection based on pin % 3 */ aml_append (while_ctx,initialize_route (route,"LNKD" , lnk_idx,0 ));
include/hw/acpi/aml-build.h +1 -1
@@ -204,7 +204,7 @@ Aml *aml_or(Aml *arg1, Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count);Aml *aml_lless (Aml *arg1,Aml *arg2); -Aml *aml_add (Aml *arg1,Aml *arg2); +Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_increment (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 08/74] acpi: extend aml_add() to accept target argument
Quoted 50 lines · Igor Mammedov
it allows to express following ASL expression:
Add(arg1, arg2, result)usecases that do not need to store result
should pass NULL as 3rd arg that would express
Add(arg1, arg2,)
construct.Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 4 ++-- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)hw/acpi/aml-build.c +2
-2@@ -497,9 +497,9 @@ Aml *aml_lless(Aml *arg1, Aml *arg2) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAdd */ -Aml *aml_add (Aml *arg1,Aml *arg2) +Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */ hw/i386/acpi-build.c +1
-1@@ -669,7 +669,7 @@ static Aml *build_prt(void) aml_store(aml_shiftright(pin, aml_int(2)), slot));/* lnk_idx = (slot + pin) & 3 */ aml_append (while_ctx, -aml_store (aml_and (aml_add (pin, slot),aml_int (3 )), lnk_idx)); +aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 )), lnk_idx));/* route[2] = "LNK[D|A|B|C]", selection based on pin % 3 */ aml_append (while_ctx,initialize_route (route,"LNKD" , lnk_idx,0 ));include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_or(Aml *arg1, Aml *arg2); · line 210
Quoted 8 lines
include/hw/acpi/aml-build.h +1
-1@@ -204,7 +204,7 @@ Aml *aml_or(Aml *arg1, Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count);Aml *aml_lless (Aml *arg1,Aml *arg2); -Aml *aml_add (Aml *arg1,Aml *arg2); +Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_increment (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2);
PATCH 9/74 acpi: add aml_decrement() and aml_subtract()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 14 ++++++++++++++ include/hw/acpi/aml-build.h | 2 ++ 2 files changed, 16 insertions(+)
hw/acpi/aml-build.c +14 -0
@@ -502,6 +502,12 @@ Aml *aml_add(Aml *arg1, Aml *arg2, Aml *dst)return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2, dst); } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefSubtract */ +Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst) +{ +return build_opcode_2arg_dst (0x74 /* SubtractOp */ , arg1, arg2, dst); +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */ Aml *aml_increment (Aml *arg) {
@@ -510,6 +516,14 @@ Aml *aml_increment(Aml *arg)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefDecrement */ +Aml *aml_decrement (Aml *arg) +{ +Aml *var =aml_opcode (0x76 /* DecrementOp */ ); +aml_append (var, arg); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */ Aml *aml_index (Aml *arg1,Aml *idx) {
include/hw/acpi/aml-build.h +2 -0
@@ -205,7 +205,9 @@ Aml *aml_shiftleft(Aml *arg1, Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count);Aml *aml_lless (Aml *arg1,Aml *arg2);Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst); +Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_increment (Aml *arg); +Aml *aml_decrement (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2);Aml *aml_call1 (const char *method,Aml *arg1);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 09/74] acpi: add aml_decrement() and aml_subtract()
Quoted 44 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 14 ++++++++++++++ include/hw/acpi/aml-build.h | 2 ++ 2 files changed, 16 insertions(+)hw/acpi/aml-build.c +14
-0@@ -502,6 +502,12 @@ Aml *aml_add(Aml *arg1, Aml *arg2, Aml *dst)return build_opcode_2arg_dst (0x72 /* AddOp */ , arg1, arg2, dst); } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefSubtract */ +Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst) +{ +return build_opcode_2arg_dst (0x74 /* SubtractOp */ , arg1, arg2, dst); +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */ Aml *aml_increment (Aml *arg) {@@ -510,6 +516,14 @@ Aml *aml_increment(Aml *arg)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefDecrement */ +Aml *aml_decrement (Aml *arg) +{ +Aml *var =aml_opcode (0x76 /* DecrementOp */ ); +aml_append (var, arg); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */ Aml *aml_index (Aml *arg1,Aml *idx) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_shiftleft(Aml *arg1, Aml *count); · line 213
Quoted 9 lines
include/hw/acpi/aml-build.h +2
-0@@ -205,7 +205,9 @@ Aml *aml_shiftleft(Aml *arg1, Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count);Aml *aml_lless (Aml *arg1,Aml *arg2);Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst); +Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_increment (Aml *arg); +Aml *aml_decrement (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2);Aml *aml_call1 (const char *method,Aml *arg1);
PATCH 10/74 acpi: add aml_call0() helper
In reply to Igor Mammedovit will help to call a method with 0 arguments
--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)
hw/acpi/aml-build.c +8 -0
@@ -540,6 +540,14 @@ Aml *aml_notify(Aml *arg1, Aml *arg2) }/* helper to call method with 1 argument */ +Aml *aml_call0 (const char *method) +{ +Aml *var =aml_alloc (); +build_append_namestring (var->buf,"%s" , method); +return var; +} + +/* helper to call method with 1 argument */ Aml *aml_call1 (const char *method,Aml *arg1) {Aml *var =aml_alloc ();
include/hw/acpi/aml-build.h +1 -0
@@ -210,6 +210,7 @@ Aml *aml_increment(Aml *arg);Aml *aml_decrement (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2); +Aml *aml_call0 (const char *method);Aml *aml_call1 (const char *method,Aml *arg1);Aml *aml_call2 (const char *method,Aml *arg1,Aml *arg2);Aml *aml_call3 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 10/74] acpi: add aml_call0() helper
Quoted 33 lines · Igor Mammedov
it will help to call a method with 0 arguments
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)hw/acpi/aml-build.c +8
-0@@ -540,6 +540,14 @@ Aml *aml_notify(Aml *arg1, Aml *arg2) }/* helper to call method with 1 argument */ +Aml *aml_call0 (const char *method) +{ +Aml *var =aml_alloc (); +build_append_namestring (var->buf,"%s" , method); +return var; +} + +/* helper to call method with 1 argument */ Aml *aml_call1 (const char *method,Aml *arg1) {Aml *var =aml_alloc ();include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_increment(Aml *arg); · line 216
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -210,6 +210,7 @@ Aml *aml_increment(Aml *arg);Aml *aml_decrement (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2); +Aml *aml_call0 (const char *method);Aml *aml_call1 (const char *method,Aml *arg1);Aml *aml_call2 (const char *method,Aml *arg1,Aml *arg2);Aml *aml_call3 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3);
Maybe aml_call instead of aml_call0 that implies some 'zero' initialization? It doesn't really matter.
Re: [Qemu-devel] [PATCH 10/74] acpi: add aml_call0() helper
Quoted 37 lines · On Thu, 10 Dec 2015 15:04:43 +0200 Marcel Apfelbaum…
Quoted 36 lines · Igor Mammedov
it will help to call a method with 0 arguments
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)hw/acpi/aml-build.c +8
-0@@ -540,6 +540,14 @@ Aml *aml_notify(Aml *arg1, Aml *arg2) }/* helper to call method with 1 argument */ +Aml *aml_call0 (const char *method) +{ +Aml *var =aml_alloc (); +build_append_namestring (var->buf,"%s" , method); +return var; +} + +/* helper to call method with 1 argument */ Aml *aml_call1 (const char *method,Aml *arg1) {Aml *var =aml_alloc ();(quoted diff) +0
-0
b/include/hw/acpi/aml-build.hindex 9761438..117ef46 100644include/hw/acpi/aml-build.h +1
-0@@ -210,6 +210,7 @@ Aml *aml_increment(Aml *arg);Aml *aml_decrement (Aml *arg);Aml *aml_index (Aml *arg1,Aml *idx);Aml *aml_notify (Aml *arg1,Aml *arg2); +Aml *aml_call0 (const char *method);
Quoted 8 lines
Quoted 5 lines
include/hw/acpi/aml-build.h +0
-0Aml *aml_call1 (const char *method,Aml *arg1);Aml *aml_call2 (const char *method,Aml *arg1,Aml *arg2); Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml*arg3);
Maybe
aml_callinstead ofaml_call0that implies some 'zero' initialization? It doesn't really matter.
it's named so for consistency with other aml_callX() helpers.
Quoted 3 lines
Reviewed-by Marcel Apfelbaum <[email protected]>
PATCH 11/74 acpi: add aml_to_integer()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/aml-build.c +9 -0
@@ -427,6 +427,15 @@ Aml *aml_arg(int pos)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToInteger */ +Aml *aml_to_integer (Aml *arg) +{ +Aml *var =aml_opcode (0x99 /* ToIntegerOp */ ); +aml_append (var, arg); +build_append_byte (var->buf,0x00 /* NullNameOp */ ); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {
include/hw/acpi/aml-build.h +1 -0
@@ -198,6 +198,7 @@ Aml *aml_name_decl(const char *name, Aml *val);Aml *aml_return (Aml *val);Aml *aml_int (const uint64_t val);Aml *aml_arg (int pos); +Aml *aml_to_integer (Aml *arg);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 11/74] acpi: add aml_to_integer()
Quoted 32 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)hw/acpi/aml-build.c +9
-0@@ -427,6 +427,15 @@ Aml *aml_arg(int pos)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToInteger */ +Aml *aml_to_integer (Aml *arg) +{ +Aml *var =aml_opcode (0x99 /* ToIntegerOp */ ); +aml_append (var, arg); +build_append_byte (var->buf,0x00 /* NullNameOp */ ); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_name_decl(const char *name, Aml *val); · line 204
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -198,6 +198,7 @@ Aml *aml_name_decl(const char *name, Aml *val);Aml *aml_return (Aml *val);Aml *aml_int (const uint64_t val);Aml *aml_arg (int pos); +Aml *aml_to_integer (Aml *arg);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
PATCH 12/74 acpi: extend aml_shiftright() to accept target argument
In reply to Igor Mammedovit allows to express ShiftRight(A,B,C) syntax
--- hw/acpi/aml-build.c | 4 ++-- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/aml-build.c +2 -2
@@ -491,9 +491,9 @@ Aml *aml_shiftleft(Aml *arg1, Aml *count) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftRight */ -Aml *aml_shiftright (Aml *arg1,Aml *count) +Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst) { -return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count,NULL ); +return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLLess */
hw/i386/acpi-build.c +1 -1
@@ -666,7 +666,7 @@ static Aml *build_prt(void)/* slot = pin >> 2 */ aml_append (while_ctx, -aml_store (aml_shiftright (pin,aml_int (2 )), slot)); +aml_store (aml_shiftright (pin,aml_int (2 ),NULL ), slot));/* lnk_idx = (slot + pin) & 3 */ aml_append (while_ctx,aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 )), lnk_idx));
include/hw/acpi/aml-build.h +1 -1
@@ -203,7 +203,7 @@ Aml *aml_store(Aml *val, Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count); -Aml *aml_shiftright (Aml *arg1,Aml *count); +Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);Aml *aml_lless (Aml *arg1,Aml *arg2);Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 12/74] acpi: extend aml_shiftright() to accept target argument
Quoted 44 lines · Igor Mammedov
it allows to express
ShiftRight(A,B,C)syntaxSigned-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 4 ++-- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)hw/acpi/aml-build.c +2
-2@@ -491,9 +491,9 @@ Aml *aml_shiftleft(Aml *arg1, Aml *count) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftRight */ -Aml *aml_shiftright (Aml *arg1,Aml *count) +Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst) { -return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count,NULL ); +return build_opcode_2arg_dst (0x7A /* ShiftRightOp */ , arg1, count, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLLess */ hw/i386/acpi-build.c +1
-1@@ -666,7 +666,7 @@ static Aml *build_prt(void)/* slot = pin >> 2 */ aml_append (while_ctx, -aml_store (aml_shiftright (pin,aml_int (2 )), slot)); +aml_store (aml_shiftright (pin,aml_int (2 ),NULL ), slot));/* lnk_idx = (slot + pin) & 3 */ aml_append (while_ctx,aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 )), lnk_idx));include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_store(Aml *val, Aml *target); · line 209
Quoted 8 lines
include/hw/acpi/aml-build.h +1
-1@@ -203,7 +203,7 @@ Aml *aml_store(Aml *val, Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count); -Aml *aml_shiftright (Aml *arg1,Aml *count); +Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);Aml *aml_lless (Aml *arg1,Aml *arg2);Aml *aml_add (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_subtract (Aml *arg1,Aml *arg2,Aml *dst);
PATCH 13/74 acpi: add aml_alias()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/aml-build.c +9 -0
@@ -1242,6 +1242,15 @@ Aml *aml_release(Aml *mutex)return var; } +/* ACPI 1.0b: 16.2.5.1 Name Space Modifier Objects Encoding: DefAlias */ +Aml *aml_alias (const char *source_object,const char *alias_object) +{ +Aml *var =aml_opcode (0x06 /* AliasOp */ ); +aml_append (var,aml_name ("%s" , source_object)); +aml_append (var,aml_name ("%s" , alias_object)); +return var; +} +void build_header (GArray *linker,GArray *table_data,AcpiTableHeader *h,const char *sig,int len,uint8_t rev)
include/hw/acpi/aml-build.h +1 -0
@@ -278,6 +278,7 @@ Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule);Aml *aml_mutex (const char *name,uint8_t sync_level);Aml *aml_acquire (Aml *mutex,uint16_t timeout);Aml *aml_release (Aml *mutex); +Aml *aml_alias (const char *source_object,const char *alias_object);Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_varpackage (uint32_t num_elements);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 13/74] acpi: add aml_alias()
Quoted 32 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)hw/acpi/aml-build.c +9
-0@@ -1242,6 +1242,15 @@ Aml *aml_release(Aml *mutex)return var; } +/* ACPI 1.0b: 16.2.5.1 Name Space Modifier Objects Encoding: DefAlias */ +Aml *aml_alias (const char *source_object,const char *alias_object) +{ +Aml *var =aml_opcode (0x06 /* AliasOp */ ); +aml_append (var,aml_name ("%s" , source_object)); +aml_append (var,aml_name ("%s" , alias_object)); +return var; +} +void build_header (GArray *linker,GArray *table_data,AcpiTableHeader *h,const char *sig,int len,uint8_t rev)include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule); · line 284
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -278,6 +278,7 @@ Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule);Aml *aml_mutex (const char *name,uint8_t sync_level);Aml *aml_acquire (Aml *mutex,uint16_t timeout);Aml *aml_release (Aml *mutex); +Aml *aml_alias (const char *source_object,const char *alias_object);Aml *aml_create_dword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_create_qword_field (Aml *srcbuf,Aml *index,const char *name);Aml *aml_varpackage (uint32_t num_elements);
PATCH 14/74 acpi: add aml_sleep()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 10 ++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 11 insertions(+)
hw/acpi/aml-build.c +10 -0
@@ -1123,6 +1123,16 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, addr_trans, len, flags); } +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefSleep */ +Aml *aml_sleep (uint64_t msec) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x22 );/* SleepOp */ +aml_append (var,aml_int (msec)); +return var; +} +static uint8_t Hex2Byte (const char *src) {int hi, lo;
include/hw/acpi/aml-build.h +1 -0
@@ -263,6 +263,7 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, uint64_t addr_gran, uint64_t addr_min, uint64_t addr_max, uint64_t addr_trans, uint64_t len); +Aml *aml_sleep (uint64_t msec);/* Block AML object primitives */ Aml *aml_scope (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/74] acpi: add aml_sleep()
Quoted 33 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 10 ++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 11 insertions(+)hw/acpi/aml-build.c +10
-0@@ -1123,6 +1123,16 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, addr_trans, len, flags); } +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefSleep */ +Aml *aml_sleep (uint64_t msec) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x22 );/* SleepOp */ +aml_append (var,aml_int (msec)); +return var; +} +static uint8_t Hex2Byte (const char *src) {int hi, lo;include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, · line 269
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -263,6 +263,7 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, uint64_t addr_gran, uint64_t addr_min, uint64_t addr_max, uint64_t addr_trans, uint64_t len); +Aml *aml_sleep (uint64_t msec);/* Block AML object primitives */ Aml *aml_scope (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );
PATCH 15/74 acpi: support serialized method
In reply to Igor MammedovFrom: Xiao Guangrong <[email protected]>
Add serialized method support so that explicit Mutex can be avoided
--- hw/acpi/aml-build.c | 17 +++++++++++++++-- hw/arm/virt-acpi-build.c | 10 +++++----- hw/i386/acpi-build.c | 41 +++++++++++++++++++++-------------------- include/hw/acpi/aml-build.h | 8 +++++++- 4 files changed, 48 insertions(+), 28 deletions(-)
hw/acpi/aml-build.c +15 -2
@@ -741,11 +741,24 @@ Aml *aml_while(Aml *predicate) }/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */ -Aml *aml_method (const char *name,int arg_count) +Aml *aml_method (const char *name,int arg_count,AmlSerializeFlag sflag) {Aml *var =aml_bundle (0x14 /* MethodOp */ ,AML_PACKAGE ); +int methodflags; + +/* +* MethodFlags: +* bit 0-2: ArgCount (0-7) +* bit 3: SerializeFlag +* 0: NotSerialized +* 1: Serialized +* bit 4-7: reserved (must be 0) +*/ +assert (arg_count <8 ); + methodflags = arg_count | (sflag <<3 ); +build_append_namestring (var->buf,"%s" , name); -build_append_byte (var->buf, arg_count);/* MethodFlags: ArgCount */ +build_append_byte (var->buf, methodflags);/* MethodFlags: ArgCount */ return var; }
hw/arm/virt-acpi-build.c +5 -5
@@ -212,16 +212,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , AML_EXCLUSIVE, irq + i));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); - method =aml_method ("_SRS" ,1 ); + method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);aml_append (dev, dev_gsi); } - method =aml_method ("_CBA" ,0 ); + method =aml_method ("_CBA" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (base_ecam)));aml_append (dev, method); - method =aml_method ("_CRS" ,0 ); + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED );Aml *rbuf =aml_resource_template (); aml_append(rbuf, aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
@@ -254,7 +254,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Declare an _OSC (OS Control Handoff) method */ aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 )));aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); - method =aml_method ("_OSC" ,4 ); + method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));
@@ -296,7 +296,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_append (method, elsectx);aml_append (dev, method); - method =aml_method ("_DSM" ,4 ); + method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );/* PCI Firmware Specification 3.0 * 4.6.1. _DSM for PCI Express Slot Information
hw/i386/acpi-build.c +21 -20
141 lines not on this page · raw message
include/hw/acpi/aml-build.h +7 -1
@@ -148,6 +148,12 @@ typedef enum {AML_SHARED_AND_WAKE =3 , } AmlShared; +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: MethodFlags */ +typedef enum { +AML_NOTSERIALIZED =0 , +AML_SERIALIZED =1 , +}AmlSerializeFlag ; + typedef struct AcpiBuildTables { GArray *table_data;
@@ -268,7 +274,7 @@ Aml *aml_sleep(uint64_t msec);/* Block AML object primitives */ Aml *aml_scope (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_device (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 ); -Aml *aml_method (const char *name,int arg_count); +Aml *aml_method (const char *name,int arg_count,AmlSerializeFlag sflag);Aml *aml_if (Aml *predicate);Aml *aml_else (void );Aml *aml_while (Aml *predicate);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/74] acpi: support serialized method
Quoted 7 lines · Igor Mammedov
From: Xiao Guangrong <[email protected]>
Add serialized method support so that explicit Mutex can be avoided
Signed-off-by Xiao Guangrong <[email protected]>Signed-off-by Igor Mammedov <[email protected]>
Quoted 262 lines
--- hw/acpi/aml-build.c | 17 +++++++++++++++-- hw/arm/virt-acpi-build.c | 10 +++++----- hw/i386/acpi-build.c | 41 +++++++++++++++++++++-------------------- include/hw/acpi/aml-build.h | 8 +++++++- 4 files changed, 48 insertions(+), 28 deletions(-)hw/acpi/aml-build.c +15
-2@@ -741,11 +741,24 @@ Aml *aml_while(Aml *predicate) }/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */ -Aml *aml_method (const char *name,int arg_count) +Aml *aml_method (const char *name,int arg_count,AmlSerializeFlag sflag) {Aml *var =aml_bundle (0x14 /* MethodOp */ ,AML_PACKAGE ); +int methodflags; + +/* +* MethodFlags: +* bit 0-2: ArgCount (0-7) +* bit 3: SerializeFlag +* 0: NotSerialized +* 1: Serialized +* bit 4-7: reserved (must be 0) +*/ +assert (arg_count <8 ); + methodflags = arg_count | (sflag <<3 ); +build_append_namestring (var->buf,"%s" , name); -build_append_byte (var->buf, arg_count);/* MethodFlags: ArgCount */ +build_append_byte (var->buf, methodflags);/* MethodFlags: ArgCount */ return var; }hw/arm/virt-acpi-build.c +5
-5@@ -212,16 +212,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , AML_EXCLUSIVE, irq + i));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); - method =aml_method ("_SRS" ,1 ); + method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);aml_append (dev, dev_gsi); } - method =aml_method ("_CBA" ,0 ); + method =aml_method ("_CBA" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (base_ecam)));aml_append (dev, method); - method =aml_method ("_CRS" ,0 ); + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED );Aml *rbuf =aml_resource_template (); aml_append(rbuf, aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,@@ -254,7 +254,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Declare an _OSC (OS Control Handoff) method */ aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 )));aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); - method =aml_method ("_OSC" ,4 ); + method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));@@ -296,7 +296,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_append (method, elsectx);aml_append (dev, method); - method =aml_method ("_DSM" ,4 ); + method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );/* PCI Firmware Specification 3.0 * 4.6.1. _DSM for PCI Express Slot Information hw/i386/acpi-build.c +21
-20@@ -487,7 +487,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,int64_t bsel_val =qint_get_int (qobject_to_qint (bsel));aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); - notify_method =aml_method ("DVNT" ,2 ); + notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); }for (i =0 ; i <ARRAY_SIZE (bus->devices); i +=PCI_FUNC_MAX ) {@@ -503,7 +503,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); - method =aml_method ("_EJ0" ,1 ); + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );@@ -546,22 +546,22 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, s3d =0 ; } - method =aml_method ("_S1D" ,0 ); + method =aml_method ("_S1D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (0 )));aml_append (dev, method); - method =aml_method ("_S2D" ,0 ); + method =aml_method ("_S2D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (0 )));aml_append (dev, method); - method =aml_method ("_S3D" ,0 ); + method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) {/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - method =aml_method ("_EJ0" ,1 ); + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );@@ -590,7 +590,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,/* Append PCNT method to notify about events on local and child buses. * Add unconditionally for root since DSDT expects it. */ - method =aml_method ("PCNT" ,0 ); + method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED );/* If bus supports hotplug select it and notify about local events */ if (bsel) {@@ -651,7 +651,7 @@ static Aml *build_prt(void) {Aml *method, *while_ctx, *pin, *res; - method =aml_method ("_PRT" ,0 ); + method =aml_method ("_PRT" ,0 ,AML_NOTSERIALIZED ); res =aml_local (0 ); pin =aml_local (1 );aml_append (method,aml_store (aml_package (128 ), res));@@ -1112,12 +1112,12 @@ build_ssdt(GArray *table_data, GArray *linker,/* device present, functioning, decoding, shown in UI */ aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); - method =aml_method ("RDPT" ,0 ); + method =aml_method ("RDPT" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_store (aml_name ("PEPT" ),aml_local (0 )));aml_append (method,aml_return (aml_local (0 )));aml_append (dev, method); - method =aml_method ("WRPT" ,1 ); + method =aml_method ("WRPT" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_store (aml_arg (0 ),aml_name ("PEPT" )));aml_append (dev, method);@@ -1153,15 +1153,15 @@ build_ssdt(GArray *table_data, GArray *linker,for (i =0 ; i < acpi_cpus; i++) { dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); - method =aml_method ("_MAT" ,0 ); + method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_call1 ("CPMA" ,aml_int (i))));aml_append (dev, method); - method =aml_method ("_STA" ,0 ); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_call1 ("CPST" ,aml_int (i))));aml_append (dev, method); - method =aml_method ("_EJ0" ,1 ); + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_call2 ("CPEJ" ,aml_int (i),aml_arg (0 ))) );@@ -1174,7 +1174,7 @@ build_ssdt(GArray *table_data, GArray *linker,* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ - method =aml_method ("NTFY" ,2 ); + method =aml_method ("NTFY" ,2 ,AML_NOTSERIALIZED );for (i =0 ; i < acpi_cpus; i++) { ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); aml_append(ifctx,@@ -1269,29 +1269,29 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i)));aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - method =aml_method ("_CRS" ,0 ); + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" ))));aml_append (dev, method); - method =aml_method ("_STA" ,0 ); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" ))));aml_append (dev, method); - method =aml_method ("_PXM" ,0 ); + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" ))));aml_append (dev, method); - method =aml_method ("_OST" ,3 ); + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);aml_append (method,aml_return (aml_call4 ( s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) )));aml_append (dev, method); - method =aml_method ("_EJ0" ,1 ); + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);aml_append (method,aml_return (aml_call2 ( s,aml_name ("_UID" ),aml_arg (0 ))));@@ -1303,7 +1303,8 @@ build_ssdt(GArray *table_data, GArray *linker,/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { * If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } */ - method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 ); + method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , +AML_NOTSERIALIZED );for (i =0 ; i < nr_mem; i++) { ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); aml_append(ifctx,include/hw/acpi/aml-build.h +7
-1@@ -148,6 +148,12 @@ typedef enum {AML_SHARED_AND_WAKE =3 , } AmlShared; +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: MethodFlags */ +typedef enum { +AML_NOTSERIALIZED =0 , +AML_SERIALIZED =1 , +}AmlSerializeFlag ; + typedef struct AcpiBuildTables { GArray *table_data;@@ -268,7 +274,7 @@ Aml *aml_sleep(uint64_t msec);/* Block AML object primitives */ Aml *aml_scope (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_device (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 ); -Aml *aml_method (const char *name,int arg_count); +Aml *aml_method (const char *name,int arg_count,AmlSerializeFlag sflag);Aml *aml_if (Aml *predicate);Aml *aml_else (void );Aml *aml_while (Aml *predicate);
Signature · 1 line
Shannon
PATCH 16/74 acpi: add aml_lor()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/aml-build.c +9 -0
@@ -484,6 +484,15 @@ Aml *aml_or(Aml *arg1, Aml *arg2)return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLOr */ +Aml *aml_lor (Aml *arg1,Aml *arg2) +{ +Aml *var =aml_opcode (0x91 /* LOrOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftLeft */ Aml *aml_shiftleft (Aml *arg1,Aml *count) {
include/hw/acpi/aml-build.h +1 -0
@@ -208,6 +208,7 @@ Aml *aml_to_integer(Aml *arg);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2); +Aml *aml_lor (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);Aml *aml_lless (Aml *arg1,Aml *arg2);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 16/74] acpi: add aml_lor()
Quoted 32 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)hw/acpi/aml-build.c +9
-0@@ -484,6 +484,15 @@ Aml *aml_or(Aml *arg1, Aml *arg2)return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLOr */ +Aml *aml_lor (Aml *arg1,Aml *arg2) +{ +Aml *var =aml_opcode (0x91 /* LOrOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefShiftLeft */ Aml *aml_shiftleft (Aml *arg1,Aml *count) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_to_integer(Aml *arg); · line 214
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -208,6 +208,7 @@ Aml *aml_to_integer(Aml *arg);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2); +Aml *aml_lor (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);Aml *aml_lless (Aml *arg1,Aml *arg2);
PATCH 17/74 acpi: add aml_lgreater()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/aml-build.c +9 -0
@@ -715,6 +715,15 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreater */ +Aml *aml_lgreater (Aml *arg1,Aml *arg2) +{ +Aml *var =aml_opcode (0x94 /* LGreaterOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */ Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2) {
include/hw/acpi/aml-build.h +1 -0
@@ -240,6 +240,7 @@ Aml *aml_local(int num);Aml *aml_string (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_lnot (Aml *arg);Aml *aml_equal (Aml *arg1,Aml *arg2); +Aml *aml_lgreater (Aml *arg1,Aml *arg2);Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2);Aml *aml_processor (uint8_t proc_id,uint32_t pblk_addr,uint8_t pblk_len,const char *name_format, ...)GCC_FMT_ATTR (4 ,5 );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 17/74] acpi: add aml_lgreater()
Quoted 32 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)hw/acpi/aml-build.c +9
-0@@ -715,6 +715,15 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreater */ +Aml *aml_lgreater (Aml *arg1,Aml *arg2) +{ +Aml *var =aml_opcode (0x94 /* LGreaterOp */ ); +aml_append (var, arg1); +aml_append (var, arg2); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */ Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_local(int num); · line 246
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -240,6 +240,7 @@ Aml *aml_local(int num);Aml *aml_string (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_lnot (Aml *arg);Aml *aml_equal (Aml *arg1,Aml *arg2); +Aml *aml_lgreater (Aml *arg1,Aml *arg2);Aml *aml_lgreater_equal (Aml *arg1,Aml *arg2);Aml *aml_processor (uint8_t proc_id,uint32_t pblk_addr,uint8_t pblk_len,const char *name_format, ...)GCC_FMT_ATTR (4 ,5 );
PATCH 18/74 acpi: extend aml_field() to support LockRule
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 5 ++++- hw/i386/acpi-build.c | 10 +++++----- include/hw/acpi/aml-build.h | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-)
hw/acpi/aml-build.c +4 -1
@@ -860,11 +860,14 @@ Aml *aml_reserved_field(unsigned length) }/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefField */ -Aml *aml_field (const char *name,AmlAccessType type,AmlUpdateRule rule) +Aml *aml_field (const char *name,AmlAccessType type,AmlLockRule lock, +AmlUpdateRule rule) {Aml *var =aml_bundle (0x81 /* FieldOp */ ,AML_EXT_PACKAGE );uint8_t flags = rule <<5 | type; + flags |= lock <<4 ;/* LockRule at 4 bit offset */ +build_append_namestring (var->buf,"%s" , name);build_append_byte (var->buf, flags);return var;
hw/i386/acpi-build.c +5 -5
@@ -1105,7 +1105,7 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (dev,aml_operation_region ("PEOR" ,AML_SYSTEM_IO , misc->pvpanic_port,1 )); - field =aml_field ("PEOR" ,AML_BYTE_ACC ,AML_PRESERVE ); + field =aml_field ("PEOR" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PEPT" ,8 ));aml_append (dev, field);
@@ -1145,7 +1145,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* declare CPU hotplug MMIO region and PRS field to access it */ aml_append (sb_scope,aml_operation_region ("PRST" ,AML_SYSTEM_IO , pm->cpu_hp_io_base, pm->cpu_hp_io_len)); - field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_PRESERVE ); + field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PRS" ,256 ));aml_append (sb_scope, field);
@@ -1220,7 +1220,7 @@ build_ssdt(GArray *table_data, GArray *linker, ); field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_PRESERVE ); +AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); aml_append(field, /* read only */
@@ -1234,7 +1234,7 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (scope, field); field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , -AML_WRITE_AS_ZEROS ); +AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ ));aml_append (field,/* 1 if enabled, read only */ aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 ));
@@ -1250,7 +1250,7 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (scope, field); field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_PRESERVE ); +AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); aml_append(field, /* _OST event code, write only */
include/hw/acpi/aml-build.h +7 -1
@@ -49,6 +49,11 @@ typedef enum { } AmlAccessType;typedef enum { +AML_NOLOCK =0 , +AML_LOCK =1 , +}AmlLockRule ; + +typedef enum { AML_PRESERVE = 0, AML_WRITE_AS_ONES = 1, AML_WRITE_AS_ZEROS = 2,
@@ -283,7 +288,8 @@ Aml *aml_while(Aml *predicate);Aml *aml_package (uint8_t num_elements);Aml *aml_buffer (int buffer_size,uint8_t *byte_list);Aml *aml_resource_template (void ); -Aml *aml_field (const char *name,AmlAccessType type,AmlUpdateRule rule); +Aml *aml_field (const char *name,AmlAccessType type,AmlLockRule lock, +AmlUpdateRule rule);Aml *aml_mutex (const char *name,uint8_t sync_level);Aml *aml_acquire (Aml *mutex,uint16_t timeout);Aml *aml_release (Aml *mutex);
Signature · 1 line
1.8.3.1
PATCH 19/74 acpi: add aml_to_hexstring()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 13 +++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 14 insertions(+)
hw/acpi/aml-build.c +13 -0
@@ -436,6 +436,19 @@ Aml *aml_to_integer(Aml *arg)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToHexString */ +Aml *aml_to_hexstring (Aml *src,Aml *dst) +{ +Aml *var =aml_opcode (0x98 /* ToHexStringOp */ ); +aml_append (var, src); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + } +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {
include/hw/acpi/aml-build.h +1 -0
@@ -210,6 +210,7 @@ Aml *aml_return(Aml *val);Aml *aml_int (const uint64_t val);Aml *aml_arg (int pos);Aml *aml_to_integer (Aml *arg); +Aml *aml_to_hexstring (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 19/74] acpi: add aml_to_hexstring()
Quoted 36 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 13 +++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 14 insertions(+)hw/acpi/aml-build.c +13
-0@@ -436,6 +436,19 @@ Aml *aml_to_integer(Aml *arg)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToHexString */ +Aml *aml_to_hexstring (Aml *src,Aml *dst) +{ +Aml *var =aml_opcode (0x98 /* ToHexStringOp */ ); +aml_append (var, src); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + } +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_return(Aml *val); · line 216
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -210,6 +210,7 @@ Aml *aml_return(Aml *val);Aml *aml_int (const uint64_t val);Aml *aml_arg (int pos);Aml *aml_to_integer (Aml *arg); +Aml *aml_to_hexstring (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
PATCH 20/74 acpi: add aml_to_buffer()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 13 +++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 14 insertions(+)
hw/acpi/aml-build.c +13 -0
@@ -449,6 +449,19 @@ Aml *aml_to_hexstring(Aml *src, Aml *dst)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToBuffer */ +Aml *aml_to_buffer (Aml *src,Aml *dst) +{ +Aml *var =aml_opcode (0x96 /* ToBufferOp */ ); +aml_append (var, src); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + } +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {
include/hw/acpi/aml-build.h +1 -0
@@ -211,6 +211,7 @@ Aml *aml_int(const uint64_t val);Aml *aml_arg (int pos);Aml *aml_to_integer (Aml *arg);Aml *aml_to_hexstring (Aml *src,Aml *dst); +Aml *aml_to_buffer (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 20/74] acpi: add aml_to_buffer()
Quoted 36 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 13 +++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 14 insertions(+)hw/acpi/aml-build.c +13
-0@@ -449,6 +449,19 @@ Aml *aml_to_hexstring(Aml *src, Aml *dst)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToBuffer */ +Aml *aml_to_buffer (Aml *src,Aml *dst) +{ +Aml *var =aml_opcode (0x96 /* ToBufferOp */ ); +aml_append (var, src); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + } +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_int(const uint64_t val); · line 217
Quoted 7 lines
include/hw/acpi/aml-build.h +1
-0@@ -211,6 +211,7 @@ Aml *aml_int(const uint64_t val);Aml *aml_arg (int pos);Aml *aml_to_integer (Aml *arg);Aml *aml_to_hexstring (Aml *src,Aml *dst); +Aml *aml_to_buffer (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2);Aml *aml_or (Aml *arg1,Aml *arg2);
PATCH 21/74 acpi add aml_dma()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 14 ++++++++++++++ include/hw/acpi/aml-build.h | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+)
hw/acpi/aml-build.c +14 -0
@@ -1183,6 +1183,20 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, addr_trans, len, flags); } +/* ACPI 1.0b: 6.4.2.2 DMA Format/6.4.2.2.1 ASL Macro for DMA Descriptor */ +Aml *aml_dma (AmlDmaType typ,AmlDmaBusMaster bm,AmlTransferSize sz, +uint8_t channel) +{ +Aml *var =aml_alloc (); +uint8_t flags = sz | bm <<2 | typ <<5 ; + +assert (channel <8 ); +build_append_byte (var->buf,0x2A );/* Byte 0: DMA Descriptor */ +build_append_byte (var->buf,1U << channel);/* Byte 1: _DMA - DmaChannel */ +build_append_byte (var->buf, flags);/* Byte 2 */ +return var; +} +/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefSleep */ Aml *aml_sleep (uint64_t msec) {
include/hw/acpi/aml-build.h +20 -0
@@ -35,6 +35,24 @@ struct Aml {typedef struct Aml Aml ;typedef enum { +AML_COMPATIBILITY =0 , +AML_TYPEA =1 , +AML_TYPEB =2 , +AML_TYPEF =3 , +}AmlDmaType ; + +typedef enum { +AML_NOTBUSMASTER =0 , +AML_BUSMASTER =1 , +}AmlDmaBusMaster ; + +typedef enum { +AML_TRANSFER8 =0 , +AML_TRANSFER8_16 =1 , +AML_TRANSFER16 =2 , +}AmlTransferSize ; + +typedef enum {AML_DECODE10 =0 ,AML_DECODE16 =1 , }AmlIODecode ;
@@ -278,6 +296,8 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, uint64_t addr_gran, uint64_t addr_min, uint64_t addr_max, uint64_t addr_trans, uint64_t len); +Aml *aml_dma (AmlDmaType typ,AmlDmaBusMaster bm,AmlTransferSize sz, +uint8_t channel);Aml *aml_sleep (uint64_t msec);/* Block AML object primitives */
Signature · 1 line
1.8.3.1
PATCH 22/74 acpi: extend aml_or() to accept target argument
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 4 ++-- hw/arm/virt-acpi-build.c | 6 +++--- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/aml-build.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-)
hw/acpi/aml-build.c +2 -2
@@ -505,9 +505,9 @@ Aml *aml_and(Aml *arg1, Aml *arg2) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ -Aml *aml_or (Aml *arg1,Aml *arg2) +Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLOr */
hw/arm/virt-acpi-build.c +3 -3
@@ -276,12 +276,12 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, aml_name("CTRL"))); ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (0x1 )))); -aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x08 )), +aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x08 ),NULL ),aml_name ("CDW1" )));aml_append (ifctx, ifctx1); ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x10 )), +aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x10 ),NULL ),aml_name ("CDW1" )));aml_append (ifctx, ifctx1);
@@ -290,7 +290,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_append (method, ifctx); elsectx =aml_else (); -aml_append (elsectx,aml_store (aml_or (aml_name ("CDW1" ),aml_int (4 )), +aml_append (elsectx,aml_store (aml_or (aml_name ("CDW1" ),aml_int (4 ),NULL ),aml_name ("CDW1" )));aml_append (elsectx,aml_return (aml_arg (3 )));aml_append (method, elsectx);
hw/i386/acpi-build.c +2 -1
@@ -679,7 +679,8 @@ static Aml *build_prt(void)/* route[0] = 0x[slot]FFFF */ aml_append (while_ctx, -aml_store (aml_or (aml_shiftleft (slot,aml_int (16 )),aml_int (0xFFFF )), +aml_store (aml_or (aml_shiftleft (slot,aml_int (16 )),aml_int (0xFFFF ), +NULL ),aml_index (route,aml_int (0 ))));/* route[1] = pin & 3 */ aml_append(while_ctx,
include/hw/acpi/aml-build.h +1 -1
@@ -232,7 +232,7 @@ Aml *aml_to_hexstring(Aml *src, Aml *dst);Aml *aml_to_buffer (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2); -Aml *aml_or (Aml *arg1,Aml *arg2); +Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_lor (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 22/74] acpi: extend aml_or() to accept target argument
Quoted 72 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 4 ++-- hw/arm/virt-acpi-build.c | 6 +++--- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/aml-build.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-)hw/acpi/aml-build.c +2
-2@@ -505,9 +505,9 @@ Aml *aml_and(Aml *arg1, Aml *arg2) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ -Aml *aml_or (Aml *arg1,Aml *arg2) +Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x7D /* OrOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLOr */ hw/arm/virt-acpi-build.c +3
-3@@ -276,12 +276,12 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, aml_name("CTRL"))); ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (0x1 )))); -aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x08 )), +aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x08 ),NULL ),aml_name ("CDW1" )));aml_append (ifctx, ifctx1); ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x10 )), +aml_append (ifctx1,aml_store (aml_or (aml_name ("CDW1" ),aml_int (0x10 ),NULL ),aml_name ("CDW1" )));aml_append (ifctx, ifctx1);@@ -290,7 +290,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,aml_append (method, ifctx); elsectx =aml_else (); -aml_append (elsectx,aml_store (aml_or (aml_name ("CDW1" ),aml_int (4 )), +aml_append (elsectx,aml_store (aml_or (aml_name ("CDW1" ),aml_int (4 ),NULL ),aml_name ("CDW1" )));aml_append (elsectx,aml_return (aml_arg (3 )));aml_append (method, elsectx);hw/i386/acpi-build.c +2
-1@@ -679,7 +679,8 @@ static Aml *build_prt(void)/* route[0] = 0x[slot]FFFF */ aml_append (while_ctx, -aml_store (aml_or (aml_shiftleft (slot,aml_int (16 )),aml_int (0xFFFF )), +aml_store (aml_or (aml_shiftleft (slot,aml_int (16 )),aml_int (0xFFFF ), +NULL ),aml_index (route,aml_int (0 ))));/* route[1] = pin & 3 */ aml_append(while_ctx,include/hw/acpi/aml-build.h +0
-0
include/hw/acpi/aml-build.h Aml *aml_to_hexstring(Aml *src, Aml *dst); · line 238
Quoted 8 lines
include/hw/acpi/aml-build.h +1
-1@@ -232,7 +232,7 @@ Aml *aml_to_hexstring(Aml *src, Aml *dst);Aml *aml_to_buffer (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2); -Aml *aml_or (Aml *arg1,Aml *arg2); +Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_lor (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);Aml *aml_shiftright (Aml *arg1,Aml *count,Aml *dst);
PATCH 23/74 acpi: extend aml_and() to accept target argument
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 4 ++-- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 8 +++++--- include/hw/acpi/aml-build.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)
hw/acpi/aml-build.c +2 -2
@@ -499,9 +499,9 @@ build_opcode_2arg_dst(uint8_t op, Aml *arg1, Aml *arg2, Aml *dst) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +Aml *aml_and (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */
hw/arm/virt-acpi-build.c +1 -1
@@ -272,7 +272,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" )));aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); -aml_append (ifctx,aml_store (aml_and (aml_name ("CTRL" ),aml_int (0x1D )), +aml_append (ifctx,aml_store (aml_and (aml_name ("CTRL" ),aml_int (0x1D ),NULL ),aml_name ("CTRL" ))); ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (0x1 ))));
hw/i386/acpi-build.c +5 -3
@@ -469,7 +469,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)Aml *if_ctx;int32_t devfn =PCI_DEVFN (slot,0 ); - if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot))); + if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL ));aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 )));aml_append (method, if_ctx); }
@@ -669,7 +669,8 @@ static Aml *build_prt(void) aml_store(aml_shiftright(pin, aml_int(2), NULL), slot));/* lnk_idx = (slot + pin) & 3 */ aml_append (while_ctx, -aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 )), lnk_idx)); +aml_store (aml_and (aml_add (pin, slot,NULL ),aml_int (3 ),NULL ), + lnk_idx));/* route[2] = "LNK[D|A|B|C]", selection based on pin % 3 */ aml_append (while_ctx,initialize_route (route,"LNKD" , lnk_idx,0 ));
@@ -684,7 +685,8 @@ static Aml *build_prt(void) aml_index(route, aml_int(0))));/* route[1] = pin & 3 */ aml_append (while_ctx, -aml_store (aml_and (pin,aml_int (3 )),aml_index (route,aml_int (1 )))); +aml_store (aml_and (pin,aml_int (3 ),NULL ), +aml_index (route,aml_int (1 ))));/* res[pin] = route */ aml_append (while_ctx,aml_store (route,aml_index (res, pin)));/* pin++ */
include/hw/acpi/aml-build.h +1 -1
@@ -231,7 +231,7 @@ Aml *aml_to_integer(Aml *arg);Aml *aml_to_hexstring (Aml *src,Aml *dst);Aml *aml_to_buffer (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target); -Aml *aml_and (Aml *arg1,Aml *arg2); +Aml *aml_and (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_lor (Aml *arg1,Aml *arg2);Aml *aml_shiftleft (Aml *arg1,Aml *count);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 23/74] acpi: extend aml_and() to accept target argument
Quoted 29 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 4 ++-- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 8 +++++--- include/hw/acpi/aml-build.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)hw/acpi/aml-build.c +2
-2@@ -499,9 +499,9 @@ build_opcode_2arg_dst(uint8_t op, Aml *arg1, Aml *arg2, Aml *dst) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +Aml *aml_and (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2,NULL ); +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ hw/arm/virt-acpi-build.c +0
-0
hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, · line 275
Quoted 5 lines
hw/arm/virt-acpi-build.c +1
-1@@ -272,7 +272,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" )));aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D)), + aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
I'm not sure why you must extend this kind functions now. When I post the patch to add aml_and(), you said
"
Quoted 10 lines
hw/arm/virt-acpi-build.c +0
-0>>> +Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3) > I know that it's possible to Store inside of And(a, b, save_here)Quoted 6 lines
ASL op, but could you instead rewrite it to
Store(And(a, b), save_here)so it wouldn't clatter trivial
And(a,b)uses and drop this hunk.Yes, we can use
Store(And(a, b), save_here)but according to the SPEC the And op can have 3 args. We don't support it?
I don't think that we should do it if it could be implemented using 2 already existing API calls to keep it simple and not to pollute code with extra ", NULL" argument in most cases. "
Thanks,
Signature · 1 line
Shannon
Re: [Qemu-devel] [PATCH 23/74] acpi: extend aml_and() to accept target argument
Quoted 51 lines · On Thu, 10 Dec 2015 10:07:43 +0800 Shannon Zhao <[email protected]>…
Quoted 30 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/aml-build.c | 4 ++-- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 8 +++++--- include/hw/acpi/aml-build.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)hw/acpi/aml-build.c +2
-2@@ -499,9 +499,9 @@ build_opcode_2arg_dst(uint8_t op, Aml *arg1, Aml *arg2, Aml *dst) }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and (Aml *arg1,Aml *arg2) +Aml *aml_and (Aml *arg1,Aml *arg2,Aml *dst) { -return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2, NULL); +return build_opcode_2arg_dst (0x7B /* AndOp */ , arg1, arg2, dst); }/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */
hw/arm/virt-acpi-build.c +0
-0hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const · line 278
Quoted 8 lines
hw/arm/virt-acpi-build.c +1
-1@@ -272,7 +272,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq, aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); aml_append(ifctx, aml_store(aml_name("CDW2"),aml_name ("SUPP" )));aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D)), + aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),I'm not sure why you must extend this kind functions now. When I post the patch to add
aml_and(), you said
"Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
+Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3)
I know that it's possible to Store inside of
And(a, b, save_here)ASL op, but could you instead rewrite it to
Store(And(a, b), save_here)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
so it wouldn't clatter trivial
And(a,b)uses and drop this hunk.Yes, we can use
Store(And(a, b), save_here)but according to the SPEC the And op can have 3 args. We don't support it?I don't think that we should do it if it could be implemented using 2 already existing API calls to keep it simple and not to pollute code with extra ", NULL" argument in most cases. "
I'd prefer 'Store(And(a, b), save_here)' but piix4/q35 DSDT currently utilizes And(arg1,arg2, dst) form and if I do that during conversion that will break exact match with IASL compiled DSDT and hence break 'make check' tests, since it produces different series of AML opcodes.
Hence making hard to prove that conversion doesn't introduce any regression.
PATCH 24/74 acpi: extend aml_interrupt() to support multiple irqs
In reply to Igor MammedovASL Interrupt() macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in _PSR object.
---
CC: [email protected]
CC: [email protected]
--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)
hw/acpi/aml-build.c +13 -9
@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count) { +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */ build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }
hw/arm/virt-acpi-build.c +12 -11
@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));
@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described
@@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));
@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }
@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {
@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;
@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);
include/hw/acpi/aml-build.h +1 -1
@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
Signature · 1 line
1.8.3.1
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 13 lines · Igor Mammedov
static void acpi_dsdt_add_virtio(Aml *scope,
const MemMapEntry*virtio_mmio_memmap,hw/arm/virt-acpi-build.c +2
-2- int mmio_irq, int num) + uint32_t mmio_irq, int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {
hw/arm/virt-acpi-build.c static void acpi_dsdt_add_virtio(Aml *scope, · line 155
Quoted 5 lines
hw/arm/virt-acpi-build.c +1
-1@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));
This looks not right. You could move uint32_t irq = mmio_irq; into the for loop and make it as uint32_t irq = mmio_irq + i;
Thanks,
Signature · 1 line
Shannon
PATCH v2 24/74 acpi: extend aml_interrupt() to support multiple irqs
ASL Interrupt() macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in _PSR object.
---
v2:
- fix incorrect irq number calculation in ARM:acpi_dsdt_add_virtio()
--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)
hw/acpi/aml-build.c +13 -9
@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count) { +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */ build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }
hw/arm/virt-acpi-build.c +12 -11
@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));
@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described
@@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));
@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }
@@ -136,14 +136,14 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq;int i;for (i =0 ; i < num; i++) { +uint32_t irq = mmio_irq + i;Aml *dev =aml_device ("VR%02u" , i);aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0005" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (i)));
@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;
@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);
include/hw/acpi/aml-build.h +1 -1
@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 6 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>
Also, I'll include this patch in my patch set[1] as you suggested.
[1] Add system_powerdown support on ARM for ACPI and DT
Quoted 163 lines
---
v2:
- fix incorrect irq number calculation in ARM:acpi_dsdt_add_virtio()Reported-by Shannon Zhao <[email protected]>--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)hw/acpi/aml-build.c +13
-9@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count) { +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */ build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,14 +136,14 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq;int i;for (i =0 ; i < num; i++) { +uint32_t irq = mmio_irq + i;Aml *dev =aml_device ("VR%02u" , i);aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0005" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (i)));@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
Signature · 1 line
Shannon
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
In reply to Igor MammedovQuoted 20 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)hw/acpi/aml-build.c +0
-0
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 670
Quoted 5 lines
hw/acpi/aml-build.c +1
-1@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count)
const uint32_t *irq_list?
Quoted 5 lines
hw/acpi/aml-build.c +1
-0{ +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 );
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 683
Quoted 10 lines
hw/acpi/aml-build.c +6
-2+const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */
build_append_int_noprefix ?
Which really needs a better name btw.
Quoted 127 lines
hw/acpi/aml-build.c +5
-6build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,Signature · 1 line
1.8.3.1
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 16 lines · On Tue, 22 Dec 2015 17:17:33 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)
Quoted 12 lines
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 670
Quoted 10 lines
hw/acpi/aml-build.c +1
-1@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count)const
uint32_t*irq_list?
will do it on top as it's in master by now.
Quoted 11 lines
Quoted 11 lines
hw/acpi/aml-build.c +5
-0{ +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );
Quoted 7 lines
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 683
Quoted 5 lines
hw/acpi/aml-build.c +2
-2build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */
build_append_int_noprefix?
it will do job to, though I'd prefer it by byte as it exactly matches table description in spec.
Quoted 2 lines
Which really needs a better name btw.
I'd like to get rid of long build_append_ prefix but would like to keep aml_ one only for ASL constructs.
How about 'acpi_int(Aml*, val, sz)' replacing both 'build_append_int[_noprefix]()' where if sz == 0 do what build_append_int() does.
same name suggestion goes for byte:
s/build_append_byte/acpi_byte/
Quoted 130 lines
Quoted 130 lines
hw/acpi/aml-build.c +5
-6build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,Signature · 1 line
1.8.3.1
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 50 lines · Igor Mammedov
Quoted 16 lines · On Tue, 22 Dec 2015 17:17:33 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)Quoted 12 lines
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 670
Quoted 10 lines
hw/acpi/aml-build.c +1
-1@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count)const
uint32_t*irq_list?will do it on top as it's in master by now.
Quoted 17 lines
Quoted 16 lines
hw/acpi/aml-build.c +7
-2{ +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */
Quoted 3 lines
Quoted 1 line
build_append_int_noprefix?it will do job to, though I'd prefer it by byte as it exactly matches table description in spec.
ok then, it's not a big deal.
Quoted 6 lines
Quoted 2 lines
Which really needs a better name btw.
I'd like to get rid of long
build_append_prefix but would like to keepaml_one only for ASL constructs.
How about 'acpi_int(Aml*, val, sz)' replacing both 'build_append_int[_noprefix]()' where if sz == 0 do whatbuild_append_int()does.
We can't drop GArray things yet - I want acpi tables to be built like this and get rid of structs.
Quoted 2 lines
same name suggestion goes for byte:
s/build_append_byte/acpi_byte/
I prefer append in there. byte implies it returns byte.
build_append_bytes?
Quoted 130 lines
Quoted 130 lines
Quoted 130 lines
hw/acpi/aml-build.c +5
-6build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,Signature · 1 line
1.8.3.1
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 58 lines · On Tue, 22 Dec 2015 17:58:41 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 50 lines · Igor Mammedov
Quoted 16 lines · On Tue, 22 Dec 2015 17:17:33 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)Quoted 12 lines
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 670
Quoted 10 lines
hw/acpi/aml-build.c +1
-1@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count)const
uint32_t*irq_list?will do it on top as it's in master by now.
Quoted 17 lines
Quoted 16 lines
hw/acpi/aml-build.c +7
-2{ +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */ Quoted 3 lines
Quoted 1 line
build_append_int_noprefix?it will do job to, though I'd prefer it by byte as it exactly matches table description in spec.
ok then, it's not a big deal.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Which really needs a better name btw.
I'd like to get rid of long
build_append_prefix but would like to keepaml_one only for ASL constructs.
How about 'acpi_int(Aml*, val, sz)' replacing both 'build_append_int[_noprefix]()' where if sz == 0 do whatbuild_append_int()does.We can't drop GArray things yet - I want acpi tables to be built like this and get rid of structs.
it doesn't have to be Aml* it could be Garray*
the point were to have single build_append_int() which does prefix/noprefix job but that might be confusing and easy to misuse, so scratch that off.
Quoted 7 lines
Quoted 3 lines
same name suggestion goes for byte:
s/build_append_byte/acpi_byte/I prefer append in there. byte implies it returns byte.
build_append_bytes?
'bytes' doesn't imply any encoding rules, while build_append_int_noprefix implies ACPI integer encoding and that was whole point of adding it so user whon't have to care about endianness.
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
hw/acpi/aml-build.c +5
-6build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,Signature · 1 line
1.8.3.1
Re: [Qemu-arm] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs
Quoted 77 lines · Igor Mammedov
Quoted 58 lines · On Tue, 22 Dec 2015 17:58:41 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 50 lines · Igor Mammedov
Quoted 16 lines · On Tue, 22 Dec 2015 17:17:33 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
ASL
Interrupt()macro translates to Extended Interrupt Descriptor which supports variable number of IRQs. It will be used for conversion of ASL code for pc/q35 machines that use it for returning several IRQs in_PSRobject.Signed-off-by Igor Mammedov <[email protected]>---
CC: [email protected]
CC: [email protected]--- hw/acpi/aml-build.c | 22 +++++++++++++--------- hw/arm/virt-acpi-build.c | 23 ++++++++++++----------- include/hw/acpi/aml-build.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-)Quoted 12 lines
hw/acpi/aml-build.c Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, · line 670
Quoted 10 lines
hw/acpi/aml-build.c +1
-1@@ -667,23 +667,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq) +uint32_t *irq_list,uint8_t irq_count)const
uint32_t*irq_list?will do it on top as it's in master by now.
Quoted 17 lines
Quoted 16 lines
hw/acpi/aml-build.c +7
-2{ +int i;Aml *var =aml_alloc ();uint8_t irq_flags = con_and_pro | (level_and_edge <<1 ) | (high_and_low <<2 ) | (shared <<3 ); +const int header_bytes_in_len =2 ; +uint16_t len = header_bytes_in_len + irq_count *sizeof (uint32_t ); + +assert (irq_count >0 );build_append_byte (var->buf,0x89 );/* Extended irq descriptor */ -build_append_byte (var->buf,6 );/* Length, bits[7:0] minimum value = 6 */ -build_append_byte (var->buf,0 );/* Length, bits[15:8] minimum value = 0 */ +build_append_byte (var->buf, len &0xFF );/* Length, bits[7:0] */ +build_append_byte (var->buf, len >>8 );/* Length, bits[15:8] */ Quoted 3 lines
Quoted 1 line
build_append_int_noprefix?it will do job to, though I'd prefer it by byte as it exactly matches table description in spec.
ok then, it's not a big deal.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Which really needs a better name btw.
I'd like to get rid of long
build_append_prefix but would like to keepaml_one only for ASL constructs.
How about 'acpi_int(Aml*, val, sz)' replacing both 'build_append_int[_noprefix]()' where if sz == 0 do whatbuild_append_int()does.We can't drop GArray things yet - I want acpi tables to be built like this and get rid of structs.
it doesn't have to be Aml* it could be Garray*
the point were to have singlebuild_append_int()which does prefix/noprefix job but that might be confusing and easy to misuse, so scratch that off.Quoted 4 lines
Quoted 3 lines
same name suggestion goes for byte:
s/build_append_byte/acpi_byte/
Quoted 6 lines
Quoted 3 lines
I prefer append in there. byte implies it returns byte.
build_append_bytes?'bytes' doesn't imply any encoding rules, while
build_append_int_noprefiximplies ACPI integer encoding and that was whole point of adding it so user whon't have to care about endianness.
No - it's not integer encoding. It's merely LE (as most of ACPI). We are adding integer byte by byte, not encoding it.
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
hw/acpi/aml-build.c +5
-6build_append_byte (var->buf, irq_flags);/* Interrupt Vector Information. */ -build_append_byte (var->buf,0x01 );/* Interrupt table length = 1 */ +build_append_byte (var->buf, irq_count);/* Interrupt table length */ -/* Interrupt Number */ -build_append_byte (var->buf,extract32 (irq,0 ,8 ));/* bits[7:0] */ -build_append_byte (var->buf,extract32 (irq,8 ,8 ));/* bits[15:8] */ -build_append_byte (var->buf,extract32 (irq,16 ,8 ));/* bits[23:16] */ -build_append_byte (var->buf,extract32 (irq,24 ,8 ));/* bits[31:24] */ +/* Interrupt Number List */ +for (i =0 ; i < irq_count; i++) { +build_append_int_noprefix (var->buf, irq_list[i],4 ); + }return var; }hw/arm/virt-acpi-build.c +12
-11@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) }static void acpi_dsdt_add_uart (Aml *scope,const MemMapEntry *uart_memmap, -int uart_irq) +uint32_t uart_irq) {Aml *dev =aml_device ("COM0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0011" )));@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uart_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , uart_irq)); +AML_EXCLUSIVE , &uart_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));/* The _ADR entry is used to link this device to the UART described @@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, }static void acpi_dsdt_add_rtc (Aml *scope,const MemMapEntry *rtc_memmap, -int rtc_irq) +uint32_t rtc_irq) {Aml *dev =aml_device ("RTC0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("LNRO0013" )));@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap, rtc_memmap->size, AML_READ_WRITE));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , rtc_irq)); +AML_EXCLUSIVE , &rtc_irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); }@@ -136,11 +136,11 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)static void acpi_dsdt_add_virtio (Aml *scope,const MemMapEntry *virtio_mmio_memmap, -int mmio_irq,int num) +uint32_t mmio_irq,int num) {hwaddr base = virtio_mmio_memmap->base;hwaddr size = virtio_mmio_memmap->size; -int irq = mmio_irq; +uint32_t irq = mmio_irq;int i;for (i =0 ; i < num; i++) {@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,aml_append (crs,aml_memory32_fixed (base, size,AML_READ_WRITE ));aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irq,1 ));aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (scope, dev); base += size; } } -static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap,int irq, -bool use_highmem) +static void acpi_dsdt_add_pci (Aml *scope,const MemMapEntry *memmap, +uint32_t irq,bool use_highmem) {Aml *method, *crs, *ifctx, *UUID , *ifctx1, *elsectx, *buf;int i, bus_no;@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,/* Create GSI link device */ for (i =0 ; i <PCI_NUM_PINS ; i++) { +uint32_t irqs = irq + i;Aml *dev_gsi =aml_device ("GSI%d" , i);aml_append (dev_gsi,aml_name_decl ("_HID" ,aml_string ("PNP0C0F" )));aml_append (dev_gsi,aml_name_decl ("_UID" ,aml_int (0 ))); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_PRS" , crs)); crs =aml_resource_template ();aml_append (crs,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE , irq + i)); +AML_EXCLUSIVE , &irqs,1 ));aml_append (dev_gsi,aml_name_decl ("_CRS" , crs)); method =aml_method ("_SRS" ,1 ,AML_NOTSERIALIZED );aml_append (dev_gsi, method);include/hw/acpi/aml-build.h +1
-1@@ -253,7 +253,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,Aml *aml_interrupt (AmlConsumerAndProducer con_and_pro,AmlLevelAndEdge level_and_edge,AmlActiveHighAndLow high_and_low,AmlShared shared, -uint32_t irq); +uint32_t *irq_list,uint8_t irq_count);Aml *aml_io (AmlIODecode dec,uint16_t min_base,uint16_t max_base,uint8_t aln,uint8_t len); Aml *aml_operation_region(const char *name, AmlRegionSpace rs,Signature · 1 line
1.8.3.1
PATCH 25/74 pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o
hw/acpi/memory_hotplug_acpi_table.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table +* +* Copyright (C) 2013 Red Hat Inc +* +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *pci_scope; +Aml *ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + { + } +aml_append (pci_scope, ctrl_dev); +aml_append (ctx, pci_scope); +}
hw/i386/acpi-build.c +3 -0
@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {
include/hw/acpi/memory_hotplug.h +4 -0
@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus:
@@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState)void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 28 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-)create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.ohw/acpi/memory_hotplug_acpi_table.c new file +0
-0
hw/acpi/memory_hotplug_acpi_table.c line 4
Quoted 4 lines
hw/acpi/memory_hotplug_acpi_table.c new file +4
-0@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table +* +* Copyright (C) 2013 Red Hat Inc
You mean 2015, right :) ?
Quoted 71 lines
hw/acpi/memory_hotplug_acpi_table.c new file +36
-0+* +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *pci_scope; +Aml *ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + { + } +aml_append (pci_scope, ctrl_dev); +aml_append (ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {include/hw/acpi/memory_hotplug.h +4
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState)void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 28 lines · On Thu, 10 Dec 2015 14:45:32 +0200 Marcel Apfelbaum…
Quoted 27 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5e
---/dev/null
Quoted 8 lines
hw/acpi/Makefile.objs line 4
Quoted 6 lines
+++
b/hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +4
-0@@ -0,0 +1,40 @@ +/* + * Memory hotplug AML code of DSDT ACPI table + * + * Copyright (C) 2013 Red Hat IncYou mean 2015, right :) ?
yep, I'll fix it.
Quoted 78 lines
Quoted 77 lines
hw/acpi/Makefile.objs +4
-0+ * + * Author: Igor Mammedov <[email protected]> + * + * This program is free software; you can redistribute it and/ormodify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.hw/acpi/Makefile.objs +7
-0+ + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General PublicLicense along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */hw/acpi/Makefile.objs +20
-0+ +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, + uint16_t io_base, uint16_t io_len) +{ + Aml *pci_scope; + Aml *ctrl_dev; + + /* scope for memory hotplug controller device node */ + pci_scope = aml_scope("_SB.PCI0"); + ctrl_dev = aml_scope(stringify(MEMORY_HOTPLUG_DEVICE)); + { + } + aml_append(pci_scope, ctrl_dev); + aml_append(ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {(quoted diff) +0
-0
b/include/hw/acpi/memory_hotplug.hindex 1342adb..b6e9f50 100644include/hw/acpi/memory_hotplug.h +1
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState) void acpi_memory_ospm_status(MemHotplugState *mem_st,ACPIOSTInfoList ***list); +
include/hw/acpi/memory_hotplug.h +2
-0+void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
In reply to Igor MammedovQuoted 28 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-)create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.ohw/acpi/memory_hotplug_acpi_table.c new file +0
-0
hw/acpi/memory_hotplug_acpi_table.c line 2
Quoted 2 lines
hw/acpi/memory_hotplug_acpi_table.c new file +2
-0@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table
You are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
Quoted 8 lines
hw/acpi/memory_hotplug_acpi_table.c new file +8
-0+* +* Copyright (C) 2013 Red Hat Inc +* +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or
hw/acpi/memory_hotplug_acpi_table.c line 20
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c new file +10
-0+* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/
Regarding the license, I was advised to just add a pointer to the main license instead of copying it in each file, something like:
This work is licensed under the terms of the GNU GPL, version 2 or later. See the COPYING file in the top-level directory.
Thanks,
Marcel
Quoted 55 lines
hw/acpi/memory_hotplug_acpi_table.c new file +20
-0+ +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *pci_scope; +Aml *ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + { + } +aml_append (pci_scope, ctrl_dev); +aml_append (ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {include/hw/acpi/memory_hotplug.h +4
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState)void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 28 lines · On Wed, 16 Dec 2015 15:25:46 +0200 Marcel Apfelbaum…
Quoted 27 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5e
---/dev/null
Quoted 8 lines
hw/acpi/Makefile.objs line 2
Quoted 4 lines
+++
b/hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +2
-0@@ -0,0 +1,40 @@ +/* + * Memory hotplug AML code of DSDT ACPI tableYou are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
There could be only one instance of DSDT and I temporarily put converted DSDT bits in SSDT until conversion is complete.
Quoted 3 lines
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
yes, starting from this patch and upto 72nd acpi test fails since patches move DSDT bits into SSDT.
But patch 73, when precompiled DSDT is empty and provides only header, moves converted DSDT content out of SSDT into QEMU generated DSDT, and drops ASL template.
Quoted 90 lines
Quoted 21 lines
hw/acpi/Makefile.objs +6
-0+ * + * Copyright (C) 2013 Red Hat Inc + * + * Author: Igor Mammedov <[email protected]> + * + * This program is free software; you can redistribute it and/ormodify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.hw/acpi/Makefile.objs +7
-0+ + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General PublicQuoted 3 lines
License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */Regarding the license, I was advised to just add a pointer to the main license instead of copying it in each file, something like:
This work is licensed under the terms of the GNU GPL, version 2
or later. See the COPYING file in the top-level directory.Thanks,
MarcelQuoted 55 lines
hw/acpi/Makefile.objs +20
-0+ +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, + uint16_t io_base, uint16_t io_len) +{ + Aml *pci_scope; + Aml *ctrl_dev; + + /* scope for memory hotplug controller device node */ + pci_scope = aml_scope("_SB.PCI0"); + ctrl_dev = aml_scope(stringify(MEMORY_HOTPLUG_DEVICE)); + { + } + aml_append(pci_scope, ctrl_dev); + aml_append(ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {(quoted diff) +0
-0
b/include/hw/acpi/memory_hotplug.hindex 1342adb..b6e9f50 100644include/hw/acpi/memory_hotplug.h +1
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState) void acpi_memory_ospm_status(MemHotplugState *mem_st,ACPIOSTInfoList ***list); +
include/hw/acpi/memory_hotplug.h +2
-0+void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 39 lines · Igor Mammedov
Quoted 28 lines · On Wed, 16 Dec 2015 15:25:46 +0200 Marcel Apfelbaum…
Quoted 27 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5e
---/dev/nullQuoted 8 lines
hw/acpi/Makefile.objs line 2
Quoted 4 lines
+++
b/hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +2
-0@@ -0,0 +1,40 @@ +/* + * Memory hotplug AML code of DSDT ACPI tableYou are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
Quoted 2 lines
There could be only one instance of DSDT and I temporarily put converted DSDT bits in SSDT until conversion is complete.
I understand there can only be one DSDT table, but can't we have a "hybrid" DSDT made from both asl files and C code?
Quoted 6 lines
Quoted 4 lines
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
yes, starting from this patch and upto 72nd acpi test fails since patches move DSDT bits into SSDT.
This can be a problem.
I am thinking of 2 solutions:
1. Disable the iasl tests on patch 1 and re-enable it on patch 73.
2. Go for a "hybrid" DSDT.
If (2) is too complicated, the implication is that all this series must be taken atomically. Of course, (1) or some other idea is needed.
What do you think?
Thanks,
Marcel
Quoted 95 lines
But patch 73, when precompiled DSDT is empty and provides only header, moves converted DSDT content out of SSDT into QEMU generated DSDT, and drops ASL template.
Quoted 90 lines
Quoted 21 lines
hw/acpi/Makefile.objs +6
-0+ * + * Copyright (C) 2013 Red Hat Inc + * + * Author: Igor Mammedov <[email protected]> + * + * This program is free software; you can redistribute it and/ormodify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.hw/acpi/Makefile.objs +7
-0+ + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General PublicQuoted 3 lines
License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */Regarding the license, I was advised to just add a pointer to the main license instead of copying it in each file, something like:
This work is licensed under the terms of the GNU GPL, version 2
or later. See the COPYING file in the top-level directory.Thanks,
MarcelQuoted 55 lines
hw/acpi/Makefile.objs +20
-0+ +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, + uint16_t io_base, uint16_t io_len) +{ + Aml *pci_scope; + Aml *ctrl_dev; + + /* scope for memory hotplug controller device node */ + pci_scope = aml_scope("_SB.PCI0"); + ctrl_dev = aml_scope(stringify(MEMORY_HOTPLUG_DEVICE)); + { + } + aml_append(pci_scope, ctrl_dev); + aml_append(ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {(quoted diff) +0
-0
b/include/hw/acpi/memory_hotplug.hindex 1342adb..b6e9f50 100644include/hw/acpi/memory_hotplug.h +1
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState) void acpi_memory_ospm_status(MemHotplugState *mem_st,ACPIOSTInfoList ***list); +
include/hw/acpi/memory_hotplug.h +2
-0+void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 40 lines · On Thu, 17 Dec 2015 14:14:28 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 39 lines · Igor Mammedov
Quoted 36 lines · On Wed, 16 Dec 2015 15:25:46 +0200 Marcel Apfelbaum…
Quoted 29 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5ehw/acpi/memory_hotplug_acpi_table.c line 2
Quoted 2 lines
hw/acpi/memory_hotplug_acpi_table.c new file +2
-0@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table You are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
Quoted 5 lines
Quoted 2 lines
There could be only one instance of DSDT and I temporarily put converted DSDT bits in SSDT until conversion is complete.
I understand there can only be one DSDT table, but can't we have a "hybrid" DSDT made from both asl files and C code?
I've considered that and it's a little painful but possible to do for some parts of DSDT if ASL moved out from beginning/end of template. However when it comes to moving parts of ASL from the middle of template due to dependencies it all becomes way to too complicated or I'll have to convert almost ALL of DSDT in one patch, but that, even though verifiable via ACPI tests, won't be human review-able chunk.
Quoted 13 lines
Quoted 7 lines
Quoted 5 lines
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
yes, starting from this patch and upto 72nd acpi test fails since patches move DSDT bits into SSDT.
This can be a problem.
I am thinking of 2 solutions:
1. Disable the iasl tests on patch 1 and re-enable it on patch 73.
2. Go for a "hybrid" DSDT.
Quoted 4 lines
If (2) is too complicated, the implication is that all this series must be taken atomically. Of course, (1) or some other idea is needed.
What do you think?
as #2 too complicated, we could go with #1 but I don't think it will gain us much if anything.
Yep, untill whole series is applied ACPI tests will not pass, that will affect bisection with 'make check' on each step but developers can deal with it and just ignore failed tests.
Main goal was to make conversion and make sure that at the end of day it hasn't regressed tests.
I don't think that putting much more efforts to keep interseries ACPI tests check passing is worth of an effort.
Quoted 100 lines
Thanks,
MarcelQuoted 95 lines
But patch 73, when precompiled DSDT is empty and provides only header, moves converted DSDT content out of SSDT into QEMU generated DSDT, and drops ASL template.
Quoted 90 lines
Quoted 21 lines
hw/acpi/memory_hotplug_acpi_table.c new file +6
-0+* +* Copyright (C) 2013 Red Hat Inc +* +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.hw/acpi/memory_hotplug_acpi_table.c new file +7
-0+ +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public Quoted 3 lines
License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */Regarding the license, I was advised to just add a pointer to the main license instead of copying it in each file, something like:
This work is licensed under the terms of the GNU GPL, version 2
or later. See the COPYING file in the top-level directory.Thanks,
MarcelQuoted 55 lines
hw/acpi/memory_hotplug_acpi_table.c new file +20
-0+ +#include <stdbool.h> +#include "hw/acpi/memory_hotplug.h" +#include "include/hw/acpi/pc-hotplug.h" +#include "hw/boards.h" + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *pci_scope; +Aml *ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + { + } +aml_append (pci_scope, ctrl_dev); +aml_append (ctx, pci_scope); +}hw/i386/acpi-build.c +3
-0@@ -928,6 +928,9 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {(quoted diff) +0
-0
b/include/hw/acpi/memory_hotplug.hindex 1342adb..b6e9f50 100644include/hw/acpi/memory_hotplug.h +1
-0@@ -4,6 +4,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/acpi/aml-build.h" /** * MemStatus: @@ -45,4 +46,7 @@ extern const VMStateDescription vmstate_memory_hotplug; vmstate_memory_hotplug, MemHotplugState) void acpi_memory_ospm_status(MemHotplugState *mem_st,ACPIOSTInfoList ***list); +
include/hw/acpi/memory_hotplug.h +2
-0+void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len);#endif
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 48 lines · Igor Mammedov
Quoted 40 lines · On Thu, 17 Dec 2015 14:14:28 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 39 lines · Igor Mammedov
Quoted 36 lines · On Wed, 16 Dec 2015 15:25:46 +0200 Marcel Apfelbaum…
Quoted 29 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5ehw/acpi/memory_hotplug_acpi_table.c line 2
Quoted 2 lines
hw/acpi/memory_hotplug_acpi_table.c new file +2
-0@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table You are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
Quoted 5 lines
Quoted 2 lines
There could be only one instance of DSDT and I temporarily put converted DSDT bits in SSDT until conversion is complete.
I understand there can only be one DSDT table, but can't we have a "hybrid" DSDT made from both asl files and C code?
Quoted 7 lines
I've considered that and it's a little painful but possible to do for some parts of DSDT if ASL moved out from beginning/end of template. However when it comes to moving parts of ASL from the middle of template due to dependencies it all becomes way to too complicated or I'll have to convert almost ALL of DSDT in one patch, but that, even though verifiable via ACPI tests, won't be human review-able chunk.
Yes, I thought it would not be easy.
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 7 lines
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
yes, starting from this patch and upto 72nd acpi test fails since patches move DSDT bits into SSDT.
This can be a problem.
I am thinking of 2 solutions:
1. Disable the iasl tests on patch 1 and re-enable it on patch 73.
2. Go for a "hybrid" DSDT.If (2) is too complicated, the implication is that all this series must be taken atomically. Of course, (1) or some other idea is needed.
Quoted 7 lines
Quoted 1 line
What do you think?
as #2 too complicated, we could go with #1 but I don't think it will gain us much if anything.
Yep, untill whole series is applied ACPI tests will not pass, that will affect bisection with 'make check' on each step but developers can deal with it and just ignore failed tests.
Here I don't agree, think about different tests not working from different reasons, and make check failing because all kind of series, how the developer would know not to take it in consideration? (and what to take?)
Quoted 5 lines
Main goal was to make conversion and make sure that at the end of day it hasn't regressed tests.
I don't think that putting much more efforts to keep interseries ACPI tests check passing is worth of an effort.
I personally think that is a little effort to disable the acpi test in order to keep 'make check' clean.
However, we can ask for another opinion, I CC-ed Michael as the PC maintainer.
Thanks,
Marcel
[...]
Re: [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code
Quoted 90 lines · On Thu, 17 Dec 2015 16:12:55 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 48 lines · Igor Mammedov
Quoted 40 lines · On Thu, 17 Dec 2015 14:14:28 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 39 lines · Igor Mammedov
Quoted 36 lines · On Wed, 16 Dec 2015 15:25:46 +0200 Marcel Apfelbaum…
Quoted 29 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug_acpi_table.c | 40 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 +++ include/hw/acpi/memory_hotplug.h | 4 ++++ 4 files changed, 48insertions(+), 1 deletion(-) create mode 100644
hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.omemory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cnew file mode 100644 index 0000000..25bbf5ehw/acpi/memory_hotplug_acpi_table.c line 2
Quoted 2 lines
hw/acpi/memory_hotplug_acpi_table.c new file +2
-0@@ -0,0 +1,40 @@ +/* +* Memory hotplug AML code of DSDT ACPI table You are advertising as part of the DSDT code, but you are putting in SSDT, right? By the way, maybe the answer is clear, but why are you moving it to SSDT?
Quoted 5 lines
Quoted 2 lines
There could be only one instance of DSDT and I temporarily put converted DSDT bits in SSDT until conversion is complete.
I understand there can only be one DSDT table, but can't we have a "hybrid" DSDT made from both asl files and C code?
Quoted 7 lines
I've considered that and it's a little painful but possible to do for some parts of DSDT if ASL moved out from beginning/end of template. However when it comes to moving parts of ASL from the middle of template due to dependencies it all becomes way to too complicated or I'll have to convert almost ALL of DSDT in one patch, but that, even though verifiable via ACPI tests, won't be human review-able chunk.
Yes, I thought it would not be easy.
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 7 lines
Last thing, from this patch forward (until maybe the last one) make check fails, right? (Specifically the acpi tests)
yes, starting from this patch and upto 72nd acpi test fails since patches move DSDT bits into SSDT.
This can be a problem.
I am thinking of 2 solutions:
1. Disable the iasl tests on patch 1 and re-enable it on patch 73.
2. Go for a "hybrid" DSDT.If (2) is too complicated, the implication is that all this series must be taken atomically. Of course, (1) or some other idea is needed.
Quoted 7 lines
Quoted 1 line
What do you think?
as #2 too complicated, we could go with #1 but I don't think it will gain us much if anything.
Yep, untill whole series is applied ACPI tests will not pass, that will affect bisection with 'make check' on each step but developers can deal with it and just ignore failed tests.
Here I don't agree, think about different tests not working from different reasons, and make check failing because all kind of series, how the developer would know not to take it in consideration? (and what to take?)
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Main goal was to make conversion and make sure that at the end of day it hasn't regressed tests.
I don't think that putting much more efforts to keep interseries ACPI tests check passing is worth of an effort.I personally think that is a little effort to disable the acpi test in order to keep 'make check' clean.
However, we can ask for another opinion, I CC-ed Michael as the PC maintainer.
So far with patches/series, that are changing SSDT or DSDT and obviously breaking ACPI test, policy was submit it without updating test and let maintainer to update ACPI blobs in test after series has been applied, i.e. not disabling it.
I sometimes post an additional patch, that updates ACPI blobs in test as the last in series. But that patch however could be easily discarded or be obsoleted because some another patch changing ACPI tables was committed before and maintainer has to update test himself.
Quoted 6 lines
Thanks,
Marcel[...]
PATCH 26/74 pc: acpi: memhp: move MHPD._STA method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 12 ++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +12 -0
@@ -29,11 +29,23 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 ); +Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); +aml_append (ifctx,aml_return (a_zero)); +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 17 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug_acpi_table.c | 12 ++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-)hw/acpi/memory_hotplug_acpi_table.c +3
-0@@ -29,11 +29,23 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 );
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 44
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c +5
-0+Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); +aml_append (ifctx,aml_return (a_zero));
Hi Igor,
The indentation is a little off here. I understand *why* you are doing it, to emphasize that is an if statement. However this is not clear I think.
What I would do is use the { } parentheses for all the method:
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
{
ifctx = aml_if(aml_equal(a_slots_nr, a_zero))
{
aml_append(ifctx, aml_return(a_zero));
}
aml_append(method, ifctx);
/* present, functioning, decoding, not shown in UI */
aml_append(method, aml_return(aml_int(0xB)));
}
aml_append(ctrl_dev, method);As you can see the, the _STA method is looking good
both as C code and is also easy to see the asl (compare with the original asl).
This is of course only a suggestion, me trying to help :) I see no problem in the conversion itself.
Thanks,
Marcel
Quoted 12 lines
hw/acpi/memory_hotplug_acpi_table.c +4
-0+aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-0
hw/i386/acpi-dsdt-mem-hotplug.dsl line 36
Quoted 2 lines
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-0@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldU835163
nitObj) // _OST status code, write only
Quoted 13 lines
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8- Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
Re: [Qemu-devel] [PATCH 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 50 lines · On Wed, 16 Dec 2015 14:08:17 +0200 Marcel Apfelbaum…
Quoted 17 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug_acpi_table.c | 12 ++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/hw/acpi/memory_hotplug_acpi_table.cindex 25bbf5e..de51717 100644hw/acpi/memory_hotplug_acpi_table.c +3
-0@@ -29,11 +29,23 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 );hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, · line 44
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c +5
-0+Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); +aml_append (ifctx,aml_return (a_zero));Hi Igor,
The indentation is a little off here. I understand *why* you are doing it, to emphasize that is an if statement. However this is not clear I think.
What I would do is use the { } parentheses for all the method:
method = aml_method("_STA", 0, AML_NOTSERIALIZED); { ifctx = aml_if(aml_equal(a_slots_nr, a_zero)) { aml_append(ifctx, aml_return(a_zero)); } aml_append(method, ifctx); /* present, functioning, decoding, not shown in UI */ aml_append(method, aml_return(aml_int(0xB))); } aml_append(ctrl_dev, method);
Quoted 3 lines
As you can see the, the
_STAmethod is looking good both as C code and is also easy to see the asl (compare with the original asl).
sure, I'll add { } parentheses around if body as you suggest.
Quoted 39 lines
This is of course only a suggestion, me trying to help :) I see no problem in the conversion itself.
Thanks,
MarcelQuoted 13 lines
hw/acpi/memory_hotplug_acpi_table.c +4
-0+aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);(quoted diff) +0
-0b/hw/i386/acpi-dsdt-mem-hotplug.dsl index c2bb6a1..b4eacc9 100644
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-0@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OSTQuoted 1 line
event code, write only External(MEMORY_SLOT_OST_STATUS, FieldU835163
nitObj) //
_OSTstatus code, write onlyQuoted 14 lines
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-5- Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI*/
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-3- Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
PATCH v2 26/74 pc: acpi: memhp: move MHPD._STA method into SSDT
In reply to Igor Mammedov---
v2:
- add parentheses around ifctx block
--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +14 -0
@@ -29,11 +29,25 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 ); +Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 50 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- add parentheses around ifctx blockSuggested-by Marcel Apfelbaum <[email protected]>--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-)hw/acpi/memory_hotplug_acpi_table.c +14
-0@@ -29,11 +29,25 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 ); +Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-1@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) {
hw/i386/acpi-dsdt-mem-hotplug.dsl line 40
Quoted 10 lines
hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-7- If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
In reply to Igor MammedovQuoted 18 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- add parentheses around ifctx blockSuggested-by Marcel Apfelbaum <[email protected]>--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-)hw/acpi/memory_hotplug_acpi_table.c +0
-0@@ -29,11 +29,25 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev;
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 41
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c +5
-0+Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 ); +Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */
You know something's wrong if you are documenting C using ASL. In this case, rename ctrl_dev to mem_hotplug_dev, move ifctx zero and slots nr within {} and drop a_ prefix for zero and slots_nr and code will be clear without this comment.
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 50
Quoted 9 lines
hw/acpi/memory_hotplug_acpi_table.c +9
-0+ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method);
Simple unserialized methods that return value depending on input being zero seem very common. How about a helper for this case?
E.g.
aml_method_if_then_else(slots_nr, aml_int(0xB), aml_int(0));
Quoted 24 lines
hw/acpi/memory_hotplug_acpi_table.c +0
-0}aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 24 lines · On Sun, 20 Dec 2015 15:41:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- add parentheses around ifctx blockSuggested-by Marcel Apfelbaum <[email protected]>--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-)hw/acpi/memory_hotplug_acpi_table.c +4
-0@@ -29,11 +29,25 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *pci_scope;Aml *ctrl_dev; +Aml *method; +Aml *ifctx; +Aml *a_zero =aml_int (0 ); +Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 41
Quoted 5 lines
hw/acpi/memory_hotplug_acpi_table.c +1
-0/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +/* MHPD._STA() method */ You know something's wrong if you are documenting C using ASL. In this case, rename
ctrl_devtomem_hotplug_dev, move ifctx zero and slots nr within {} and drop a_ prefix for zero andslots_nrand code will be clear without this comment.
ok, will do it on respin.
Quoted 12 lines
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 50
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c +9
-0+ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method);
Quoted 6 lines
Simple unserialized methods that return value depending on input being zero seem very common. How about a helper for this case?
E.g.
aml_method_if_then_else(slots_nr, aml_int(0xB), aml_int(0));
sure
Quoted 26 lines
Quoted 26 lines
hw/acpi/memory_hotplug_acpi_table.c +0
-0}aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
In reply to Michael S. TsirkinQuoted 1 line · On Sun, 20 Dec 2015 15:41:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
On Wed, Dec 16, 2015 at 03:47:35PM +0100, Igor Mammedov wrote:
[...]
Quoted 11 lines
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 50
Quoted 9 lines
hw/acpi/memory_hotplug_acpi_table.c +9
-0+ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method);
Quoted 6 lines
Simple unserialized methods that return value depending on input being zero seem very common. How about a helper for this case?
E.g.
aml_method_if_then_else(slots_nr, aml_int(0xB), aml_int(0));
I've looked through all _STA methods that exist in DSDT
and though this method for mem hotplug doesn't belong to common pattern, I could use you suggestion for 4 ISA devices.
Or perhaps I can save 2-3 LOC by making common
build_if_else(cond, truectx, false_ctx);
I'll try both but it looks like build_if_else() will be more useful.
And after this series is applied there is a plenty to optimize, for example most of these _STA methods will be gone or replaced by simple _STA = FOO expression.
Quoted 25 lines
Quoted 25 lines
} aml_append(pci_scope, ctrl_dev); aml_append(ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 21 lines · Igor Mammedov
Quoted 1 line · On Sun, 20 Dec 2015 15:41:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
On Wed, Dec 16, 2015 at 03:47:35PM +0100, Igor Mammedov wrote:
[...]
Quoted 16 lines
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 50
Quoted 9 lines
hw/acpi/memory_hotplug_acpi_table.c +9
-0+ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method);Simple unserialized methods that return value depending on input being zero seem very common. How about a helper for this case?
E.g.
Quoted 8 lines
Quoted 1 line
aml_method_if_then_else(slots_nr, aml_int(0xB), aml_int(0));I've looked through all
_STAmethods that exist in DSDT
and though this method for mem hotplug doesn't belong to common pattern, I could use you suggestion for 4 ISA devices.Or perhaps I can save 2-3 LOC by making common
build_if_else(cond, truectx, false_ctx);
I'll try both but it looks likebuild_if_else()will be more useful.
Yes but the issue is it makes code look weird since you need to prepare the context ahead of the time.
Quoted 3 lines
And after this series is applied there is a plenty to optimize, for example most of these
_STAmethods will be gone or replaced by simple_STA= FOO expression.
OK.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
} aml_append(pci_scope, ctrl_dev); aml_append(ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT
Quoted 27 lines · On Tue, 22 Dec 2015 17:11:46 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 26 lines · Igor Mammedov
Quoted 1 line · On Sun, 20 Dec 2015 15:41:22 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
On Wed, Dec 16, 2015 at 03:47:35PM +0100, Igor Mammedov wrote:
[...]
Quoted 11 lines
hw/acpi/memory_hotplug_acpi_table.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 50
Quoted 9 lines
hw/acpi/memory_hotplug_acpi_table.c +9
-0+ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); + { +aml_append (ifctx,aml_return (a_zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (ctrl_dev, method);Quoted 6 lines
Simple unserialized methods that return value depending on input being zero seem very common. How about a helper for this case?
E.g.
aml_method_if_then_else(slots_nr, aml_int(0xB), aml_int(0));I've looked through all
_STAmethods that exist in DSDT
and though this method for mem hotplug doesn't belong to common pattern, I could use you suggestion for 4 ISA devices.
Quoted 6 lines
Quoted 3 lines
Or perhaps I can save 2-3 LOC by making common
build_if_else(cond, truectx, false_ctx);
I'll try both but it looks likebuild_if_else()will be more useful.Yes but the issue is it makes code look weird since you need to prepare the context ahead of the time.
I was thinking using it only for simple true/falsectx where it could be inlined as argument, like:
aml_append(method,
build_if_else(aml_equal(slots_nr, zero),
aml_return(zero), aml_return(aml_int(0xB))));maybe save this idea for after this series to see what is left after cleanups and if it's worth a trouble.
Quoted 33 lines
Quoted 4 lines
And after this series is applied there is a plenty to optimize, for example most of these
_STAmethods will be gone or replaced by simple_STA= FOO expression.OK.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
} aml_append(pci_scope, ctrl_dev); aml_append(ctx, pci_scope);hw/i386/acpi-dsdt-mem-hotplug.dsl +0
-8@@ -35,14 +35,6 @@ External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - Method(_STA, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(0x0) - } - /* present, functioning, decoding, not shown in UI */ - Return(0xB) - } - Mutex (MEMORY_SLOT_LOCK, 0) Method(MEMORY_SLOT_SCAN_METHOD, 0) {Signature · 1 line
1.8.3.1
PATCH 27/74 pc: acpi: memhp: move MHPD.MLCK mutex into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 2 ++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +2 -0
@@ -46,6 +46,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB )));aml_append (ctrl_dev, method); + +aml_append (ctrl_dev,aml_mutex (stringify (MEMORY_SLOT_LOCK ),0 )); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -2
@@ -34,8 +34,7 @@ External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only - - Mutex (MEMORY_SLOT_LOCK, 0) + External(MEMORY_SLOT_LOCK, MutexObj) Method(MEMORY_SLOT_SCAN_METHOD, 0) { If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
Signature · 1 line
1.8.3.1
PATCH 28/74 pc: acpi: memhp: move MHPD.MSCN method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 48 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 27 +-------------------- 2 files changed, 49 insertions(+), 26 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +48 -0
@@ -31,13 +31,19 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,Aml *ctrl_dev;Aml *method;Aml *ifctx; +Aml *else_ctx; +Aml *while_ctx;Aml *a_zero =aml_int (0 ); +Aml *a_one =aml_int (1 );Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER ));/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); { +Aml *a_ctrl_lock =aml_name (stringify (MEMORY_SLOT_LOCK )); +Aml *a_slot_selector =aml_name (stringify (MEMORY_SLOT_SLECTOR )); +/* MHPD._STA() method */ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (a_slots_nr, a_zero));
@@ -48,6 +54,48 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (ctrl_dev, method);aml_append (ctrl_dev,aml_mutex (stringify (MEMORY_SLOT_LOCK ),0 )); + + method =aml_method (stringify (MEMORY_SLOT_SCAN_METHOD ),0 , +AML_NOTSERIALIZED ); + { +Aml *a_idx =aml_local (0 ); + + ifctx =aml_if (aml_equal (a_slots_nr, a_zero)); +aml_append (ifctx,aml_return (a_zero)); +aml_append (method, ifctx); + +aml_append (method,aml_store (aml_int (0 ), a_idx)); +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); + while_ctx =aml_while ( +aml_lless (a_idx, a_slots_nr)); + { +Aml *a_ins_evt =aml_name (stringify (MEMORY_SLOT_INSERT_EVENT )); +Aml *a_rm_evt =aml_name (stringify (MEMORY_SLOT_REMOVE_EVENT )); + +aml_append (while_ctx,aml_store (a_idx, a_slot_selector)); + ifctx =aml_if (aml_equal (a_ins_evt, a_one)); +aml_append (ifctx, +aml_call2 (stringify (MEMORY_SLOT_NOTIFY_METHOD ), + a_idx, a_one)); +aml_append (ifctx,aml_store (a_one, a_ins_evt)); +aml_append (while_ctx, ifctx); + + else_ctx =aml_else (); + ifctx =aml_if (aml_equal (a_rm_evt, a_one)); +aml_append (ifctx, +aml_call2 (stringify (MEMORY_SLOT_NOTIFY_METHOD ), + a_idx,aml_int (3 ))); +aml_append (ifctx,aml_store (a_one, a_rm_evt)); +aml_append (else_ctx, ifctx); +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx,aml_add (a_idx, a_one, a_idx)); + } +aml_append (method, while_ctx); +aml_append (method,aml_release (a_ctrl_lock)); +aml_append (method,aml_return (a_one)); + } +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -26
@@ -13,13 +13,12 @@ * with this program; if not, see <http://www.gnu.org/licenses/>. */ - External(MEMORY_SLOT_NOTIFY_METHOD, MethodObj) + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) Scope(\_SB.PCI0) { Device(MEMORY_HOTPLUG_DEVICE) { Name(_HID, "PNP0A06") Name(_UID, "Memory hotplug resources") - External(MEMORY_SLOTS_NUMBER, IntObj) /* Memory hotplug IO registers */ External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
@@ -28,36 +27,12 @@ External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only - External(MEMORY_SLOT_INSERT_EVENT, FieldUnitObj) // (read) 1 if has a insert event. (write) 1 to clear event - External(MEMORY_SLOT_REMOVE_EVENT, FieldUnitObj) // (read) 1 if has a remove event. (write) 1 to clear event External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) - Method(MEMORY_SLOT_SCAN_METHOD, 0) { - If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { - Return(Zero) - } - - Store(Zero, Local0) // Mem devs iterrator - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - while (LLess(Local0, MEMORY_SLOTS_NUMBER)) { - Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM - If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check - MEMORY_SLOT_NOTIFY_METHOD(Local0, 1) - Store(1, MEMORY_SLOT_INSERT_EVENT) - } Elseif (LEqual(MEMORY_SLOT_REMOVE_EVENT, One)) { // Ejection request - MEMORY_SLOT_NOTIFY_METHOD(Local0, 3) - Store(1, MEMORY_SLOT_REMOVE_EVENT) - } - Add(Local0, One, Local0) // goto next DIMM - } - Release(MEMORY_SLOT_LOCK) - Return(One) - } - Method(MEMORY_SLOT_STATUS_METHOD, 1) { Store(Zero, Local0)
Signature · 1 line
1.8.3.1
PATCH 29/74 pc: acpi: memhp: move MHPD.MRST method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 21 +++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 15 --------------- 2 files changed, 21 insertions(+), 15 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +21 -0
@@ -43,6 +43,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, {Aml *a_ctrl_lock =aml_name (stringify (MEMORY_SLOT_LOCK ));Aml *a_slot_selector =aml_name (stringify (MEMORY_SLOT_SLECTOR )); +Aml *a_ret_val =aml_local (0 ); +Aml *a_slot_arg0 =aml_arg (0 );/* MHPD._STA() method */ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );
@@ -96,6 +98,25 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (a_one)); }aml_append (ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_STATUS_METHOD ),1 , +AML_NOTSERIALIZED ); + { +Aml *a_slot_enabled =aml_name (stringify (MEMORY_SLOT_ENABLED )); + +aml_append (method,aml_store (a_zero, a_ret_val)); +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (a_slot_arg0), + a_slot_selector)); + + ifctx =aml_if (aml_equal (a_slot_enabled, a_one)); +aml_append (ifctx,aml_store (aml_int (0xF ), a_ret_val)); +aml_append (method, ifctx); + +aml_append (method,aml_release (a_ctrl_lock)); +aml_append (method,aml_return (a_ret_val)); + } +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -15
@@ -26,27 +26,12 @@ External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only - External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) - Method(MEMORY_SLOT_STATUS_METHOD, 1) { - Store(Zero, Local0) - - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - - If (LEqual(MEMORY_SLOT_ENABLED, One)) { - Store(0xF, Local0) - } - - Release(MEMORY_SLOT_LOCK) - Return(Local0) - } - Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH 30/74 pc: acpi: memhp: move MHPD.MPXM method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 14 ++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +14 -0
@@ -117,6 +117,20 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (a_ret_val)); }aml_append (ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_PROXIMITY_METHOD ),1 , +AML_NOTSERIALIZED ); + { +Aml *a_proximity =aml_name (stringify (MEMORY_SLOT_PROXIMITY )); + +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (a_slot_arg0), + a_slot_selector)); +aml_append (method,aml_store (a_proximity, a_ret_val)); +aml_append (method,aml_release (a_ctrl_lock)); +aml_append (method,aml_return (a_ret_val)); + } +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -9
@@ -25,7 +25,6 @@ External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only - External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
@@ -96,14 +95,6 @@ Return(MR64) } - Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(MEMORY_SLOT_PROXIMITY, Local0) - Release(MEMORY_SLOT_LOCK) - Return(Local0) - } - Method(MEMORY_SLOT_OST_METHOD, 4) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH 31/74 pc: acpi: memhp: move MHPD.MOST method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 15 +++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +15 -0
@@ -131,6 +131,21 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (a_ret_val)); }aml_append (ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_OST_METHOD ),4 , +AML_NOTSERIALIZED ); + { +Aml *a_ost_evt =aml_name (stringify (MEMORY_SLOT_OST_EVENT )); +Aml *a_ost_status =aml_name (stringify (MEMORY_SLOT_OST_STATUS )); + +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (a_slot_arg0), + a_slot_selector)); +aml_append (method,aml_store (aml_arg (1 ), a_ost_evt)); +aml_append (method,aml_store (aml_arg (2 ), a_ost_status)); +aml_append (method,aml_release (a_ctrl_lock)); + } +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -10
@@ -27,8 +27,6 @@ External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only - External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only - External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only External(MEMORY_SLOT_LOCK, MutexObj) Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
@@ -95,14 +93,6 @@ Return(MR64) } - Method(MEMORY_SLOT_OST_METHOD, 4) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(Arg1, MEMORY_SLOT_OST_EVENT) - Store(Arg2, MEMORY_SLOT_OST_STATUS) - Release(MEMORY_SLOT_LOCK) - } - Method(MEMORY_SLOT_EJECT_METHOD, 2) { Acquire(MEMORY_SLOT_LOCK, 0xFFFF) Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
Signature · 1 line
1.8.3.1
PATCH 32/74 pc: acpi: memhp: move MHPD.MEJ0 method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 13 +++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +13 -0
@@ -146,6 +146,19 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_release (a_ctrl_lock)); }aml_append (ctrl_dev, method); + + method =aml_method (stringify (MEMORY_SLOT_EJECT_METHOD ),2 , +AML_NOTSERIALIZED ); + { +Aml *a_eject =aml_name (stringify (MEMORY_SLOT_EJECT )); + +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (a_slot_arg0), + a_slot_selector)); +aml_append (method,aml_store (a_one, a_eject)); +aml_append (method,aml_release (a_ctrl_lock)); + } +aml_append (ctrl_dev, method); }aml_append (pci_scope, ctrl_dev);aml_append (ctx, pci_scope);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -25,7 +25,6 @@ External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only - External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only External(MEMORY_SLOT_LOCK, MutexObj)
@@ -92,12 +91,5 @@ Release(MEMORY_SLOT_LOCK) Return(MR64) } - - Method(MEMORY_SLOT_EJECT_METHOD, 2) { - Acquire(MEMORY_SLOT_LOCK, 0xFFFF) - Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM - Store(1, MEMORY_SLOT_EJECT) - Release(MEMORY_SLOT_LOCK) - } } // Device() } // Scope()
Signature · 1 line
1.8.3.1
PATCH 33/74 pc: acpi: memhp: move MHPD.MCRS method into SSDT
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 85 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 72 ------------------------------- 2 files changed, 85 insertions(+), 72 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +85 -0
@@ -118,6 +118,91 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); + method =aml_method (stringify (MEMORY_SLOT_CRS_METHOD ),1 , +AML_SERIALIZED ); + { +Aml *a_mr64 =aml_name ("MR64" ); +Aml *a_mr32 =aml_name ("MR32" ); +Aml *a_crs_tmpl =aml_resource_template (); +Aml *a_minl =aml_name ("MINL" ); +Aml *a_minh =aml_name ("MINH" ); +Aml *a_maxl =aml_name ("MAXL" ); +Aml *a_maxh =aml_name ("MAXH" ); +Aml *a_lenl =aml_name ("LENL" ); +Aml *a_lenh =aml_name ("LENH" ); + +aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (a_slot_arg0), + a_slot_selector)); + +aml_append (a_crs_tmpl, +aml_qword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED , +AML_CACHEABLE ,AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFFFFFFFFFE ,0 , +0xFFFFFFFFFFFFFFFF )); +aml_append (method,aml_name_decl ("MR64" , a_crs_tmpl)); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (14 ),"MINL" )); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (18 ),"MINH" )); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (38 ),"LENL" )); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (42 ),"LENH" )); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (22 ),"MAXL" )); +aml_append (method, +aml_create_dword_field (a_mr64,aml_int (26 ),"MAXH" )); + +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_HIGH )), a_minh)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_LOW )), a_minl)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_HIGH )), a_lenh)); +aml_append (method, +aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_LOW )), a_lenl)); + +/* 64-bit math: MAX = MIN + LEN - 1 */ +aml_append (method,aml_add (a_minl, a_lenl, a_maxl)); +aml_append (method,aml_add (a_minh, a_lenh, a_maxh)); + ifctx =aml_if (aml_lless (a_maxl, a_minl)); +aml_append (ifctx,aml_add (a_maxh, a_one, a_maxh)); +aml_append (method, ifctx); + ifctx =aml_if (aml_lless (a_maxl, a_one)); +aml_append (ifctx,aml_subtract (a_maxh, a_one, a_maxh)); +aml_append (method, ifctx); +aml_append (method,aml_subtract (a_maxl, a_one, a_maxl)); + +/* return 32-bit _CRS if addr/size is in low mem */ +/* TODO: remove it since all hotplugged DIMMs are in high mem */ + ifctx =aml_if (aml_equal (a_maxh, a_zero)); + a_crs_tmpl =aml_resource_template (); +aml_append (a_crs_tmpl, +aml_dword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED , +AML_CACHEABLE ,AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFE ,0 , +0xFFFFFFFF )); +aml_append (ifctx,aml_name_decl ("MR32" , a_crs_tmpl)); +aml_append (ifctx, +aml_create_dword_field (a_mr32,aml_int (10 ),"MIN" )); +aml_append (ifctx, +aml_create_dword_field (a_mr32,aml_int (14 ),"MAX" )); +aml_append (ifctx, +aml_create_dword_field (a_mr32,aml_int (22 ),"LEN" )); +aml_append (ifctx,aml_store (a_minl,aml_name ("MIN" ))); +aml_append (ifctx,aml_store (a_maxl,aml_name ("MAX" ))); +aml_append (ifctx,aml_store (a_lenl,aml_name ("LEN" ))); + +aml_append (ifctx,aml_release (a_ctrl_lock)); +aml_append (ifctx,aml_return (a_mr32)); +aml_append (method, ifctx); + +aml_append (method,aml_release (a_ctrl_lock)); +aml_append (method,aml_return (a_mr64)); + } +aml_append (ctrl_dev, method); + method =aml_method (stringify (MEMORY_SLOT_PROXIMITY_METHOD ),1 ,AML_NOTSERIALIZED ); {
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -72
77 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 34/74 pc: acpi: memhp: move MHPD Device into SSDT
In reply to Igor Mammedovmove remnants of MHPD device from DSDT into SSDT.
i.e. Device(MHPD), _UID, _HID
--- hw/acpi/memory_hotplug_acpi_table.c | 6 +++++- hw/i386/acpi-dsdt-mem-hotplug.dsl | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +5 -1
@@ -39,13 +39,17 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); - ctrl_dev =aml_scope (stringify (MEMORY_HOTPLUG_DEVICE )); + ctrl_dev =aml_device (stringify (MEMORY_HOTPLUG_DEVICE )); {Aml *a_ctrl_lock =aml_name (stringify (MEMORY_SLOT_LOCK ));Aml *a_slot_selector =aml_name (stringify (MEMORY_SLOT_SLECTOR ));Aml *a_ret_val =aml_local (0 );Aml *a_slot_arg0 =aml_arg (0 ); +aml_append (ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); +aml_append (ctrl_dev, +aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); +/* MHPD._STA() method */ method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (a_slots_nr, a_zero));
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -7
@@ -14,10 +14,3 @@ */ External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) - - Scope(\_SB.PCI0) { - Device(MEMORY_HOTPLUG_DEVICE) { - Name(_HID, "PNP0A06") - Name(_UID, "Memory hotplug resources") - } // Device() - } // Scope()
Signature · 1 line
1.8.3.1
PATCH 35/74 pc: acpi: factor out memhp code from build_ssdt() into separate function
In reply to Igor Mammedovbefore consolidating memhp code in memory_hotplug_acpi_table.c and for simplifying review, first factor out memhp code into new function build_memory_devices() in i386/acpi-build.c
----
PS:
no functional change, only code movement.
--- hw/i386/acpi-build.c | 239 +++++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 113 deletions(-)
hw/i386/acpi-build.c +126 -113
@@ -903,6 +903,130 @@ static Aml *build_crs(PCIHostState *host,return crs; } +static void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); +aml_append (scope, +aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , + io_base, io_len) + ); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); +aml_append (scope, field); +aml_append (sb_scope, scope); + +for (i =0 ; i < nr_mem; i++) { +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "." +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD); +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , +AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1206,119 +1330,8 @@ build_ssdt(GArray *table_data, GArray *linker, }aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); -aml_append (scope, -aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->mem_hp_io_base, pm->mem_hp_io_base,0 , - pm->mem_hp_io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , - pm->mem_hp_io_base, pm->mem_hp_io_len) - ); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); -aml_append (scope, field); - -aml_append (sb_scope, scope); - -for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , -AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); +build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); {Object *pci_host;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 35/74] pc: acpi: factor out memhp code from build_ssdt() into separate function
Quoted 82 lines · Igor Mammedov
before consolidating memhp code in
memory_hotplug_acpi_table.cand for simplifying review, first factor out memhp code into new functionbuild_memory_devices()ini386/acpi-build.cSigned-off-by Igor Mammedov <[email protected]>----
PS:
no functional change, only code movement.--- hw/i386/acpi-build.c | 239 +++++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 113 deletions(-)hw/i386/acpi-build.c +62
-0@@ -903,6 +903,130 @@ static Aml *build_crs(PCIHostState *host,return crs; } +static void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); +aml_append (scope, +aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , + io_base, io_len) + ); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); + aml_append(field, /* DIMM selector, write only */
hw/i386/acpi-build.c static Aml *build_crs(PCIHostState *host, · line 977
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+ aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32)); +aml_append (field,/* _OST event code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); +aml_append (scope, field); +aml_append (sb_scope, scope); + +for (i =0 ; i < nr_mem; i++) { +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
Again we'll have to clean this up down the line. All #defines should start at the 1st column. And we should not pollute global namespace like this. Would ACPI_MEMHP_BASEPATH be all that bad? I think not. Existing code so can be a separate patch on top.
Quoted 30 lines
hw/i386/acpi-build.c +30
-0+const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
hw/i386/acpi-build.c static Aml *build_crs(PCIHostState *host, · line 1017
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/
BTW this needs a cleanup. It does nothing to clarify what is the method doing, which by now I have forgotten :( ASL is generally barely readable, if one finds documenting C using ASL one knows one is in trouble :)
Quoted 140 lines
hw/i386/acpi-build.c +14
-113+ method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , +AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,@@ -1206,119 +1330,8 @@ build_ssdt(GArray *table_data, GArray *linker, }aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); -aml_append (scope, -aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->mem_hp_io_base, pm->mem_hp_io_base,0 , - pm->mem_hp_io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , - pm->mem_hp_io_base, pm->mem_hp_io_len) - ); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); -aml_append (scope, field); - -aml_append (sb_scope, scope); - -for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , -AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); +build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); {Object *pci_host;Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 35/74] pc: acpi: factor out memhp code from build_ssdt() into separate function
Quoted 91 lines · On Sat, 19 Dec 2015 22:18:14 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 90 lines · Igor Mammedov
before consolidating memhp code in
memory_hotplug_acpi_table.cand for simplifying review, first factor out memhp code into new functionbuild_memory_devices()ini386/acpi-build.cSigned-off-by Igor Mammedov <[email protected]>----
PS:
no functional change, only code movement.--- hw/i386/acpi-build.c | 239 +++++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 113 deletions(-)hw/i386/acpi-build.c +70
-0@@ -903,6 +903,130 @@ static Aml *build_crs(PCIHostState *host,return crs; } +static void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); +aml_append (scope, +aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , + io_base, io_len) + ); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); +aml_append (field,/* read only */ +aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); +aml_append (scope, field); + + field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); +aml_append (scope, field); +aml_append (sb_scope, scope); +
Quoted 8 lines
hw/i386/acpi-build.c static Aml *build_crs(PCIHostState *host, · line 977
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+for (i =0 ; i < nr_mem; i++) { +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."Again we'll have to clean this up down the line. All #defines should start at the 1st column. And we should not pollute global namespace like this. Would
ACPI_MEMHP_BASEPATHbe all that bad? I think not. Existing code so can be a separate patch on top.
I can do it on top of series if you don't object.
Quoted 38 lines
Quoted 38 lines
hw/i386/acpi-build.c +37
-0+const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD); +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } +
Quoted 8 lines
hw/i386/acpi-build.c static Aml *build_crs(PCIHostState *host, · line 1017
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ BTW this needs a cleanup. It does nothing to clarify what is the method doing, which by now I have forgotten :( ASL is generally barely readable, if one finds documenting C using ASL one knows one is in trouble :)
Generally, I've put ASL comments there so that whoever debugs that code could easily correlate ASL seen in a table with C code that produces it.
Quoted 141 lines
Quoted 141 lines
hw/i386/acpi-build.c +14
-113+ method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , +AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,@@ -1206,119 +1330,8 @@ build_ssdt(GArray *table_data, GArray *linker, }aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE )); -aml_append (scope, -aml_name_decl (stringify (MEMORY_SLOTS_NUMBER ),aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->mem_hp_io_base, pm->mem_hp_io_base,0 , - pm->mem_hp_io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -stringify (MEMORY_HOTPLUG_IO_REGION ),AML_SYSTEM_IO , - pm->mem_hp_io_base, pm->mem_hp_io_len) - ); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_ADDR_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_LOW ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_SIZE_HIGH ),32 )); -aml_append (field,/* read only */ -aml_named_field (stringify (MEMORY_SLOT_PROXIMITY ),32 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (stringify (MEMORY_SLOT_ENABLED ),1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_INSERT_EVENT ),1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (stringify (MEMORY_SLOT_REMOVE_EVENT ),1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (stringify (MEMORY_SLOT_EJECT ),1 )); -aml_append (scope, field); - - field =aml_field (stringify (MEMORY_HOTPLUG_IO_REGION ),AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (stringify (MEMORY_SLOT_SLECTOR ),32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_EVENT ),32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (stringify (MEMORY_SLOT_OST_STATUS ),32 )); -aml_append (scope, field); - -aml_append (sb_scope, scope); - -for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (stringify (MEMORY_SLOT_NOTIFY_METHOD ),2 , -AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); +build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, + pm->mem_hp_io_len); {Object *pci_host;Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 35/74] pc: acpi: factor out memhp code from build_ssdt() into separate function
Quoted 2 lines · Igor Mammedov
Quoted 1 line
Existing code so can be a separate patch on top.
I can do it on top of series if you don't object.
I suggested this too so I won't object :)
Signature · 1 line
MST
PATCH 36/74 pc: acpi: memhp: move \_GPE._E03 into SSDT
In reply to Igor Mammedovin addition remove no longer needed acpi-dsdt-mem-hotplug.dsl.
--- hw/i386/acpi-build.c | 6 ++++++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 16 ---------------- hw/i386/acpi-dsdt.dsl | 5 ----- hw/i386/q35-acpi-dsdt.dsl | 5 ----- include/hw/acpi/memory_hotplug.h | 5 +++++ include/hw/acpi/pc-hotplug.h | 2 -- 6 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
hw/i386/acpi-build.c +6 -0
@@ -1055,6 +1055,12 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); + scope =aml_scope ("\\_GPE" ); + method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); +aml_append (scope, method); +aml_append (ssdt, scope); +/* Extra PCI root buses are implemented only for i440fx */ bus =find_i440fx ();if (bus) {
hw/i386/acpi-dsdt-mem-hotplug.dsl deleted +0 -16
@@ -1,16 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - - External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
hw/i386/acpi-dsdt.dsl +0 -5
@@ -250,7 +250,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -271,10 +270,6 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } - Method(_E03) { - // Memory hotplug event - \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
hw/i386/q35-acpi-dsdt.dsl +0 -5
@@ -387,7 +387,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -404,10 +403,6 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } - Method(_E03) { - // Memory hotplug event - \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
include/hw/acpi/memory_hotplug.h +5 -0
@@ -47,6 +47,11 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); +#define MEMORY_HOTPLUG_DEVICE MHPD +#define MEMORY_SLOT_SCAN_METHOD MSCN +#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ + stringify(MEMORY_HOTPLUG_DEVICE) "." stringify(MEMORY_SLOT_SCAN_METHOD) +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);#endif
include/hw/acpi/pc-hotplug.h +0 -2
@@ -32,7 +32,6 @@#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -#define MEMORY_HOTPLUG_DEVICE MHPD#define MEMORY_SLOTS_NUMBER MDNR#define MEMORY_HOTPLUG_IO_REGION HPMR#define MEMORY_SLOT_ADDR_LOW MRBL
@@ -54,6 +53,5 @@#define MEMORY_SLOT_PROXIMITY_METHOD MPXM#define MEMORY_SLOT_EJECT_METHOD MEJ0#define MEMORY_SLOT_NOTIFY_METHOD MTFY -#define MEMORY_SLOT_SCAN_METHOD MSCN#endif
Signature · 1 line
1.8.3.1
PATCH 37/74 pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage
In reply to Igor Mammedovmost of MEMORY_foo defines are not shared with ASL anymore and are used only inside of memory_hotplug_acpi_table.c, so move them there and make them strings. As result we can replace stringify(MEMORY_foo) with just MEMORY_foo, which makes code a bit cleaner.
No AML change introduced by this patch.
--- hw/acpi/memory_hotplug_acpi_table.c | 53 +++++++++++++++++-------------------- hw/i386/acpi-build.c | 52 ++++++++++++++++++------------------ include/hw/acpi/memory_hotplug.h | 6 ++--- include/hw/acpi/pc-hotplug.h | 42 ++++++++++++++--------------- 4 files changed, 74 insertions(+), 79 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +24 -29
@@ -35,14 +35,14 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,Aml *while_ctx;Aml *a_zero =aml_int (0 );Aml *a_one =aml_int (1 ); -Aml *a_slots_nr =aml_name (stringify (MEMORY_SLOTS_NUMBER )); +Aml *a_slots_nr =aml_name (MEMORY_SLOTS_NUMBER );/* scope for memory hotplug controller device node */ pci_scope =aml_scope ("_SB.PCI0" ); - ctrl_dev =aml_device (stringify (MEMORY_HOTPLUG_DEVICE )); + ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); { -Aml *a_ctrl_lock =aml_name (stringify (MEMORY_SLOT_LOCK )); -Aml *a_slot_selector =aml_name (stringify (MEMORY_SLOT_SLECTOR )); +Aml *a_ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); +Aml *a_slot_selector =aml_name (MEMORY_SLOT_SLECTOR );Aml *a_ret_val =aml_local (0 );Aml *a_slot_arg0 =aml_arg (0 );
@@ -59,10 +59,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (method,aml_return (aml_int (0xB )));aml_append (ctrl_dev, method); -aml_append (ctrl_dev,aml_mutex (stringify (MEMORY_SLOT_LOCK ),0 )); +aml_append (ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); - method =aml_method (stringify (MEMORY_SLOT_SCAN_METHOD ),0 , -AML_NOTSERIALIZED ); + method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {Aml *a_idx =aml_local (0 );
@@ -75,13 +74,13 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, while_ctx =aml_while (aml_lless (a_idx, a_slots_nr)); { -Aml *a_ins_evt =aml_name (stringify (MEMORY_SLOT_INSERT_EVENT )); -Aml *a_rm_evt =aml_name (stringify (MEMORY_SLOT_REMOVE_EVENT )); +Aml *a_ins_evt =aml_name (MEMORY_SLOT_INSERT_EVENT ); +Aml *a_rm_evt =aml_name (MEMORY_SLOT_REMOVE_EVENT );aml_append (while_ctx,aml_store (a_idx, a_slot_selector)); ifctx =aml_if (aml_equal (a_ins_evt, a_one));aml_append (ifctx, -aml_call2 (stringify (MEMORY_SLOT_NOTIFY_METHOD ), +aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , a_idx, a_one));aml_append (ifctx,aml_store (a_one, a_ins_evt));aml_append (while_ctx, ifctx);
@@ -89,7 +88,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, else_ctx =aml_else (); ifctx =aml_if (aml_equal (a_rm_evt, a_one));aml_append (ifctx, -aml_call2 (stringify (MEMORY_SLOT_NOTIFY_METHOD ), +aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , a_idx,aml_int (3 )));aml_append (ifctx,aml_store (a_one, a_rm_evt));aml_append (else_ctx, ifctx);
@@ -103,10 +102,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); - method =aml_method (stringify (MEMORY_SLOT_STATUS_METHOD ),1 , -AML_NOTSERIALIZED ); + method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); { -Aml *a_slot_enabled =aml_name (stringify (MEMORY_SLOT_ENABLED )); +Aml *a_slot_enabled =aml_name (MEMORY_SLOT_ENABLED );aml_append (method,aml_store (a_zero, a_ret_val));aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF ));
@@ -122,8 +120,7 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); - method =aml_method (stringify (MEMORY_SLOT_CRS_METHOD ),1 , -AML_SERIALIZED ); + method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {Aml *a_mr64 =aml_name ("MR64" );Aml *a_mr32 =aml_name ("MR32" );
@@ -159,13 +156,13 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, aml_create_dword_field(a_mr64, aml_int(26), "MAXH"));aml_append (method, -aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_HIGH )), a_minh)); +aml_store (aml_name (MEMORY_SLOT_ADDR_HIGH ), a_minh));aml_append (method, -aml_store (aml_name (stringify (MEMORY_SLOT_ADDR_LOW )), a_minl)); +aml_store (aml_name (MEMORY_SLOT_ADDR_LOW ), a_minl));aml_append (method, -aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_HIGH )), a_lenh)); +aml_store (aml_name (MEMORY_SLOT_SIZE_HIGH ), a_lenh));aml_append (method, -aml_store (aml_name (stringify (MEMORY_SLOT_SIZE_LOW )), a_lenl)); +aml_store (aml_name (MEMORY_SLOT_SIZE_LOW ), a_lenl));/* 64-bit math: MAX = MIN + LEN - 1 */ aml_append (method,aml_add (a_minl, a_lenl, a_maxl));
@@ -207,10 +204,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); - method =aml_method (stringify (MEMORY_SLOT_PROXIMITY_METHOD ),1 , + method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED ); { -Aml *a_proximity =aml_name (stringify (MEMORY_SLOT_PROXIMITY )); +Aml *a_proximity =aml_name (MEMORY_SLOT_PROXIMITY );aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
@@ -221,11 +218,10 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); - method =aml_method (stringify (MEMORY_SLOT_OST_METHOD ),4 , -AML_NOTSERIALIZED ); + method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); { -Aml *a_ost_evt =aml_name (stringify (MEMORY_SLOT_OST_EVENT )); -Aml *a_ost_status =aml_name (stringify (MEMORY_SLOT_OST_STATUS )); +Aml *a_ost_evt =aml_name (MEMORY_SLOT_OST_EVENT ); +Aml *a_ost_status =aml_name (MEMORY_SLOT_OST_STATUS );aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
@@ -236,10 +232,9 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, }aml_append (ctrl_dev, method); - method =aml_method (stringify (MEMORY_SLOT_EJECT_METHOD ),2 , -AML_NOTSERIALIZED ); + method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); { -Aml *a_eject =aml_name (stringify (MEMORY_SLOT_EJECT )); +Aml *a_eject =aml_name (MEMORY_SLOT_EJECT );aml_append (method,aml_acquire (a_ctrl_lock,0xFFFF )); aml_append(method, aml_store(aml_to_integer(a_slot_arg0),
hw/i386/acpi-build.c +26 -26
125 lines not on this page · raw message
include/hw/acpi/memory_hotplug.h +3 -3
@@ -47,10 +47,10 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); -#define MEMORY_HOTPLUG_DEVICE MHPD -#define MEMORY_SLOT_SCAN_METHOD MSCN +#define MEMORY_HOTPLUG_DEVICE "MHPD" +#define MEMORY_SLOT_SCAN_METHOD "MSCN"#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - stringify(MEMORY_HOTPLUG_DEVICE) "." stringify(MEMORY_SLOT_SCAN_METHOD) + MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);
include/hw/acpi/pc-hotplug.h +21 -21
47 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 38/74 pc: acpi: drop unused CPU_STATUS_LEN from DSDT
In reply to Igor Mammedov--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 1 - 1 file changed, 1 deletion(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -1
@@ -53,7 +53,6 @@ Scope(\_SB) { Sleep(200) } -#define CPU_STATUS_LEN ACPI_GPE_PROC_LEN Method(PRSC, 0) { // Local5 = active cpu bitmap Store(PRS, Local5)
Signature · 1 line
1.8.3.1
PATCH 39/74 pc: acpi: cpuhp: move CPEJ() method to SSDT
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 2 +- hw/acpi/cpu_hotplug_acpi_table.c | 28 ++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 3 ++- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 4 ---- include/hw/acpi/cpu_hotplug.h | 5 +++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 hw/acpi/cpu_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,6 +1,6 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o -common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o +common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o cpu_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
hw/acpi/cpu_hotplug_acpi_table.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/acpi/cpu_hotplug.h" + +void build_cpu_hotplug_aml (Aml *ctx) +{ +Aml *method; +Aml *sb_scope =aml_scope ("_SB" ); + + method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_sleep (200 )); +aml_append (sb_scope, method); + +aml_append (ctx, sb_scope); +}
hw/i386/acpi-build.c +2 -1
@@ -1052,6 +1052,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
@@ -1299,7 +1300,7 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, -aml_return (aml_call2 ("CPEJ" ,aml_int (i),aml_arg (0 ))) +aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) );aml_append (dev, method);
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -4
@@ -48,10 +48,6 @@ Scope(\_SB) { Return (0x0) } } - Method(CPEJ, 2, NotSerialized) { - // _EJ0 method - eject callback - Sleep(200) - } Method(PRSC, 0) { // Local5 = active cpu bitmap
include/hw/acpi/cpu_hotplug.h +5 -0
@@ -14,6 +14,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/pc-hotplug.h" +#include "hw/acpi/aml-build.h" typedef struct AcpiCpuHotplug { MemoryRegion io;
@@ -25,4 +26,8 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,void acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner,AcpiCpuHotplug *gpe_cpu,uint16_t base); + +#define CPU_EJECT_METHOD "CPEJ" + +void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH 40/74 pc: acpi: cpuhp: move CPMA() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 23 +++++++++++++++++++++++ hw/i386/acpi-build.c | 5 +++-- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 13 ------------- include/hw/acpi/cpu_hotplug.h | 2 ++ 4 files changed, 28 insertions(+), 15 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +23 -0
@@ -19,6 +19,29 @@ void build_cpu_hotplug_aml(Aml *ctx) {Aml *method;Aml *sb_scope =aml_scope ("_SB" ); +uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 }; +Aml *a_cpu_id =aml_arg (0 ); +Aml *a_cpu_on =aml_local (0 ); +Aml *a_madt =aml_local (1 ); +Aml *a_cpus_map =aml_name (CPU_CPU_ON_BITMAP ); + +/* +* _MAT method - creates an madt apic buffer +* a_cpu_id = Arg0 = Processor ID = Local APIC ID +* a_cpu_on = Local0 = CPON flag for this cpu +* a_madt = Local1 = Buffer (in madt apic form) to return +*/ + method =aml_method (CPU_MAT_METHOD ,1 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store ( +aml_derefof (aml_index (a_cpus_map, a_cpu_id)), a_cpu_on)); +aml_append (method,aml_store ( +aml_buffer (sizeof (madt_tmpl), madt_tmpl), a_madt)); +/* Update the processor id, lapic id, and enable/disable status */ +aml_append (method,aml_store (a_cpu_id,aml_index (a_madt,aml_int (2 )))); +aml_append (method,aml_store (a_cpu_id,aml_index (a_madt,aml_int (3 )))); +aml_append (method,aml_store (a_cpu_on,aml_index (a_madt,aml_int (4 )))); +aml_append (method,aml_return (a_madt)); +aml_append (sb_scope, method); method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED );aml_append (method,aml_sleep (200 ));
hw/i386/acpi-build.c +3 -2
@@ -1291,7 +1291,8 @@ build_ssdt(GArray *table_data, GArray *linker, dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (aml_call1 ("CPMA" ,aml_int (i)))); +aml_append (method, +aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i))));aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );
@@ -1335,7 +1336,7 @@ build_ssdt(GArray *table_data, GArray *linker,uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ;aml_append (pkg,aml_int (b)); } -aml_append (sb_scope,aml_name_decl ("CPON" , pkg)); +aml_append (sb_scope,aml_name_decl (CPU_CPU_ON_BITMAP , pkg));build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -13
@@ -24,19 +24,6 @@ Scope(\_SB) { External(PRS, FieldUnitObj) /* Methods called by run-time generated SSDT Processor objects */ - Method(CPMA, 1, NotSerialized) { - // _MAT method - create an madt apic buffer - // Arg0 = Processor ID = Local APIC ID - // Local0 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Arg0)), Local0) - // Local1 = Buffer (in madt apic form) to return - Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1) - // Update the processor id, lapic id, and enable/disable status - Store(Arg0, Index(Local1, 2)) - Store(Arg0, Index(Local1, 3)) - Store(Local0, Index(Local1, 4)) - Return (Local1) - } Method(CPST, 1, NotSerialized) { // _STA method - return ON status of cpu // Arg0 = Processor ID = Local APIC ID
include/hw/acpi/cpu_hotplug.h +2 -0
@@ -28,6 +28,8 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base);#define CPU_EJECT_METHOD "CPEJ" +#define CPU_MAT_METHOD "CPMA" +#define CPU_CPU_ON_BITMAP "CPON"void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH 41/74 pc: acpi: cpuhp: move CPST() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 18 ++++++++++++++++++ hw/i386/acpi-build.c | 3 ++- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 12 ------------ include/hw/acpi/cpu_hotplug.h | 1 + 4 files changed, 21 insertions(+), 13 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +18 -0
@@ -18,6 +18,8 @@void build_cpu_hotplug_aml (Aml *ctx) {Aml *method; +Aml *if_ctx; +Aml *else_ctx;Aml *sb_scope =aml_scope ("_SB" );uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 };Aml *a_cpu_id =aml_arg (0 );
@@ -43,6 +45,22 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_return (a_madt));aml_append (sb_scope, method); +/* +* _STA method - return ON status of cpu +* a_cpu_id = Arg0 = Processor ID = Local APIC ID +* a_cpu_on = Local0 = CPON flag for this cpu +*/ + method =aml_method (CPU_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store ( +aml_derefof (aml_index (a_cpus_map, a_cpu_id)), a_cpu_on)); + if_ctx =aml_if (a_cpu_on); +aml_append (if_ctx,aml_return (aml_int (0xF ))); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (aml_int (0x0 ))); +aml_append (method, else_ctx); +aml_append (sb_scope, method); + method =aml_method (CPU_EJECT_METHOD ,2 ,AML_NOTSERIALIZED );aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method);
hw/i386/acpi-build.c +2 -1
@@ -1296,7 +1296,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (aml_call1 ("CPST" ,aml_int (i)))); +aml_append (method, +aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i))));aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );
hw/i386/acpi-dsdt-cpu-hotplug.dsl +0 -12
@@ -24,18 +24,6 @@ Scope(\_SB) { External(PRS, FieldUnitObj) /* Methods called by run-time generated SSDT Processor objects */ - Method(CPST, 1, NotSerialized) { - // _STA method - return ON status of cpu - // Arg0 = Processor ID = Local APIC ID - // Local0 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Arg0)), Local0) - If (Local0) { - Return (0xF) - } Else { - Return (0x0) - } - } - Method(PRSC, 0) { // Local5 = active cpu bitmap Store(PRS, Local5)
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -30,6 +30,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_EJECT_METHOD "CPEJ"#define CPU_MAT_METHOD "CPMA"#define CPU_CPU_ON_BITMAP "CPON" +#define CPU_STATUS_METHOD "CPST"void build_cpu_hotplug_aml (Aml *ctx);#endif
Signature · 1 line
1.8.3.1
PATCH 42/74 pc: acpi: cpuhp: move PRSC() method into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 55 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +-------------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- include/hw/acpi/aml-build.h | 2 ++ include/hw/acpi/cpu_hotplug.h | 1 + include/hw/acpi/pc-hotplug.h | 1 + 8 files changed, 63 insertions(+), 41 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +55 -0
@@ -26,6 +26,8 @@ void build_cpu_hotplug_aml(Aml *ctx)Aml *a_cpu_on =aml_local (0 );Aml *a_madt =aml_local (1 );Aml *a_cpus_map =aml_name (CPU_CPU_ON_BITMAP ); +Aml *a_zero =aml_int (0 ); +Aml *a_one =aml_int (1 );/* * _MAT method - creates an madt apic buffer
@@ -65,5 +67,58 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method); + method =aml_method (stringify (CPU_SCAN_METHOD ),0 ,AML_NOTSERIALIZED ); + { +Aml *while_ctx, *if_ctx2; +Aml *a_bus_check_evt =aml_int (1 ); +Aml *a_remove_evt =aml_int (3 ); +Aml *a_status_map =aml_local (5 );/* Local5 = active cpu bitmap */ +Aml *a_byte =aml_local (2 );/* Local2 = last read byte from bitmap */ +Aml *a_idx =aml_local (0 );/* Processor ID / APIC ID iterator */ +Aml *a_is_cpu_on =aml_local (1 );/* Local1 = CPON flag for cpu */ +Aml *a_status =aml_local (3 );/* Local3 = active state for cpu */ + +aml_append (method,aml_store (aml_name (CPU_STATUS_MAP ), a_status_map)); +aml_append (method,aml_store (a_zero, a_byte)); +aml_append (method,aml_store (a_zero, a_idx)); + +/* While (a_idx < SizeOf(CPON)) */ + while_ctx =aml_while (aml_lless (a_idx,aml_sizeof (a_cpus_map))); +aml_append (while_ctx,aml_store ( +aml_derefof (aml_index (a_cpus_map, a_idx)), a_is_cpu_on)); + + if_ctx =aml_if (aml_and (a_idx,aml_int (0x07 ),NULL )); +/* Shift down previously read bitmap byte */ +aml_append (if_ctx,aml_shiftright (a_byte, a_one, a_byte)); +aml_append (while_ctx, if_ctx); + + else_ctx =aml_else (); +/* Read next byte from cpu bitmap */ +aml_append (else_ctx,aml_store (aml_derefof ( +aml_index (a_status_map,aml_shiftright (a_idx,aml_int (3 ),NULL ))), + a_byte)); +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx, +aml_store (aml_and (a_byte, a_one,NULL ), a_status)); + if_ctx =aml_if (aml_lnot (aml_equal (a_is_cpu_on, a_status))); + +/* State change - update CPON with new state */ +aml_append (if_ctx,aml_store (a_status,aml_index (a_cpus_map, a_idx))); + if_ctx2 =aml_if (aml_equal (a_status, a_one)); +aml_append (if_ctx2, +aml_call2 (AML_NOTIFY_METHOD , a_idx, a_bus_check_evt)); +aml_append (if_ctx, if_ctx2); + else_ctx =aml_else (); +aml_append (else_ctx, +aml_call2 (AML_NOTIFY_METHOD , a_idx, a_remove_evt)); +aml_append (if_ctx, else_ctx); +aml_append (while_ctx, if_ctx); + +aml_append (while_ctx,aml_increment (a_idx));/* go to next cpu */ +aml_append (method, while_ctx); + } +aml_append (sb_scope, method); +aml_append (ctx, sb_scope); }
hw/i386/acpi-build.c +1 -1
@@ -1313,7 +1313,7 @@ build_ssdt(GArray *table_data, GArray *linker,* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ - method =aml_method ("NTFY" ,2 ,AML_NOTSERIALIZED ); + method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED );for (i =0 ; i < acpi_cpus; i++) { ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); aml_append(ifctx,
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -38
@@ -19,42 +19,5 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ - External(NTFY, MethodObj) - External(CPON, PkgObj) - External(PRS, FieldUnitObj) - - /* Methods called by run-time generated SSDT Processor objects */ - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } + External(CPU_SCAN_METHOD, MethodObj) }
hw/i386/acpi-dsdt.dsl +1 -1
@@ -268,7 +268,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { }
hw/i386/q35-acpi-dsdt.dsl +1 -1
@@ -401,7 +401,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { }
include/hw/acpi/aml-build.h +2 -0
@@ -16,6 +16,8 @@#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" +#define AML_NOTIFY_METHOD "NTFY" + typedef enum { AML_NO_OPCODE = 0,/* has only data */ AML_OPCODE, /* has opcode optionally followed by data */
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -31,6 +31,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_MAT_METHOD "CPMA"#define CPU_CPU_ON_BITMAP "CPON"#define CPU_STATUS_METHOD "CPST" +#define CPU_STATUS_MAP "PRS"void build_cpu_hotplug_aml (Aml *ctx);#endif
include/hw/acpi/pc-hotplug.h +1 -0
@@ -28,6 +28,7 @@#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES +#define CPU_SCAN_METHOD PRSC#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
Signature · 1 line
1.8.3.1
PATCH 43/74 pc: acpi: cpuhp: move \_GPE._E02() into SSDT
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 2 +- hw/i386/acpi-build.c | 12 +++++++++--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 23 ----------------------- hw/i386/acpi-dsdt.dsl | 9 --------- hw/i386/q35-acpi-dsdt.dsl | 9 --------- include/hw/acpi/cpu_hotplug.h | 1 + include/hw/acpi/pc-hotplug.h | 1 - 7 files changed, 11 insertions(+), 46 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl
hw/acpi/cpu_hotplug_acpi_table.c +1 -1
@@ -67,7 +67,7 @@ void build_cpu_hotplug_aml(Aml *ctx)aml_append (method,aml_sleep (200 ));aml_append (sb_scope, method); - method =aml_method (stringify (CPU_SCAN_METHOD ),0 ,AML_NOTSERIALIZED ); + method =aml_method (CPU_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {Aml *while_ctx, *if_ctx2;Aml *a_bus_check_evt =aml_int (1 );
hw/i386/acpi-build.c +9 -3
@@ -1057,9 +1057,15 @@ build_ssdt(GArray *table_data, GArray *linker, pm->mem_hp_io_len); scope =aml_scope ("\\_GPE" ); - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); + { + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); +aml_append (scope, method); + + method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); +aml_append (scope, method); + }aml_append (ssdt, scope);/* Extra PCI root buses are implemented only for i440fx */
hw/i386/acpi-dsdt-cpu-hotplug.dsl deleted +0 -23
@@ -1,23 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/**************************************************************** - * CPU hotplug - ****************************************************************/ - -Scope(\_SB) { - /* Objects filled in by run-time generated SSDT */ - External(CPU_SCAN_METHOD, MethodObj) -}
hw/i386/acpi-dsdt.dsl +0 -9
@@ -247,11 +247,6 @@ DefinitionBlock ( } } -#include "hw/acpi/pc-hotplug.h" -#define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE -#include "acpi-dsdt-cpu-hotplug.dsl" - - /**************************************************************** * General purpose events ****************************************************************/
@@ -266,10 +261,6 @@ DefinitionBlock ( \_SB.PCI0.PCNT() Release(\_SB.PCI0.BLCK) } - Method(_E02) { - // CPU hotplug event - \_SB.CPU_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
hw/i386/q35-acpi-dsdt.dsl +0 -9
@@ -384,11 +384,6 @@ DefinitionBlock ( define_gsi_link(GSIH, 0, 0x17) } -#include "hw/acpi/pc-hotplug.h" -#define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE -#include "acpi-dsdt-cpu-hotplug.dsl" - - /**************************************************************** * General purpose events ****************************************************************/
@@ -399,10 +394,6 @@ DefinitionBlock ( } Method(_L01) { } - Method(_E02) { - // CPU hotplug event - \_SB.CPU_SCAN_METHOD() - } Method(_L04) { } Method(_L05) {
include/hw/acpi/cpu_hotplug.h +1 -0
@@ -32,6 +32,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_CPU_ON_BITMAP "CPON"#define CPU_STATUS_METHOD "CPST"#define CPU_STATUS_MAP "PRS" +#define CPU_SCAN_METHOD "PRSC"void build_cpu_hotplug_aml (Aml *ctx);#endif
include/hw/acpi/pc-hotplug.h +0 -1
@@ -28,7 +28,6 @@#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES -#define CPU_SCAN_METHOD PRSC#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
Signature · 1 line
1.8.3.1
PATCH 44/74 pc: acpi: factor out cpu hotplug code from build_ssdt() into separate function
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 174 ++++++++++++++++++++++++++++----------------------- 1 file changed, 94 insertions(+), 80 deletions(-)
hw/i386/acpi-build.c +94 -80
@@ -765,6 +765,98 @@ static void crs_replace_with_free_ranges(GPtrArray *ranges,g_ptr_array_free (free_ranges, false); } +static void build_processor_devices (Aml *sb_scope,unsigned acpi_cpus, +AcpiCpuInfo *cpu,AcpiPmInfo *pm) +{ +int i; +Aml *dev; +Aml *crs; +Aml *pkg; +Aml *field; +Aml *ifctx; +Aml *method; + +/* The current AML generator can cover the APIC ID range [0..255], +* inclusive, for VCPU hotplug. */ +QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); +g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT ); + +/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ + dev =aml_device ("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE )); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); +aml_append (dev, +aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" )) + ); +/* device present, functioning, decoding, not shown in UI */ +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , pm->cpu_hp_io_base, pm->cpu_hp_io_base,1 , + pm->cpu_hp_io_len) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (sb_scope, dev); +/* declare CPU hotplug MMIO region and PRS field to access it */ +aml_append (sb_scope,aml_operation_region ( +"PRST" ,AML_SYSTEM_IO , pm->cpu_hp_io_base, pm->cpu_hp_io_len)); + field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRS" ,256 )); +aml_append (sb_scope, field); + +/* build Processor object for each processor */ +for (i =0 ; i < acpi_cpus; i++) { + dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); + + method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i)))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i)))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) + ); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build this code: +* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} +*/ +/* Arg0 = Processor ID = APIC ID */ + method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < acpi_cpus; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("CP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); + +/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" +* +* Note: The ability to create variable-sized packages was first +* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages +* ith up to 255 elements. Windows guests up to win2k8 fail when +* VarPackageOp is used. +*/ + pkg = acpi_cpus <=255 ?aml_package (acpi_cpus) : +aml_varpackage (acpi_cpus); + +for (i =0 ; i < acpi_cpus; i++) { +uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ; +aml_append (pkg,aml_int (b)); + } +aml_append (sb_scope,aml_name_decl (CPU_CPU_ON_BITMAP , pkg)); +} +static Aml *build_crs (PCIHostState *host,GPtrArray *io_ranges,GPtrArray *mem_ranges) {
@@ -1034,8 +1126,7 @@ build_ssdt(GArray *table_data, GArray *linker, {MachineState *machine =MACHINE (qdev_get_machine ());uint32_t nr_mem = machine->ram_slots; -unsigned acpi_cpus = guest_info->apic_id_limit; -Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field, *ifctx; +Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field;PCIBus *bus =NULL ;GPtrArray *io_ranges =g_ptr_array_new_with_free_func (crs_range_free);GPtrArray *mem_ranges =g_ptr_array_new_with_free_func (crs_range_free);
@@ -1044,10 +1135,6 @@ build_ssdt(GArray *table_data, GArray *linker,int i; ssdt =init_aml_allocator (); -/* The current AML generator can cover the APIC ID range [0..255], -* inclusive, for VCPU hotplug. */ -QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); -g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT );/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader));
@@ -1270,80 +1357,7 @@ build_ssdt(GArray *table_data, GArray *linker, sb_scope =aml_scope ("\\_SB" ); { -/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ - dev =aml_device ("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE )); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); -aml_append (dev, -aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" )) - ); -/* device present, functioning, decoding, not shown in UI */ -aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->cpu_hp_io_base, pm->cpu_hp_io_base,1 , - pm->cpu_hp_io_len) - ); -aml_append (dev,aml_name_decl ("_CRS" , crs)); -aml_append (sb_scope, dev); -/* declare CPU hotplug MMIO region and PRS field to access it */ -aml_append (sb_scope,aml_operation_region ( -"PRST" ,AML_SYSTEM_IO , pm->cpu_hp_io_base, pm->cpu_hp_io_len)); - field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,aml_named_field ("PRS" ,256 )); -aml_append (sb_scope, field); - -/* build Processor object for each processor */ -for (i =0 ; i < acpi_cpus; i++) { - dev =aml_processor (i,0 ,0 ,"CP%.02X" , i); - - method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (i)))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (i)))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (i),aml_arg (0 ))) - ); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build this code: -* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} -*/ -/* Arg0 = Processor ID = APIC ID */ - method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < acpi_cpus; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("CP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); - -/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" -* -* Note: The ability to create variable-sized packages was first -* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages -* ith up to 255 elements. Windows guests up to win2k8 fail when -* VarPackageOp is used. -*/ - pkg = acpi_cpus <=255 ?aml_package (acpi_cpus) : -aml_varpackage (acpi_cpus); - -for (i =0 ; i < acpi_cpus; i++) { -uint8_t b =test_bit (i, cpu->found_cpus) ?0x01 :0x00 ; -aml_append (pkg,aml_int (b)); - } -aml_append (sb_scope,aml_name_decl (CPU_CPU_ON_BITMAP , pkg)); +build_processor_devices (sb_scope, guest_info->apic_id_limit, cpu, pm);build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
Signature · 1 line
1.8.3.1
PATCH 45/74 pc: acpi: move HPET from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-hpet.dsl | 48 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 3 --- hw/timer/hpet.c | 2 +- include/hw/timer/hpet.h | 1 + 6 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
hw/i386/acpi-build.c +53 -0
@@ -50,6 +50,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h" #include "hw/i386/intel_iommu.h" +#include "hw/timer/hpet.h" #include "hw/i386/q35-acpi-dsdt.hex" #include "hw/i386/acpi-dsdt.hex"
@@ -1119,6 +1120,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (sb_scope, method); } +static void build_hpet_aml (Aml *table) +{ +Aml *crs; +Aml *field; +Aml *method; +Aml *if_ctx; +Aml *scope =aml_scope ("_SB" ); +Aml *dev =aml_device ("HPET" ); +Aml *a_zero =aml_int (0 ); +Aml *a_id =aml_local (0 ); +Aml *a_period =aml_local (1 ); + +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0103" ))); +aml_append (dev,aml_name_decl ("_UID" , a_zero)); + +aml_append (dev,aml_operation_region ("HPTM" ,AML_SYSTEM_MEMORY , +HPET_BASE ,HPET_LEN )); + field =aml_field ("HPTM" ,AML_DWORD_ACC ,AML_LOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("VEND" ,32 )); +aml_append (field,aml_named_field ("PRD" ,32 )); +aml_append (dev, field); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("VEND" ), a_id)); +aml_append (method,aml_store (aml_name ("PRD" ), a_period)); +aml_append (method,aml_shiftright (a_id,aml_int (16 ), a_id)); + if_ctx =aml_if (aml_lor ( +aml_equal (a_id, a_zero), +aml_equal (a_id,aml_int (0xffff )))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + + if_ctx =aml_if (aml_lor ( +aml_equal (a_period, a_zero), +aml_lgreater (a_period,aml_int (100000000 )))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + +aml_append (method,aml_return (aml_int (0x0F ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs, +aml_memory32_fixed (HPET_BASE ,HPET_LEN ,AML_READ_ONLY ) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1139,6 +1191,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-hpet.dsl deleted +0 -48
48 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -2
@@ -41,8 +41,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - /**************************************************************** * PIIX4 PM ****************************************************************/
hw/i386/q35-acpi-dsdt.dsl +0 -3
@@ -115,9 +115,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - - /**************************************************************** * LPC ISA bridge ****************************************************************/
hw/timer/hpet.c +1 -1
@@ -713,7 +713,7 @@ static void hpet_init(Object *obj)HPETState *s =HPET (obj);/* HPET Area */ -memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,0x400 ); +memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,HPET_LEN );sysbus_init_mmio (sbd, &s->iomem); }
include/hw/timer/hpet.h +1 -0
@@ -16,6 +16,7 @@#include "qom/object.h" #define HPET_BASE 0xfed00000 +#define HPET_LEN 0x400#define HPET_CLK_PERIOD 10/* 10 ns*/ #define FS_PER_NS 1000000/* 1000000 femtoseconds == 1 ns */
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 45/74] pc: acpi: move HPET from DSDT to SSDT
Quoted 28 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-hpet.dsl | 48 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 3 --- hw/timer/hpet.c | 2 +- include/hw/timer/hpet.h | 1 + 6 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-hpet.dslhw/i386/acpi-build.c +2
-0@@ -50,6 +50,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h" #include "hw/i386/intel_iommu.h" +#include "hw/timer/hpet.h" #include "hw/i386/q35-acpi-dsdt.hex" #include "hw/i386/acpi-dsdt.hex" @@ -1119,6 +1120,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (sb_scope, method); } +static void build_hpet_aml (Aml *table)
hw/i386/acpi-build.c static void build_memory_devices(Aml *sb_scope, int nr_mem, · line 1133
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+{ +Aml *crs; +Aml *field; +Aml *method; +Aml *if_ctx; +Aml *scope =aml_scope ("_SB" ); +Aml *dev =aml_device ("HPET" ); +Aml *a_zero =aml_int (0 ); +Aml *a_id =aml_local (0 ); +Aml *a_period =aml_local (1 );
This one really jumps out, but it's all over the place. Please drop these a_ prefixes all over, they don't help.
Quoted 12 lines
hw/i386/acpi-build.c +12
-0+ +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0103" ))); +aml_append (dev,aml_name_decl ("_UID" , a_zero)); + +aml_append (dev,aml_operation_region ("HPTM" ,AML_SYSTEM_MEMORY , +HPET_BASE ,HPET_LEN )); + field =aml_field ("HPTM" ,AML_DWORD_ACC ,AML_LOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("VEND" ,32 )); +aml_append (field,aml_named_field ("PRD" ,32 )); +aml_append (dev, field); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );
hw/i386/acpi-build.c static void build_memory_devices(Aml *sb_scope, int nr_mem, · line 1155
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+aml_append (method,aml_store (aml_name ("VEND" ), a_id)); +aml_append (method,aml_store (aml_name ("PRD" ), a_period)); +aml_append (method,aml_shiftright (a_id,aml_int (16 ), a_id)); + if_ctx =aml_if (aml_lor ( +aml_equal (a_id, a_zero), +aml_equal (a_id,aml_int (0xffff )))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + + if_ctx = aml_if(aml_lor(
Don't split lines like this please.
Quoted 138 lines
hw/i386/acpi-build.c +19
-0+aml_equal (a_period, a_zero), + aml_lgreater(a_period, aml_int(100000000)))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + +aml_append (method,aml_return (aml_int (0x0F ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs, +aml_memory32_fixed (HPET_BASE ,HPET_LEN ,AML_READ_ONLY ) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,@@ -1139,6 +1191,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);hw/i386/acpi-dsdt-hpet.dsl deleted +0
-48@@ -1,48 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/**************************************************************** - * HPET - ****************************************************************/ - -Scope(\_SB) { - Device(HPET) { - Name(_HID, EISAID("PNP0103")) - Name(_UID, 0) - OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400) - Field(HPTM, DWordAcc, Lock, Preserve) { - VEND, 32, - PRD, 32, - } - Method(_STA, 0, NotSerialized) { - Store(VEND, Local0) - Store(PRD, Local1) - ShiftRight(Local0, 16, Local0) - If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) { - Return (0x0) - } - If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) { - Return (0x0) - } - Return (0x0F) - } - Name(_CRS, ResourceTemplate() { - Memory32Fixed(ReadOnly, - 0xFED00000, // Address Base - 0x00000400, // Address Length - ) - }) - } -}hw/i386/acpi-dsdt.dsl +0
-2@@ -41,8 +41,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - /**************************************************************** * PIIX4 PM ****************************************************************/hw/i386/q35-acpi-dsdt.dsl +0
-3@@ -115,9 +115,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - - /**************************************************************** * LPC ISA bridge ****************************************************************/hw/timer/hpet.c +1
-1@@ -713,7 +713,7 @@ static void hpet_init(Object *obj)HPETState *s =HPET (obj);/* HPET Area */ -memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,0x400 ); +memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,HPET_LEN );sysbus_init_mmio (sbd, &s->iomem); }include/hw/timer/hpet.h +1
-0@@ -16,6 +16,7 @@#include "qom/object.h" #define HPET_BASE 0xfed00000 +#define HPET_LEN 0x400#define HPET_CLK_PERIOD 10/* 10 ns*/ #define FS_PER_NS 1000000/* 1000000 femtoseconds == 1 ns */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 45/74] pc: acpi: move HPET from DSDT to SSDT
Quoted 28 lines · On Sat, 19 Dec 2015 21:50:41 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 27 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-hpet.dsl | 48 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 3 --- hw/timer/hpet.c | 2 +- include/hw/timer/hpet.h | 1 + 6 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-hpet.dslhw/i386/acpi-build.c +1
-0@@ -50,6 +50,7 @@#include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h" #include "hw/i386/intel_iommu.h" +#include "hw/timer/hpet.h" #include "hw/i386/q35-acpi-dsdt.hex" #include "hw/i386/acpi-dsdt.hex" @@ -1119,6 +1120,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (sb_scope, method); }
Quoted 14 lines
hw/i386/acpi-build.c static void build_memory_devices(Aml *sb_scope, int nr_mem, · line 1133
Quoted 11 lines
hw/i386/acpi-build.c +11
-0+static void build_hpet_aml (Aml *table) +{ +Aml *crs; +Aml *field; +Aml *method; +Aml *if_ctx; +Aml *scope =aml_scope ("_SB" ); +Aml *dev =aml_device ("HPET" ); +Aml *a_zero =aml_int (0 ); +Aml *a_id =aml_local (0 ); +Aml *a_period =aml_local (1 );This one really jumps out, but it's all over the place. Please drop these a_ prefixes all over, they don't help.
sure
Quoted 17 lines
Quoted 17 lines
hw/i386/acpi-build.c +16
-0+ +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0103" ))); +aml_append (dev,aml_name_decl ("_UID" , a_zero)); + +aml_append (dev,aml_operation_region ("HPTM" ,AML_SYSTEM_MEMORY , +HPET_BASE ,HPET_LEN )); + field =aml_field ("HPTM" ,AML_DWORD_ACC ,AML_LOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("VEND" ,32 )); +aml_append (field,aml_named_field ("PRD" ,32 )); +aml_append (dev, field); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_store (aml_name ("VEND" ), a_id)); +aml_append (method,aml_store (aml_name ("PRD" ), a_period)); +aml_append (method,aml_shiftright (a_id,aml_int (16 ), a_id)); + if_ctx = aml_if(aml_lor(
Quoted 8 lines
hw/i386/acpi-build.c static void build_memory_devices(Aml *sb_scope, int nr_mem, · line 1155
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+aml_equal (a_id, a_zero), + aml_equal(a_id, aml_int(0xffff)))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + + if_ctx = aml_if(aml_lor(Don't split lines like this please.
What style would you prefer?
Quoted 139 lines
Quoted 139 lines
hw/i386/acpi-build.c +19
-0+aml_equal (a_period, a_zero), + aml_lgreater(a_period, aml_int(100000000)))); +aml_append (if_ctx,aml_return (a_zero)); +aml_append (method, if_ctx); + +aml_append (method,aml_return (aml_int (0x0F ))); +aml_append (dev, method); + + crs =aml_resource_template (); +aml_append (crs, +aml_memory32_fixed (HPET_BASE ,HPET_LEN ,AML_READ_ONLY ) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,@@ -1139,6 +1191,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);hw/i386/acpi-dsdt-hpet.dsl deleted +0
-48@@ -1,48 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/**************************************************************** - * HPET - ****************************************************************/ - -Scope(\_SB) { - Device(HPET) { - Name(_HID, EISAID("PNP0103")) - Name(_UID, 0) - OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400) - Field(HPTM, DWordAcc, Lock, Preserve) { - VEND, 32, - PRD, 32, - } - Method(_STA, 0, NotSerialized) { - Store(VEND, Local0) - Store(PRD, Local1) - ShiftRight(Local0, 16, Local0) - If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) { - Return (0x0) - } - If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) { - Return (0x0) - } - Return (0x0F) - } - Name(_CRS, ResourceTemplate() { - Memory32Fixed(ReadOnly, - 0xFED00000, // Address Base - 0x00000400, // Address Length - ) - }) - } -}hw/i386/acpi-dsdt.dsl +0
-2@@ -41,8 +41,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - /**************************************************************** * PIIX4 PM ****************************************************************/hw/i386/q35-acpi-dsdt.dsl +0
-3@@ -115,9 +115,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-hpet.dsl" - - /**************************************************************** * LPC ISA bridge ****************************************************************/hw/timer/hpet.c +1
-1@@ -713,7 +713,7 @@ static void hpet_init(Object *obj)HPETState *s =HPET (obj);/* HPET Area */ -memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,0x400 ); +memory_region_init_io (&s->iomem, obj, &hpet_ram_ops, s,"hpet" ,HPET_LEN );sysbus_init_mmio (sbd, &s->iomem); }include/hw/timer/hpet.h +1
-0@@ -16,6 +16,7 @@#include "qom/object.h" #define HPET_BASE 0xfed00000 +#define HPET_LEN 0x400#define HPET_CLK_PERIOD 10/* 10 ns*/ #define FS_PER_NS 1000000/* 1000000 femtoseconds == 1 ns */ Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 45/74] pc: acpi: move HPET from DSDT to SSDT
Quoted 5 lines · Igor Mammedov
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + if_ctx = aml_if(aml_lor(Don't split lines like this please.
What style would you prefer?
break after a comma:
if_ctx = aml_if(aml_lor(aml_equal(a_period, a_zero),
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hw/i386/acpi-build.c +2
-0+aml_equal (a_period, a_zero), + aml_lgreater(a_period, aml_int(100000000))));
PATCH 46/74 pc: acpi: move DBUG() from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 36 ++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt-dbug.dsl | 41 ----------------------------------------- hw/i386/acpi-dsdt.dsl | 2 -- hw/i386/q35-acpi-dsdt.dsl | 2 -- 4 files changed, 36 insertions(+), 45 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl
hw/i386/acpi-build.c +36 -0
@@ -1171,6 +1171,41 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } +static void build_dbg_aml (Aml *table) +{ +Aml *field; +Aml *method; +Aml *while_ctx; +Aml *scope =aml_scope ("\\" ); +Aml *a_buf =aml_local (0 ); +Aml *a_len =aml_local (1 ); +Aml *a_idx =aml_local (2 ); + +aml_append (scope,aml_operation_region ("DBG" ,AML_SYSTEM_IO , +0x0402 ,0x01 )); + field =aml_field ("DBG" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("DBGB" ,8 )); +aml_append (scope, field); + + method =aml_method ("DBUG" ,1 ,AML_NOTSERIALIZED ); + +aml_append (method,aml_to_hexstring (aml_arg (0 ), a_buf)); +aml_append (method,aml_to_buffer (a_buf, a_buf)); +aml_append (method,aml_subtract (aml_sizeof (a_buf),aml_int (1 ), a_len)); +aml_append (method,aml_store (aml_int (0 ), a_idx)); + + while_ctx =aml_while (aml_lless (a_idx, a_len)); +aml_append (while_ctx, +aml_store (aml_derefof (aml_index (a_buf, a_idx)),aml_name ("DBGB" ))); +aml_append (while_ctx,aml_increment (a_idx)); +aml_append (method, while_ctx); + +aml_append (method,aml_store (aml_int (0x0A ),aml_name ("DBGB" ))); +aml_append (scope, method); + +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1191,6 +1226,7 @@ build_ssdt(GArray *table_data, GArray *linker,/* Reserve space for header */ acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader)); +build_dbg_aml (ssdt);build_hpet_aml (ssdt);build_cpu_hotplug_aml (ssdt); build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
hw/i386/acpi-dsdt-dbug.dsl deleted +0 -41
41 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -2
@@ -29,8 +29,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" - Scope(\_SB) { Device(PCI0) { Name(_HID, EisaId("PNP0A03"))
hw/i386/q35-acpi-dsdt.dsl +0 -2
@@ -35,8 +35,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" - Scope(\_SB) { OperationRegion(PCST, SystemIO, 0xae00, 0x0c) OperationRegion(PCSB, SystemIO, 0xae0c, 0x01)
Signature · 1 line
1.8.3.1
PATCH 47/74 pc: acpi: move RTC device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 27 +++++++++++++++++++++++++++ hw/i386/acpi-dsdt-isa.dsl | 9 --------- 2 files changed, 27 insertions(+), 9 deletions(-)
hw/i386/acpi-build.c +27 -0
@@ -1171,6 +1171,32 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } +static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs) +{ +Aml *dev; + + dev =aml_device ("%s" , name); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid))); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} + +static void build_isa_devices_aml (Aml *table) +{ +Aml *crs; +Aml *scope =aml_scope ("_SB.PCI0.ISA" ); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0070 ,0x0070 ,0x10 ,0x02 )); +aml_append (crs,aml_irq_no_flags (8 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 )); +aml_append (scope,build_eisa_device_aml ( +"RTC" ,"PNP0B00" , crs)); + +aml_append (table, scope); +} +static void build_dbg_aml (Aml *table) {Aml *field;
@@ -1228,6 +1254,7 @@ build_ssdt(GArray *table_data, GArray *linker,build_dbg_aml (ssdt);build_hpet_aml (ssdt); +build_isa_devices_aml (ssdt);build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt-isa.dsl +0 -9
@@ -16,15 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(RTC) { - Name(_HID, EisaId("PNP0B00")) - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0070, 0x0070, 0x10, 0x02) - IRQNoFlags() { 8 } - IO(Decode16, 0x0072, 0x0072, 0x02, 0x06) - }) - } - Device(KBD) { Name(_HID, EisaId("PNP0303")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH 48/74 pc: acpi: move KBD device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 20 ++++++++++++++++++-- hw/i386/acpi-dsdt-isa.dsl | 12 ------------ 2 files changed, 18 insertions(+), 14 deletions(-)
hw/i386/acpi-build.c +18 -2
@@ -1171,12 +1171,21 @@ static void build_hpet_aml(Aml *table)aml_append (table, scope); } -static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs) +static Aml * +build_eisa_device_aml (const char *name,const char *hid,Aml *crs, +bool have_sta) {Aml *dev; +Aml *method; +Aml *a_device_present =aml_int (0x0f ); dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid))); +if (have_sta) { + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (a_device_present)); +aml_append (dev, method); + }aml_append (dev,aml_name_decl ("_CRS" , crs));return dev;
@@ -1192,7 +1201,14 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs)); +"RTC" ,"PNP0B00" , crs, false)); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 )); +aml_append (crs,aml_irq_no_flags (1 )); +aml_append (scope,build_eisa_device_aml ( +"KBD" ,"PNP0303" , crs, true));aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -12
@@ -16,18 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(KBD) { - Name(_HID, EisaId("PNP0303")) - Method(_STA, 0, NotSerialized) { - Return (0x0f) - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0060, 0x0060, 0x01, 0x01) - IO(Decode16, 0x0064, 0x0064, 0x01, 0x01) - IRQNoFlags() { 1 } - }) - } - Device(MOU) { Name(_HID, EisaId("PNP0F13")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH 49/74 pc: acpi: move MOU device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 5 +++++ hw/i386/acpi-dsdt-isa.dsl | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-)
hw/i386/acpi-build.c +5 -0
@@ -1210,6 +1210,11 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_eisa_device_aml ("KBD" ,"PNP0303" , crs, true)); + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (12 )); +aml_append (scope,build_eisa_device_aml ( +"MOU" ,"PNP0F13" , crs, true)); +aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -10
@@ -16,16 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(MOU) { - Name(_HID, EisaId("PNP0F13")) - Method(_STA, 0, NotSerialized) { - Return (0x0f) - } - Name(_CRS, ResourceTemplate() { - IRQNoFlags() { 12 } - }) - } - Device(FDC0) { Name(_HID, EisaId("PNP0700")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
PATCH 50/74 pc: acpi: move FDC0 device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++++++++++++------ hw/i386/acpi-dsdt-isa.dsl | 18 ------------------ 2 files changed, 32 insertions(+), 24 deletions(-)
hw/i386/acpi-build.c +32 -6
@@ -1173,17 +1173,34 @@ static void build_hpet_aml(Aml *table)static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs, -bool have_sta) +bool have_sta,const char *present_field) {Aml *dev;Aml *method; -Aml *a_device_present =aml_int (0x0f ); dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid)));if (have_sta) { +Aml *if_ctx; +Aml *else_ctx; +Aml *a_zero =aml_int (0 ); +Aml *a_is_present =aml_local (0 ); +Aml *a_device_present =aml_int (0x0f ); +Aml *a_device_not_present =aml_int (0x00 ); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (a_device_present)); +if (!present_field) { +aml_append (method,aml_return (a_device_present)); + }else { +aml_append (method, +aml_store (aml_name ("%s" , present_field), a_is_present)); + if_ctx =aml_if (aml_equal (a_is_present, a_zero)); +aml_append (if_ctx,aml_return (a_device_not_present)); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (a_device_present)); +aml_append (method, else_ctx); + }aml_append (dev, method); }aml_append (dev,aml_name_decl ("_CRS" , crs));
@@ -1201,19 +1218,28 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs, false)); +"RTC" ,"PNP0B00" , crs, false,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 ));aml_append (crs,aml_irq_no_flags (1 ));aml_append (scope,build_eisa_device_aml ( -"KBD" ,"PNP0303" , crs, true)); +"KBD" ,"PNP0303" , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_irq_no_flags (12 ));aml_append (scope,build_eisa_device_aml ( -"MOU" ,"PNP0F13" , crs, true)); +"MOU" ,"PNP0F13" , crs, true,NULL )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F7 ,0x03F7 ,0x00 ,0x01 )); +aml_append (crs,aml_irq_no_flags (6 )); +aml_append (crs, +aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 )); +aml_append (scope,build_eisa_device_aml ( +"FDC0" ,"PNP0700" , crs, true,"FDEN" ));aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -18
@@ -16,24 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(FDC0) { - Name(_HID, EisaId("PNP0700")) - Method(_STA, 0, NotSerialized) { - Store(FDEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) - IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) - IRQNoFlags() { 6 } - DMA(Compatibility, NotBusMaster, Transfer8) { 2 } - }) - } - Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 50/74] pc: acpi: move FDC0 device from DSDT to SSDT
Quoted 11 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++++++++++++------ hw/i386/acpi-dsdt-isa.dsl | 18 ------------------ 2 files changed, 32 insertions(+), 24 deletions(-)hw/i386/acpi-build.c +0
-0
hw/i386/acpi-build.c static void build_hpet_aml(Aml *table) · line 1176
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -1173,17 +1173,34 @@ static void build_hpet_aml(Aml *table)static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs, -bool have_sta) +bool have_sta,const char *present_field)
At this point, the number of arguments is getting ridiculous. I think you should give it up, and write a function per device type, even if there's a minor code duplication as a result.
As a bonus, we will get reasonably readable function names, e.g. build_floppy_controller()
Quoted 5 lines
hw/i386/acpi-build.c +0
-1{Aml *dev;Aml *method; -Aml *a_device_present =aml_int (0x0f );
hw/i386/acpi-build.c static void build_hpet_aml(Aml *table) · line 1190
Quoted 10 lines
hw/i386/acpi-build.c +7
-0dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid)));if (have_sta) { +Aml *if_ctx; +Aml *else_ctx; +Aml *a_zero =aml_int (0 ); +Aml *a_is_present =aml_local (0 ); +Aml *a_device_present =aml_int (0x0f ); +Aml *a_device_not_present =aml_int (0x00 ); +
What does a_ prefix mean here?
Quoted 57 lines
hw/i386/acpi-build.c +24
-4method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (a_device_present)); +if (!present_field) { +aml_append (method,aml_return (a_device_present)); + }else { +aml_append (method, +aml_store (aml_name ("%s" , present_field), a_is_present)); + if_ctx =aml_if (aml_equal (a_is_present, a_zero)); +aml_append (if_ctx,aml_return (a_device_not_present)); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (a_device_present)); +aml_append (method, else_ctx); + }aml_append (dev, method); }aml_append (dev,aml_name_decl ("_CRS" , crs));@@ -1201,19 +1218,28 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs, false)); +"RTC" ,"PNP0B00" , crs, false,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 ));aml_append (crs,aml_irq_no_flags (1 ));aml_append (scope,build_eisa_device_aml ( -"KBD" ,"PNP0303" , crs, true)); +"KBD" ,"PNP0303" , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_irq_no_flags (12 ));aml_append (scope,build_eisa_device_aml ( -"MOU" ,"PNP0F13" , crs, true)); +"MOU" ,"PNP0F13" , crs, true,NULL )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F7 ,0x03F7 ,0x00 ,0x01 )); +aml_append (crs,aml_irq_no_flags (6 )); +aml_append (crs, +aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 )); +aml_append (scope,build_eisa_device_aml ( +"FDC0" ,"PNP0700" , crs, true,"FDEN" ));aml_append (table, scope); }hw/i386/acpi-dsdt-isa.dsl +0
-0@@ -16,24 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) {
hw/i386/acpi-dsdt-isa.dsl line 28
Quoted 10 lines
hw/i386/acpi-dsdt-isa.dsl +0
-10- Device(FDC0) { - Name(_HID, EisaId("PNP0700")) - Method(_STA, 0, NotSerialized) { - Store(FDEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - }
All these guys have in common is the _STA method. So write a function generating one, and be done with it.
Quoted 14 lines
hw/i386/acpi-dsdt-isa.dsl +0
-8- Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) - IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) - IRQNoFlags() { 6 } - DMA(Compatibility, NotBusMaster, Transfer8) { 2 } - }) - } - Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 50/74] pc: acpi: move FDC0 device from DSDT to SSDT
Quoted 42 lines · On Sat, 19 Dec 2015 21:44:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++++++++++++------ hw/i386/acpi-dsdt-isa.dsl | 18 ------------------ 2 files changed, 32 insertions(+), 24 deletions(-)hw/i386/acpi-build.c +0
-0hw/i386/acpi-build.c static void build_hpet_aml(Aml *table) · line 1176
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -1173,17 +1173,34 @@ static void build_hpet_aml(Aml *table)static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs, -bool have_sta) +bool have_sta,const char *present_field)At this point, the number of arguments is getting ridiculous. I think you should give it up, and write a function per device type, even if there's a minor code duplication as a result.
As a bonus, we will get reasonably readable function names, e.g.
build_floppy_controller()Quoted 5 lines
hw/i386/acpi-build.c +0
-1{Aml *dev;Aml *method; -Aml *a_device_present =aml_int (0x0f );hw/i386/acpi-build.c static void build_hpet_aml(Aml *table) · line 1190
Quoted 10 lines
hw/i386/acpi-build.c +7
-0dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid)));if (have_sta) { +Aml *if_ctx; +Aml *else_ctx; +Aml *a_zero =aml_int (0 ); +Aml *a_is_present =aml_local (0 ); +Aml *a_device_present =aml_int (0x0f ); +Aml *a_device_not_present =aml_int (0x00 ); +
Quoted 1 line
What does a_ prefix mean here?
it's used to distinguish aml variables.
Quoted 58 lines
Quoted 58 lines
hw/i386/acpi-build.c +24
-4method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (a_device_present)); +if (!present_field) { +aml_append (method,aml_return (a_device_present)); + }else { +aml_append (method, +aml_store (aml_name ("%s" , present_field), a_is_present)); + if_ctx =aml_if (aml_equal (a_is_present, a_zero)); +aml_append (if_ctx,aml_return (a_device_not_present)); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (a_device_present)); +aml_append (method, else_ctx); + }aml_append (dev, method); }aml_append (dev,aml_name_decl ("_CRS" , crs));@@ -1201,19 +1218,28 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs, false)); +"RTC" ,"PNP0B00" , crs, false,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 ));aml_append (crs,aml_irq_no_flags (1 ));aml_append (scope,build_eisa_device_aml ( -"KBD" ,"PNP0303" , crs, true)); +"KBD" ,"PNP0303" , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_irq_no_flags (12 ));aml_append (scope,build_eisa_device_aml ( -"MOU" ,"PNP0F13" , crs, true)); +"MOU" ,"PNP0F13" , crs, true,NULL )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F7 ,0x03F7 ,0x00 ,0x01 )); +aml_append (crs,aml_irq_no_flags (6 )); +aml_append (crs, +aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 )); +aml_append (scope,build_eisa_device_aml ( +"FDC0" ,"PNP0700" , crs, true,"FDEN" ));aml_append (table, scope); }hw/i386/acpi-dsdt-isa.dsl +0
-0@@ -16,24 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) {
Quoted 13 lines
hw/i386/acpi-dsdt-isa.dsl line 28
Quoted 10 lines
hw/i386/acpi-dsdt-isa.dsl +0
-10- Device(FDC0) { - Name(_HID, EisaId("PNP0700")) - Method(_STA, 0, NotSerialized) { - Store(FDEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - }All these guys have in common is the
_STAmethod. So write a function generating one, and be done with it.
I'll try to do so.
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-dsdt-isa.dsl +0
-8- Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) - IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) - IRQNoFlags() { 6 } - DMA(Compatibility, NotBusMaster, Transfer8) { 2 } - }) - } - Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 50/74] pc: acpi: move FDC0 device from DSDT to SSDT
Quoted 45 lines · Igor Mammedov
Quoted 42 lines · On Sat, 19 Dec 2015 21:44:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++++++++++++------ hw/i386/acpi-dsdt-isa.dsl | 18 ------------------ 2 files changed, 32 insertions(+), 24 deletions(-)hw/i386/acpi-build.c +0
-0hw/i386/acpi-build.c static void build_hpet_aml(Aml *table) · line 1176
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -1173,17 +1173,34 @@ static void build_hpet_aml(Aml *table)static Aml *build_eisa_device_aml (const char *name,const char *hid,Aml *crs, -bool have_sta) +bool have_sta,const char *present_field)At this point, the number of arguments is getting ridiculous. I think you should give it up, and write a function per device type, even if there's a minor code duplication as a result.
As a bonus, we will get reasonably readable function names, e.g.
build_floppy_controller()Quoted 15 lines
hw/i386/acpi-build.c +7
-1{Aml *dev;Aml *method; -Aml *a_device_present =aml_int (0x0f ); dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid)));if (have_sta) { +Aml *if_ctx; +Aml *else_ctx; +Aml *a_zero =aml_int (0 ); +Aml *a_is_present =aml_local (0 ); +Aml *a_device_present =aml_int (0x0f ); +Aml *a_device_not_present =aml_int (0x00 ); +
Quoted 2 lines
Quoted 1 line
What does a_ prefix mean here?
it's used to distinguish aml variables.
Ow, hungarian notation. Let's not go there please.
Quoted 89 lines
Quoted 58 lines
Quoted 58 lines
hw/i386/acpi-build.c +24
-4method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_return (a_device_present)); +if (!present_field) { +aml_append (method,aml_return (a_device_present)); + }else { +aml_append (method, +aml_store (aml_name ("%s" , present_field), a_is_present)); + if_ctx =aml_if (aml_equal (a_is_present, a_zero)); +aml_append (if_ctx,aml_return (a_device_not_present)); +aml_append (method, if_ctx); + else_ctx =aml_else (); +aml_append (else_ctx,aml_return (a_device_present)); +aml_append (method, else_ctx); + }aml_append (dev, method); }aml_append (dev,aml_name_decl ("_CRS" , crs));@@ -1201,19 +1218,28 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs, false)); +"RTC" ,"PNP0B00" , crs, false,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 ));aml_append (crs,aml_irq_no_flags (1 ));aml_append (scope,build_eisa_device_aml ( -"KBD" ,"PNP0303" , crs, true)); +"KBD" ,"PNP0303" , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_irq_no_flags (12 ));aml_append (scope,build_eisa_device_aml ( -"MOU" ,"PNP0F13" , crs, true)); +"MOU" ,"PNP0F13" , crs, true,NULL )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 )); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F7 ,0x03F7 ,0x00 ,0x01 )); +aml_append (crs,aml_irq_no_flags (6 )); +aml_append (crs, +aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 )); +aml_append (scope,build_eisa_device_aml ( +"FDC0" ,"PNP0700" , crs, true,"FDEN" ));aml_append (table, scope); }hw/i386/acpi-dsdt-isa.dsl +0
-0@@ -16,24 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) {Quoted 13 lines
hw/i386/acpi-dsdt-isa.dsl line 28
Quoted 10 lines
hw/i386/acpi-dsdt-isa.dsl +0
-10- Device(FDC0) { - Name(_HID, EisaId("PNP0700")) - Method(_STA, 0, NotSerialized) { - Store(FDEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - }All these guys have in common is the
_STAmethod. So write a function generating one, and be done with it.I'll try to do so.
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-dsdt-isa.dsl +0
-8- Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) - IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) - IRQNoFlags() { 6 } - DMA(Compatibility, NotBusMaster, Transfer8) { 2 } - }) - } - Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {Signature · 1 line
1.8.3.1
PATCH 51/74 pc: acpi: move LPT device from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 6 ++++++ hw/i386/acpi-dsdt-isa.dsl | 16 ---------------- 2 files changed, 6 insertions(+), 16 deletions(-)
hw/i386/acpi-build.c +6 -0
@@ -1241,6 +1241,12 @@ static void build_isa_devices_aml(Aml *table)aml_append (scope,build_eisa_device_aml ("FDC0" ,"PNP0700" , crs, true,"FDEN" )); + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x0378 ,0x0378 ,0x08 ,0x08 )); +aml_append (crs,aml_irq_no_flags (7 )); +aml_append (scope,build_eisa_device_aml ( +"LPT" ,"PNP0400" , crs, true,"LPEN" )); +aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl +0 -16
@@ -16,22 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device(LPT) { - Name(_HID, EisaId("PNP0400")) - Method(_STA, 0, NotSerialized) { - Store(LPEN, Local0) - If (LEqual(Local0, 0)) { - Return (0x00) - } Else { - Return (0x0F) - } - } - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x0378, 0x0378, 0x08, 0x08) - IRQNoFlags() { 7 } - }) - } - Device(COM1) { Name(_HID, EisaId("PNP0501")) Name(_UID, 0x01)
Signature · 1 line
1.8.3.1
PATCH 52/74 pc: acpi: move COM devices from DSDT to SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 27 ++++++++++++++++++------ hw/i386/acpi-dsdt-isa.dsl | 52 ----------------------------------------------- hw/i386/acpi-dsdt.dsl | 3 --- hw/i386/q35-acpi-dsdt.dsl | 3 --- 4 files changed, 21 insertions(+), 64 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-isa.dsl
hw/i386/acpi-build.c +21 -6
@@ -1172,7 +1172,7 @@ static void build_hpet_aml(Aml *table) }static Aml * -build_eisa_device_aml (const char *name,const char *hid,Aml *crs, +build_eisa_device_aml (const char *name,const char *hid,Aml *uid,Aml *crs,bool have_sta,const char *present_field) {Aml *dev;
@@ -1180,6 +1180,9 @@ build_eisa_device_aml(const char *name, const char *hid, Aml *crs, dev =aml_device ("%s" , name);aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid (hid))); +if (uid) { +aml_append (dev,aml_name_decl ("_UID" , uid)); + }if (have_sta) {Aml *if_ctx;Aml *else_ctx;
@@ -1218,19 +1221,19 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_irq_no_flags (8 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0072 ,0x0072 ,0x02 ,0x06 ));aml_append (scope,build_eisa_device_aml ( -"RTC" ,"PNP0B00" , crs, false,NULL )); +"RTC" ,"PNP0B00" ,NULL , crs, false,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0060 ,0x0060 ,0x01 ,0x01 ));aml_append (crs,aml_io (AML_DECODE16 ,0x0064 ,0x0064 ,0x01 ,0x01 ));aml_append (crs,aml_irq_no_flags (1 ));aml_append (scope,build_eisa_device_aml ( -"KBD" ,"PNP0303" , crs, true,NULL )); +"KBD" ,"PNP0303" ,NULL , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_irq_no_flags (12 ));aml_append (scope,build_eisa_device_aml ( -"MOU" ,"PNP0F13" , crs, true,NULL )); +"MOU" ,"PNP0F13" ,NULL , crs, true,NULL )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x03F2 ,0x03F2 ,0x00 ,0x04 ));
@@ -1239,13 +1242,25 @@ static void build_isa_devices_aml(Aml *table)aml_append (crs,aml_dma (AML_COMPATIBILITY ,AML_NOTBUSMASTER ,AML_TRANSFER8 ,2 ));aml_append (scope,build_eisa_device_aml ( -"FDC0" ,"PNP0700" , crs, true,"FDEN" )); +"FDC0" ,"PNP0700" ,NULL , crs, true,"FDEN" )); crs =aml_resource_template ();aml_append (crs,aml_io (AML_DECODE16 ,0x0378 ,0x0378 ,0x08 ,0x08 ));aml_append (crs,aml_irq_no_flags (7 ));aml_append (scope,build_eisa_device_aml ( -"LPT" ,"PNP0400" , crs, true,"LPEN" )); +"LPT" ,"PNP0400" ,NULL , crs, true,"LPEN" )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x03F8 ,0x03F8 ,0x00 ,0x08 )); +aml_append (crs,aml_irq_no_flags (4 )); +aml_append (scope,build_eisa_device_aml ( +"COM1" ,"PNP0501" ,aml_int (1 ), crs, true,"CAEN" )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 ,0x02F8 ,0x02F8 ,0x00 ,0x08 )); +aml_append (crs,aml_irq_no_flags (3 )); +aml_append (scope,build_eisa_device_aml ( +"COM2" ,"PNP0501" ,aml_int (2 ), crs, true,"CBEN" ));aml_append (table, scope); }
hw/i386/acpi-dsdt-isa.dsl deleted +0 -52
52 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl +0 -3
@@ -80,9 +80,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-isa.dsl" - - /**************************************************************** * PCI hotplug ****************************************************************/
hw/i386/q35-acpi-dsdt.dsl +0 -3
@@ -146,9 +146,6 @@ DefinitionBlock ( } } -#include "acpi-dsdt-isa.dsl" - - /**************************************************************** * PCI IRQs ****************************************************************/
Signature · 1 line
1.8.3.1
PATCH 53/74 pc: acpi: move PIIX4 isa-bridge and pm devices into SSDT
In reply to Igor Mammedovand also move PRQx fields declaration as it can't be split out into separate patch since fields use PCI0.ISA.P40C operation region and OperationRegion must be declared in the same table as a Field that uses it. If this condition is not statisfied Windows will BSOD ans IASL (make check) will error out as well.
For the same reason pm is moved together with isa-bridge as the later refernces P13C OperationRegion from pm device.
--- hw/i386/acpi-build.c | 77 +++++++++++++++++++++++++++++++++++++++++++-- hw/i386/acpi-dsdt.dsl | 52 +++--------------------------- include/hw/acpi/aml-build.h | 1 + 3 files changed, 81 insertions(+), 49 deletions(-)
hw/i386/acpi-build.c +75 -2
@@ -107,6 +107,7 @@ typedef struct AcpiPmInfo { } AcpiPmInfo; typedef struct AcpiMiscInfo { + bool is_piix4; bool has_hpet; TPMVersion tpm_version; const unsigned char *dsdt_code;
@@ -129,10 +130,12 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)assert (!!piix != !!lpc);if (piix) { + info->is_piix4 = true; info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size =sizeof AcpiDsdtAmlCode; }if (lpc) { + info->is_piix4 = false; info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; }
@@ -1300,6 +1303,68 @@ static void build_dbg_aml(Aml *table)aml_append (table, scope); } +static void build_piix4_pci0_int (Aml *table) +{ +Aml *field; +Aml *sb_scope =aml_scope ("_SB" ); + + field =aml_field ("PCI0.ISA.P40C" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRQ0" ,8 )); +aml_append (field,aml_named_field ("PRQ1" ,8 )); +aml_append (field,aml_named_field ("PRQ2" ,8 )); +aml_append (field,aml_named_field ("PRQ3" ,8 )); +aml_append (sb_scope, field); + +aml_append (table, sb_scope); +} + +static void build_piix4_pm (Aml *table) +{ +Aml *dev; +Aml *scope; + + scope =aml_scope ("_SB.PCI0" ); + dev =aml_device ("PX13" ); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0x00010003 ))); + +aml_append (dev,aml_operation_region ("P13C" ,AML_PCI_CONFIG , +0x00 ,0xff )); +aml_append (scope, dev); +aml_append (table, scope); +} + +static void build_piix4_isa_bridge (Aml *table) +{ +Aml *dev; +Aml *scope; +Aml *field; + + scope =aml_scope ("_SB.PCI0" ); + dev =aml_device ("ISA" ); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (0x00010000 ))); + +/* PIIX PCI to ISA irq remapping */ +aml_append (dev,aml_operation_region ("P40C" ,AML_PCI_CONFIG , +0x60 ,0x04 )); +/* enable bits */ + field =aml_field ("^PX13.P13C" ,AML_ANY_ACC ,AML_NOLOCK ,AML_PRESERVE ); +/* Offset(0x5f),, 7, */ +aml_append (field,aml_reserved_field (0x2f8 )); +aml_append (field,aml_reserved_field (7 )); +aml_append (field,aml_named_field ("LPEN" ,1 )); +/* Offset(0x67),, 3, */ +aml_append (field,aml_reserved_field (0x38 )); +aml_append (field,aml_reserved_field (3 )); +aml_append (field,aml_named_field ("CAEN" ,1 )); +aml_append (field,aml_reserved_field (3 )); +aml_append (field,aml_named_field ("CBEN" ,1 )); +aml_append (dev, field); +aml_append (dev,aml_name_decl ("FDEN" ,aml_int (1 ))); + +aml_append (scope, dev); +aml_append (table, scope); +} + static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1321,8 +1386,16 @@ build_ssdt(GArray *table_data, GArray *linker,acpi_data_push (ssdt->buf,sizeof (AcpiTableHeader));build_dbg_aml (ssdt); -build_hpet_aml (ssdt); -build_isa_devices_aml (ssdt); +if (misc->is_piix4) { +build_hpet_aml (ssdt); +build_piix4_pm (ssdt); +build_piix4_isa_bridge (ssdt); +build_isa_devices_aml (ssdt); +build_piix4_pci0_int (ssdt); + }else { +build_hpet_aml (ssdt); +build_isa_devices_aml (ssdt); + }build_cpu_hotplug_aml (ssdt);build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
hw/i386/acpi-dsdt.dsl +5 -47
64 lines not on this page · raw message
include/hw/acpi/aml-build.h +1 -0
@@ -82,6 +82,7 @@ typedef enum {typedef enum {AML_SYSTEM_MEMORY =0X00 ,AML_SYSTEM_IO =0X01 , +AML_PCI_CONFIG =0X02 , }AmlRegionSpace ; typedef enum {
Signature · 1 line
1.8.3.1
PATCH 54/74 pc: acpi: move remaining GPE handlers into SSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)
hw/i386/acpi-build.c +25 -1
@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);
@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); + +for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + } }aml_append (ssdt, scope);
hw/i386/acpi-dsdt.dsl +0 -40
@@ -197,44 +197,4 @@ DefinitionBlock ( Method(_SRS, 1, NotSerialized) { } } } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_E01) { - // PCI hotplug event - Acquire(\_SB.PCI0.BLCK, 0xFFFF) - \_SB.PCI0.PCNT() - Release(\_SB.PCI0.BLCK) - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }
hw/i386/q35-acpi-dsdt.dsl +0 -36
@@ -375,40 +375,4 @@ DefinitionBlock ( define_gsi_link(GSIG, 0, 0x16) define_gsi_link(GSIH, 0, 0x17) } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_L01) { - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
Quoted 12 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)hw/i386/acpi-build.c +0
-0
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1403
Quoted 5 lines
hw/i386/acpi-build.c +1
-1@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" );
Should be in one of the previous patches.
Quoted 132 lines
hw/i386/acpi-build.c +24
-0{ +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); + +for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + } }aml_append (ssdt, scope);hw/i386/acpi-dsdt.dsl +0
-40@@ -197,44 +197,4 @@ DefinitionBlock ( Method(_SRS, 1, NotSerialized) { } } } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_E01) { - // PCI hotplug event - Acquire(\_SB.PCI0.BLCK, 0xFFFF) - \_SB.PCI0.PCNT() - Release(\_SB.PCI0.BLCK) - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }hw/i386/q35-acpi-dsdt.dsl +0
-36@@ -375,40 +375,4 @@ DefinitionBlock ( define_gsi_link(GSIG, 0, 0x16) define_gsi_link(GSIH, 0, 0x17) } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_L01) { - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
In reply to Igor MammedovQuoted 39 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)hw/i386/acpi-build.c +18
-1@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 10 lines
hw/i386/acpi-build.c +7
-0@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); + +for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }
How about we make aml_method accept ... format instead?
Quoted 100 lines
hw/i386/acpi-build.c +0
-0}aml_append (ssdt, scope);hw/i386/acpi-dsdt.dsl +0
-40@@ -197,44 +197,4 @@ DefinitionBlock ( Method(_SRS, 1, NotSerialized) { } } } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_E01) { - // PCI hotplug event - Acquire(\_SB.PCI0.BLCK, 0xFFFF) - \_SB.PCI0.PCNT() - Release(\_SB.PCI0.BLCK) - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }hw/i386/q35-acpi-dsdt.dsl +0
-36@@ -375,40 +375,4 @@ DefinitionBlock ( define_gsi_link(GSIG, 0, 0x16) define_gsi_link(GSIH, 0, 0x17) } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_L01) { - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
Quoted 44 lines · On Sat, 19 Dec 2015 22:34:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 43 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)hw/i386/acpi-build.c +19
-1@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); +
Quoted 8 lines
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }How about we make
aml_methodaccept ... format instead?
ok, I'll do it on respin
Quoted 102 lines
Quoted 102 lines
hw/i386/acpi-build.c +0
-0}aml_append (ssdt, scope);hw/i386/acpi-dsdt.dsl +0
-40@@ -197,44 +197,4 @@ DefinitionBlock ( Method(_SRS, 1, NotSerialized) { } } } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_E01) { - // PCI hotplug event - Acquire(\_SB.PCI0.BLCK, 0xFFFF) - \_SB.PCI0.PCNT() - Release(\_SB.PCI0.BLCK) - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }hw/i386/q35-acpi-dsdt.dsl +0
-36@@ -375,40 +375,4 @@ DefinitionBlock ( define_gsi_link(GSIG, 0, 0x16) define_gsi_link(GSIH, 0, 0x17) } - -/**************************************************************** - * General purpose events - ****************************************************************/ - Scope(\_GPE) { - Name(_HID, "ACPI0006") - - Method(_L00) { - } - Method(_L01) { - } - Method(_L04) { - } - Method(_L05) { - } - Method(_L06) { - } - Method(_L07) { - } - Method(_L08) { - } - Method(_L09) { - } - Method(_L0A) { - } - Method(_L0B) { - } - Method(_L0C) { - } - Method(_L0D) { - } - Method(_L0E) { - } - Method(_L0F) { - } - } }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
In reply to Michael S. TsirkinQuoted 44 lines · On Sat, 19 Dec 2015 22:34:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 43 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)hw/i386/acpi-build.c +19
-1@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); +
Quoted 8 lines
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }How about we make
aml_methodaccept ... format instead?
actually instead of making aml_method(format,...) it would be easier to make it accept Aml* so we could reuse aml_name(format,...) in the end it would look like:
Aml gpe_name = aml_name("_L0%X", i);
aml_method(gpe_name, AML_NOTSERIALIZED);
in addition name object could be reused in other places that reference that method.
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
Quoted 59 lines · Igor Mammedov
Quoted 44 lines · On Sat, 19 Dec 2015 22:34:55 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 43 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/acpi-build.c | 26 +++++++++++++++++++++++++- hw/i386/acpi-dsdt.dsl | 40 ---------------------------------------- hw/i386/q35-acpi-dsdt.dsl | 36 ------------------------------------ 3 files changed, 25 insertions(+), 77 deletions(-)hw/i386/acpi-build.c +19
-1@@ -1400,8 +1400,25 @@ build_ssdt(GArray *table_data, GArray *linker,build_memory_hotplug_aml (ssdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len); - scope =aml_scope ("\\_GPE" ); + scope =aml_scope ("_GPE" ); { +aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); + + method =aml_method ("_L00" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + +if (misc->is_piix4) { + method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +aml_append (scope, method); + }else { + method =aml_method ("_L01" ,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); + } + method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD ));aml_append (scope, method);@@ -1409,6 +1426,13 @@ build_ssdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); +Quoted 8 lines
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }How about we make
aml_methodaccept ... format instead?actually instead of making
aml_method(format,...)it would be easier to make it accept Aml* so we could reuseaml_name(format,...)in the end it would look like:
Quoted 5 lines
Aml
gpe_name=aml_name("_L0%X", i);
aml_method(gpe_name, AML_NOTSERIALIZED);in addition name object could be reused in other places that reference that method.
Except most methods are simple, so maybe do both APIs. Avoiding string duplication is a good idea, but using string constants works just as well.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
On Tue, 22 Dec 2015 11:37:40 +0200
"Michael S. Tsirkin" <[email protected]> wrote:
[...]
Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }How about we make
aml_methodaccept ... format instead?actually instead of making
aml_method(format,...)it would be easier to make it accept Aml* so we could reuseaml_name(format,...)in the end it would look like:Aml
gpe_name=aml_name("_L0%X", i);
aml_method(gpe_name, AML_NOTSERIALIZED);
Quoted 6 lines
Quoted 2 lines
in addition name object could be reused in other places that reference that method.
Except most methods are simple, so maybe do both APIs. Avoiding string duplication is a good idea, but using string constants works just as well.
I don't like having 2 APIs, one with 'Aml* name' and other with 'const char *name' in C. I'd prefer to have just one that suits the majority use cases and
I'm not so comfortable with using format string here directly as it would look weird (at least to me):
aml_method("_L0%X", i, argcount, AML_NOTSERIALIZED);
- static format string check at compile time won't work here
or
aml_method(argcount, AML_NOTSERIALIZED, "_L0%X", i);
- that should be fine except of that argument order doesn't match the way it's in spec, which I'd prefer to keep
so it leaves for me 2 options:
1: use aml_method(aml_name("_L0%X", i), argcount, AML_NOTSERIALIZED)
It's a bit of code churn and not sure if we really need it but I can do if asked for it.
2: just leave it as is for now, because the most of method names
are just string constants. These "_L0%X" will be gone after cleanup, leaving us with only handlers that use string const and do some work.
I can replace g_strdup_printf() with static buffer here if you dislike alloc/free in this patch.
Re: [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers into SSDT
Quoted 29 lines · Igor Mammedov
On Tue, 22 Dec 2015 11:37:40 +0200
"Michael S. Tsirkin" <[email protected]> wrote:[...]
Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1435
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+for (i =4 ; i <=0xF ; i++) { +char *name =g_strdup_printf ("_L0%X" , i); + method =aml_method (name,0 ,AML_NOTSERIALIZED ); +aml_append (scope, method); +g_free (name); + }How about we make
aml_methodaccept ... format instead?actually instead of making
aml_method(format,...)it would be easier to make it accept Aml* so we could reuseaml_name(format,...)in the end it would look like:Aml
gpe_name=aml_name("_L0%X", i);
aml_method(gpe_name, AML_NOTSERIALIZED);Quoted 6 lines
Quoted 2 lines
in addition name object could be reused in other places that reference that method.
Except most methods are simple, so maybe do both APIs. Avoiding string duplication is a good idea, but using string constants works just as well.
I don't like having 2 APIs, one with 'Aml* name' and other with 'const char *name' in C. I'd prefer to have just one that suits the majority use cases and
Quoted 8 lines
I'm not so comfortable with using format string here directly as it would look weird (at least to me):
aml_method("_L0%X", i, argcount, AML_NOTSERIALIZED);
- static format string check at compile time won't work here
or
aml_method(argcount, AML_NOTSERIALIZED, "_L0%X", i);
- that should be fine except of that argument order doesn't match the way it's in spec, which I'd prefer to keep
Just add ... at the end:
aml_method("_L0%X", argcount, AML_NOTSERIALIZED, i);
looks a bit weird if you have to use it, but it's uncommon, and the common case looks simple.
Quoted 5 lines
so it leaves for me 2 options:
1: useaml_method(aml_name("_L0%X", i), argcount, AML_NOTSERIALIZED)
It's a bit of code churn and not sure if we really need it but I can do if asked for it.
Quoted 7 lines
2: just leave it as is for now, because the most of method names
are just string constants. These "_L0%X" will be gone after cleanup, leaving us with only handlers that use string const and do some work.I can replace
g_strdup_printf()with static buffer here if you dislike alloc/free in this patch.
So how about just open-coding this loop for now? That's just about 10 lines of code,
not a big deal.
As you say, will be gone after refactoring.
Signature · 1 line
MST