Remove the frontend appserver code
authorBarret Rhoden <brho@cs.berkeley.edu>
Sat, 16 Sep 2017 15:03:14 +0000 (11:03 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sat, 16 Sep 2017 15:03:14 +0000 (11:03 -0400)
The frontend code was for working with the RISC-V and SPARC boards.
Whenever we ever resurrect the RISC-V port, we can add support for
whatever they are using then.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
12 files changed:
kern/arch/x86/Kbuild
kern/arch/x86/frontend.c [deleted file]
kern/arch/x86/frontend.h [deleted file]
kern/include/frontend.h [deleted file]
kern/src/Kbuild
kern/src/elf.c
kern/src/frontend.c [deleted file]
kern/src/init.c
kern/src/manager.c
kern/src/mm.c
kern/src/process.c
kern/src/syscall.c

index 318bdaa..22b0ad1 100644 (file)
@@ -4,7 +4,6 @@ obj-y                                           += console.o
 obj-y                                          += cpuinfo.o
 obj-y                                          += devarch.o
 obj-y                                          += entry64.o
-obj-y                                          += frontend.o
 obj-y                                          += idle.o
 obj-y                                          += init.o
 obj-y                                          += intel.o
diff --git a/kern/arch/x86/frontend.c b/kern/arch/x86/frontend.c
deleted file mode 100644 (file)
index 5ae5dbb..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <multiboot.h>
-#include <arch/frontend.h>
-#include <kmalloc.h>
-#include <assert.h>
-
-#define debug(...) printk(__VA_ARGS__)
-
-int handle_appserver_packet(const char* p, size_t size)
-{
-
-       panic("bad appserver packet!");
-}
diff --git a/kern/arch/x86/frontend.h b/kern/arch/x86/frontend.h
deleted file mode 100644 (file)
index e54210b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2010 The Regents of the University of California
- * See LICENSE for details.
- */
-
-#pragma once
-
-#define APPSERVER_MAX_PAYLOAD_SIZE 1024
-
-#define APPSERVER_CMD_LOAD  0
-#define APPSERVER_CMD_STORE 1
-#define APPSERVER_CMD_ACK   2
-
-int handle_appserver_packet(const char *buf, size_t len);
-
-typedef struct
-{
-       uint8_t dst_mac[6];
-       uint8_t src_mac[6];
-       uint16_t ethertype;
-       uint8_t cmd;
-       uint8_t seqno;
-       uint32_t payload_size;
-       uint32_t addr;
-} appserver_packet_header_t;
-
-typedef struct
-{
-       appserver_packet_header_t header;
-       uint8_t payload[APPSERVER_MAX_PAYLOAD_SIZE];
-} appserver_packet_t;
diff --git a/kern/include/frontend.h b/kern/include/frontend.h
deleted file mode 100644 (file)
index 7946657..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#pragma once
-
-#include <ros/common.h>
-
-#ifdef ROS_KERNEL
-
-#include <env.h>
-#include <vfs.h>
-#include <process.h>
-
-// Default APPSERVER_ETH_TYPE if not defined externally
-#ifndef APPSERVER_ETH_TYPE
-#define APPSERVER_ETH_TYPE 0x8888
-#endif
-
-void frontend_proc_init(struct proc* p);
-void frontend_proc_free(struct proc* p);
-
-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 frontend_syscall_errno(struct proc* p, int n, int a0,
-                           int a1, int a2, int a3);
-
-void file_init(void);
-error_t file_read_page(struct file* f, physaddr_t pa, size_t pgoff);
-struct file* file_open(const char* path, int oflag, int mode);
-struct file* file_open_from_fd(struct proc* p, int fd);
-void file_incref(struct file* f);
-void file_decref(struct file* f);
-
-#endif
-
-#define APPSERVER_MAXPATH            1024
-
-#define APPSERVER_SYSCALL_exit          1
-#define APPSERVER_SYSCALL_read          3
-#define APPSERVER_SYSCALL_write         4
-#define APPSERVER_SYSCALL_open          5
-#define APPSERVER_SYSCALL_close         6
-#define APPSERVER_SYSCALL_link          9
-#define APPSERVER_SYSCALL_unlink       10
-#define APPSERVER_SYSCALL_chdir        12
-#define APPSERVER_SYSCALL_chmod        15
-#define APPSERVER_SYSCALL_brk          17
-#define APPSERVER_SYSCALL_stat         18
-#define APPSERVER_SYSCALL_lseek        19
-#define APPSERVER_SYSCALL_fstat        28
-#define APPSERVER_SYSCALL_utime        30
-#define APPSERVER_SYSCALL_access       33
-#define APPSERVER_SYSCALL_dup          41
-#define APPSERVER_SYSCALL_umask        60
-#define APPSERVER_SYSCALL_fcntl        62
-#define APPSERVER_SYSCALL_kdup         87
-#define APPSERVER_SYSCALL_lstat        88
-#define APPSERVER_SYSCALL_tcgetattr    89
-#define APPSERVER_SYSCALL_tcsetattr    90
-#define APPSERVER_SYSCALL_closedir     91
-#define APPSERVER_SYSCALL_rewinddir    92
-#define APPSERVER_SYSCALL_readdir      93
-#define APPSERVER_SYSCALL_opendir      94
-#define APPSERVER_SYSCALL_dup2         95
-#define APPSERVER_SYSCALL_proc_free    96
-#define APPSERVER_SYSCALL_proc_init    97
-#define APPSERVER_SYSCALL_time         98
-#define APPSERVER_SYSCALL_pread       173
-#define APPSERVER_SYSCALL_pwrite      174
-#define APPSERVER_SYSCALL_getcwd      229
index b0b94cc..22dbbc9 100644 (file)
@@ -47,7 +47,6 @@ obj-y                                         += fdtap.o
 obj-$(CONFIG_COREALLOC_FCFS) += corealloc_fcfs.o
 obj-y                                          += find_next_bit.o
 obj-y                                          += find_last_bit.o
-obj-y                                          += frontend.o
 obj-y                                          += hashtable.o
 obj-y                                          += hexdump.o
 obj-y                                          += init.o
index 233b202..a287bb3 100644 (file)
@@ -1,5 +1,4 @@
 #include <mm.h>
-#include <frontend.h>
 #include <string.h>
 #include <kmalloc.h>
 #include <syscall.h>
diff --git a/kern/src/frontend.c b/kern/src/frontend.c
deleted file mode 100644 (file)
index 43554ce..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-#include <atomic.h>
-#include <process.h>
-#include <kmalloc.h>
-#include <pmap.h>
-#include <frontend.h>
-#include <syscall.h>
-#include <smp.h>
-#include <slab.h>
-#include <arch/arch.h>
-
-volatile int magic_mem[10];
-
-void
-frontend_proc_init(struct proc *p)
-{
-#ifdef CONFIG_APPSERVER
-       pid_t parent_id = p->ppid, id = p->pid;
-       int32_t errno;
-       if(frontend_syscall(parent_id,APPSERVER_SYSCALL_proc_init,id,0,0,0,&errno))
-               panic("Front-end server couldn't initialize new process!");
-#endif
-}
-
-void
-frontend_proc_free(struct proc *p)
-{
-#ifdef CONFIG_APPSERVER
-       int32_t errno;
-       if(frontend_syscall(0,APPSERVER_SYSCALL_proc_free,p->pid,0,0,0,&errno))
-               panic("Front-end server couldn't free process!");
-#endif
-}
-
-struct kmem_cache* struct_file_cache;
-void file_init()
-{
-       struct_file_cache = kmem_cache_create("struct_file",
-                                             sizeof(struct file), 8, 0,
-                                             NULL, 0, 0, NULL);
-}
-
-/* will zero anything in the page after the EOF */
-error_t file_read_page(struct file* f, physaddr_t pa, size_t pgoff)
-{
-       int ret = frontend_syscall(0,APPSERVER_SYSCALL_pread,f->fd,pa,PGSIZE,
-                                  pgoff*PGSIZE,NULL);
-       if(ret >= 0)
-               memset(KADDR(pa)+ret,0,PGSIZE-ret);
-       return ret;
-}
-
-struct file* file_open_from_fd(struct proc* p, int fd)
-{
-       struct file* f = NULL;
-       if(!(f = kmem_cache_alloc(struct_file_cache,0)))
-               goto out;
-
-       f->fd = frontend_syscall(p->pid,APPSERVER_SYSCALL_kdup,fd,0,0,0,NULL);
-       if(f->fd == -1)
-       {
-               kmem_cache_free(struct_file_cache,f);
-               f = NULL;
-               goto out;
-       }
-       spinlock_init(&f->lock);
-       f->refcnt = 1;
-
-out:
-       return f;
-}
-
-struct file* file_open(const char* path, int oflag, int mode)
-{
-       struct file* f = NULL;
-       // although path is a kernel pointer, it may be below KERNBASE.
-       // fix that if so.
-       char* malloced = NULL;
-       if((uintptr_t)path < KERNBASE)
-       {
-               size_t len = strlen(path)+1;
-               malloced = kmalloc(len,0);
-               if(!malloced)
-                       goto out;
-               path = memcpy(malloced,path,len);
-       }
-
-       if(!(f = kmem_cache_alloc(struct_file_cache,0)))
-               goto out;
-
-       f->fd = frontend_syscall(0,APPSERVER_SYSCALL_open,PADDR(path),
-                                oflag,mode,0,NULL);
-       if(f->fd == -1)
-       {
-               kmem_cache_free(struct_file_cache,f);
-               f = NULL;
-               goto out;
-       }
-       spinlock_init(&f->lock);
-       f->refcnt = 1;
-
-out:
-       if(malloced)
-               kfree(malloced);
-       return f;
-}
-
-void file_incref(struct file* f)
-{
-       spin_lock(&f->lock);
-       f->refcnt++;
-       spin_unlock(&f->lock);
-}
-
-void file_decref(struct file* f)
-{
-       // if you decref too many times, you'll clobber memory :(
-       spin_lock(&f->lock);
-       if(--f->refcnt == 0)
-       {
-               int ret = frontend_syscall(0,APPSERVER_SYSCALL_close,f->fd,0,0,0,NULL);
-               assert(ret == 0);
-               kmem_cache_free(struct_file_cache,f);
-       }
-       else
-               spin_unlock(&f->lock);
-}
-
-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)
-               set_errno(errno);
-       return ret;
-}
-
-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)
-{
-#ifndef CONFIG_APPSERVER
-       warn("No appserver support, requested syscall %d for proc %d", syscall_num,
-            pid);
-       if(errno)
-               *errno = ENOSYS;
-       return -1;
-#endif
-
-#ifdef CONFIG_X86
-       if (!irq_is_enabled())
-               warn("IRQ is disabled in frontend_syscall %d for proc %d\n", syscall_num, pid);
-#endif
-
-       static spinlock_t lock = SPINLOCK_INITIALIZER;
-       int32_t ret;
-
-       // only one frontend request at a time.
-       // interrupts could try to do frontend requests,
-       // which would deadlock, so disable them
-       spin_lock(&lock);
-
-       // write syscall into magic memory
-       magic_mem[7] = 0;
-       magic_mem[1] = syscall_num;
-       magic_mem[2] = arg0;
-       magic_mem[3] = arg1;
-       magic_mem[4] = arg2;
-       magic_mem[5] = arg3;
-       magic_mem[6] = pid;
-       magic_mem[0] = 0x80;
-
-       // wait for front-end response
-       while(magic_mem[7] == 0)
-               ;
-
-       ret = magic_mem[1];
-       if(errno)
-               *errno = magic_mem[2];
-
-       spin_unlock(&lock);
-
-       return ret;
-}
-
-void __diediedie(uint32_t srcid, uint32_t code, uint32_t a1, uint32_t a2)
-{
-       int32_t errno;
-       frontend_syscall(0,APPSERVER_SYSCALL_exit,(int)code,0,0,0,&errno);
-       while(1);
-}
-
-void appserver_die(uintptr_t code)
-{
-       int i;
-       for(i = 0; i < num_cores; i++)
-               if(i != core_id())
-                       while(send_kernel_message(i, (amr_t)&__diediedie, code, 0, 0,
-                                                 KMSG_IMMEDIATE));
-
-       // just in case.
-       __diediedie(0, code, 0, 0);
-}
index 8e3a70b..935e569 100644 (file)
@@ -27,7 +27,6 @@
 #include <hashtable.h>
 #include <radix.h>
 #include <mm.h>
