]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
Append double-null for Type 19 data record.
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
6ae81428 1/**@file\r
8879d432 2\r
3e570e6e 3Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
8f2a5f80 4This program and the accompanying materials\r
8879d432 5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 MiscSubclassDriverEntryPoint.c\r
15\r
16Abstract:\r
17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
6ae81428 21**/\r
8879d432 22\r
8879d432 23#include "MiscSubclassDriver.h"\r
24\r
1fdd39d3 25EFI_HII_HANDLE mHiiHandle;\r
8879d432 26\r
1fdd39d3 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
8879d432 31\r
1fdd39d3 32 @param ImageHandle Handle for the image of this driver\r
33 @param SystemTable Pointer to the EFI System Table\r
8879d432 34\r
1fdd39d3 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
8879d432 39EFI_STATUS\r
1fdd39d3 40LogMemorySmbiosRecord (\r
41 VOID\r
8879d432 42 )\r
8879d432 43{\r
1fdd39d3 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 *Nt32MemString;\r
51\r
52 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
53 ASSERT_EFI_ERROR (Status);\r
54 \r
55 NumSlots = 1;\r
8879d432 56\r
57 //\r
1fdd39d3 58 // Process Memory String in form size!size ...\r
59 // So 64!64 is 128 MB\r
8879d432 60 //\r
1fdd39d3 61 Nt32MemString = PcdGetPtr (PcdWinNtMemorySize);\r
62 for (TotalMemorySize = 0; *Nt32MemString != '\0';) {\r
63 TotalMemorySize += StrDecimalToUint64 (Nt32MemString);\r
64 while (*Nt32MemString != '\0') {\r
65 if (*Nt32MemString == '!') {\r
66 Nt32MemString++; \r
67 break;\r
68 }\r
69 Nt32MemString++;\r
70 }\r
8879d432 71 }\r
1fdd39d3 72\r
73 //\r
74 // Convert Total Memory Size to based on KiloByte\r
8879d432 75 //\r
1fdd39d3 76 TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
8879d432 77 //\r
1fdd39d3 78 // Generate Memory Array Mapped Address info\r
79 //\r
3e570e6e 80 Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2);\r
1fdd39d3 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
87 Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
8879d432 88\r
89 //\r
1fdd39d3 90 // Generate Memory Array Mapped Address info (TYPE 19)\r
8879d432 91 //\r
7ee85aa2
SZ
92 Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
93\r
1fdd39d3 94 FreePool(Type19Record);\r
95 ASSERT_EFI_ERROR (Status);\r
8879d432 96\r
b397fbbb 97 return Status;\r
8879d432 98}\r
99\r
100\r
101EFI_STATUS\r
102EFIAPI\r
103MiscSubclassDriverEntryPoint (\r
104 IN EFI_HANDLE ImageHandle,\r
105 IN EFI_SYSTEM_TABLE *SystemTable\r
106 )\r
107/*++\r
108Description:\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
113Arguments:\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
121Returns:\r
122\r
123 EFI_SUCCESS\r
124 The data was successfully reported to the Data Hub.\r
125\r
126--*/\r
127{\r
1fdd39d3 128 UINTN Index;\r
129 EFI_STATUS EfiStatus;\r
130 EFI_SMBIOS_PROTOCOL *Smbios; \r
8879d432 131\r
1fdd39d3 132 EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
8879d432 133\r
1fdd39d3 134 if (EFI_ERROR(EfiStatus)) {\r
135 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
136 return EfiStatus;\r
8879d432 137 }\r
8879d432 138\r
1fdd39d3 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
8879d432 148 //\r
1fdd39d3 149 // If the entry have a function pointer, just log the data.\r
8879d432 150 //\r
1fdd39d3 151 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
152 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
8879d432 153 mMiscSubclassDataTable[Index].RecordData,\r
1fdd39d3 154 Smbios\r
8879d432 155 );\r
b397fbbb 156\r
1fdd39d3 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
b397fbbb 160 }\r
8879d432 161 }\r
8879d432 162 }\r
163\r
8879d432 164 //\r
1fdd39d3 165 // Log Memory SMBIOS Record\r
8879d432 166 //\r
1fdd39d3 167 EfiStatus = LogMemorySmbiosRecord();\r
168 return EfiStatus;\r
8879d432 169}\r
7ee85aa2
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
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
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
185EFI_STATUS\r
186AddSmbiosRecord (\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