3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Support routines for PxeBc
24 #include "PxeBcImpl.h"
29 @param Smbios Pointer to SMBIOS structure
30 @param StringNumber String number to return. 0 is used to skip all
31 strings and point to the next SMBIOS structure.
33 @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == 0
36 // GC_NOTO: function comment is missing 'Routine Description:'
39 IN SMBIOS_STRUCTURE_POINTER
*Smbios
,
40 IN UINT16 StringNumber
47 // Skip over formatted section
49 String
= (CHAR8
*) (Smbios
->Raw
+ Smbios
->Hdr
->Length
);
52 // Look through unformated section
54 for (Index
= 1; Index
<= StringNumber
|| StringNumber
== 0; Index
++) {
55 if (StringNumber
== Index
) {
61 for (; *String
!= 0; String
++)
67 // If double NULL then we are done.
68 // Return pointer to next structure in Smbios.
69 // if you pass in a 0 you will always get here
71 Smbios
->Raw
= (UINT8
*)++String
;
81 This function gets system guid and serial number from the smbios table
83 @param SystemGuid The pointer of returned system guid
84 @param SystemSerialNumber The pointer of returned system serial number
86 @retval EFI_SUCCESS Successfully get the system guid and system serial
88 @retval EFI_NOT_FOUND Not find the SMBIOS table
92 GetSmbiosSystemGuidAndSerialNumber (
93 IN EFI_GUID
*SystemGuid
,
94 OUT CHAR8
**SystemSerialNumber
98 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
99 SMBIOS_STRUCTURE_POINTER Smbios
;
100 SMBIOS_STRUCTURE_POINTER SmbiosEnd
;
103 Status
= EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid
, (VOID
**) &SmbiosTable
);
105 if (EFI_ERROR (Status
)) {
106 return EFI_NOT_FOUND
;
109 Smbios
.Hdr
= (SMBIOS_STRUCTURE
*) (UINTN
) SmbiosTable
->TableAddress
;
110 SmbiosEnd
.Raw
= (UINT8
*) (UINTN
) (SmbiosTable
->TableAddress
+ SmbiosTable
->TableLength
);
112 for (Index
= 0; Index
< SmbiosTable
->TableLength
; Index
++) {
113 if (Smbios
.Hdr
->Type
== 1) {
114 if (Smbios
.Hdr
->Length
< 0x19) {
116 // Older version did not support Guid and Serial number
121 // SMBIOS tables are byte packed so we need to do a byte copy to
122 // prevend alignment faults on Itanium-based platform.
124 CopyMem (SystemGuid
, &Smbios
.Type1
->Uuid
, sizeof (EFI_GUID
));
125 *SystemSerialNumber
= GetSmbiosString (&Smbios
, Smbios
.Type1
->SerialNumber
);
130 // Make Smbios point to the next record
132 GetSmbiosString (&Smbios
, 0);
134 if (Smbios
.Raw
>= SmbiosEnd
.Raw
) {
136 // SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
137 // given this we must double check against the length of the structure.
148 GC_NOTO: Add function description
150 @param Event GC_NOTO: add argument description
151 @param Context GC_NOTO: add argument description
153 @return GC_NOTO: add return values
162 *((BOOLEAN
*) Context
) = TRUE
;
167 Convert number to ASCII value
169 @param Number Numeric value to convert to decimal ASCII value.
170 @param Buffer Buffer to place ASCII version of the Number
171 @param Length Length of Buffer.
186 Remainder
= Number
% 10;
188 Buffer
[Length
] = (UINT8
) ('0' + Remainder
);
194 GC_NOTO: Add function description
196 @param Number GC_NOTO: add argument description
197 @param Buffer GC_NOTO: add argument description
199 @return GC_NOTO: add return values
216 TempStr
[Index
] = (CHAR8
) ('0' + (Number
% 10));
217 Number
= Number
/ 10;
218 } while (Number
!= 0);
220 AsciiStrCpy (Buffer
, &TempStr
[Index
]);
222 return AsciiStrLen (Buffer
);
227 Convert ASCII numeric string to a UINTN value
229 @param Number Numeric value to convert to decimal ASCII value.
230 @param Buffer Buffer to place ASCII version of the Number
232 @retval Value UINTN value of the ASCII string.
244 while ((Character
= *Buffer
++) != '\0') {
245 Value
= MultU64x32 (Value
, 10) + (Character
- '0');