Changeset 77662 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe
- Timestamp:
- Mar 12, 2019 12:40:12 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129295
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 7 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776 /vendor/edk2/current 103735-103757,103769-103776,129194-129237
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuDxe.c
r58459 r77662 1 1 /** @file 2 CPU DXE Module .3 4 Copyright (c) 2008 - 201 3, Intel Corporation. All rights reserved.<BR>2 CPU DXE Module to produce CPU ARCH Protocol. 3 4 Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 14 14 15 15 #include "CpuDxe.h" 16 #include "CpuMp.h" 17 #include "CpuPageTable.h" 18 19 #define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) 20 #define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY_RO) 16 21 17 22 // … … 21 26 EFI_HANDLE mCpuHandle = NULL; 22 27 BOOLEAN mIsFlushingGCD; 23 UINT64 mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; 24 UINT64 mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; 28 BOOLEAN mIsAllocatingPageTable = FALSE; 29 UINT64 mValidMtrrAddressMask; 30 UINT64 mValidMtrrBitsMask; 31 UINT64 mTimerPeriod = 0; 25 32 26 33 FIXED_MTRR mFixedMtrrTable[] = { 27 34 { 28 M TRR_LIB_IA32_MTRR_FIX64K_00000,35 MSR_IA32_MTRR_FIX64K_00000, 29 36 0, 30 37 0x10000 31 38 }, 32 39 { 33 M TRR_LIB_IA32_MTRR_FIX16K_80000,40 MSR_IA32_MTRR_FIX16K_80000, 34 41 0x80000, 35 42 0x4000 36 43 }, 37 44 { 38 M TRR_LIB_IA32_MTRR_FIX16K_A0000,45 MSR_IA32_MTRR_FIX16K_A0000, 39 46 0xA0000, 40 47 0x4000 41 48 }, 42 49 { 43 M TRR_LIB_IA32_MTRR_FIX4K_C0000,50 MSR_IA32_MTRR_FIX4K_C0000, 44 51 0xC0000, 45 52 0x1000 46 53 }, 47 54 { 48 M TRR_LIB_IA32_MTRR_FIX4K_C8000,55 MSR_IA32_MTRR_FIX4K_C8000, 49 56 0xC8000, 50 57 0x1000 51 58 }, 52 59 { 53 M TRR_LIB_IA32_MTRR_FIX4K_D0000,60 MSR_IA32_MTRR_FIX4K_D0000, 54 61 0xD0000, 55 62 0x1000 56 63 }, 57 64 { 58 M TRR_LIB_IA32_MTRR_FIX4K_D8000,65 MSR_IA32_MTRR_FIX4K_D8000, 59 66 0xD8000, 60 67 0x1000 61 68 }, 62 69 { 63 M TRR_LIB_IA32_MTRR_FIX4K_E0000,70 MSR_IA32_MTRR_FIX4K_E0000, 64 71 0xE0000, 65 72 0x1000 66 73 }, 67 74 { 68 M TRR_LIB_IA32_MTRR_FIX4K_E8000,75 MSR_IA32_MTRR_FIX4K_E8000, 69 76 0xE8000, 70 77 0x1000 71 78 }, 72 79 { 73 M TRR_LIB_IA32_MTRR_FIX4K_F0000,80 MSR_IA32_MTRR_FIX4K_F0000, 74 81 0xF0000, 75 82 0x1000 76 83 }, 77 84 { 78 M TRR_LIB_IA32_MTRR_FIX4K_F8000,85 MSR_IA32_MTRR_FIX4K_F8000, 79 86 0xF8000, 80 87 0x1000 … … 293 300 ) 294 301 { 302 UINT64 BeginValue; 303 UINT64 EndValue; 304 295 305 if (TimerValue == NULL) { 296 306 return EFI_INVALID_PARAMETER; … … 304 314 305 315 if (TimerPeriod != NULL) { 316 if (mTimerPeriod == 0) { 306 317 // 307 // BugBug: Hard coded. Don't know how to do this generically318 // Read time stamp counter before and after delay of 100 microseconds 308 319 // 309 *TimerPeriod = 1000000000; 320 BeginValue = AsmReadTsc (); 321 MicroSecondDelay (100); 322 EndValue = AsmReadTsc (); 323 // 324 // Calculate the actual frequency 325 // 326 mTimerPeriod = DivU64x64Remainder ( 327 MultU64x32 ( 328 1000 * 1000 * 1000, 329 100 330 ), 331 EndValue - BeginValue, 332 NULL 333 ); 334 } 335 *TimerPeriod = mTimerPeriod; 310 336 } 311 337 … … 313 339 } 314 340 341 /** 342 A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to 343 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure. 344 345 @param[in] Buffer Pointer to an MTRR_SETTINGS object, to be passed to 346 MtrrSetAllMtrrs(). 347 **/ 348 VOID 349 EFIAPI 350 SetMtrrsFromBuffer ( 351 IN VOID *Buffer 352 ) 353 { 354 MtrrSetAllMtrrs (Buffer); 355 } 315 356 316 357 /** … … 350 391 RETURN_STATUS Status; 351 392 MTRR_MEMORY_CACHE_TYPE CacheType; 352 353 if (!IsMtrrSupported ()) { 354 return EFI_UNSUPPORTED; 355 } 393 EFI_STATUS MpStatus; 394 EFI_MP_SERVICES_PROTOCOL *MpService; 395 MTRR_SETTINGS MtrrSettings; 396 UINT64 CacheAttributes; 397 UINT64 MemoryAttributes; 398 MTRR_MEMORY_CACHE_TYPE CurrentCacheType; 356 399 357 400 // … … 362 405 // 363 406 if (mIsFlushingGCD) { 364 DEBUG(( EFI_D_INFO, " Flushing GCD\n"));407 DEBUG((DEBUG_INFO, " Flushing GCD\n")); 365 408 return EFI_SUCCESS; 366 409 } 367 410 368 switch (Attributes) { 369 case EFI_MEMORY_UC: 370 CacheType = CacheUncacheable; 371 break; 372 373 case EFI_MEMORY_WC: 374 CacheType = CacheWriteCombining; 375 break; 376 377 case EFI_MEMORY_WT: 378 CacheType = CacheWriteThrough; 379 break; 380 381 case EFI_MEMORY_WP: 382 CacheType = CacheWriteProtected; 383 break; 384 385 case EFI_MEMORY_WB: 386 CacheType = CacheWriteBack; 387 break; 388 389 case EFI_MEMORY_UCE: 390 case EFI_MEMORY_RP: 391 case EFI_MEMORY_XP: 392 case EFI_MEMORY_RUNTIME: 393 return EFI_UNSUPPORTED; 394 395 default: 411 // 412 // During memory attributes updating, new pages may be allocated to setup 413 // smaller granularity of page table. Page allocation action might then cause 414 // another calling of CpuSetMemoryAttributes() recursively, due to memory 415 // protection policy configured (such as PcdDxeNxMemoryProtectionPolicy). 416 // Since this driver will always protect memory used as page table by itself, 417 // there's no need to apply protection policy requested from memory service. 418 // So it's safe to just return EFI_SUCCESS if this time of calling is caused 419 // by page table memory allocation. 420 // 421 if (mIsAllocatingPageTable) { 422 DEBUG((DEBUG_VERBOSE, " Allocating page table memory\n")); 423 return EFI_SUCCESS; 424 } 425 426 CacheAttributes = Attributes & CACHE_ATTRIBUTE_MASK; 427 MemoryAttributes = Attributes & MEMORY_ATTRIBUTE_MASK; 428 429 if (Attributes != (CacheAttributes | MemoryAttributes)) { 396 430 return EFI_INVALID_PARAMETER; 397 431 } 398 // 399 // call MTRR libary function 400 // 401 Status = MtrrSetMemoryAttribute ( 402 BaseAddress, 403 Length, 404 CacheType 405 ); 406 407 return (EFI_STATUS) Status; 432 433 if (CacheAttributes != 0) { 434 if (!IsMtrrSupported ()) { 435 return EFI_UNSUPPORTED; 436 } 437 438 switch (CacheAttributes) { 439 case EFI_MEMORY_UC: 440 CacheType = CacheUncacheable; 441 break; 442 443 case EFI_MEMORY_WC: 444 CacheType = CacheWriteCombining; 445 break; 446 447 case EFI_MEMORY_WT: 448 CacheType = CacheWriteThrough; 449 break; 450 451 case EFI_MEMORY_WP: 452 CacheType = CacheWriteProtected; 453 break; 454 455 case EFI_MEMORY_WB: 456 CacheType = CacheWriteBack; 457 break; 458 459 default: 460 return EFI_INVALID_PARAMETER; 461 } 462 CurrentCacheType = MtrrGetMemoryAttribute(BaseAddress); 463 if (CurrentCacheType != CacheType) { 464 // 465 // call MTRR libary function 466 // 467 Status = MtrrSetMemoryAttribute ( 468 BaseAddress, 469 Length, 470 CacheType 471 ); 472 473 if (!RETURN_ERROR (Status)) { 474 MpStatus = gBS->LocateProtocol ( 475 &gEfiMpServiceProtocolGuid, 476 NULL, 477 (VOID **)&MpService 478 ); 479 // 480 // Synchronize the update with all APs 481 // 482 if (!EFI_ERROR (MpStatus)) { 483 MtrrGetAllMtrrs (&MtrrSettings); 484 MpStatus = MpService->StartupAllAPs ( 485 MpService, // This 486 SetMtrrsFromBuffer, // Procedure 487 FALSE, // SingleThread 488 NULL, // WaitEvent 489 0, // TimeoutInMicrosecsond 490 &MtrrSettings, // ProcedureArgument 491 NULL // FailedCpuList 492 ); 493 ASSERT (MpStatus == EFI_SUCCESS || MpStatus == EFI_NOT_STARTED); 494 } 495 } 496 if (EFI_ERROR(Status)) { 497 return Status; 498 } 499 } 500 } 501 502 // 503 // Set memory attribute by page table 504 // 505 return AssignMemoryPageAttributes (NULL, BaseAddress, Length, MemoryAttributes, NULL); 408 506 } 409 507 … … 428 526 429 527 PhysicalAddressBits = (UINT8) RegEax; 430 431 mValidMtrrBitsMask = LShiftU64 (1, PhysicalAddressBits) - 1;432 mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;433 528 } else { 434 mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; 435 mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; 436 } 529 PhysicalAddressBits = 36; 530 } 531 532 mValidMtrrBitsMask = LShiftU64 (1, PhysicalAddressBits) - 1; 533 mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL; 437 534 } 438 535 … … 602 699 **/ 603 700 VOID 604 Refresh GcdMemoryAttributes(701 RefreshMemoryAttributesFromMtrr ( 605 702 VOID 606 703 ) … … 623 720 UINT8 DefaultMemoryType; 624 721 625 if (!IsMtrrSupported ()) {626 return;627 }628 629 722 FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount (); 630 723 ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); 631 724 632 mIsFlushingGCD = TRUE;633 725 MemorySpaceMap = NULL; 634 726 … … 781 873 FreePool (MemorySpaceMap); 782 874 } 875 } 876 877 /** 878 Check if paging is enabled or not. 879 **/ 880 BOOLEAN 881 IsPagingAndPageAddressExtensionsEnabled ( 882 VOID 883 ) 884 { 885 IA32_CR0 Cr0; 886 IA32_CR4 Cr4; 887 888 Cr0.UintN = AsmReadCr0 (); 889 Cr4.UintN = AsmReadCr4 (); 890 891 return ((Cr0.Bits.PG != 0) && (Cr4.Bits.PAE != 0)); 892 } 893 894 /** 895 Refreshes the GCD Memory Space attributes according to MTRRs and Paging. 896 897 This function refreshes the GCD Memory Space attributes according to MTRRs 898 and page tables. 899 900 **/ 901 VOID 902 RefreshGcdMemoryAttributes ( 903 VOID 904 ) 905 { 906 mIsFlushingGCD = TRUE; 907 908 if (IsMtrrSupported ()) { 909 RefreshMemoryAttributesFromMtrr (); 910 } 911 912 if (IsPagingAndPageAddressExtensionsEnabled ()) { 913 RefreshGcdMemoryAttributesFromPaging (); 914 } 783 915 784 916 mIsFlushingGCD = FALSE; … … 826 958 } 827 959 960 /** 961 Ensure the compatibility of a memory space descriptor with the MMIO aperture. 962 963 The memory space descriptor can come from the GCD memory space map, or it can 964 represent a gap between two neighboring memory space descriptors. In the 965 latter case, the GcdMemoryType field is expected to be 966 EfiGcdMemoryTypeNonExistent. 967 968 If the memory space descriptor already has type 969 EfiGcdMemoryTypeMemoryMappedIo, and its capabilities are a superset of the 970 required capabilities, then no action is taken -- it is by definition 971 compatible with the aperture. 972 973 Otherwise, the intersection of the memory space descriptor is calculated with 974 the aperture. If the intersection is the empty set (no overlap), no action is 975 taken; the memory space descriptor is compatible with the aperture. 976 977 Otherwise, the type of the descriptor is investigated again. If the type is 978 EfiGcdMemoryTypeNonExistent (representing a gap, or a genuine descriptor with 979 such a type), then an attempt is made to add the intersection as MMIO space 980 to the GCD memory space map, with the specified capabilities. This ensures 981 continuity for the aperture, and the descriptor is deemed compatible with the 982 aperture. 983 984 Otherwise, the memory space descriptor is incompatible with the MMIO 985 aperture. 986 987 @param[in] Base Base address of the aperture. 988 @param[in] Length Length of the aperture. 989 @param[in] Capabilities Capabilities required by the aperture. 990 @param[in] Descriptor The descriptor to ensure compatibility with the 991 aperture for. 992 993 @retval EFI_SUCCESS The descriptor is compatible. The GCD memory 994 space map may have been updated, for 995 continuity within the aperture. 996 @retval EFI_INVALID_PARAMETER The descriptor is incompatible. 997 @return Error codes from gDS->AddMemorySpace(). 998 **/ 999 EFI_STATUS 1000 IntersectMemoryDescriptor ( 1001 IN UINT64 Base, 1002 IN UINT64 Length, 1003 IN UINT64 Capabilities, 1004 IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor 1005 ) 1006 { 1007 UINT64 IntersectionBase; 1008 UINT64 IntersectionEnd; 1009 EFI_STATUS Status; 1010 1011 if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo && 1012 (Descriptor->Capabilities & Capabilities) == Capabilities) { 1013 return EFI_SUCCESS; 1014 } 1015 1016 IntersectionBase = MAX (Base, Descriptor->BaseAddress); 1017 IntersectionEnd = MIN (Base + Length, 1018 Descriptor->BaseAddress + Descriptor->Length); 1019 if (IntersectionBase >= IntersectionEnd) { 1020 // 1021 // The descriptor and the aperture don't overlap. 1022 // 1023 return EFI_SUCCESS; 1024 } 1025 1026 if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { 1027 Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, 1028 IntersectionBase, IntersectionEnd - IntersectionBase, 1029 Capabilities); 1030 1031 DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, 1032 "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__, 1033 IntersectionBase, IntersectionEnd, Status)); 1034 return Status; 1035 } 1036 1037 DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts " 1038 "with aperture [%Lx, %Lx) cap %Lx\n", gEfiCallerBaseName, __FUNCTION__, 1039 Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length, 1040 (UINT32)Descriptor->GcdMemoryType, Descriptor->Capabilities, 1041 Base, Base + Length, Capabilities)); 1042 return EFI_INVALID_PARAMETER; 1043 } 1044 1045 /** 1046 Add MMIO space to GCD. 1047 The routine checks the GCD database and only adds those which are 1048 not added in the specified range to GCD. 1049 1050 @param Base Base address of the MMIO space. 1051 @param Length Length of the MMIO space. 1052 @param Capabilities Capabilities of the MMIO space. 1053 1054 @retval EFI_SUCCES The MMIO space was added successfully. 1055 **/ 1056 EFI_STATUS 1057 AddMemoryMappedIoSpace ( 1058 IN UINT64 Base, 1059 IN UINT64 Length, 1060 IN UINT64 Capabilities 1061 ) 1062 { 1063 EFI_STATUS Status; 1064 UINTN Index; 1065 UINTN NumberOfDescriptors; 1066 EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; 1067 1068 Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); 1069 if (EFI_ERROR (Status)) { 1070 DEBUG ((DEBUG_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n", 1071 gEfiCallerBaseName, __FUNCTION__, Status)); 1072 return Status; 1073 } 1074 1075 for (Index = 0; Index < NumberOfDescriptors; Index++) { 1076 Status = IntersectMemoryDescriptor (Base, Length, Capabilities, 1077 &MemorySpaceMap[Index]); 1078 if (EFI_ERROR (Status)) { 1079 goto FreeMemorySpaceMap; 1080 } 1081 } 1082 1083 DEBUG_CODE ( 1084 // 1085 // Make sure there are adjacent descriptors covering [Base, Base + Length). 1086 // It is possible that they have not been merged; merging can be prevented 1087 // by allocation and different capabilities. 1088 // 1089 UINT64 CheckBase; 1090 EFI_STATUS CheckStatus; 1091 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; 1092 1093 for (CheckBase = Base; 1094 CheckBase < Base + Length; 1095 CheckBase = Descriptor.BaseAddress + Descriptor.Length) { 1096 CheckStatus = gDS->GetMemorySpaceDescriptor (CheckBase, &Descriptor); 1097 ASSERT_EFI_ERROR (CheckStatus); 1098 ASSERT (Descriptor.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo); 1099 ASSERT ((Descriptor.Capabilities & Capabilities) == Capabilities); 1100 } 1101 ); 1102 1103 FreeMemorySpaceMap: 1104 FreePool (MemorySpaceMap); 1105 1106 return Status; 1107 } 1108 1109 /** 1110 Add and allocate CPU local APIC memory mapped space. 1111 1112 @param[in]ImageHandle Image handle this driver. 1113 1114 **/ 1115 VOID 1116 AddLocalApicMemorySpace ( 1117 IN EFI_HANDLE ImageHandle 1118 ) 1119 { 1120 EFI_STATUS Status; 1121 EFI_PHYSICAL_ADDRESS BaseAddress; 1122 1123 BaseAddress = (EFI_PHYSICAL_ADDRESS) GetLocalApicBaseAddress(); 1124 Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC); 1125 ASSERT_EFI_ERROR (Status); 1126 1127 // 1128 // Try to allocate APIC memory mapped space, does not check return 1129 // status because it may be allocated by other driver, or DXE Core if 1130 // this range is built into Memory Allocation HOB. 1131 // 1132 Status = gDS->AllocateMemorySpace ( 1133 EfiGcdAllocateAddress, 1134 EfiGcdMemoryTypeMemoryMappedIo, 1135 0, 1136 SIZE_4KB, 1137 &BaseAddress, 1138 ImageHandle, 1139 NULL 1140 ); 1141 if (EFI_ERROR (Status)) { 1142 DEBUG ((DEBUG_INFO, "%a: %a: AllocateMemorySpace() Status - %r\n", 1143 gEfiCallerBaseName, __FUNCTION__, Status)); 1144 } 1145 } 828 1146 829 1147 /** … … 848 1166 EFI_EVENT IdleLoopEvent; 849 1167 1168 InitializePageTableLib(); 1169 850 1170 InitializeFloatingPointUnits (); 851 1171 … … 864 1184 // 865 1185 InitInterruptDescriptorTable (); 866 867 //868 // Enable the local APIC for Virtual Wire Mode.869 //870 ProgramVirtualWireMode ();871 1186 872 1187 // … … 884 1199 // 885 1200 RefreshGcdMemoryAttributes (); 1201 1202 // 1203 // Add and allocate local APIC memory mapped space 1204 // 1205 AddLocalApicMemorySpace (ImageHandle); 886 1206 887 1207 // … … 898 1218 ASSERT_EFI_ERROR (Status); 899 1219 1220 InitializeMpSupport (); 1221 900 1222 return Status; 901 1223 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuDxe.h
r58459 r77662 1 1 /** @file 2 CPU DXE Module .3 4 Copyright (c) 2008 - 201 3, Intel Corporation. All rights reserved.<BR>2 CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol. 3 4 Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 19 19 20 20 #include <Protocol/Cpu.h> 21 #include <Protocol/MpService.h> 22 #include <Register/Msr.h> 23 24 #include <Ppi/SecPlatformInformation.h> 25 #include <Ppi/SecPlatformInformation2.h> 21 26 22 27 #include <Library/UefiDriverEntryPoint.h> … … 33 38 #include <Library/UefiLib.h> 34 39 #include <Library/CpuExceptionHandlerLib.h> 40 #include <Library/HobLib.h> 41 #include <Library/ReportStatusCodeLib.h> 42 #include <Library/MpInitLib.h> 43 #include <Library/TimerLib.h> 44 35 45 #include <Guid/IdleLoopEvent.h> 36 46 #include <Guid/VectorHandoffTable.h> … … 43 53 ) 44 54 55 #define EFI_MEMORY_PAGETYPE_MASK (EFI_MEMORY_RP | \ 56 EFI_MEMORY_XP | \ 57 EFI_MEMORY_RO \ 58 ) 45 59 46 60 /** … … 252 266 ); 253 267 268 /** 269 Update GCD memory space attributes according to current page table setup. 270 **/ 271 VOID 272 RefreshGcdMemoryAttributesFromPaging ( 273 VOID 274 ); 275 276 extern BOOLEAN mIsAllocatingPageTable; 277 254 278 #endif 255 279 -
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuDxe.inf
r58459 r77662 1 1 ## @file 2 # Simple CPU driver installs CPU Architecture Protocol.2 # CPU driver installs CPU Architecture Protocol and CPU MP protocol. 3 3 # 4 # Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> 4 # Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR> 5 # Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR> 6 # 5 7 # This program and the accompanying materials 6 8 # are licensed and made available under the terms and conditions of the BSD License … … 20 22 MODULE_TYPE = DXE_DRIVER 21 23 VERSION_STRING = 1.0 22 23 24 ENTRY_POINT = InitializeCpu 24 25 … … 42 43 UefiLib 43 44 CpuExceptionHandlerLib 45 HobLib 46 ReportStatusCodeLib 47 MpInitLib 48 TimerLib 44 49 45 50 [Sources] … … 47 52 CpuDxe.h 48 53 CpuGdt.c 54 CpuGdt.h 55 CpuMp.c 56 CpuMp.h 57 CpuPageTable.h 58 CpuPageTable.c 49 59 50 60 [Sources.IA32] 51 Ia32/CpuAsm.asm | MSFT52 Ia32/CpuAsm. asm | INTEL53 Ia32/CpuAsm.S | GCC61 Ia32/CpuAsm.asm 62 Ia32/CpuAsm.nasm 63 Ia32/CpuAsm.S 54 64 55 65 [Sources.X64] 56 X64/CpuAsm.asm | MSFT57 X64/CpuAsm. asm | INTEL58 X64/CpuAsm.S | GCC66 X64/CpuAsm.asm 67 X64/CpuAsm.nasm 68 X64/CpuAsm.S 59 69 60 70 [Protocols] 61 71 gEfiCpuArchProtocolGuid ## PRODUCES 72 gEfiMpServiceProtocolGuid ## PRODUCES 73 gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES 62 74 63 75 [Guids] 64 76 gIdleLoopEventGuid ## CONSUMES ## Event 65 77 gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable 78 79 [Ppis] 80 gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB 81 gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB 82 83 [Pcd] 84 gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES 85 gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES 86 gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ## CONSUMES 87 gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ## CONSUMES 66 88 67 89 [Depex] -
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuDxe.uni
r58464 r77662 1 // /** @file2 // Simple CPU driver installs CPU ArchitectureProtocol.1 // /** @file 2 // CPU driver installs CPU Architecture Protocol and CPU MP Protocol. 3 3 // 4 // Simple CPU driver installs CPU ArchitectureProtocol.4 // CPU driver installs CPU Architecture Protocol and CPU MP Protocol. 5 5 // 6 // Copyright (c) 2008 - 201 4, Intel Corporation. All rights reserved.<BR>6 // Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR> 7 7 // 8 8 // This program and the accompanying materials … … 17 17 18 18 19 #string STR_MODULE_ABSTRACT #language en-US " Installs CPU Architecture Protocol"19 #string STR_MODULE_ABSTRACT #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." 20 20 21 #string STR_MODULE_DESCRIPTION #language en-US " Simple CPU driver installs CPU ArchitectureProtocol."21 #string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." 22 22 -
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // CpuDxe Localized Strings and Content 3 3 // 4 // Copyright (c) 2013 - 201 4, Intel Corporation. All rights reserved.<BR>4 // Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 // 6 6 // This program and the accompanying materials … … 16 16 #string STR_PROPERTIES_MODULE_NAME 17 17 #language en-US 18 "CPU Architectural DXE Driver"18 "CPU Architectural and CPU Multi-processor DXE Driver" 19 19 20 20 -
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuDxe/CpuGdt.c
r58517 r77662 3 3 requiring a minimal assembly interrupt entry point. 4 4 5 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> 6 6 This program and the accompanying materials 7 7 are licensed and made available under the terms and conditions of the BSD License … … 15 15 16 16 #include "CpuDxe.h" 17 18 19 // 20 // Local structure definitions 21 // 22 23 #pragma pack (1) 24 25 // 26 // Global Descriptor Entry structures 27 // 28 29 typedef struct _GDT_ENTRY { 30 UINT16 Limit15_0; 31 UINT16 Base15_0; 32 UINT8 Base23_16; 33 UINT8 Type; 34 UINT8 Limit19_16_and_flags; 35 UINT8 Base31_24; 36 } GDT_ENTRY; 37 38 typedef 39 struct _GDT_ENTRIES { 40 GDT_ENTRY Null; 41 GDT_ENTRY Linear; 42 GDT_ENTRY LinearCode; 43 GDT_ENTRY SysData; 44 GDT_ENTRY SysCode; 45 GDT_ENTRY LinearCode64; 46 GDT_ENTRY Spare4; 47 GDT_ENTRY Spare5; 48 } GDT_ENTRIES; 49 50 #define NULL_SEL OFFSET_OF (GDT_ENTRIES, Null) 51 #define LINEAR_SEL OFFSET_OF (GDT_ENTRIES, Linear) 52 #define LINEAR_CODE_SEL OFFSET_OF (GDT_ENTRIES, LinearCode) 53 #define SYS_DATA_SEL OFFSET_OF (GDT_ENTRIES, SysData) 54 #define SYS_CODE_SEL OFFSET_OF (GDT_ENTRIES, SysCode) 55 #define LINEAR_CODE64_SEL OFFSET_OF (GDT_ENTRIES, LinearCode64) 56 #define SPARE4_SEL OFFSET_OF (GDT_ENTRIES, Spare4) 57 #define SPARE5_SEL OFFSET_OF (GDT_ENTRIES, Spare5) 58 59 #if defined (MDE_CPU_IA32) 60 #define CPU_CODE_SEL LINEAR_CODE_SEL 61 #define CPU_DATA_SEL LINEAR_SEL 62 #elif defined (MDE_CPU_X64) 63 #define CPU_CODE_SEL LINEAR_CODE64_SEL 64 #define CPU_DATA_SEL LINEAR_SEL 65 #else 66 #error CPU type not supported for CPU GDT initialization! 67 #endif 17 #include "CpuGdt.h" 68 18 69 19 // … … 86 36 // 87 37 { 88 0x0FFFF, // limit 0xFFFFF89 0x0, // base 090 0x0, 91 0x092, // present, ring 0, data, expand-up, writable38 0x0FFFF, // limit 15:0 39 0x0, // base 15:0 40 0x0, // base 23:16 41 0x092, // present, ring 0, data, read/write 92 42 0x0CF, // page-granular, 32-bit 93 43 0x0, … … 97 47 // 98 48 { 99 0x0FFFF, // limit 0xFFFFF100 0x0, // base 0101 0x0, 102 0x09 A, // present, ring 0, data, expand-up, writable49 0x0FFFF, // limit 15:0 50 0x0, // base 15:0 51 0x0, // base 23:16 52 0x09F, // present, ring 0, code, execute/read, conforming, accessed 103 53 0x0CF, // page-granular, 32-bit 104 54 0x0, … … 108 58 // 109 59 { 110 0x0FFFF, // limit 0xFFFFF111 0x0, // base 0112 0x0, 113 0x09 2, // present, ring 0, data, expand-up, writable60 0x0FFFF, // limit 15:0 61 0x0, // base 15:0 62 0x0, // base 23:16 63 0x093, // present, ring 0, data, read/write, accessed 114 64 0x0CF, // page-granular, 32-bit 115 65 0x0, … … 119 69 // 120 70 { 121 0x0FFFF, // limit 0xFFFFF 122 0x0, // base 0 71 0x0FFFF, // limit 15:0 72 0x0, // base 15:0 73 0x0, // base 23:16 74 0x09A, // present, ring 0, code, execute/read 75 0x0CF, // page-granular, 32-bit 123 76 0x0, 124 0x09A, // present, ring 0, data, expand-up, writable 77 }, 78 // 79 // SPARE4_SEL 80 // 81 { 82 0x0, // limit 15:0 83 0x0, // base 15:0 84 0x0, // base 23:16 85 0x0, // type 86 0x0, // limit 19:16, flags 87 0x0, // base 31:24 88 }, 89 // 90 // LINEAR_DATA64_SEL 91 // 92 { 93 0x0FFFF, // limit 15:0 94 0x0, // base 15:0 95 0x0, // base 23:16 96 0x092, // present, ring 0, data, read/write 125 97 0x0CF, // page-granular, 32-bit 126 98 0x0, … … 130 102 // 131 103 { 132 0x0FFFF, // limit 0xFFFFF133 0x0, // base 0134 0x0, 135 0x09 B, // present, ring 0, code, expand-up, writable136 0x0AF, // LimitHigh (CS.L=1, CS.D=0)104 0x0FFFF, // limit 15:0 105 0x0, // base 15:0 106 0x0, // base 23:16 107 0x09A, // present, ring 0, code, execute/read 108 0x0AF, // page-granular, 64-bit code 137 109 0x0, // base (high) 138 },139 //140 // SPARE4_SEL141 //142 {143 0x0, // limit 0144 0x0, // base 0145 0x0,146 0x0, // present, ring 0, data, expand-up, writable147 0x0, // page-granular, 32-bit148 0x0,149 110 }, 150 111 // … … 152 113 // 153 114 { 154 0x0, // limit 0155 0x0, // base 0156 0x0, 157 0x0, // present, ring 0, data, expand-up, writable158 0x0, // page-granular, 32-bit159 0x0, 115 0x0, // limit 15:0 116 0x0, // base 15:0 117 0x0, // base 23:16 118 0x0, // type 119 0x0, // limit 19:16, flags 120 0x0, // base 31:24 160 121 }, 161 122 };
Note:
See TracChangeset
for help on using the changeset viewer.