1 /** @file
2   API for SMBIOS Plug and Play functions, access to SMBIOS table and structures.
3 
4   Copyright (c) 2005 - 2015, 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 #ifndef _LIB_SMBIOS_VIEW_H_
16 #define _LIB_SMBIOS_VIEW_H_
17 
18 #include <IndustryStandard/SmBios.h>
19 
20 #define DMI_SUCCESS                     0x00
21 #define DMI_UNKNOWN_FUNCTION            0x81
22 #define DMI_FUNCTION_NOT_SUPPORTED      0x82
23 #define DMI_INVALID_HANDLE              0x83
24 #define DMI_BAD_PARAMETER               0x84
25 #define DMI_INVALID_SUBFUNCTION         0x85
26 #define DMI_NO_CHANGE                   0x86
27 #define DMI_ADD_STRUCTURE_FAILED        0x87
28 #define DMI_READ_ONLY                   0x8D
29 #define DMI_LOCK_NOT_SUPPORTED          0x90
30 #define DMI_CURRENTLY_LOCKED            0x91
31 #define DMI_INVALID_LOCK                0x92
32 
33 #define INVALID_HANDLE                  (UINT16) (-1)
34 
35 #define EFI_SMBIOSERR(val)              EFIERR (0x30000 | val)
36 
37 #define EFI_SMBIOSERR_FAILURE           EFI_SMBIOSERR (1)
38 #define EFI_SMBIOSERR_STRUCT_NOT_FOUND  EFI_SMBIOSERR (2)
39 #define EFI_SMBIOSERR_TYPE_UNKNOWN      EFI_SMBIOSERR (3)
40 #define EFI_SMBIOSERR_UNSUPPORTED       EFI_SMBIOSERR (4)
41 
42 /**
43   Init the SMBIOS VIEW API's environment for the 32-bit table..
44 
45   @retval EFI_SUCCESS  Successful to init the SMBIOS VIEW Lib.
46 **/
47 EFI_STATUS
48 LibSmbiosInit (
49   VOID
50   );
51 
52 /**
53   Init the SMBIOS VIEW API's environment for the 64-bit table..
54 
55   @retval EFI_SUCCESS  Successful to init the SMBIOS VIEW Lib.
56 **/
57 EFI_STATUS
58 LibSmbios64BitInit (
59   VOID
60   );
61 
62 /**
63   Cleanup the Smbios information.
64 **/
65 VOID
66 LibSmbiosCleanup (
67   VOID
68   );
69 
70 /**
71   Cleanup the Smbios information.
72 **/
73 VOID
74 LibSmbios64BitCleanup (
75   VOID
76   );
77 
78 /**
79   Get the entry point structure for the table.
80 
81   @param[out] EntryPointStructure  The pointer to populate.
82 **/
83 VOID
84 LibSmbiosGetEPS (
85   OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
86   );
87 
88 /**
89   Get the entry point structure for the 64-bit table.
90 
91   @param[out] EntryPointStructure  The pointer to populate.
92 **/
93 VOID
94 LibSmbios64BitGetEPS (
95   OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
96   );
97 
98 /**
99   Return SMBIOS string for the given string number.
100 
101   @param[in] Smbios         Pointer to SMBIOS structure.
102   @param[in] StringNumber   String number to return. -1 is used to skip all strings and
103                             point to the next SMBIOS structure.
104 
105   @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
106 **/
107 CHAR8*
108 LibGetSmbiosString (
109   IN  SMBIOS_STRUCTURE_POINTER    *Smbios,
110   IN  UINT16                      StringNumber
111   );
112 
113 /**
114     Get SMBIOS structure for the given Handle,
115     Handle is changed to the next handle or 0xFFFF when the end is
116     reached or the handle is not found.
117 
118     @param[in, out] Handle     0xFFFF: get the first structure
119                                Others: get a structure according to this value.
120     @param[out] Buffer         The pointer to the pointer to the structure.
121     @param[out] Length         Length of the structure.
122 
123     @retval DMI_SUCCESS   Handle is updated with next structure handle or
124                           0xFFFF(end-of-list).
125 
126     @retval DMI_INVALID_HANDLE  Handle is updated with first structure handle or
127                                 0xFFFF(end-of-list).
128 **/
129 EFI_STATUS
130 LibGetSmbiosStructure (
131   IN  OUT UINT16  *Handle,
132   OUT UINT8       **Buffer,
133   OUT UINT16      *Length
134   );
135 
136 /**
137     Get SMBIOS structure for the given Handle in 64-bit table,
138     Handle is changed to the next handle or 0xFFFF when the end is
139     reached or the handle is not found.
140 
141     @param[in, out] Handle     0xFFFF: get the first structure
142                                Others: get a structure according to this value.
143     @param[out] Buffer         The pointer to the pointer to the structure.
144     @param[out] Length         Length of the structure.
145 
146     @retval DMI_SUCCESS   Handle is updated with next structure handle or
147                           0xFFFF(end-of-list).
148 
149     @retval DMI_INVALID_HANDLE  Handle is updated with first structure handle or
150                                 0xFFFF(end-of-list).
151 **/
152 EFI_STATUS
153 LibGetSmbios64BitStructure (
154   IN  OUT UINT16  *Handle,
155   OUT UINT8       **Buffer,
156   OUT UINT16      *Length
157   );
158 
159 #endif
160