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