44 for (Index = 0; Index < NumberOfDescriptors; Index++) {
45 if ((BaseAddress >= MemorySpaceMap[Index].BaseAddress) &&
46 (BaseAddress < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)))
51 if (((BaseAddress + Length - 1) >= MemorySpaceMap[Index].BaseAddress) &&
52 ((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)))
97 "SetGcdMemorySpaceAttributes[0x%lX; 0x%lX] = 0x%lX\n",
104 if ((Length & EFI_PAGE_MASK) != 0) {
107 "Warning: We do not support smaller granularity than 4KB on ARM Architecture (passed length: 0x%lX).\n",
123 if (EFI_ERROR (Status)) {
130 for (Index = StartIndex; Index <= EndIndex; Index++) {
138 if (BaseAddress >= MemorySpaceMap[Index].BaseAddress) {
139 RegionStart = BaseAddress;
141 RegionStart = MemorySpaceMap[Index].BaseAddress;
144 if ((BaseAddress + Length - 1) < (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length)) {
145 RegionLength = BaseAddress + Length - RegionStart;
147 RegionLength = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - RegionStart;
152 Capabilities = MemorySpaceMap[Index].Capabilities | EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP;
156 Status =
gDS->SetMemorySpaceCapabilities (
162 if (EFI_ERROR (Status)) {
165 "%a - failed to update GCD capabilities: 0x%llx on memory region: 0x%llx length: 0x%llx Status: %r\n",
181 Status =
gDS->SetMemorySpaceAttributes (
184 (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK) | (Attributes & Capabilities)
187 if (EFI_ERROR (Status)) {
190 "%a - failed to update GCD attributes: 0x%llx on memory region: 0x%llx length: 0x%llx Status: %r\n",
232 IN UINT64 EfiAttributes
237 UINTN RegionBaseAddress;
239 UINTN RegionArmAttributes;
241 if (mIsFlushingGCD) {
245 if ((BaseAddress & (SIZE_4KB - 1)) != 0) {
247 DEBUG ((DEBUG_PAGE,
"CpuSetMemoryAttributes(%lx, %lx, %lx): Minimum granularity is SIZE_4KB\n", BaseAddress, Length, EfiAttributes));
248 return EFI_UNSUPPORTED;
252 ArmAttributes = EfiAttributeToArmAttribute (EfiAttributes);
255 RegionBaseAddress = BaseAddress;
256 Status = GetMemoryRegion (&RegionBaseAddress, &RegionLength, &RegionArmAttributes);
260 if (EFI_ERROR (Status) || (RegionArmAttributes != ArmAttributes) ||
261 ((BaseAddress + Length) > (RegionBaseAddress + RegionLength)))
EFI_STATUS ArmSetMemoryAttributes(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN UINT64 AttributeMask)
EFI_STATUS SetGcdMemorySpaceAttributes(IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, IN UINTN NumberOfDescriptors, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
EFI_STATUS EFIAPI CpuSetMemoryAttributes(IN EFI_CPU_ARCH_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 EfiAttributes)
EFI_STATUS SearchGcdMemorySpaces(IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, IN UINTN NumberOfDescriptors, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, OUT UINTN *StartIndex, OUT UINTN *EndIndex)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ EfiGcdMemoryTypeNonExistent
UINT64 EFI_PHYSICAL_ADDRESS