Changeset 6d7ffa65 in mainline


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.

Files:
5 added
17 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/Makefile.inc

    r566ba81 r6d7ffa65  
    5959CONFIG_ACPI = y
    6060
     61## Compile with hierarchical page tables support.
     62#
     63
     64CONFIG_PAGE_PT = y
     65
    6166## Accepted configuration directives
    6267#
  • arch/amd64/src/mm/page.c

    r566ba81 r6d7ffa65  
    2828
    2929#include <arch/mm/page.h>
     30#include <genarch/mm/page_pt.h>
    3031#include <arch/mm/frame.h>
    3132#include <mm/page.h>
     
    4546
    4647        if (config.cpu_active == 1) {
     48                page_operations = &page_pt_operations;
     49       
    4750                dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME);
    4851                memsetb(dba, PAGE_SIZE, 0);
  • arch/ia32/Makefile.inc

    r566ba81 r6d7ffa65  
    7878CONFIG_ACPI = y
    7979
     80## Compile with hierarchical page tables support.
     81#
     82
     83CONFIG_PAGE_PT = y
     84
    8085## Accepted configuration directives
    8186#
  • arch/ia32/src/mm/page.c

    r566ba81 r6d7ffa65  
    2828
    2929#include <arch/mm/page.h>
     30#include <genarch/mm/page_pt.h>
    3031#include <arch/mm/frame.h>
    3132#include <mm/frame.h>
     
    4950
    5051        if (config.cpu_active == 1) {
     52                page_operations = &page_pt_operations;
     53       
    5154                dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME);
    5255                memsetb(dba, PAGE_SIZE, 0);
  • arch/ia64/Makefile.inc

    r566ba81 r6d7ffa65  
    4343AFLAGS += -mconstant-gp
    4444
     45## Compile with page hash table support.
     46#
     47
     48CONFIG_PAGE_HT = y
     49
    4550ARCH_SOURCES = \
    4651        arch/$(ARCH)/src/start.S \
     
    5560        arch/$(ARCH)/src/interrupt.c \
    5661        arch/$(ARCH)/src/mm/frame.c \
     62        arch/$(ARCH)/src/mm/page.c \
    5763        arch/$(ARCH)/src/drivers/it.c
  • arch/ia64/include/mm/page.h

    r566ba81 r6d7ffa65  
    3838#define PA2KA(x)        ((__address) (x))
    3939
    40 #define page_arch_init()        ;
    41 
    4240/*
    4341 * Implementation of generic 4-level page table interface.
     
    7169#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)
    7270
     71extern void page_arch_init(void);
     72
    7373#endif
  • arch/mips32/Makefile.inc

    r566ba81 r6d7ffa65  
    4646CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss
    4747DEFS += -DMACHINE=${MIPS_MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS} -DINIT_ADDRESS=${INIT_ADDRESS} -DINIT_SIZE=${INIT_SIZE}
     48
     49## Compile with hierarchical page tables support.
     50#
     51
     52CONFIG_PAGE_PT = y
     53
    4854
    4955## Accepted MACHINEs
  • arch/mips32/src/mm/page.c

    r566ba81 r6d7ffa65  
    2727 */
    2828
    29 #include <arch/types.h>
    3029#include <arch/mm/page.h>
     30#include <genarch/mm/page_pt.h>
    3131#include <arch/mm/frame.h>
    3232#include <mm/frame.h>
    3333#include <mm/page.h>
     34#include <arch/types.h>
    3435#include <memstr.h>
    3536
     
    3940{
    4041        __address ptl0;
     42
     43        page_operations = &page_pt_operations;
    4144       
    4245        ptl0 = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME);
  • arch/ppc32/Makefile.inc

    r566ba81 r6d7ffa65  
    4646CONFIG_OFW = y
    4747
     48## Compile with hierarchical page tables support.
     49#
     50
     51CONFIG_PAGE_PT = y
     52
    4853ARCH_SOURCES = \
    4954        arch/$(ARCH)/src/console.c \
  • arch/ppc32/src/mm/page.c

    r566ba81 r6d7ffa65  
    2727 */
    2828
    29 #include <arch/types.h>
    3029#include <arch/mm/page.h>
     30#include <genarch/mm/page_pt.h>
    3131#include <arch/mm/frame.h>
    3232#include <mm/frame.h>
    3333#include <mm/page.h>
     34#include <arch/types.h>
    3435
    3536void page_arch_init(void)
    3637{
     38        page_operations = &page_pt_operations;
    3739}
  • arch/sparc64/Makefile.inc

    r566ba81 r6d7ffa65  
    4747CONFIG_OFW = y
    4848
     49## Compile with page hash table support.
     50#
     51
     52CONFIG_PAGE_HT = y
     53
    4954ARCH_SOURCES = \
    5055        arch/$(ARCH)/src/cpu/cpu.c \
  • arch/sparc64/src/mm/page.c

    r566ba81 r6d7ffa65  
    2828
    2929#include <arch/mm/page.h>
     30#include <genarch/mm/page_ht.h>
    3031
    3132void page_arch_init(void)
    3233{
     34        page_operations = &page_ht_operations;
    3335}
  • genarch/Makefile.inc

    r566ba81 r6d7ffa65  
    3838                genarch/src/acpi/matd.c
    3939endif
     40ifeq ($(CONFIG_PAGE_PT),y)
     41        GENARCH_SOURCES += \
     42                genarch/src/mm/page_pt.c
     43endif
     44ifeq ($(CONFIG_PAGE_HT),y)
     45        GENARCH_SOURCES += \
     46                genarch/src/mm/page_ht.c
     47endif
  • 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.