microsoft/mu_tiano_platforms
Publicmirrored fromhttps://github.com/microsoft/mu_tiano_platformsAvailable
UefiDbgExt/tables.cpp
75lines · modecode
| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft Corporation |
| 4 | |
| 5 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 6 | |
| 7 | Module Name: |
| 8 | |
| 9 | tables.cpp |
| 10 | |
| 11 | Abstract: |
| 12 | |
| 13 | This file contains debug commands enumerating EFI tables. |
| 14 | |
| 15 | --*/ |
| 16 | |
| 17 | #include "uefiext.h" |
| 18 | |
| 19 | GUID TableGuids[] = EFI_TABLE_GUIDS; |
| 20 | |
| 21 | ULONG64 |
| 22 | GetTableAddress(EFI_TABLE Table) |
| 23 | { |
| 24 | |
| 25 | ULONG64 StPtrAddr; |
| 26 | ULONG64 SystemTableAddr; |
| 27 | ULONG64 NumTables; |
| 28 | ULONG64 ConfigTables; |
| 29 | ULONG64 TableAddr; |
| 30 | ULONG64 Result; |
| 31 | ULONG64 ConfigTableSize; |
| 32 | GUID TableGuid; |
| 33 | ULONG64 i; |
| 34 | |
| 35 | if (gUefiEnv == DXE) { |
| 36 | StPtrAddr = GetExpression("gST"); |
| 37 | if (StPtrAddr == NULL) { |
| 38 | dprintf("Failed to find global system table!\n"); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | if (!ReadPointer(StPtrAddr, &SystemTableAddr)) { |
| 43 | dprintf("Failed to find global system table!\n"); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | GetFieldValue(SystemTableAddr, "EFI_SYSTEM_TABLE", "NumberOfTableEntries", NumTables); |
| 48 | GetFieldValue(SystemTableAddr, "EFI_SYSTEM_TABLE", "ConfigurationTable", ConfigTables); |
| 49 | ConfigTableSize = GetTypeSize("EFI_CONFIGURATION_TABLE"); |
| 50 | |
| 51 | // |
| 52 | // Check the number of tables in case something is wrong. |
| 53 | // |
| 54 | |
| 55 | if (NumTables > 100) { |
| 56 | dprintf("Found too many system tables! (%lld) \n", NumTables); |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | for (i = 0; i < NumTables; i++) { |
| 61 | TableAddr = ConfigTables + (i * ConfigTableSize); |
| 62 | GetFieldValue(TableAddr, "EFI_CONFIGURATION_TABLE", "VendorGuid", TableGuid); |
| 63 | if (TableGuid == TableGuids[Table]) { |
| 64 | GetFieldValue(TableAddr, "EFI_CONFIGURATION_TABLE", "VendorTable", Result); |
| 65 | return Result; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | else { |
| 71 | dprintf("Not supported for this environment!\n"); |
| 72 | } |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |