Changeset 6d7ffa65 in mainline for generic


Ignore:
Timestamp:
2006-01-08T15:03:41Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1a67595
Parents:
566ba81
Message:

Memory management work.
Move generic 4-level page table interface to genarch
and enable architectures to use different virtual memory
mechanisms (e.g. page hash tables).
Start page hash table support.
Switch ia64 and sparc64 to page hash tables.
Other architectures keep on using 4-level page table interface.

Location:
generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • generic/include/mm/page.h

    r566ba81 r6d7ffa65  
    5656#define PAGE_EXEC               (1<<PAGE_EXEC_SHIFT)
    5757
    58 /*
    59  * This is the generic 4-level page table interface.
    60  * Architectures are supposed to implement *_ARCH macros.
    61  */
     58struct page_operations {
     59        void (* mapping_insert)(__address page, __address frame, int flags, __address root);
     60        pte_t *(* mapping_find)(__address page, __address root);
     61};
     62typedef struct page_operations page_operations_t;
    6263
    63 /*
    64  * These macros process vaddr and extract those portions
    65  * of it that function as indices to respective page tables.
    66  */
    67 #define PTL0_INDEX(vaddr)               PTL0_INDEX_ARCH(vaddr)
    68 #define PTL1_INDEX(vaddr)               PTL1_INDEX_ARCH(vaddr)
    69 #define PTL2_INDEX(vaddr)               PTL2_INDEX_ARCH(vaddr)
    70 #define PTL3_INDEX(vaddr)               PTL3_INDEX_ARCH(vaddr)
    71 
    72 #define GET_PTL0_ADDRESS()              GET_PTL0_ADDRESS_ARCH()
    73 #define SET_PTL0_ADDRESS(ptl0)          SET_PTL0_ADDRESS_ARCH(ptl0)
    74 
    75 /*
    76  * These macros traverse the 4-level tree of page tables,
    77  * each descending by one level.
    78  */
    79 #define GET_PTL1_ADDRESS(ptl0, i)       GET_PTL1_ADDRESS_ARCH(ptl0, i)
    80 #define GET_PTL2_ADDRESS(ptl1, i)       GET_PTL2_ADDRESS_ARCH(ptl1, i)
    81 #define GET_PTL3_ADDRESS(ptl2, i)       GET_PTL3_ADDRESS_ARCH(ptl2, i)
    82 #define GET_FRAME_ADDRESS(ptl3, i)      GET_FRAME_ADDRESS_ARCH(ptl3, i)
    83 
    84 /*
    85  * These macros are provided to change shape of the 4-level
    86  * tree of page tables on respective level.
    87  */
    88 #define SET_PTL1_ADDRESS(ptl0, i, a)    SET_PTL1_ADDRESS_ARCH(ptl0, i, a)
    89 #define SET_PTL2_ADDRESS(ptl1, i, a)    SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
    90 #define SET_PTL3_ADDRESS(ptl2, i, a)    SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
    91 #define SET_FRAME_ADDRESS(ptl3, i, a)   SET_FRAME_ADDRESS_ARCH(ptl3, i, a)
    92 
    93 /*
    94  * These macros are provided to query various flags within the page tables.
    95  */
    96 #define GET_PTL1_FLAGS(ptl0, i)         GET_PTL1_FLAGS_ARCH(ptl0, i)
    97 #define GET_PTL2_FLAGS(ptl1, i)         GET_PTL2_FLAGS_ARCH(ptl1, i)
    98 #define GET_PTL3_FLAGS(ptl2, i)         GET_PTL3_FLAGS_ARCH(ptl2, i)
    99 #define GET_FRAME_FLAGS(ptl3, i)        GET_FRAME_FLAGS_ARCH(ptl3, i)
    100 
    101 /*
    102  * These macros are provided to set/clear various flags within the page tables.
    103  */
    104 #define SET_PTL1_FLAGS(ptl0, i, x)      SET_PTL1_FLAGS_ARCH(ptl0, i, x)
    105 #define SET_PTL2_FLAGS(ptl1, i, x)      SET_PTL2_FLAGS_ARCH(ptl1, i, x)
    106 #define SET_PTL3_FLAGS(ptl2, i, x)      SET_PTL3_FLAGS_ARCH(ptl2, i, x)
    107 #define SET_FRAME_FLAGS(ptl3, i, x)     SET_FRAME_FLAGS_ARCH(ptl3, i, x)
     64extern page_operations_t *page_operations;
    10865
    10966extern void page_init(void);
  • generic/src/main/main.c

    r566ba81 r6d7ffa65  
    4747#include <mm/frame.h>
    4848#include <mm/page.h>
     49#include <genarch/mm/page_pt.h>
    4950#include <mm/tlb.h>
    5051#include <mm/vm.h>
  • generic/src/mm/page.c

    r566ba81 r6d7ffa65  
    3434#include <arch/asm.h>
    3535#include <memstr.h>
     36#include <debug.h>
     37
     38/** Virtual operations for page subsystem. */
     39page_operations_t *page_operations = NULL;
    3640
    3741void page_init(void)
     
    7478void page_mapping_insert(__address page, __address frame, int flags, __address root)
    7579{
    76         pte_t *ptl0, *ptl1, *ptl2, *ptl3;
    77         __address newpt;
    78 
    79         ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
    80 
    81         if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
    82                 newpt = frame_alloc(FRAME_KA, ONE_FRAME);
    83                 memsetb(newpt, PAGE_SIZE, 0);
    84                 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
    85                 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    86         }
    87 
    88         ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
    89 
    90         if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
    91                 newpt = frame_alloc(FRAME_KA, ONE_FRAME);
    92                 memsetb(newpt, PAGE_SIZE, 0);
    93                 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
    94                 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    95         }
    96 
    97         ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
    98 
    99         if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
    100                 newpt = frame_alloc(FRAME_KA, ONE_FRAME);
    101                 memsetb(newpt, PAGE_SIZE, 0);
    102                 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
    103                 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
    104         }
    105 
    106         ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
    107 
    108         SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
    109         SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags);
     80        ASSERT(page_operations);
     81        ASSERT(page_operations->mapping_insert);
     82       
     83        page_operations->mapping_insert(page, frame, flags, root);
    11084}
    11185
     
    12195pte_t *page_mapping_find(__address page, __address root)
    12296{
    123         pte_t *ptl0, *ptl1, *ptl2, *ptl3;
     97        ASSERT(page_operations);
     98        ASSERT(page_operations->mapping_find);
    12499
    125         ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
    126 
    127         if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
    128                 return NULL;
    129 
    130         ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
    131 
    132         if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
    133                 return NULL;
    134 
    135         ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
    136 
    137         if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
    138                 return NULL;
    139 
    140         ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
    141 
    142         return &ptl3[PTL3_INDEX(page)];
     100        return page_operations->mapping_find(page, root);
    143101}
  • generic/src/mm/vm.c

    r566ba81 r6d7ffa65  
    3333#include <mm/heap.h>
    3434#include <arch/mm/page.h>
     35#include <genarch/mm/page_pt.h>
    3536#include <arch/mm/asid.h>
    3637#include <arch/mm/vm.h>
Note: See TracChangeset for help on using the changeset viewer.