2 Static SMBIOS Table for platform
5 Copyright (c) 2012, Apple Inc. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <IndustryStandard/SmBios.h>
12 #include <Protocol/Smbios.h>
14 #include <Library/BaseLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/SmbiosLib.h>
18 #include <Library/HobLib.h>
20 extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate
[];
24 SMBIOS_TABLE_TYPE19 gSmbiosType19Template
= {
25 { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
, sizeof (SMBIOS_TABLE_TYPE19
), 0 },
26 0xffffffff, // StartingAddress;
27 0xffffffff, // EndingAddress;
28 0, // MemoryArrayHandle;
30 0, // ExtendedStartingAddress;
31 0, // ExtendedEndingAddress;
35 CreatePlatformSmbiosMemoryRecords (
39 EFI_PEI_HOB_POINTERS HobPtr
;
40 SMBIOS_STRUCTURE_POINTER Smbios16
;
41 SMBIOS_STRUCTURE_POINTER Smbios17
;
42 EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle
;
43 EFI_SMBIOS_HANDLE SmbiosHandle
;
45 Smbios16
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY
, 0, &PhyscialMemoryArrayHandle
);
46 if (Smbios16
.Hdr
== NULL
) {
47 // Only make a Type19 entry if a Type16 entry exists.
51 Smbios17
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_MEMORY_DEVICE
, 0, &SmbiosHandle
);
52 if (Smbios17
.Hdr
== NULL
) {
53 // if type17 exits update with type16 Smbios handle
54 Smbios17
.Type17
->MemoryArrayHandle
= PhyscialMemoryArrayHandle
;
57 // Generate Type16 records
58 gSmbiosType19Template
.MemoryArrayHandle
= PhyscialMemoryArrayHandle
;
59 HobPtr
.Raw
= GetHobList ();
60 while ((HobPtr
.Raw
= GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, HobPtr
.Raw
)) != NULL
) {
61 if (HobPtr
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) {
62 gSmbiosType19Template
.ExtendedStartingAddress
= HobPtr
.ResourceDescriptor
->PhysicalStart
;
63 gSmbiosType19Template
.ExtendedEndingAddress
=
64 HobPtr
.ResourceDescriptor
->PhysicalStart
+
65 HobPtr
.ResourceDescriptor
->ResourceLength
- 1;
67 SmbiosLibCreateEntry ((SMBIOS_STRUCTURE
*)&gSmbiosType19Template
, NULL
);
69 HobPtr
.Raw
= GET_NEXT_HOB (HobPtr
);
75 Main entry for this driver.
77 @param ImageHandle Image handle this driver.
78 @param SystemTable Pointer to SystemTable.
80 @retval EFI_SUCESS This function always complete successfully.
85 PlatfomrSmbiosDriverEntryPoint (
86 IN EFI_HANDLE ImageHandle
,
87 IN EFI_SYSTEM_TABLE
*SystemTable
91 EFI_SMBIOS_HANDLE SmbiosHandle
;
92 SMBIOS_STRUCTURE_POINTER Smbios
;
94 // Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform
95 // to an early version of the specification.
97 // Phase 1 - Initialize SMBIOS tables from template
98 Status
= SmbiosLibInitializeFromTemplate (gSmbiosTemplate
);
99 ASSERT_EFI_ERROR (Status
);
101 // Phase 2 - Patch SMBIOS table entries
103 Smbios
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_BIOS_INFORMATION
, 0, &SmbiosHandle
);
104 if (Smbios
.Type0
!= NULL
) {
106 Smbios
.Type0
->BiosSize
= (UINT8
)DivU64x32 (FixedPcdGet64 (PcdEmuFirmwareFdSize
), 64*1024) - 1;
108 SmbiosLibUpdateUnicodeString (
110 Smbios
.Type0
->BiosVersion
,
111 (CHAR16
*) PcdGetPtr (PcdFirmwareVersionString
)
113 SmbiosLibUpdateUnicodeString (
115 Smbios
.Type0
->BiosReleaseDate
,
116 (CHAR16
*) PcdGetPtr (PcdFirmwareReleaseDateString
)
120 // Phase 3 - Create tables from scratch
122 // Create Type 13 record from EFI Variables
123 // Do we need this record for EFI as the info is available from EFI varaibles
124 // Also language types don't always match between EFI and SMBIOS
125 // CreateSmbiosLanguageInformation (1, gSmbiosLangToEfiLang);
127 CreatePlatformSmbiosMemoryRecords ();