diff --git a/BUGS b/BUGS index 849bcf3..44a44c7 100644 --- a/BUGS +++ b/BUGS @@ -2,6 +2,8 @@ Bugs: +10/27/06 - NEED TO IMPLIMENT ENV!!!! + 10/12/06 - Tempermental Keyboard Driver diff --git a/Makefile b/Makefile index d433aec..ff3b324 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,18 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: kernel ubix_api libc_old libc ubix libcpp bin tools +all: kernel csu ubix_api libc_old libc ubix libcpp bin tools # depend kernel tools +csu: src + (cd src/lib/csu;make) + ubix_api: src (cd src/lib/ubix_api;make) + libc_old: src (cd src/lib/libc_old;make) + libc: src (cd src/lib/libc;make) @@ -43,6 +48,7 @@ clean: (cd src/sys;make clean) + (cd src/lib/cvs;make clean) (cd src/lib/ubix_api;make clean) (cd src/lib/libc_old;make clean) (cd src/lib/libc;make clean) diff --git a/src/bin/clock/main.c b/src/bin/clock/main.c index 57f9fe6..3ee83be 100644 --- a/src/bin/clock/main.c +++ b/src/bin/clock/main.c @@ -90,7 +90,7 @@ sysTime -= (min*MINUTE); sec = sysTime; - printf("[%02d/%02d/%i, %02d:%02d.%02d]\n",month,day,year,hour,min,sec); + printf("[%s][%02d/%02d/%i, %02d:%02d.%02d]\n",argv[0],month,day,year,hour,min,sec); return(0); } diff --git a/src/bin/edit/Makefile b/src/bin/edit/Makefile index bdc3aa6..4743ca9 100644 --- a/src/bin/edit/Makefile +++ b/src/bin/edit/Makefile @@ -21,6 +21,8 @@ LIBRARIES = ../../lib/libc/libc.so +STARTUP = ../../lib/csu/*.o + # Link The Binary $(BINARY) : $(OBJS) $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) diff --git a/src/bin/ld/addlibrary.c b/src/bin/ld/addlibrary.c index 0713b93..d8330d9 100644 --- a/src/bin/ld/addlibrary.c +++ b/src/bin/ld/addlibrary.c @@ -30,7 +30,7 @@ } sprintf(tmpLib->name,lib); } - + printf("Base: [0x%X]\n",tmpLib->output); if (tmpLib->linkerHeader == 0x0) { fseek(linkerFd,0x0,0x0); if ((tmpLib->linkerHeader = (elfHeader *)malloc(sizeof(elfHeader))) == 0x0) { @@ -59,9 +59,11 @@ case PT_GNU_STACK: /* Tells us if the stack should be executable. Failsafe to executable until we add checking */ + printf("NOT DEF1\n"); break; case PT_PAX_FLAGS: /* Not sure... */ + printf("NOT DEF2\n"); break; default: printf("Unhandled Header (ld.so) : %08x\n", tmpLib->linkerProgramHeader[i].phType); diff --git a/src/bin/ld/findfunc.c b/src/bin/ld/findfunc.c index dd85313..d0d4516 100644 --- a/src/bin/ld/findfunc.c +++ b/src/bin/ld/findfunc.c @@ -18,7 +18,7 @@ if (!strcmp(func,(libPtr->linkerDynStr + libPtr->linkerRelSymTab[i].dynName))) { funcPtr = (uInt32 *)((uInt32)(libPtr->linkerRelSymTab[i].dynValue) + (uInt32)libPtr->output); if (funcPtr == 0x0) { - printf("[%s]\n",func); + printf("[%s:0x%X]\n",func,funcPtr); } return((uInt32)funcPtr); break; diff --git a/src/bin/shell/input.c b/src/bin/shell/input.c index 7b57d7f..672781d 100644 --- a/src/bin/shell/input.c +++ b/src/bin/shell/input.c @@ -56,12 +56,13 @@ } } - buffer->argv = (char **)malloc(4*buffer->argc); + buffer->argv = (char **)malloc(4*(buffer->argc * 1)); tmpArgs = buffer->args; for (i=0;iargc;i++) { buffer->argv[i] = tmpArgs->arg; tmpArgs = tmpArgs->next; } + buffer->argv[i] = 0x0; } void freeArgs(inputBuffer *ptr) { diff --git a/src/sys/kernel/Makefile b/src/sys/kernel/Makefile index b025135..c62788b 100644 --- a/src/sys/kernel/Makefile +++ b/src/sys/kernel/Makefile @@ -6,7 +6,7 @@ include ../Makefile.inc # Objects -OBJS = kern_descrip.o kernsysctl.o gen_calls.o schedyield.o tty.o sys_call_new.o sys_call.o endtask.o spinlock.o bioscall.o ld.o time.o fork.o syscall.o elf.o systemtask.o exec.o sched.o kpanic.o vitals.o ubthread.o timer.o +OBJS = pipe.o kern_descrip.o kernsysctl.o gen_calls.o schedyield.o tty.o sys_call_new.o sys_call.o endtask.o spinlock.o bioscall.o ld.o time.o fork.o syscall.o syscall_new.o elf.o systemtask.o exec.o sched.o kpanic.o vitals.o ubthread.o timer.o # ap-boot.o smp.o all: $(OBJS) diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index fb488d5..c948f4e 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -232,7 +232,8 @@ kpanic("Error: vmmFindFreePage Failed\n"); memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); } - _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->oInfo.vmStart = 0x80000000;//((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->td.vm_daddr = (programHeader[i].phVaddr & 0xFFFFF000); /* Now Load Section To Memory */ fseek(tmpFd,programHeader[i].phOffset,0); fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); @@ -246,19 +247,53 @@ } /* Set Virtual Memory Start */ - _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->oInfo.vmStart = 0x80000000;//((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->td.vm_daddr = (programHeader[i].phVaddr & 0xFFFFF000); + //0xC800000 + for (x = 0;x < 1000;x++) { + vmm_remapPage(vmmFindFreePage(_current->id),0xC800000 + (x * 0x1000),PAGE_DEFAULT | PAGE_STACK); + } - /* Task Stack 0x2000 bytes long */ + /* Task Stack 0xD000 bytes long */ + /* vmm_remapPage(vmmFindFreePage(_current->id),0x5DC000,PAGE_DEFAULT | PAGE_STACK); vmm_remapPage(vmmFindFreePage(_current->id),0x5DB000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5DA000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D9000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D8000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D7000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D6000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D5000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D4000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D3000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D2000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D1000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5D0000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CF000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CE000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CD000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CC000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CB000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CA000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C9000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C8000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C7000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C6000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C5000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C4000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C3000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C2000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C1000,PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5C0000,PAGE_DEFAULT | PAGE_STACK); + */ /* Kernel Stack 0x2000 bytes long */ - vmm_remapPage(vmmFindFreePage(_current->id),0x5CC000,KERNEL_PAGE_DEFAULT | PAGE_STACK); - vmm_remapPage(vmmFindFreePage(_current->id),0x5CB000,KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5BC000,KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5BB000,KERNEL_PAGE_DEFAULT | PAGE_STACK); /* Set All The Proper Information For The Task */ _current->tss.back_link = 0x0; - _current->tss.esp0 = 0x5CC000; + _current->tss.esp0 = 0x5BC000; _current->tss.ss0 = 0x10; _current->tss.esp1 = 0x0; _current->tss.ss1 = 0x0; @@ -266,8 +301,8 @@ _current->tss.ss2 = 0x0; _current->tss.eip = (long)binaryHeader->eEntry; _current->tss.eflags = 0x206; - _current->tss.esp = 0x5DD000-12; - _current->tss.ebp = 0x5DD000; + _current->tss.esp = 0xCBE8000-12;//0x5DD000-12; + _current->tss.ebp = 0xCBE8000;//0x5DD000; _current->tss.esi = 0x0; _current->tss.edi = 0x0; @@ -388,7 +423,9 @@ kpanic("Error: vmmFindFreePage Failed\n"); memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); } - _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->oInfo.vmStart = 0x80000000;//((programHeader[i].phVaddr & 0xFFFFF000) + 0x1900000); + _current->td.vm_daddr = (programHeader[i].phVaddr & 0xFFFFF000); + /* Now Load Section To Memory */ fseek(tmpFd,programHeader[i].phOffset,0); fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); @@ -426,8 +463,8 @@ /* Adjust iframe */ tmp = (uInt32 *)_current->tss.esp0 - 5; tmp[0] = binaryHeader->eEntry; - tmp[3] = 0x5DD000-12; - tmp = (uInt32 *)0x5DD000 - 2; + tmp[3] = 0xCBE8000-12;//0x5DD000-12; + tmp = (uInt32 *)0xCBE8000 - 2;//0x5DD000 - 2; tmp[0] = argc; tmp[1] = (uInt32)argv; diff --git a/src/sys/kernel/gen_calls.c b/src/sys/kernel/gen_calls.c index bed91b9..8ae7fbb 100644 --- a/src/sys/kernel/gen_calls.c +++ b/src/sys/kernel/gen_calls.c @@ -39,6 +39,19 @@ return (0); } +int getuid(struct thread *td, struct getuid_args *uap) { + td->td_retval[0] = _current->uid; + return (0); + } + +int getgid(struct thread *td, struct getgid_args *uap) { + td->td_retval[0] = _current->gid; + return (0); + } + + + + int sys_write(struct thread *td, struct write_args *uap) { if (uap->fd == 2) { kprintf("stderr: %s",uap->buf); @@ -54,6 +67,13 @@ return (0); } +int readlink(struct thread *td,struct readlink_args *uap) { + kprintf("readlink: [%s:%i]\n",uap->path,uap->count); + td->td_retval[0] = -1; + td->td_retval[1] = 0x0; + return(0x0); + } + /*** END diff --git a/src/sys/kernel/kern_descrip.c b/src/sys/kernel/kern_descrip.c index d0eb1af..66e05f5 100644 --- a/src/sys/kernel/kern_descrip.c +++ b/src/sys/kernel/kern_descrip.c @@ -32,10 +32,13 @@ #include #include #include +#include +#include #include int fcntl(struct thread *td, struct fcntl_args *uap) { - kprintf("fcntl: [%i:%i]\n",uap->cmd,uap->fd); + struct file *fp = 0x0; + //kprintf("fcntl: [%i:%i]\n",uap->cmd,uap->fd); if (uap->fd == 0) { td->td_retval[0] = 0x2; } @@ -46,11 +49,54 @@ td->td_retval[0] = 0x2; } else { - td->td_retval[0] = -1; + if (td->o_files[uap->fd] == -1) { + kprintf("Descriptor Broken: [%i][%i], Ending task.\n",uap->fd,td->o_files[uap->fd]); + endTask(_current->id); + } + else { + fp = (struct file *)td->o_files[uap->fd]; + } + switch (uap->cmd) { + case F_GETFL: + td->td_retval[0] = fp->f_flag; + break; + case F_SETFL: + fp->f_flag &= ~FCNTLFLAGS; + fp->f_flag |= FFLAGS(uap->arg & ~O_ACCMODE) & FCNTLFLAGS; + break; + default: + kprintf("Unsupported fcntl cmd: [%i]\n",uap->cmd); + } } return(0x0); } +int falloc(struct thread *td,struct file **resultfp, int *resultfd) { + struct file *fp = 0x0; + int i = 0; + + fp = (struct file *)kmalloc(sizeof(struct file)); + /* First 5 Descriptors Are Reserved */ + for (i = 5;i<1024;i++) { + if (td->o_files[i] == 0x0) { + td->o_files[i] = (uInt32)fp; + if (resultfd) + *resultfd = i; + if (resultfp) + *resultfp = fp; + break; + } + } + return(0x0); + } + +int close(struct thread *td,struct close_args *uap) { + kfree(td->o_files[uap->fd]); + td->o_files[uap->fd] = 0x0; + td->td_retval[0] = 0x0; + return(0x0); + } + /*** END diff --git a/src/sys/kernel/kernsysctl.c b/src/sys/kernel/kernsysctl.c index 999145d..783e213 100644 --- a/src/sys/kernel/kernsysctl.c +++ b/src/sys/kernel/kernsysctl.c @@ -31,16 +31,193 @@ #include #include #include +#include #include +#include #include +#include -int __sysctl(struct thread *td, struct sysctl_args *uap) { - //kprintf("Name: [%s][%i][%i:%i]\n",uap->name,uap->namelen,uap->oldlenp,uap->newlen); - kprintf("__sysctl: Just a place holder\n"); - td->td_retval[0] = -1; +#define CTL_MAXNAME 24 + +static struct sysctl_entry *ctls = 0x0; + +static struct sysctl_entry *sysctl_find(int *,int); + +int sysctl_init() { + struct sysctl_entry *tmpCtl = 0x0; + if (ctls != 0x0) { + kprintf("sysctl already Initialized\n"); + while (1); + } + + ctls = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + ctls->prev = 0x0; + ctls->id = 0x0; + ctls->children = 0x0; + sprintf(ctls->name,"CTL_UNSPEC"); + + tmpCtl = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->prev = ctls; + tmpCtl->id = 1; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_KERN"); + ctls->next = tmpCtl; + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 2; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_VM"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 3; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_VFS"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 4; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_NET"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 5; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_DEBUG"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 6; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_HW"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 7; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_MACHDEP"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 8; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_USER"); + + tmpCtl->next = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->next->prev = tmpCtl; + tmpCtl = tmpCtl->next; + tmpCtl->id = 9; + tmpCtl->children = 0x0; + sprintf(tmpCtl->name,"CTL_P1003_1B"); + return(0x0); } +static void def_ctls() { + int name[CTL_MAXNAME], name_len; + uInt32 page_val = 0x1000; + name[0] = 6; + name[1] = 7; + name_len = 2; + sysctl_add(name,name_len,"page_size",&page_val,sizeof(uInt32)); + } + +int __sysctl(struct thread *td, struct sysctl_args *uap) { + struct sysctl_entry *tmpCtl = 0x0; + if (ctls == 0x0) { + def_ctls(); + } + if (uap->newlen < 0) { + kprintf("Changing Not supported yet.\n"); + endTask(_current->id); + } + + tmpCtl = sysctl_find(uap->name,uap->namelen); + if (tmpCtl == 0x0) { + kprintf("Invalid CTL\n"); + endTask(_current->id); + } + + if (uap->oldlenp < tmpCtl->val_len) + memcpy(uap->old,tmpCtl->value,(uInt32)uap->oldlenp); + else + memcpy(uap->old,tmpCtl->value,tmpCtl->val_len); + + td->td_retval[0] = 0x0; + + return(0x0); + } + +static struct sysctl_entry *sysctl_find(int *name,int namelen) { + int i = 0x0; + struct sysctl_entry *tmpCtl = 0x0; + struct sysctl_entry *lCtl = ctls; + + /* Loop Name Len */ + for (i = 0; i < namelen;i++) { + for (tmpCtl = lCtl;tmpCtl != 0x0;tmpCtl = tmpCtl->next) { + //kprintf("ctlName: [%s], ctlId; [%i]\n",tmpCtl->name,tmpCtl->id); + if (tmpCtl->id == name[i]) { + if ((i+1) == namelen) { + return(tmpCtl); + } + lCtl = tmpCtl->children; + break; + } + } + } + return(0x0); + } + +int sysctl_add(int *name,int namelen,char *str_name,void *buf,int buf_size) { + struct sysctl_entry *tmpCtl = 0x0; + + if (ctls == 0x0) { + sysctl_init(); + } + + /* Check if it exists */ + tmpCtl = sysctl_find(name,namelen); + if (tmpCtl != 0x0) { + kprintf("Node Exists!\n"); + while (1); + } + + /* Get Parent Node */ + tmpCtl = sysctl_find(name,namelen-1); + if (tmpCtl == 0x0) { + kprintf("Parent Node Non Existant\n"); + return(-1); + } + if (tmpCtl->children == 0x0) { + tmpCtl->children = (struct sysctl_entry *)kmalloc(sizeof(struct sysctl_entry)); + tmpCtl->children->children = 0x0; + tmpCtl->children->prev = 0x0; + tmpCtl->children->next = 0x0; + tmpCtl->children->id = name[namelen-1]; + sprintf(tmpCtl->children->name,str_name); + tmpCtl->children->value = (void *)kmalloc(buf_size); + memcpy(tmpCtl->children->value,buf,buf_size); + tmpCtl->children->val_len = buf_size; + } + else { + kprintf("CTL error\n"); + while (1); + } + + return(0x0); + } + + /*** END ***/ diff --git a/src/sys/kernel/pipe.c b/src/sys/kernel/pipe.c new file mode 100644 index 0000000..f47bfc3 --- /dev/null +++ b/src/sys/kernel/pipe.c @@ -0,0 +1,53 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. 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. 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 COPYRIGHT HOLDERS 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. + + $Id$ + +*****************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +int pipe(struct thread *td, struct pipe_args *uap) { + struct file *rf, *wf; + int fd = 0x0; + falloc(td,&rf,&fd); + rf->f_flag = FREAD | FWRITE; + td->td_retval[0] = fd; + falloc(td,&wf,&fd); + wf->f_flag = FREAD | FWRITE; + td->td_retval[1] = fd; + return(0x0); + } + +/*** + END + ***/ + diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index dc7b17a..fda4a41 100644 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -45,9 +44,9 @@ #include /* #include */ #include -#include +#include -typedef char * caddr_t; +long fuword(const void *base); void sdeTestThread(); @@ -250,29 +249,6 @@ return; } -void syscall(struct trapframe frame) { - caddr_t params; - struct thread *td = &_current->td; - int args[8]; - if (frame.tf_eax > totalCalls_new) { - kprintf("Invalid Call: [%i]\n",frame.tf_eax); - } - else if ((uInt32)systemCalls_new[frame.tf_eax] == 0x0) { - kprintf("Invalid Call: [%i][0x%X]\n",frame.tf_eax,(uInt32)systemCalls_new[frame.tf_eax]); - frame.tf_eax = -1; - frame.tf_edx = 0x0; - } - else { - params = (caddr_t)frame.tf_esp + sizeof(int); - //copyin(params, (caddr_t)args, (u_int)(8 * sizeof(int))); - memcpy(args,params,8); - systemCalls_new[frame.tf_eax](td,args); - frame.tf_eax = td->td_retval[0]; - frame.tf_edx = td->td_retval[1]; - } - } - - /*** END ***/ diff --git a/src/sys/kernel/syscall_new.c b/src/sys/kernel/syscall_new.c new file mode 100644 index 0000000..118c9ae --- /dev/null +++ b/src/sys/kernel/syscall_new.c @@ -0,0 +1,72 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. 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. 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 COPYRIGHT HOLDERS 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. + + $Id$ + +*****************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +void syscall(struct trapframe frame) { + uInt32 code = 0x0; + caddr_t params; + struct thread *td = &_current->td; + int args[8]; + + params = (caddr_t)frame.tf_esp + sizeof(int); + + code = frame.tf_eax; + if (code == 198) { + memcpy(&code,params,sizeof(int)); + params += sizeof(quad_t); + } + + if (code > totalCalls_new) { + kprintf("Invalid Call: [%i]\n",frame.tf_eax); + } + else if ((uInt32)systemCalls_new[code] == 0x0) { + kprintf("Invalid Call: [%i][0x%X]\n",code,(uInt32)systemCalls_new[code]); + frame.tf_eax = -1; + frame.tf_edx = 0x0; + } + else { + memcpy(args,params,8 * sizeof(int)); + systemCalls_new[code](td,args); + frame.tf_eax = td->td_retval[0]; + frame.tf_edx = td->td_retval[1]; + } + } + + +/*** + END + ***/ + diff --git a/src/sys/vmm/pagefault.c b/src/sys/vmm/pagefault.c index 68e83ba..51bf0e4 100644 --- a/src/sys/vmm/pagefault.c +++ b/src/sys/vmm/pagefault.c @@ -111,6 +111,7 @@ spinUnlock(&pageFaultSpinLock); /* Need To Create A Routine For Attempting To Access Non Mapped Memory */ kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X] Non Mapped\n",memAddr,esp,_current->id,eip); + kprintf("Out Of Stack Space: [0x%X]\n",memAddr & 0xFF0000); spinUnlock(&pageFaultSpinLock); endTask(_current->id); } @@ -127,6 +128,9 @@ /*** $Log$ + Revision 1.1.1.1 2006/06/01 12:46:13 reddawg + ubix2 + Revision 1.2 2005/10/12 00:13:38 reddawg Removed diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index 2e50a30..54eed1f 100644 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -422,84 +422,33 @@ return (0x0); } +int mmap(struct thread *td,struct mmap_args *uap) { + if (uap->addr != 0x0) { + kprintf("Address hints are not supported yet.\n"); + } + kprintf("uap->addr: [0x%X]\n",uap->addr); + kprintf("uap->len: [0x%X]\n",uap->len); + kprintf("uap->prot: [0x%X]\n",uap->prot); + kprintf("uap->flags: [0x%X]\n",uap->flags); + kprintf("uap->fd: [%i]\n",uap->fd); + kprintf("uap->pad: [0x%X]\n",uap->pad); + kprintf("uap->pos: [0x%X]\n",uap->pos); + if (uap->fd == -1) + td->td_retval[0] = vmmGetFreeVirtualPage(_current->id,uap->len/0x1000); + else + td->td_retval[0] = 0x0; + return(0x0); + } + +int obreak(struct thread *td,struct obreak_args *uap) { + kprintf("nsize: [0x%X]\n",uap->nsize); + kprintf("vm_daddr: [0x%X]\n",td->vm_daddr); + td->td_retval[0] = 0x0;//uap->nsize; + //td->td_retval[1] = 0x0; + return(0x0); + } + /*** - $Log$ - Revision 1.4 2006/06/01 12:42:09 reddawg - Getting back to the basics - - Revision 1.3 2006/06/01 03:58:33 reddawg - wondering about this stuff here - - Revision 1.2 2005/10/12 00:13:38 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:24:53 reddawg - no message - - Revision 1.18 2004/09/07 21:54:38 reddawg - ok reverted back to old scheduling for now.... - - Revision 1.16 2004/07/28 15:05:43 reddawg - Major: - Pages now have strict security enforcement. - Many null dereferences have been resolved. - When apps loaded permissions set for pages rw and ro - - Revision 1.15 2004/07/28 00:17:05 reddawg - Major: - Disconnected page 0x0 from the system... Unfortunately this broke many things - all of which have been fixed. This was good because nothing deferences NULL - any more. - - Things affected: - malloc,kmalloc,getfreepage,getfreevirtualpage,pagefault,fork,exec,ld,ld.so,exec,file - - Revision 1.14 2004/07/27 12:02:01 reddawg - chg: fixed marks bug readFile did a lookup which is why it looked like it was loopping so much - - Revision 1.13 2004/07/27 07:15:21 reddawg - chg: made page 0x0 writeable should boot now - - Revision 1.12 2004/07/27 06:48:26 flameshadow - chg: fixed ubu's typo - - Revision 1.11 2004/07/27 06:47:01 reddawg - Try now TCA - - Revision 1.10 2004/07/26 19:15:49 reddawg - test code, fixes and the like - - Revision 1.9 2004/07/24 23:13:21 reddawg - Oh yeah try this one - - Revision 1.8 2004/07/24 20:00:51 reddawg - Lots of changes to the vmm subsystem.... Page faults have been adjust to now be blocking on a per thread basis not system wide. This has resulted in no more deadlocks.. also the addition of per thread locking has removed segfaults as a result of COW in which two tasks fault the same COW page and try to modify it. - - Revision 1.7 2004/07/22 17:32:25 reddawg - I broke it hopefully - - Revision 1.6 2004/07/19 02:06:35 reddawg - cleaned out some debug code - - Revision 1.5 2004/07/17 15:54:52 reddawg - kmalloc: added assert() - bioscall: fixed some potential problem by not making 16bit code - paging: added assert() - - Revision 1.4 2004/06/10 22:23:56 reddawg - Volatiles - - Revision 1.3 2004/06/10 15:24:35 reddawg - Fixed an asm statement - - Revision 1.2 2004/05/22 21:46:37 reddawg - Fixed some bugs - - Revision 1.1.1.1 2004/04/15 12:06:52 reddawg - UbixOS v1.0 - - Revision 1.30 2004/04/13 16:36:34 reddawg - Changed our copyright, it is all now under a BSD-Style license - END ***/ +