-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
int new_thread(void *arg1, void *arg2, void *arg3) {
puts("HELLO");
printf("Hello2: arg1 %p, arg2 %p, arg3 %p\n", arg1, arg2, arg3);
// void (*func)(int) = arg1;
// func(*(int *)arg2);
while (1)
;
}
int main(int c, char *arbv[]) {
printf("Hello, World!\n");
seL4_DebugDumpScheduler();
// TODO fix the parameters in this invocation
seL4_Error result =
seL4_Untyped_Retype(tcb_untyped, seL4_TCBObject, seL4_TCBBits, root_cnode,
0, 0, tcb_cap_slot, 1);
ZF_LOGF_IF(result, "Failed to retype thread: %d", result);
seL4_DebugDumpScheduler();
// TODO fix the parameters in this invocation
result = seL4_TCB_Configure(tcb_cap_slot, 0, root_cnode, 0, root_vspace, 0,
(seL4_Word)thread_ipc_buff_sym, tcb_ipc_frame);
ZF_LOGF_IF(result, "Failed to configure thread: %d", result);
// TODO fix the call to set priority using the authority of the current thread
// and change the priority to 254
result = seL4_TCB_SetPriority(tcb_cap_slot, root_tcb, 254);
ZF_LOGF_IF(result, "Failed to set the priority for the new TCB object.\n");
seL4_DebugDumpScheduler();
seL4_UserContext regs = {0};
int error = seL4_TCB_ReadRegisters(tcb_cap_slot, 0, 0,
sizeof(regs) / sizeof(seL4_Word), ®s);
ZF_LOGF_IFERR(error, "Failed to read the new thread's register set.\n");
// TODO use valid instruction pointer
sel4utils_set_instruction_pointer(®s, (seL4_Word)new_thread);
// TODO use valid stack pointer
sel4utils_set_stack_pointer(®s, tcb_stack_top);
// TODO fix parameters to this invocation
error = seL4_TCB_WriteRegisters(tcb_cap_slot, 0, 0,
sizeof(regs) / sizeof(seL4_Word), ®s);
ZF_LOGF_IFERR(error,
"Failed to write the new thread's register set.\n"
"\tDid you write the correct number of registers? See arg4.\n");
seL4_DebugDumpScheduler();
// TODO resume the new thread
error = seL4_TCB_Resume(tcb_cap_slot);
ZF_LOGF_IFERR(error, "Failed to start new thread.\n");
while (1)
;
return 0;
}I followed the tutorial and completed the task as above.
However, if new_thread function contains a printf invocation, it will fail before it prints out anything.
I originally thought it's an issue with my solution to the tutorial, but I tried puts, which outputs content.
This means new_thread indeed started but failed at printf.
As I am new to seL4, I am not sure what's going on here. I have tested replacing every piece of my code with the solution code but the error remains.
Thank you in advance for your kind help.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels