Changeset 20d50a1 in mainline for generic/src


Ignore:
Timestamp:
2006-01-13T13:02:45Z (20 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().
Location:
generic/src
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • 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.