3 Copyright (c) 2000 Intel Corporation
11 Lib fucntions for SMBIOS. Used to get system serial number and GUID
20 * We convert 32 bit values to pointers. In 64 bit mode the compiler will issue a
21 * warning stating that the value is too small for the pointer:
22 * "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]"
23 * we can safely ignore them here.
26 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
30 LibGetSmbiosSystemGuidAndSerialNumber (
31 IN EFI_GUID
*SystemGuid
,
32 OUT CHAR8
**SystemSerialNumber
36 SMBIOS_STRUCTURE_TABLE
*SmbiosTable
;
37 SMBIOS_STRUCTURE_POINTER Smbios
;
38 SMBIOS_STRUCTURE_POINTER SmbiosEnd
;
41 Status
= LibGetSystemConfigurationTable(&SMBIOSTableGuid
, (VOID
**)&SmbiosTable
);
42 if (EFI_ERROR(Status
)) {
46 Smbios
.Hdr
= (SMBIOS_HEADER
*)SmbiosTable
->TableAddress
;
47 SmbiosEnd
.Raw
= (UINT8
*)(SmbiosTable
->TableAddress
+ SmbiosTable
->TableLength
);
48 for (Index
= 0; Index
< SmbiosTable
->TableLength
; Index
++) {
49 if (Smbios
.Hdr
->Type
== 1) {
50 if (Smbios
.Hdr
->Length
< 0x19) {
52 // Older version did not support Guid and Serial number
58 // SMBIOS tables are byte packed so we need to do a byte copy to
59 // prevend alignment faults on IA-64.
61 CopyMem (SystemGuid
, &Smbios
.Type1
->Uuid
, sizeof(EFI_GUID
));
62 *SystemSerialNumber
= LibGetSmbiosString(&Smbios
, Smbios
.Type1
->SerialNumber
);
67 // Make Smbios point to the next record
69 LibGetSmbiosString (&Smbios
, -1);
71 if (Smbios
.Raw
>= SmbiosEnd
.Raw
) {
73 // SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
74 // given this we must double check against the lenght of
75 /// the structure. My home PC has this bug.ruthard
86 IN SMBIOS_STRUCTURE_POINTER
*Smbios
,
87 IN UINT16 StringNumber
91 Return SMBIOS string given the string number.
94 Smbios - Pointer to SMBIOS structure
95 StringNumber - String number to return. -1 is used to skip all strings and
96 point to the next SMBIOS structure.
99 Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
106 // Skip over formatted section
108 String
= (CHAR8
*)(Smbios
->Raw
+ Smbios
->Hdr
->Length
);
111 // Look through unformated section
113 for (Index
= 1; Index
<= StringNumber
; Index
++) {
114 if (StringNumber
== Index
) {
121 for (; *String
!= 0; String
++);
126 // If double NULL then we are done.
127 // Retrun pointer to next structure in Smbios.
128 // if you pass in a -1 you will always get here
130 Smbios
->Raw
= (UINT8
*)++String
;