]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/Smbios.c
ShellPkg: Fix GCC 4.4 build issues
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / SmbiosView / Smbios.c
1 /** @file
2 Lib fucntions for SMBIOS. Used to get system serial number and GUID
3
4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "../UefiShellDebug1CommandsLib.h"
16 #include <Guid/SmBios.h>
17 #include "LibSmbios.h"
18
19 /**
20 Return SMBIOS string given the string number.
21
22 @param[in] Smbios Pointer to SMBIOS structure.
23 @param[in] StringNumber String number to return. -1 is used to skip all strings and
24 point to the next SMBIOS structure.
25
26 @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
27 **/
28 CHAR8*
29 LibGetSmbiosString (
30 IN SMBIOS_STRUCTURE_POINTER *Smbios,
31 IN UINT16 StringNumber
32 )
33 {
34 UINT16 Index;
35 CHAR8 *String;
36
37 ASSERT (Smbios != NULL);
38
39 //
40 // Skip over formatted section
41 //
42 String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length);
43
44 //
45 // Look through unformated section
46 //
47 for (Index = 1; Index <= StringNumber; Index++) {
48 if (StringNumber == Index) {
49 return String;
50 }
51 //
52 // Skip string
53 //
54 for (; *String != 0; String++);
55 String++;
56
57 if (*String == 0) {
58 //
59 // If double NULL then we are done.
60 // Retrun pointer to next structure in Smbios.
61 // if you pass in a -1 you will always get here
62 //
63 Smbios->Raw = (UINT8 *)++String;
64 return NULL;
65 }
66 }
67
68 return NULL;
69 }