]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c
EmulatorPkg: formalize line endings
[mirror_edk2.git] / EmulatorPkg / PlatformSmbiosDxe / PlatformSmbiosDxe.c
CommitLineData
afa99fac
GL
1/** @file\r
2 Static SMBIOS Table for platform\r
3\r
4\r
5 Copyright (c) 2012, Apple Inc. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <PiDxe.h>\r
17#include <IndustryStandard/SmBios.h>\r
18#include <Protocol/Smbios.h>\r
19\r
20#include <Library/BaseLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/SmbiosLib.h>\r
24#include <Library/HobLib.h>\r
25\r
26extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[];\r
27\r
28\r
29\r
30SMBIOS_TABLE_TYPE19 gSmbiosType19Template = {\r
31 { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },\r
32 0xffffffff, // StartingAddress;\r
33 0xffffffff, // EndingAddress;\r
34 0, // MemoryArrayHandle;\r
35 1, // PartitionWidth;\r
36 0, // ExtendedStartingAddress;\r
37 0, // ExtendedEndingAddress;\r
38};\r
39\r
40VOID\r
41CreatePlatformSmbiosMemoryRecords (\r
42 VOID\r
43 )\r
44{\r
45 EFI_PEI_HOB_POINTERS HobPtr;\r
46 SMBIOS_STRUCTURE_POINTER Smbios16;\r
47 SMBIOS_STRUCTURE_POINTER Smbios17;\r
48 EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle;\r
49 EFI_SMBIOS_HANDLE SmbiosHandle;\r
50\r
51 Smbios16.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, 0, &PhyscialMemoryArrayHandle);\r
52 if (Smbios16.Hdr == NULL) {\r
53 // Only make a Type19 entry if a Type16 entry exists.\r
54 return;\r
55 }\r
56\r
57 Smbios17.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_MEMORY_DEVICE, 0, &SmbiosHandle);\r
58 if (Smbios17.Hdr == NULL) {\r
59 // if type17 exits update with type16 Smbios handle\r
60 Smbios17.Type17->MemoryArrayHandle = PhyscialMemoryArrayHandle;\r
61 }\r
62\r
63 // Generate Type16 records\r
64 gSmbiosType19Template.MemoryArrayHandle = PhyscialMemoryArrayHandle;\r
65 HobPtr.Raw = GetHobList ();\r
66 while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, HobPtr.Raw)) != NULL) {\r
67 if (HobPtr.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
68 gSmbiosType19Template.ExtendedStartingAddress = HobPtr.ResourceDescriptor->PhysicalStart;\r
79e4f2a5
RN
69 gSmbiosType19Template.ExtendedEndingAddress =\r
70 HobPtr.ResourceDescriptor->PhysicalStart +\r
afa99fac 71 HobPtr.ResourceDescriptor->ResourceLength - 1;\r
79e4f2a5 72\r
afa99fac
GL
73 SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL);\r
74 }\r
75 HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
76 }\r
77}\r
78\r
79\r
80/**\r
81 Main entry for this driver.\r
82\r
83 @param ImageHandle Image handle this driver.\r
84 @param SystemTable Pointer to SystemTable.\r
85\r
86 @retval EFI_SUCESS This function always complete successfully.\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91PlatfomrSmbiosDriverEntryPoint (\r
92 IN EFI_HANDLE ImageHandle,\r
93 IN EFI_SYSTEM_TABLE *SystemTable\r
94 )\r
95{\r
96 EFI_STATUS Status;\r
97 EFI_SMBIOS_HANDLE SmbiosHandle;\r
98 SMBIOS_STRUCTURE_POINTER Smbios;\r
99\r
79e4f2a5 100 // Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform\r
afa99fac
GL
101 // to an early version of the specification.\r
102\r
103 // Phase 1 - Initialize SMBIOS tables from template\r
104 Status = SmbiosLibInitializeFromTemplate (gSmbiosTemplate);\r
105 ASSERT_EFI_ERROR (Status);\r
106\r
107 // Phase 2 - Patch SMBIOS table entries\r
108\r
109 Smbios.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_BIOS_INFORMATION, 0, &SmbiosHandle);\r
110 if (Smbios.Type0 != NULL) {\r
111 // 64K * (n+1) bytes\r
112 Smbios.Type0->BiosSize = (UINT8)DivU64x32 (FixedPcdGet64 (PcdEmuFirmwareFdSize), 64*1024) - 1;\r
113\r
114 SmbiosLibUpdateUnicodeString (\r
79e4f2a5
RN
115 SmbiosHandle,\r
116 Smbios.Type0->BiosVersion,\r
afa99fac
GL
117 (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString)\r
118 );\r
119 SmbiosLibUpdateUnicodeString (\r
79e4f2a5
RN
120 SmbiosHandle,\r
121 Smbios.Type0->BiosReleaseDate,\r
afa99fac
GL
122 (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString)\r
123 );\r
124 }\r
125\r
79e4f2a5 126 // Phase 3 - Create tables from scratch\r
afa99fac
GL
127\r
128 // Create Type 13 record from EFI Variables\r
129 // Do we need this record for EFI as the info is available from EFI varaibles\r
130 // Also language types don't always match between EFI and SMBIOS\r
131 // CreateSmbiosLanguageInformation (1, gSmbiosLangToEfiLang);\r
132\r
133 CreatePlatformSmbiosMemoryRecords ();\r
134\r
135 return EFI_SUCCESS;\r
136}\r