aboutsummaryrefslogtreecommitdiffstats
path: root/Lesson_28/UefiLessonsPkg/AcpiInfo
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-02 20:02:07 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-02 20:02:07 +0300
commit560f0303beaac1bfa8966de3fe636657825724da (patch)
treea8f8103fb5eca00e845adbc9fa718868e682c7dd /Lesson_28/UefiLessonsPkg/AcpiInfo
parent689f1cfc6e8f40960d9be5125e48fd17f23e5883 (diff)
downloadUEFI-Lessons-560f0303beaac1bfa8966de3fe636657825724da.tar.gz
UEFI-Lessons-560f0303beaac1bfa8966de3fe636657825724da.tar.bz2
UEFI-Lessons-560f0303beaac1bfa8966de3fe636657825724da.zip
Add draft for lesson 28
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'Lesson_28/UefiLessonsPkg/AcpiInfo')
-rw-r--r--Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.c69
-rw-r--r--Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.inf21
2 files changed, 90 insertions, 0 deletions
diff --git a/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.c b/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.c
new file mode 100644
index 0000000..88c78b6
--- /dev/null
+++ b/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.c
@@ -0,0 +1,69 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Library/BaseMemoryLib.h>
+
+EFI_STATUS
+EFIAPI
+UefiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_ACPI_6_3_ROOT_SYSTEM_DESCRIPTION_POINTER* RSDP = NULL;
+
+ for (UINTN i=0; i<SystemTable->NumberOfTableEntries; i++) {
+ if (CompareGuid(&(SystemTable->ConfigurationTable[i].VendorGuid), &gEfiAcpi20TableGuid)) {
+ Print(L"RSDP table is placed at %p\n\n", SystemTable->ConfigurationTable[i].VendorTable);
+ RSDP = SystemTable->ConfigurationTable[i].VendorTable;
+ }
+ }
+
+ if (!RSDP) {
+ Print(L"No ACPI2.0 table was found in the system\n");
+ return EFI_SUCCESS;
+ }
+
+ if (((CHAR8)((RSDP->Signature >> 0) & 0xFF) != 'R') ||
+ ((CHAR8)((RSDP->Signature >> 8) & 0xFF) != 'S') ||
+ ((CHAR8)((RSDP->Signature >> 16) & 0xFF) != 'D') ||
+ ((CHAR8)((RSDP->Signature >> 24) & 0xFF) != ' ') ||
+ ((CHAR8)((RSDP->Signature >> 32) & 0xFF) != 'P') ||
+ ((CHAR8)((RSDP->Signature >> 40) & 0xFF) != 'T') ||
+ ((CHAR8)((RSDP->Signature >> 48) & 0xFF) != 'R') ||
+ ((CHAR8)((RSDP->Signature >> 56) & 0xFF) != ' ')) {
+ Print(L"Error! RSDP signature is not valid!\n");
+ return EFI_SUCCESS;
+ }
+
+ Print(L"System description tables:\n");
+ Print(L"\tRSDT table is placed at address %p\n", RSDP->RsdtAddress);
+ Print(L"\tXSDT table is placed at address %p\n", RSDP->XsdtAddress);
+ Print(L"\n");
+
+ EFI_ACPI_DESCRIPTION_HEADER* XSDT = (EFI_ACPI_DESCRIPTION_HEADER*)RSDP->XsdtAddress;
+ if (((CHAR8)((XSDT->Signature >> 0) & 0xFF) != 'X') ||
+ ((CHAR8)((XSDT->Signature >> 8) & 0xFF) != 'S') ||
+ ((CHAR8)((XSDT->Signature >> 16) & 0xFF) != 'D') ||
+ ((CHAR8)((XSDT->Signature >> 24) & 0xFF) != 'T')) {
+ Print(L"Error! XSDT signature is not valid!\n");
+ return EFI_SUCCESS;
+ }
+
+ Print(L"Main ACPI tables:\n");
+ UINT64 offset = sizeof(EFI_ACPI_DESCRIPTION_HEADER);
+ while (offset < XSDT->Length) {
+ UINT64* table_address = (UINT64*)((UINT8*)XSDT + offset);
+ EFI_ACPI_6_3_COMMON_HEADER* table = (EFI_ACPI_6_3_COMMON_HEADER*)(*table_address);
+ Print(L"\t%c%c%c%c table is placed at address %p with length 0x%x\n",
+ (CHAR8)((table->Signature>> 0)&0xFF),
+ (CHAR8)((table->Signature>> 8)&0xFF),
+ (CHAR8)((table->Signature>>16)&0xFF),
+ (CHAR8)((table->Signature>>24)&0xFF),
+ table,
+ table->Length);
+ offset += sizeof(UINT64);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.inf b/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.inf
new file mode 100644
index 0000000..3884e76
--- /dev/null
+++ b/Lesson_28/UefiLessonsPkg/AcpiInfo/AcpiInfo.inf
@@ -0,0 +1,21 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = AcpiInfo
+ FILE_GUID = 18998798-69a2-4ab5-9ffc-a8ee2494b029
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = UefiMain
+
+[Sources]
+ AcpiInfo.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+
+[Guids]
+ gEfiAcpi20TableGuid
+