Open 2.3 development tree

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
pc: acpi-build: make linker table dynamic

linker table is build only once, so if later
during rebuild sizes of other ACPI tables change
pointers will be patched incorrectly due to wrong
offsets leading to tables corruption.

Fix is to rebuild linker table along with the rest
of ACPI tables so that it would have correct offsets.

CC: qemu-stable@nongnu.org
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: acpi-build: place RSDT at fixed offset across reboots

Fixing RSDT location allows pointer to RSDP
be constant and we can keep RSDP file immutable
for the whole instance lifetime.

Which makes this fix suitable for stable, since
migration format doesn't change in addition it
fixes old machine types as well without breaking
compatibility.

CC: qemu-stable@nongnu.org
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: Add pc-[i440fx|q35]-2.3 machine type and pc_compat_2_2() function

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: acpi-build: make RSDP table dynamic

Rebuild RSDP along with other tables to make
building ACPI blob more robust and not depend
on particular tables order.

Use it only with new machine types to avoid
breaking migration since it changes migration
format.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
  fix build error in hw/i386/pc_q35.c due to typo in
    has_imutable_rsdp variable
pc: acpi: fix WindowsXP BSOD when memory hotplug is enabled

ACPI parser in XP considers PNP0A06 devices of CPU and
memory hotplug as duplicates. Adding unique _UID
to CPU hotplug device fixes BSOD.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: acpi: decribe bridge device as not hotpluggable

when bridge hotplug is disabled, i.e. for machine
types less then 2.0, bridge device was created as
hotpluggable by mistake since commit 133a2da.

Fix it by just creating it as a present device.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: acpi-build: cleanup AcpiPmInfo initialization

zero initialize AcpiPmInfo struct to reduce code bloat
a little bit.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: build_append_nameseg(): add padding if necessary

According to ACPI spec NameSeg shorter than 4 characters
must be padded up to 4 characters with "_" symbol.
ACPI 5.0:  20.2.2 "Name Objects Encoding"

Do it in build_append_nameseg() so that caller shouldn't know
or care about it.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  * simplify padding, suggested by: "Michael S. Tsirkin" <mst@redhat.com>
acpi: move generic aml building helpers into dedictated file

the will be later used for composing AML primitives
and all that could be reused later for ARM machines
as well.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add build_append_namestring() helper

Use build_append_namestring() instead of build_append_nameseg()
So user won't have to care whether name is NameSeg, NamePath or
NameString.

See for refernce ACPI 5.0: 20.2.2 Name Objects Encoding

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: drop min-bytes in build_package()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: acpi-build: replace recursive PCI bus tree generation with loop based

it replaces PCI tree structure in SSDT with a set of scopes
describing each PCI bus as a separate scope with a child devices.
It makes code easier to follow and a little bit smaller.

In addition it makes simplier to convert current template
patching approach to completely dynamically generated SSDT
without dependency on IASL, which would allow to drop
template binary blobs from source tree.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: intoduce AML composer aml_append()

Adds the only helper for dynamic AML creation, which
will be used for piecing ASL/AML primitives together
and hiding from user/caller details about how nested
context should be closed/packed leaving less space for
mistakes and neccessity to know how AML should be
encoded, allowing user to conentrate on ASL
representation instead.

For example it will allow to create AML like this:

AcpiAml scope = acpi_scope("PCI0")
AcpiAml dev = acpi_device("E1000")

aml_append(&dev, acpi_name_decl("_ADR", acpi_int(addr)))

aml_append(&scope, dev);

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add acpi_scope() term

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add acpi_device() term

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add acpi_method() term

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add acpi_if() term

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: add acpi_name() & acpi_name_decl() term

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: factor out ACPI const int packing out build_append_value()

so it could be reused for adding plain integer value into AML.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>