Major reorganization in prep for appserver merge
[akaros.git] / kern / arch / sparc / process.c
1 #include <arch/arch.h>
2 #include <arch/trap.h>
3 #include <process.h>
4 #include <frontend.h>
5 #include <pmap.h>
6 #include <smp.h>
7
8 #include <string.h>
9 #include <assert.h>
10 #include <stdio.h>
11
12 #ifdef __SHARC__
13 #pragma nosharc
14 #endif
15
16 // architecture-specific process initialization code
17 void
18 proc_init_arch(struct proc *SAFE p)
19 {
20         pid_t parent_id = p->ppid, id = p->pid;
21         int32_t errno;
22         if(frontend_syscall(parent_id,APPSERVER_SYSCALL_proc_init,id,0,0,0,&errno))
23                 panic("Front-end server couldn't initialize new process!");
24 }
25
26 // architecture-specific process termination code
27 void
28 proc_free_arch(struct proc *SAFE p)
29 {
30         int32_t errno;
31         if(frontend_syscall(0,APPSERVER_SYSCALL_proc_free,p->pid,0,0,0,&errno))
32                 panic("Front-end server couldn't free process!");
33 }
34
35 void
36 proc_init_trapframe(trapframe_t *tf, uint32_t vcoreid,
37                     uint32_t entryp, uint32_t stack_top)
38 {
39         memset(tf,0,sizeof(*tf));
40
41         tf->psr = PSR_S; // but PS = 0
42         tf->gpr[14] = stack_top-96;
43         tf->asr13 = vcoreid;
44
45         tf->pc = entryp;
46         tf->npc = entryp+4;
47 }
48
49 /* For cases that we won't return from a syscall via the normal path, and need
50  * to set the syscall return value in the registers manually.  Like in a syscall
51  * moving to RUNNING_M */
52 void proc_set_syscall_retval(trapframe_t *SAFE tf, intreg_t value)
53 {
54         tf->gpr[8] = value;
55 }