]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/DataHubSmBiosRecordsOnPiSmBiosThunk/ProcessorConv.c
Fix bug that that the template does not match fields in structure EFI_BLOCK_IO_MEDIA
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / DataHubSmBiosRecordsOnPiSmBiosThunk / ProcessorConv.c
CommitLineData
024b1029 1/** @file\r
2 Routines that support Processor SubClass data records translation.\r
3 \r
4Copyright (c) 2009, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "Thunk.h"\r
16\r
17/**\r
18 Field Filling Function for Processor SubClass record type 17 -- Cache association.\r
19 \r
20 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
21 @param Offset Offset of SMBIOS record which RecordData will be filled.\r
22 @param RecordData RecordData buffer will be filled.\r
23 @param RecordDataSize The size of RecordData buffer.\r
24 \r
25 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.\r
26**/\r
27EFI_STATUS\r
28SmbiosFldProcessorType17 (\r
29 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,\r
30 IN UINT32 Offset,\r
31 IN VOID *RecordData,\r
32 IN UINT32 RecordDataSize\r
33 )\r
34{\r
35 EFI_SUBCLASS_TYPE1_HEADER *DataHeader;\r
36 EFI_INTER_LINK_DATA *LinkData;\r
37 UINT16 FieldOffset;\r
38 UINT8 *Pointer;\r
39\r
40 DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) RecordData;\r
41 LinkData = (EFI_INTER_LINK_DATA *) (DataHeader + 1);\r
42 if (RecordDataSize != sizeof (EFI_INTER_LINK_DATA) + sizeof (EFI_SUBCLASS_TYPE1_HEADER)) {\r
43 return EFI_INVALID_PARAMETER;\r
44 }\r
45 //\r
46 // Determine the cache level\r
47 //\r
48 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);\r
49 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {\r
50 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle), 2, 0xFF);\r
51 }\r
52\r
53 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);\r
54 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {\r
55 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle), 2, 0xFF);\r
56 }\r
57\r
58 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);\r
59 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {\r
60 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle), 2, 0xFF);\r
61 }\r
62\r
63 if (LinkData->SubInstance == 1) {\r
64 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);\r
65 } else if (LinkData->SubInstance == 2) {\r
66 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);\r
67 } else if (LinkData->SubInstance == 3) {\r
68 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);\r
69 } else {\r
70 return EFI_INVALID_PARAMETER;\r
71 }\r
72\r
73 return SmbiosFldInterLink (\r
74 StructureNode,\r
75 FieldOffset,\r
76 7, // Smbios type 7 -- Cache Information\r
77 LinkData,\r
78 &gEfiCacheSubClassGuid // gProcessorSubClassName\r
79 );\r
80}\r
81\r
82/**\r
83 Field Filling Function for Processor SubClass record type 6 -- ProcessorID.\r
84 Offset is mandatory.\r
85 \r
86 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
87 @param Offset Offset of SMBIOS record which RecordData will be filled.\r
88 @param RecordData RecordData buffer will be filled.\r
89 @param RecordDataSize The size of RecordData buffer.\r
90 \r
91 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.\r
92**/\r
93EFI_STATUS\r
94SmbiosFldProcessorType6 (\r
95 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,\r
96 IN UINT32 Offset,\r
97 IN VOID *RecordData,\r
98 IN UINT32 RecordDataSize\r
99 )\r
100{\r
101 EFI_PROCESSOR_ID_DATA *ProcessorIdData;\r
102\r
103 ProcessorIdData = RecordData;\r
104 CopyMem (\r
105 (UINT8 *) (StructureNode->Structure) + Offset,\r
106 &(ProcessorIdData->Signature),\r
107 4\r
108 );\r
109\r
110 CopyMem (\r
111 (UINT8 *) (StructureNode->Structure) + Offset + 4,\r
112 &(ProcessorIdData->FeatureFlags),\r
113 4\r
114 );\r
115\r
116 return EFI_SUCCESS;\r
117}\r
118\r
119/**\r
120 Field Filling Function for Processor SubClass record type 9 -- Voltage.\r
121 Offset is mandatory.\r
122 \r
123 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
124 @param Offset Offset of SMBIOS record which RecordData will be filled.\r
125 @param RecordData RecordData buffer will be filled.\r
126 @param RecordDataSize The size of RecordData buffer.\r
127 \r
128 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.\r
129**/\r
130EFI_STATUS\r
131SmbiosFldProcessorType9 (\r
132 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,\r
133 IN UINT32 Offset,\r
134 IN VOID *RecordData,\r
135 IN UINT32 RecordDataSize\r
136 )\r
137{\r
138 EFI_EXP_BASE10_DATA *Base10Data;\r
139 INT16 Value;\r
140 INT16 Exponent;\r
141\r
142 if (RecordDataSize != sizeof (EFI_EXP_BASE10_DATA)) {\r
143 return EFI_INVALID_PARAMETER;\r
144 }\r
145\r
146 Base10Data = RecordData;\r
147 Value = Base10Data->Value;\r
148 Exponent = Base10Data->Exponent;\r
149\r
150 Exponent += 1;\r
151 while (Exponent != 0) {\r
152 if (Exponent > 0) {\r
153 Value = (INT16) (Value * 10);\r
154 Exponent--;\r
155 } else {\r
156 Value = (INT16) (Value / 10);\r
157 Exponent++;\r
158 }\r
159 }\r
160\r
161 * (UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) (Value | BIT7);\r
162\r
163 return EFI_SUCCESS;\r
164}\r