diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index 31f4e6d..5027a30 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -35,6 +35,7 @@ #include #include #include +#include typedef enum { PLACEHOLDER=-2,DEAD=-1,NEW=0,READY=1,RUNNING=2,IDLE=3,FORK=4,WAIT=5 } tState; @@ -80,6 +81,8 @@ uInt32 maxPages; uInt32 Quantum; uInt8 Priority; + mMap *FirstPage; + mMap *LastPage; } kTask_t; diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index 63ca1d1..96cf548 100644 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -30,6 +30,7 @@ #ifndef _PAGING_H #define _PAGING_H +#include #include #define pageLength 0x00000400 @@ -48,6 +49,7 @@ #define KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE) int vmmClearVirtualPage(uInt32 pageAddr); +void *vmmGetFreePage2(kTask_t *task); void vmmUnmapPage(uInt32,int); void vmmUnmapPages(void *,uInt32); @@ -72,6 +74,9 @@ /*** $Log$ + Revision 1.9 2005/08/08 21:33:44 fsdfs + new scheduler! + Revision 1.8 2004/08/14 11:23:02 reddawg Changes diff --git a/src/sys/include/vmm/vmm.h b/src/sys/include/vmm/vmm.h index 7afc458..ac29f5b 100644 --- a/src/sys/include/vmm/vmm.h +++ b/src/sys/include/vmm/vmm.h @@ -30,6 +30,7 @@ #ifndef _VMM_H #define _VMM_H +#include #include #include @@ -38,13 +39,25 @@ #define vmmID -3 #define vmmMemoryMapAddr 0xE6667000 -typedef struct { - uInt32 pageAddr; - uInt16 status; - uInt16 reserved; - pid_t pid; - int cowCounter; - } mMap; +typedef struct _mMap mMap; + +struct _mMap +{ + uInt32 pageAddr; + uInt16 status; + uInt16 reserved; + pid_t pid; + int cowCounter; + mMap *First; + mMap *Last; + mMap *Next; + mMap *Previous; +}; + +uInt32 freePages = 0; +uInt32 usedPages = 0; +mMap *FreePages; +mMap *UsedPages; extern int numPages; extern mMap *vmmMemoryMap; @@ -61,6 +74,9 @@ /*** $Log$ + Revision 1.6 2004/07/21 17:39:04 reddawg + removed device + Revision 1.5 2004/07/19 02:08:28 reddawg Cleaned out the rest of debuging code also temporarily disabled the ip stack to improve boot time diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 50f1724..51de4a9 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -116,7 +116,7 @@ execFile("sys:/init",0x0,0x0,0x0); /* start the scheduler */ - irqEnable(0x0); + //irqEnable(0x0); sched(); kpanic("We should not have gone this far!\n"); diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 2a7c050..d5ac232 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -228,11 +228,7 @@ 02/20/2004 - Approved for quality ************************************************************************/ -void -schedEndTask(pidType pid) { - endTask(_current->id); - sched_yield(); -} + /************************************************************************ @@ -248,9 +244,15 @@ void sched_yield() { - sched(); + //sched(); } + +void +schedEndTask(pidType pid) { + endTask(_current->id); + sched_yield(); +} /* asm( ".globl sched_yield \n" @@ -269,6 +271,11 @@ Notes: ************************************************************************/ +int sched_setStatus2(kTask_t *task, tState state) +{ + task->state = state; +} + int sched_setStatus(pidType pid,tState state) { kTask_t *tmpTask = schedFindTask(pid); if (tmpTask == 0x0) diff --git a/src/sys/kernel/schedyield.S b/src/sys/kernel/schedyield.S index dc43c7b..a985015 100644 --- a/src/sys/kernel/schedyield.S +++ b/src/sys/kernel/schedyield.S @@ -37,7 +37,7 @@ push %es push %fs push %gs - //call sched + call sched mov %eax,%esp pop %gs pop %fs diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index d446cf2..168d636 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -41,8 +41,15 @@ #include #include -void systemTask() { +void systemTask() { + + kprintf("System task\n"); + asm("ret"); + +} + +/* mpi_message_t myMsg; uInt32 counter = 0x0; int i = 0x0; @@ -101,7 +108,7 @@ return; } - +*/ /*** END ***/ diff --git a/src/sys/vmm/getfreepage.c b/src/sys/vmm/getfreepage.c index f4706ed..05ca224 100644 --- a/src/sys/vmm/getfreepage.c +++ b/src/sys/vmm/getfreepage.c @@ -30,6 +30,7 @@ #include #include #include +#include static spinLock_t vmmGFPlock = SPIN_LOCK_INITIALIZER; @@ -44,6 +45,26 @@ 07/30/02 - This Returns A Free Page In The Top 1GB For The Kernel ************************************************************************/ + +void * +vmmGetFreePage2(kTask_t *task) +{ + mMap *tmp; + + /* remove the first free entry from the free pages list */ + tmp = FreePages->First; + freePages--; + FreePages->First = FreePages->First->Next; + FreePages->First->Previous = NULL; + + /* add the free entry to the task's pages list */ + usedPages++; + tmp->Next = NULL; + tmp->Previous = task->LastPage; + task->LastPage = tmp; + return tmp; +} + void * vmmGetFreePage(pidType pid) { @@ -78,6 +99,9 @@ /*** $Log$ + Revision 1.8 2005/08/09 08:45:40 fsdfs + reverting to old vmm. i may have modified something accidently when i wasted time indenting the code. + Revision 1.6 2004/09/11 16:57:27 apwillia Add locking get GetFreePage diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 3b55edb..2f81de3 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -36,13 +36,11 @@ #include #include -static uInt32 freePages = 0; static spinLock_t vmmSpinLock = SPIN_LOCK_INITIALIZER; static spinLock_t vmmCowSpinLock = SPIN_LOCK_INITIALIZER; - -int numPages = 0x0; -mMap *vmmMemoryMap = (mMap *) 0x101000; +int numPages = 0; +mMap *vmmMemoryMap = (mMap *)0x101000; /************************************************************************ @@ -55,38 +53,98 @@ ************************************************************************/ int vmmMemMapInit() { - int i = 0x0; - int memStart = 0x0; + int i, memStart, z; + mMap *tmpMap; /* Count System Memory */ numPages = countMemory(); /* Set Memory Map To Point To First Physical Page That We Will Use */ - vmmMemoryMap = (mMap *) 0x101000; + + + memStart = 0x101; + memStart += (((sizeof(mMap) * numPages) + (sizeof(mMap) - 1)) / 0x1000); /* Initialize Map Make All Pages Not Available */ - for (i = 0x0; i < numPages; i++) { + for (i = 0x0; i < memStart; i++) + { vmmMemoryMap[i].cowCounter = 0x0; vmmMemoryMap[i].status = memNotavail; vmmMemoryMap[i].pid = vmmID; vmmMemoryMap[i].pageAddr = i * 4096; + usedPages++; } - /* Calculate Start Of Free Memory */ - memStart = (0x101000 / 0x1000); - memStart += (((sizeof(mMap) * numPages) + (sizeof(mMap) - 1)) / 0x1000); + /* Initialize All Free Pages To Available */ - vmmMemoryMap[(0x100000 / 0x1000)].status = memAvail; + vmmMemoryMap[0x100].status = memAvail; freePages++; for (i = memStart; i < numPages; i++) { vmmMemoryMap[i].status = memAvail; + vmmMemoryMap[i].pid = vmmID; + vmmMemoryMap[i].pageAddr = i * 4096; freePages++; } - /* Print Out Amount Of Memory */ - kprintf("Real Memory: %iKB\n", numPages * 4); - kprintf("Available Memory: %iKB\n", freePages * 4); + for(z = 0 ; z < numPages; z++) + { + if(vmmMemoryMap[z].status == memAvail) + { + if(FreePages == NULL) + { + //UBU: replace this with static location + FreePages = kmalloc(sizeof(mMap)); + FreePages->First = FreePages; + FreePages->Last = FreePages; + FreePages->Next = NULL; + FreePages->Previous = NULL; + FreePages->pid = vmmID; + FreePages->pageAddr = z * 4096; + FreePages->status = memAvail; + } + else + { + tmpMap = kmalloc(sizeof(mMap)); + FreePages->Last->Next = tmpMap; + tmpMap->Previous = FreePages->Last; + FreePages->Last = tmpMap; + tmpMap->pid = vmmID; + tmpMap->pageAddr = z * 4096; + tmpMap->status = memAvail; + } + } + else + { + if(UsedPages == NULL) + { + //UBU: replace this with static location + UsedPages = kmalloc(sizeof(mMap)); + UsedPages->First = UsedPages; + UsedPages->Last = UsedPages; + UsedPages->Next = NULL; + UsedPages->Previous = NULL; + UsedPages->pid = vmmID; + UsedPages->pageAddr = z * 4096; + UsedPages->status = memNotavail; + } + else + { + tmpMap = kmalloc(sizeof(mMap)); + UsedPages->Last->Next = tmpMap; + tmpMap->Previous = UsedPages->Last; + UsedPages->Last = tmpMap; + tmpMap->pid = vmmID; + tmpMap->pageAddr = z * 4096; + tmpMap->status = memNotavail; + } + } + } + + /* Print Out Memory Information */ + kprintf("Real Memory: %iMB\n", ((numPages * 4096) / 1024) / 1024 ); + kprintf("Available Memory: %iMB\n", ((freePages * 4096) / 1024) / 1024 ); + kprintf("Used Memory: %iMB\n", ((usedPages * 4096) / 1024) / 1024 ); /* Return */ return (0); @@ -193,6 +251,7 @@ spinLock(&vmmSpinLock); + for (i = 0; i <= numPages; i++) { /* @@ -333,6 +392,9 @@ /*** $Log$ + Revision 1.18 2005/08/09 08:45:40 fsdfs + reverting to old vmm. i may have modified something accidently when i wasted time indenting the code. + Revision 1.15 2004/09/11 23:39:31 reddawg ok time for bed