Changeset 20d50a1 in mainline


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

Memory management work.

  • vm.* → as.* (as like address space is, imho, more fitting)
  • Don't do TLB shootdown on vm_install(). Some architectures only need to call tlb_invalidate_asid().
  • Don't allocate all frames for as_area in as_area_create(), but let them be allocated on-demand by as_page_fault().
  • Add high-level page fault handler as_page_fault().
  • Add as_area_load_mapping().
Files:
1 added
1 deleted
20 edited
8 moved

Legend:

Unmodified
Added
Removed
  • Makefile

    r0369911 r20d50a1  
    118118        generic/src/mm/page.c \
    119119        generic/src/mm/tlb.c \
    120         generic/src/mm/vm.c \
     120        generic/src/mm/as.c \
    121121        generic/src/lib/func.c \
    122122        generic/src/lib/list.c \
  • arch/amd64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __amd64_VM_H__
    30 #define __amd64_VM_H__
     29#ifndef __amd64_AS_H__
     30#define __amd64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/amd64/src/interrupt.c

    r0369911 r20d50a1  
    3636#include <arch/asm.h>
    3737#include <mm/tlb.h>
     38#include <mm/as.h>
    3839#include <arch.h>
    3940#include <symtab.h>
     
    125126}
    126127
    127 
    128 
    129128void page_fault(int n, void *stack)
    130129{
    131         print_info_errcode(n,stack);
    132         printf("Page fault address: %Q\n", read_cr2());
    133         panic("page fault\n");
     130        __address page;
     131       
     132        page = read_cr2();
     133        if (!as_page_fault(page)) {
     134                print_info_errcode(n,stack);
     135                printf("Page fault address: %Q\n", page);
     136                panic("page fault\n");
     137        }
    134138}
    135139
  • arch/amd64/src/userspace.c

    r0369911 r20d50a1  
    3232#include <arch.h>
    3333#include <proc/thread.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636
  • arch/ia32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ia32_VM_H__
    30 #define __ia32_VM_H__
     29#ifndef __ia32_AS_H__
     30#define __ia32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/ia32/src/interrupt.c

    r0369911 r20d50a1  
    3636#include <arch/asm.h>
    3737#include <mm/tlb.h>
     38#include <mm/as.h>
    3839#include <arch.h>
    3940#include <symtab.h>
     
    100101void page_fault(int n, void *stack)
    101102{
    102         PRINT_INFO_ERRCODE(stack);
    103         printf("page fault address: %X\n", read_cr2());
    104         panic("page fault\n");
     103        __address page;
     104
     105        page = read_cr2();
     106        if (!as_page_fault(page)) {
     107                PRINT_INFO_ERRCODE(stack);
     108                printf("page fault address: %X\n", page);
     109                panic("page fault\n");
     110        }
    105111}
    106112
  • arch/ia32/src/mm/frame.c

    r0369911 r20d50a1  
    2929#include <mm/frame.h>
    3030#include <arch/mm/frame.h>
    31 #include <mm/vm.h>
     31#include <mm/as.h>
    3232#include <config.h>
    3333#include <arch/boot/boot.h>
  • arch/ia32/src/userspace.c

    r0369911 r20d50a1  
    3232#include <arch.h>
    3333#include <proc/thread.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636
     
    4848        __asm__ volatile (
    4949                /* CLNT */
    50                 "pushfl;"
    51                 "pop %%eax;"
    52                 "and $0xFFFFBFFF,%%eax;"
    53                 "push %%eax;"
    54                 "popfl;"
     50                "pushfl\n"
     51                "pop %%eax\n"
     52                "and $0xffffbfff,%%eax\n"
     53                "push %%eax\n"
     54                "popfl\n"
    5555
    5656                "pushl %0\n"
     
    6565       
    6666        /* Unreachable */
    67         for(;;);
     67        for(;;)
     68                ;
    6869}
  • arch/ia64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ia64_VM_H__
    30 #define __ia64_VM_H__
     29#ifndef __ia64_AS_H__
     30#define __ia64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x0000000001001000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/mips32/Makefile.inc

    r0369911 r20d50a1  
    113113        arch/$(ARCH)/src/mm/page.c \
    114114        arch/$(ARCH)/src/mm/tlb.c \
    115         arch/$(ARCH)/src/mm/vm.c \
     115        arch/$(ARCH)/src/mm/as.c \
    116116        arch/$(ARCH)/src/fpu_context.c \
    117117        arch/$(ARCH)/src/drivers/arc.c \
  • arch/mips32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __mips32_VM_H__
    30 #define __mips32_VM_H__
     29#ifndef __mips32_AS_H__
     30#define __mips32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4242#define UDATA_ADDRESS_ARCH      0x01001000
    4343
    44 extern void vm_install_arch(vm_t *vm);
    45 
    4644#endif
  • arch/mips32/src/mips32.c

    r0369911 r20d50a1  
    3232#include <arch/exception.h>
    3333#include <arch/asm.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636#include <userspace.h>
  • arch/mips32/src/mm/as.c

    r0369911 r20d50a1  
    2727 */
    2828
    29 #include <arch/mm/vm.h>
     29#include <arch/mm/as.h>
    3030#include <arch/mm/tlb.h>
    31 #include <mm/vm.h>
     31#include <mm/tlb.h>
     32#include <mm/as.h>
    3233#include <arch/cp0.h>
    3334#include <arch.h>
    3435
    35 /** Install ASID of the current VM
     36/** Install address space.
    3637 *
    37  * Install ASID of the current VM.
     38 * Install ASID and if necessary, purge TLB.
    3839 *
    39  * @param vm VM structure.
     40 * @param as Address space structure.
    4041 */
    41 void vm_install_arch(vm_t *vm)
     42void as_install_arch(as_t *as)
    4243{
    4344        entry_hi_t hi;
    4445        ipl_t ipl;
    45        
     46
     47        /*
     48         * If necessary, purge TLB.
     49         */
     50        tlb_invalidate_asid(as->asid);  /* TODO: do it only if necessary */
     51
     52        /*
     53         * Install ASID.
     54         */     
    4655        hi.value = cp0_entry_hi_read();
    4756
    4857        ipl = interrupts_disable();
    49         spinlock_lock(&vm->lock);
    50         hi.asid = vm->asid;
     58        spinlock_lock(&as->lock);
     59        hi.asid = as->asid;
    5160        cp0_entry_hi_write(hi.value);   
    52         spinlock_unlock(&vm->lock);
     61        spinlock_unlock(&as->lock);
    5362        interrupts_restore(ipl);
    5463}
  • arch/mips32/src/mm/tlb.c

    r0369911 r20d50a1  
    3131#include <mm/tlb.h>
    3232#include <mm/page.h>
    33 #include <mm/vm.h>
     33#include <mm/as.h>
    3434#include <arch/cp0.h>
    3535#include <panic.h>
     
    9393        badvaddr = cp0_badvaddr_read();
    9494
    95         spinlock_lock(&VM->lock);               
     95        spinlock_lock(&AS->lock);               
    9696
    9797        pte = find_mapping_and_check(badvaddr);
     
    104104        pte->a = 1;
    105105
    106         prepare_entry_hi(&hi, VM->asid, badvaddr);
     106        prepare_entry_hi(&hi, AS->asid, badvaddr);
    107107        prepare_entry_lo(&lo, pte->lo.g, pte->lo.v, pte->lo.d, pte->lo.c, pte->lo.pfn);
    108108
     
    122122        tlbwr();
    123123
    124         spinlock_unlock(&VM->lock);
     124        spinlock_unlock(&AS->lock);
    125125        return;
    126126       
    127127fail:
    128         spinlock_unlock(&VM->lock);
     128        spinlock_unlock(&AS->lock);
    129129        tlb_refill_fail(pstate);
    130130}
     
    155155        index.value = cp0_index_read();
    156156       
    157         spinlock_lock(&VM->lock);       
     157        spinlock_lock(&AS->lock);       
    158158       
    159159        /*
     
    191191        tlbwi();
    192192
    193         spinlock_unlock(&VM->lock);     
     193        spinlock_unlock(&AS->lock);     
    194194        return;
    195195       
    196196fail:
    197         spinlock_unlock(&VM->lock);
     197        spinlock_unlock(&AS->lock);
    198198        tlb_invalid_fail(pstate);
    199199}
     
    224224        index.value = cp0_index_read();
    225225       
    226         spinlock_lock(&VM->lock);       
     226        spinlock_lock(&AS->lock);       
    227227       
    228228        /*
     
    267267        tlbwi();
    268268
    269         spinlock_unlock(&VM->lock);     
     269        spinlock_unlock(&AS->lock);     
    270270        return;
    271271       
    272272fail:
    273         spinlock_unlock(&VM->lock);
     273        spinlock_unlock(&AS->lock);
    274274        tlb_modified_fail(pstate);
    275275}
     
    313313 *
    314314 * Try to find PTE for faulting address.
    315  * The VM->lock must be held on entry to this function.
     315 * The AS->lock must be held on entry to this function.
    316316 *
    317317 * @param badvaddr Faulting virtual address.
     
    329329         * Handler cannot succeed if the ASIDs don't match.
    330330         */
    331         if (hi.asid != VM->asid) {
    332                 printf("EntryHi.asid=%d, VM->asid=%d\n", hi.asid, VM->asid);
     331        if (hi.asid != AS->asid) {
     332                printf("EntryHi.asid=%d, AS->asid=%d\n", hi.asid, AS->asid);
    333333                return NULL;
    334334        }
    335        
     335
     336        /*
     337         * Check if the mapping exists in page tables.
     338         */     
     339        pte = page_mapping_find(badvaddr, AS->asid, 0);
     340        if (pte && pte->lo.v) {
     341                /*
     342                 * Mapping found in page tables.
     343                 * Immediately succeed.
     344                 */
     345                return pte;
     346        } else {
     347                /*
     348                 * Mapping not found in page tables.
     349                 * Resort to higher-level page fault handler.
     350                 */
     351                if (as_page_fault(badvaddr)) {
     352                        /*
     353                         * The higher-level page fault handler succeeded,
     354                         * The mapping ought to be in place.
     355                         */
     356                        pte = page_mapping_find(badvaddr, AS->asid, 0);
     357                        ASSERT(pte && pte->lo.v);
     358                        return pte;
     359                }
     360        }
     361
    336362        /*
    337363         * Handler cannot succeed if badvaddr has no mapping.
    338364         */
    339         pte = page_mapping_find(badvaddr, VM->asid, 0);
    340365        if (!pte) {
    341366                printf("No such mapping.\n");
  • arch/ppc32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ppc32_VM_H__
    30 #define __ppc32_VM_H__
     29#ifndef __ppc32_AS_H__
     30#define __ppc32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/sparc64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __sparc64_VM_H__
    30 #define __sparc64_VM_H__
     29#ifndef __sparc64_AS_H__
     30#define __sparc64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x8000000000000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • doc/mm

    r0369911 r20d50a1  
    22=================
    33
    4 SPARTAN kernel deploys generic interface for 4-level page tables,
    5 no matter what the real underlying hardware architecture is.
     41. Virtual Address Translation
     5
     61.1 Hierarchical 4-level per address space page tables
     7
     8SPARTAN kernel deploys generic interface for 4-level page tables
     9for these architectures: amd64, ia32, mips32 and ppc32. In this
     10setting, page tables are hierarchical and are not shared by
     11address spaces (i.e. one set of page tables per address space).
    612
    713
     
    5157left out. TLB-only architectures are to define custom format for software page
    5258tables.
     59
     60
     61
     621.2 Single global page hash table
     63
     64Generic page hash table interface is deployed on 64-bit architectures without
     65implied hardware support for hierarchical page tables, i.e. ia64 and sparc64.
     66There is only one global page hash table in the system shared by all address
     67spaces.
  • generic/include/arch.h

    r0369911 r20d50a1  
    4040#define THREAD                  THE->thread
    4141#define TASK                    THE->task
    42 #define VM                      THE->vm
     42#define AS                      THE->as
    4343#define PREEMPTION_DISABLED     THE->preemption_disabled
    4444
     
    5353        task_t *task;                   /**< Current task. */
    5454        cpu_t *cpu;                     /**< Executing cpu. */
    55         vm_t *vm;                       /**< Current vm. */
     55        as_t *as;                       /**< Current address space. */
    5656};
    5757
  • generic/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __VM_H__
    30 #define __VM_H__
     29#ifndef __AS_H__
     30#define __AS_H__
    3131
    3232#include <arch/mm/page.h>
    33 #include <arch/mm/vm.h>
     33#include <arch/mm/as.h>
    3434#include <arch/mm/asid.h>
    3535#include <arch/types.h>
     
    4949#define UDATA_ADDRESS   UDATA_ADDRESS_ARCH
    5050
    51 enum vm_type {
    52         VMA_TEXT = 1, VMA_DATA, VMA_STACK
     51enum as_area_type {
     52        AS_AREA_TEXT = 1, AS_AREA_DATA, AS_AREA_STACK
    5353};
    5454
    55 /*
    56  * Each vm_area_t structure describes one continuous area of virtual memory.
    57  * In the future, it should not be difficult to support shared areas of vm.
     55/** Address space area structure.
     56 *
     57 * Each as_area_t structure describes one contiguous area of virtual memory.
     58 * In the future, it should not be difficult to support shared areas.
    5859 */
    59 struct vm_area {
     60struct as_area {
    6061        SPINLOCK_DECLARE(lock);
    6162        link_t link;
    62         vm_type_t type;
    63         int size;
    64         __address address;
    65         __address *mapping;
     63        as_area_type_t type;
     64        size_t size;            /**< Size of this area. */
     65        __address base;         /**< Base address of this area. */
     66        index_t *mapping;       /**< Map of physical frame numbers mapped to virtual page numbers in this area. */
    6667};
    6768
    68 /*
    69  * vm_t contains the list of vm_areas of userspace accessible
     69/** Address space structure.
     70 *
     71 * as_t contains the list of as_areas of userspace accessible
    7072 * pages for one or more tasks. Ranges of kernel memory pages are not
    7173 * supposed to figure in the list as they are shared by all tasks and
    7274 * set up during system initialization.
    7375 */
    74 struct vm {
     76struct as {
    7577        SPINLOCK_DECLARE(lock);
    76         link_t vm_area_head;
     78        link_t as_area_head;
    7779        pte_t *ptl0;
    78         asid_t asid;
     80        asid_t asid;                    /**< Address space identifier. */
    7981};
    8082
    81 extern vm_t * vm_create(pte_t *ptl0);
    82 extern void vm_destroy(vm_t *m);
     83extern as_t * as_create(pte_t *ptl0);
     84extern as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base);
     85extern void as_area_load_mapping(as_area_t *a, index_t *pfn);
     86extern int as_page_fault(__address page);
     87extern void as_install(as_t *m);
    8388
    84 extern vm_area_t *vm_area_create(vm_t *m, vm_type_t type, size_t size, __address addr);
    85 extern void vm_area_destroy(vm_area_t *a);
    86 
    87 extern void vm_area_map(vm_area_t *a, vm_t *m);
    88 extern void vm_area_unmap(vm_area_t *a, vm_t *m);
    89 
    90 extern void vm_install(vm_t *m);
    91 extern void vm_uninstall(vm_t *m);
     89/*
     90 * Each architecture should implement this function.
     91 * Its main purpose is to do TLB purges according
     92 * to architecture's requirements. Note that
     93 * some architectures invalidate their TLB automatically
     94 * on hardware address space switch (e.g. ia32 and
     95 * amd64).
     96 */
     97#ifndef as_install_arch
     98extern void as_install_arch(as_t *as);
     99#endif /* !def as_install_arch */
    92100
    93101#endif
  • generic/include/proc/task.h

    r0369911 r20d50a1  
    3434#include <list.h>
    3535
     36/** Task structure. */
    3637struct task {
    3738        SPINLOCK_DECLARE(lock);
    3839        link_t th_head;         /**< List of threads contained in this task. */
    3940        link_t tasks_link;      /**< Link to other tasks within the system. */
    40         vm_t *vm;
     41        as_t *as;               /**< Address space. */
    4142};
    4243
     
    4546
    4647extern void task_init(void);
    47 extern task_t *task_create(vm_t *m);
     48extern task_t *task_create(as_t *as);
    4849
    4950#endif
  • generic/include/typedefs.h

    r0369911 r20d50a1  
    7171typedef struct region region_t;
    7272
    73 typedef enum vm_type vm_type_t;
    74 typedef struct vm_area vm_area_t;
    75 typedef struct vm vm_t;
     73typedef enum as_area_type as_area_type_t;
     74typedef struct as_area as_area_t;
     75typedef struct as as_t;
    7676
    7777typedef struct link link_t;
  • generic/src/main/kinit.c

    r0369911 r20d50a1  
    4040#include <mm/page.h>
    4141#include <arch/mm/page.h>
    42 #include <mm/vm.h>
     42#include <mm/as.h>
    4343#include <mm/frame.h>
    4444#include <print.h>
     
    7171        thread_t *t;
    7272#ifdef CONFIG_USERSPACE
    73         vm_t *m;
    74         vm_area_t *a;
     73        as_t *as;
     74        as_area_t *a;
     75        __address frame;
     76        index_t pfn[1];
    7577        task_t *u;
    7678#endif
     
    142144         * Create the first user task.
    143145         */
    144         m = vm_create(NULL);
    145         if (!m)
    146                 panic("vm_create\n");
    147         u = task_create(m);
     146        as = as_create(NULL);
     147        if (!as)
     148                panic("as_create\n");
     149        u = task_create(as);
    148150        if (!u)
    149151                panic("task_create\n");
     
    153155
    154156        /*
    155          * Create the text vm_area and copy the userspace code there.
     157         * Create the text as_area and copy the userspace code there.
    156158         */     
    157         a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS);
     159        a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS);
    158160        if (!a)
    159                 panic("vm_area_create: vm_text\n");
    160         vm_area_map(a, m);
     161                panic("as_area_create: text\n");
     162
     163        frame = frame_alloc(0, ONE_FRAME, NULL);
     164
    161165        if (config.init_size > 0)
    162                 memcpy((void *) PA2KA(a->mapping[0]), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
     166                memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE);
    163167        else
    164                 memcpy((void *) PA2KA(a->mapping[0]), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
     168                memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);
     169       
     170        pfn[0] = frame / FRAME_SIZE;
     171        as_area_load_mapping(a, pfn);
    165172
    166173        /*
    167          * Create the data vm_area.
     174         * Create the data as_area.
    168175         */
    169         a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS);
     176        a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
    170177        if (!a)
    171                 panic("vm_area_create: vm_stack\n");
    172         vm_area_map(a, m);
     178                panic("as_area_create: stack\n");
    173179       
    174180        thread_ready(t);
  • generic/src/main/main.c

    r0369911 r20d50a1  
    4949#include <genarch/mm/page_pt.h>
    5050#include <mm/tlb.h>
    51 #include <mm/vm.h>
     51#include <mm/as.h>
    5252#include <synch/waitq.h>
    5353#include <arch/arch.h>
     
    136136void main_bsp_separated_stack(void)
    137137{
    138         vm_t *m;
     138        as_t *as;
    139139        task_t *k;
    140140        thread_t *t;
     
    184184
    185185        /*
    186          * Create kernel vm mapping.
    187          */
    188         m = vm_create(GET_PTL0_ADDRESS());
    189         if (!m)
    190                 panic("can't create kernel vm address space\n");
     186         * Create kernel address space.
     187         */
     188        as = as_create(GET_PTL0_ADDRESS());
     189        if (!as)
     190                panic("can't create kernel address space\n");
    191191
    192192        /*
    193193         * Create kernel task.
    194194         */
    195         k = task_create(m);
     195        k = task_create(as);
    196196        if (!k)
    197197                panic("can't create kernel task\n");
  • generic/src/mm/frame.c

    r0369911 r20d50a1  
    3232#include <mm/heap.h>
    3333#include <mm/frame.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535#include <panic.h>
    3636#include <debug.h>
  • generic/src/mm/page.c

    r0369911 r20d50a1  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2001-2006 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2525 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/*
     30 * Virtual Address Translation subsystem.
    2731 */
    2832
  • generic/src/proc/scheduler.c

    r0369911 r20d50a1  
    3333#include <mm/frame.h>
    3434#include <mm/page.h>
    35 #include <mm/vm.h>
     35#include <mm/as.h>
    3636#include <arch/asm.h>
    3737#include <arch/faddr.h>
     
    353353         */
    354354        if (TASK != THREAD->task) {
    355                 vm_t *m1 = NULL;
    356                 vm_t *m2;
     355                as_t *as1 = NULL;
     356                as_t *as2;
    357357
    358358                if (TASK) {
    359359                        spinlock_lock(&TASK->lock);
    360                         m1 = TASK->vm;
     360                        as1 = TASK->as;
    361361                        spinlock_unlock(&TASK->lock);
    362362                }
    363363
    364364                spinlock_lock(&THREAD->task->lock);
    365                 m2 = THREAD->task->vm;
     365                as2 = THREAD->task->as;
    366366                spinlock_unlock(&THREAD->task->lock);
    367367               
    368368                /*
    369                  * Note that it is possible for two tasks to share one vm mapping.
    370                  */
    371                 if (m1 != m2) {
    372                         /*
    373                          * Both tasks and vm mappings are different.
     369                 * Note that it is possible for two tasks to share one address space.
     370                 */
     371                if (as1 != as2) {
     372                        /*
     373                         * Both tasks and address spaces are different.
    374374                         * Replace the old one with the new one.
    375375                         */
    376                         vm_install(m2);
     376                        as_install(as2);
    377377                }
    378378                TASK = THREAD->task;   
  • generic/src/proc/task.c

    r0369911 r20d50a1  
    2929#include <proc/thread.h>
    3030#include <proc/task.h>
    31 #include <mm/vm.h>
     31#include <mm/as.h>
    3232#include <mm/heap.h>
    3333
     
    5555 * Create new task with no threads.
    5656 *
    57  * @param m Task's virtual memory structure.
     57 * @param as Task's address space.
    5858 *
    5959 * @return New task's structure on success, NULL on failure.
    6060 *
    6161 */
    62 task_t *task_create(vm_t *m)
     62task_t *task_create(as_t *as)
    6363{
    6464        ipl_t ipl;
     
    7070                list_initialize(&ta->th_head);
    7171                list_initialize(&ta->tasks_link);
    72                 ta->vm = m;
     72                ta->as = as;
    7373               
    7474                ipl = interrupts_disable();
  • generic/src/proc/the.c

    r0369911 r20d50a1  
    4343        the->thread = NULL;
    4444        the->task = NULL;
    45         the->vm = NULL;
     45        the->as = NULL;
    4646}
    4747
Note: See TracChangeset for help on using the changeset viewer.