]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
949f388f 1/*++\r
2\r
3Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
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
21**/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
25EFI_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
39EFI_STATUS\r
40LogMemorySmbiosRecord (\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
80 Type19Record = AllocatePool(sizeof (SMBIOS_TABLE_TYPE19));\r
81 ZeroMem(Type19Record, sizeof(SMBIOS_TABLE_TYPE19));\r
82 Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
83 Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
84 Type19Record->Hdr.Handle = 0;\r
85 Type19Record->StartingAddress = 0;\r
86 Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
87 Type19Record->MemoryArrayHandle = 0;\r
d18d8a1d 88 Type19Record->PartitionWidth = (UINT8)(NumSlots);\r
949f388f 89\r
90 //\r
91 // Generate Memory Array Mapped Address info (TYPE 19)\r
92 //\r
93 MemArrayMappedAddrSmbiosHandle = 0;\r
94 Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
95 FreePool(Type19Record);\r
96 ASSERT_EFI_ERROR (Status);\r
97\r
98 return Status;\r
99}\r
100\r
101\r
102EFI_STATUS\r
103EFIAPI\r
104MiscSubclassDriverEntryPoint (\r
105 IN EFI_HANDLE ImageHandle,\r
106 IN EFI_SYSTEM_TABLE *SystemTable\r
107 )\r
108/*++\r
109Description:\r
110\r
111 Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
112 structure and reports any generated data to the DataHub.\r
113\r
114Arguments:\r
115\r
116 ImageHandle\r
117 Handle for the image of this driver\r
118\r
119 SystemTable\r
120 Pointer to the EFI System Table\r
121\r
122Returns:\r
123\r
124 EFI_SUCCESS\r
125 The data was successfully reported to the Data Hub.\r
126\r
127**/\r
128{\r
129 UINTN Index;\r
130 EFI_STATUS EfiStatus;\r
d18d8a1d 131 EFI_SMBIOS_PROTOCOL *Smbios;\r
949f388f 132\r
133 EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
134\r
135 if (EFI_ERROR(EfiStatus)) {\r
136 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
137 return EfiStatus;\r
138 }\r
139\r
140 mHiiHandle = HiiAddPackages (\r
141 &gEfiCallerIdGuid,\r
142 NULL,\r
143 MiscSubclassStrings,\r
144 NULL\r
145 );\r
146 ASSERT (mHiiHandle != NULL);\r
147\r
148 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
149 //\r
150 // If the entry have a function pointer, just log the data.\r
151 //\r
152 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
153 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
154 mMiscSubclassDataTable[Index].RecordData,\r
155 Smbios\r
156 );\r
157\r
158 if (EFI_ERROR(EfiStatus)) {\r
159 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
160 return EfiStatus;\r
161 }\r
162 }\r
163 }\r
164\r
165 //\r
166 // Log Memory SMBIOS Record\r
167 //\r
168 EfiStatus = LogMemorySmbiosRecord();\r
169 return EfiStatus;\r
170}\r