diff --git a/sys/i386/Makefile b/sys/i386/Makefile index 39947fd..1e3207d 100644 --- a/sys/i386/Makefile +++ b/sys/i386/Makefile @@ -6,7 +6,7 @@ include ../Makefile.incl # Objects -OBJS = support.o strcpy.o strcmp.o strncmp.o memset.o memcmp.o schedyield.o kpanic.o timer.o spinlock.o i386_exec.o sys_call_new.o sys_call.o syscall.o bioscall.o fork.o systemtask.o sched.o cpu.o trap.o +OBJS = support.o strcpy.o strcmp.o strncmp.o memset.o memcmp.o schedyield.o kpanic.o timer.o spinlock.o i386_exec.o sys_call_new.o sys_call.o bioscall.o fork.o systemtask.o sched.o cpu.o trap.o # ap-boot.o smp.o vitals.o(obsolete) all: $(OBJS) diff --git a/sys/i386/syscall.c b/sys/i386/syscall.c deleted file mode 100644 index 82cad2d..0000000 --- a/sys/i386/syscall.c +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* #include */ -#include -#include - -//long fuword( const void *base ); - -//void sdeTestThread(); - -int InvalidSystemCall() { - kprintf("attempt was made to an invalid system call\n"); - return (0); -} - -typedef struct _UbixUser UbixUser; -struct _UbixUser { - char *username; - char *password; - int uid; - int gid; - char *home; - char *shell; -}; - -int sysAuth(UbixUser *uu) { - kprintf("authenticating user %s\n", uu->username); - - /* MrOlsen 2016-01-01 uh? - if(uu->username == "root" && uu->password == "user") - { - uu->uid = 0; - uu->gid = 0; - } - */ - uu->uid = -1; - uu->gid = -1; - return (0); -} - -int sysPasswd(char *passwd) { - kprintf("changing user password for user %d\n", _current->uid); - return (0); -} - -int sysAddModule() { - return (0); -} - -int sysRmModule() { - return (0); -} - -int sysGetpid(int *pid) { - if (pid) - *pid = _current->id; - return (0); -} - -int sysExit(int status) { - endTask(_current->id); - return (0x0); -} - -int sysCheckPid(int pid, int *ptr) { - kTask_t *tmpTask = schedFindTask(pid); - if ((tmpTask != 0x0) && (ptr != 0x0)) - *ptr = tmpTask->state; - else - *ptr = 0x0; - return (0); -} - -/************************************************************************ - - Function: int sysGetFreePage(); - Description: Allocs A Page To The Users VM Space - Notes: - - ************************************************************************/ -int sysGetFreePage(struct thread *td, uint32_t *count) { - //MrOlsen 2017-12-15 kprintf("sysGetFreePage - Count: %i\n", *count); - return ((int) vmm_getFreeVirtualPage(_current->id, *count, VM_THRD)); - //return(vmm_getFreeVirtualPage(_current->id, *count, VM_TASK)); -} - -int sysGetFreePage_OLD(long *ptr, int count, int type) { - if (ptr) { - if (type == 2) - *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_THRD); - else - *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_TASK); - } - return (0); -} - -int sysGetDrives(uInt32 *ptr) { - if (ptr) - *ptr = 0x0; //(uInt32)devices; - return (0); -} - -int sysGetUptime(uInt32 *ptr) { - if (ptr) - *ptr = systemVitals->sysTicks; - return (0); -} - -int sysGetTime(uInt32 *ptr) { - if (ptr) - *ptr = systemVitals->sysUptime + systemVitals->timeStart; - return (0); -} - -int sys_getcwd(struct thread *td, struct sys_getcwd_args *args) { - char *buf = (char *) args->buf; - //kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); - if (args->buf) { - sprintf(buf, "%s", _current->oInfo.cwd); - buf[strlen(_current->oInfo.cwd)] = '\0'; - //MrOlsen (2018-01-01) - Why is sprintf not null terminating - } - // kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); - // kprintf("[%s]", args->buf); - return (0); -} - -int sys_sched_yield(struct thread *td, void *args) { - sched_yield(); - return (0); -} - -int sysStartSDE() { - int i = 0x0; - for (i = 0; i < 1400; i++) { - asm("hlt"); - } - //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); - for (i = 0; i < 1400; i++) { - asm("hlt"); - } - return (0); -} diff --git a/sys/include/ubixos/syscall.h b/sys/include/ubixos/syscall.h index e24253a..09867a2 100644 --- a/sys/include/ubixos/syscall.h +++ b/sys/include/ubixos/syscall.h @@ -26,38 +26,14 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYSCALL_H -#define _SYSCALL_H +#ifndef _UBIXOS_SYSCALL_H +#define _UBIXOS_SYSCALL_H #include -void _sysCall(); -void _sysCall_new(); +void _sys_call(); +void sys_call(struct trapframe *frame) int invalidCall(); void invalidCallINT(int); #endif - -/*** - $Log: syscall.h,v $ - Revision 1.2 2006/10/26 23:52:02 reddawg - Cleaned - - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:56 reddawg - no message - - Revision 1.3 2004/07/05 23:06:32 reddawg - Fixens - - Revision 1.2 2004/05/21 15:20:00 reddawg - Cleaned up - - - END - ***/ diff --git a/sys/include/ubixos/syscall_posix.h b/sys/include/ubixos/syscall_posix.h new file mode 100644 index 0000000..f1bb998 --- /dev/null +++ b/sys/include/ubixos/syscall_posix.h @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_SYSCALL_POXIX_H +#define _UBIXOS_SYSCALL_POSIX_H + +void _sys_call_posix(); +void sys_call_posix(struct trapframe *frame) + +#endif diff --git a/sys/kernel/Makefile b/sys/kernel/Makefile index 622e23a..97b965d 100644 --- a/sys/kernel/Makefile +++ b/sys/kernel/Makefile @@ -6,7 +6,7 @@ include ../Makefile.incl # Objects -OBJS = vfs_calls.o tty.o kern_sig.o pipe.o kern_descrip.o kern_sysctl.o gen_calls.o endtask.o ld.o time.o syscall_new.o elf.o ubthread.o vitals.o access.o syscalls.o execve.o +OBJS = vfs_calls.o tty.o kern_sig.o pipe.o kern_descrip.o kern_sysctl.o gen_calls.o endtask.o ld.o time.o syscall_new.o elf.o ubthread.o vitals.o access.o syscall.o syscalls.o execve.o #OBJS += ../${_ARCH}/schedyield.o ../${_ARCH}/kpanic.o ../${_ARCH}/timer.o ../${_ARCH}/spinlock.o ../${_ARCH}/exec.o ../${_ARCH}/sys_call_new.o ../${_ARCH}/sys_call.o ../${_ARCH}/bioscall.o ../${_ARCH}/fork.o ../${_ARCH}/syscall.o ../${_ARCH}/systemtask.o ../${_ARCH}/sched.o ../${_ARCH}/cpu.o # ap-boot.o smp.o vitals.o(obsolete) diff --git a/sys/kernel/syscall.c b/sys/kernel/syscall.c new file mode 100644 index 0000000..82cad2d --- /dev/null +++ b/sys/kernel/syscall.c @@ -0,0 +1,183 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/* #include */ +#include +#include + +//long fuword( const void *base ); + +//void sdeTestThread(); + +int InvalidSystemCall() { + kprintf("attempt was made to an invalid system call\n"); + return (0); +} + +typedef struct _UbixUser UbixUser; +struct _UbixUser { + char *username; + char *password; + int uid; + int gid; + char *home; + char *shell; +}; + +int sysAuth(UbixUser *uu) { + kprintf("authenticating user %s\n", uu->username); + + /* MrOlsen 2016-01-01 uh? + if(uu->username == "root" && uu->password == "user") + { + uu->uid = 0; + uu->gid = 0; + } + */ + uu->uid = -1; + uu->gid = -1; + return (0); +} + +int sysPasswd(char *passwd) { + kprintf("changing user password for user %d\n", _current->uid); + return (0); +} + +int sysAddModule() { + return (0); +} + +int sysRmModule() { + return (0); +} + +int sysGetpid(int *pid) { + if (pid) + *pid = _current->id; + return (0); +} + +int sysExit(int status) { + endTask(_current->id); + return (0x0); +} + +int sysCheckPid(int pid, int *ptr) { + kTask_t *tmpTask = schedFindTask(pid); + if ((tmpTask != 0x0) && (ptr != 0x0)) + *ptr = tmpTask->state; + else + *ptr = 0x0; + return (0); +} + +/************************************************************************ + + Function: int sysGetFreePage(); + Description: Allocs A Page To The Users VM Space + Notes: + + ************************************************************************/ +int sysGetFreePage(struct thread *td, uint32_t *count) { + //MrOlsen 2017-12-15 kprintf("sysGetFreePage - Count: %i\n", *count); + return ((int) vmm_getFreeVirtualPage(_current->id, *count, VM_THRD)); + //return(vmm_getFreeVirtualPage(_current->id, *count, VM_TASK)); +} + +int sysGetFreePage_OLD(long *ptr, int count, int type) { + if (ptr) { + if (type == 2) + *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_THRD); + else + *ptr = (long) vmm_getFreeVirtualPage(_current->id, count, VM_TASK); + } + return (0); +} + +int sysGetDrives(uInt32 *ptr) { + if (ptr) + *ptr = 0x0; //(uInt32)devices; + return (0); +} + +int sysGetUptime(uInt32 *ptr) { + if (ptr) + *ptr = systemVitals->sysTicks; + return (0); +} + +int sysGetTime(uInt32 *ptr) { + if (ptr) + *ptr = systemVitals->sysUptime + systemVitals->timeStart; + return (0); +} + +int sys_getcwd(struct thread *td, struct sys_getcwd_args *args) { + char *buf = (char *) args->buf; + //kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); + if (args->buf) { + sprintf(buf, "%s", _current->oInfo.cwd); + buf[strlen(_current->oInfo.cwd)] = '\0'; + //MrOlsen (2018-01-01) - Why is sprintf not null terminating + } + // kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); + // kprintf("[%s]", args->buf); + return (0); +} + +int sys_sched_yield(struct thread *td, void *args) { + sched_yield(); + return (0); +} + +int sysStartSDE() { + int i = 0x0; + for (i = 0; i < 1400; i++) { + asm("hlt"); + } + //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + for (i = 0; i < 1400; i++) { + asm("hlt"); + } + return (0); +} diff --git a/sys/kernel/syscall_new.c b/sys/kernel/syscall_new.c index 8f08310..723f5b2 100644 --- a/sys/kernel/syscall_new.c +++ b/sys/kernel/syscall_new.c @@ -39,14 +39,14 @@ struct spinLock Master = SPIN_LOCK_INITIALIZER; -void syscall(struct trapframe *frame) { +void sys_call_posix(struct trapframe *frame) { uint32_t code = 0x0; caddr_t params; /* - if (_current->id == 6) - kprintf("SYSCALL: 0x%X.", frame->tf_eip); - */ + if (_current->id == 6) + kprintf("SYSCALL: 0x%X.", frame->tf_eip); + */ struct thread *td = &_current->td; @@ -120,9 +120,9 @@ } } /* - if (_current->id == 6) - kprintf("SYSCALL-EXIT"); - */ + if (_current->id == 6) + kprintf("SYSCALL-EXIT"); + */ } int invalidCall() { diff --git a/sys/sys/idt.c b/sys/sys/idt.c index 5d77250..f0c7496 100644 --- a/sys/sys/idt.c +++ b/sys/sys/idt.c @@ -26,6 +26,8 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -98,8 +99,8 @@ setVector(_int12, 12, dPresent + dInt + dDpl0); setTaskVector(13, dPresent + dTask + dDpl0, 0x38); setVector(_vmm_pageFault, 14, dPresent + dInt + dDpl0); - setVector(_sysCall, 0x80, dPresent + dTrap + dDpl3); - setVector(_sysCall_new, 0x81, dPresent + dTrap + dDpl3); + setVector(_sys_call_posix, 0x80, dPresent + dTrap + dDpl3); + setVector(_sys_call, 0x81, dPresent + dTrap + dDpl3); //setVector(_sysCallNew, 0x90, dPresent + dTrap + dDpl3); setVector(timerInt, 0x68, (dInt + dPresent + dDpl0));