]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/DataHubSmBiosRecordsOnPiSmBiosThunk/ProcessorConv.c
Add a thunk driver to translate framework DataHub's smbios related record to PI SMBIO...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / DataHubSmBiosRecordsOnPiSmBiosThunk / ProcessorConv.c
1 /** @file
2 Routines that support Processor SubClass data records translation.
3
4 Copyright (c) 2009, Intel Corporation
5 All rights reserved. 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 "Thunk.h"
16
17 /**
18 Field Filling Function for Processor SubClass record type 17 -- Cache association.
19
20 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
21 @param Offset Offset of SMBIOS record which RecordData will be filled.
22 @param RecordData RecordData buffer will be filled.
23 @param RecordDataSize The size of RecordData buffer.
24
25 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
26 **/
27 EFI_STATUS
28 SmbiosFldProcessorType17 (
29 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
30 IN UINT32 Offset,
31 IN VOID *RecordData,
32 IN UINT32 RecordDataSize
33 )
34 {
35 EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
36 EFI_INTER_LINK_DATA *LinkData;
37 UINT16 FieldOffset;
38 UINT8 *Pointer;
39
40 DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) RecordData;
41 LinkData = (EFI_INTER_LINK_DATA *) (DataHeader + 1);
42 if (RecordDataSize != sizeof (EFI_INTER_LINK_DATA) + sizeof (EFI_SUBCLASS_TYPE1_HEADER)) {
43 return EFI_INVALID_PARAMETER;
44 }
45 //
46 // Determine the cache level
47 //
48 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);
49 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
50 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle), 2, 0xFF);
51 }
52
53 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);
54 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
55 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle), 2, 0xFF);
56 }
57
58 Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);
59 if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
60 SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle), 2, 0xFF);
61 }
62
63 if (LinkData->SubInstance == 1) {
64 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);
65 } else if (LinkData->SubInstance == 2) {
66 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);
67 } else if (LinkData->SubInstance == 3) {
68 FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);
69 } else {
70 return EFI_INVALID_PARAMETER;
71 }
72
73 return SmbiosFldInterLink (
74 StructureNode,
75 FieldOffset,
76 7, // Smbios type 7 -- Cache Information
77 LinkData,
78 &gEfiCacheSubClassGuid // gProcessorSubClassName
79 );
80 }
81
82 /**
83 Field Filling Function for Processor SubClass record type 6 -- ProcessorID.
84 Offset is mandatory.
85
86 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
87 @param Offset Offset of SMBIOS record which RecordData will be filled.
88 @param RecordData RecordData buffer will be filled.
89 @param RecordDataSize The size of RecordData buffer.
90
91 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
92 **/
93 EFI_STATUS
94 SmbiosFldProcessorType6 (
95 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
96 IN UINT32 Offset,
97 IN VOID *RecordData,
98 IN UINT32 RecordDataSize
99 )
100 {
101 EFI_PROCESSOR_ID_DATA *ProcessorIdData;
102
103 ProcessorIdData = RecordData;
104 CopyMem (
105 (UINT8 *) (StructureNode->Structure) + Offset,
106 &(ProcessorIdData->Signature),
107 4
108 );
109
110 CopyMem (
111 (UINT8 *) (StructureNode->Structure) + Offset + 4,
112 &(ProcessorIdData->FeatureFlags),
113 4
114 );
115
116 return EFI_SUCCESS;
117 }
118
119 /**
120 Field Filling Function for Processor SubClass record type 9 -- Voltage.
121 Offset is mandatory.
122
123 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
124 @param Offset Offset of SMBIOS record which RecordData will be filled.
125 @param RecordData RecordData buffer will be filled.
126 @param RecordDataSize The size of RecordData buffer.
127
128 @retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
129 **/
130 EFI_STATUS
131 SmbiosFldProcessorType9 (
132 IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
133 IN UINT32 Offset,
134 IN VOID *RecordData,
135 IN UINT32 RecordDataSize
136 )
137 {
138 EFI_EXP_BASE10_DATA *Base10Data;
139 INT16 Value;
140 INT16 Exponent;
141
142 if (RecordDataSize != sizeof (EFI_EXP_BASE10_DATA)) {
143 return EFI_INVALID_PARAMETER;
144 }
145
146 Base10Data = RecordData;
147 Value = Base10Data->Value;
148 Exponent = Base10Data->Exponent;
149
150 Exponent += 1;
151 while (Exponent != 0) {
152 if (Exponent > 0) {
153 Value = (INT16) (Value * 10);
154 Exponent--;
155 } else {
156 Value = (INT16) (Value / 10);
157 Exponent++;
158 }
159 }
160
161 * (UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) (Value | BIT7);
162
163 return EFI_SUCCESS;
164 }