]>
Commit | Line | Data |
---|---|---|
949f388f | 1 | /*++\r |
2 | \r | |
3e570e6e | 3 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r |
949f388f | 4 | This program and the accompanying materials\r |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | MiscSubclassDriverEntryPoint.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | This driver parses the mMiscSubclassDataTable structure and reports\r | |
19 | any generated data to the DataHub.\r | |
20 | \r | |
21 | **/\r | |
22 | \r | |
23 | #include "MiscSubClassDriver.h"\r | |
24 | \r | |
25 | EFI_HII_HANDLE mHiiHandle;\r | |
26 | \r | |
27 | /**\r | |
28 | This is the standard EFI driver point that detects whether there is a\r | |
29 | MemoryConfigurationData Variable and, if so, reports memory configuration info\r | |
30 | to the DataHub.\r | |
31 | \r | |
32 | @param ImageHandle Handle for the image of this driver\r | |
33 | @param SystemTable Pointer to the EFI System Table\r | |
34 | \r | |
35 | @return EFI_SUCCESS if the data is successfully reported\r | |
36 | @return EFI_NOT_FOUND if the HOB list could not be located.\r | |
37 | \r | |
38 | **/\r | |
39 | EFI_STATUS\r | |
40 | LogMemorySmbiosRecord (\r | |
41 | VOID\r | |
42 | )\r | |
43 | {\r | |
44 | EFI_STATUS Status;\r | |
45 | UINT64 TotalMemorySize;\r | |
46 | UINT8 NumSlots;\r | |
47 | SMBIOS_TABLE_TYPE19 *Type19Record;\r | |
48 | EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;\r | |
49 | EFI_SMBIOS_PROTOCOL *Smbios;\r | |
50 | CHAR16 *MemString;\r | |
51 | \r | |
52 | Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r | |
53 | ASSERT_EFI_ERROR (Status);\r | |
d18d8a1d | 54 | \r |
949f388f | 55 | NumSlots = 1;\r |
56 | \r | |
57 | //\r | |
58 | // Process Memory String in form size!size ...\r | |
59 | // So 64!64 is 128 MB\r | |
60 | //\r | |
61 | MemString = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);\r | |
62 | for (TotalMemorySize = 0; *MemString != '\0';) {\r | |
63 | TotalMemorySize += StrDecimalToUint64 (MemString);\r | |
64 | while (*MemString != '\0') {\r | |
65 | if (*MemString == '!') {\r | |
d18d8a1d | 66 | MemString++;\r |
949f388f | 67 | break;\r |
68 | }\r | |
69 | MemString++;\r | |
70 | }\r | |
71 | }\r | |
72 | \r | |
73 | //\r | |
74 | // Convert Total Memory Size to based on KiloByte\r | |
75 | //\r | |
76 | TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r | |
77 | //\r | |
78 | // Generate Memory Array Mapped Address info\r | |
79 | //\r | |
3e570e6e | 80 | Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2);\r |
949f388f | 81 | Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r |
82 | Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r | |
83 | Type19Record->Hdr.Handle = 0;\r | |
84 | Type19Record->StartingAddress = 0;\r | |
85 | Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r | |
86 | Type19Record->MemoryArrayHandle = 0;\r | |
d18d8a1d | 87 | Type19Record->PartitionWidth = (UINT8)(NumSlots);\r |
949f388f | 88 | \r |
89 | //\r | |
90 | // Generate Memory Array Mapped Address info (TYPE 19)\r | |
91 | //\r | |
2bfd90f9 SZ |
92 | Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r |
93 | \r | |
949f388f | 94 | FreePool(Type19Record);\r |
95 | ASSERT_EFI_ERROR (Status);\r | |
96 | \r | |
97 | return Status;\r | |
98 | }\r | |
99 | \r | |
100 | \r | |
101 | EFI_STATUS\r | |
102 | EFIAPI\r | |
103 | MiscSubclassDriverEntryPoint (\r | |
104 | IN EFI_HANDLE ImageHandle,\r | |
105 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
106 | )\r | |
107 | /*++\r | |
108 | Description:\r | |
109 | \r | |
110 | Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r | |
111 | structure and reports any generated data to the DataHub.\r | |
112 | \r | |
113 | Arguments:\r | |
114 | \r | |
115 | ImageHandle\r | |
116 | Handle for the image of this driver\r | |
117 | \r | |
118 | SystemTable\r | |
119 | Pointer to the EFI System Table\r | |
120 | \r | |
121 | Returns:\r | |
122 | \r | |
123 | EFI_SUCCESS\r | |
124 | The data was successfully reported to the Data Hub.\r | |
125 | \r | |
126 | **/\r | |
127 | {\r | |
128 | UINTN Index;\r | |
129 | EFI_STATUS EfiStatus;\r | |
d18d8a1d | 130 | EFI_SMBIOS_PROTOCOL *Smbios;\r |
949f388f | 131 | \r |
132 | EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r | |
133 | \r | |
134 | if (EFI_ERROR(EfiStatus)) {\r | |
135 | DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r | |
136 | return EfiStatus;\r | |
137 | }\r | |
138 | \r | |
139 | mHiiHandle = HiiAddPackages (\r | |
140 | &gEfiCallerIdGuid,\r | |
141 | NULL,\r | |
142 | MiscSubclassStrings,\r | |
143 | NULL\r | |
144 | );\r | |
145 | ASSERT (mHiiHandle != NULL);\r | |
146 | \r | |
147 | for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r | |
148 | //\r | |
149 | // If the entry have a function pointer, just log the data.\r | |
150 | //\r | |
151 | if (mMiscSubclassDataTable[Index].Function != NULL) {\r | |
152 | EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r | |
153 | mMiscSubclassDataTable[Index].RecordData,\r | |
154 | Smbios\r | |
155 | );\r | |
156 | \r | |
157 | if (EFI_ERROR(EfiStatus)) {\r | |
158 | DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r | |
159 | return EfiStatus;\r | |
160 | }\r | |
161 | }\r | |
162 | }\r | |
163 | \r | |
164 | //\r | |
165 | // Log Memory SMBIOS Record\r | |
166 | //\r | |
167 | EfiStatus = LogMemorySmbiosRecord();\r | |
168 | return EfiStatus;\r | |
169 | }\r | |
2bfd90f9 SZ |
170 | \r |
171 | /**\r | |
172 | Add an SMBIOS record.\r | |
173 | \r | |
174 | @param Smbios The EFI_SMBIOS_PROTOCOL instance.\r | |
175 | @param SmbiosHandle A unique handle will be assigned to the SMBIOS record.\r | |
176 | @param Record The data for the fixed portion of the SMBIOS record. The format of the record is\r | |
79e4f2a5 RN |
177 | determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined\r |
178 | by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or\r | |
2bfd90f9 SZ |
179 | a set of null terminated strings and a null.\r |
180 | \r | |
181 | @retval EFI_SUCCESS Record was added.\r | |
182 | @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | AddSmbiosRecord (\r | |
187 | IN EFI_SMBIOS_PROTOCOL *Smbios,\r | |
188 | OUT EFI_SMBIOS_HANDLE *SmbiosHandle,\r | |
189 | IN EFI_SMBIOS_TABLE_HEADER *Record\r | |
190 | )\r | |
191 | {\r | |
192 | *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r | |
193 | return Smbios->Add (\r | |
194 | Smbios,\r | |
195 | NULL,\r | |
196 | SmbiosHandle,\r | |
197 | Record\r | |
198 | );\r | |
199 | }\r | |
200 | \r |