Message ID | 20180823160743.45638-30-ming.huang@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | Upload for D06 platform | expand |
On Fri, Aug 24, 2018 at 12:07:41AM +0800, Ming Huang wrote: > Select without SMMU iort while SMMU item is disable, > Select with SMMU iort while SMMU item is enable. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ming Huang <ming.huang@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> > --- > Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + > Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 89 ++++++++++++++++++++ > 2 files changed, 90 insertions(+) > > diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf > index 281a4f2ebd..3d133aff85 100644 > --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf > +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf > @@ -51,6 +51,7 @@ > > [Guids] > gHisiEfiMemoryMapGuid > + gOemConfigGuid > > [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile ## CONSUMES > diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c > index 54f49977c3..c2c8f687b0 100644 > --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c > +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c > @@ -16,12 +16,98 @@ > #include <Library/DebugLib.h> > #include <Library/HobLib.h> > #include <Library/HwMemInitLib.h> > +#include <Library/OemConfigData.h> > #include <Library/OemMiscLib.h> > #include <Library/UefiBootServicesTableLib.h> > +#include <Library/UefiRuntimeServicesTableLib.h> > #include <Library/UefiLib.h> > > #define CORECOUNT(X) ((X) * CORE_NUM_PER_SOCKET) > > +#define FIELD_IORT_NODE_OFFSET 40 > + > +typedef enum { > + NodeTypeIts = 0, > + NodeTypeNameComponent, > + NodeTypePciRC, > + NodeTypeSmmuV1, > + NodeTypeSmmuV3, > + NodeTypePMCG > +} IORT_NODE_TYPE; > + > +#pragma pack(1) > +typedef struct { > + UINT8 Type; > + UINT16 Length; > + UINT8 Revision; > + UINT32 Reserved; > + UINT32 IdMapNumber; > + UINT32 IdArrayOffset; > +} IORT_NODE_HEAD; > +#pragma pack() > + > +BOOLEAN > +IsIortWithSmmu ( > + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader > + ) > +{ > + UINT32 *NodeOffset; > + UINT32 NextOffset; > + IORT_NODE_HEAD *Node; > + > + NodeOffset = (UINT32 *)((UINT8 *)TableHeader + FIELD_IORT_NODE_OFFSET); > + NextOffset = *NodeOffset; > + > + while (NextOffset < TableHeader->Length) { > + Node = (IORT_NODE_HEAD *)((UINT8 *)TableHeader + NextOffset); > + NextOffset += Node->Length; > + > + if ((Node->Type == NodeTypeSmmuV1) || (Node->Type == NodeTypeSmmuV3)) { > + return TRUE; > + } > + } > + > + return FALSE; > +} > + > +EFI_STATUS > +SelectIort ( > + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader > + ) > +{ > + EFI_STATUS Status; > + UINTN Size; > + OEM_CONFIG_DATA Configuration; > + > + Configuration.EnableSmmu = 0; > + Size = sizeof (OEM_CONFIG_DATA); > + Status = gRT->GetVariable ( > + OEM_CONFIG_NAME, > + &gOemConfigGuid, > + NULL, > + &Size, > + &Configuration > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Get OemConfig variable (%r).\n", Status)); > + } > + > + Status = EFI_SUCCESS; > + if (IsIortWithSmmu (TableHeader)) { > + if (!Configuration.EnableSmmu) { > + Status = EFI_ABORTED; > + } > + } else { > + if (Configuration.EnableSmmu) { > + Status = EFI_ABORTED; > + } > + } > + DEBUG ((DEBUG_INFO, "SmmuEnable=%x, return %r for Iort table.\n", > + Configuration.EnableSmmu, Status)); > + > + return Status; > +} > + > STATIC > VOID > RemoveUnusedMemoryNode ( > @@ -130,6 +216,9 @@ UpdateAcpiTable ( > case EFI_ACPI_6_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE: > Status = UpdateSlit (TableHeader); > break; > + case EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE: > + Status = SelectIort (TableHeader); > + break; > } > return Status; > } > -- > 2.18.0 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf index 281a4f2ebd..3d133aff85 100644 --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf @@ -51,6 +51,7 @@ [Guids] gHisiEfiMemoryMapGuid + gOemConfigGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile ## CONSUMES diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c index 54f49977c3..c2c8f687b0 100644 --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c @@ -16,12 +16,98 @@ #include <Library/DebugLib.h> #include <Library/HobLib.h> #include <Library/HwMemInitLib.h> +#include <Library/OemConfigData.h> #include <Library/OemMiscLib.h> #include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> #include <Library/UefiLib.h> #define CORECOUNT(X) ((X) * CORE_NUM_PER_SOCKET) +#define FIELD_IORT_NODE_OFFSET 40 + +typedef enum { + NodeTypeIts = 0, + NodeTypeNameComponent, + NodeTypePciRC, + NodeTypeSmmuV1, + NodeTypeSmmuV3, + NodeTypePMCG +} IORT_NODE_TYPE; + +#pragma pack(1) +typedef struct { + UINT8 Type; + UINT16 Length; + UINT8 Revision; + UINT32 Reserved; + UINT32 IdMapNumber; + UINT32 IdArrayOffset; +} IORT_NODE_HEAD; +#pragma pack() + +BOOLEAN +IsIortWithSmmu ( + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader + ) +{ + UINT32 *NodeOffset; + UINT32 NextOffset; + IORT_NODE_HEAD *Node; + + NodeOffset = (UINT32 *)((UINT8 *)TableHeader + FIELD_IORT_NODE_OFFSET); + NextOffset = *NodeOffset; + + while (NextOffset < TableHeader->Length) { + Node = (IORT_NODE_HEAD *)((UINT8 *)TableHeader + NextOffset); + NextOffset += Node->Length; + + if ((Node->Type == NodeTypeSmmuV1) || (Node->Type == NodeTypeSmmuV3)) { + return TRUE; + } + } + + return FALSE; +} + +EFI_STATUS +SelectIort ( + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader + ) +{ + EFI_STATUS Status; + UINTN Size; + OEM_CONFIG_DATA Configuration; + + Configuration.EnableSmmu = 0; + Size = sizeof (OEM_CONFIG_DATA); + Status = gRT->GetVariable ( + OEM_CONFIG_NAME, + &gOemConfigGuid, + NULL, + &Size, + &Configuration + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Get OemConfig variable (%r).\n", Status)); + } + + Status = EFI_SUCCESS; + if (IsIortWithSmmu (TableHeader)) { + if (!Configuration.EnableSmmu) { + Status = EFI_ABORTED; + } + } else { + if (Configuration.EnableSmmu) { + Status = EFI_ABORTED; + } + } + DEBUG ((DEBUG_INFO, "SmmuEnable=%x, return %r for Iort table.\n", + Configuration.EnableSmmu, Status)); + + return Status; +} + STATIC VOID RemoveUnusedMemoryNode ( @@ -130,6 +216,9 @@ UpdateAcpiTable ( case EFI_ACPI_6_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE: Status = UpdateSlit (TableHeader); break; + case EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE: + Status = SelectIort (TableHeader); + break; } return Status; }
Select without SMMU iort while SMMU item is disable, Select with SMMU iort while SMMU item is enable. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang <ming.huang@linaro.org> --- Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 89 ++++++++++++++++++++ 2 files changed, 90 insertions(+) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel