]>
Commit | Line | Data |
---|---|---|
6ae81428 | 1 | /**@file\r |
8879d432 | 2 | \r |
8f2a5f80 HT |
3 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials\r | |
8879d432 | 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 | |
6ae81428 | 21 | **/\r |
8879d432 | 22 | \r |
8879d432 | 23 | #include "MiscSubclassDriver.h"\r |
24 | \r | |
1fdd39d3 | 25 | EFI_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 | 39 | EFI_STATUS\r |
1fdd39d3 | 40 | LogMemorySmbiosRecord (\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 | |
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 | |
8879d432 | 89 | \r |
90 | //\r | |
1fdd39d3 | 91 | // Generate Memory Array Mapped Address info (TYPE 19)\r |
8879d432 | 92 | //\r |
1fdd39d3 | 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 | |
8879d432 | 97 | \r |
b397fbbb | 98 | return Status;\r |
8879d432 | 99 | }\r |
100 | \r | |
101 | \r | |
102 | EFI_STATUS\r | |
103 | EFIAPI\r | |
104 | MiscSubclassDriverEntryPoint (\r | |
105 | IN EFI_HANDLE ImageHandle,\r | |
106 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
107 | )\r | |
108 | /*++\r | |
109 | Description:\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 | |
114 | Arguments:\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 | |
122 | Returns:\r | |
123 | \r | |
124 | EFI_SUCCESS\r | |
125 | The data was successfully reported to the Data Hub.\r | |
126 | \r | |
127 | --*/\r | |
128 | {\r | |
1fdd39d3 | 129 | UINTN Index;\r |
130 | EFI_STATUS EfiStatus;\r | |
131 | EFI_SMBIOS_PROTOCOL *Smbios; \r | |
8879d432 | 132 | \r |
1fdd39d3 | 133 | EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r |
8879d432 | 134 | \r |
1fdd39d3 | 135 | if (EFI_ERROR(EfiStatus)) {\r |
136 | DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r | |
137 | return EfiStatus;\r | |
8879d432 | 138 | }\r |
8879d432 | 139 | \r |
1fdd39d3 | 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 | |
8879d432 | 149 | //\r |
1fdd39d3 | 150 | // If the entry have a function pointer, just log the data.\r |
8879d432 | 151 | //\r |
1fdd39d3 | 152 | if (mMiscSubclassDataTable[Index].Function != NULL) {\r |
153 | EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r | |
8879d432 | 154 | mMiscSubclassDataTable[Index].RecordData,\r |
1fdd39d3 | 155 | Smbios\r |
8879d432 | 156 | );\r |
b397fbbb | 157 | \r |
1fdd39d3 | 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 | |
b397fbbb | 161 | }\r |
8879d432 | 162 | }\r |
8879d432 | 163 | }\r |
164 | \r | |
8879d432 | 165 | //\r |
1fdd39d3 | 166 | // Log Memory SMBIOS Record\r |
8879d432 | 167 | //\r |
1fdd39d3 | 168 | EfiStatus = LogMemorySmbiosRecord();\r |
169 | return EfiStatus;\r | |
8879d432 | 170 | }\r |