OvmfPkg: bump commonly used ACPI table revision numbers

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14151 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: fold macros of unsupported PM1b register blocks into Facp.aslc

Soon we're going to specify Extended Addresses of register blocks in
Generic Address Structure format. The GAS is easy to fill if we want to
posit either "unsupported" (all zero) or a given address in a specific
address space. However deriving "unsupported" just from a macro expanding
to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14152 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: fold macros of unsupported PM2 control reg. block into Facp.aslc

Soon we're going to specify Extended Addresses of register blocks in
Generic Address Structure format. The GAS is easy to fill if we want to
posit either "unsupported" (all zero) or a given address in a specific
address space. However deriving "unsupported" just from a macro expanding
to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14153 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: fold macros of unsupported GPE1 register block into Facp.aslc

In the next patch we're going to specify Extended Addresses of register
blocks in Generic Address Structure format. The GAS is easy to fill if we
want to posit either "unsupported" (all zero) or a given address in a
specific address space. However deriving "unsupported" just from a macro
expanding to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14154 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: upgrade the FADT to ACPI 2.0 without functional changes

This conversion cannot be split very well into smaller patches. Comparing
version 1 and version 2 (modulo the header fields):

> --- EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
> +++ EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
> @@ -1,14 +1,14 @@
>    EFI_ACPI_DESCRIPTION_HEADER             Header;
>    UINT32                                  FirmwareCtrl;
>    UINT32                                  Dsdt;
> -  UINT8                                   IntModel;
> -  UINT8                                   Reserved1;
> +  UINT8                                   Reserved0;
> +  UINT8                                   PreferredPmProfile;

The INT_MODEL field was present in ACPI 1.0, but eliminated in 2.0.
According to the spec, "platforms should set this field to zero but field
values of one are also allowed to maintain compatibility with ACPI 1.0".
We're setting it to zero.

About Preferred_PM_Profile (taking the place of an 1.0 reserved field),
the specification says:

  This field is set by the OEM to convey the preferred power management
  profile to OSPM. OSPM can use this field to set default power management
  policy parameters during OS installation.

>From <MdePkg/Include/IndustryStandard/Acpi20.h>:

  #define EFI_ACPI_2_0_PM_PROFILE_UNSPECIFIED         0
  #define EFI_ACPI_2_0_PM_PROFILE_DESKTOP             1
  #define EFI_ACPI_2_0_PM_PROFILE_MOBILE              2
  #define EFI_ACPI_2_0_PM_PROFILE_WORKSTATION         3
  #define EFI_ACPI_2_0_PM_PROFILE_ENTERPRISE_SERVER   4
  #define EFI_ACPI_2_0_PM_PROFILE_SOHO_SERVER         5
  #define EFI_ACPI_2_0_PM_PROFILE_APPLIANCE_PC        6

For a virtual machine, "unspecified" is the best choice.

>    UINT16                                  SciInt;
>    UINT32                                  SmiCmd;
>    UINT8                                   AcpiEnable;
>    UINT8                                   AcpiDisable;
>    UINT8                                   S4BiosReq;
> -  UINT8                                   Reserved2;
> +  UINT8                                   PstateCnt;

We've been already treating this field as PSTATE_CNT. No change in value.

>    UINT32                                  Pm1aEvtBlk;
>    UINT32                                  Pm1bEvtBlk;
>    UINT32                                  Pm1aCntBlk;
> @@ -20,11 +20,11 @@
>    UINT8                                   Pm1EvtLen;
>    UINT8                                   Pm1CntLen;
>    UINT8                                   Pm2CntLen;
> -  UINT8                                   PmTmLen;
> +  UINT8                                   PmTmrLen;

(Field renaming artifact.)

>    UINT8                                   Gpe0BlkLen;
>    UINT8                                   Gpe1BlkLen;
>    UINT8                                   Gpe1Base;
> -  UINT8                                   Reserved3;
> +  UINT8                                   CstCnt;

We've been already treating this field as CST_CNT. No change in value.

>    UINT16                                  PLvl2Lat;
>    UINT16                                  PLvl3Lat;
>    UINT16                                  FlushSize;
> @@ -34,7 +34,19 @@
>    UINT8                                   DayAlrm;
>    UINT8                                   MonAlrm;
>    UINT8                                   Century;
> -  UINT8                                   Reserved4;
> -  UINT8                                   Reserved5;
> -  UINT8                                   Reserved6;
> +  UINT16                                  IaPcBootArch;
> +  UINT8                                   Reserved1;

The first two octets are now merged into a 16-bit short; otherwise we've
been treating those as boot architecture flags already (see SVN rev
13615). No change in value.

>    UINT32                                  Flags;

The fixed feature flags are not modified, only the macro names (expanding
to identical values) are updated to ACPI 2.0.

The following fields are all new in ACPI 2.0:

> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  ResetReg;
> +  UINT8                                   ResetValue;

We don't claim support for the reset register yet.

> +  UINT8                                   Reserved2[3];
> +  UINT64                                  XFirmwareCtrl;
> +  UINT64                                  XDsdt;

The 64-bit physical addresses for the FACS and the DSDT are automatically
filled at installation time, see AddTableToList() and DeleteTable() in
"MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c".

> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk;

We specify the extended addresses for the required and supported PM1a
Event & Control, PM Timer, and GPE0 Register Blocks, and zero the rest, in
accordance with the ACPI 1.0 fields.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14155 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: report support for the PIIX3 reset register in the FADT

The value to be written corresponds to hard reset, which is what the ACPI
spec prescribes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14156 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: attempt to trigger cold reset through PIIX3 reset control register

The reset requested via the keyboard controller (port 0x64) is actually a
soft reset, but qemu has supported it since forever (plus qemu has not
distinguished between hard reset and soft reset, although this is changing
now). Therefore leave the current IoWrite() in place for compatibility.

On qemu versions with commit 1ec4ba74 ("PIIX3: reset the VM when the Reset
Control Register's RCPU bit gets set"), use the PIIX3 RCR as first choice.
In the future qemu will act differently on soft vs. hard reset requests,
and we should honor that in ResetCold().

  Writing to ioport 0xCF9 on qemu builds prior to commit 1ec4ba74 should
  have no effect. Access to the PCI host config register went through
  several implementations in qemu. Commit 9f6f0423 ("pci_host: rewrite
  using rwhandler") seems safe, both before and after.

  Commit d0ed8076 ("pci_host: convert conf index and data ports to memory
  API") inadvertently dropped the alignment/size check, causing a boot
  regression on NetBSD. It was fixed about six months later in commit
  cdde6ffc, which is current. Translating that to qemu releases, the bug
  was visible from v1.0 to v1.1.0.

On physical hardware cycling between reset methods is sometimes necessary
<http://mjg59.dreamwidth.org/3561.html>. On qemu the port access should
trap immediately.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14157 6f19259b-4bc3-4df7-8a09-765794883524
OvmfPkg: make sure ResetCold() and ResetWarm() never return

Also, add a small delay after the 0xCF9 hard reset request -- on qemu/kvm the
port access is translated to the qemu-internal system reset request by the CPU
thread, and it might progress some more before the IO thread acts upon the
system reset request.

MicroSecondDelay() is implemented by OvmfPkg's own AcpiTimerLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14158 6f19259b-4bc3-4df7-8a09-765794883524