summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c
blob: 2dbc812953d29d8f058174c63d8b5d0d225ecc55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/** @file
  OVMF ACPI Platform Driver for Xen guests

  Copyright (C) 2021, Red Hat, Inc.
  Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Library/AcpiPlatformLib.h> // InstallAcpiTablesFromMemory()
#include <Library/DebugLib.h>        // DEBUG()
#include <Library/XenPlatformLib.h>  // XenDetected()

#include "AcpiPlatform.h"

#define XEN_ACPI_PHYSICAL_ADDRESS  0x000EA020
#define XEN_BIOS_PHYSICAL_END      0x000FFFFF

/**
  Effective entrypoint of Acpi Platform driver.

  @param  ImageHandle
  @param  SystemTable

  @return EFI_SUCCESS
  @return EFI_LOAD_ERROR
  @return EFI_OUT_OF_RESOURCES

**/
EFI_STATUS
EFIAPI
InstallAcpiTables (
  IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiTable
  )
{
  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *RsdpStructurePtr;
  EFI_XEN_INFO                                  *XenInfo;
  EFI_STATUS                                    Status;

  if (XenDetected ()) {
    //
    // Detect the RSDP structure
    //

    //
    // First look for PVH one
    //
    XenInfo = XenGetInfoHOB ();
    ASSERT (XenInfo != NULL);
    if (XenInfo->RsdpPvh != NULL) {
      DEBUG ((
        DEBUG_INFO,
        "%a: Use ACPI RSDP table at 0x%p\n",
        gEfiCallerBaseName,
        XenInfo->RsdpPvh
        ));
      RsdpStructurePtr = XenInfo->RsdpPvh;
    } else {
      //
      // Otherwise, look for the HVM one
      //
      Status = GetAcpiRsdpFromMemory (
                 XEN_ACPI_PHYSICAL_ADDRESS,
                 XEN_BIOS_PHYSICAL_END,
                 &RsdpStructurePtr
                 );
      if (EFI_ERROR (Status)) {
        return Status;
      }
    }

    Status = InstallAcpiTablesFromRsdp (
               AcpiTable,
               RsdpStructurePtr
               );
  } else {
    Status = EFI_UNSUPPORTED;
  }

  return Status;
}