3 Copyright (c) 2000 Intel Corporation
11 Lib fucntions for SMBIOS. Used to get system serial number and GUID
21 LibGetSmbiosSystemGuidAndSerialNumber (
22 IN EFI_GUID *SystemGuid,
23 OUT CHAR8 **SystemSerialNumber
27 SMBIOS_STRUCTURE_TABLE *SmbiosTable;
28 SMBIOS_STRUCTURE_POINTER Smbios;
29 SMBIOS_STRUCTURE_POINTER SmbiosEnd;
32 Status = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID**)&SmbiosTable);
33 if (EFI_ERROR(Status)) {
37 Smbios.Hdr = (SMBIOS_HEADER *)SmbiosTable->TableAddress;
38 SmbiosEnd.Raw = (UINT8 *)(SmbiosTable->TableAddress + SmbiosTable->TableLength);
39 for (Index = 0; Index < SmbiosTable->TableLength ; Index++) {
40 if (Smbios.Hdr->Type == 1) {
41 if (Smbios.Hdr->Length < 0x19) {
43 // Older version did not support Guid and Serial number
49 // SMBIOS tables are byte packed so we need to do a byte copy to
50 // prevend alignment faults on IA-64.
52 CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof(EFI_GUID));
53 *SystemSerialNumber = LibGetSmbiosString(&Smbios, Smbios.Type1->SerialNumber);
58 // Make Smbios point to the next record
60 LibGetSmbiosString (&Smbios, -1);
62 if (Smbios.Raw >= SmbiosEnd.Raw) {
64 // SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
65 // given this we must double check against the lenght of
66 /// the structure. My home PC has this bug.ruthard
77 IN SMBIOS_STRUCTURE_POINTER *Smbios,
78 IN UINT16 StringNumber
82 Return SMBIOS string given the string number.
85 Smbios - Pointer to SMBIOS structure
86 StringNumber - String number to return. -1 is used to skip all strings and
87 point to the next SMBIOS structure.
90 Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
97 // Skip over formatted section
99 String = (CHAR8 *)(Smbios->Raw + Smbios->Hdr->Length);
102 // Look through unformated section
104 for (Index = 1; Index <= StringNumber; Index++) {
105 if (StringNumber == Index) {
112 for (; *String != 0; String++);
117 // If double NULL then we are done.
118 // Retrun pointer to next structure in Smbios.
119 // if you pass in a -1 you will always get here
121 Smbios->Raw = (UINT8 *)++String;