2 Static SMBIOS Table for platform
5 Copyright (c) 2012, Apple Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <IndustryStandard/SmBios.h>
18 #include <Protocol/Smbios.h>
20 #include <Library/BaseLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/SmbiosLib.h>
24 #include <Library/HobLib.h>
26 extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate
[];
30 SMBIOS_TABLE_TYPE19 gSmbiosType19Template
= {
31 { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
, sizeof (SMBIOS_TABLE_TYPE19
), 0 },
32 0xffffffff, // StartingAddress;
33 0xffffffff, // EndingAddress;
34 0, // MemoryArrayHandle;
36 0, // ExtendedStartingAddress;
37 0, // ExtendedEndingAddress;
41 CreatePlatformSmbiosMemoryRecords (
45 EFI_PEI_HOB_POINTERS HobPtr
;
46 SMBIOS_STRUCTURE_POINTER Smbios16
;
47 SMBIOS_STRUCTURE_POINTER Smbios17
;
48 EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle
;
49 EFI_SMBIOS_HANDLE SmbiosHandle
;
51 Smbios16
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY
, 0, &PhyscialMemoryArrayHandle
);
52 if (Smbios16
.Hdr
== NULL
) {
53 // Only make a Type19 entry if a Type16 entry exists.
57 Smbios17
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_MEMORY_DEVICE
, 0, &SmbiosHandle
);
58 if (Smbios17
.Hdr
== NULL
) {
59 // if type17 exits update with type16 Smbios handle
60 Smbios17
.Type17
->MemoryArrayHandle
= PhyscialMemoryArrayHandle
;
63 // Generate Type16 records
64 gSmbiosType19Template
.MemoryArrayHandle
= PhyscialMemoryArrayHandle
;
65 HobPtr
.Raw
= GetHobList ();
66 while ((HobPtr
.Raw
= GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, HobPtr
.Raw
)) != NULL
) {
67 if (HobPtr
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) {
68 gSmbiosType19Template
.ExtendedStartingAddress
= HobPtr
.ResourceDescriptor
->PhysicalStart
;
69 gSmbiosType19Template
.ExtendedEndingAddress
=
70 HobPtr
.ResourceDescriptor
->PhysicalStart
+
71 HobPtr
.ResourceDescriptor
->ResourceLength
- 1;
73 SmbiosLibCreateEntry ((SMBIOS_STRUCTURE
*)&gSmbiosType19Template
, NULL
);
75 HobPtr
.Raw
= GET_NEXT_HOB (HobPtr
);
81 Main entry for this driver.
83 @param ImageHandle Image handle this driver.
84 @param SystemTable Pointer to SystemTable.
86 @retval EFI_SUCESS This function always complete successfully.
91 PlatfomrSmbiosDriverEntryPoint (
92 IN EFI_HANDLE ImageHandle
,
93 IN EFI_SYSTEM_TABLE
*SystemTable
97 EFI_SMBIOS_HANDLE SmbiosHandle
;
98 SMBIOS_STRUCTURE_POINTER Smbios
;
100 // Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform
101 // to an early version of the specification.
103 // Phase 1 - Initialize SMBIOS tables from template
104 Status
= SmbiosLibInitializeFromTemplate (gSmbiosTemplate
);
105 ASSERT_EFI_ERROR (Status
);
107 // Phase 2 - Patch SMBIOS table entries
109 Smbios
.Hdr
= SmbiosLibGetRecord (EFI_SMBIOS_TYPE_BIOS_INFORMATION
, 0, &SmbiosHandle
);
110 if (Smbios
.Type0
!= NULL
) {
112 Smbios
.Type0
->BiosSize
= (UINT8
)DivU64x32 (FixedPcdGet64 (PcdEmuFirmwareFdSize
), 64*1024) - 1;
114 SmbiosLibUpdateUnicodeString (
116 Smbios
.Type0
->BiosVersion
,
117 (CHAR16
*) PcdGetPtr (PcdFirmwareVersionString
)
119 SmbiosLibUpdateUnicodeString (
121 Smbios
.Type0
->BiosReleaseDate
,
122 (CHAR16
*) PcdGetPtr (PcdFirmwareReleaseDateString
)
126 // Phase 3 - Create tables from scratch
128 // Create Type 13 record from EFI Variables
129 // Do we need this record for EFI as the info is available from EFI varaibles
130 // Also language types don't always match between EFI and SMBIOS
131 // CreateSmbiosLanguageInformation (1, gSmbiosLangToEfiLang);
133 CreatePlatformSmbiosMemoryRecords ();