sched: implement passing arguments to user-mode threads
This commit is contained in:
41
kernel/bsp.c
41
kernel/bsp.c
@@ -179,15 +179,52 @@ kern_status_t bsp_launch_async(struct bsp *bsp, struct task *task)
|
||||
return status;
|
||||
}
|
||||
|
||||
status = vm_region_map_object(
|
||||
task->t_address_space,
|
||||
VM_REGION_ANY_OFFSET,
|
||||
bsp->bsp_vmo,
|
||||
0,
|
||||
bsp->bsp_trailer.bsp_exec_offset,
|
||||
VM_PROT_READ | VM_PROT_USER,
|
||||
&bsp_data_base);
|
||||
|
||||
if (status != KERN_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = map_executable(bsp, task, &entry);
|
||||
if (status != KERN_OK) {
|
||||
return status;
|
||||
}
|
||||
#ifdef TRACE
|
||||
vm_region_dump(task->t_address_space, 0);
|
||||
vm_region_dump(task->t_address_space);
|
||||
#endif
|
||||
|
||||
sp = stack_buffer + BOOTSTRAP_STACK_SIZE;
|
||||
tracek("bootstrap: entry=%llx, sp=%llx", entry, sp);
|
||||
|
||||
kern_handle_t self, self_address_space;
|
||||
task_open_handle(task, &task->t_base, 0, &self);
|
||||
task_open_handle(
|
||||
task,
|
||||
&task->t_address_space->vr_base,
|
||||
0,
|
||||
&self_address_space);
|
||||
|
||||
const uintptr_t args[] = {
|
||||
0, // int argc
|
||||
0, // const char ** argv
|
||||
self, // kern_handle_t task
|
||||
self_address_space, // kern_handle_t address_space
|
||||
|
||||
/* this parameter is specific to the bsp bootstrap program, so
|
||||
* that it can access the rest of the bsp image. */
|
||||
bsp_data_base,
|
||||
};
|
||||
const size_t nr_args = sizeof args / sizeof args[0];
|
||||
|
||||
struct thread *init_thread = task_create_thread(task);
|
||||
thread_init_user(init_thread, entry, sp);
|
||||
thread_init_user(init_thread, entry, sp, args, nr_args);
|
||||
schedule_thread_on_cpu(init_thread);
|
||||
|
||||
return KERN_OK;
|
||||
|
||||
Reference in New Issue
Block a user