]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
804405e7 1/*++\r
2\r
f9b8ab56
HT
3Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
804405e7 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
aaa2cc19 25EFI_HII_HANDLE mHiiHandle;\r
804405e7 26\r
aaa2cc19 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
804405e7 31\r
aaa2cc19 32 @param ImageHandle Handle for the image of this driver\r
33 @param SystemTable Pointer to the EFI System Table\r
804405e7 34\r
aaa2cc19 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
804405e7 37\r
aaa2cc19 38**/\r
39EFI_STATUS\r
40LogMemorySmbiosRecord (\r
41 VOID\r
42 )\r
804405e7 43{\r
aaa2cc19 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 *UnixMemString;\r
51\r
52 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
53 ASSERT_EFI_ERROR (Status);\r
54 \r
55 NumSlots = 1;\r
804405e7 56\r
57 //\r
aaa2cc19 58 // Process Memory String in form size!size ...\r
59 // So 64!64 is 128 MB\r
804405e7 60 //\r
aaa2cc19 61 UnixMemString = PcdGetPtr (PcdUnixMemorySize);\r
62 for (TotalMemorySize = 0; *UnixMemString != '\0';) {\r
63 TotalMemorySize += StrDecimalToUint64 (UnixMemString);\r
64 while (*UnixMemString != '\0') {\r
65 if (*UnixMemString == '!') {\r
66 UnixMemString++; \r
67 break;\r
68 }\r
69 UnixMemString++;\r
70 }\r
804405e7 71 }\r
aaa2cc19 72\r
73 //\r
74 // Convert Total Memory Size to based on KiloByte\r
804405e7 75 //\r
aaa2cc19 76 TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
804405e7 77 //\r
aaa2cc19 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
88 Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
804405e7 89\r
90 //\r
aaa2cc19 91 // Generate Memory Array Mapped Address info (TYPE 19)\r
804405e7 92 //\r
aaa2cc19 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
804405e7 97\r
aaa2cc19 98 return Status;\r
804405e7 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
aaa2cc19 129 UINTN Index;\r
130 EFI_STATUS EfiStatus;\r
131 EFI_SMBIOS_PROTOCOL *Smbios; \r
804405e7 132\r
aaa2cc19 133 EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
804405e7 134\r
aaa2cc19 135 if (EFI_ERROR(EfiStatus)) {\r
136 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
804405e7 137 return EfiStatus;\r
804405e7 138 }\r
139\r
aaa2cc19 140 mHiiHandle = HiiAddPackages (\r
141 &gEfiCallerIdGuid,\r
142 NULL,\r
143 MiscSubclassStrings,\r
144 NULL\r
145 );\r
146 ASSERT (mHiiHandle != NULL);\r
cb7d01c0 147\r
804405e7 148 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
149 //\r
aaa2cc19 150 // If the entry have a function pointer, just log the data.\r
804405e7 151 //\r
aaa2cc19 152 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
153 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
804405e7 154 mMiscSubclassDataTable[Index].RecordData,\r
aaa2cc19 155 Smbios\r
804405e7 156 );\r
804405e7 157\r
aaa2cc19 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
804405e7 161 }\r
804405e7 162 }\r
163 }\r
164\r
804405e7 165 //\r
aaa2cc19 166 // Log Memory SMBIOS Record\r
804405e7 167 //\r
aaa2cc19 168 EfiStatus = LogMemorySmbiosRecord();\r
169 return EfiStatus;\r
804405e7 170}\r