TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatformSmbiosDxe.c
Go to the documentation of this file.
1
10#include <PiDxe.h>
12#include <Protocol/Smbios.h>
13
14#include <Library/BaseLib.h>
16#include <Library/DebugLib.h>
17#include <Library/SmbiosLib.h>
18#include <Library/HobLib.h>
19
20extern SMBIOS_TEMPLATE_ENTRY gSmbiosTemplate[];
21
22SMBIOS_TABLE_TYPE19 gSmbiosType19Template = {
23 { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },
24 0xffffffff, // StartingAddress;
25 0xffffffff, // EndingAddress;
26 0, // MemoryArrayHandle;
27 1, // PartitionWidth;
28 0, // ExtendedStartingAddress;
29 0, // ExtendedEndingAddress;
30};
31
32VOID
33CreatePlatformSmbiosMemoryRecords (
34 VOID
35 )
36{
40 EFI_SMBIOS_HANDLE PhyscialMemoryArrayHandle;
41 EFI_SMBIOS_HANDLE SmbiosHandle;
42
43 Smbios16.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, 0, &PhyscialMemoryArrayHandle);
44 if (Smbios16.Hdr == NULL) {
45 // Only make a Type19 entry if a Type16 entry exists.
46 return;
47 }
48
49 Smbios17.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_MEMORY_DEVICE, 0, &SmbiosHandle);
50 if (Smbios17.Hdr == NULL) {
51 // if type17 exits update with type16 Smbios handle
52 Smbios17.Type17->MemoryArrayHandle = PhyscialMemoryArrayHandle;
53 }
54
55 // Generate Type16 records
56 gSmbiosType19Template.MemoryArrayHandle = PhyscialMemoryArrayHandle;
57 HobPtr.Raw = GetHobList ();
58 while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, HobPtr.Raw)) != NULL) {
59 if (HobPtr.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
60 gSmbiosType19Template.ExtendedStartingAddress = HobPtr.ResourceDescriptor->PhysicalStart;
61 gSmbiosType19Template.ExtendedEndingAddress =
62 HobPtr.ResourceDescriptor->PhysicalStart +
63 HobPtr.ResourceDescriptor->ResourceLength - 1;
64
65 SmbiosLibCreateEntry ((SMBIOS_STRUCTURE *)&gSmbiosType19Template, NULL);
66 }
67
68 HobPtr.Raw = GET_NEXT_HOB (HobPtr);
69 }
70}
71
82EFIAPI
84 IN EFI_HANDLE ImageHandle,
85 IN EFI_SYSTEM_TABLE *SystemTable
86 )
87{
88 EFI_STATUS Status;
89 EFI_SMBIOS_HANDLE SmbiosHandle;
91
92 // Phase 0 - Patch table to make SMBIOS 2.7 structures smaller to conform
93 // to an early version of the specification.
94
95 // Phase 1 - Initialize SMBIOS tables from template
96 Status = SmbiosLibInitializeFromTemplate (gSmbiosTemplate);
97 ASSERT_EFI_ERROR (Status);
98
99 // Phase 2 - Patch SMBIOS table entries
100
101 Smbios.Hdr = SmbiosLibGetRecord (EFI_SMBIOS_TYPE_BIOS_INFORMATION, 0, &SmbiosHandle);
102 if (Smbios.Type0 != NULL) {
103 // 64K * (n+1) bytes
104 Smbios.Type0->BiosSize = (UINT8)DivU64x32 (FixedPcdGet64 (PcdEmuFirmwareFdSize), 64*1024) - 1;
105
107 SmbiosHandle,
108 Smbios.Type0->BiosVersion,
109 (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)
110 );
112 SmbiosHandle,
113 Smbios.Type0->BiosReleaseDate,
114 (CHAR16 *)PcdGetPtr (PcdFirmwareReleaseDateString)
115 );
116 }
117
118 // Phase 3 - Create tables from scratch
119
120 // Create Type 13 record from EFI Variables
121 // Do we need this record for EFI as the info is available from EFI varaibles
122 // Also language types don't always match between EFI and SMBIOS
123 // CreateSmbiosLanguageInformation (1, gSmbiosLangToEfiLang);
124
125 CreatePlatformSmbiosMemoryRecords ();
126
127 return EFI_SUCCESS;
128}
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
Definition: HobLib.c:103
VOID *EFIAPI GetHobList(VOID)
Definition: HobLib.c:76
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
Definition: DivU64x32.c:29
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define FixedPcdGet64(TokenName)
Definition: PcdLib.h:106
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
EFI_STATUS EFIAPI PlatformSmbiosDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
SMBIOS_STRUCTURE *EFIAPI SmbiosLibGetRecord(IN EFI_SMBIOS_TYPE Type, IN UINTN Instance, OUT EFI_SMBIOS_HANDLE *SmbiosHandle)
Definition: SmbiosLib.c:278
EFI_STATUS EFIAPI SmbiosLibCreateEntry(IN SMBIOS_STRUCTURE *SmbiosEntry, IN CHAR8 **StringArray)
Definition: SmbiosLib.c:83
EFI_STATUS EFIAPI SmbiosLibInitializeFromTemplate(IN SMBIOS_TEMPLATE_ENTRY *Template)
Definition: SmbiosLib.c:34
EFI_STATUS EFIAPI SmbiosLibUpdateUnicodeString(IN EFI_SMBIOS_HANDLE SmbiosHandle, IN SMBIOS_TABLE_STRING StringNumber, IN CHAR16 *String)
Definition: SmbiosLib.c:199
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: PiHob.h:328
EFI_RESOURCE_TYPE ResourceType
Definition: PiHob.h:320