Cleaned up front-end code a bit
authorKevin Klues <klueska@ros-dev.(none)>
Thu, 25 Mar 2010 00:59:10 +0000 (17:59 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:37 +0000 (17:35 -0700)
More consistent function names; unnecessary functions removed

kern/include/frontend.h
kern/include/ros/syscall.h
kern/src/frontend.c
kern/src/syscall.c

index 35d1974..ee24588 100644 (file)
 void frontend_proc_init(struct proc* p);
 void frontend_proc_free(struct proc* p);
 
-int32_t frontend_syscall_from_user(env_t* p, int32_t syscall_num, 
-                                   uint32_t arg0, uint32_t arg1, 
-                                   uint32_t arg2, uint32_t translate_args);
-
 int32_t frontend_syscall(pid_t pid, int32_t syscall_num, 
                          uint32_t arg0, uint32_t arg1, uint32_t arg2, 
                          uint32_t arg3, int32_t* errno);
 
-int user_frontend_syscall(struct proc* p, int n, int a0, 
-                          int a1, int a2, int a3);
-
-int32_t frontend_nbputch(char ch);
-int32_t frontend_nbgetch();
+int frontend_syscall_errno(struct proc* p, int n, int a0, 
+                           int a1, int a2, int a3);
 
 void* user_memdup(struct proc* p, const void* va, int len);
 void* user_memdup_errno(struct proc* p, const void* va, int len);
index 63366a4..fbcf46e 100644 (file)
@@ -39,7 +39,6 @@
 #define SYS_eth_write                          28
 #define SYS_eth_get_mac_addr                   29
 #define SYS_eth_recv_check                     30
-#define SYS_frontend                           31
 
 #define SYS_read                               100
 #define SYS_write                              101
index e3d2b97..75e6f80 100644 (file)
@@ -148,7 +148,7 @@ error_t close_file(struct proc* p, int fd)
        return frontend_syscall(p->pid,APPSERVER_SYSCALL_close,fd,0,0,0,&errno);
 }
 
-int user_frontend_syscall(struct proc* p, int n, int a0, int a1, int a2, int a3)
+int frontend_syscall_errno(struct proc* p, int n, int a0, int a1, int a2, int a3)
 {
        int errno, ret = frontend_syscall(p->pid,n,a0,a1,a2,a3,&errno);
        if(errno && p)
@@ -190,38 +190,6 @@ int32_t frontend_syscall(pid_t pid, int32_t syscall_num,
        return ret;
 }
 
-int32_t frontend_nbputch(char ch)
-{
-       static spinlock_t putch_lock = SPINLOCK_INITIALIZER;
-       spin_lock_irqsave(&putch_lock);
-
-       int ret = -1;
-       if(magic_mem[8] == 0)
-       {
-               magic_mem[8] = (unsigned int)(unsigned char)ch;
-               ret = 0;
-       }
-
-       spin_unlock_irqsave(&putch_lock);
-       return ret;
-}
-
-int32_t frontend_nbgetch()
-{
-       static spinlock_t getch_lock = SPINLOCK_INITIALIZER;
-       spin_lock_irqsave(&getch_lock);
-
-       int result = -1;
-       if(magic_mem[9]) 
-       {
-               result = magic_mem[9];
-               magic_mem[9] = 0;
-       }
-
-       spin_unlock_irqsave(&getch_lock);
-       return result;
-}
-
 void __diediedie(trapframe_t* tf, uint32_t srcid, uint32_t code, uint32_t a1, uint32_t a2)
 {
        int32_t errno;
index 836cd2e..da62c0a 100644 (file)
@@ -681,41 +681,9 @@ static int sys_eth_recv_check(env_t* e)
 
 // Syscalls below here are serviced by the appserver for now.
 #define ufe(which,a0,a1,a2,a3) \
-       user_frontend_syscall(p,APPSERVER_SYSCALL_##which,\
+       frontend_syscall_errno(p,APPSERVER_SYSCALL_##which,\
                           (int)(a0),(int)(a1),(int)(a2),(int)(a3))
 
-int32_t sys_frontend(env_t* p, int32_t syscall_num, 
-                     uint32_t arg0, uint32_t arg1, 
-                     uint32_t arg2, uint32_t translate_args)
-{
-       // really, we just want to pin pages, but irqdisable works
-       static spinlock_t lock = SPINLOCK_INITIALIZER;
-       spin_lock_irqsave(&lock);
-
-       uint32_t arg[3] = {arg0,arg1,arg2};
-       for(int i = 0; i < 3; i++)
-       {
-               int flags = (translate_args & (1 << (i+3))) ? PTE_USER_RW :
-                          ((translate_args & (1 << i)) ? PTE_USER_RO : 0);
-               if(flags)
-               {
-                       pte_t* pte = pgdir_walk(p->env_pgdir,(void*)arg[i],0);
-                       if(pte == NULL || !(*pte & flags))
-                       {
-                               spin_unlock_irqsave(&lock);
-                               return -1;
-                       }
-                       arg[i] = PTE_ADDR(*pte) | PGOFF(arg[i]);
-               }
-       }
-
-       int32_t ret = user_frontend_syscall(p,syscall_num,arg[0],arg[1],arg[2],0);
-
-       spin_unlock_irqsave(&lock);
-       return ret;
-}
-
-
 intreg_t sys_write(struct proc* p, int fd, const void* buf, int len)
 {
        void* kbuf = user_memdup_errno(p,buf,len);
@@ -993,7 +961,6 @@ intreg_t syscall(struct proc *p, uintreg_t syscallno, uintreg_t a1,
                [SYS_eth_recv_check] = (syscall_t)sys_eth_recv_check,
        #endif
                // Syscalls serviced by the appserver for now.
-               [SYS_frontend] = (syscall_t)sys_frontend,
                [SYS_read] = (syscall_t)sys_read,
                [SYS_write] = (syscall_t)sys_write,
                [SYS_open] = (syscall_t)sys_open,