-#include <frontend.h>
 #include <ex_table.h>
 #include <percpu.h>
 
@@ -149,7 +148,6 @@ void kernel_init(multiboot_info_t *mboot_info)
        percpu_init();
        kthread_init();                                 /* might need to tweak when this happens */
        vmr_init();
-       file_init();
        page_check();
        idt_init();
        /* After kthread_init and idt_init, we can use a real kstack. */
index 9004b21..e190ca7 100644 (file)
@@ -10,7 +10,6 @@
 #include <arch/init.h>
 #include <mm.h>
 #include <elf.h>
-#include <frontend.h>
 
 #include <kmalloc.h>
 #include <assert.h>
index 906d297..8fde0ba 100644 (file)
@@ -13,7 +13,6 @@
  * Note that if we were called from kern/src/syscall.c, we probably don't have
  * an edible reference to p. */
 
-#include <frontend.h>
 #include <ros/common.h>
 #include <pmap.h>
 #include <mm.h>
index f8c80ed..898262d 100644 (file)
@@ -19,7 +19,6 @@
 #include <hashtable.h>
 #include <slab.h>
 #include <sys/queue.h>
-#include <frontend.h>
 #include <monitor.h>
 #include <elf.h>
 #include <arsc_server.h>
@@ -451,7 +450,6 @@ error_t proc_alloc(struct proc **pp, struct proc *parent, int flags)
        hashlock_init_irqsave(p->ucq_hashlock, HASHLOCK_DEFAULT_SZ);
 
        atomic_inc(&num_envs);
