Changeset ef67bab in mainline


Ignore:
Timestamp:
2006-02-01T00:02:16Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
071a8ae6
Parents:
fc1e4f6
Message:

Memory management work.
Remove the last (i.e. 'root') argument from page_mapping_insert() and page_mapping_find().
Page table address is now extracted from the first (i.e. 'as') argument.
Add a lot of infrastructure to make the above possible.
sparc64 is now broken, most likely because of insufficient identity mapping of physical memory.

Files:
9 added
35 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/Makefile.inc

    rfc1e4f6 ref67bab  
    8888        arch/$(ARCH)/src/bios/bios.c \
    8989        arch/$(ARCH)/src/interrupt.c \
     90        arch/$(ARCH)/src/mm/as.c \
    9091        arch/$(ARCH)/src/mm/frame.c \
    9192        arch/$(ARCH)/src/mm/page.c \
  • arch/amd64/include/mm/as.h

    rfc1e4f6 ref67bab  
    4343#define as_install_arch(as)
    4444
     45extern void as_arch_init(void);
     46
    4547#endif
  • arch/amd64/src/mm/page.c

    rfc1e4f6 ref67bab  
    3939#include <interrupt.h>
    4040
    41 static __address bootstrap_dba;
    42 
    4341void page_arch_init(void)
    4442{
    45         __address dba;
    4643        __address cur;
    4744
     
    4946                page_operations = &page_pt_operations;
    5047       
    51                 dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);
    52                 memsetb(dba, PAGE_SIZE, 0);
    53 
    54                 bootstrap_dba = dba;
    55 
    5648                /*
    5749                 * PA2KA(identity) mapping for all frames.
    5850                 */
    5951                for (cur = 0; cur < last_frame; cur += FRAME_SIZE) {
    60                         page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE | PAGE_EXEC, KA2PA(dba));
     52                        page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE | PAGE_EXEC);
    6153                }
    6254
    6355                exc_register(14, "page_fault", page_fault);
    64                 write_cr3(KA2PA(dba));
     56                write_cr3((__address) AS_KERNEL->page_table);
    6557        }
    6658        else {
    67                 write_cr3(KA2PA(bootstrap_dba));
     59                write_cr3((__address) AS_KERNEL->page_table);
    6860        }
    6961}
  • arch/ia32/Makefile.inc

    rfc1e4f6 ref67bab  
    111111        arch/$(ARCH)/src/userspace.c \
    112112        arch/$(ARCH)/src/cpu/cpu.c \
     113        arch/$(ARCH)/src/mm/as.c \
    113114        arch/$(ARCH)/src/mm/frame.c \
    114115        arch/$(ARCH)/src/mm/memory_init.c \
  • arch/ia32/include/mm/as.h

    rfc1e4f6 ref67bab  
    4343#define as_install_arch(as)
    4444
     45extern void as_arch_init(void);
     46
    4547#endif
  • arch/ia32/src/drivers/ega.c

    rfc1e4f6 ref67bab  
    6060        __u8 hi, lo;
    6161
    62         page_mapping_insert(AS_KERNEL, PA2KA(VIDEORAM), VIDEORAM, PAGE_NOT_CACHEABLE, 0);
     62        page_mapping_insert(AS_KERNEL, PA2KA(VIDEORAM), VIDEORAM, PAGE_NOT_CACHEABLE);
    6363        outb(0x3d4,0xe);
    6464        hi = inb(0x3d5);
  • arch/ia32/src/mm/page.c

    rfc1e4f6 ref67bab  
    4343#include <interrupt.h>
    4444
    45 static __address bootstrap_dba;
    46 
    4745void page_arch_init(void)
    4846{
    49         __address dba;
    5047        __address cur;
    5148
     
    5350                page_operations = &page_pt_operations;
    5451       
    55                 dba = frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);
    56                 memsetb(dba, PAGE_SIZE, 0);
    57 
    58                 bootstrap_dba = dba;
    59                
    6052                /*
    6153                 * PA2KA(identity) mapping for all frames until last_frame.
    6254                 */
    6355                for (cur = 0; cur < last_frame; cur += FRAME_SIZE)
    64                         page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE, KA2PA(dba));
     56                        page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, PAGE_CACHEABLE);
    6557
    6658                exc_register(14, "page_fault", page_fault);
    67                 write_cr3(KA2PA(dba));
     59                write_cr3((__address) AS_KERNEL->page_table);
    6860        }
    6961        else {
    70                 write_cr3(KA2PA(bootstrap_dba));
     62                write_cr3((__address) AS_KERNEL->page_table);
    7163        }
    7264
  • arch/ia32/src/smp/smp.c

    rfc1e4f6 ref67bab  
    6767        if (config.cpu_count > 1) {             
    6868                page_mapping_insert(AS_KERNEL, (__address) l_apic, (__address) l_apic,
    69                                   PAGE_NOT_CACHEABLE, 0);
     69                                  PAGE_NOT_CACHEABLE);
    7070                page_mapping_insert(AS_KERNEL, (__address) io_apic, (__address) io_apic,
    71                                   PAGE_NOT_CACHEABLE, 0);
     71                                  PAGE_NOT_CACHEABLE);
    7272        }
    7373
  • arch/ia64/Makefile.inc

    rfc1e4f6 ref67bab  
    6565        arch/$(ARCH)/src/ivt.S \
    6666        arch/$(ARCH)/src/interrupt.c \
     67        arch/$(ARCH)/src/mm/as.c \
    6768        arch/$(ARCH)/src/mm/frame.c \
    6869        arch/$(ARCH)/src/mm/page.c \
  • arch/ia64/include/mm/as.h

    rfc1e4f6 ref67bab  
    4343#define as_install_arch(as)
    4444
     45extern void as_arch_init(void);
     46
    4547#endif
  • arch/ia64/include/mm/page.h

    rfc1e4f6 ref67bab  
    4444#define PA2KA(x)        ((__address) (x))
    4545
    46 #define GET_PTL0_ADDRESS_ARCH()                 ((pte_t *) 0)
    47 #define SET_PTL0_ADDRESS_ARCH(ptl0)
     46#define SET_PTL0_ADDRESS_ARCH(x)        /**< To be removed as situation permits. */
    4847
    4948/** Implementation of page hash table interface. */
    50 #define HT_ENTRIES_ARCH                                 (VHPT_SIZE/sizeof(pte_t))
     49#define HT_WIDTH_ARCH                                   20      /* 1M */
    5150#define HT_HASH_ARCH(page, asid)                        vhpt_hash((page), (asid))
    5251#define HT_COMPARE_ARCH(page, asid, t)                  vhpt_compare((page), (asid), (t))
  • arch/ia64/src/mm/tlb.c

    rfc1e4f6 ref67bab  
    3434#include <arch/mm/asid.h>
    3535
    36 /** Invalidate all TLB entries.
    37  *
    38  * Because of ASID management, region registers must be reset
    39  * with new RIDs derived from the potentionally new ASID.
    40  */
     36/** Invalidate all TLB entries. */
    4137void tlb_invalidate_all(void)
    4238{
  • arch/mips32/include/mm/as.h

    rfc1e4f6 ref67bab  
    4242#define UDATA_ADDRESS_ARCH      0x01001000
    4343
     44extern void as_arch_init(void);
     45
    4446#endif
  • arch/mips32/src/mm/as.c

    rfc1e4f6 ref67bab  
    2828
    2929#include <arch/mm/as.h>
     30#include <genarch/mm/as_pt.h>
    3031#include <arch/mm/tlb.h>
    3132#include <mm/tlb.h>
     
    3334#include <arch/cp0.h>
    3435#include <arch.h>
     36
     37/** Architecture dependent address space init. */
     38void as_arch_init(void)
     39{
     40        as_operations = &as_pt_operations;
     41}
    3542
    3643/** Install address space.
     
    5764        interrupts_restore(ipl);
    5865}
     66
  • arch/mips32/src/mm/tlb.c

    rfc1e4f6 ref67bab  
    340340         * Check if the mapping exists in page tables.
    341341         */     
    342         pte = page_mapping_find(AS, badvaddr, 0);
     342        pte = page_mapping_find(AS, badvaddr);
    343343        if (pte && pte->lo.v) {
    344344                /*
     
    357357                         * The mapping ought to be in place.
    358358                         */
    359                         pte = page_mapping_find(AS, badvaddr, 0);
     359                        pte = page_mapping_find(AS, badvaddr);
    360360                        ASSERT(pte && pte->lo.v);
    361361                        return pte;
  • arch/ppc32/Makefile.inc

    rfc1e4f6 ref67bab  
    6161        arch/$(ARCH)/src/asm.S \
    6262        arch/$(ARCH)/src/cpu/cpu.c \
     63        arch/$(ARCH)/src/mm/as.c \
    6364        arch/$(ARCH)/src/mm/frame.c \
    6465        arch/$(ARCH)/src/mm/memory_init.c \
  • arch/ppc32/include/mm/as.h

    rfc1e4f6 ref67bab  
    4343#define as_install_arch(as)
    4444
     45extern void as_arch_init(void);
     46
    4547#endif
  • arch/sparc64/Makefile.inc

    rfc1e4f6 ref67bab  
    6565        arch/$(ARCH)/src/context.S \
    6666        arch/$(ARCH)/src/dummy.s \
     67        arch/$(ARCH)/src/mm/as.c \
    6768        arch/$(ARCH)/src/mm/frame.c \
    6869        arch/$(ARCH)/src/mm/page.c \
  • arch/sparc64/include/mm/as.h

    rfc1e4f6 ref67bab  
    4343#define as_install_arch(as)
    4444
     45extern void as_arch_init(void);
     46
    4547#endif
  • arch/sparc64/include/mm/frame.h

    rfc1e4f6 ref67bab  
    3232#include <arch/types.h>
    3333
    34 #define FRAME_SIZE              8192
     34#define FRAME_WIDTH             13
     35#define FRAME_SIZE              (1<<FRAME_WIDTH)
    3536
    3637union frame_address {
  • arch/sparc64/include/mm/page.h

    rfc1e4f6 ref67bab  
    3939#define PA2KA(x)        ((__address) (x))
    4040
    41 #define GET_PTL0_ADDRESS_ARCH()         0
    42 #define SET_PTL0_ADDRESS_ARCH(ptl0)
     41#define SET_PTL0_ADDRESS_ARCH(x)        /**< To be removed as situation permits. */
    4342
    4443/** Implementation of page hash table interface. */
    45 #define HT_ENTRIES_ARCH                 0
     44#define HT_WIDTH_ARCH                   20      /* 1M */
    4645#define HT_HASH_ARCH(page, asid)        0
    4746#define HT_COMPARE_ARCH(page, asid, t)  0
  • genarch/Makefile.inc

    rfc1e4f6 ref67bab  
    4040ifeq ($(CONFIG_PAGE_PT),y)
    4141        GENARCH_SOURCES += \
    42                 genarch/src/mm/page_pt.c
     42                genarch/src/mm/page_pt.c \
     43                genarch/src/mm/as_pt.c
    4344endif
    4445ifeq ($(CONFIG_PAGE_HT),y)
    4546        GENARCH_SOURCES += \
    46                 genarch/src/mm/page_ht.c
     47                genarch/src/mm/page_ht.c \
     48                genarch/src/mm/as_ht.c
    4749endif
    4850ifeq ($(CONFIG_ASID),y)
  • genarch/include/mm/page_ht.h

    rfc1e4f6 ref67bab  
    3939#include <typedefs.h>
    4040
    41 /** Number of slots in page hash table. */
    42 #define HT_ENTRIES                      HT_ENTRIES_ARCH
     41/** Page hash table size. */
     42#define HT_WIDTH                        HT_WIDTH_ARCH
     43#define HT_SIZE                         (1<<HT_WIDTH)
     44#define HT_ENTRIES                      (HT_SIZE/sizeof(pte_t))
    4345
    4446/** Hash function.
     
    100102#define HT_SET_RECORD(t, page, asid, frame, flags)      HT_SET_RECORD_ARCH(t, page, asid, frame, flags)
    101103
    102 
    103104extern page_operations_t page_ht_operations;
    104105extern spinlock_t page_ht_lock;
  • genarch/include/mm/page_pt.h

    rfc1e4f6 ref67bab  
    8888extern page_operations_t page_pt_operations;
    8989
    90 extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags, __address root);
    91 extern pte_t *page_mapping_find_pt(as_t *as, __address page, __address root);
     90extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags);
     91extern pte_t *page_mapping_find_pt(as_t *as, __address page);
    9292
    9393#endif
  • genarch/src/acpi/acpi.c

    rfc1e4f6 ref67bab  
    8080static void map_sdt(struct acpi_sdt_header *sdt)
    8181{
    82         page_mapping_insert(AS_KERNEL, (__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE, 0);
     82        page_mapping_insert(AS_KERNEL, (__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE);
    8383        map_structure((__address) sdt, sdt->length);
    8484}
  • genarch/src/mm/page_ht.c

    rfc1e4f6 ref67bab  
    3939#include <arch.h>
    4040#include <debug.h>
     41#include <memstr.h>
    4142
    4243/**
    43  * This lock protects the page hash table. Note that software must
    44  * be still careful about ordering of writes to ensure consistent
    45  * view of the page hash table for hardware helpers such as VHPT
    46  * walker on ia64.
     44 * This lock protects the page hash table.
    4745 */
    4846SPINLOCK_INITIALIZE(page_ht_lock);
     
    5452pte_t *page_ht = NULL;
    5553
    56 static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root);
    57 static pte_t *ht_mapping_find(as_t *as, __address page, __address root);
     54static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags);
     55static pte_t *ht_mapping_find(as_t *as, __address page);
    5856
    5957page_operations_t page_ht_operations = {
    6058        .mapping_insert = ht_mapping_insert,
    61         .mapping_find = ht_mapping_find
     59        .mapping_find = ht_mapping_find,
    6260};
    6361
     
    6563 *
    6664 * Map virtual address 'page' to physical address 'frame'
    67  * using 'flags'. In order not to disturb hardware searching,
    68  * new mappings are appended to the end of the collision
    69  * chain.
     65 * using 'flags'.
    7066 *
    71  * @param as Address space to which page belongs. Must be locked prior the call.
     67 * The address space must be locked and interruptsmust be disabled.
     68 *
     69 * @param as Address space to which page belongs.
    7270 * @param page Virtual address of the page to be mapped.
    7371 * @param frame Physical address of memory frame to which the mapping is done.
    7472 * @param flags Flags to be used for mapping.
    75  * @param root Ignored.
    7673 */
    77 void ht_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root)
     74void ht_mapping_insert(as_t *as, __address page, __address frame, int flags)
    7875{
    7976        pte_t *t, *u;
     
    122119 * Find mapping for virtual page.
    123120 *
    124  * Interrupts must be disabled.
     121 * The address space must be locked and interrupts must be disabled.
    125122 *
    126  * @param as Address space to wich page belongs. Must be locked prior the call.
     123 * @param as Address space to wich page belongs.
    127124 * @param page Virtual page.
    128  * @param root Ignored.
    129125 *
    130126 * @return NULL if there is no such mapping; requested mapping otherwise.
    131127 */
    132 pte_t *ht_mapping_find(as_t *as, __address page, __address root)
     128pte_t *ht_mapping_find(as_t *as, __address page)
    133129{
    134130        pte_t *t;
  • genarch/src/mm/page_pt.c

    rfc1e4f6 ref67bab  
    3030#include <mm/page.h>
    3131#include <mm/frame.h>
     32#include <mm/as.h>
    3233#include <arch/mm/page.h>
    3334#include <arch/mm/as.h>
     
    3738#include <memstr.h>
    3839
    39 static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root);
    40 static pte_t *pt_mapping_find(as_t *as, __address page, __address root);
     40static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags);
     41static pte_t *pt_mapping_find(as_t *as, __address page);
    4142
    4243page_operations_t page_pt_operations = {
     
    5051 * using 'flags'.
    5152 *
    52  * @param as Ignored.
     53 * The address space must be locked and interrupts must be disabled.
     54 *
     55 * @param as Address space to wich page belongs.
    5356 * @param page Virtual address of the page to be mapped.
    5457 * @param frame Physical address of memory frame to which the mapping is done.
    5558 * @param flags Flags to be used for mapping.
    56  * @param root Explicit PTL0 address.
    5759 */
    58 void pt_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root)
     60void pt_mapping_insert(as_t *as, __address page, __address frame, int flags)
    5961{
    6062        pte_t *ptl0, *ptl1, *ptl2, *ptl3;
    6163        __address newpt;
    6264
    63         ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
     65        ptl0 = (pte_t *) PA2KA((__address) as->page_table);
    6466
    6567        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
     
    98100 * Find mapping for virtual page.
    99101 *
    100  * @param as Ignored.
     102 * The address space must be locked and interrupts must be disabled.
     103 *
     104 * @param as Address space to which page belongs.
    101105 * @param page Virtual page.
    102  * @param root PTL0 address if non-zero.
    103106 *
    104107 * @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
    105108 */
    106 pte_t *pt_mapping_find(as_t *as, __address page, __address root)
     109pte_t *pt_mapping_find(as_t *as, __address page)
    107110{
    108111        pte_t *ptl0, *ptl1, *ptl2, *ptl3;
    109112
    110         ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS());
     113        ptl0 = (pte_t *) PA2KA((__address) as->page_table);
    111114
    112115        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
  • generic/include/mm/as.h

    rfc1e4f6 ref67bab  
    8181        SPINLOCK_DECLARE(lock);
    8282        link_t as_area_head;
    83         pte_t *ptl0;
    84         asid_t asid;                    /**< Address space identifier. */
     83
     84        /** Page table pointer. Constant on architectures that use global page hash table. */
     85        pte_t *page_table;
     86
     87        /** Address space identifier. Constant on architectures that do not support ASIDs.*/
     88        asid_t asid;
    8589};
    8690
     91struct as_operations {
     92        pte_t *(* page_table_create)(int flags);
     93};
     94typedef struct as_operations as_operations_t;
     95
    8796extern as_t *AS_KERNEL;
     97extern as_operations_t *as_operations;
    8898
    89 extern as_t *as_create(pte_t *ptl0, int flags);
     99extern void as_init(void);
     100extern as_t *as_create(int flags);
    90101extern as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base);
    91102extern void as_set_mapping(as_t *as, __address page, __address frame);
  • generic/include/mm/buddy.h

    rfc1e4f6 ref67bab  
    5858extern void buddy_system_structure_print(buddy_system_t *b, size_t elem_size);
    5959
    60 
    6160#endif
  • generic/include/mm/page.h

    rfc1e4f6 ref67bab  
    6262/** Operations to manipulate page mappings. */
    6363struct page_operations {
    64         void (* mapping_insert)(as_t *as, __address page, __address frame, int flags, __address root);
    65         pte_t *(* mapping_find)(as_t *as, __address page, __address root);
     64        void (* mapping_insert)(as_t *as, __address page, __address frame, int flags);
     65        pte_t *(* mapping_find)(as_t *as, __address page);
    6666};
    6767typedef struct page_operations page_operations_t;
     
    7070
    7171extern void page_init(void);
    72 extern void page_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root);
    73 extern pte_t *page_mapping_find(as_t *as, __address page, __address root);
     72extern void page_mapping_insert(as_t *as, __address page, __address frame, int flags);
     73extern pte_t *page_mapping_find(as_t *as, __address page);
     74extern pte_t *page_table_create(int flags);
    7475extern void map_structure(__address s, size_t size);
    7576
  • generic/src/main/kinit.c

    rfc1e4f6 ref67bab  
    148148                        panic("config.init_addr is not frame aligned");
    149149               
    150                 as = as_create(NULL, 0);
     150                as = as_create(0);
    151151                if (!as)
    152152                        panic("as_create\n");
     
    159159               
    160160                /*
    161                  * Create the text as_area and copy the userspace code there.
     161                 * Create the text as_area and initialize its mapping.
    162162                 */
    163163               
     
    170170                if (!a)
    171171                        panic("as_area_create: text\n");
    172                
     172
     173                for (i = 0; i < frames; i++)
     174                        as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE);
     175
    173176                /*
    174177                 * Create the data as_area.
     
    178181                        panic("as_area_create: stack\n");
    179182
    180                 /*
    181                  * Initialize text area mapping.
    182                  */
    183                 for (i = 0; i < frames; i++)
    184                         as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE);
    185 
    186        
    187183                thread_ready(t);
    188184        }
  • generic/src/main/main.c

    rfc1e4f6 ref67bab  
    139139void main_bsp_separated_stack(void)
    140140{
    141         as_t *as;
    142141        task_t *k;
    143142        thread_t *t;
     
    152151        kconsole_init();
    153152
    154         /* Exception handler initialization, before architecture
     153        /*
     154         * Exception handler initialization, before architecture
    155155         * starts adding its own handlers
    156156         */
     
    163163        early_heap_init(config.heap_addr, config.heap_size + config.heap_delta);
    164164        frame_init();
     165        as_init();
    165166        page_init();
    166167        tlb_init();
     
    190191
    191192        /*
    192          * Create kernel address space.
    193          */
    194         as = as_create(GET_PTL0_ADDRESS(), FLAG_AS_KERNEL);
    195         if (!as)
    196                 panic("can't create kernel address space\n");
    197 
    198         /*
    199193         * Create kernel task.
    200194         */
    201         k = task_create(as);
     195        k = task_create(AS_KERNEL);
    202196        if (!k)
    203197                panic("can't create kernel task\n");
  • generic/src/mm/as.c

    rfc1e4f6 ref67bab  
    3434
    3535#include <mm/as.h>
    36 #include <mm/asid.h>
     36#include <arch/mm/as.h>
    3737#include <mm/page.h>
    3838#include <mm/frame.h>
     
    4343#include <mm/asid.h>
    4444#include <arch/mm/asid.h>
    45 #include <arch/mm/as.h>
    4645#include <arch/types.h>
    4746#include <typedefs.h>
     
    5655#include <print.h>
    5756
    58 #define KAS_START_INDEX         PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)
    59 #define KAS_END_INDEX           PTL0_INDEX(KERNEL_ADDRESS_SPACE_END)
    60 #define KAS_INDICES             (1+(KAS_END_INDEX-KAS_START_INDEX))
     57as_operations_t *as_operations = NULL;
    6158
    6259static int get_area_flags(as_area_t *a);
    6360
     61/** Initialize address space subsystem. */
     62void as_init(void)
     63{
     64        as_arch_init();
     65        AS_KERNEL = as_create(FLAG_AS_KERNEL);
     66        if (!AS_KERNEL)
     67                panic("can't create kernel address space\n");
     68}
     69
    6470/** Create address space. */
    65 /*
    66  * FIXME: this interface must be meaningful for all possible VAT
    67  *        (Virtual Address Translation) mechanisms.
    68  */
    69 as_t *as_create(pte_t *ptl0, int flags)
     71as_t *as_create(int flags)
    7072{
    7173        as_t *as;
     
    8284                        as->asid = ASID_INVALID;
    8385
    84                 as->ptl0 = ptl0;
    85                 if (!as->ptl0) {
    86                         pte_t *src_ptl0, *dst_ptl0;
    87                
    88                         src_ptl0 = (pte_t *) PA2KA((__address) GET_PTL0_ADDRESS());
    89                         dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);
    90 
    91 //                      memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
    92 //                      memcpy((void *) &dst_ptl0[KAS_START_INDEX], (void *) &src_ptl0[KAS_START_INDEX], KAS_INDICES);
    93                        
    94                         memcpy((void *) dst_ptl0,(void *) src_ptl0, PAGE_SIZE);
    95 
    96                         as->ptl0 = (pte_t *) KA2PA((__address) dst_ptl0);
    97                 }
     86                as->page_table = page_table_create(flags);
    9887        }
    9988
     
    187176         */
    188177       
    189         page_mapping_insert(as, page, frame, get_area_flags(area), (__address) as->ptl0);
     178        page_mapping_insert(as, page, frame, get_area_flags(area));
    190179       
    191180        spinlock_unlock(&area->lock);
     
    267256         * inserted into page tables.
    268257         */
    269         page_mapping_insert(AS, page, frame, get_area_flags(area), (__address) AS->ptl0);
     258        page_mapping_insert(AS, page, frame, get_area_flags(area));
    270259       
    271260        spinlock_unlock(&area->lock);
     
    287276        ipl = interrupts_disable();
    288277        spinlock_lock(&as->lock);
    289         ASSERT(as->ptl0);
    290         SET_PTL0_ADDRESS(as->ptl0);
     278        ASSERT(as->page_table);
     279        SET_PTL0_ADDRESS(as->page_table);
    291280        spinlock_unlock(&as->lock);
    292281        interrupts_restore(ipl);
     
    328317        return flags;
    329318}
     319
     320/** Create page table.
     321 *
     322 * Depending on architecture, create either address space
     323 * private or global page table.
     324 *
     325 * @param flags Flags saying whether the page table is for kernel address space.
     326 *
     327 * @return First entry of the page table.
     328 */
     329pte_t *page_table_create(int flags)
     330{
     331        ASSERT(as_operations);
     332        ASSERT(as_operations->page_table_create);
     333
     334        return as_operations->page_table_create(flags);
     335}
  • generic/src/mm/page.c

    rfc1e4f6 ref67bab  
    4949{
    5050        page_arch_init();
    51         page_mapping_insert(AS_KERNEL, 0x0, 0x0, PAGE_NOT_PRESENT, 0);
    5251}
    5352
     
    6968
    7069        for (i = 0; i < cnt; i++)
    71                 page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE, 0);
     70                page_mapping_insert(AS_KERNEL, s + i*PAGE_SIZE, s + i*PAGE_SIZE, PAGE_NOT_CACHEABLE);
    7271
    7372}
     
    7877 * using 'flags'. Allocate and setup any missing page tables.
    7978 *
    80  * @param as Address space to wich page belongs. Must be locked prior the call.
     79 * The address space must be locked and interrupts must be disabled.
     80 *
     81 * @param as Address space to wich page belongs..
    8182 * @param page Virtual address of the page to be mapped.
    8283 * @param frame Physical address of memory frame to which the mapping is done.
    8384 * @param flags Flags to be used for mapping.
    84  * @param root Explicit PTL0 address.
    8585 */
    86 void page_mapping_insert(as_t *as, __address page, __address frame, int flags, __address root)
     86void page_mapping_insert(as_t *as, __address page, __address frame, int flags)
    8787{
    8888        ASSERT(page_operations);
    8989        ASSERT(page_operations->mapping_insert);
    9090       
    91         page_operations->mapping_insert(as, page, frame, flags, root);
     91        page_operations->mapping_insert(as, page, frame, flags);
    9292}
    9393
     
    9696 * Find mapping for virtual page.
    9797 *
    98  * @param as Address space to wich page belongs must be locked prior the call.
     98 * The address space must be locked and interrupts must be disabled.
     99 *
     100 * @param as Address space to wich page belongs.
    99101 * @param page Virtual page.
    100  * @param root PTL0 address if non-zero.
    101102 *
    102103 * @return NULL if there is no such mapping; requested mapping otherwise.
    103104 */
    104 pte_t *page_mapping_find(as_t *as, __address page, __address root)
     105pte_t *page_mapping_find(as_t *as, __address page)
    105106{
    106107        ASSERT(page_operations);
    107108        ASSERT(page_operations->mapping_find);
    108109
    109         return page_operations->mapping_find(as, page, root);
     110        return page_operations->mapping_find(as, page);
    110111}
  • test/mm/mapping1/test.c

    rfc1e4f6 ref67bab  
    5757       
    5858        printf("Mapping virtual address %P to physical address %P.\n", PAGE0, KA2PA(frame0));
    59         page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE, 0);
     59        page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
    6060        printf("Mapping virtual address %P to physical address %P.\n", PAGE1, KA2PA(frame1));   
    61         page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE, 0);
     61        page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
    6262       
    6363        printf("Value at virtual address %P is %L.\n", PAGE0, v0 = *((__u32 *) PAGE0));
Note: See TracChangeset for help on using the changeset viewer.