summaryrefslogtreecommitdiff
path: root/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMisc.h
blob: 66f9db9665b661654f668e7ed9cf04fa6636e6db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/**@file

Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Module Name:

  SmbiosMisc.h

Abstract:

  Header file for the SmbiosMisc Driver.

Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
**/

#ifndef _SMBIOS_MISC_DRIVER_H
#define _SMBIOS_MISC_DRIVER_H

#include <FrameworkDxe.h>
#include <Protocol/Smbios.h>
#include <IndustryStandard/SmBios.h>
#include <Library/HiiLib.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Guid/DebugMask.h>

#include <Library/PrintLib.h>

//
// Data table entry update function.
//
typedef EFI_STATUS (EFIAPI EFI_MISC_SMBIOS_DATA_FUNCTION) (
  IN  VOID                 *RecordData,
  IN  EFI_SMBIOS_PROTOCOL  *Smbios
  );


//
// Data table entry definition.
//
typedef struct {
  //
  // intermediat input data for SMBIOS record
  //
  VOID                              *RecordData;
  EFI_MISC_SMBIOS_DATA_FUNCTION     *Function;
} EFI_MISC_SMBIOS_DATA_TABLE;


//
// Data Table extern definitions.
//
#define MISC_SMBIOS_TABLE_EXTERNS(NAME1, NAME2, NAME3) \
extern NAME1 NAME2 ## Data; \
extern EFI_MISC_SMBIOS_DATA_FUNCTION NAME3 ## Function;


//
// Data Table entries
//

#define MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \
{ \
  & NAME1 ## Data, \
    NAME2 ## Function \
}


//
// Global definition macros.
//
#define MISC_SMBIOS_TABLE_DATA(NAME1, NAME2) \
  NAME1 NAME2 ## Data

#define MISC_SMBIOS_TABLE_FUNCTION(NAME2) \
  EFI_STATUS EFIAPI NAME2 ## Function( \
  IN  VOID                  *RecordData, \
  IN  EFI_SMBIOS_PROTOCOL   *Smbios \
  )

//
// Data Table Array Entries
//
extern EFI_HII_HANDLE               mHiiHandle;

typedef struct _EFI_TYPE11_OEM_STRING{
  UINT8                               Offset;
  EFI_STRING_ID                       RefOemDefineString;
} EFI_TYPE11_OEM_STRING;

typedef struct _EFI_TYPE12_SYSTEM_CONFIGURATION_OPTIONS_STRING{
  UINT8                               Offset;
  EFI_STRING_ID                       RefType12SystemConfigurationOptionsString;
} EFI_TYPE12_SYSTEM_CONFIGURATION_OPTIONS_STRING;

typedef struct _EFI_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING{
  UINT8                               *LanguageSignature;
  EFI_STRING_ID                       InstallableLanguageLongString;
  EFI_STRING_ID                       InstallableLanguageAbbreviateString;
} EFI_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING;

typedef struct _EFI_TYPE40_ADDITIONAL_INFORMATION_ENTRY{
  UINT8           RefType;
  UINT8           RefOffset;
  EFI_STRING_ID   RefString;
  UINT8           Value;
} EFI_TYPE40_ADDITIONAL_INFORMATION_ENTRY;

typedef enum {
  STRING,
  DATA,
} OEM_DEFINE_TYPE;

typedef struct {
  OEM_DEFINE_TYPE                Type;
  UINTN                          Token;
  UINTN                          DataSize;
} OEM_DEFINE_INFO_STRING;

typedef struct {
  OEM_DEFINE_TYPE                Type;
  UINTN                          DataAddress;
  UINTN                          DataSize;
} OEM_DEFINE_INFO_DATA;

typedef union {
  OEM_DEFINE_INFO_STRING         DefineString;
  OEM_DEFINE_INFO_DATA           DefineData;
} EFI_OEM_DEFINE_ARRAY;

typedef struct _DMI_STRING_STRUCTURE {
  UINT8                                 Type;
  UINT8                                 Offset;
  UINT8                                 Valid;
  UINT16                                Length;
  UINT8                                 String[1]; // Variable length field
} DMI_STRING_STRUCTURE;

typedef struct {
  UINT8                                 Type;           // The SMBIOS structure type
  UINT8                                 FixedOffset;    // The offset of the string reference
                                                        // within the structure's fixed data.
} DMI_UPDATABLE_STRING;

EFI_STATUS
FindString (
  IN UINT8                              Type,
  IN UINT8                              Offset,
  IN EFI_STRING_ID                      TokenToUpdate
);

EFI_STATUS
FindUuid (
  EFI_GUID                    *Uuid
);

EFI_STATUS
StringToBiosVeriosn (
  IN  EFI_STRING_ID                     BiosVersionToken,
  OUT UINT8                             *MajorVersion,
  OUT UINT8                             *MinorVersion
);


/**
 Logs SMBIOS record.

 @param [in]   Buffer         Pointer to the data buffer.
 @param [in]   SmbiosHandle   Pointer for retrieve handle.

**/
EFI_STATUS
LogSmbiosData (
  IN       UINT8                      *Buffer,
  IN  OUT  EFI_SMBIOS_HANDLE          *SmbiosHandle
  );

/**
 Get Link Type Handle.

 @param [in]   SmbiosType     Get this Type from SMBIOS table
 @param [out]  HandleArray    Pointer to Hadndler array with has been free by caller
 @param [out]  HandleCount    Pointer to Hadndler Counter

**/
VOID
GetLinkTypeHandle(
  IN  UINT8                 SmbiosType,
  OUT UINT16                **HandleArray,
  OUT UINTN                 *HandleCount
  );

typedef enum {
    ProductNameType01,
    SerialNumType01,
    UuidType01,
    SystemManufacturerType01,
    AssertTagType02,
    SrNumType02,
    BoardManufacturerType02,
    AssetTagType03,
    SrNumType03,
    VersionType03,
    ChassisTypeType03 ,
    ManufacturerType03,
} GET_INFO_BMC_OFFSET;

VOID UpdateSmbiosInfo (IN EFI_HII_HANDLE mHiiHandle, IN EFI_STRING_ID TokenToUpdate, IN UINT8 Offset);
EFI_STATUS GetUuidType1 (IN OUT EFI_GUID *Uuid);
EFI_STATUS IpmiGetChassisType (IN OUT UINT8 *Type);
#endif