Skip to content

Commit

Permalink
Add new process entry point in librtl.
Browse files Browse the repository at this point in the history
  • Loading branch information
BERTRAND Joel committed Dec 27, 2010
1 parent 53b7571 commit d3e5bb1
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 22 deletions.
1 change: 1 addition & 0 deletions sources/freevms/include/freevms/librtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void rtl$strcpy(struct vms$string *s1, const char *s2);
extern "C"
{
void __attribute__((noreturn)) __bootstrap(int argc, char **argv);
void __attribute__((noreturn)) __bootstrap_process(int argc, char **argv);
void __attribute__((noreturn)) exit(int v);
}

Expand Down
9 changes: 9 additions & 0 deletions sources/freevms/librtl/rtl_bootstrap.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifdef AMD64
.text
.global _start
.global _start_proces
.global _stext

_stext:
Expand All @@ -32,4 +33,12 @@ _start:
callq __bootstrap
leaveq
retq

_start_process:
callq __L4_Init
movq (%rsp), %rsi
movq 8(%rsp), %rdi
callq __bootstrap_process
leaveq
retq
#endif
94 changes: 90 additions & 4 deletions sources/freevms/librtl/rtl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,96 @@
* argv[1] = parent_tid;
*/

L4_ThreadId_t roottask_tid;
L4_ThreadId_t parent_tid;
L4_ThreadId_t roottask_tid;
L4_ThreadId_t parent_tid;

static struct vms$string message;

/*
* Start a thread with a pre-existing pager
*/

void
__bootstrap(int argc, char **argv)
{
int v;
int l;
int v;

unsigned char *p;

roottask_tid.raw = (vms$pointer) argv[0];
parent_tid.raw = (vms$pointer) argv[1];

p = (unsigned char *) argv[2];

if (p != NULL)
{
l = 0;

while(*p)
{
p++;
l++;
}
}
else
{
l = 0;
}

message.c = (unsigned char *) argv[2];
message.length = l;
message.length_trim = l;

argc -= 3;
argv += 3;

v = main(argc, argv);
exit(v);
}

/*
* Start a process
* - create an address space
* - launch pager
* - launch executable as child thread
*/

void
__bootstrap_process(int argc, char **argv)
{
int l;
int v;

unsigned char *p;

roottask_tid.raw = (vms$pointer) argv[0];
parent_tid.raw = (vms$pointer) argv[1];

p = (unsigned char *) argv[2];

if (p != NULL)
{
l = 0;

while(*p)
{
p++;
l++;
}
}
else
{
l = 0;
}

message.c = (unsigned char *) argv[2];
message.length = l;
message.length_trim = l;

argc -= 3;
argv += 3;

v = main(argc, argv);
exit(v);
}
Expand All @@ -54,7 +133,14 @@ exit(int v)
L4_Load(&msg);
L4_Call(parent_tid);

// Send IPC to roottask stop thread.
// Print message

if (message.length_trim != 0)
{
rtl$print(&message, NULL);
}

// Send IPC to roottask to stop thread.

L4_Clear(&msg);
L4_Append(&msg, L4_Myself().raw);
Expand Down
24 changes: 6 additions & 18 deletions sources/freevms/sys/sys_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,18 @@ sys$pager(L4_KernelInterfacePage_t *kip, struct vms$meminfo *meminfo,
// Setup the stack (16 bytes alignment)
user_stack = (vms$pointer *) sys$page_round_down(stack->end + 1, 16);

if (sys$back_mem(heap->base, heap->base + (12 * sizeof(vms$pointer)),
if (sys$back_mem(heap->base, heap->base + (3 * sizeof(vms$pointer)),
pagesize) != 0)
{
PANIC(1, notice(MEM_F_BACKMEM "unable to back heap during startup\n"));
}

init_vars = (vms$pointer *) (heap->base);
*(init_vars + 0) = L4_Myself().raw;
*(init_vars + 1) = L4_Myself().raw;
/*
*(init_vars + 0) = NULL; // Callback pointer
*(init_vars + 1) = 0; // SYS$INPUT
*(init_vars + 2) = 0; // SYS$OUTPUT
*(init_vars + 3) = 0; // SYS$ERROR
*(init_vars + 4) = heap->base;
*(init_vars + 5) = heap->end;
*(init_vars + 6) = 0; // cap_slot
*(init_vars + 7) = i - 1; // cap_used
*(init_vars + 8) = pagesize / sizeof(cap_t); // cap_size
*(init_vars + 9) = clist_section->base; // cap_addr
*(init_vars + 10) = 0; // naming_server
*/

*(--user_stack) = 1; // argc
*(init_vars + 0) = L4_Myself().raw; // Roottask
*(init_vars + 1) = L4_Myself().raw; // Parent
*(init_vars + 2) = (vms$pointer) RUN_S_STOPPED // Exit message
"PAGER.SYS process stopped";
*(--user_stack) = 3; // argc
*(--user_stack) = (vms$pointer) init_vars; // arguments

sys$thread_start(thread, init->entry, (vms$pointer) user_stack);
Expand Down

0 comments on commit d3e5bb1

Please sign in to comment.