3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 This is the filter driver to retrieve data hub entries.
21 #include "PlatformSetupDxe.h"
22 #include <Protocol/LegacyBios.h>
23 #include <Protocol/PciRootBridgeIo.h>
24 #include <Protocol/SimpleNetwork.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/DiskInfo.h>
27 #include <Protocol/IdeControllerInit.h>
28 #include <Protocol/MpService.h>
29 #include <Protocol/PchPlatformPolicy.h>
30 #include <Protocol/CpuIo2.h>
31 #include <Protocol/Smbios.h>
32 #include <IndustryStandard/SmBios.h>
33 #include <Library/IoLib.h>
34 #include <Library/I2CLib.h>
35 #include <Guid/GlobalVariable.h>
37 #include "Valleyview.h"
38 #include "VlvAccess.h"
39 #include "PchAccess.h"
40 #include "SetupMode.h"
41 #include "PchCommonDefinitions.h"
42 #include <PlatformBaseAddresses.h>
58 SB_REV SBRevisionTable
[] = {
59 {V_PCH_LPC_RID_0
, "(A0 Stepping)"},
60 {V_PCH_LPC_RID_1
, "(A0 Stepping)"},
61 {V_PCH_LPC_RID_2
, "(A1 Stepping)"},
62 {V_PCH_LPC_RID_3
, "(A1 Stepping)"},
63 {V_PCH_LPC_RID_4
, "(B0 Stepping)"},
64 {V_PCH_LPC_RID_5
, "(B0 Stepping)"},
65 {V_PCH_LPC_RID_6
, "(B1 Stepping)"},
66 {V_PCH_LPC_RID_7
, "(B1 Stepping)"},
67 {V_PCH_LPC_RID_8
, "(B2 Stepping)"},
68 {V_PCH_LPC_RID_9
, "(B2 Stepping)"},
69 {V_PCH_LPC_RID_A
, "(B3 Stepping)"},
70 {V_PCH_LPC_RID_B
, "(B3 Stepping)"},
71 {V_PCH_LPC_RID_C
, "(C0 Stepping)"},
72 {V_PCH_LPC_RID_D
, "(C0 Stepping)"}
75 #define LEFT_JUSTIFY 0x01
76 #define PREFIX_SIGN 0x02
77 #define PREFIX_BLANK 0x04
78 #define COMMA_TYPE 0x08
79 #define LONG_TYPE 0x10
80 #define PREFIX_ZERO 0x20
82 #define ICH_REG_REV 0x08
83 #define MSR_IA32_PLATFORM_ID 0x17
86 BOOLEAN mSetupInfoDone
= FALSE
;
87 UINT8 mUseProductKey
= 0;
88 EFI_EXP_BASE10_DATA mProcessorFrequency
;
89 EFI_EXP_BASE10_DATA mProcessorFsbFrequency
;
91 EFI_GUID mProcessorProducerGuid
;
92 EFI_HII_HANDLE mHiiHandle
;
93 EFI_PLATFORM_CPU_INFO mPlatformCpuInfo
;
94 SYSTEM_CONFIGURATION mSystemConfiguration
;
95 EFI_PLATFORM_INFO_HOB
*mPlatformInfo
;
100 UINT16 mMemorySpeed
= 0xffff;
101 EFI_PHYSICAL_ADDRESS mMemorySizeChannelASlot0
= 0;
102 UINT16 mMemorySpeedChannelASlot0
= 0xffff;
103 EFI_PHYSICAL_ADDRESS mMemorySizeChannelASlot1
= 0;
104 UINT16 mMemorySpeedChannelASlot1
= 0xffff;
105 EFI_PHYSICAL_ADDRESS mMemorySizeChannelBSlot0
= 0;
106 UINT16 mMemorySpeedChannelBSlot0
= 0xffff;
107 EFI_PHYSICAL_ADDRESS mMemorySizeChannelBSlot1
= 0;
108 UINT16 mMemorySpeedChannelBSlot1
= 0xffff;
109 EFI_PHYSICAL_ADDRESS mMemorySizeChannelCSlot0
= 0;
110 UINT16 mMemorySpeedChannelCSlot0
= 0xffff;
111 EFI_PHYSICAL_ADDRESS mMemorySizeChannelCSlot1
= 0;
112 UINT16 mMemorySpeedChannelCSlot1
= 0xffff;
113 UINTN mMemoryMode
= 0xff;
115 #define CHARACTER_NUMBER_FOR_VALUE 30
117 EFI_STRING_TOKEN MemoryDeviceLocator
;
118 EFI_STRING_TOKEN MemoryBankLocator
;
119 EFI_STRING_TOKEN MemoryManufacturer
;
120 EFI_STRING_TOKEN MemorySerialNumber
;
121 EFI_STRING_TOKEN MemoryAssetTag
;
122 EFI_STRING_TOKEN MemoryPartNumber
;
123 EFI_INTER_LINK_DATA MemoryArrayLink
;
124 EFI_INTER_LINK_DATA MemorySubArrayLink
;
125 UINT16 MemoryTotalWidth
;
126 UINT16 MemoryDataWidth
;
127 UINT64 MemoryDeviceSize
;
128 EFI_MEMORY_FORM_FACTOR MemoryFormFactor
;
129 UINT8 MemoryDeviceSet
;
130 EFI_MEMORY_ARRAY_TYPE MemoryType
;
131 EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail
;
133 EFI_MEMORY_STATE MemoryState
;
134 } EFI_MEMORY_ARRAY_LINK
;
138 EFI_PHYSICAL_ADDRESS MemoryArrayStartAddress
;
139 EFI_PHYSICAL_ADDRESS MemoryArrayEndAddress
;
140 EFI_INTER_LINK_DATA PhysicalMemoryArrayLink
;
141 UINT16 MemoryArrayPartitionWidth
;
142 } EFI_MEMORY_ARRAY_START_ADDRESS
;
146 PCH_SATA_MODE_IDE
= 0,
153 Acquire the string associated with the Index from smbios structure and return it.
154 The caller is responsible for free the string buffer.
156 @param OptionalStrStart The start position to search the string
157 @param Index The index of the string to extract
158 @param String The string that is extracted
160 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
164 GetOptionalStringByIndex (
165 IN CHAR8
*OptionalStrStart
,
173 *String
= AllocateZeroPool (sizeof (CHAR16
));
180 OptionalStrStart
+= StrSize
;
181 StrSize
= AsciiStrSize (OptionalStrStart
);
182 } while (OptionalStrStart
[StrSize
] != 0 && Index
!= 0);
184 if ((Index
!= 0) || (StrSize
== 1)) {
186 // Meet the end of strings set but Index is non-zero, or
187 // Find an empty string
189 return EFI_NOT_FOUND
;
191 *String
= AllocatePool (StrSize
* sizeof (CHAR16
));
192 AsciiStrToUnicodeStr (OptionalStrStart
, *String
);
199 VSPrint worker function that prints a Value as a decimal number in Buffer
201 @param Buffer Location to place ascii decimal number string of Value.
202 @param Value Decimal value to convert to a string in Buffer.
203 @param Flags Flags to use in printing decimal string, see file header for details.
204 @param Width Width of hex value.
206 Number of characters printed.
211 IN OUT CHAR16
*Buffer
,
217 CHAR16 TempBuffer
[CHARACTER_NUMBER_FOR_VALUE
];
225 BOOLEAN ValueIsNegative
;
228 TempStr
= TempBuffer
;
232 ValueIsNegative
= FALSE
;
234 if (Width
> CHARACTER_NUMBER_FOR_VALUE
- 1) {
235 Width
= CHARACTER_NUMBER_FOR_VALUE
- 1;
240 ValueIsNegative
= TRUE
;
245 Value
= (INT64
)DivU64x32 ((UINT64
)Value
, 10);
246 Remainder
= (UINTN
)((UINT64
)TempValue
- 10 * Value
);
247 *(TempStr
++) = (CHAR16
)(Remainder
+ '0');
250 if ((Flags
& COMMA_TYPE
) == COMMA_TYPE
) {
251 if (ValueCharNum
% 3 == 0 && Value
!= 0) {
256 } while (Value
!= 0);
258 if (ValueIsNegative
) {
263 if ((Flags
& PREFIX_ZERO
) && !ValueIsNegative
) {
270 if (!(Flags
& LEFT_JUSTIFY
)) {
271 for (; Index
< Width
; Index
++) {
272 *(TempStr
++) = Prefix
;
277 // Reverse temp string into Buffer.
279 if (Width
> 0 && (UINTN
) (TempStr
- TempBuffer
) > Width
) {
280 TempStr
= TempBuffer
+ Width
;
283 while (TempStr
!= TempBuffer
) {
284 *(BufferPtr
++) = *(--TempStr
);
292 static CHAR16 mHexStr
[] = { L
'0', L
'1', L
'2', L
'3', L
'4', L
'5', L
'6', L
'7',
293 L
'8', L
'9', L
'A', L
'B', L
'C', L
'D', L
'E', L
'F' };
296 VSPrint worker function that prints a Value as a hex number in Buffer
298 @param Buffer Location to place ascii hex string of Value.
299 @param Value Hex value to convert to a string in Buffer.
300 @param Flags Flags to use in printing Hex string, see file header for details.
301 @param Width Width of hex value.
303 @retval Number of characters printed.
308 IN OUT CHAR16
*Buffer
,
314 CHAR16 TempBuffer
[CHARACTER_NUMBER_FOR_VALUE
];
321 TempStr
= TempBuffer
;
325 // Count starts at one since we will null terminate. Each iteration of the
326 // loop picks off one nibble. Oh yea TempStr ends up backwards
330 if (Width
> CHARACTER_NUMBER_FOR_VALUE
- 1) {
331 Width
= CHARACTER_NUMBER_FOR_VALUE
- 1;
335 Index
= ((UINTN
)Value
& 0xf);
336 *(TempStr
++) = mHexStr
[Index
];
337 Value
= RShiftU64 (Value
, 4);
339 } while (Value
!= 0);
341 if (Flags
& PREFIX_ZERO
) {
348 if (!(Flags
& LEFT_JUSTIFY
)) {
349 for (; Index
< Width
; Index
++) {
350 *(TempStr
++) = Prefix
;
355 // Reverse temp string into Buffer.
357 if (Width
> 0 && (UINTN
) (TempStr
- TempBuffer
) > Width
) {
358 TempStr
= TempBuffer
+ Width
;
361 while (TempStr
!= TempBuffer
) {
362 *(BufferPtr
++) = *(--TempStr
);
371 Converts MAC address to Unicode string.
372 The value is 64-bit and the resulting string will be 12
373 digit hex number in pairs of digits separated by dashes.
375 @param String string that will contain the value
376 @param MacAddr add argument and description to function comment
377 @param AddrSize add argument and description to function comment
383 IN EFI_MAC_ADDRESS
*MacAddr
,
389 for (i
= 0; i
< AddrSize
; i
++) {
393 MacAddr
->Addr
[i
] & 0xFF,
400 // Terminate the string.
402 String
[2 * AddrSize
] = L
'\0';
407 VOID
UpdateLatestBootTime() {
412 if (mSystemConfiguration
.LogBootTime
!= 1) {
415 VarSize
= sizeof(TimeValue
);
416 Status
= gRT
->GetVariable(
418 &gEfiNormalSetupGuid
,
423 if (EFI_ERROR(Status
)) {
426 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d ms", (UINT32
)TimeValue
);
427 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_LOG_BOOT_TIME_VALUE
), Buffer
, NULL
);
431 Get Cache Type for the specified Cache. This function is invoked when there is data records
432 available in the Data Hub.
434 Get Cache Type function arguments:
436 @param Instance The instance number of the subclass with the same ProducerName..
437 @param SubInstance The instance number of the RecordType for the same Instance.
438 @param CacheType Cache type, see definition of EFI_CACHE_TYPE_DATA.
446 IN UINT16 SubInstance
,
447 IN EFI_CACHE_TYPE_DATA
* CacheType
)
450 EFI_DATA_HUB_PROTOCOL
*DataHub
;
451 EFI_DATA_RECORD_HEADER
*Record
;
452 UINT64 MonotonicCount
;
453 EFI_CACHE_VARIABLE_RECORD
* CacheVariableRecord
;
454 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
456 Status
= gBS
->LocateProtocol (
457 &gEfiDataHubProtocolGuid
,
461 ASSERT_EFI_ERROR(Status
);
464 // Get all available data records from data hub
470 Status
= DataHub
->GetNextRecord (
476 if (!EFI_ERROR(Status
)) {
477 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
478 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
480 if(CompareGuid(&Record
->DataRecordGuid
, &gEfiCacheSubClassGuid
) &&
481 (DataHeader
->RecordType
== CacheTypeRecordType
) &&
482 (DataHeader
->Instance
== Instance
) &&
483 (DataHeader
->SubInstance
== SubInstance
)) {
484 CacheVariableRecord
= (EFI_CACHE_VARIABLE_RECORD
*)(DataHeader
+ 1);
486 *CacheType
= CacheVariableRecord
->CacheType
;
492 } while(!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
494 return EFI_NOT_FOUND
;
498 Setup data filter function. This function is invoked when there is data records
499 available in the Data Hub.
502 Standard event notification function arguments:
503 @param Event The event that is signaled.
504 @param Context Not used here.
510 PrepareSetupInformation (
515 EFI_DATA_HUB_PROTOCOL
*DataHub
;
516 EFI_DATA_RECORD_HEADER
*Record
;
518 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
521 CHAR16
*NewStringToken
;
522 STRING_REF TokenToUpdate
;
523 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
527 EFI_PROCESSOR_MICROCODE_REVISION_DATA
*CpuUcodeRevisionData
;
528 EFI_MEMORY_ARRAY_START_ADDRESS
*MemoryArray
;
529 EFI_MEMORY_ARRAY_LINK
*MemoryArrayLink
;
530 UINT64 MonotonicCount
;
532 CHAR16 Version
[100]; //Assuming that strings are < 100 UCHAR
533 CHAR16 ReleaseDate
[100]; //Assuming that strings are < 100 UCHAR
534 CHAR16 ReleaseTime
[100]; //Assuming that strings are < 100 UCHAR
536 NewString
= AllocateZeroPool (0x100);
537 NewString2
= AllocateZeroPool (0x100);
538 SetMem(Version
, sizeof(Version
), 0);
539 SetMem(ReleaseDate
, sizeof(ReleaseDate
), 0);
540 SetMem(ReleaseTime
, sizeof(ReleaseTime
), 0);
543 // Get the Data Hub Protocol. Assume only one instance
545 Status
= gBS
->LocateProtocol (&gEfiDataHubProtocolGuid
, NULL
, (void **)&DataHub
);
546 ASSERT_EFI_ERROR(Status
);
549 // Get all available data records from data hub
555 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
556 if (!EFI_ERROR(Status
)) {
557 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
558 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
559 SrcData
= (UINT8
*)(DataHeader
+ 1);
564 if (CompareGuid(&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
)) {
565 CopyMem (&mProcessorProducerGuid
, &Record
->ProducerName
, sizeof(EFI_GUID
));
566 switch (DataHeader
->RecordType
) {
567 case ProcessorCoreFrequencyRecordType
:
568 CopyMem(&mProcessorFrequency
, SrcData
, sizeof(EFI_EXP_BASE10_DATA
));
569 Index
= EfiValueToString (
571 ConvertBase10ToRaw ((EFI_EXP_BASE10_DATA
*)SrcData
)/1000000000,
575 StrCat (NewString
, L
".");
577 NewString
+ Index
+ 1,
578 ((ConvertBase10ToRaw ((EFI_EXP_BASE10_DATA
*)SrcData
)%1000000000)/10000000),
582 StrCat (NewString
, L
" GHz");
583 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_SPEED_VALUE
;
584 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
587 case ProcessorVersionRecordType
:
588 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*)SrcData
;
589 NewStringToken
= HiiGetPackageString(&mProcessorProducerGuid
, *ProcessorVersion
, NULL
);
590 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_VERSION_VALUE
;
591 HiiSetString(mHiiHandle
, TokenToUpdate
, NewStringToken
, NULL
);
593 case CpuUcodeRevisionDataRecordType
:
594 CpuUcodeRevisionData
= (EFI_PROCESSOR_MICROCODE_REVISION_DATA
*) SrcData
;
595 if (CpuUcodeRevisionData
->ProcessorMicrocodeRevisionNumber
!= 0) {
598 CpuUcodeRevisionData
->ProcessorMicrocodeRevisionNumber
,
602 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_MICROCODE_VALUE
;
603 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
613 } else if (CompareGuid(&Record
->DataRecordGuid
, &gEfiCacheSubClassGuid
) &&
614 (DataHeader
->RecordType
== CacheSizeRecordType
)) {
615 if (DataHeader
->SubInstance
== EFI_CACHE_L1
) {
616 EFI_CACHE_TYPE_DATA CacheType
;
617 if (EFI_SUCCESS
== GetCacheType(DataHeader
->Instance
, DataHeader
->SubInstance
,&CacheType
)){
618 if (CacheType
== EfiCacheTypeData
) {
619 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L1_DATA_CACHE_VALUE
;
620 } else if (CacheType
== EfiCacheTypeInstruction
) {
621 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L1_INSTR_CACHE_VALUE
;
629 else if (DataHeader
->SubInstance
== EFI_CACHE_L2
) {
630 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L2_CACHE_VALUE
;
634 if (ConvertBase2ToRaw((EFI_EXP_BASE2_DATA
*)SrcData
)) {
635 DataOutput
= ConvertBase2ToRaw((EFI_EXP_BASE2_DATA
*)SrcData
) >> 10;
636 EfiValueToString (NewString
, DataOutput
, PREFIX_ZERO
, 0);
638 StrCat (NewString
, L
" KB");
639 if (DataHeader
->SubInstance
== EFI_CACHE_L3
) {
640 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
641 } else if(DataHeader
->SubInstance
== EFI_CACHE_L2
&& mPlatformCpuInfo
.CpuPackage
.CoresPerPhysicalPackage
> 1){
647 mPlatformCpuInfo
.CpuPackage
.CoresPerPhysicalPackage
,
651 StrCat(NewString2
, L
"x ");
652 StrCat(NewString2
, NewString
);
653 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString2
, NULL
);
655 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
662 } else if (CompareGuid(&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
)) {
663 switch (DataHeader
->RecordType
) {
664 case EFI_MEMORY_ARRAY_LINK_RECORD_NUMBER
:
665 MemoryArrayLink
= (EFI_MEMORY_ARRAY_LINK
*)SrcData
;
667 if (MemoryArrayLink
->MemorySpeed
> 0) {
669 // Save the lowest speed memory module
671 if (MemoryArrayLink
->MemorySpeed
< mMemorySpeed
) {
672 mMemorySpeed
= MemoryArrayLink
->MemorySpeed
;
674 switch (DataHeader
->SubInstance
) {
676 mMemorySpeedChannelASlot0
= MemoryArrayLink
->MemorySpeed
;
677 mMemorySizeChannelASlot0
= MemoryArrayLink
->MemoryDeviceSize
;
680 mMemorySpeedChannelASlot1
= MemoryArrayLink
->MemorySpeed
;
681 mMemorySizeChannelASlot1
= MemoryArrayLink
->MemoryDeviceSize
;
684 mMemorySpeedChannelBSlot0
= MemoryArrayLink
->MemorySpeed
;
685 mMemorySizeChannelBSlot0
= MemoryArrayLink
->MemoryDeviceSize
;
688 mMemorySpeedChannelBSlot1
= MemoryArrayLink
->MemorySpeed
;
689 mMemorySizeChannelBSlot1
= MemoryArrayLink
->MemoryDeviceSize
;
692 mMemorySpeedChannelCSlot0
= MemoryArrayLink
->MemorySpeed
;
693 mMemorySizeChannelCSlot0
= MemoryArrayLink
->MemoryDeviceSize
;
696 mMemorySpeedChannelCSlot1
= MemoryArrayLink
->MemorySpeed
;
697 mMemorySizeChannelCSlot1
= MemoryArrayLink
->MemoryDeviceSize
;
705 case EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
:
706 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS
*)SrcData
;
707 if (MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
) {
708 DataOutput
= (UINTN
)RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20);
709 EfiValueToString (NewString
, DataOutput
/ 1024, PREFIX_ZERO
, 0);
710 if(DataOutput
% 1024) {
711 StrCat (NewString
, L
".");
712 DataOutput
= ((DataOutput
% 1024) * 1000) / 1024;
713 while(!(DataOutput
% 10))
714 DataOutput
= DataOutput
/ 10;
715 EfiValueToString (NewString2
, DataOutput
, PREFIX_ZERO
, 0);
716 StrCat (NewString
, NewString2
);
718 StrCat (NewString
, L
" GB");
719 TokenToUpdate
= (STRING_REF
)STR_TOTAL_MEMORY_SIZE_VALUE
;
720 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
730 } while (!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
732 Status
= GetBiosVersionDateTime (
738 DEBUG ((EFI_D_ERROR
, "GetBiosVersionDateTime :%s %s %s \n", Version
, ReleaseDate
, ReleaseTime
));
739 if (!EFI_ERROR (Status
)) {
741 CHAR16
*BuildDateTime
;
743 Length
= StrLen(ReleaseDate
) + StrLen(ReleaseTime
);
745 BuildDateTime
= AllocateZeroPool ((Length
+2) * sizeof(CHAR16
));
746 StrCpy (BuildDateTime
, ReleaseDate
);
747 StrCat (BuildDateTime
, L
" ");
748 StrCat (BuildDateTime
, ReleaseTime
);
750 TokenToUpdate
= (STRING_REF
)STR_BIOS_VERSION_VALUE
;
751 DEBUG ((EFI_D_ERROR
, "update STR_BIOS_VERSION_VALUE\n"));
752 HiiSetString(mHiiHandle
, TokenToUpdate
, Version
, NULL
);
754 TokenToUpdate
= (STRING_REF
)STR_BIOS_BUILD_TIME_VALUE
;
755 DEBUG ((EFI_D_ERROR
, "update STR_BIOS_BUILD_TIME_VALUE\n"));
756 HiiSetString(mHiiHandle
, TokenToUpdate
, BuildDateTime
, NULL
);
760 // Calculate and update memory speed display in Main Page
763 // Update the overall memory speed
765 if (mMemorySpeed
!= 0xffff) {
766 EfiValueToString (NewString
, mMemorySpeed
, PREFIX_ZERO
, 0);
767 StrCat (NewString
, L
" MHz");
769 TokenToUpdate
= (STRING_REF
)STR_SYSTEM_MEMORY_SPEED_VALUE
;
770 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
773 gBS
->FreePool(NewString
);
774 gBS
->FreePool(NewString2
);
781 Routine Description: update the SETUP info for "Additional Information" which is SMBIOS info.
787 UpdateAdditionalInformation (
791 UINT64 MonotonicCount
;
792 EFI_DATA_HUB_PROTOCOL
*DataHub
;
793 EFI_DATA_RECORD_HEADER
*Record
;
794 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
795 EFI_SMBIOS_PROTOCOL
*Smbios
;
796 EFI_SMBIOS_HANDLE SmbiosHandle
;
797 EFI_SMBIOS_TABLE_HEADER
*SmbiosRecord
;
798 SMBIOS_TABLE_TYPE0
*Type0Record
;
800 CHAR16
*BiosVersion
= NULL
;
801 CHAR16
*IfwiVersion
= NULL
;
803 EFI_STRING_ID TokenToUpdate
;
804 #if defined( RVP_SUPPORT ) && RVP_SUPPORT
805 EFI_MISC_SYSTEM_MANUFACTURER
*SystemManufacturer
;
808 Status
= gBS
->LocateProtocol (
809 &gEfiDataHubProtocolGuid
,
814 ASSERT_EFI_ERROR(Status
);
819 Status
= DataHub
->GetNextRecord (
825 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
826 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
828 if (CompareGuid(&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
829 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)) {
830 #if defined( RVP_SUPPORT ) && RVP_SUPPORT
832 // System Information
834 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER
*)(DataHeader
+ 1);
837 // UUID (System Information)
839 SMBIOSString
= EfiLibAllocateZeroPool (0x100);
840 GuidToString ( &SystemManufacturer
->SystemUuid
, SMBIOSString
, 0x00 );
842 TokenToUpdate
= (STRING_REF
)STR_SYSTEM_UUID_VALUE
;
843 HiiSetString(mHiiHandle
, TokenToUpdate
, SMBIOSString
, NULL
);
845 gBS
->FreePool(SMBIOSString
);
849 } while (!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
851 Status
= gBS
->LocateProtocol (
852 &gEfiSmbiosProtocolGuid
,
856 ASSERT_EFI_ERROR (Status
);
858 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
860 Status
= Smbios
->GetNext (
867 if (SmbiosRecord
->Type
== EFI_SMBIOS_TYPE_BIOS_INFORMATION
) {
868 Type0Record
= (SMBIOS_TABLE_TYPE0
*) SmbiosRecord
;
869 StrIndex
= Type0Record
->BiosVersion
;
870 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type0Record
+ Type0Record
->Hdr
.Length
), StrIndex
, &BiosVersion
);
871 TokenToUpdate
= STRING_TOKEN (STR_BIOS_VERSION_VALUE
);
872 for (SearchIndex
= 0x0; SearchIndex
< SMBIOS_STRING_MAX_LENGTH
; SearchIndex
++) {
873 if (BiosVersion
[SearchIndex
] == 0x0020) {
874 BiosVersion
[SearchIndex
] = 0x0000;
875 IfwiVersion
= (CHAR16
*)(&BiosVersion
[SearchIndex
+1]);
877 } else if (BiosVersion
[SearchIndex
] == 0x0000) {
881 HiiSetString (mHiiHandle
, TokenToUpdate
, BiosVersion
, NULL
);
884 // Check IfwiVersion, to avoid no IFWI version in SMBIOS Type 0 strucntion
887 TokenToUpdate
= STRING_TOKEN (STR_IFWI_VERSION_VALUE
);
888 HiiSetString (mHiiHandle
, TokenToUpdate
, IfwiVersion
, NULL
);
891 } while (!EFI_ERROR(Status
));
893 UpdateLatestBootTime();
899 UpdateCPUInformation ()
907 EFI_MP_SERVICES_PROTOCOL
*MpService
;
908 UINTN MaximumNumberOfCPUs
;
909 UINTN NumberOfEnabledCPUs
;
910 UINT32 Buffer32
= 0xFFFFFFFF; // Keep buffer with unknown device
912 EfiCpuVersion (&FamilyId
, &Model
, &SteppingId
, &ProcessorType
);
915 //we need raw Model data
922 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d/%d/%d", FamilyId
, Model
, SteppingId
);
923 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_ID_VALUE
), Buffer
, NULL
);
925 Status
= gBS
->LocateProtocol (
926 &gEfiMpServiceProtocolGuid
,
930 if (!EFI_ERROR (Status
)) {
932 // Determine the number of processors
934 MpService
->GetNumberOfProcessors (
936 &MaximumNumberOfCPUs
,
939 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d", MaximumNumberOfCPUs
);
940 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_CORE_VALUE
), Buffer
, NULL
);
943 // Update Mobile / Desktop / Tablet SKU
945 Buffer32
=(UINT32
) RShiftU64 (EfiReadMsr (MSR_IA32_PLATFORM_ID
), 50) & 0x07;
949 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - ISG SKU SOC", Buffer32
);
952 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Mobile SKU SOC", Buffer32
);
955 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Desktop SKU SOC", Buffer32
);
958 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Mobile SKU SOC", Buffer32
);
961 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Unknown SKU SOC", Buffer32
);
964 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_SKU_VALUE
), Buffer
, NULL
);
977 EFI_GUID
**ProtocolGuidArray
= NULL
;
982 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
= NULL
;
984 EFI_HANDLE
*mHandleBuffer
= NULL
;
987 // Retrieve the list of all handles from the handle database
989 Status
= gBS
->LocateHandleBuffer (
997 for (HandleIndex
= 0; HandleIndex
< mHandleCount
; HandleIndex
++)
1000 // Retrieve the list of all the protocols on each handle
1002 Status
= gBS
->ProtocolsPerHandle (
1003 mHandleBuffer
[HandleIndex
],
1007 if (!EFI_ERROR (Status
))
1009 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++)
1011 Status
= gBS
->OpenProtocolInformation (
1012 mHandleBuffer
[HandleIndex
],
1013 ProtocolGuidArray
[ProtocolIndex
],
1017 if (!EFI_ERROR (Status
))
1019 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++)
1021 if(OpenInfo
[OpenInfoIndex
].AgentHandle
== Father
)
1023 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
)
1025 *Child
= mHandleBuffer
[HandleIndex
];
1026 Status
= EFI_SUCCESS
;
1031 Status
= EFI_NOT_FOUND
;
1034 if(OpenInfo
!= NULL
)
1040 FreePool (ProtocolGuidArray
);
1041 ProtocolGuidArray
= NULL
;
1044 if(OpenInfo
!= NULL
)
1046 FreePool (OpenInfo
);
1049 if(ProtocolGuidArray
!= NULL
)
1051 FreePool(ProtocolGuidArray
);
1052 ProtocolGuidArray
= NULL
;
1054 if(mHandleBuffer
!= NULL
)
1056 FreePool (mHandleBuffer
);
1057 mHandleBuffer
= NULL
;
1063 JudgeHandleIsPCIDevice(
1070 EFI_DEVICE_PATH
*DPath
;
1072 Status
= gBS
->HandleProtocol (
1074 &gEfiDevicePathProtocolGuid
,
1077 if(!EFI_ERROR(Status
))
1079 while(!IsDevicePathEnd(DPath
))
1081 if((DPath
->Type
== HARDWARE_DEVICE_PATH
) && (DPath
->SubType
== HW_PCI_DP
))
1083 PCI_DEVICE_PATH
*PCIPath
;
1085 PCIPath
= (PCI_DEVICE_PATH
*) DPath
;
1086 DPath
= NextDevicePathNode(DPath
);
1087 if(IsDevicePathEnd(DPath
) && (PCIPath
->Device
== Device
) && (PCIPath
->Function
== Funs
))
1094 DPath
= NextDevicePathNode(DPath
);
1098 return EFI_UNSUPPORTED
;
1107 EFI_DRIVER_BINDING_PROTOCOL
*BindHandle
= NULL
;
1111 Status
= gBS
->OpenProtocol(
1113 &gEfiDriverBindingProtocolGuid
,
1114 (VOID
**)&BindHandle
,
1117 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1120 if (EFI_ERROR(Status
))
1122 return EFI_NOT_FOUND
;
1125 Version
= BindHandle
->Version
;
1126 Ptr
= (UINT16
*)&Version
;
1127 UnicodeSPrint(Name
, 40, L
"%d.%d.%d", Version
>> 24 , (Version
>>16)& 0x0f ,*(Ptr
));
1138 EFI_HANDLE
*Handles
= NULL
;
1141 EFI_HANDLE Child
= 0;
1143 Status
= gBS
->LocateHandleBuffer(
1145 &gEfiDriverBindingProtocolGuid
,
1150 for (Index
= 0; Index
< HandleCount
; Index
++)
1152 Status
= SearchChildHandle(Handles
[Index
], &Child
);
1153 if(!EFI_ERROR(Status
))
1155 Status
= JudgeHandleIsPCIDevice(
1160 if(!EFI_ERROR(Status
))
1162 return GetDriverName(Handles
[Index
], Name
);
1166 return EFI_UNSUPPORTED
;
1170 UpdatePlatformInformation (
1173 UINT32 MicroCodeVersion
;
1178 EFI_IA32_REGISTER_SET RegSet
;
1179 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
= NULL
;
1182 EFI_PEI_HOB_POINTERS GuidHob
;
1184 EFI_HANDLE
*HandleBuffer
;
1186 DXE_PCH_PLATFORM_POLICY_PROTOCOL
*PchPlatformPolicy
;
1187 UINTN PciD31F0RegBase
;
1196 // Get the HOB list. If it is not present, then ASSERT.
1198 GuidHob
.Raw
= GetHobList ();
1199 if (GuidHob
.Raw
!= NULL
) {
1200 if ((GuidHob
.Raw
= GetNextGuidHob (&gEfiPlatformInfoGuid
, GuidHob
.Raw
)) != NULL
) {
1201 mPlatformInfo
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
1208 Status
= gBS
->LocateProtocol(
1209 &gEfiLegacyBiosProtocolGuid
,
1211 (void **)&LegacyBios
1213 if (!EFI_ERROR (Status
)) {
1214 RegSet
.X
.AX
= 0x5f01;
1215 Status
= LegacyBios
->Int86 (LegacyBios
, 0x10, &RegSet
);
1216 ASSERT_EFI_ERROR(Status
);
1219 // simulate AMI int15 (ax=5f01) handler
1220 // check NbInt15.asm in AMI code for asm edition
1222 EDX
= (UINT16
)((RegSet
.E
.EBX
>> 16) & 0xffff);
1223 IgdVBIOSRevH
= (UINT8
)(((EDX
& 0x0F00) >> 4) | (EDX
& 0x000F));
1224 IgdVBIOSRevL
= (UINT8
)(((RegSet
.X
.BX
& 0x0F00) >> 4) | (RegSet
.X
.BX
& 0x000F));
1226 if (IgdVBIOSRevH
==0 && IgdVBIOSRevL
==0){
1227 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_CHIP_IGD_VBIOS_REV_VALUE
), L
"N/A", NULL
);
1229 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%02X%02X", IgdVBIOSRevH
,IgdVBIOSRevL
);
1230 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_CHIP_IGD_VBIOS_REV_VALUE
), Buffer
, NULL
);
1234 Status
= GetGOPDriverName(Name
);
1236 if (!EFI_ERROR(Status
))
1238 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_GOP_VALUE
), Name
, NULL
);
1244 // ISG-DC Tablet 000
1245 // VLV-QC Tablet 001
1246 // VLV-QC Desktop 010
1247 // VLV-QC Notebook 011
1249 CpuFlavor
= RShiftU64 (EfiReadMsr (MSR_IA32_PLATFORM_ID
), 50) & 0x07;
1253 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-DC Tablet", CpuFlavor
);
1256 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Notebook", CpuFlavor
);
1259 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Desktop", CpuFlavor
);
1262 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Notebook", CpuFlavor
);
1265 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"Unknown CPU", CpuFlavor
);
1268 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_CPU_FLAVOR_VALUE
), Buffer
, NULL
);
1270 if ( NULL
!= mPlatformInfo
) {
1274 switch(mPlatformInfo
->BoardId
){
1276 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE RVP(%02x)", mPlatformInfo
->BoardId
);
1280 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE FFRD(%02x)", mPlatformInfo
->BoardId
);
1284 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY ROCK RVP DDR3L (%02x)", mPlatformInfo
->BoardId
);
1288 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAYLEY BAY (%02x)", mPlatformInfo
->BoardId
);
1292 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAKER SPORT (%02x)", mPlatformInfo
->BoardId
);
1296 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"ALPINE VALLEY (%x)", mPlatformInfo
->BoardId
);
1300 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE FFD8 (%x)", mPlatformInfo
->BoardId
);
1304 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"Unknown BOARD (%02x)", mPlatformInfo
->BoardId
);
1307 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_BOARD_ID_VALUE
), Buffer
, NULL
);
1311 // Get Board FAB ID Info from protocol, update into the NVS area.
1312 // bit0~bit3 are for Fab ID, 0x0F means unknow FAB.
1314 if(mPlatformInfo
->BoardRev
== 0x0F) {
1315 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s", L
"Unknown FAB");
1316 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_FAB_ID_VALUE
), Buffer
, NULL
);
1318 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%2x", mPlatformInfo
->BoardRev
);
1319 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_FAB_ID_VALUE
), Buffer
, NULL
);
1324 //Update MRC Version
1326 MrcVersion
= 0x00000000;
1327 MrcVersion
&= 0xffff;
1328 Index
= EfiValueToString (Buffer
, MrcVersion
/100, PREFIX_ZERO
, 0);
1329 StrCat (Buffer
, L
".");
1330 EfiValueToString (Buffer
+ Index
+ 1, (MrcVersion
%100)/10, PREFIX_ZERO
, 0);
1331 EfiValueToString (Buffer
+ Index
+ 2, (MrcVersion
%100)%10, PREFIX_ZERO
, 0);
1332 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_MRC_VERSION_VALUE
), Buffer
, NULL
);
1335 //Update Soc Version
1339 // Retrieve all instances of PCH Platform Policy protocol
1341 Status
= gBS
->LocateHandleBuffer (
1343 &gDxePchPlatformPolicyProtocolGuid
,
1348 if (!EFI_ERROR (Status
)) {
1350 // Find the matching PCH Policy protocol
1352 for (Index
= 0; Index
< NumHandles
; Index
++) {
1353 Status
= gBS
->HandleProtocol (
1354 HandleBuffer
[Index
],
1355 &gDxePchPlatformPolicyProtocolGuid
,
1356 (void **)&PchPlatformPolicy
1358 if (!EFI_ERROR (Status
)) {
1359 PciD31F0RegBase
= MmPciAddress (
1361 PchPlatformPolicy
->BusNumber
,
1362 PCI_DEVICE_NUMBER_PCH_LPC
,
1363 PCI_FUNCTION_NUMBER_PCH_LPC
,
1367 Data8
= MmioRead8 (PciD31F0RegBase
+ R_PCH_LPC_RID_CC
);
1368 count
= ARRAY_SIZE (SBRevisionTable
);
1369 for (Index
= 0; Index
< count
; Index
++) {
1370 if(Data8
== SBRevisionTable
[Index
].RevId
) {
1371 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%02x %a", Data8
, SBRevisionTable
[Index
].String
);
1372 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_SOC_VALUE
), Buffer
, NULL
);
1382 // Microcode Revision
1384 EfiWriteMsr (EFI_MSR_IA32_BIOS_SIGN_ID
, 0);
1385 EfiCpuid (EFI_CPUID_VERSION_INFO
, NULL
);
1386 MicroCodeVersion
= (UINT32
) RShiftU64 (EfiReadMsr (EFI_MSR_IA32_BIOS_SIGN_ID
), 32);
1387 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%x", MicroCodeVersion
);
1388 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_MICROCODE_VALUE
), Buffer
, NULL
);
1394 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"0x%x", Data8
);
1395 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PUNIT_FW_VALUE
), Buffer
, NULL
);
1400 Data8
= (UINT8
)((MmioRead32 (PMC_BASE_ADDRESS
+ R_PCH_PMC_PRSTS
)>>16)&0x00FF);
1401 PIDData8
= (UINT8
)((MmioRead32 (PMC_BASE_ADDRESS
+ R_PCH_PMC_PRSTS
)>>24)&0x00FF);
1402 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"0x%X_%X",PIDData8
, Data8
);
1403 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PMC_FW_VALUE
), Buffer
, NULL
);
1410 Update SATA Drivesize Strings for Setup and Boot order
1412 @param NewString - pointer to string.
1413 @param DeviceSpeed - speed of drive.
1417 GetDeviceSpeedString (
1419 IN UINTN DeviceSpeed
1422 if (DeviceSpeed
== 0x01) {
1423 StrCat (NewString
, L
"1.5Gb/s");
1424 } else if (DeviceSpeed
== 0x02) {
1425 StrCat (NewString
, L
"3.0Gb/s");
1426 } else if (DeviceSpeed
== 0x03) {
1427 StrCat (NewString
, L
"6.0Gb/s");
1428 } else if (DeviceSpeed
== 0x0) {
1434 GetChipsetSataPortSpeed (
1439 UINT8 DeviceConfigStatus
;
1441 EFI_PHYSICAL_ADDRESS MemBaseAddress
= 0;
1444 DeviceSpeed
= 0x01; // generation 1
1448 // Allocate the AHCI BAR
1450 FunNum
= PCI_FUNCTION_NUMBER_PCH_SATA
;
1451 MemBaseAddress
= 0x0ffffffff;
1452 gDS
->AllocateMemorySpace (
1453 EfiGcdAllocateMaxAddressSearchBottomUp
,
1454 EfiGcdMemoryTypeMemoryMappedIo
,
1455 N_PCH_SATA_ABAR_ALIGNMENT
, // 2^11: 2K Alignment
1456 V_PCH_SATA_ABAR_LENGTH
, // 2K Length
1461 IdeAhciBar
= MmioRead32 (
1465 PCI_DEVICE_NUMBER_PCH_SATA
,
1470 IdeAhciBar
&= 0xFFFFF800;
1471 DeviceConfigStatus
= 0;
1472 if (IdeAhciBar
== 0) {
1473 DeviceConfigStatus
= 1;
1474 IdeAhciBar
= (UINT32
)MemBaseAddress
;
1476 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_ABAR
),
1480 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_COMMAND
),
1481 B_PCH_SATA_COMMAND_MSE
1485 if (mSystemConfiguration
.SataType
== PCH_SATA_MODE_IDE
){
1487 // Program the "Ports Implemented Register"
1489 MmioAndThenOr32 (IdeAhciBar
+ R_PCH_SATA_AHCI_PI
, (UINT32
)~(B_PCH_SATA_PORT0_IMPLEMENTED
+ B_PCH_SATA_PORT1_IMPLEMENTED
), (UINT32
)(B_PCH_SATA_PORT0_IMPLEMENTED
+ B_PCH_SATA_PORT1_IMPLEMENTED
));
1495 DeviceSpeed
= *(volatile UINT32
*)(UINTN
)(IdeAhciBar
+ R_PCH_SATA_AHCI_P0SSTS
);
1498 DeviceSpeed
= *(volatile UINT32
*)(UINTN
)(IdeAhciBar
+ R_PCH_SATA_AHCI_P1SSTS
);
1502 if (MemBaseAddress
) {
1503 gDS
->FreeMemorySpace (
1505 V_PCH_SATA_ABAR_LENGTH
1509 if (DeviceConfigStatus
) {
1512 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_ABAR
),
1517 DeviceSpeed
= (UINT8
)((DeviceSpeed
>> 4) & 0x0F);
1519 return (UINT8
)DeviceSpeed
;
1524 IDE data filter function.
1528 IdeDataFilter (void)
1532 EFI_HANDLE
*HandleBuffer
;
1533 EFI_DISK_INFO_PROTOCOL
*DiskInfo
;
1534 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, *DevicePathNode
;
1535 PCI_DEVICE_PATH
*PciDevicePath
;
1542 EFI_ATA_IDENTIFY_DATA
*IdentifyDriveInfo
;
1544 CHAR16 SizeString
[20];
1545 STRING_REF NameToUpdate
;
1546 CHAR8 StringBuffer
[0x100];
1551 // Assume no line strings is longer than 256 bytes.
1553 NewString
= AllocateZeroPool (0x100);
1554 PciDevicePath
= NULL
;
1557 // Fill IDE Infomation
1559 Status
= gBS
->LocateHandleBuffer (
1561 &gEfiDiskInfoProtocolGuid
,
1567 if (EFI_ERROR (Status
)) {
1571 for (Index
= 0; Index
< HandleCount
; Index
++) {
1573 Status
= gBS
->HandleProtocol (
1574 HandleBuffer
[Index
],
1575 &gEfiDevicePathProtocolGuid
,
1578 ASSERT_EFI_ERROR (Status
);
1580 DevicePathNode
= DevicePath
;
1581 while (!IsDevicePathEnd (DevicePathNode
) ) {
1582 if ((DevicePathType (DevicePathNode
) == HARDWARE_DEVICE_PATH
) &&
1583 ( DevicePathSubType (DevicePathNode
) == HW_PCI_DP
)) {
1584 PciDevicePath
= (PCI_DEVICE_PATH
*) DevicePathNode
;
1587 DevicePathNode
= NextDevicePathNode (DevicePathNode
);
1590 if (PciDevicePath
== NULL
) {
1595 // Check for onboard IDE
1597 if (PciDevicePath
->Device
== PCI_DEVICE_NUMBER_PCH_SATA
) {
1598 Status
= gBS
->HandleProtocol (
1599 HandleBuffer
[Index
],
1600 &gEfiDiskInfoProtocolGuid
,
1603 ASSERT_EFI_ERROR (Status
);
1605 Status
= DiskInfo
->WhichIde (
1610 ASSERT_EFI_ERROR (Status
);
1612 IdentifyDriveInfo
= AllocatePool (sizeof(EFI_ATA_IDENTIFY_DATA
));
1614 BufferSize
= sizeof(EFI_ATA_IDENTIFY_DATA
);
1615 Status
= DiskInfo
->Identify (
1620 ASSERT_EFI_ERROR(Status
);
1623 // Onboard SATA Devices
1625 if (PciDevicePath
->Function
== PCI_FUNCTION_NUMBER_PCH_SATA
) {
1626 if (IdeChannel
== 0 && IdeDevice
== 0) {
1627 NameToUpdate
= (STRING_REF
)STR_SATA0_NAME
;
1628 } else if (IdeChannel
== 1 && IdeDevice
== 0) {
1629 NameToUpdate
= (STRING_REF
)STR_SATA1_NAME
;
1637 ZeroMem(StringBuffer
, sizeof(StringBuffer
));
1640 (CHAR8
*)&IdentifyDriveInfo
->ModelName
,
1641 sizeof(IdentifyDriveInfo
->ModelName
)
1643 SwapEntries(StringBuffer
);
1644 AsciiToUnicode(StringBuffer
, NewString
);
1647 // Chap it off after 16 characters
1652 // For HardDisk append the size. Otherwise display atapi
1654 if ((IdentifyDriveInfo
->config
& 0x8000) == 00) {
1656 // 48 bit address feature set is supported, get maximum capacity
1658 if ((IdentifyDriveInfo
->command_set_supported_83
& 0x0400) == 0) {
1659 DriveSize
= (((((IdentifyDriveInfo
->user_addressable_sectors_hi
<< 16) +
1660 IdentifyDriveInfo
->user_addressable_sectors_lo
) / 1000) * 512) / 1000);
1662 DriveSize
= IdentifyDriveInfo
->maximum_lba_for_48bit_addressing
[0];
1663 for (Index1
= 1; Index1
< 4; Index1
++) {
1665 // Lower byte goes first: word[100] is the lowest word, word[103] is highest
1667 DriveSize
|= LShiftU64(IdentifyDriveInfo
->maximum_lba_for_48bit_addressing
[Index1
], 16 * Index1
);
1669 DriveSize
= (UINT32
) DivU64x32(MultU64x32(DivU64x32(DriveSize
, 1000), 512), 1000);
1672 StrCat (NewString
, L
"(");
1673 EfiValueToString (SizeString
, DriveSize
/1000, PREFIX_BLANK
, 0);
1674 StrCat (NewString
, SizeString
);
1675 StrCat (NewString
, L
".");
1676 EfiValueToString (SizeString
, (DriveSize
%1000)/100, PREFIX_BLANK
, 0);
1677 StrCat (NewString
, SizeString
);
1678 StrCat (NewString
, L
"GB");
1680 StrCat (NewString
, L
"(ATAPI");
1686 PortNumber
= (IdeDevice
<< 1) + IdeChannel
;
1687 DeviceSpeed
= GetChipsetSataPortSpeed(PortNumber
);
1690 StrCat (NewString
, L
"-");
1691 GetDeviceSpeedString( NewString
, DeviceSpeed
);
1694 StrCat (NewString
, L
")");
1696 HiiSetString(mHiiHandle
, NameToUpdate
, NewString
, NULL
);
1701 if (HandleBuffer
!= NULL
) {
1702 gBS
->FreePool (HandleBuffer
);
1705 gBS
->FreePool(NewString
);
1717 EFI_PEI_HOB_POINTERS GuidHob
;
1719 if (mSetupInfoDone
) {
1723 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1724 Status
= gRT
->GetVariable(
1726 &gEfiNormalSetupGuid
,
1729 &mSystemConfiguration
1732 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
1733 //The setup variable is corrupted
1734 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1735 Status
= gRT
->GetVariable(
1737 &gEfiNormalSetupGuid
,
1740 &mSystemConfiguration
1742 ASSERT_EFI_ERROR (Status
);
1746 // Update HOB variable for PCI resource information
1747 // Get the HOB list. If it is not present, then ASSERT.
1749 GuidHob
.Raw
= GetHobList ();
1750 if (GuidHob
.Raw
!= NULL
) {
1751 if ((GuidHob
.Raw
= GetNextGuidHob (&gEfiPlatformInfoGuid
, GuidHob
.Raw
)) != NULL
) {
1752 mPlatformInfo
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
1757 PrepareSetupInformation();
1758 UpdateAdditionalInformation ();
1759 UpdatePlatformInformation();
1760 UpdateCPUInformation();
1762 mSetupInfoDone
= TRUE
;
1768 #define EFI_SECURE_BOOT_MODE_NAME L"SecureBoot"
1771 CheckSystemConfigLoad(SYSTEM_CONFIGURATION
*SystemConfigPtr
)
1778 DataSize
= sizeof(SecureBoot
);
1779 Status
= gRT
->GetVariable (
1780 EFI_SECURE_BOOT_MODE_NAME
,
1781 &gEfiGlobalVariableGuid
,
1787 if (EFI_ERROR(Status
)) {
1788 SystemConfigPtr
->SecureBoot
= 0;
1790 SystemConfigPtr
->SecureBoot
= SecureBoot
;
1796 // "SecureBootEnable" variable for the Secure boot feature enable/disable.
1798 #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable"
1799 extern EFI_GUID gEfiSecureBootEnableDisableGuid
;
1803 CheckSystemConfigSave(SYSTEM_CONFIGURATION
*SystemConfigPtr
)
1806 UINT8 SecureBootCfg
;
1807 BOOLEAN SecureBootNotFound
;
1812 // Secure Boot configuration changes
1814 DataSize
= sizeof(SecureBootCfg
);
1815 SecureBootNotFound
= FALSE
;
1816 Status
= gRT
->GetVariable (
1817 EFI_SECURE_BOOT_ENABLE_NAME
,
1818 &gEfiSecureBootEnableDisableGuid
,
1824 if (EFI_ERROR(Status
)) {
1825 SecureBootNotFound
= TRUE
;
1827 if (SecureBootNotFound
) {
1828 Status
= gRT
->GetVariable (
1829 EFI_SECURE_BOOT_ENABLE_NAME
,
1830 &gEfiSecureBootEnableDisableGuid
,
1835 ASSERT_EFI_ERROR(Status
);
1837 if ((SecureBootCfg
) != SystemConfigPtr
->SecureBoot
) {
1838 SecureBootCfg
= !SecureBootCfg
;
1839 Status
= gRT
->SetVariable (
1840 EFI_SECURE_BOOT_ENABLE_NAME
,
1841 &gEfiSecureBootEnableDisableGuid
,
1842 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1851 ConfirmSecureBootTest()