Changeset ef67bab in mainline for generic/src/mm/as.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.