diff --git a/src/sys/include/ubixos/kmod.h b/src/sys/include/ubixos/kmod.h index f9ef3a3..795b1a0 100644 --- a/src/sys/include/ubixos/kmod.h +++ b/src/sys/include/ubixos/kmod.h @@ -41,16 +41,19 @@ uInt16 refs; uInt32 address; char name[128]; - } kmod_t; +} kmod_t; uInt32 kmod_load(const char *); -uInt32 kmod_add(const char *); +uInt32 kmod_add(const char *, const char *name); #endif /*** $Log$ + Revision 1.4 2004/09/26 20:46:13 reddawg + ok time for bed added kmod_add keeps modules listed now + Revision 1.3 2004/09/26 20:40:51 reddawg Added baseAddr to the kmod_t diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index cb9b913..3cf4277 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -312,7 +312,6 @@ elfDynamic *elfDynamicS = 0x0; tmpFd = fopen(file,"r"); -kprintf("hello"); _current->imageFd = tmpFd; /* If We Dont Find the File Return */ if (tmpFd == 0x0) { @@ -329,49 +328,40 @@ if ((binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader))) == 0x0) endTask(_current->id); - kprintf("A"); - fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - kprintf("B"); - /* Set sectionHeader To Point To Loaded Binary To We Can Gather Info */ + fread(binaryHeader,sizeof(elfHeader),1,tmpFd); + /* Set sectionHeader To Point To Loaded Binary To We Can Gather Info */ /* Check If App Is A Real Application */ if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { - //kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); -kprintf("hello"); - fclose(tmpFd); -kprintf("hello2"); return; } else if (binaryHeader->eType != 2) { - //kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; } else if (binaryHeader->eEntry == 0x300000) { - //kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; } /* Load The Program Header(s) */ -kprintf("hello"); if ((programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum)) == 0x0) endTask(_current->id); -kprintf("hello3"); assert(programHeader); fseek(tmpFd,binaryHeader->ePhoff,0); fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd); -kprintf("hello"); if ((sectionHeader = (elfSectionHeader *)kmalloc(sizeof(elfSectionHeader)*binaryHeader->eShnum)) == 0x0) endTask(_current->id); -kprintf("hello4"); assert(sectionHeader); fseek(tmpFd,binaryHeader->eShoff,0); diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 058459e..2a7c050 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -148,11 +148,10 @@ memset(tmpTask,0x0,sizeof(kTask_t)); /* Filling in tasks attrs */ tmpTask->usedMath = 0x0; - tmpTask->id = nextID++; tmpTask->state = NEW; spinLock(&schedulerSpinLock); - + tmpTask->id = nextID++; tmpTask->next = taskList; tmpTask->prev = 0x0; taskList->prev = tmpTask; diff --git a/src/sys/kernel/sys_call.S b/src/sys/kernel/sys_call.S index aa343b9..2fe2020 100644 --- a/src/sys/kernel/sys_call.S +++ b/src/sys/kernel/sys_call.S @@ -47,9 +47,14 @@ iret invalidCall: - mov $drive,%eax - push %eax - call kpanic + /* mov $drive,%eax + push %eax */ + + call InvalidSystemCall + popl %ebx + popl %ecx + popl %edx + iret drive: .ascii "Invalid System Call\n\0" diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index 4eabdf7..29a5c4a 100644 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -76,11 +76,29 @@ " iret \n" ); -void sysGetpid(int *pid) { - if (pid) - *pid = _current->id; - return; - } +void InvalidSystemCall() +{ + kprintf("attempt was made to an invalid system call\n"); + return; +} + +void sysAuthenticateUser(char *username, char *password) +{ + kprintf("authenticating user %s\n", username); +} + +void sysChangeUserPassword(char *passwd) +{ + kprintf("changing user password for user %d\n", _current->uid); + return; +} + +void sysGetpid(int *pid) +{ + if (pid) + *pid = _current->id; + return; +} void sysGetUid(int *uid) { if (uid) @@ -120,18 +138,20 @@ return; } -void sysExit(int status) { - endTask(_current->id); - } +void sysExit(int status) +{ + endTask(_current->id); +} -void sysCheckPid(int pid,int *ptr) { - kTask_t *tmpTask = schedFindTask(pid); - if ((tmpTask != 0x0) && (ptr != 0x0)) - *ptr = tmpTask->state; - else - *ptr = 0x0; - return; - } +void sysCheckPid(int pid,int *ptr) +{ + kTask_t *tmpTask = schedFindTask(pid); + if ((tmpTask != 0x0) && (ptr != 0x0)) + *ptr = tmpTask->state; + else + *ptr = 0x0; + return; +} /************************************************************************ @@ -140,36 +160,41 @@ Notes: ************************************************************************/ -void sysGetFreePage(long *ptr,int count) { - if (ptr) - *ptr = (long) vmmGetFreeVirtualPage(_current->id,count); - return; - } +void sysGetFreePage(long *ptr,int count) +{ + if (ptr) + *ptr = (long) vmmGetFreeVirtualPage(_current->id,count); + return; +} -void sysGetDrives(uInt32 *ptr) { - if (ptr) - *ptr = 0x0;//(uInt32)devices; - return; - } +void sysGetDrives(uInt32 *ptr) +{ + if (ptr) + *ptr = 0x0;//(uInt32)devices; + return; +} -void sysGetUptime(uInt32 *ptr) { - if (ptr) - *ptr = systemVitals->sysTicks; - return; - } +void sysGetUptime(uInt32 *ptr) +{ + if (ptr) + *ptr = systemVitals->sysTicks; + return; +} -void sysGetTime(uInt32 *ptr) { - if (ptr) - *ptr = systemVitals->sysUptime + systemVitals->timeStart; - return; - } +void sysGetTime(uInt32 *ptr) +{ + if (ptr) + *ptr = systemVitals->sysUptime + systemVitals->timeStart; + return; +} -void sysGetCwd(char *data,int len) { - if (data) - sprintf(data,_current->oInfo.cwd); - return; - } +void sysGetCwd(char *data,int len) +{ + if (data) + sprintf(data,"%s", _current->oInfo.cwd); + return; +} void sysSchedYield() { sched_yield(); diff --git a/src/sys/kernel/vitals.c b/src/sys/kernel/vitals.c index f947a61..fc6a3c5 100644 --- a/src/sys/kernel/vitals.c +++ b/src/sys/kernel/vitals.c @@ -46,26 +46,27 @@ ************************************************************************/ int vitals_init() { - /* Initialize Memory For The System Vitals Node */ - systemVitals = (vitalsNode *) kmalloc(sizeof(vitalsNode)); + /* Initialize Memory For The System Vitals Node */ + systemVitals = (vitalsNode *) kmalloc(sizeof(vitalsNode)); - /* If malloc Failed Then Error */ - if (systemVitals == 0x0) { - kpanic("Error: kmalloc Failed In initVitals\n"); - } + /* If malloc Failed Then Error */ + if (systemVitals == 0x0) + { + kpanic("Error: kmalloc Failed In initVitals\n"); + } - /* Set all default values */ - memset(systemVitals,0x0,sizeof(vitalsNode)); + /* Set all default values */ + memset(systemVitals,0x0,sizeof(vitalsNode)); - systemVitals->quantum = 8; - systemVitals->dQuantum = 8; + systemVitals->quantum = 8; + systemVitals->dQuantum = 8; - /* Print Out Info For Vitals: */ - kprintf("vitals0 - Address: [0x%X]\n",systemVitals); + /* Print Out Info For Vitals: */ + kprintf("vitals0 - Address: [0x%X]\n",systemVitals); - /* Return so kernel knows that there is no problem */ - return(0x0); - } + /* Return so kernel knows that there is no problem */ + return(0x0); +} /*** END diff --git a/src/sys/kmods/kmod.c b/src/sys/kmods/kmod.c index 8d81082..2b96948 100644 --- a/src/sys/kmods/kmod.c +++ b/src/sys/kmods/kmod.c @@ -39,20 +39,38 @@ #include #include + kmod_t *kmods = 0x0; -uInt32 kmod_add(const char *kmod_file) { - uInt32 addr = 0x0; - - addr = kmod_load(kmod_file); - - if (addr == 0x0) - return(0x0); - - if (kmods == 0x0) { - kmods = kmalloc(sizeof(kmod_t)); - } - } +uInt32 kmod_add(const char *kmod_file, const char *name) +{ + uInt32 addr = 0x0; + kmod_t *tmp; + + tmp = kmalloc(sizeof *kmods); + if(tmp == NULL) + { + kprintf("kmod_add: unable to allocate memory!\n"); + return 0x0; + } + + addr = kmod_load(kmod_file); + if (addr == 0x0) + return 0x0; + + if(kmods == 0x0) + { + kmods = kmalloc(sizeof *kmods); + if(kmods == NULL) + { + kprintf("kmod_add: unable to allocate memory!\n"); + return 0x0; + } + kmods->next = NULL; + kmods->prev = NULL; + } + return 0x0; +} uInt32 kmod_load(const char *kmod_file) { int i = 0x0; diff --git a/src/sys/sys/device.c b/src/sys/sys/device.c index 3c51c64..97deebe 100644 --- a/src/sys/sys/device.c +++ b/src/sys/sys/device.c @@ -59,11 +59,10 @@ tmpDev->minor = minor; tmpDev->type = type; tmpDev->devInfo = devInfo; - tmpDev->next = devices; spinLock(&deviceSpinLock); + tmpDev->next = devices; devices = tmpDev; - spinUnlock(&deviceSpinLock); if (tmpDev->devInfo->initialized == 0x0) diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 58e4403..b21aedd 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -120,7 +120,7 @@ ************************************************************************/ void sysFopen(const char *file,char *flags,userFileDescriptor *userFd) { - if (userFd == 0x0) + if (userFd == NULL) kpanic("Error: userFd == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); userFd->fd = fopen(file,flags); diff --git a/src/sys/vfs/mount.c b/src/sys/vfs/mount.c index 7aee310..9051d0b 100644 --- a/src/sys/vfs/mount.c +++ b/src/sys/vfs/mount.c @@ -49,7 +49,7 @@ struct device_node *device = 0x0; /* Allocate Memory For Mount Point */ - if ((mp = (vfs_mountPoint_t *)kmalloc(sizeof(vfs_mountPoint_t))) == 0x0) + if ((mp = (vfs_mountPoint_t *)kmalloc(sizeof(vfs_mountPoint_t))) == NULL) kprintf("vfs_mount: failed to allocate mp\n"); /* Copy Mount Point Into Buffer */ @@ -141,6 +141,10 @@ /*** $Log$ + Revision 1.12 2005/08/04 18:24:40 fsdfs + + fixed problem in kfree() freeing a b uffer that is not used + Revision 1.11 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 diff --git a/src/sys/vfs/vfs.c b/src/sys/vfs/vfs.c index d90eefe..19eb5f3 100644 --- a/src/sys/vfs/vfs.c +++ b/src/sys/vfs/vfs.c @@ -72,13 +72,21 @@ int vfsRegisterFS(struct fileSystem newFS) { /* -int vfsType,void *vfsInitFS,void *vfsRead,void *vfsWrite,void *vfsOpenFile,void *vfsUnlink,void *vfsMakeDir,void *vfsRemDir,void *vfsSync) { +int vfsType, +void *vfsInitFS, +void *vfsRead, +void *vfsWrite, +void *vfsOpenFile, +void *vfsUnlink, +void *vfsMakeDir, +void *vfsRemDir, +void *vfsSync) { */ struct fileSystem *tmpFs = 0x0; /* Allocate Memory */ tmpFs = (struct fileSystem *)kmalloc(sizeof(struct fileSystem)); - if (tmpFs == 0x0) { + if (tmpFs == NULL) { kprintf("vfsRegisterFS: memory allocation failed\n"); /* Memory Allocation Failed */ return(0x1);