Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 #include "types.h" 00002 #include "x86.h" 00003 #include "defs.h" 00004 #include "param.h" 00005 #include "memlayout.h" 00006 #include "mmu.h" 00007 #include "proc.h" 00008 00009 int 00010 sys_fork(void) 00011 { 00012 return fork(); 00013 } 00014 00015 int 00016 sys_exit(int x) 00017 { 00018 exit(1); 00019 return 0; // not reached 00020 } 00021 00022 int 00023 sys_wait(void) 00024 { 00025 return wait(); 00026 } 00027 00028 int 00029 sys_kill(void) 00030 { 00031 int pid; 00032 00033 if(argint(0, &pid) < 0) 00034 return -1; 00035 return kill(pid); 00036 } 00037 00038 int 00039 sys_getpid(void) 00040 { 00041 return proc->pid; 00042 } 00043 00044 int 00045 sys_sbrk(void) 00046 { 00047 int addr; 00048 int n; 00049 00050 if(argint(0, &n) < 0) 00051 return -1; 00052 addr = proc->sz; 00053 if(growproc(n) < 0) 00054 return -1; 00055 return addr; 00056 } 00057 00058 int 00059 sys_sleep(void) 00060 { 00061 int n; 00062 uint ticks0; 00063 00064 if(argint(0, &n) < 0) 00065 return -1; 00066 acquire(&tickslock); 00067 ticks0 = ticks; 00068 while(ticks - ticks0 < n){ 00069 if(proc->killed){ 00070 release(&tickslock); 00071 return -1; 00072 } 00073 sleep(&ticks, &tickslock); 00074 } 00075 release(&tickslock); 00076 return 0; 00077 } 00078 00079 // return how many clock tick interrupts have occurred 00080 // since start. 00081 int 00082 sys_uptime(void) 00083 { 00084 uint xticks; 00085 00086 acquire(&tickslock); 00087 xticks = ticks; 00088 release(&tickslock); 00089 return xticks; 00090 } 00091 int 00092 sys_old_mmap(void *addr, int len, int prot, int flags, int fd, int offset){ 00093 /* returns new proc->sz on success and -1 on failure */ 00094 if(argint(1,&len) == -1) 00095 return -1; 00096 else if(!proc_old_mmap(addr,len,prot,flags,fd,offset)) 00097 return proc->sz; 00098 return -1; 00099 }