From 1828acbc561720ca953d6d595058d0c3134d210c Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 2 Feb 2024 22:10:51 +0100 Subject: [PATCH] Implement AcGetSMBiosTable() and AcGetSMBios3Table() routines --- sdk/xtdk/hltypes.h | 35 ++++++++++++++++ xtldr/modules/acpi/acpi.c | 64 ++++++++++++++++++++++++++++++ xtldr/modules/acpi/includes/acpi.h | 8 ++++ 3 files changed, 107 insertions(+) diff --git a/sdk/xtdk/hltypes.h b/sdk/xtdk/hltypes.h index bfcee77..2160f46 100644 --- a/sdk/xtdk/hltypes.h +++ b/sdk/xtdk/hltypes.h @@ -142,6 +142,7 @@ typedef struct _CPPORT USHORT Flags; } CPPORT, *PCPPORT; +/* HAL framebuffer data structure */ typedef struct _HAL_FRAMEBUFFER_DATA { BOOLEAN Initialized; @@ -154,4 +155,38 @@ typedef struct _HAL_FRAMEBUFFER_DATA UINT Pitch; } HAL_FRAMEBUFFER_DATA, *PHAL_FRAMEBUFFER_DATA; +/* SMBIOS table header structure */ +typedef struct _SMBIOS_TABLE_HEADER +{ + UCHAR Signature[4]; + UCHAR Checksum; + UCHAR Length; + UCHAR MajorVersion; + UCHAR MinorVersion; + USHORT MaxStructureSize; + UCHAR EntryPointRevision; + UCHAR Reserved[5]; + UCHAR Signature2[5]; + UCHAR IntermediateChecksum; + USHORT TableLength; + ULONG TableAddress; + USHORT NumberOfStructures; + UCHAR BcdRevision; +} SMBIOS_TABLE_HEADER, *PSMBIOS_TABLE_HEADER; + +/* SMBIOS3 table header structure */ +typedef struct _SMBIOS3_TABLE_HEADER +{ + UCHAR Signature[5]; + UCHAR Checksum; + UCHAR Length; + UCHAR MajorVersion; + UCHAR MinorVersion; + UCHAR DocRevision; + UCHAR EntryPointRevision; + UCHAR Reserved; + ULONG MaxStructureSize; + ULONGLONG TableAddress; +} SMBIOS3_TABLE_HEADER, *PSMBIOS3_TABLE_HEADER; + #endif /* __XTDK_HLTYPES_H */ diff --git a/xtldr/modules/acpi/acpi.c b/xtldr/modules/acpi/acpi.c index 005870d..e1f922b 100644 --- a/xtldr/modules/acpi/acpi.c +++ b/xtldr/modules/acpi/acpi.c @@ -119,6 +119,70 @@ AcGetRsdpTable(OUT PVOID *AcpiTable) return STATUS_EFI_SUCCESS; } +/** + * Gets SMBIOS from EFI system configuration + * + * @param SmBiosTable + * Suplies a pointer to memory area where SMBIOS address will be stored. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTCDECL +EFI_STATUS +AcGetSMBiosTable(OUT PVOID *SmBiosTable) +{ + EFI_GUID SmBiosGuid = EFI_CONFIG_TABLE_SMBIOS_TABLE_GUID; + PSMBIOS_TABLE_HEADER SmBios; + EFI_STATUS Status; + + /* Get SMBIOS table from system configuration tables */ + Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBiosGuid, (PVOID)&SmBios); + if(Status != STATUS_EFI_SUCCESS || AcpChecksumTable(SmBios, SmBios->Length) != 0) + { + /* SMBIOS not found or checksum mismatch */ + *SmBiosTable = NULL; + return STATUS_EFI_NOT_FOUND; + } + + /* SMBIOS found, return success */ + *SmBiosTable = SmBios; + return STATUS_EFI_SUCCESS; +} + +/** + * Gets SMBIOS3 from EFI system configuration + * + * @param SmBiosTable + * Suplies a pointer to memory area where SMBIOS3 address will be stored. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTCDECL +EFI_STATUS +AcGetSMBios3Table(OUT PVOID *SmBiosTable) +{ + EFI_GUID SmBios3Guid = EFI_CONFIG_TABLE_SMBIOS3_TABLE_GUID; + PSMBIOS3_TABLE_HEADER SmBios; + EFI_STATUS Status; + + /* Get SMBIOS3 table from system configuration tables */ + Status = XtLdrProtocol->Util.GetConfigurationTable(&SmBios3Guid, (PVOID)&SmBios); + if(Status != STATUS_EFI_SUCCESS || AcpChecksumTable(SmBios, SmBios->Length) != 0) + { + /* SMBIOS3 not found or checksum mismatch */ + *SmBiosTable = NULL; + return STATUS_EFI_NOT_FOUND; + } + + /* SMBIOS3 found, return success */ + *SmBiosTable = SmBios; + return STATUS_EFI_SUCCESS; +} + /** * Gets XSDP (ACPI 2.0) from EFI system configuration * diff --git a/xtldr/modules/acpi/includes/acpi.h b/xtldr/modules/acpi/includes/acpi.h index 19fa8bb..a49600c 100644 --- a/xtldr/modules/acpi/includes/acpi.h +++ b/xtldr/modules/acpi/includes/acpi.h @@ -26,6 +26,14 @@ XTCDECL EFI_STATUS AcGetRsdpTable(OUT PVOID *AcpiTable); +XTCDECL +EFI_STATUS +AcGetSMBiosTable(OUT PVOID *SmBiosTable); + +XTCDECL +EFI_STATUS +AcGetSMBios3Table(OUT PVOID *SmBiosTable); + XTCDECL EFI_STATUS AcGetXsdpTable(OUT PVOID *AcpiTable);