Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_pt.c

    rc72dc15 r235e6c7  
    3939#include <mm/page.h>
    4040#include <mm/frame.h>
    41 #include <mm/km.h>
    4241#include <mm/as.h>
    4342#include <arch/mm/page.h>
     
    7675       
    7776        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
    78                 pte_t *newpt = (pte_t *) frame_alloc(PTL1_SIZE,
    79                     FRAME_LOWMEM | FRAME_KA);
     77                pte_t *newpt = (pte_t *) frame_alloc(PTL1_SIZE, FRAME_KA);
    8078                memsetb(newpt, FRAME_SIZE << PTL1_SIZE, 0);
    8179                SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
    82                 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page),
    83                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    84                     PAGE_WRITE);
     80                SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    8581        }
    8682       
     
    8884       
    8985        if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
    90                 pte_t *newpt = (pte_t *) frame_alloc(PTL2_SIZE,
    91                     FRAME_LOWMEM | FRAME_KA);
     86                pte_t *newpt = (pte_t *) frame_alloc(PTL2_SIZE, FRAME_KA);
    9287                memsetb(newpt, FRAME_SIZE << PTL2_SIZE, 0);
    9388                SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
    94                 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page),
    95                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    96                     PAGE_WRITE);
     89                SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    9790        }
    9891       
     
    10093       
    10194        if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
    102                 pte_t *newpt = (pte_t *) frame_alloc(PTL3_SIZE,
    103                     FRAME_LOWMEM | FRAME_KA);
     95                pte_t *newpt = (pte_t *) frame_alloc(PTL3_SIZE, FRAME_KA);
    10496                memsetb(newpt, FRAME_SIZE << PTL3_SIZE, 0);
    10597                SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
    106                 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page),
    107                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    108                     PAGE_WRITE);
     98                SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    10999        }
    110100       
     
    154144       
    155145        /*
    156          * Second, free all empty tables along the way from PTL3 down to PTL0
    157          * except those needed for sharing the kernel non-identity mappings.
     146         * Second, free all empty tables along the way from PTL3 down to PTL0.
     147         *
    158148         */
    159149       
     
    172162                /*
    173163                 * PTL3 is empty.
    174                  * Release the frame and remove PTL3 pointer from the parent
    175                  * table.
    176                  */
     164                 * Release the frame and remove PTL3 pointer from preceding table.
     165                 *
     166                 */
     167                frame_free(KA2PA((uintptr_t) ptl3));
    177168#if (PTL2_ENTRIES != 0)
    178169                memsetb(&ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
     
    180171                memsetb(&ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
    181172#else
    182                 if (km_is_non_identity(page))
    183                         return;
    184 
    185173                memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
    186174#endif
    187                 frame_free(KA2PA((uintptr_t) ptl3));
    188175        } else {
    189176                /*
     
    208195                /*
    209196                 * PTL2 is empty.
    210                  * Release the frame and remove PTL2 pointer from the parent
    211                  * table.
    212                  */
     197                 * Release the frame and remove PTL2 pointer from preceding table.
     198                 *
     199                 */
     200                frame_free(KA2PA((uintptr_t) ptl2));
    213201#if (PTL1_ENTRIES != 0)
    214202                memsetb(&ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
    215203#else
    216                 if (km_is_non_identity(page))
    217                         return;
    218 
    219204                memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
    220205#endif
    221                 frame_free(KA2PA((uintptr_t) ptl2));
    222206        } else {
    223207                /*
     
    243227                /*
    244228                 * PTL1 is empty.
    245                  * Release the frame and remove PTL1 pointer from the parent
    246                  * table.
    247                  */
    248                 if (km_is_non_identity(page))
    249                         return;
    250 
     229                 * Release the frame and remove PTL1 pointer from preceding table.
     230                 *
     231                 */
     232                frame_free(KA2PA((uintptr_t) ptl1));
    251233                memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
    252                 frame_free(KA2PA((uintptr_t) ptl1));
    253234        }
    254235#endif /* PTL1_ENTRIES != 0 */
Note: See TracChangeset for help on using the changeset viewer.