Changeset b07769b6 in mainline


Ignore:
Timestamp:
2005-08-19T13:12:32Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4a61ef
Parents:
6a4177a
Message:

Switch over to per vm_t page tables. (breaks ia32 userspace)

Define dummy memcopy() for amd64 and ppc to satisfy compiler.

Get rid of problematic #include <arch/mm/page.h> in mm/page.h.

Indentation fixes and small changes here and there.

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/src/dummy.s

    r6a4177a rb07769b6  
    2929.text
    3030
     31.global memcopy
    3132.global cpu_priority_high
    3233.global cpu_priority_low
     
    5455.global dummy
    5556
     57memcopy:
    5658cpu_priority_high:
    5759cpu_priority_low:
  • arch/ia32/src/drivers/ega.c

    r6a4177a rb07769b6  
    3030#include <putchar.h>
    3131#include <mm/page.h>
     32#include <arch/mm/page.h>
    3233#include <synch/spinlock.h>
    3334#include <arch/types.h>
  • arch/ia32/src/mm/page.c

    r6a4177a rb07769b6  
    3737#include <synch/spinlock.h>
    3838#include <debug.h>
    39 
    40 /*
    41  * Note.
    42  * This is the preliminary code for controlling paging mechanism on ia32. It is
    43  * needed by other parts of the kernel for its ability to map virtual addresses
    44  * to physical. SMP code relies on this feature. Other than that, this code is
    45  * by no means meant to implement virtual memory in terms of swapping pages in
    46  * and out.
    47  */
    4839
    4940__address bootstrap_dba;
  • arch/ia32/src/pm.c

    r6a4177a rb07769b6  
    3535#include <arch/context.h>
    3636#include <panic.h>
     37#include <arch/mm/page.h>
    3738
    3839/*
     
    132133static void clean_IOPL_NT_flags(void)
    133134{
    134   asm
     135        asm
    135136        (
    136     "pushfl;"
     137                "pushfl;"
    137138                "pop %%eax;"
    138139                "and $0xffff8fff,%%eax;"
     
    148149static void clean_AM_flag(void)
    149150{
    150   asm
     151        asm
    151152        (
    152     "mov %%cr0,%%eax;"
     153                "mov %%cr0,%%eax;"
    153154                "and $0xFFFBFFFF,%%eax;"
    154155                "mov %%eax,%%cr0;"
     
    158159        );
    159160}
    160 
    161 
    162 
    163 
    164161
    165162void pm_init(void)
  • arch/ia32/src/proc/scheduler.c

    r6a4177a rb07769b6  
    3535{
    3636        CPU->arch.tss->esp0 = (__address) &THREAD->kstack[THREAD_STACK_SIZE-8];
    37         CPU->arch.tss->ss0 = selector(KDATA_DES);       
     37        CPU->arch.tss->ss0 = selector(KDATA_DES);
    3838}
  • arch/ppc/src/dummy.s

    r6a4177a rb07769b6  
    2929.text
    3030
     31.global memcopy
    3132.global cpu_priority_high
    3233.global cpu_priority_low
     
    5152.global dummy
    5253
     54memcopy:
    5355cpu_priority_high:
    5456cpu_priority_low:
  • include/mm/page.h

    r6a4177a rb07769b6  
    107107#define SET_FRAME_FLAGS(ptl3, i, x)     SET_FRAME_FLAGS_ARCH(ptl3, i, x)
    108108
    109 #include <arch/mm/page.h>
    110 
    111109extern void page_init(void);
    112110extern void map_page_to_frame(__address page, __address frame, int flags, __address root);
  • include/mm/vm.h

    r6a4177a rb07769b6  
    7777};
    7878
    79 extern vm_t * vm_create(void);
     79extern vm_t * vm_create(pte_t *ptl0);
    8080extern void vm_destroy(vm_t *m);
    8181
     
    8383extern void vm_area_destroy(vm_area_t *a);
    8484
    85 extern void vm_area_map(vm_area_t *a);
    86 extern void vm_area_unmap(vm_area_t *a);
     85extern void vm_area_map(vm_area_t *a, vm_t *m);
     86extern void vm_area_unmap(vm_area_t *a, vm_t *m);
    8787
    8888extern void vm_install(vm_t *m);
  • src/main/kinit.c

    r6a4177a rb07769b6  
    119119         * Create the first user task.
    120120         */
    121         m = vm_create();
     121        m = vm_create(NULL);
    122122        if (!m) panic("vm_create");
    123123        u = task_create(m);
     
    131131        a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS);
    132132        if (!a) panic("vm_area_create: vm_text");
     133        vm_area_map(a, m);
    133134        memcopy((__address) utext, PA2KA(a->mapping[0]), utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
    134135
     
    138139        a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS);
    139140        if (!a) panic("vm_area_create: vm_stack");
     141        vm_area_map(a, m);     
    140142       
    141143        thread_ready(t);
  • src/main/main.c

    r6a4177a rb07769b6  
    150150         * Create kernel vm mapping.
    151151         */
    152         m = vm_create();
     152        m = vm_create(GET_PTL0_ADDRESS());
    153153        if (!m) panic("can't create kernel vm address space\n");
    154154
  • src/mm/vm.c

    r6a4177a rb07769b6  
    4040#include <panic.h>
    4141#include <arch/asm.h>
     42#include <debug.h>
    4243
    43 vm_t *vm_create(void)
     44#define KAS_START_INDEX         PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)
     45#define KAS_END_INDEX           PTL0_INDEX(KERNEL_ADDRESS_SPACE_END)
     46#define KAS_INDICES             (1+(KAS_END_INDEX-KAS_START_INDEX))
     47
     48vm_t *vm_create(pte_t *ptl0)
    4449{
    4550        vm_t *m;
     
    4954                spinlock_initialize(&m->lock);
    5055                list_initialize(&m->vm_area_head);
    51                 m->ptl0 = NULL;
     56
     57                /*
     58                 * Each vm_t is supposed to have its own page table.
     59                 * It is either passed one or it has to allocate and set one up.
     60                 */
     61                if (!(m->ptl0 = ptl0)) {
     62                        pte_t *src_ptl0, *dst_ptl0;
     63               
     64                        src_ptl0 = (pte_t *) PA2KA(GET_PTL0_ADDRESS());
     65                        dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC);
     66                        memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
     67                        memcopy((__address) &src_ptl0[KAS_START_INDEX], (__address) &dst_ptl0[KAS_START_INDEX], KAS_INDICES*sizeof(pte_t));
     68                        m->ptl0 = (pte_t *) KA2PA(dst_ptl0);
     69                }
    5270        }
    5371       
     
    110128}
    111129
    112 void vm_area_map(vm_area_t *a)
     130void vm_area_map(vm_area_t *a, vm_t *m)
    113131{
    114132        int i, flags;
     
    116134       
    117135        pri = cpu_priority_high();
     136        spinlock_lock(&m->lock);
    118137        spinlock_lock(&a->lock);
    119138
     
    127146                        break;
    128147                default:
    129                         panic("unexpected vm_type_t %d", a->type); 
     148                        panic("unexpected vm_type_t %d", a->type);
    130149        }
    131        
     150
     151        ASSERT(m->ptl0);
    132152        for (i=0; i<a->size; i++)
    133                 map_page_to_frame(a->address + i*PAGE_SIZE, a->mapping[i], flags, 0);
     153                map_page_to_frame(a->address + i*PAGE_SIZE, a->mapping[i], flags, (__address) m->ptl0);
    134154               
    135155        spinlock_unlock(&a->lock);
     156        spinlock_unlock(&m->lock);
    136157        cpu_priority_restore(pri);
    137158}
    138159
    139 void vm_area_unmap(vm_area_t *a)
     160void vm_area_unmap(vm_area_t *a, vm_t *m)
    140161{
    141162        int i;
     
    143164       
    144165        pri = cpu_priority_high();
     166        spinlock_lock(&m->lock);
    145167        spinlock_lock(&a->lock);
    146168
     169        ASSERT(m->ptl0);
    147170        for (i=0; i<a->size; i++)               
    148                 map_page_to_frame(a->address + i*PAGE_SIZE, 0, PAGE_NOT_PRESENT, 0);
     171                map_page_to_frame(a->address + i*PAGE_SIZE, 0, PAGE_NOT_PRESENT, (__address) m->ptl0);
    149172       
    150173        spinlock_unlock(&a->lock);
     174        spinlock_unlock(&m->lock);
    151175        cpu_priority_restore(pri);
    152176}
     
    158182       
    159183        pri = cpu_priority_high();
     184
     185        tlb_shootdown_start();
    160186        spinlock_lock(&m->lock);
    161187
    162         for(l = m->vm_area_head.next; l != &m->vm_area_head; l = l->next)
    163                 vm_area_map(list_get_instance(l, vm_area_t, link));
     188        ASSERT(m->ptl0);
     189        SET_PTL0_ADDRESS(m->ptl0);
    164190
    165191        spinlock_unlock(&m->lock);
    166         cpu_priority_restore(pri);
    167 }
    168 
    169 void vm_uninstall(vm_t *m)
    170 {
    171         link_t *l;
    172         pri_t pri;
    173        
    174         pri = cpu_priority_high();
    175 
    176         tlb_shootdown_start();
    177 
    178         spinlock_lock(&m->lock);
    179 
    180         for(l = m->vm_area_head.next; l != &m->vm_area_head; l = l->next)
    181                 vm_area_unmap(list_get_instance(l, vm_area_t, link));
    182 
    183         spinlock_unlock(&m->lock);
    184 
    185192        tlb_shootdown_finalize();
    186193
  • src/proc/scheduler.c

    r6a4177a rb07769b6  
    381381                         * Replace the old one with the new one.
    382382                         */
    383                         if (m1) {
    384                                 vm_uninstall(m1);
    385                         }
    386383                        vm_install(m2);
    387384                }
Note: See TracChangeset for help on using the changeset viewer.