diff options
Diffstat (limited to 'memtestEDK/Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.c')
-rw-r--r-- | memtestEDK/Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/memtestEDK/Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.c b/memtestEDK/Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.c new file mode 100644 index 0000000..b9e3e48 --- /dev/null +++ b/memtestEDK/Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.c @@ -0,0 +1,173 @@ +#include <stdio.h> + +#include <stdint.h> +#include <Uefi.h> +#include <Library/UefiLib.h> +#include <Library/UefiApplicationEntryPoint.h> + +struct RSDPDescriptor { + char Signature[8]; + uint8_t Checksum; + char OEMID[6]; + uint8_t Revision; + uint32_t RsdtAddress; +} __attribute__ ((packed)); + +EFI_STATUS +EFIAPI +UefiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINTN NumberOfTableEntries = SystemTable->NumberOfTableEntries; + EFI_CONFIGURATION_TABLE *ConfigurationTable = SystemTable->ConfigurationTable; + + + + Print(L"NumberOfTableEntries: %d\n", NumberOfTableEntries); + + for (int i = 0; i < NumberOfTableEntries; i++) { + EFI_GUID guid = ConfigurationTable->VendorGuid; + UINT32 Data1 = guid.Data1; + UINT16 Data2 = guid.Data2; + UINT16 Data3 = guid.Data3; + UINT8 Data4[8]; + Data4[0] = guid.Data4[0]; + + if (Data1 == 0xEB9D2D30) { + // ACPI 1.0 + // TODO check other fields + // VOID *VendorTable + + Print(L"ConfigurationTable pointer: %p\n", ConfigurationTable); + Print(L"VendorGuid: %x\n", Data1); + Print(L"VendorGuid: %x\n", Data2); + Print(L"VendorGuid: %x\n", Data3); + for (int j = 0; j < 8; j++) { + Print(L"VendorGuid: %x\n", Data4[j]); + } + + struct RSDPDescriptor *VendorTable = ConfigurationTable->VendorTable; + + char Signature[8]; + for (int k = 0; k < 8; k++) { + Signature[k] = VendorTable->Signature[k]; + Print(L"Signature of RootSystemDescriptorTable: %c\n", Signature[k]); + } + //(L"Signature of RootSystemDescriptorTable: %s\n", Signature); + + + + uint8_t Checksum = VendorTable->Checksum; + Print(L"Checksum: %d\n", Checksum); + + char OEMID[6]; + for (int l = 0; l < 6; l++) { + OEMID[l] = VendorTable->OEMID[l]; + Print(L"OEMID: %c\n", OEMID[l]); + } + + uint8_t Revision = VendorTable->Revision; + Print(L"Revision: %d\n", Revision); + + uint32_t RsdtAddress = VendorTable->RsdtAddress; + Print(L"RsdtAddress: %p\n", RsdtAddress); + Print(L"VendorTable Adress: %p\n", VendorTable); + } +/* + if (Data1 == 0x8868E871) { + // ACPI 2.0 + // TODO check other fields + // VOID *VendorTable + + Print(L"ConfigurationTable pointer: %p\n", ConfigurationTable); + Print(L"VendorGuid: %x\n", Data1); + Print(L"VendorGuid: %x\n", Data2); + Print(L"VendorGuid: %x\n", Data3); + for (int j = 0; j < 8; j++) { + Print(L"VendorGuid: %x\n", Data4[j]); + } + + //VOID *VendorTable = ConfigurationTable->VendorTable; + + }*/ + + ConfigurationTable += 1; + } + + return EFI_SUCCESS; + +} + +/* + +//EFI_GUID + +typedef struct { +UINT32 Data1; +UINT16 Data2; +UINT16 Data3; +UINT8 +Data4[8]; +} EFI_GUID;*/ + +/* +typedef struct{ +EFI_GUID VendorGuid; 128-bit GUID +VOID *VendorTable; +} EFI_CONFIGURATION_TABLE; +*/ + +/* +In ACPI Version 1.0 it has this structure: + +struct RSDPDescriptor { + char Signature[8]; + uint8_t Checksum; + char OEMID[6]; + uint8_t Revision; + uint32_t RsdtAddress; +} __attribute__ ((packed)); + +since Version 2.0 it has been extended, and the following new fields have been added: + +struct RSDPDescriptor20 { + RSDPDescriptor firstPart; + + uint32_t Length; + uint64_t XsdtAddress; + uint8_t ExtendedChecksum; + uint8_t reserved[3]; +} __attribute__ ((packed));*/ + +/*UINTN NumberOfTableEntries The number of system configuration tables in the buffer +ConfigurationTable. +EFI_CONFIGURATION_TABLE *ConfigurationTable A pointer to the system configuration tables. The number of +entries in the table is NumberOfTableEntries.*/ + +/*ACPI5_1_Specification.pdf + +5.2.5.2 Finding the RSDP on UEFI Enabled Systems +In Unified Extensible Firmware Interface (UEFI) enabled systems, a pointer to the RSDP structure +exists within the EFI System Table. The OS loader is provided a pointer to the EFI System Table at +invocation. The OS loader must retrieve the pointer to the RSDP structure from the EFI System +Table and convey the pointer to OSPM, using an OS dependent data structure, as part of the hand off +of control from the OS loader to the OS. +The OS loader locates the pointer to the RSDP structure by examining the EFI Configuration Table +within the EFI System Table. EFI Configuration Table entries consist of Globally Unique Identifier +(GUID)/table pointer pairs. The UEFI specification defines two GUIDs for ACPI; one for ACPI 1.0 +and the other for ACPI 2.0 or later specification revisions. +The EFI GUID for a pointer to the ACPI 1.0 specification RSDP structure is: +• +EB9D2D30-2D88-11D3-9A16-0090273FC14D. +The EFI GUID for a pointer to the ACPI 2.0 or later specification RSDP structure is: +• +8868E871-E4F1-11D3-BC22-0080C73C8881. +The OS loader for an ACPI-compatible OS will search for an RSDP structure pointer using the +current revision GUID first and if it finds one, will use the corresponding RSDP structure pointer. If +the GUID is not found then the OS loader will search for the RSDP structure pointer using the ACPI +1.0 version GUID. +The OS loader must retrieve the pointer to the RSDP structure from the EFI System Table before +assuming platform control via the EFI ExitBootServices interface. See the UEFI Specification for +more information.*/
\ No newline at end of file |