]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
1 /*++
2
3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 MiscSubclassDriverEntryPoint.c
15
16 Abstract:
17
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
20
21 --*/
22
23 #include "MiscSubClassDriver.h"
24
25 EFI_HII_HANDLE mHiiHandle;
26
27 /**
28 This is the standard EFI driver point that detects whether there is a
29 MemoryConfigurationData Variable and, if so, reports memory configuration info
30 to the DataHub.
31
32 @param ImageHandle Handle for the image of this driver
33 @param SystemTable Pointer to the EFI System Table
34
35 @return EFI_SUCCESS if the data is successfully reported
36 @return EFI_NOT_FOUND if the HOB list could not be located.
37
38 **/
39 EFI_STATUS
40 LogMemorySmbiosRecord (
41 VOID
42 )
43 {
44 EFI_STATUS Status;
45 UINT64 TotalMemorySize;
46 UINT8 NumSlots;
47 SMBIOS_TABLE_TYPE19 *Type19Record;
48 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;
49 EFI_SMBIOS_PROTOCOL *Smbios;
50 CHAR16 *UnixMemString;
51
52 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);
53 ASSERT_EFI_ERROR (Status);
54
55 NumSlots = 1;
56
57 //
58 // Process Memory String in form size!size ...
59 // So 64!64 is 128 MB
60 //
61 UnixMemString = PcdGetPtr (PcdUnixMemorySize);
62 for (TotalMemorySize = 0; *UnixMemString != '\0';) {
63 TotalMemorySize += StrDecimalToUint64 (UnixMemString);
64 while (*UnixMemString != '\0') {
65 if (*UnixMemString == '!') {
66 UnixMemString++;
67 break;
68 }
69 UnixMemString++;
70 }
71 }
72
73 //
74 // Convert Total Memory Size to based on KiloByte
75 //
76 TotalMemorySize = LShiftU64 (TotalMemorySize, 20);
77 //
78 // Generate Memory Array Mapped Address info
79 //
80 Type19Record = AllocatePool(sizeof (SMBIOS_TABLE_TYPE19));
81 ZeroMem(Type19Record, sizeof(SMBIOS_TABLE_TYPE19));
82 Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;
83 Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);
84 Type19Record->Hdr.Handle = 0;
85 Type19Record->StartingAddress = 0;
86 Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1;
87 Type19Record->MemoryArrayHandle = 0;
88 Type19Record->PartitionWidth = (UINT8)(NumSlots);
89
90 //
91 // Generate Memory Array Mapped Address info (TYPE 19)
92 //
93 MemArrayMappedAddrSmbiosHandle = 0;
94 Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);
95 FreePool(Type19Record);
96 ASSERT_EFI_ERROR (Status);
97
98 return Status;
99 }
100
101
102 EFI_STATUS
103 EFIAPI
104 MiscSubclassDriverEntryPoint (
105 IN EFI_HANDLE ImageHandle,
106 IN EFI_SYSTEM_TABLE *SystemTable
107 )
108 /*++
109 Description:
110
111 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
112 structure and reports any generated data to the DataHub.
113
114 Arguments:
115
116 ImageHandle
117 Handle for the image of this driver
118
119 SystemTable
120 Pointer to the EFI System Table
121
122 Returns:
123
124 EFI_SUCCESS
125 The data was successfully reported to the Data Hub.
126
127 --*/
128 {
129 UINTN Index;
130 EFI_STATUS EfiStatus;
131 EFI_SMBIOS_PROTOCOL *Smbios;
132
133 EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);
134
135 if (EFI_ERROR(EfiStatus)) {
136 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));
137 return EfiStatus;
138 }
139
140 mHiiHandle = HiiAddPackages (
141 &gEfiCallerIdGuid,
142 NULL,
143 MiscSubclassStrings,
144 NULL
145 );
146 ASSERT (mHiiHandle != NULL);
147
148 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {
149 //
150 // If the entry have a function pointer, just log the data.
151 //
152 if (mMiscSubclassDataTable[Index].Function != NULL) {
153 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(
154 mMiscSubclassDataTable[Index].RecordData,
155 Smbios
156 );
157
158 if (EFI_ERROR(EfiStatus)) {
159 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));
160 return EfiStatus;
161 }
162 }
163 }
164
165 //
166 // Log Memory SMBIOS Record
167 //
168 EfiStatus = LogMemorySmbiosRecord();
169 return EfiStatus;
170 }