diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 4740ba6..920f5f8 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -108,11 +108,10 @@ kprintf("Starting OS\n"); sysTask = kmalloc(0x2000); - if(sysTask == 0x0 || sysTask == NULL) + if(sysTask == NULL) kprintf("OS: Unable to allocate memory\n"); execThread(systemTask, (uInt32)sysTask+0x2000,0x0); - //execThread(systemTask,(uInt32)kmalloc(0x2000)+0x2000,0x0); execFile("sys:/init",0x0,0x0,0x0); /* OS Initializer */ //execFile("sys:/stat",0x0,0x0,0x1); /* OS Status Monitor */ diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 254ec38..cb9b913 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -143,8 +143,8 @@ _current->uid = 0x0; _current->term = tty_find(console); if (_current->term == 0x0) - kpanic("Error: invalid console\n"); - + kprintf("Error: invalid console\n"); + /* Set tty ownership */ _current->term->owner = _current->id; @@ -163,37 +163,39 @@ /* If We Dont Find the File Return */ if (tmpFd == 0x0) { - // kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; } if (tmpFd->perms == 0x0) { - //kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; } /* Load ELF Header */ binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader)); + + //kprintf(">a:%i:0x%X:0x%X<",sizeof(elfHeader),binaryHeader,tmpFd); fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - //kprintf(">b<"); + /* 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); fclose(tmpFd); 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; @@ -202,6 +204,7 @@ /* Load The Program Header(s) */ programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum); fseek(tmpFd,binaryHeader->ePhoff,0); + //kprintf(">c:%i:0x%X:0x%X<",sizeof(elfProgramHeader)*binaryHeader->ePhnum,programHeader,tmpFd); fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd); //kprintf(">d<"); @@ -309,6 +312,7 @@ elfDynamic *elfDynamicS = 0x0; tmpFd = fopen(file,"r"); +kprintf("hello"); _current->imageFd = tmpFd; /* If We Dont Find the File Return */ if (tmpFd == 0x0) { @@ -316,7 +320,7 @@ return; } if (tmpFd->perms == 0) { - //kprintf("Exec Format Error: Binary File Not Executable.\n"); + kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; } @@ -325,16 +329,20 @@ if ((binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader))) == 0x0) endTask(_current->id); - //kprintf("A"); + kprintf("A"); fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - //kprintf("B"); + kprintf("B"); /* 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"); kfree(binaryHeader); +kprintf("hello"); + fclose(tmpFd); +kprintf("hello2"); + return; } else if (binaryHeader->eType != 2) { @@ -351,15 +359,19 @@ } /* 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/lib/kmalloc.c b/src/sys/lib/kmalloc.c index 0319bcd..eb9bf41 100644 --- a/src/sys/lib/kmalloc.c +++ b/src/sys/lib/kmalloc.c @@ -258,6 +258,7 @@ if (len == 0x0) { spinUnlock(&mallocSpinLock); + kprintf("kmalloc: len = 0!\n"); return(0x0); } for (tmpDesc1 = freeKernDesc;tmpDesc1 != 0x0;tmpDesc1=tmpDesc1->next) { @@ -292,6 +293,7 @@ } spinUnlock(&mallocSpinLock); //kprintf("m1[%i:%i:0x%X]",tmpDesc1->limit,len,tmpDesc1->baseAddr); + assert(tmpDesc1->baseAddr); return(tmpDesc1->baseAddr); } } @@ -326,6 +328,7 @@ spinUnlock(&mallocSpinLock); //kprintf("baseAddr2[0x%X:0x%X]",tmpDesc1,tmpDesc1->baseAddr); //kprintf("m2[%i:%i:0x%X]",tmpDesc1->limit,len,tmpDesc1->baseAddr); + assert(tmpDesc1->baseAddr); return(tmpDesc1->baseAddr); } //Return Null If Unable To Malloc @@ -388,6 +391,9 @@ /*** $Log$ + Revision 1.34 2005/08/04 18:23:41 reddawg + BUG: Assert has issues that must be looked into + Revision 1.33 2005/08/04 17:11:11 fsdfs ---------------------------------------- diff --git a/src/sys/sys/device.c b/src/sys/sys/device.c index 8aecb20..3c51c64 100644 --- a/src/sys/sys/device.c +++ b/src/sys/sys/device.c @@ -52,7 +52,8 @@ tmpDev = (struct device_node *)kmalloc(sizeof(struct device_node)); - assert(tmpDev); + if(tmpDev == NULL) + kprintf("Error Adding Device: memory failure\n"); tmpDev->prev = 0x0; tmpDev->minor = minor;