-       frontend_proc_init(p);
        plan9setup(p, parent, flags);
        devalarm_init(p);
        TAILQ_INIT(&p->abortable_sleepers);
@@ -528,7 +526,6 @@ static void __proc_free(struct kref *kref)
        kref_put(&p->fs_env.pwd->d_kref);
        /* now we'll finally decref files for the file-backed vmrs */
        unmap_and_destroy_vmrs(p);
-       frontend_proc_free(p);  /* TODO: please remove me one day */
        /* Remove us from the pid_hash and give our PID back (in that order). */
        spin_lock(&pid_hash_lock);
        hash_ret = hashtable_remove(pid_hash, (void*)(long)p->pid);
index 64ed4c5..d4ffa34 100644 (file)
@@ -23,7 +23,6 @@
 #include <kmalloc.h>
 #include <profiler.h>
 #include <stdio.h>
-#include <frontend.h>
 #include <hashtable.h>
 #include <bitmask.h>
 #include <vfs.h>
@@ -1735,11 +1734,6 @@ static intreg_t sys_close(struct proc *p, int fd)
        return retval;
 }
 
-/* kept around til we remove the last ufe */
-#define ufe(which,a0,a1,a2,a3) \
-       frontend_syscall_errno(p,APPSERVER_SYSCALL_##which,\
-                          (int)(a0),(int)(a1),(int)(a2),(int)(a3))
-
 static intreg_t sys_fstat(struct proc *p, int fd, struct kstat *u_stat)
 {
        struct kstat *kbuf;