aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/SmbiosInfo
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-12 13:04:07 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2021-07-12 13:06:10 +0300
commitea5d514727e1b9abcc4558e62ca9311755937a5d (patch)
tree7d09250b31bfaaff0d028b75268fd9d336a093c5 /UefiLessonsPkg/SmbiosInfo
parent7d9311124853be51b5a65f41daa7bee0f37bf2ba (diff)
downloadUEFI-Lessons-ea5d514727e1b9abcc4558e62ca9311755937a5d.tar.gz
UEFI-Lessons-ea5d514727e1b9abcc4558e62ca9311755937a5d.tar.bz2
UEFI-Lessons-ea5d514727e1b9abcc4558e62ca9311755937a5d.zip
Add 'UefiLessonsPkg' folder to the repo
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'UefiLessonsPkg/SmbiosInfo')
-rw-r--r--UefiLessonsPkg/SmbiosInfo/SmbiosInfo.c88
-rw-r--r--UefiLessonsPkg/SmbiosInfo/SmbiosInfo.inf24
2 files changed, 112 insertions, 0 deletions
diff --git a/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.c b/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.c
new file mode 100644
index 0000000..b75026d
--- /dev/null
+++ b/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.c
@@ -0,0 +1,88 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Library/BaseMemoryLib.h>
+#include <Protocol/Smbios.h>
+
+CHAR8* GetRecordString(EFI_SMBIOS_TABLE_HEADER* Record, UINTN number)
+{
+ if (!number)
+ return "";
+
+ CHAR8* String = (CHAR8*)Record + Record->Length;
+ UINTN i=1;
+ while (i < number) {
+ String = String + AsciiStrSize(String);
+ i++;
+ }
+ return String;
+}
+
+EFI_STATUS
+EFIAPI
+UefiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ for (UINTN i=0; i<SystemTable->NumberOfTableEntries; i++) {
+ if (CompareGuid(&(SystemTable->ConfigurationTable[i].VendorGuid), &gEfiSmbiosTableGuid)) {
+ Print(L"SMBIOS table is placed at %p\n\n", SystemTable->ConfigurationTable[i].VendorTable);
+ }
+ }
+
+ EFI_SMBIOS_PROTOCOL* SmbiosProtocol;
+ EFI_STATUS Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID**)&SmbiosProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ EFI_SMBIOS_HANDLE SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ EFI_SMBIOS_TABLE_HEADER* Record;
+ Status = SmbiosProtocol->GetNext(SmbiosProtocol,
+ &SmbiosHandle,
+ NULL,
+ &Record,
+ NULL);
+ while (!EFI_ERROR(Status)) {
+ Print (L"SMBIOS Type %d \n", Record->Type);
+ switch (Record->Type) {
+ case EFI_SMBIOS_TYPE_BIOS_INFORMATION: {
+ SMBIOS_TABLE_TYPE0* Type0Record = (SMBIOS_TABLE_TYPE0*) Record;
+ Print(L"\tVendor=%a\n", GetRecordString(Record, Type0Record->Vendor));
+ Print(L"\tBiosVersion=%a\n", GetRecordString(Record, Type0Record->BiosVersion));
+ Print(L"\tBiosReleaseDate=%a\n", GetRecordString(Record, Type0Record->BiosReleaseDate));
+ Print(L"\tBiosSegment=0x%x\n", Type0Record->BiosSegment);
+ Print(L"\tSystemBiosMajorRelease=0x%x\n", Type0Record->SystemBiosMajorRelease);
+ Print(L"\tSystemBiosMinorRelease=0x%x\n", Type0Record->SystemBiosMinorRelease);
+ break;
+ }
+ case EFI_SMBIOS_TYPE_SYSTEM_INFORMATION: {
+ SMBIOS_TABLE_TYPE1* Type1Record = (SMBIOS_TABLE_TYPE1*) Record;
+ Print(L"\tManufacturer=%a\n", GetRecordString(Record, Type1Record->Manufacturer));
+ Print(L"\tProductName=%a\n", GetRecordString(Record, Type1Record->ProductName));
+ Print(L"\tVersion=%a\n", GetRecordString(Record, Type1Record->Version));
+ Print(L"\tSerialNumber=%a\n", GetRecordString(Record, Type1Record->SerialNumber));
+ Print(L"\tUUID=%g\n", Type1Record->Uuid);
+ Print(L"\tWakeUpType=%d\n", Type1Record->WakeUpType);
+ Print(L"\tSKUNumber=%a\n", GetRecordString(Record, Type1Record->SKUNumber));
+ Print(L"\tFamily=%a\n", GetRecordString(Record, Type1Record->Family));
+ break;
+ }
+ default:
+ Print(L"\tTODO: Parsing for this table is not ready yet\n");
+ break;
+ }
+ Status = SmbiosProtocol->GetNext(SmbiosProtocol,
+ &SmbiosHandle,
+ NULL,
+ &Record,
+ NULL);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.inf b/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.inf
new file mode 100644
index 0000000..ab6013a
--- /dev/null
+++ b/UefiLessonsPkg/SmbiosInfo/SmbiosInfo.inf
@@ -0,0 +1,24 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SmbiosInfo
+ FILE_GUID = 4a8836db-9e1d-4b7d-a785-f552340fba59
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = UefiMain
+
+[Sources]
+ SmbiosInfo.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+
+[Guids]
+ gEfiSmbiosTableGuid
+
+[Protocols]
+ gEfiSmbiosProtocolGuid
+