- Timestamp:
- 2006-01-15T18:35:45Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77147d6
- Parents:
- ae10582
- Location:
- generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/main/uinit.h
rae10582 r44c259c 32 32 #include <arch/types.h> 33 33 34 extern void utext(void);35 extern __u32 utext_size;36 37 34 extern void uinit(void *arg); 38 35 -
generic/src/main/kinit.c
rae10582 r44c259c 70 70 { 71 71 thread_t *t; 72 #ifdef CONFIG_USERSPACE73 72 as_t *as; 74 73 as_area_t *a; … … 76 75 index_t pfn[1]; 77 76 task_t *u; 78 #endif79 77 80 78 interrupts_disable(); … … 140 138 interrupts_enable(); 141 139 142 #ifdef CONFIG_USERSPACE 143 /* 144 * Create the first user task. 145 */ 146 as = as_create(NULL); 147 if (!as) 148 panic("as_create\n"); 149 u = task_create(as); 150 if (!u) 151 panic("task_create\n"); 152 t = thread_create(uinit, NULL, u, THREAD_USER_STACK); 153 if (!t) 154 panic("thread_create\n"); 155 156 /* 157 * Create the text as_area and copy the userspace code there. 158 */ 159 a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS); 160 if (!a) 161 panic("as_area_create: text\n"); 162 163 frame = frame_alloc(0, ONE_FRAME, NULL); 164 165 if (config.init_size > 0) 140 if (config.init_size > 0) { 141 /* 142 * Create the first user task. 143 */ 144 as = as_create(NULL); 145 if (!as) 146 panic("as_create\n"); 147 u = task_create(as); 148 if (!u) 149 panic("task_create\n"); 150 t = thread_create(uinit, NULL, u, THREAD_USER_STACK); 151 if (!t) 152 panic("thread_create\n"); 153 154 /* 155 * Create the text as_area and copy the userspace code there. 156 */ 157 a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS); 158 if (!a) 159 panic("as_area_create: text\n"); 160 161 // FIXME: Better way to initialize static code/data 162 frame = frame_alloc(0, ONE_FRAME, NULL); 166 163 memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE); 167 else 168 memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE); 164 165 pfn[0] = frame / FRAME_SIZE; 166 as_area_load_mapping(a, pfn); 169 167 170 pfn[0] = frame / FRAME_SIZE; 171 as_area_load_mapping(a, pfn); 172 173 /* 174 * Create the data as_area. 175 */ 176 a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); 177 if (!a) 178 panic("as_area_create: stack\n"); 168 /* 169 * Create the data as_area. 170 */ 171 a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); 172 if (!a) 173 panic("as_area_create: stack\n"); 179 174 180 thread_ready(t);181 #endif /* CONFIG_USERSPACE */ 175 thread_ready(t); 176 } 182 177 183 178 #ifdef CONFIG_TEST
Note:
See TracChangeset
for help on using the changeset viewer.