]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib: Added ConvertSectionAttributesToPageAttributes()
authorOlivier Martin <olivier.martin@arm.com>
Mon, 19 Aug 2013 17:37:50 +0000 (17:37 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 Aug 2013 17:37:50 +0000 (17:37 +0000)
This helper function converts the section attributes into their page equivalents.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14567 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c
ArmPkg/Include/Chipset/ArmV7Mmu.h
ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c

index ce8bd65c24178c69aae5d38dbec2032c0f4a14d7..38b709de15deb163a90813d9265e998deaf21969 100644 (file)
@@ -635,12 +635,7 @@ ConvertSectionToPages (
 \r
   // Get section attributes and convert to page attributes\r
   SectionDescriptor = FirstLevelTable[FirstLevelIdx];\r
-  PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE;\r
-  PageDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY(SectionDescriptor,0);\r
-  PageDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP(SectionDescriptor);\r
-  PageDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN(SectionDescriptor,0);\r
-  PageDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG(SectionDescriptor);\r
-  PageDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S(SectionDescriptor);\r
+  PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor, FALSE);\r
 \r
   // Allocate a page table for the 4KB entries (we use up a full page even though we only need 1KB)\r
   Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, 1, &PageTableAddr);\r
index 2ddab7635059991e536d077cf0781d0faf46d5ab..a3b3e35f10748bdb429cb64478711a69d7709d63 100644 (file)
                                                         TT_DESCRIPTOR_PAGE_AP_RW_RW                                                       | \\r
                                                         TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE)\r
 \r
+UINT32\r
+ConvertSectionAttributesToPageAttributes (\r
+  IN UINT32   SectionAttributes,\r
+  IN BOOLEAN  IsLargePage\r
+  );\r
+\r
 #endif\r
index 0f8b814c63b288dfb5c69256e01907e3fb4bcd3c..d64c188dc50376927e8ef675dd8e75ca2d8dd8b8 100644 (file)
 #include "ArmV7Lib.h"\r
 #include "ArmLibPrivate.h"\r
 \r
+UINT32\r
+ConvertSectionAttributesToPageAttributes (\r
+  IN UINT32   SectionAttributes,\r
+  IN BOOLEAN  IsLargePage\r
+  )\r
+{\r
+  UINT32 PageAttributes;\r
+\r
+  PageAttributes = 0;\r
+  PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (SectionAttributes, IsLargePage);\r
+  PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (SectionAttributes);\r
+  PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN (SectionAttributes, IsLargePage);\r
+  PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG (SectionAttributes);\r
+  PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S (SectionAttributes);\r
+\r
+  return PageAttributes;\r
+}\r
+\r
 STATIC\r
 VOID\r
 PopulateLevel2PageTable (\r
@@ -76,12 +94,7 @@ PopulateLevel2PageTable (
       TranslationTable = ((UINTN)TranslationTable + TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK) & ~TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK;\r
 \r
       // Translate the Section Descriptor into Page Descriptor\r
-      SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE;\r
-      SectionDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY(*SectionEntry,0);\r
-      SectionDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP(*SectionEntry);\r
-      SectionDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN(*SectionEntry,0);\r
-      SectionDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG(*SectionEntry);\r
-      SectionDescriptor |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S(*SectionEntry);\r
+      SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (*SectionEntry, FALSE);\r
 \r
       BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(*SectionEntry);\r
 \r