diff --git a/sys/sde/ogDisplay_UbixOS.cc b/sys/sde/ogDisplay_UbixOS.cc index 0f86c7c..5829d55 100755 --- a/sys/sde/ogDisplay_UbixOS.cc +++ b/sys/sde/ogDisplay_UbixOS.cc @@ -29,8 +29,6 @@ #include #include #include - -extern "C" { #include #include #include @@ -39,7 +37,6 @@ #include #include #include -} /* * @@ -234,12 +231,16 @@ //mode = 0x114; // was 0x111 //SetMode(mode); - mode = FindMode(_xRes, _yRes, _pixFormat.BPP); - if ((mode == 0) && ((_pixFormat.BPP==24) || (_pixFormat.BPP==32))) { - if (_pixFormat.BPP==24) _pixFormat.BPP=32; else _pixFormat.BPP=24; - mode=FindMode(_xRes,_yRes,_pixFormat.BPP); - } // if - if (mode!=0) SetMode(mode); + mode = FindMode(_xRes, _yRes, _pixFormat.BPP); + if ((mode == 0) && ((_pixFormat.BPP == 24) || (_pixFormat.BPP == 32))) { + if (_pixFormat.BPP == 24) + _pixFormat.BPP = 32; + else + _pixFormat.BPP = 24; + mode = FindMode(_xRes, _yRes, _pixFormat.BPP); + } // if + if (mode != 0) + SetMode(mode); return (mode != 0); } // ogDisplay_UbixOS::ogCreate diff --git a/sys/vmm/copyvirtualspace.c b/sys/vmm/copyvirtualspace.c index 88fd4e7..dba354b 100644 --- a/sys/vmm/copyvirtualspace.c +++ b/sys/vmm/copyvirtualspace.c @@ -231,54 +231,6 @@ * Allocate A New Page For The The First Page Table Where We Will Map The * Lower Region First 4MB */ - /* - if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) - kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - */ - - /* Flush The Page From Garbage In Memory */ - /* - bzero(newPageTable, PAGE_SIZE); - */ - - /* Map This Into The Page Directory */ - /* - newPageDirectory[0] = (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT); - */ - - /* Set Address Of Parents Page Table */ - /* - parentPageTable = (uint32_t) PT_BASE_ADDR; - */ - - /* Map The First 1MB Worth Of Pages */ - /* - for (x = 0; x < (PD_ENTRIES / 4); x++) { - newPageTable[x] = parentPageTable[x]; - } - */ - - /* Map The Next 3MB Worth Of Pages But Make Them COW */ - /* - for (x = (PD_ENTRIES / 4); x < PD_ENTRIES; x++) { - - // If Page Is Avaiable Map It - if ((parentPageTable[x] & 0xFFFFF000) != 0x0) { - - // Set Pages To COW - newPageTable[x] = (((uint32_t) parentPageTable[x] & 0xFFFFF000) | (PAGE_DEFAULT | PAGE_COW)); - - // Increment The COW Counter For This Page - if (((uint32_t) parentPageTable[x] & PAGE_COW) == PAGE_COW) { - adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), 1); - } - else { - adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), 2); - parentPageTable[x] = newPageTable[x]; - } - } - } - */ /* * diff --git a/sys/vmm/createvirtualspace.c b/sys/vmm/createvirtualspace.c index 8dad1d2..927912e 100644 --- a/sys/vmm/createvirtualspace.c +++ b/sys/vmm/createvirtualspace.c @@ -72,9 +72,11 @@ bzero(newPageDirectory, PAGE_SIZE); /* Map The Lower 8MB Kernel Code Space */ + /* Map First 4MB 1:1 */ newPageDirectory[0] = parentPageDirectory[0]; //XXX: We Dont Need This - newPageDirectory[1] = parentPageDirectory[1]; + /* Map Second 4MB */ newPageTable = (uint32_t *) vmm_getFreePage(pid); bzero(newPageTable, PAGE_SIZE); @@ -105,6 +107,7 @@ newPageDirectory[1] = (vmm_getPhysicalAddr((uint32_t) newPageTable) | KERNEL_PAGE_DEFAULT); vmm_unmapPage((uint32_t) newPageTable, 1); + /* Done Mapping Second 4MB */ /* Map The Top Kernel (APPROX 1GB) Region Of The VM Space */ for (x = PD_INDEX(VMM_KERN_START); x < PD_ENTRIES; x++) { @@ -175,8 +178,6 @@ bzero(newPageTable, PAGE_SIZE); for (x = 0; x < PD_ENTRIES; x++) { - if (x == 0x21) - kprintf("[0x%X]", newPageDirectory[x]); newPageTable[x] = newPageDirectory[x]; } @@ -184,7 +185,6 @@ vmm_unmapPage((uint32_t) newPageTable, 1); /* Now We Are Done With The Page Directory So Lets Unmap That Too */ - vmm_unmapPage((uint32_t) newPageDirectory, 1); /* Return Physical Address Of Page Directory */ diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c index bc8a910..f8e8b39 100644 --- a/sys/vmm/paging.c +++ b/sys/vmm/paging.c @@ -68,20 +68,17 @@ } /* end if */ /* Clear The Memory To Ensure There Is No Garbage */ - for (i = 0; i < PD_ENTRIES; i++) { - kernelPageDirectory[i] = (uint32_t) 0x0; - } /* end for */ + bzero(kernelPageDirectory, PAGE_SIZE); /* Allocate a page for the first 4MB of memory */ if ((pageTable = (uint32_t *) vmm_findFreePage( sysID)) == 0x0) K_PANIC("Error: vmm_findFreePage Failed"); /* Make Sure The Page Table Is Clean */ - memset(pageTable, 0x0, 0x1000); + bzero(pageTable, PAGE_SIZE); kernelPageDirectory[0] = (uint32_t) ((uint32_t) (pageTable) | PAGE_DEFAULT); - /* * Map the first 1MB of Memory to the kernel MM space because our kernel starts * at 0x30000 @@ -93,12 +90,12 @@ pageTable[i] = (uint32_t) ((i * 0x1000) | PAGE_DEFAULT); //FIXME: This is temp becauseo f bios callKERNEL_PAGE_DEFAULT); //MrOlsen 2018-01-14 PAGE_DEFAULT } /* end for */ - /* Allocate a page for the first 4MB of memory */ + /* Allocate a page for the second 4MB of memory */ if ((pageTable = (uint32_t *) vmm_findFreePage( sysID)) == 0x0) K_PANIC("Error: vmm_findFreePage Failed"); /* Make Sure The Page Table Is Clean */ - memset(pageTable, 0x0, 0x1000); + bzero(pageTable, PAGE_SIZE); kernelPageDirectory[1] = (uint32_t) ((uint32_t) (pageTable) | PAGE_DEFAULT); @@ -107,14 +104,12 @@ * for kernel space and will be shared with each process */ - kprintf("PD: %i\n", PD_INDEX(VMM_KERN_START)); - for (i = PD_INDEX(VMM_KERN_START); i <= PD_INDEX(VMM_KERN_END); i++) { if ((pageTable = (uint32_t *) vmm_findFreePage( sysID)) == 0x0) K_PANIC("Error: vmm_findFreePage Failed"); /* Make Sure The Page Table Is Clean */ - memset(pageTable, 0x0, 0x1000); + bzero(pageTable, PAGE_SIZE); /* Map In The Page Directory */ kernelPageDirectory[i] = (uint32_t) ((uint32_t) (pageTable) | KERNEL_PAGE_DEFAULT | PAGE_GLOBAL); @@ -122,6 +117,7 @@ kernelPageDirectory[1023] = (uint32_t) ((uint32_t) (pageTable) | KERNEL_PAGE_DEFAULT); pageTable = (uint32_t *) (kernelPageDirectory[1023] & 0xFFFFF000); + pageTable[1023] = (vmm_findFreePage(sysID) | KERNEL_PAGE_DEFAULT | PAGE_STACK); pageTable[1022] = (vmm_findFreePage(sysID) | KERNEL_PAGE_DEFAULT | PAGE_STACK); @@ -133,10 +129,11 @@ if ((pageTable = (uint32_t *) vmm_findFreePage( sysID)) == 0x0) K_PANIC("Error: vmm_findFreePage Failed"); + bzero(pageTable, PAGE_SIZE); + kernelPageDirectory[PD_INDEX(PT_BASE_ADDR)] = (uint32_t) ((uint32_t) (pageTable) | KERNEL_PAGE_DEFAULT); } - kprintf("PD2: %i\n", PD_INDEX(PT_BASE_ADDR)); pageTable = (uint32_t *) (kernelPageDirectory[PD_INDEX(PT_BASE_ADDR)] & 0xFFFFF000); for (i = 0; i < PD_ENTRIES; i++) { @@ -147,23 +144,17 @@ * Map Page Directory Into VM Space * First Page After Page Tables */ - kprintf("PPD3: %i\n", PD_INDEX(PD_BASE_ADDR)); if (kernelPageDirectory[PD_INDEX(PD_BASE_ADDR)] == 0) { if ((pageTable = (uint32_t *) vmm_findFreePage( sysID)) == 0x0) K_PANIC("Error: vmm_findFreePage Failed"); + bzero(pageTable, PAGE_SIZE); + kernelPageDirectory[PD_INDEX(PD_BASE_ADDR)] = (uint32_t) ((uint32_t) (pageTable) | KERNEL_PAGE_DEFAULT); } pageTable = (uint32_t *) (kernelPageDirectory[PD_INDEX(PD_BASE_ADDR)] & 0xFFFFF000); - pageTable[0] = (uint32_t) ((uint32_t) (kernelPageDirectory) | PAGE_DEFAULT); - - /* Also Set Up Page Directory To Be The The First Page In 0xE0400000 */ - /* - pageTable = (uint32_t *) (kernelPageDirectory[0] & 0xFFFFF000); - - pageTable[256] = (uint32_t)( (uint32_t)( kernelPageDirectory ) | PAGE_DEFAULT ); - */ + pageTable[0] = (uint32_t) ((uint32_t) (kernelPageDirectory) | KERNEL_PAGE_DEFAULT); /* Allocate New Stack Space */ if ((pageTable = (uint32_t *) vmm_findFreePage(sysID)) == 0x0) @@ -181,7 +172,7 @@ ); /* Remap The Memory List */ - for (i = 0x101000; i <= (0x101000 + (numPages * sizeof(mMap))); i += 0x1000) { + for (i = VMM_MMAP_ADDR_RMODE; i <= (0x101000 + (numPages * sizeof(mMap))); i += 0x1000) { if ((vmm_remapPage(i, (VMM_MMAP_ADDR_PMODE + (i - 0x101000)), PAGE_DEFAULT, sysID, 0)) == 0x0) K_PANIC("vmmRemapPage failed\n"); } @@ -224,10 +215,10 @@ K_PANIC("dest == 0x0"); if (haveLock == 0) { - if (dest >= VMM_USER_START && dest <= VMM_USER_END) - spinLock(&rmpSpinLock); - else - spinLock(&pdSpinLock); + if (dest >= VMM_USER_START && dest <= VMM_USER_END) + spinLock(&rmpSpinLock); + else + spinLock(&pdSpinLock); } if (perms == 0x0) @@ -273,8 +264,7 @@ pageTable[destPageTableIndex] = (uint32_t) (source | perms); /* Reload The Page Table; */ - rmDone: - asm volatile( + rmDone: asm volatile( "push %eax \n" "movl %cr3,%eax\n" "movl %eax,%cr3\n" @@ -346,8 +336,7 @@ startAddress = 0x0; goto noPagesAvail; - gotPages: -for (c = 0; c < count; c++) { + gotPages: for (c = 0; c < count; c++) { if ((vmm_remapPage((uint32_t) vmm_findFreePage(pid), (startAddress + (PAGE_SIZE * c)), KERNEL_PAGE_DEFAULT, pid, 1)) == 0x0) K_PANIC("vmmRemapPage failed: gfkp-1\n"); @@ -355,8 +344,7 @@ } - noPagesAvail: -spinUnlock(&pdSpinLock); + noPagesAvail: spinUnlock(&pdSpinLock); return (startAddress); } @@ -608,22 +596,22 @@ adjustCowCounter(((uint32_t) pageTableSrc[y] & 0xFFFFF000), -1); pageTableSrc[y] = 0x0; } -/* - else if ((pageTableSrc[y] & PAGE_STACK) == PAGE_STACK) { - //TODO: We need to fix this so we can clean the stack! - //kprintf("Page Stack!: 0x%X", (x * 0x400000) + (y * 0x1000)); - // pageTableSrc[y] = 0x0; - //MrOlsen (2016-01-18) NOTE: WHat should I Do Here? kprintf( "STACK: (%i:%i)", x, y ); - } -*/ + /* + else if ((pageTableSrc[y] & PAGE_STACK) == PAGE_STACK) { + //TODO: We need to fix this so we can clean the stack! + //kprintf("Page Stack!: 0x%X", (x * 0x400000) + (y * 0x1000)); + // pageTableSrc[y] = 0x0; + //MrOlsen (2016-01-18) NOTE: WHat should I Do Here? kprintf( "STACK: (%i:%i)", x, y ); + } + */ else { -/* -int vmmMemoryMapIndex = ((pageTableSrc[y] & 0xFFFFF000) / 4096); - vmmMemoryMap[vmmMemoryMapIndex].cowCounter = 0x0; - vmmMemoryMap[vmmMemoryMapIndex].pid = vmmID; - vmmMemoryMap[vmmMemoryMapIndex].status = memAvail; - systemVitals->freePages++; -*/ + /* + int vmmMemoryMapIndex = ((pageTableSrc[y] & 0xFFFFF000) / 4096); + vmmMemoryMap[vmmMemoryMapIndex].cowCounter = 0x0; + vmmMemoryMap[vmmMemoryMapIndex].pid = vmmID; + vmmMemoryMap[vmmMemoryMapIndex].status = memAvail; + systemVitals->freePages++; + */ pageTableSrc[y] = 0x0; } } @@ -635,7 +623,7 @@ "movl %cr3,%eax\n" "movl %eax,%cr3\n" ); -kprintf("Here?"); + kprintf("Here?"); return (0x0); }