3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 This is the filter driver to retrieve data hub entries.
26 #include "PlatformSetupDxe.h"
27 #include <Protocol/LegacyBios.h>
28 #include <Protocol/PciRootBridgeIo.h>
29 #include <Protocol/SimpleNetwork.h>
30 #include <Protocol/DevicePath.h>
31 #include <Protocol/DiskInfo.h>
32 #include <Protocol/IdeControllerInit.h>
33 #include <Protocol/MpService.h>
34 #include <Protocol/PchPlatformPolicy.h>
35 #include <Protocol/CpuIo2.h>
36 #include <Protocol/Smbios.h>
37 #include <IndustryStandard/SmBios.h>
38 #include <Library/IoLib.h>
39 #include <Library/I2CLib.h>
40 #include <Guid/GlobalVariable.h>
42 #include "Valleyview.h"
43 #include "VlvAccess.h"
44 #include "PchAccess.h"
45 #include "SetupMode.h"
46 #include "PchCommonDefinitions.h"
47 #include <PlatformBaseAddresses.h>
63 SB_REV SBRevisionTable
[] = {
64 {V_PCH_LPC_RID_0
, "(A0 Stepping)"},
65 {V_PCH_LPC_RID_1
, "(A0 Stepping)"},
66 {V_PCH_LPC_RID_2
, "(A1 Stepping)"},
67 {V_PCH_LPC_RID_3
, "(A1 Stepping)"},
68 {V_PCH_LPC_RID_4
, "(B0 Stepping)"},
69 {V_PCH_LPC_RID_5
, "(B0 Stepping)"},
70 {V_PCH_LPC_RID_6
, "(B1 Stepping)"},
71 {V_PCH_LPC_RID_7
, "(B1 Stepping)"},
72 {V_PCH_LPC_RID_8
, "(B2 Stepping)"},
73 {V_PCH_LPC_RID_9
, "(B2 Stepping)"},
74 {V_PCH_LPC_RID_A
, "(B3 Stepping)"},
75 {V_PCH_LPC_RID_B
, "(B3 Stepping)"},
76 {V_PCH_LPC_RID_C
, "(C0 Stepping)"},
77 {V_PCH_LPC_RID_D
, "(C0 Stepping)"}
80 #define LEFT_JUSTIFY 0x01
81 #define PREFIX_SIGN 0x02
82 #define PREFIX_BLANK 0x04
83 #define COMMA_TYPE 0x08
84 #define LONG_TYPE 0x10
85 #define PREFIX_ZERO 0x20
87 #define ICH_REG_REV 0x08
88 #define MSR_IA32_PLATFORM_ID 0x17
91 BOOLEAN mSetupInfoDone
= FALSE
;
92 UINT8 mUseProductKey
= 0;
93 EFI_EXP_BASE10_DATA mProcessorFrequency
;
94 EFI_EXP_BASE10_DATA mProcessorFsbFrequency
;
96 EFI_GUID mProcessorProducerGuid
;
97 EFI_HII_HANDLE mHiiHandle
;
98 EFI_PLATFORM_CPU_INFO mPlatformCpuInfo
;
99 SYSTEM_CONFIGURATION mSystemConfiguration
;
100 EFI_PLATFORM_INFO_HOB
*mPlatformInfo
;
103 #define memset SetMem
105 UINT16 mMemorySpeed
= 0xffff;
106 EFI_PHYSICAL_ADDRESS mMemorySizeChannelASlot0
= 0;
107 UINT16 mMemorySpeedChannelASlot0
= 0xffff;
108 EFI_PHYSICAL_ADDRESS mMemorySizeChannelASlot1
= 0;
109 UINT16 mMemorySpeedChannelASlot1
= 0xffff;
110 EFI_PHYSICAL_ADDRESS mMemorySizeChannelBSlot0
= 0;
111 UINT16 mMemorySpeedChannelBSlot0
= 0xffff;
112 EFI_PHYSICAL_ADDRESS mMemorySizeChannelBSlot1
= 0;
113 UINT16 mMemorySpeedChannelBSlot1
= 0xffff;
114 EFI_PHYSICAL_ADDRESS mMemorySizeChannelCSlot0
= 0;
115 UINT16 mMemorySpeedChannelCSlot0
= 0xffff;
116 EFI_PHYSICAL_ADDRESS mMemorySizeChannelCSlot1
= 0;
117 UINT16 mMemorySpeedChannelCSlot1
= 0xffff;
118 UINTN mMemoryMode
= 0xff;
120 #define CHARACTER_NUMBER_FOR_VALUE 30
122 EFI_STRING_TOKEN MemoryDeviceLocator
;
123 EFI_STRING_TOKEN MemoryBankLocator
;
124 EFI_STRING_TOKEN MemoryManufacturer
;
125 EFI_STRING_TOKEN MemorySerialNumber
;
126 EFI_STRING_TOKEN MemoryAssetTag
;
127 EFI_STRING_TOKEN MemoryPartNumber
;
128 EFI_INTER_LINK_DATA MemoryArrayLink
;
129 EFI_INTER_LINK_DATA MemorySubArrayLink
;
130 UINT16 MemoryTotalWidth
;
131 UINT16 MemoryDataWidth
;
132 UINT64 MemoryDeviceSize
;
133 EFI_MEMORY_FORM_FACTOR MemoryFormFactor
;
134 UINT8 MemoryDeviceSet
;
135 EFI_MEMORY_ARRAY_TYPE MemoryType
;
136 EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail
;
138 EFI_MEMORY_STATE MemoryState
;
139 } EFI_MEMORY_ARRAY_LINK
;
143 EFI_PHYSICAL_ADDRESS MemoryArrayStartAddress
;
144 EFI_PHYSICAL_ADDRESS MemoryArrayEndAddress
;
145 EFI_INTER_LINK_DATA PhysicalMemoryArrayLink
;
146 UINT16 MemoryArrayPartitionWidth
;
147 } EFI_MEMORY_ARRAY_START_ADDRESS
;
151 PCH_SATA_MODE_IDE
= 0,
158 Acquire the string associated with the Index from smbios structure and return it.
159 The caller is responsible for free the string buffer.
161 @param OptionalStrStart The start position to search the string
162 @param Index The index of the string to extract
163 @param String The string that is extracted
165 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
169 GetOptionalStringByIndex (
170 IN CHAR8
*OptionalStrStart
,
178 *String
= AllocateZeroPool (sizeof (CHAR16
));
185 OptionalStrStart
+= StrSize
;
186 StrSize
= AsciiStrSize (OptionalStrStart
);
187 } while (OptionalStrStart
[StrSize
] != 0 && Index
!= 0);
189 if ((Index
!= 0) || (StrSize
== 1)) {
191 // Meet the end of strings set but Index is non-zero, or
192 // Find an empty string
194 return EFI_NOT_FOUND
;
196 *String
= AllocatePool (StrSize
* sizeof (CHAR16
));
197 AsciiStrToUnicodeStr (OptionalStrStart
, *String
);
204 VSPrint worker function that prints a Value as a decimal number in Buffer
206 @param Buffer Location to place ascii decimal number string of Value.
207 @param Value Decimal value to convert to a string in Buffer.
208 @param Flags Flags to use in printing decimal string, see file header for details.
209 @param Width Width of hex value.
211 Number of characters printed.
216 IN OUT CHAR16
*Buffer
,
222 CHAR16 TempBuffer
[CHARACTER_NUMBER_FOR_VALUE
];
230 BOOLEAN ValueIsNegative
;
233 TempStr
= TempBuffer
;
237 ValueIsNegative
= FALSE
;
239 if (Width
> CHARACTER_NUMBER_FOR_VALUE
- 1) {
240 Width
= CHARACTER_NUMBER_FOR_VALUE
- 1;
245 ValueIsNegative
= TRUE
;
250 Value
= (INT64
)DivU64x32 ((UINT64
)Value
, 10);
251 Remainder
= (UINTN
)((UINT64
)TempValue
- 10 * Value
);
252 *(TempStr
++) = (CHAR16
)(Remainder
+ '0');
255 if ((Flags
& COMMA_TYPE
) == COMMA_TYPE
) {
256 if (ValueCharNum
% 3 == 0 && Value
!= 0) {
261 } while (Value
!= 0);
263 if (ValueIsNegative
) {
268 if ((Flags
& PREFIX_ZERO
) && !ValueIsNegative
) {
275 if (!(Flags
& LEFT_JUSTIFY
)) {
276 for (; Index
< Width
; Index
++) {
277 *(TempStr
++) = Prefix
;
282 // Reverse temp string into Buffer.
284 if (Width
> 0 && (UINTN
) (TempStr
- TempBuffer
) > Width
) {
285 TempStr
= TempBuffer
+ Width
;
288 while (TempStr
!= TempBuffer
) {
289 *(BufferPtr
++) = *(--TempStr
);
297 static CHAR16 mHexStr
[] = { L
'0', L
'1', L
'2', L
'3', L
'4', L
'5', L
'6', L
'7',
298 L
'8', L
'9', L
'A', L
'B', L
'C', L
'D', L
'E', L
'F' };
301 VSPrint worker function that prints a Value as a hex number in Buffer
303 @param Buffer Location to place ascii hex string of Value.
304 @param Value Hex value to convert to a string in Buffer.
305 @param Flags Flags to use in printing Hex string, see file header for details.
306 @param Width Width of hex value.
308 @retval Number of characters printed.
313 IN OUT CHAR16
*Buffer
,
319 CHAR16 TempBuffer
[CHARACTER_NUMBER_FOR_VALUE
];
326 TempStr
= TempBuffer
;
330 // Count starts at one since we will null terminate. Each iteration of the
331 // loop picks off one nibble. Oh yea TempStr ends up backwards
335 if (Width
> CHARACTER_NUMBER_FOR_VALUE
- 1) {
336 Width
= CHARACTER_NUMBER_FOR_VALUE
- 1;
340 Index
= ((UINTN
)Value
& 0xf);
341 *(TempStr
++) = mHexStr
[Index
];
342 Value
= RShiftU64 (Value
, 4);
344 } while (Value
!= 0);
346 if (Flags
& PREFIX_ZERO
) {
353 if (!(Flags
& LEFT_JUSTIFY
)) {
354 for (; Index
< Width
; Index
++) {
355 *(TempStr
++) = Prefix
;
360 // Reverse temp string into Buffer.
362 if (Width
> 0 && (UINTN
) (TempStr
- TempBuffer
) > Width
) {
363 TempStr
= TempBuffer
+ Width
;
366 while (TempStr
!= TempBuffer
) {
367 *(BufferPtr
++) = *(--TempStr
);
376 Converts MAC address to Unicode string.
377 The value is 64-bit and the resulting string will be 12
378 digit hex number in pairs of digits separated by dashes.
380 @param String string that will contain the value
381 @param MacAddr add argument and description to function comment
382 @param AddrSize add argument and description to function comment
388 IN EFI_MAC_ADDRESS
*MacAddr
,
394 for (i
= 0; i
< AddrSize
; i
++) {
398 MacAddr
->Addr
[i
] & 0xFF,
405 // Terminate the string.
407 String
[2 * AddrSize
] = L
'\0';
412 VOID
UpdateLatestBootTime() {
417 if (mSystemConfiguration
.LogBootTime
!= 1) {
420 VarSize
= sizeof(TimeValue
);
421 Status
= gRT
->GetVariable(
423 &gEfiNormalSetupGuid
,
428 if (EFI_ERROR(Status
)) {
431 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d ms", (UINT32
)TimeValue
);
432 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_LOG_BOOT_TIME_VALUE
), Buffer
, NULL
);
436 Get Cache Type for the specified Cache. This function is invoked when there is data records
437 available in the Data Hub.
439 Get Cache Type function arguments:
441 @param Instance The instance number of the subclass with the same ProducerName..
442 @param SubInstance The instance number of the RecordType for the same Instance.
443 @param CacheType Cache type, see definition of EFI_CACHE_TYPE_DATA.
451 IN UINT16 SubInstance
,
452 IN EFI_CACHE_TYPE_DATA
* CacheType
)
455 EFI_DATA_HUB_PROTOCOL
*DataHub
;
456 EFI_DATA_RECORD_HEADER
*Record
;
457 UINT64 MonotonicCount
;
458 EFI_CACHE_VARIABLE_RECORD
* CacheVariableRecord
;
459 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
461 Status
= gBS
->LocateProtocol (
462 &gEfiDataHubProtocolGuid
,
466 ASSERT_EFI_ERROR(Status
);
469 // Get all available data records from data hub
475 Status
= DataHub
->GetNextRecord (
481 if (!EFI_ERROR(Status
)) {
482 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
483 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
485 if(CompareGuid(&Record
->DataRecordGuid
, &gEfiCacheSubClassGuid
) &&
486 (DataHeader
->RecordType
== CacheTypeRecordType
) &&
487 (DataHeader
->Instance
== Instance
) &&
488 (DataHeader
->SubInstance
== SubInstance
)) {
489 CacheVariableRecord
= (EFI_CACHE_VARIABLE_RECORD
*)(DataHeader
+ 1);
491 *CacheType
= CacheVariableRecord
->CacheType
;
497 } while(!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
499 return EFI_NOT_FOUND
;
503 Setup data filter function. This function is invoked when there is data records
504 available in the Data Hub.
507 Standard event notification function arguments:
508 @param Event The event that is signaled.
509 @param Context Not used here.
515 PrepareSetupInformation (
520 EFI_DATA_HUB_PROTOCOL
*DataHub
;
521 EFI_DATA_RECORD_HEADER
*Record
;
523 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
526 CHAR16
*NewStringToken
;
527 STRING_REF TokenToUpdate
;
528 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
532 EFI_PROCESSOR_MICROCODE_REVISION_DATA
*CpuUcodeRevisionData
;
533 EFI_MEMORY_ARRAY_START_ADDRESS
*MemoryArray
;
534 EFI_MEMORY_ARRAY_LINK
*MemoryArrayLink
;
535 UINT64 MonotonicCount
;
537 CHAR16 Version
[100]; //Assuming that strings are < 100 UCHAR
538 CHAR16 ReleaseDate
[100]; //Assuming that strings are < 100 UCHAR
539 CHAR16 ReleaseTime
[100]; //Assuming that strings are < 100 UCHAR
541 NewString
= AllocateZeroPool (0x100);
542 NewString2
= AllocateZeroPool (0x100);
543 SetMem(Version
, sizeof(Version
), 0);
544 SetMem(ReleaseDate
, sizeof(ReleaseDate
), 0);
545 SetMem(ReleaseTime
, sizeof(ReleaseTime
), 0);
548 // Get the Data Hub Protocol. Assume only one instance
550 Status
= gBS
->LocateProtocol (&gEfiDataHubProtocolGuid
, NULL
, (void **)&DataHub
);
551 ASSERT_EFI_ERROR(Status
);
554 // Get all available data records from data hub
560 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
561 if (!EFI_ERROR(Status
)) {
562 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
563 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
564 SrcData
= (UINT8
*)(DataHeader
+ 1);
569 if (CompareGuid(&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
)) {
570 CopyMem (&mProcessorProducerGuid
, &Record
->ProducerName
, sizeof(EFI_GUID
));
571 switch (DataHeader
->RecordType
) {
572 case ProcessorCoreFrequencyRecordType
:
573 CopyMem(&mProcessorFrequency
, SrcData
, sizeof(EFI_EXP_BASE10_DATA
));
574 Index
= EfiValueToString (
576 ConvertBase10ToRaw ((EFI_EXP_BASE10_DATA
*)SrcData
)/1000000000,
580 StrCat (NewString
, L
".");
582 NewString
+ Index
+ 1,
583 ((ConvertBase10ToRaw ((EFI_EXP_BASE10_DATA
*)SrcData
)%1000000000)/10000000),
587 StrCat (NewString
, L
" GHz");
588 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_SPEED_VALUE
;
589 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
592 case ProcessorVersionRecordType
:
593 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*)SrcData
;
594 NewStringToken
= HiiGetPackageString(&mProcessorProducerGuid
, *ProcessorVersion
, NULL
);
595 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_VERSION_VALUE
;
596 HiiSetString(mHiiHandle
, TokenToUpdate
, NewStringToken
, NULL
);
598 case CpuUcodeRevisionDataRecordType
:
599 CpuUcodeRevisionData
= (EFI_PROCESSOR_MICROCODE_REVISION_DATA
*) SrcData
;
600 if (CpuUcodeRevisionData
->ProcessorMicrocodeRevisionNumber
!= 0) {
603 CpuUcodeRevisionData
->ProcessorMicrocodeRevisionNumber
,
607 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_MICROCODE_VALUE
;
608 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
618 } else if (CompareGuid(&Record
->DataRecordGuid
, &gEfiCacheSubClassGuid
) &&
619 (DataHeader
->RecordType
== CacheSizeRecordType
)) {
620 if (DataHeader
->SubInstance
== EFI_CACHE_L1
) {
621 EFI_CACHE_TYPE_DATA CacheType
;
622 if (EFI_SUCCESS
== GetCacheType(DataHeader
->Instance
, DataHeader
->SubInstance
,&CacheType
)){
623 if (CacheType
== EfiCacheTypeData
) {
624 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L1_DATA_CACHE_VALUE
;
625 } else if (CacheType
== EfiCacheTypeInstruction
) {
626 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L1_INSTR_CACHE_VALUE
;
634 else if (DataHeader
->SubInstance
== EFI_CACHE_L2
) {
635 TokenToUpdate
= (STRING_REF
)STR_PROCESSOR_L2_CACHE_VALUE
;
639 if (ConvertBase2ToRaw((EFI_EXP_BASE2_DATA
*)SrcData
)) {
640 DataOutput
= ConvertBase2ToRaw((EFI_EXP_BASE2_DATA
*)SrcData
) >> 10;
641 EfiValueToString (NewString
, DataOutput
, PREFIX_ZERO
, 0);
643 StrCat (NewString
, L
" KB");
644 if (DataHeader
->SubInstance
== EFI_CACHE_L3
) {
645 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
646 } else if(DataHeader
->SubInstance
== EFI_CACHE_L2
&& mPlatformCpuInfo
.CpuPackage
.CoresPerPhysicalPackage
> 1){
652 mPlatformCpuInfo
.CpuPackage
.CoresPerPhysicalPackage
,
656 StrCat(NewString2
, L
"x ");
657 StrCat(NewString2
, NewString
);
658 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString2
, NULL
);
660 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
667 } else if (CompareGuid(&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
)) {
668 switch (DataHeader
->RecordType
) {
669 case EFI_MEMORY_ARRAY_LINK_RECORD_NUMBER
:
670 MemoryArrayLink
= (EFI_MEMORY_ARRAY_LINK
*)SrcData
;
672 if (MemoryArrayLink
->MemorySpeed
> 0) {
674 // Save the lowest speed memory module
676 if (MemoryArrayLink
->MemorySpeed
< mMemorySpeed
) {
677 mMemorySpeed
= MemoryArrayLink
->MemorySpeed
;
679 switch (DataHeader
->SubInstance
) {
681 mMemorySpeedChannelASlot0
= MemoryArrayLink
->MemorySpeed
;
682 mMemorySizeChannelASlot0
= MemoryArrayLink
->MemoryDeviceSize
;
685 mMemorySpeedChannelASlot1
= MemoryArrayLink
->MemorySpeed
;
686 mMemorySizeChannelASlot1
= MemoryArrayLink
->MemoryDeviceSize
;
689 mMemorySpeedChannelBSlot0
= MemoryArrayLink
->MemorySpeed
;
690 mMemorySizeChannelBSlot0
= MemoryArrayLink
->MemoryDeviceSize
;
693 mMemorySpeedChannelBSlot1
= MemoryArrayLink
->MemorySpeed
;
694 mMemorySizeChannelBSlot1
= MemoryArrayLink
->MemoryDeviceSize
;
697 mMemorySpeedChannelCSlot0
= MemoryArrayLink
->MemorySpeed
;
698 mMemorySizeChannelCSlot0
= MemoryArrayLink
->MemoryDeviceSize
;
701 mMemorySpeedChannelCSlot1
= MemoryArrayLink
->MemorySpeed
;
702 mMemorySizeChannelCSlot1
= MemoryArrayLink
->MemoryDeviceSize
;
710 case EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
:
711 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS
*)SrcData
;
712 if (MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
) {
713 DataOutput
= (UINTN
)RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20);
714 EfiValueToString (NewString
, DataOutput
/ 1024, PREFIX_ZERO
, 0);
715 if(DataOutput
% 1024) {
716 StrCat (NewString
, L
".");
717 DataOutput
= ((DataOutput
% 1024) * 1000) / 1024;
718 while(!(DataOutput
% 10))
719 DataOutput
= DataOutput
/ 10;
720 EfiValueToString (NewString2
, DataOutput
, PREFIX_ZERO
, 0);
721 StrCat (NewString
, NewString2
);
723 StrCat (NewString
, L
" GB");
724 TokenToUpdate
= (STRING_REF
)STR_TOTAL_MEMORY_SIZE_VALUE
;
725 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
735 } while (!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
737 Status
= GetBiosVersionDateTime (
743 DEBUG ((EFI_D_ERROR
, "GetBiosVersionDateTime :%s %s %s \n", Version
, ReleaseDate
, ReleaseTime
));
744 if (!EFI_ERROR (Status
)) {
746 CHAR16
*BuildDateTime
;
748 Length
= StrLen(ReleaseDate
) + StrLen(ReleaseTime
);
750 BuildDateTime
= AllocateZeroPool ((Length
+2) * sizeof(CHAR16
));
751 StrCpy (BuildDateTime
, ReleaseDate
);
752 StrCat (BuildDateTime
, L
" ");
753 StrCat (BuildDateTime
, ReleaseTime
);
755 TokenToUpdate
= (STRING_REF
)STR_BIOS_VERSION_VALUE
;
756 DEBUG ((EFI_D_ERROR
, "update STR_BIOS_VERSION_VALUE\n"));
757 HiiSetString(mHiiHandle
, TokenToUpdate
, Version
, NULL
);
759 TokenToUpdate
= (STRING_REF
)STR_BIOS_BUILD_TIME_VALUE
;
760 DEBUG ((EFI_D_ERROR
, "update STR_BIOS_BUILD_TIME_VALUE\n"));
761 HiiSetString(mHiiHandle
, TokenToUpdate
, BuildDateTime
, NULL
);
765 // Calculate and update memory speed display in Main Page
768 // Update the overall memory speed
770 if (mMemorySpeed
!= 0xffff) {
771 EfiValueToString (NewString
, mMemorySpeed
, PREFIX_ZERO
, 0);
772 StrCat (NewString
, L
" MHz");
774 TokenToUpdate
= (STRING_REF
)STR_SYSTEM_MEMORY_SPEED_VALUE
;
775 HiiSetString(mHiiHandle
, TokenToUpdate
, NewString
, NULL
);
778 gBS
->FreePool(NewString
);
779 gBS
->FreePool(NewString2
);
786 Routine Description: update the SETUP info for "Additional Information" which is SMBIOS info.
792 UpdateAdditionalInformation (
796 UINT64 MonotonicCount
;
797 EFI_DATA_HUB_PROTOCOL
*DataHub
;
798 EFI_DATA_RECORD_HEADER
*Record
;
799 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
800 EFI_SMBIOS_PROTOCOL
*Smbios
;
801 EFI_SMBIOS_HANDLE SmbiosHandle
;
802 EFI_SMBIOS_TABLE_HEADER
*SmbiosRecord
;
803 SMBIOS_TABLE_TYPE0
*Type0Record
;
805 CHAR16
*BiosVersion
= NULL
;
806 CHAR16
*IfwiVersion
= NULL
;
808 EFI_STRING_ID TokenToUpdate
;
809 #if defined( RVP_SUPPORT ) && RVP_SUPPORT
810 EFI_MISC_SYSTEM_MANUFACTURER
*SystemManufacturer
;
813 Status
= gBS
->LocateProtocol (
814 &gEfiDataHubProtocolGuid
,
819 ASSERT_EFI_ERROR(Status
);
824 Status
= DataHub
->GetNextRecord (
830 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
831 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*)(Record
+ 1);
833 if (CompareGuid(&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
834 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)) {
835 #if defined( RVP_SUPPORT ) && RVP_SUPPORT
837 // System Information
839 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER
*)(DataHeader
+ 1);
842 // UUID (System Information)
844 SMBIOSString
= EfiLibAllocateZeroPool (0x100);
845 GuidToString ( &SystemManufacturer
->SystemUuid
, SMBIOSString
, 0x00 );
847 TokenToUpdate
= (STRING_REF
)STR_SYSTEM_UUID_VALUE
;
848 HiiSetString(mHiiHandle
, TokenToUpdate
, SMBIOSString
, NULL
);
850 gBS
->FreePool(SMBIOSString
);
854 } while (!EFI_ERROR(Status
) && (MonotonicCount
!= 0));
856 Status
= gBS
->LocateProtocol (
857 &gEfiSmbiosProtocolGuid
,
861 ASSERT_EFI_ERROR (Status
);
863 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
865 Status
= Smbios
->GetNext (
872 if (SmbiosRecord
->Type
== EFI_SMBIOS_TYPE_BIOS_INFORMATION
) {
873 Type0Record
= (SMBIOS_TABLE_TYPE0
*) SmbiosRecord
;
874 StrIndex
= Type0Record
->BiosVersion
;
875 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type0Record
+ Type0Record
->Hdr
.Length
), StrIndex
, &BiosVersion
);
876 TokenToUpdate
= STRING_TOKEN (STR_BIOS_VERSION_VALUE
);
877 for (SearchIndex
= 0x0; SearchIndex
< SMBIOS_STRING_MAX_LENGTH
; SearchIndex
++) {
878 if (BiosVersion
[SearchIndex
] == 0x0020) {
879 BiosVersion
[SearchIndex
] = 0x0000;
880 IfwiVersion
= (CHAR16
*)(&BiosVersion
[SearchIndex
+1]);
882 } else if (BiosVersion
[SearchIndex
] == 0x0000) {
886 HiiSetString (mHiiHandle
, TokenToUpdate
, BiosVersion
, NULL
);
889 // Check IfwiVersion, to avoid no IFWI version in SMBIOS Type 0 strucntion
892 TokenToUpdate
= STRING_TOKEN (STR_IFWI_VERSION_VALUE
);
893 HiiSetString (mHiiHandle
, TokenToUpdate
, IfwiVersion
, NULL
);
896 } while (!EFI_ERROR(Status
));
898 UpdateLatestBootTime();
904 UpdateCPUInformation ()
912 EFI_MP_SERVICES_PROTOCOL
*MpService
;
913 UINTN MaximumNumberOfCPUs
;
914 UINTN NumberOfEnabledCPUs
;
915 UINT32 Buffer32
= 0xFFFFFFFF; // Keep buffer with unknown device
917 EfiCpuVersion (&FamilyId
, &Model
, &SteppingId
, &ProcessorType
);
920 //we need raw Model data
927 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d/%d/%d", FamilyId
, Model
, SteppingId
);
928 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_ID_VALUE
), Buffer
, NULL
);
930 Status
= gBS
->LocateProtocol (
931 &gEfiMpServiceProtocolGuid
,
935 if (!EFI_ERROR (Status
)) {
937 // Determine the number of processors
939 MpService
->GetNumberOfProcessors (
941 &MaximumNumberOfCPUs
,
944 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%d", MaximumNumberOfCPUs
);
945 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_CORE_VALUE
), Buffer
, NULL
);
948 // Update Mobile / Desktop / Tablet SKU
950 Buffer32
=(UINT32
) RShiftU64 (EfiReadMsr (MSR_IA32_PLATFORM_ID
), 50) & 0x07;
954 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - ISG SKU SOC", Buffer32
);
957 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Mobile SKU SOC", Buffer32
);
960 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Desktop SKU SOC", Buffer32
);
963 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Mobile SKU SOC", Buffer32
);
966 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"(%d) - Unknown SKU SOC", Buffer32
);
969 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_SKU_VALUE
), Buffer
, NULL
);
982 EFI_GUID
**ProtocolGuidArray
= NULL
;
987 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfo
= NULL
;
989 EFI_HANDLE
*mHandleBuffer
= NULL
;
992 // Retrieve the list of all handles from the handle database
994 Status
= gBS
->LocateHandleBuffer (
1002 for (HandleIndex
= 0; HandleIndex
< mHandleCount
; HandleIndex
++)
1005 // Retrieve the list of all the protocols on each handle
1007 Status
= gBS
->ProtocolsPerHandle (
1008 mHandleBuffer
[HandleIndex
],
1012 if (!EFI_ERROR (Status
))
1014 for (ProtocolIndex
= 0; ProtocolIndex
< ArrayCount
; ProtocolIndex
++)
1016 Status
= gBS
->OpenProtocolInformation (
1017 mHandleBuffer
[HandleIndex
],
1018 ProtocolGuidArray
[ProtocolIndex
],
1022 if (!EFI_ERROR (Status
))
1024 for (OpenInfoIndex
= 0; OpenInfoIndex
< OpenInfoCount
; OpenInfoIndex
++)
1026 if(OpenInfo
[OpenInfoIndex
].AgentHandle
== Father
)
1028 if ((OpenInfo
[OpenInfoIndex
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
)
1030 *Child
= mHandleBuffer
[HandleIndex
];
1031 Status
= EFI_SUCCESS
;
1036 Status
= EFI_NOT_FOUND
;
1039 if(OpenInfo
!= NULL
)
1045 FreePool (ProtocolGuidArray
);
1046 ProtocolGuidArray
= NULL
;
1049 if(OpenInfo
!= NULL
)
1051 FreePool (OpenInfo
);
1054 if(ProtocolGuidArray
!= NULL
)
1056 FreePool(ProtocolGuidArray
);
1057 ProtocolGuidArray
= NULL
;
1059 if(mHandleBuffer
!= NULL
)
1061 FreePool (mHandleBuffer
);
1062 mHandleBuffer
= NULL
;
1068 JudgeHandleIsPCIDevice(
1075 EFI_DEVICE_PATH
*DPath
;
1077 Status
= gBS
->HandleProtocol (
1079 &gEfiDevicePathProtocolGuid
,
1082 if(!EFI_ERROR(Status
))
1084 while(!IsDevicePathEnd(DPath
))
1086 if((DPath
->Type
== HARDWARE_DEVICE_PATH
) && (DPath
->SubType
== HW_PCI_DP
))
1088 PCI_DEVICE_PATH
*PCIPath
;
1090 PCIPath
= (PCI_DEVICE_PATH
*) DPath
;
1091 DPath
= NextDevicePathNode(DPath
);
1092 if(IsDevicePathEnd(DPath
) && (PCIPath
->Device
== Device
) && (PCIPath
->Function
== Funs
))
1099 DPath
= NextDevicePathNode(DPath
);
1103 return EFI_UNSUPPORTED
;
1112 EFI_DRIVER_BINDING_PROTOCOL
*BindHandle
= NULL
;
1116 Status
= gBS
->OpenProtocol(
1118 &gEfiDriverBindingProtocolGuid
,
1119 (VOID
**)&BindHandle
,
1122 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1125 if (EFI_ERROR(Status
))
1127 return EFI_NOT_FOUND
;
1130 Version
= BindHandle
->Version
;
1131 Ptr
= (UINT16
*)&Version
;
1132 UnicodeSPrint(Name
, 40, L
"%d.%d.%d", Version
>> 24 , (Version
>>16)& 0x0f ,*(Ptr
));
1143 EFI_HANDLE
*Handles
= NULL
;
1146 EFI_HANDLE Child
= 0;
1148 Status
= gBS
->LocateHandleBuffer(
1150 &gEfiDriverBindingProtocolGuid
,
1155 for (Index
= 0; Index
< HandleCount
; Index
++)
1157 Status
= SearchChildHandle(Handles
[Index
], &Child
);
1158 if(!EFI_ERROR(Status
))
1160 Status
= JudgeHandleIsPCIDevice(
1165 if(!EFI_ERROR(Status
))
1167 return GetDriverName(Handles
[Index
], Name
);
1171 return EFI_UNSUPPORTED
;
1175 UpdatePlatformInformation (
1178 UINT32 MicroCodeVersion
;
1183 EFI_IA32_REGISTER_SET RegSet
;
1184 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
= NULL
;
1187 EFI_PEI_HOB_POINTERS GuidHob
;
1189 EFI_HANDLE
*HandleBuffer
;
1191 DXE_PCH_PLATFORM_POLICY_PROTOCOL
*PchPlatformPolicy
;
1192 UINTN PciD31F0RegBase
;
1201 // Get the HOB list. If it is not present, then ASSERT.
1203 GuidHob
.Raw
= GetHobList ();
1204 if (GuidHob
.Raw
!= NULL
) {
1205 if ((GuidHob
.Raw
= GetNextGuidHob (&gEfiPlatformInfoGuid
, GuidHob
.Raw
)) != NULL
) {
1206 mPlatformInfo
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
1213 Status
= gBS
->LocateProtocol(
1214 &gEfiLegacyBiosProtocolGuid
,
1216 (void **)&LegacyBios
1218 if (!EFI_ERROR (Status
)) {
1219 RegSet
.X
.AX
= 0x5f01;
1220 Status
= LegacyBios
->Int86 (LegacyBios
, 0x10, &RegSet
);
1221 ASSERT_EFI_ERROR(Status
);
1224 // simulate AMI int15 (ax=5f01) handler
1225 // check NbInt15.asm in AMI code for asm edition
1227 EDX
= (UINT16
)((RegSet
.E
.EBX
>> 16) & 0xffff);
1228 IgdVBIOSRevH
= (UINT8
)(((EDX
& 0x0F00) >> 4) | (EDX
& 0x000F));
1229 IgdVBIOSRevL
= (UINT8
)(((RegSet
.X
.BX
& 0x0F00) >> 4) | (RegSet
.X
.BX
& 0x000F));
1231 if (IgdVBIOSRevH
==0 && IgdVBIOSRevL
==0){
1232 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_CHIP_IGD_VBIOS_REV_VALUE
), L
"N/A", NULL
);
1234 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%02X%02X", IgdVBIOSRevH
,IgdVBIOSRevL
);
1235 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_CHIP_IGD_VBIOS_REV_VALUE
), Buffer
, NULL
);
1239 Status
= GetGOPDriverName(Name
);
1241 if (!EFI_ERROR(Status
))
1243 HiiSetString(mHiiHandle
, STRING_TOKEN(STR_GOP_VALUE
), Name
, NULL
);
1249 // ISG-DC Tablet 000
1250 // VLV-QC Tablet 001
1251 // VLV-QC Desktop 010
1252 // VLV-QC Notebook 011
1254 CpuFlavor
= RShiftU64 (EfiReadMsr (MSR_IA32_PLATFORM_ID
), 50) & 0x07;
1258 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-DC Tablet", CpuFlavor
);
1261 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Notebook", CpuFlavor
);
1264 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Desktop", CpuFlavor
);
1267 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"VLV-QC Notebook", CpuFlavor
);
1270 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s (%01x)", L
"Unknown CPU", CpuFlavor
);
1273 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_CPU_FLAVOR_VALUE
), Buffer
, NULL
);
1275 if ( NULL
!= mPlatformInfo
) {
1279 switch(mPlatformInfo
->BoardId
){
1281 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE RVP(%02x)", mPlatformInfo
->BoardId
);
1285 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE FFRD(%02x)", mPlatformInfo
->BoardId
);
1289 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY ROCK RVP DDR3L (%02x)", mPlatformInfo
->BoardId
);
1293 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAYLEY BAY (%02x)", mPlatformInfo
->BoardId
);
1297 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAKER SPORT (%02x)", mPlatformInfo
->BoardId
);
1301 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"ALPINE VALLEY (%x)", mPlatformInfo
->BoardId
);
1305 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"BAY LAKE FFD8 (%x)", mPlatformInfo
->BoardId
);
1309 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"Unknown BOARD (%02x)", mPlatformInfo
->BoardId
);
1312 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_BOARD_ID_VALUE
), Buffer
, NULL
);
1316 // Get Board FAB ID Info from protocol, update into the NVS area.
1317 // bit0~bit3 are for Fab ID, 0x0F means unknow FAB.
1319 if(mPlatformInfo
->BoardRev
== 0x0F) {
1320 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%s", L
"Unknown FAB");
1321 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_FAB_ID_VALUE
), Buffer
, NULL
);
1323 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%2x", mPlatformInfo
->BoardRev
);
1324 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_FAB_ID_VALUE
), Buffer
, NULL
);
1329 //Update MRC Version
1331 MrcVersion
= 0x00000000;
1332 MrcVersion
&= 0xffff;
1333 Index
= EfiValueToString (Buffer
, MrcVersion
/100, PREFIX_ZERO
, 0);
1334 StrCat (Buffer
, L
".");
1335 EfiValueToString (Buffer
+ Index
+ 1, (MrcVersion
%100)/10, PREFIX_ZERO
, 0);
1336 EfiValueToString (Buffer
+ Index
+ 2, (MrcVersion
%100)%10, PREFIX_ZERO
, 0);
1337 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_MRC_VERSION_VALUE
), Buffer
, NULL
);
1340 //Update Soc Version
1344 // Retrieve all instances of PCH Platform Policy protocol
1346 Status
= gBS
->LocateHandleBuffer (
1348 &gDxePchPlatformPolicyProtocolGuid
,
1353 if (!EFI_ERROR (Status
)) {
1355 // Find the matching PCH Policy protocol
1357 for (Index
= 0; Index
< NumHandles
; Index
++) {
1358 Status
= gBS
->HandleProtocol (
1359 HandleBuffer
[Index
],
1360 &gDxePchPlatformPolicyProtocolGuid
,
1361 (void **)&PchPlatformPolicy
1363 if (!EFI_ERROR (Status
)) {
1364 PciD31F0RegBase
= MmPciAddress (
1366 PchPlatformPolicy
->BusNumber
,
1367 PCI_DEVICE_NUMBER_PCH_LPC
,
1368 PCI_FUNCTION_NUMBER_PCH_LPC
,
1372 Data8
= MmioRead8 (PciD31F0RegBase
+ R_PCH_LPC_RID_CC
);
1373 count
= ARRAY_SIZE (SBRevisionTable
);
1374 for (Index
= 0; Index
< count
; Index
++) {
1375 if(Data8
== SBRevisionTable
[Index
].RevId
) {
1376 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%02x %a", Data8
, SBRevisionTable
[Index
].String
);
1377 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_SOC_VALUE
), Buffer
, NULL
);
1387 // Microcode Revision
1389 EfiWriteMsr (EFI_MSR_IA32_BIOS_SIGN_ID
, 0);
1390 EfiCpuid (EFI_CPUID_VERSION_INFO
, NULL
);
1391 MicroCodeVersion
= (UINT32
) RShiftU64 (EfiReadMsr (EFI_MSR_IA32_BIOS_SIGN_ID
), 32);
1392 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"%x", MicroCodeVersion
);
1393 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PROCESSOR_MICROCODE_VALUE
), Buffer
, NULL
);
1399 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"0x%x", Data8
);
1400 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PUNIT_FW_VALUE
), Buffer
, NULL
);
1405 Data8
= (UINT8
)((MmioRead32 (PMC_BASE_ADDRESS
+ R_PCH_PMC_PRSTS
)>>16)&0x00FF);
1406 PIDData8
= (UINT8
)((MmioRead32 (PMC_BASE_ADDRESS
+ R_PCH_PMC_PRSTS
)>>24)&0x00FF);
1407 UnicodeSPrint (Buffer
, sizeof (Buffer
), L
"0x%X_%X",PIDData8
, Data8
);
1408 HiiSetString(mHiiHandle
,STRING_TOKEN(STR_PMC_FW_VALUE
), Buffer
, NULL
);
1415 Update SATA Drivesize Strings for Setup and Boot order
1417 @param NewString - pointer to string.
1418 @param DeviceSpeed - speed of drive.
1422 GetDeviceSpeedString (
1424 IN UINTN DeviceSpeed
1427 if (DeviceSpeed
== 0x01) {
1428 StrCat (NewString
, L
"1.5Gb/s");
1429 } else if (DeviceSpeed
== 0x02) {
1430 StrCat (NewString
, L
"3.0Gb/s");
1431 } else if (DeviceSpeed
== 0x03) {
1432 StrCat (NewString
, L
"6.0Gb/s");
1433 } else if (DeviceSpeed
== 0x0) {
1439 GetChipsetSataPortSpeed (
1444 UINT8 DeviceConfigStatus
;
1446 EFI_PHYSICAL_ADDRESS MemBaseAddress
= 0;
1449 DeviceSpeed
= 0x01; // generation 1
1453 // Allocate the AHCI BAR
1455 FunNum
= PCI_FUNCTION_NUMBER_PCH_SATA
;
1456 MemBaseAddress
= 0x0ffffffff;
1457 gDS
->AllocateMemorySpace (
1458 EfiGcdAllocateMaxAddressSearchBottomUp
,
1459 EfiGcdMemoryTypeMemoryMappedIo
,
1460 N_PCH_SATA_ABAR_ALIGNMENT
, // 2^11: 2K Alignment
1461 V_PCH_SATA_ABAR_LENGTH
, // 2K Length
1466 IdeAhciBar
= MmioRead32 (
1470 PCI_DEVICE_NUMBER_PCH_SATA
,
1475 IdeAhciBar
&= 0xFFFFF800;
1476 DeviceConfigStatus
= 0;
1477 if (IdeAhciBar
== 0) {
1478 DeviceConfigStatus
= 1;
1479 IdeAhciBar
= (UINT32
)MemBaseAddress
;
1481 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_ABAR
),
1485 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_COMMAND
),
1486 B_PCH_SATA_COMMAND_MSE
1490 if (mSystemConfiguration
.SataType
== PCH_SATA_MODE_IDE
){
1492 // Program the "Ports Implemented Register"
1494 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
));
1500 DeviceSpeed
= *(volatile UINT32
*)(UINTN
)(IdeAhciBar
+ R_PCH_SATA_AHCI_P0SSTS
);
1503 DeviceSpeed
= *(volatile UINT32
*)(UINTN
)(IdeAhciBar
+ R_PCH_SATA_AHCI_P1SSTS
);
1507 if (MemBaseAddress
) {
1508 gDS
->FreeMemorySpace (
1510 V_PCH_SATA_ABAR_LENGTH
1514 if (DeviceConfigStatus
) {
1517 MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA
, FunNum
, R_PCH_SATA_ABAR
),
1522 DeviceSpeed
= (UINT8
)((DeviceSpeed
>> 4) & 0x0F);
1524 return (UINT8
)DeviceSpeed
;
1529 IDE data filter function.
1533 IdeDataFilter (void)
1537 EFI_HANDLE
*HandleBuffer
;
1538 EFI_DISK_INFO_PROTOCOL
*DiskInfo
;
1539 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, *DevicePathNode
;
1540 PCI_DEVICE_PATH
*PciDevicePath
;
1547 EFI_ATA_IDENTIFY_DATA
*IdentifyDriveInfo
;
1549 CHAR16 SizeString
[20];
1550 STRING_REF NameToUpdate
;
1551 CHAR8 StringBuffer
[0x100];
1556 // Assume no line strings is longer than 256 bytes.
1558 NewString
= AllocateZeroPool (0x100);
1559 PciDevicePath
= NULL
;
1562 // Fill IDE Infomation
1564 Status
= gBS
->LocateHandleBuffer (
1566 &gEfiDiskInfoProtocolGuid
,
1572 if (EFI_ERROR (Status
)) {
1576 for (Index
= 0; Index
< HandleCount
; Index
++) {
1578 Status
= gBS
->HandleProtocol (
1579 HandleBuffer
[Index
],
1580 &gEfiDevicePathProtocolGuid
,
1583 ASSERT_EFI_ERROR (Status
);
1585 DevicePathNode
= DevicePath
;
1586 while (!IsDevicePathEnd (DevicePathNode
) ) {
1587 if ((DevicePathType (DevicePathNode
) == HARDWARE_DEVICE_PATH
) &&
1588 ( DevicePathSubType (DevicePathNode
) == HW_PCI_DP
)) {
1589 PciDevicePath
= (PCI_DEVICE_PATH
*) DevicePathNode
;
1592 DevicePathNode
= NextDevicePathNode (DevicePathNode
);
1595 if (PciDevicePath
== NULL
) {
1600 // Check for onboard IDE
1602 if (PciDevicePath
->Device
== PCI_DEVICE_NUMBER_PCH_SATA
) {
1603 Status
= gBS
->HandleProtocol (
1604 HandleBuffer
[Index
],
1605 &gEfiDiskInfoProtocolGuid
,
1608 ASSERT_EFI_ERROR (Status
);
1610 Status
= DiskInfo
->WhichIde (
1615 ASSERT_EFI_ERROR (Status
);
1617 IdentifyDriveInfo
= AllocatePool (sizeof(EFI_ATA_IDENTIFY_DATA
));
1619 BufferSize
= sizeof(EFI_ATA_IDENTIFY_DATA
);
1620 Status
= DiskInfo
->Identify (
1625 ASSERT_EFI_ERROR(Status
);
1628 // Onboard SATA Devices
1630 if (PciDevicePath
->Function
== PCI_FUNCTION_NUMBER_PCH_SATA
) {
1631 if (IdeChannel
== 0 && IdeDevice
== 0) {
1632 NameToUpdate
= (STRING_REF
)STR_SATA0_NAME
;
1633 } else if (IdeChannel
== 1 && IdeDevice
== 0) {
1634 NameToUpdate
= (STRING_REF
)STR_SATA1_NAME
;
1642 ZeroMem(StringBuffer
, sizeof(StringBuffer
));
1645 (CHAR8
*)&IdentifyDriveInfo
->ModelName
,
1646 sizeof(IdentifyDriveInfo
->ModelName
)
1648 SwapEntries(StringBuffer
);
1649 AsciiToUnicode(StringBuffer
, NewString
);
1652 // Chap it off after 16 characters
1657 // For HardDisk append the size. Otherwise display atapi
1659 if ((IdentifyDriveInfo
->config
& 0x8000) == 00) {
1661 // 48 bit address feature set is supported, get maximum capacity
1663 if ((IdentifyDriveInfo
->command_set_supported_83
& 0x0400) == 0) {
1664 DriveSize
= (((((IdentifyDriveInfo
->user_addressable_sectors_hi
<< 16) +
1665 IdentifyDriveInfo
->user_addressable_sectors_lo
) / 1000) * 512) / 1000);
1667 DriveSize
= IdentifyDriveInfo
->maximum_lba_for_48bit_addressing
[0];
1668 for (Index1
= 1; Index1
< 4; Index1
++) {
1670 // Lower byte goes first: word[100] is the lowest word, word[103] is highest
1672 DriveSize
|= LShiftU64(IdentifyDriveInfo
->maximum_lba_for_48bit_addressing
[Index1
], 16 * Index1
);
1674 DriveSize
= (UINT32
) DivU64x32(MultU64x32(DivU64x32(DriveSize
, 1000), 512), 1000);
1677 StrCat (NewString
, L
"(");
1678 EfiValueToString (SizeString
, DriveSize
/1000, PREFIX_BLANK
, 0);
1679 StrCat (NewString
, SizeString
);
1680 StrCat (NewString
, L
".");
1681 EfiValueToString (SizeString
, (DriveSize
%1000)/100, PREFIX_BLANK
, 0);
1682 StrCat (NewString
, SizeString
);
1683 StrCat (NewString
, L
"GB");
1685 StrCat (NewString
, L
"(ATAPI");
1691 PortNumber
= (IdeDevice
<< 1) + IdeChannel
;
1692 DeviceSpeed
= GetChipsetSataPortSpeed(PortNumber
);
1695 StrCat (NewString
, L
"-");
1696 GetDeviceSpeedString( NewString
, DeviceSpeed
);
1699 StrCat (NewString
, L
")");
1701 HiiSetString(mHiiHandle
, NameToUpdate
, NewString
, NULL
);
1706 if (HandleBuffer
!= NULL
) {
1707 gBS
->FreePool (HandleBuffer
);
1710 gBS
->FreePool(NewString
);
1722 EFI_PEI_HOB_POINTERS GuidHob
;
1724 if (mSetupInfoDone
) {
1728 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1729 Status
= gRT
->GetVariable(
1731 &gEfiNormalSetupGuid
,
1734 &mSystemConfiguration
1737 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
1738 //The setup variable is corrupted
1739 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1740 Status
= gRT
->GetVariable(
1742 &gEfiNormalSetupGuid
,
1745 &mSystemConfiguration
1747 ASSERT_EFI_ERROR (Status
);
1751 // Update HOB variable for PCI resource information
1752 // Get the HOB list. If it is not present, then ASSERT.
1754 GuidHob
.Raw
= GetHobList ();
1755 if (GuidHob
.Raw
!= NULL
) {
1756 if ((GuidHob
.Raw
= GetNextGuidHob (&gEfiPlatformInfoGuid
, GuidHob
.Raw
)) != NULL
) {
1757 mPlatformInfo
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
1762 PrepareSetupInformation();
1763 UpdateAdditionalInformation ();
1764 UpdatePlatformInformation();
1765 UpdateCPUInformation();
1767 mSetupInfoDone
= TRUE
;
1773 #define EFI_SECURE_BOOT_MODE_NAME L"SecureBoot"
1776 CheckSystemConfigLoad(SYSTEM_CONFIGURATION
*SystemConfigPtr
)
1783 DataSize
= sizeof(SecureBoot
);
1784 Status
= gRT
->GetVariable (
1785 EFI_SECURE_BOOT_MODE_NAME
,
1786 &gEfiGlobalVariableGuid
,
1792 if (EFI_ERROR(Status
)) {
1793 SystemConfigPtr
->SecureBoot
= 0;
1795 SystemConfigPtr
->SecureBoot
= SecureBoot
;
1801 // "SecureBootEnable" variable for the Secure boot feature enable/disable.
1803 #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable"
1804 extern EFI_GUID gEfiSecureBootEnableDisableGuid
;
1808 CheckSystemConfigSave(SYSTEM_CONFIGURATION
*SystemConfigPtr
)
1811 UINT8 SecureBootCfg
;
1812 BOOLEAN SecureBootNotFound
;
1817 // Secure Boot configuration changes
1819 DataSize
= sizeof(SecureBootCfg
);
1820 SecureBootNotFound
= FALSE
;
1821 Status
= gRT
->GetVariable (
1822 EFI_SECURE_BOOT_ENABLE_NAME
,
1823 &gEfiSecureBootEnableDisableGuid
,
1829 if (EFI_ERROR(Status
)) {
1830 SecureBootNotFound
= TRUE
;
1832 if (SecureBootNotFound
) {
1833 Status
= gRT
->GetVariable (
1834 EFI_SECURE_BOOT_ENABLE_NAME
,
1835 &gEfiSecureBootEnableDisableGuid
,
1840 ASSERT_EFI_ERROR(Status
);
1842 if ((SecureBootCfg
) != SystemConfigPtr
->SecureBoot
) {
1843 SecureBootCfg
= !SecureBootCfg
;
1844 Status
= gRT
->SetVariable (
1845 EFI_SECURE_BOOT_ENABLE_NAME
,
1846 &gEfiSecureBootEnableDisableGuid
,
1847 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1856 ConfirmSecureBootTest()