- Timestamp:
- 2006-01-13T13:02:45Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f9425006
- Parents:
- 0369911
- Location:
- generic
- Files:
-
- 1 added
- 1 deleted
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
generic/include/arch.h
r0369911 r20d50a1 40 40 #define THREAD THE->thread 41 41 #define TASK THE->task 42 #define VM THE->vm42 #define AS THE->as 43 43 #define PREEMPTION_DISABLED THE->preemption_disabled 44 44 … … 53 53 task_t *task; /**< Current task. */ 54 54 cpu_t *cpu; /**< Executing cpu. */ 55 vm_t *vm; /**< Current vm. */55 as_t *as; /**< Current address space. */ 56 56 }; 57 57 -
generic/include/mm/as.h
r0369911 r20d50a1 27 27 */ 28 28 29 #ifndef __ VM_H__30 #define __ VM_H__29 #ifndef __AS_H__ 30 #define __AS_H__ 31 31 32 32 #include <arch/mm/page.h> 33 #include <arch/mm/ vm.h>33 #include <arch/mm/as.h> 34 34 #include <arch/mm/asid.h> 35 35 #include <arch/types.h> … … 49 49 #define UDATA_ADDRESS UDATA_ADDRESS_ARCH 50 50 51 enum vm_type {52 VMA_TEXT = 1, VMA_DATA, VMA_STACK51 enum as_area_type { 52 AS_AREA_TEXT = 1, AS_AREA_DATA, AS_AREA_STACK 53 53 }; 54 54 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. 58 59 */ 59 struct vm_area {60 struct as_area { 60 61 SPINLOCK_DECLARE(lock); 61 62 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. */ 66 67 }; 67 68 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 70 72 * pages for one or more tasks. Ranges of kernel memory pages are not 71 73 * supposed to figure in the list as they are shared by all tasks and 72 74 * set up during system initialization. 73 75 */ 74 struct vm{76 struct as { 75 77 SPINLOCK_DECLARE(lock); 76 link_t vm_area_head;78 link_t as_area_head; 77 79 pte_t *ptl0; 78 asid_t asid; 80 asid_t asid; /**< Address space identifier. */ 79 81 }; 80 82 81 extern vm_t * vm_create(pte_t *ptl0); 82 extern void vm_destroy(vm_t *m); 83 extern as_t * as_create(pte_t *ptl0); 84 extern as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base); 85 extern void as_area_load_mapping(as_area_t *a, index_t *pfn); 86 extern int as_page_fault(__address page); 87 extern void as_install(as_t *m); 83 88 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 98 extern void as_install_arch(as_t *as); 99 #endif /* !def as_install_arch */ 92 100 93 101 #endif -
generic/include/proc/task.h
r0369911 r20d50a1 34 34 #include <list.h> 35 35 36 /** Task structure. */ 36 37 struct task { 37 38 SPINLOCK_DECLARE(lock); 38 39 link_t th_head; /**< List of threads contained in this task. */ 39 40 link_t tasks_link; /**< Link to other tasks within the system. */ 40 vm_t *vm;41 as_t *as; /**< Address space. */ 41 42 }; 42 43 … … 45 46 46 47 extern void task_init(void); 47 extern task_t *task_create( vm_t *m);48 extern task_t *task_create(as_t *as); 48 49 49 50 #endif -
generic/include/typedefs.h
r0369911 r20d50a1 71 71 typedef struct region region_t; 72 72 73 typedef enum vm_type vm_type_t;74 typedef struct vm_area vm_area_t;75 typedef struct vm vm_t;73 typedef enum as_area_type as_area_type_t; 74 typedef struct as_area as_area_t; 75 typedef struct as as_t; 76 76 77 77 typedef struct link link_t; -
generic/src/main/kinit.c
r0369911 r20d50a1 40 40 #include <mm/page.h> 41 41 #include <arch/mm/page.h> 42 #include <mm/ vm.h>42 #include <mm/as.h> 43 43 #include <mm/frame.h> 44 44 #include <print.h> … … 71 71 thread_t *t; 72 72 #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]; 75 77 task_t *u; 76 78 #endif … … 142 144 * Create the first user task. 143 145 */ 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); 148 150 if (!u) 149 151 panic("task_create\n"); … … 153 155 154 156 /* 155 * Create the text vm_area and copy the userspace code there.157 * Create the text as_area and copy the userspace code there. 156 158 */ 157 a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS);159 a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS); 158 160 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 161 165 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); 163 167 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); 165 172 166 173 /* 167 * Create the data vm_area.174 * Create the data as_area. 168 175 */ 169 a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS);176 a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); 170 177 if (!a) 171 panic("vm_area_create: vm_stack\n"); 172 vm_area_map(a, m); 178 panic("as_area_create: stack\n"); 173 179 174 180 thread_ready(t); -
generic/src/main/main.c
r0369911 r20d50a1 49 49 #include <genarch/mm/page_pt.h> 50 50 #include <mm/tlb.h> 51 #include <mm/ vm.h>51 #include <mm/as.h> 52 52 #include <synch/waitq.h> 53 53 #include <arch/arch.h> … … 136 136 void main_bsp_separated_stack(void) 137 137 { 138 vm_t *m;138 as_t *as; 139 139 task_t *k; 140 140 thread_t *t; … … 184 184 185 185 /* 186 * Create kernel vm mapping.187 */ 188 m = vm_create(GET_PTL0_ADDRESS());189 if (! m)190 panic("can't create kernel vmaddress 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"); 191 191 192 192 /* 193 193 * Create kernel task. 194 194 */ 195 k = task_create( m);195 k = task_create(as); 196 196 if (!k) 197 197 panic("can't create kernel task\n"); -
generic/src/mm/frame.c
r0369911 r20d50a1 32 32 #include <mm/heap.h> 33 33 #include <mm/frame.h> 34 #include <mm/ vm.h>34 #include <mm/as.h> 35 35 #include <panic.h> 36 36 #include <debug.h> -
generic/src/mm/page.c
r0369911 r20d50a1 1 1 /* 2 * Copyright (C) 2001-200 4Jakub Jermar2 * Copyright (C) 2001-2006 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 25 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * Virtual Address Translation subsystem. 27 31 */ 28 32 -
generic/src/proc/scheduler.c
r0369911 r20d50a1 33 33 #include <mm/frame.h> 34 34 #include <mm/page.h> 35 #include <mm/ vm.h>35 #include <mm/as.h> 36 36 #include <arch/asm.h> 37 37 #include <arch/faddr.h> … … 353 353 */ 354 354 if (TASK != THREAD->task) { 355 vm_t *m1 = NULL;356 vm_t *m2;355 as_t *as1 = NULL; 356 as_t *as2; 357 357 358 358 if (TASK) { 359 359 spinlock_lock(&TASK->lock); 360 m1 = TASK->vm;360 as1 = TASK->as; 361 361 spinlock_unlock(&TASK->lock); 362 362 } 363 363 364 364 spinlock_lock(&THREAD->task->lock); 365 m2 = THREAD->task->vm;365 as2 = THREAD->task->as; 366 366 spinlock_unlock(&THREAD->task->lock); 367 367 368 368 /* 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. 374 374 * Replace the old one with the new one. 375 375 */ 376 vm_install(m2);376 as_install(as2); 377 377 } 378 378 TASK = THREAD->task; -
generic/src/proc/task.c
r0369911 r20d50a1 29 29 #include <proc/thread.h> 30 30 #include <proc/task.h> 31 #include <mm/ vm.h>31 #include <mm/as.h> 32 32 #include <mm/heap.h> 33 33 … … 55 55 * Create new task with no threads. 56 56 * 57 * @param m Task's virtual memory structure.57 * @param as Task's address space. 58 58 * 59 59 * @return New task's structure on success, NULL on failure. 60 60 * 61 61 */ 62 task_t *task_create( vm_t *m)62 task_t *task_create(as_t *as) 63 63 { 64 64 ipl_t ipl; … … 70 70 list_initialize(&ta->th_head); 71 71 list_initialize(&ta->tasks_link); 72 ta-> vm = m;72 ta->as = as; 73 73 74 74 ipl = interrupts_disable(); -
generic/src/proc/the.c
r0369911 r20d50a1 43 43 the->thread = NULL; 44 44 the->task = NULL; 45 the-> vm= NULL;45 the->as = NULL; 46 46 } 47 47
Note:
See TracChangeset
for help on using the changeset viewer.