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 <[email protected]> --- kern/arch/x86/Kbuild | 1 - kern/arch/x86/frontend.c | 12 --- kern/arch/x86/frontend.h | 31 -------- kern/include/frontend.h | 69 ---------------- kern/src/Kbuild | 1 - kern/src/elf.c | 1 - kern/src/frontend.c | 201 ----------------------------------------------- kern/src/init.c | 2 - kern/src/manager.c | 1 - kern/src/mm.c | 1 - kern/src/process.c | 3 - kern/src/syscall.c | 6 -- 12 files changed, 329 deletions(-) delete mode 100644 kern/arch/x86/frontend.c delete mode 100644 kern/arch/x86/frontend.h delete mode 100644 kern/include/frontend.h delete mode 100644 kern/src/frontend.c diff --git a/kern/arch/x86/Kbuild b/kern/arch/x86/Kbuild index 318bdaa49d04..22b0ad10525d 100644 --- a/kern/arch/x86/Kbuild +++ b/kern/arch/x86/Kbuild @@ -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 index 5ae5dbbc74d3..000000000000 --- a/kern/arch/x86/frontend.c +++ /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 index e54210b139b1..000000000000 --- a/kern/arch/x86/frontend.h +++ /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 index 79466574d118..000000000000 --- a/kern/include/frontend.h +++ /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 diff --git a/kern/src/Kbuild b/kern/src/Kbuild index b0b94ccb07b8..22dbbc9a34b3 100644 --- a/kern/src/Kbuild +++ b/kern/src/Kbuild @@ -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 diff --git a/kern/src/elf.c b/kern/src/elf.c index 233b202cc856..a287bb3ab169 100644 --- a/kern/src/elf.c +++ b/kern/src/elf.c @@ -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 index 43554cedab20..000000000000 --- a/kern/src/frontend.c +++ /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); -} diff --git a/kern/src/init.c b/kern/src/init.c index 8e3a70bf1a4b..935e56990688 100644 --- a/kern/src/init.c +++ b/kern/src/init.c @@ -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. */ diff --git a/kern/src/manager.c b/kern/src/manager.c index 9004b218f88f..e190ca7632d6 100644 --- a/kern/src/manager.c +++ b/kern/src/manager.c @@ -10,7 +10,6 @@ #include <arch/init.h> #include <mm.h> #include <elf.h> -#include <frontend.h> #include <kmalloc.h> #include <assert.h> diff --git a/kern/src/mm.c b/kern/src/mm.c index 906d297f8d4c..8fde0ba7ce90 100644 --- a/kern/src/mm.c +++ b/kern/src/mm.c @@ -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> diff --git a/kern/src/process.c b/kern/src/process.c index f8c80edfb1cf..898262dcefb2 100644 --- a/kern/src/process.c +++ b/kern/src/process.c @@ -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); diff --git a/kern/src/syscall.c b/kern/src/syscall.c index 64ed4c567ec9..d4ffa345e415 100644 --- a/kern/src/syscall.c +++ b/kern/src/syscall.c @@ -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; -- 2.13.2 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
