]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/PlatformSmbiosDxe/PlatformSmbiosDxe.c
EmulatorPkg: Apply uncrustify changes
[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
e3ba31da 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
afa99fac
GL
7\r
8**/\r
9\r
10#include <PiDxe.h>\r
11#include <IndustryStandard/SmBios.h>\r
12#include <Protocol/Smbios.h>\r
13\r
14#include <Library/BaseLib.h>\r
15#include <Library/BaseMemoryLib.h>\r
16#include <Library/DebugLib.h>\r
17#include <Library/SmbiosLib.h>\r
18#include <Library/HobLib.h>\r
19\r
a550d468 20extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[];\r
afa99fac 21\r
a550d468 22SMBIOS_TABLE_TYPE19 gSmbiosType19Template = {\r
afa99fac
GL
23 { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },\r
24 0xffffffff, // StartingAddress;\r
25 0xffffffff, // EndingAddress;\r
26 0, // MemoryArrayHandle;\r
27 1, // PartitionWidth;\r
28 0, // ExtendedStartingAddress;\r
29 0, // ExtendedEndingAddress;\r
30};\r
31\r
32VOID\r
33CreatePlatformSmbiosMemoryRecords (\r
34 VOID\r
35 )\r
36{\r
a550d468
MK
37 EFI_PEI_HOB_POINTERS HobPtr;\r
38 SMBIOS_STRUCTURE_POINTER Smbios16;\r
39 SMBIOS_STRUCTURE_POINTER Smbios17;\r
40 EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle;\r
41 EFI_SMBIOS_HANDLE SmbiosHandle;\r
afa99fac
GL
42\r
43 Smbios16.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, 0, &PhyscialMemoryArrayHandle);\r
44 if (Smbios16.Hdr == NULL) {\r
45 // Only make a Type19 entry if a Type16 entry exists.\r
46 return;\r
47 }\r
48\r
49 Smbios17.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_MEMORY_DEVICE, 0, &SmbiosHandle);\r
50 if (Smbios17.Hdr == NULL) {\r
51 // if type17 exits update with type16 Smbios handle\r
52 Smbios17.Type17->MemoryArrayHandle = PhyscialMemoryArrayHandle;\r
53 }\r
54\r
55 // Generate Type16 records\r
56 gSmbiosType19Template.MemoryArrayHandle = PhyscialMemoryArrayHandle;\r
a550d468 57 HobPtr.Raw = GetHobList ();\r
afa99fac
GL
58 while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, HobPtr.Raw)) != NULL) {\r
59 if (HobPtr.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
60 gSmbiosType19Template.ExtendedStartingAddress = HobPtr.ResourceDescriptor->PhysicalStart;\r
a550d468 61 gSmbiosType19Template.ExtendedEndingAddress =\r
79e4f2a5 62 HobPtr.ResourceDescriptor->PhysicalStart +\r
afa99fac 63 HobPtr.ResourceDescriptor->ResourceLength - 1;\r
79e4f2a5 64\r
afa99fac
GL
65 SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL);\r
66 }\r
a550d468 67\r
afa99fac
GL
68 HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
69 }\r
70}\r
71\r
afa99fac
GL
72/**\r
73 Main entry for this driver.\r
74\r
75 @param ImageHandle Image handle this driver.\r
76 @param SystemTable Pointer to SystemTable.\r
77\r
78 @retval EFI_SUCESS This function always complete successfully.\r
79\r
80**/\r
81EFI_STATUS\r
82EFIAPI\r
bfcf2624 83PlatformSmbiosDriverEntryPoint (\r
a550d468
MK
84 IN EFI_HANDLE ImageHandle,\r
85 IN EFI_SYSTEM_TABLE *SystemTable\r
afa99fac
GL
86 )\r
87{\r
a550d468
MK
88 EFI_STATUS Status;\r
89 EFI_SMBIOS_HANDLE SmbiosHandle;\r
90 SMBIOS_STRUCTURE_POINTER Smbios;\r
afa99fac 91\r
79e4f2a5 92 // Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform\r
afa99fac
GL
93 // to an early version of the specification.\r
94\r
95 // Phase 1 - Initialize SMBIOS tables from template\r
96 Status = SmbiosLibInitializeFromTemplate (gSmbiosTemplate);\r
97 ASSERT_EFI_ERROR (Status);\r
98\r
99 // Phase 2 - Patch SMBIOS table entries\r
100\r
101 Smbios.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_BIOS_INFORMATION, 0, &SmbiosHandle);\r
102 if (Smbios.Type0 != NULL) {\r
103 // 64K * (n+1) bytes\r
104 Smbios.Type0->BiosSize = (UINT8)DivU64x32 (FixedPcdGet64 (PcdEmuFirmwareFdSize), 64*1024) - 1;\r
105\r
106 SmbiosLibUpdateUnicodeString (\r
79e4f2a5
RN
107 SmbiosHandle,\r
108 Smbios.Type0->BiosVersion,\r
a550d468 109 (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)\r
afa99fac
GL
110 );\r
111 SmbiosLibUpdateUnicodeString (\r
79e4f2a5
RN
112 SmbiosHandle,\r
113 Smbios.Type0->BiosReleaseDate,\r
a550d468 114 (CHAR16 *)PcdGetPtr (PcdFirmwareReleaseDateString)\r
afa99fac
GL
115 );\r
116 }\r
117\r
79e4f2a5 118 // Phase 3 - Create tables from scratch\r
afa99fac
GL
119\r
120 // Create Type 13 record from EFI Variables\r
121 // Do we need this record for EFI as the info is available from EFI varaibles\r
122 // Also language types don't always match between EFI and SMBIOS\r
123 // CreateSmbiosLanguageInformation (1, gSmbiosLangToEfiLang);\r
124\r
125 CreatePlatformSmbiosMemoryRecords ();\r
126\r
127 return EFI_SUCCESS;\r
128}\r