diff --git a/sys/init/main.c b/sys/init/main.c index 68536bf..a1be926 100644 --- a/sys/init/main.c +++ b/sys/init/main.c @@ -45,6 +45,7 @@ #define B_CONTROLLERSHIFT 20 #define B_CONTROLLERMASK 0xf #define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK) + /* * Constants for converting boot-style device number to type, * adaptor (uba, mba, etc), unit number and partition number. @@ -70,7 +71,6 @@ #define B_TYPEMASK 0xff #define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK) - /***************************************************************************************** Desc: The Kernels Descriptor table: 0 - 0x00 - Dummy Entry @@ -91,35 +91,28 @@ *****************************************************************************************/ ubixDescriptorTable(ubixGDT, 11) { -{ .dummy = 0}, -ubixStandardDescriptor(0x0000, 0xFFFFF, (dCode + dRead + dBig + dBiglim)), -ubixStandardDescriptor(0x0000, 0xFFFFF, (dData + dWrite + dBig + dBiglim)), -ubixStandardDescriptor(VMM_USER_LDT, 0xFFFFF, (dLdt)), -ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss + dDpl3)), -ubixStandardDescriptor(0x0000, 0xFFFFF, (dCode + dRead + dBig + dBiglim + dDpl3)), -ubixStandardDescriptor(0x0000, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)), -ubixStandardDescriptor(0x5200, (sizeof(struct tssStruct)), (dTss + dDpl3)), -ubixStandardDescriptor(0x6200, (sizeof(struct tssStruct)), (dTss)), -ubixStandardDescriptor(0x0000, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl0)), -ubixStandardDescriptor(0xBFC00000, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)), +{ .dummy = 0 }, +ubixStandardDescriptor( 0x0000, 0xFFFFF, ( dCode + dRead + dBig + dBiglim ) ), +ubixStandardDescriptor( 0x0000, 0xFFFFF, ( dData + dWrite + dBig + dBiglim ) ), +ubixStandardDescriptor( VMM_USER_LDT, 0xFFFFF, ( dLdt ) ), +ubixStandardDescriptor( 0x4200, ( sizeof( struct tssStruct ) ), ( dTss + dDpl3 ) ), +ubixStandardDescriptor( 0x0000, 0xFFFFF, ( dCode + dRead + dBig + dBiglim + dDpl3 ) ), +ubixStandardDescriptor( 0x0000, 0xFFFFF, ( dData + dWrite + dBig + dBiglim + dDpl3 ) ), +ubixStandardDescriptor( 0x5200, ( sizeof(struct tssStruct)), ( dTss + dDpl3 ) ), +ubixStandardDescriptor( 0x6200, ( sizeof(struct tssStruct)), ( dTss ) ), +ubixStandardDescriptor( 0x0000, 0xFFFFF, ( dData + dWrite + dBig + dBiglim + dDpl0 ) ), +ubixStandardDescriptor( 0xBFC00000, 0xFFFFF, ( dData + dWrite + dBig + dBiglim + dDpl3 ) ), }; struct { - unsigned short limit __attribute__ ((packed)); - union descriptorTableUnion *gdt __attribute__ ((packed)); + unsigned short limit __attribute__ ((packed)); + union descriptorTableUnion *gdt __attribute__ ((packed)); } loadGDT = { (11 * sizeof(union descriptorTableUnion) - 1), ubixGDT }; -static char *argv_init[2] = { - "init", - 0x0, }; /* ARGV For Initial Process */ +static char *argv_init[2] = { "init", 0x0, }; /* ARGV For Initial Process */ -static char *envp_init[6] = { - "HOME=/", - "PWD=/", - "PATH=/bin:/sbin:/usr/bin:/usr/sbin", - "USER=root", - "GROUP=admin", - 0x0, }; /* ENVP For Initial Process */ +static char *envp_init[6] = { "HOME=/", "PWD=/", + "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", 0x0, }; /* ENVP For Initial Process */ struct bootinfo _bootinfo; char _kernelname[512]; @@ -132,74 +125,96 @@ * \param rootdev address of root device structure */ int kmain(uint32_t rootdev) { - /* Set up counter for startup routine */ - int i = 0x0; - /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */ - clearScreen(); + /* Set up counter for startup routine */ + int i = 0x0; - /* Modify src/sys/include/ubixos/init.h to add a startup routine */ - for (i = 0x0; i < init_tasksTotal; i++) { - if (init_tasks[i]() != 0x0) - kpanic("Error: Initializing System Task[%i].\n", i); - } + /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */ + clearScreen(); - /* New Root Mount Point */ - /* Old 2 new 10 */ - kprintf("[0x%X][0x%X:0x%X:0x%X:0x%X:0x%X:0x%X]\n", B_ADAPTOR(rootdev), B_CONTROLLER(rootdev), B_SLICE(rootdev), B_UNIT(rootdev), B_PARTITION(rootdev), B_TYPE(rootdev)); - /* if ( vfs_mount( B_UNIT(_bootdev), B_PARTITION(_bootdev), 0x0, 0xAA, "sys", "rw" ) != 0x0 ) { */ + /* Modify src/sys/include/ubixos/init.h to add a startup routine */ + for (i = 0x0; i < init_tasksTotal; i++) { - if (vfs_mount(0x1, 0x2, 0x0, 0xAA, "sys2", "rw") != 0x0) { //UFS FS - kprintf("Problem Mounting sys2 Mount Point\n"); - } - else - kprintf("Mounted sys2\n"); + if (init_tasks[i]() != 0x0) { + kpanic("Error: Initializing System Task[%i].\n", i); - if (vfs_mount(0x2, 0x1, 0x1, 0xFA, "sys", "rw") != 0x0) { //FAT FS - kprintf("Problem Mounting sys Mount Point\n"); - } - else - kprintf("Mounted sys\n"); + } - /* Do our mounting */ - /* - if (vfs_mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) { - kprintf("Problem Mounting sys Mount Point\n"); - } - if (vfs_mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) { - kprintf("Problem Mounting tmp Mount Point\n"); - } - */ + } - /* Initialize the system */ - kprintf("Free Pages: [%i]\n", systemVitals->freePages); - kprintf("MemoryMap: [0x%X]\n", vmmMemoryMap); - kprintf("Starting OS\n"); + /* New Root Mount Point */ + /* Old 2 new 10 */ + kprintf("[0x%X][0x%X:0x%X:0x%X:0x%X:0x%X:0x%X]\n", B_ADAPTOR(rootdev), + B_CONTROLLER(rootdev), B_SLICE(rootdev), B_UNIT(rootdev), + B_PARTITION(rootdev), B_TYPE(rootdev)); + /* if ( vfs_mount( B_UNIT(_bootdev), B_PARTITION(_bootdev), 0x0, 0xAA, "sys", "rw" ) != 0x0 ) { */ - /* kprintf("SDE Thread Start! [0x%X]\n", &sdeThread); */ - /* execThread(&sdeThread, 0x2000,0x0); */ + if (vfs_mount(0x1, 0x2, 0x0, 0xAA, "sys2", "rw") != 0x0) { //UFS FS - kprintf("Kernel Name: [%s], Boot How To [0x%X], Boot Dev: [0x%X]\n", _kernelname, _boothowto, _bootdev); - kprintf("B_TYPE(0x%X), B_SLICE(0x%X), B_UNIT(0x%X), B_PARTITION(0x%X)\n", B_TYPE(_bootdev), B_SLICE(_bootdev), B_UNIT(_bootdev), B_PARTITION(_bootdev)); - kprintf("_bootinfo.bi_version: 0x%X\n", _bootinfo.bi_version); - kprintf("_bootinfo.bi_size: 0x%X\n", _bootinfo.bi_size); - kprintf("_bootinfo.bi_bios_dev: 0x%X\n", _bootinfo.bi_bios_dev); + kprintf("Problem Mounting sys2 Mount Point\n"); - execThread(systemTask, 0x2000, 0x0); + } else { - execFile("sys:/bin/init", argv_init, envp_init, 0x0); /* OS Initializer */ + kprintf("Mounted sys2\n"); - //execFile("fat:/bin/init", argv_init, envp_init, 0x0); + } - irqEnable(0x0); + if (vfs_mount(0x2, 0x1, 0x1, 0xFA, "sys", "rw") != 0x0) { //FAT FS - while (0x1) - asm("hlt"); + kprintf("Problem Mounting sys Mount Point\n"); - /* Keep halting until the scheduler reacts */ + } else { - /* Return to start however we should never get this far */ - return (0x0); + kprintf("Mounted sys\n"); + + } + + /* Do our mounting */ + /* + if (vfs_mount(0x0,0x0,0x0,0x0,"sys","rw") != 0x0) { + kprintf("Problem Mounting sys Mount Point\n"); + } + if (vfs_mount(0x0,0x0,0x1,0x0,"tmp","rw") != 0x0) { + kprintf("Problem Mounting tmp Mount Point\n"); + } + */ + + /* Initialize the system */ + kprintf("Free Pages: [%i]\n", systemVitals->freePages); + kprintf("MemoryMap: [0x%X]\n", vmmMemoryMap); + kprintf("Starting OS\n"); + + /* kprintf("SDE Thread Start! [0x%X]\n", &sdeThread); */ + /* execThread(&sdeThread, 0x2000,0x0); */ + + kprintf("Kernel Name: [%s], Boot How To [0x%X], Boot Dev: [0x%X]\n", + _kernelname, _boothowto, _bootdev); + + kprintf("B_TYPE(0x%X), B_SLICE(0x%X), B_UNIT(0x%X), B_PARTITION(0x%X)\n", + B_TYPE(_bootdev), B_SLICE(_bootdev), B_UNIT(_bootdev), + B_PARTITION(_bootdev)); + + kprintf("_bootinfo.bi_version: 0x%X\n", _bootinfo.bi_version); + + kprintf("_bootinfo.bi_size: 0x%X\n", _bootinfo.bi_size); + + kprintf("_bootinfo.bi_bios_dev: 0x%X\n", _bootinfo.bi_bios_dev); + + execThread(systemTask, 0x2000, 0x0); + + execFile("sys:/bin/init", argv_init, envp_init, 0x0); /* OS Initializer */ + + //execFile("fat:/bin/init", argv_init, envp_init, 0x0); + + irqEnable(0x0); + + while (0x1) + asm("hlt"); + + /* Keep halting until the scheduler reacts */ + + /* Return to start however we should never get this far */ + return (0x0); } diff --git a/sys/init/static.c b/sys/init/static.c index f7bbdc1..f971539 100644 --- a/sys/init/static.c +++ b/sys/init/static.c @@ -27,20 +27,26 @@ */ // XXX Set up the ctors -int static_constructors(void) { - extern void (*__ctor_list)(); +int static_constructors( void ) { - void (**l_ctor)() = &__ctor_list; + extern void (*__ctor_list)(); - int l_ctorCount = *(int *) l_ctor; + void (**l_ctor)() = &__ctor_list; - l_ctor++; + int l_ctorCount = *(int *) l_ctor; - while (l_ctorCount) { - (*l_ctor)(); - l_ctorCount--; - l_ctor++; - } + l_ctor++; - return (0x0); + while (l_ctorCount) { + + (*l_ctor)(); + + l_ctorCount--; + + l_ctor++; + + } + + return (0x0); + } diff --git a/sys/vmm/copyvirtualspace.c b/sys/vmm/copyvirtualspace.c index dba354b..cebf052 100644 --- a/sys/vmm/copyvirtualspace.c +++ b/sys/vmm/copyvirtualspace.c @@ -49,35 +49,36 @@ Which Task Has Which Physical Pages ************************************************************************/ -void *vmm_copyVirtualSpace(pidType pid) { - void *newPageDirectoryAddress = 0x0; +void *vmm_copyVirtualSpace( pidType pid ) { - uint32_t *parentPageDirectory = 0x0, *newPageDirectory = 0x0; - uint32_t *parentPageTable = 0x0, *newPageTable = 0x0; - uint32_t *parentStackPage = 0x0, *newStackPage = 0x0; - uint16_t x = 0, i = 0, s = 0; + void *newPageDirectoryAddress = 0x0; - spinLock(&cvsSpinLock); + uint32_t *parentPageDirectory = 0x0, *newPageDirectory = 0x0; + uint32_t *parentPageTable = 0x0, *newPageTable = 0x0; + uint32_t *parentStackPage = 0x0, *newStackPage = 0x0; + uint16_t x = 0, i = 0, s = 0; - /* Set Address Of Parent Page Directory */ - parentPageDirectory = (uint32_t *) PD_BASE_ADDR; + spinLock( &cvsSpinLock ); - /* Allocate A New Page For The New Page Directory */ - if ((newPageDirectory = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) - kpanic("Error: newPageDirectory == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); + /* Set Address Of Parent Page Directory */ + parentPageDirectory = ( uint32_t * ) PD_BASE_ADDR; - /* Set newPageDirectoryAddress To The Newly Created Page Directories Page */ - newPageDirectoryAddress = (void *) vmm_getPhysicalAddr((uint32_t) newPageDirectory); + /* Allocate A New Page For The New Page Directory */ + if ((newPageDirectory = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic( "Error: newPageDirectory == NULL, File: %s, Line: %i\n", __FILE__, __LINE__ ); - /* First Set Up A Flushed Page Directory */ - bzero(newPageDirectory, PAGE_SIZE); + /* Set newPageDirectoryAddress To The Newly Created Page Directories Page */ + newPageDirectoryAddress = ( void * ) vmm_getPhysicalAddr( ( uint32_t ) newPageDirectory ); - /* Map Kernel Code Region Entries 0 & 1 */ - newPageDirectory[0] = parentPageDirectory[0]; - //XXX: We Dont Need This - newPageDirectory[1] = parentPageDirectory[1]; + /* First Set Up A Flushed Page Directory */ + bzero(newPageDirectory, PAGE_SIZE); - if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) - kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); + /* Map Kernel Code Region Entries 0 & 1 */ + newPageDirectory[0] = parentPageDirectory[0]; + //XXX: We Dont Need This - newPageDirectory[1] = parentPageDirectory[1]; + + if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * 1));