diff --git a/src/sys/drivers/fdc.c b/src/sys/drivers/fdc.c index e3d8fda..5a83bfa 100755 --- a/src/sys/drivers/fdc.c +++ b/src/sys/drivers/fdc.c @@ -122,7 +122,7 @@ } if (!seek(track)) { motorOff(); - kprint("FDC: Error seeking to track\n"); + kprintf("FDC: Error seeking to track [%i]\n",block); return FALSE; } outportByte(fdcCcr,0); diff --git a/src/sys/include/types.h b/src/sys/include/types.h index bedf0df..5df036c 100755 --- a/src/sys/include/types.h +++ b/src/sys/include/types.h @@ -1,66 +1,2 @@ /* $Id$ */ -#ifndef _TYPES_H_ -#define _TYPES_H_ - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef _BSD_TYPES_ -typedef unsigned char u_int8_t; -typedef unsigned short u_int16_t; -typedef unsigned int u_int32_t; -typedef unsigned long long int u_int64_t; -#define _BSD_TYPES_ -#endif /* _BSD_TYPES_ */ - -#ifndef _POSIX_TYPES_ -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; /* Sys V */ -typedef unsigned int uint; /* Sys V */ -#define _POSIX_TYPES_ -#endif /* POSIX_TYPES_ */ - -#ifndef _ANSI_ISO_TYPES_ -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long int uint64_t; -#define _ANSI_ISO_TYPES_ -#endif /* ANSI_ISO_TYPES_ */ - -typedef signed char s8; -typedef signed short s16; -typedef signed long s32; - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned long u32; - -#ifndef _UBU_SPECIAL_TYPES_ -typedef unsigned char byte; -typedef unsigned short word; -typedef unsigned long dWord; -typedef unsigned char uChar; -typedef unsigned long uLong; -typedef unsigned short uShort; -#define _UBU_SPECIAL_TYPES_ -#endif /* Ubu's special types */ -typedef unsigned int uInt; - -#ifndef __PID_T -#define __PID_T -typedef int pid_t; -#endif - -#ifndef _STDLIB_H -#ifndef FALSE -typedef enum { FALSE = 0, TRUE = 1 } bool; -#endif -#endif - -#endif /* _TYPES_H_ */ diff --git a/src/sys/include/ubixfs/ubixfs.h b/src/sys/include/ubixfs/ubixfs.h index b640649..8ace7e5 100755 --- a/src/sys/include/ubixfs/ubixfs.h +++ b/src/sys/include/ubixfs/ubixfs.h @@ -27,7 +27,7 @@ #include #include -#define UBIXDISKMAGIC ((u_int32_t)0x45) /* The disk magic number */ +#define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ #define MAXUBIXPARTITIONS 16 //Partition Information diff --git a/src/sys/include/ubixos/kmalloc.h b/src/sys/include/ubixos/kmalloc.h index 0b9000c..7207efc 100755 --- a/src/sys/include/ubixos/kmalloc.h +++ b/src/sys/include/ubixos/kmalloc.h @@ -21,11 +21,20 @@ **************************************************************************************/ -#ifndef _A_OUT_H -#define _A_OUT_H +#ifndef _KMALLOC_H +#define _KMALLOC_H #include +struct memDescriptor { + struct memDescriptor *next; + void *basePage; + void *baseAddr; + uInt16 limit; + uInt8 numPages; + uInt8 status; + }; + void *kmalloc(uInt len); void kfree(void *baseAddr); diff --git a/src/sys/include/ubixos/types.h b/src/sys/include/ubixos/types.h index bbf62a7..17163cb 100755 --- a/src/sys/include/ubixos/types.h +++ b/src/sys/include/ubixos/types.h @@ -21,13 +21,13 @@ **************************************************************************************/ -#include - -#define _TYPES_H - #ifndef _TYPES_H #define _TYPES_H +#ifndef NULL +#define NULL 0x0 +#endif + typedef unsigned char byte; /* 8-bit byte */ typedef unsigned short word; /* 16-bit word */ typedef unsigned long dWord; /* 32-bit dword */ @@ -37,12 +37,14 @@ typedef unsigned short uShort; typedef unsigned int uInt; -/* Standard Types */ +typedef unsigned char uInt8; +typedef unsigned short uInt16; +typedef unsigned long uInt32; + typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; -//Fork Typedef typedef int pid_t; #ifndef _STDLIB_H_ diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index c53ec87..10206b6 100755 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -35,7 +35,7 @@ #define pageCow 0x00000200 #define pageStack 0x00000400 #define pageDefault (pagePresent|pageWrite|pageUser) -#define tablesBaseAddress 0xBFC00000 + #define tablesBaseAddress 0xBFC00000 #define parentPageDirAddr 0x100000 extern uLong *kernelPageDirectory; diff --git a/src/sys/init/main.c b/src/sys/init/main.c index e5156ac..38664d8 100755 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -100,7 +100,7 @@ initScheduler(); //Initialize Scheduler initFloppy(); //Initialize Floppy Controller initUbixFS(); //Initialize File System - initPit(); + //initPit(); execThread(idleThread,0xAFFF,"Idle Thread"); execFile("init"); kprintf("Free Pages: [%i]\n",freePages); diff --git a/src/sys/kernel/idt.c b/src/sys/kernel/idt.c index c1ffa29..8bda9dc 100755 --- a/src/sys/kernel/idt.c +++ b/src/sys/kernel/idt.c @@ -92,6 +92,7 @@ schedule(); while(1); } + void _int0() { kprint("int0: Divide-by-Zero\n"); freeProcessPages(_current->id); @@ -206,4 +207,4 @@ "done: \n" " popa \n" " iret \n" - ); \ No newline at end of file + ); \ No newline at end of file diff --git a/src/sys/kernel/kmalloc.c b/src/sys/kernel/kmalloc.c index be880f8..2b98cb5 100755 --- a/src/sys/kernel/kmalloc.c +++ b/src/sys/kernel/kmalloc.c @@ -27,14 +27,6 @@ #include #include -struct memDescriptor { - void *page; - void *base; - uShort limit; - uShort counter; - struct memDescriptor *next; - }; - struct memDescriptor *kernDesc = 0x0; void initMalloc() { @@ -44,10 +36,11 @@ //kprintf("Malloc: [0x%X]\n",getPhysicalAddr(kernDesc)); tmpDesc = kernDesc; for (i=0;i<4096;i+=sizeof(struct memDescriptor)) { - tmpDesc->page = 0x0; - tmpDesc->base = 0x0; - tmpDesc->limit = 0x0; - tmpDesc->counter = 0x0; + tmpDesc->basePage = 0x0; + tmpDesc->baseAddr = 0x0; + tmpDesc->limit = 0x0; + tmpDesc->status = 0x0; + tmpDesc->numPages = 0x1; if ((i+sizeof(struct memDescriptor)) < 4096) { tmpDesc->next = (struct memDescriptor *)((uLong)tmpDesc+sizeof(struct memDescriptor)); } @@ -62,19 +55,19 @@ int i = 0; struct memDescriptor *findDesc = 0x0,*tmpDesc = 0x0; for (findDesc=(struct memDescriptor *)kernDesc;(findDesc != 0x0);findDesc=(struct memDescriptor *)findDesc->next) { - if (findDesc->base == 0) { + if (findDesc->baseAddr == 0x0) { return(findDesc); } - if (findDesc->next == 0) { break; } + if (findDesc->next == 0x0) { break; } } tmpDesc = (void *)getFreePage(_current->id); - //kprintf("Malloc: [0x%X]\n",getPhysicalAddr(tmpDesc)); findDesc->next = tmpDesc; for (i=0;i<4096;i+=sizeof(struct memDescriptor)) { - tmpDesc->page = 0x0; - tmpDesc->base = 0x0; - tmpDesc->limit = 0x0; - tmpDesc->counter = 0x0; + tmpDesc->basePage = 0x0; + tmpDesc->baseAddr = 0x0; + tmpDesc->limit = 0x0; + tmpDesc->status = 0x0; + tmpDesc->numPages = 0x1; if ((i+sizeof(struct memDescriptor)) < 4096) { tmpDesc->next = (struct memDescriptor *)((uLong)tmpDesc+sizeof(struct memDescriptor)); } @@ -93,31 +86,28 @@ initMalloc(); } for(tmpDesc=kernDesc;tmpDesc;tmpDesc=tmpDesc->next) { - if (tmpDesc->counter == 0) { + if (tmpDesc->status == 0) { if (tmpDesc->limit >= len) { - //kprintf("Had Page [%i][%i]\n",tmpDesc->limit,len); if (tmpDesc->limit > len+4) { newDesc = findFreeDesc(); - newDesc->page = tmpDesc->page; - newDesc->base = tmpDesc->base + len + 1; + newDesc->basePage = tmpDesc->basePage; + newDesc->baseAddr = tmpDesc->baseAddr + len + 1; newDesc->limit = tmpDesc->limit - len; tmpDesc->limit = len; } - tmpDesc->counter = 1; - return(tmpDesc->base); + tmpDesc->status = 1; + return(tmpDesc->baseAddr); } - else if (tmpDesc->page == 0x0) { - //kprintf("Alloced\n"); - tmpDesc->page = (void *)getFreePage(_current->id); - //kprintf("Malloc: [0x%X]\n",getPhysicalAddr(tmpDesc->page)); - tmpDesc->base = tmpDesc->page; + else if (tmpDesc->basePage == 0x0) { + tmpDesc->basePage = (void *)getFreePage(_current->id); + tmpDesc->baseAddr = tmpDesc->basePage; tmpDesc->limit = len; - tmpDesc->counter = 1; + tmpDesc->status = 1; newDesc = findFreeDesc(); - newDesc->page = tmpDesc->page; - newDesc->base = tmpDesc->base + len + 1; + newDesc->basePage = tmpDesc->basePage; + newDesc->baseAddr = tmpDesc->baseAddr + len + 1; newDesc->limit = 4096 - tmpDesc->limit; - return(tmpDesc->base); + return(tmpDesc->baseAddr); } } } @@ -128,8 +118,8 @@ void kfree(void *baseAddr) { struct memDescriptor *tmpDesc = 0x0; for (tmpDesc=kernDesc;tmpDesc;tmpDesc=tmpDesc->next) { - if (tmpDesc->base == baseAddr) { - tmpDesc->counter = 0; + if (tmpDesc->baseAddr == baseAddr) { + tmpDesc->status = 0; return; } } diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 00944e2..f156317 100755 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -40,14 +40,10 @@ readBlock(diskLabel->partitions[0].p_offset,(char *)blockAllocationTable,diskLabel->partitions[0].p_bsize); kprintf("UbixFS Initialized\n"); } - else { - //kfree(bs); - //kfree(pInfo); + else { kprintf("Insert System Disk\n"); initUbixFS(); } - //kfree(bs); - //kfree(pInfo); //Return return; } @@ -93,12 +89,10 @@ if (offset < fd->size) { //If FD Status Is Not fdRead Then Load A Sector From Disk if (fd->status != fdRead) { - //readBlock(diskLabel->partitions[0].p_offset+blockAllocationTable[batIndex].realSector+bSect,fd->buffer,1); readBlock(diskLabel->partitions[0].p_offset+blockAllocationTable[batIndex].realSector+bSect,fd->buffer,8); fd->status = fdRead; } //This Sets The Char To Return - //ch = fd->buffer[offset-(bSect*512)-(blockCount*4096)]; ch = fd->buffer[offset-(blockCount*4096)]; } else { diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index f5c7b31..d1c54aa 100755 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -202,9 +202,9 @@ pageTable = (uLong *)(tablesBaseAddress + (4096 * pageDirectoryIndex)); //Free The Physical Page If Flags Is 0 if (flags == 0) { - //kprintf("Test\n"); - clearVirtualPage(pageAddr); - freePage((uLong)(pageTable[pageTableIndex] & 0xFFFFF000)); + //This is temp i think its still an issue + //clearVirtualPage(pageAddr); + //freePage((uLong)(pageTable[pageTableIndex] & 0xFFFFF000)); } //Unmap The Page pageTable[pageTableIndex] = 0x0;