diff --git a/bin/Makefile b/bin/Makefile index 553d63c..e9f4071 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,7 +1,7 @@ # $Id: Makefile 121 2016-01-14 03:18:20Z reddawg $ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin login-bin shell-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin ttyd-bin stat-bin ls-bin +all: init-bin login-bin shell-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin ttyd-bin stat-bin # cat-bin # MrOlsen (2016-01-11) ERROR: weird it didnt like -elf rtld-elf-bin # MrOlsen (2016-01-11) NOTE: edit-bin diff --git a/bin/init/main.c b/bin/init/main.c index 92d2656..2bf72b4 100644 --- a/bin/init/main.c +++ b/bin/init/main.c @@ -56,6 +56,7 @@ printf("Initializing UbixOS\n"); /* Start TTYD */ + #ifdef _IGNORE i = fork(); printf("Forked: %i", i); @@ -66,7 +67,7 @@ printf("Error: Could not start TTYD\n"); exit(0x0); } - + #endif #ifdef _IGNORE i = fork(); diff --git a/bin/shell/exec.c b/bin/shell/exec.c index 0ba94f4..859daf8 100644 --- a/bin/shell/exec.c +++ b/bin/shell/exec.c @@ -45,7 +45,7 @@ if (!cPid) { sprintf(file, "%s%s", cwd, data->argv[1]); - execve(file,argv_init, envp_init); + execve(file, argv_init, envp_init); printf("%s: Command Not Found.\n",data->argv[1]); exit(-1); } diff --git a/sys/fs/vfs/file.c b/sys/fs/vfs/file.c index 25d97b5..2be808b 100644 --- a/sys/fs/vfs/file.c +++ b/sys/fs/vfs/file.c @@ -227,7 +227,7 @@ } /* Return */ - return (fclose( args->FILE )); + return (fclose( args->FILE->fd )); } /* KERNEL */ @@ -262,8 +262,6 @@ fd->offset += size * nmemb; - //kprintf("fread: %i:%i",i,size *nmemb); - return (i); } @@ -354,7 +352,7 @@ return (NULL); } - if (file[0] == "." && file[1] == '\0') + if (file[0] == '.' && file[1] == '\0') strcpy(fileName, _current->oInfo.cwd); else strcpy( fileName, file ); @@ -373,10 +371,12 @@ sprintf( tmpFd->fileName, "/%s", path ); /* Find our mount point or set default to sys */ - if ( mountPoint == 0x0 ) + if ( mountPoint == 0x0 ) { tmpFd->mp = vfs_findMount( "sys" ); - else + } + else { tmpFd->mp = vfs_findMount( mountPoint ); + } if ( tmpFd->mp == 0x0 ) { kprintf( "Mount Point Bad\n" ); @@ -420,7 +420,7 @@ kfree( tmpFd ); kprintf( "Error: tmpFd->buffer == NULL, File: %s, Line: %i\n", __FILE__, __LINE__ ); spinUnlock( &fdTable_lock ); - return 0x1; + return(0x0); } /* Set Its Status To Open */ tmpFd->status = fdOpen; @@ -567,8 +567,3 @@ mp->fs->vfsUnlink( path, mp ); return (0x0); } - -/*** - END - ***/ - diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index 22afe47..b820e51 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -94,14 +94,14 @@ int i = 0x0; for (i = 1; i <= argc; i++) { - argv_tmp[i] = args_tmp + sp; - strcpy(argv_tmp[i], argv_in[i - 1]); + argv_tmp[i] = (uint32_t)(args_tmp + sp); + strcpy((char *)argv_tmp[i], argv_in[i - 1]); sp += strlen(argv_in[i - 1]) + 1; } argv_tmp[i++] = 0x0; - *argv_out = argv_tmp; + *argv_out = (char *)argv_tmp; *args_out = args_tmp; return (0); @@ -121,13 +121,13 @@ int i = 0x0; for (i = 0; i < envc; i++) { - envp_tmp[i] = envs_tmp + sp; - strcpy(envp_tmp[i], envp_in[i]); + envp_tmp[i] = (uint32_t)(envs_tmp + sp); + strcpy((char *)envp_tmp[i], envp_in[i]); sp += strlen(envp_in[i]) + 1; } envp_tmp[i++] = 0x0; - *envp_out = envp_tmp; + *envp_out = (char *)envp_tmp; *envs_out = envs_tmp; return (0); } @@ -370,8 +370,8 @@ //MrOlsen (2016-01-14) FIX: is the stack start supposed to be addressable xhcnage x= 1 to x=0 //x = 0 because GS= stack address not address -1 fix! for (x = 1; x <= 100; x++) { - vmm_remapPage(vmm_findFreePage(newProcess->id), (STACK_ADDR+1) - (x * 0x1000), PAGE_DEFAULT | PAGE_STACK, newProcess->id, 0); - bzero((STACK_ADDR+1) - (x * 0x1000), 0x1000); + vmm_remapPage(vmm_findFreePage(newProcess->id), (STACK_ADDR+1) - (x * PAGE_SIZE), PAGE_DEFAULT | PAGE_STACK, newProcess->id, 0); + bzero((void *)((STACK_ADDR+1) - (x * PAGE_SIZE)), PAGE_SIZE); } /* Kernel Stack 0x2000 bytes long */ @@ -455,7 +455,7 @@ struct gdtDescriptor *taskLDT = 0x0; - taskLDT = VMM_USER_LDT + sizeof(struct gdtDescriptor); + taskLDT = (struct gdtDescriptor *)(VMM_USER_LDT + sizeof(struct gdtDescriptor)); uint32_t data_addr = 0x0; taskLDT->limitLow = (0xFFFFF & 0xFFFF); @@ -539,14 +539,12 @@ uint32_t *argv_out = 0x0; char *args_out = 0x0; - //MrOlsen 2018kprintf("ARGV: 0x%X\n", &argv_out); - - args_copyin(argv, &argv_out, &args_out); + args_copyin(argv, (char **)&argv_out, &args_out); uint32_t *envp_out = 0x0; char *envs_out = 0x0; - envs_copyin(envp, &envp_out, &envs_out); + envs_copyin(envp, (char **)&envp_out, &envs_out); //! Clean the virtual of COW pages left over from the fork //vmm_cleanVirtualSpace( (uint32_t) _current->td.vm_daddr + (_current->td.vm_dsize << PAGE_SHIFT) ); @@ -558,7 +556,7 @@ //bzero(STACK_ADDR - (100 * PAGE_SIZE), (PAGE_SIZE * 100)); for (x = 1; x <= 100; x++) { vmm_remapPage(vmm_findFreePage(_current->id), (STACK_ADDR+1) - (x * 0x1000), PAGE_DEFAULT | PAGE_STACK, _current->id, 0); - bzero((STACK_ADDR+1) - (x * 0x1000), 0x1000); + bzero((void *)((STACK_ADDR+1) - (x * 0x1000)), 0x1000); } /* Load ELF Header */ @@ -686,7 +684,7 @@ fseek(fd, programHeader[i].p_offset, 0); fread((void *) interp, programHeader[i].p_filesz, 1, fd); kprintf("Interp: [%s]\n", interp); - ldAddr = ldEnable(); + ldAddr = ldEnable(interp); //ef->ld_addr = ldEnable(); break; case PT_GNU_STACK: @@ -738,13 +736,13 @@ for (i = 1; i <= argc; i++) { tmp[i] = (uint32_t) STACK_ADDR - ARGV_PAGE + sp; if (i == 1) { - EXECP = tmp[i]; + EXECP = (char *)tmp[i]; } - strcpy((char *) tmp[i], (char *) argv_out[i]); - sp += strlen(argv_out[i]) + 1; + strcpy((char *)tmp[i], (const char *)argv_out[i]); + sp += strlen((const char *)argv_out[i]) + 1; } - tmp[i++] = (char *) 0x0; + tmp[i++] = 0x0; kfree(argv_out); kfree(args_out); @@ -755,11 +753,11 @@ for (x = 0; x < envc; x++) { tmp[x + i] = (uint32_t) STACK_ADDR - ARGV_PAGE - ENVP_PAGE + sp; - strcpy((char *) tmp[x + i], (char *) envp_out[x]); - sp += strlen(envp_out[x]) + 1; + strcpy((char *) tmp[x + i], (const char *)envp_out[x]); + sp += strlen((const char *)envp_out[x]) + 1; } - tmp[i + x] = (char *) 0x0; + tmp[i + x] = 0x0; kfree(envp_out); kfree(envs_out); @@ -767,7 +765,7 @@ i = i + x + 1; struct file *tFP = 0x0; - int *tFD = 0x0; + int tFD = 0x0; fseek(_current->files[0], 0x0, 0x0); // Reset File Position falloc(&_current->td, &tFP, &tFD); @@ -818,7 +816,7 @@ tmp[i++] = 0x0; tmp[i++] = 15; //EXEC PATH - tmp[i++] = EXECP; + tmp[i++] = (uint32_t)EXECP; tmp[i++] = 19; //NCPUS tmp[i++] = 0x1; @@ -871,7 +869,7 @@ struct gdtDescriptor *taskLDT = 0x0; - taskLDT = VMM_USER_LDT + sizeof(struct gdtDescriptor);//taskLDT[1]; + taskLDT = (struct gdtDescriptor *)(VMM_USER_LDT + sizeof(struct gdtDescriptor)); //data_addr = 0x0; //TEMP @@ -894,7 +892,6 @@ static int elf_parse_dynamic(elf_file_t ef) { Elf32_Dyn *dynp; int plttype = DT_REL; - uint32_t *tmp; for (dynp = ef->dynamic; dynp->d_tag != 0x0; dynp++) { switch (dynp->d_tag) { diff --git a/sys/i386/sched.c b/sys/i386/sched.c index 72d942a..6612f91 100644 --- a/sys/i386/sched.c +++ b/sys/i386/sched.c @@ -98,16 +98,17 @@ tmpTask->state = READY; if (tmpTask->state == READY) { - _current->state = READY; + _current->state = (_current->state == DEAD) ? DEAD : READY; _current = tmpTask; break; } else if (tmpTask->state == DEAD) { + kprintf("DEAD: %i", tmpTask->id); delTask = tmpTask; if (delTask->parent != 0x0) { delTask->parent->children -= 1; delTask->parent->last_exit = delTask->id; - schedSetStatus(delTask->parent->id, READY); + delTask->parent->state = READY; } tmpTask = tmpTask->next; @@ -123,7 +124,7 @@ goto schedStart; } - if (_current->state == READY) { + if (_current->state == READY || _current->state == RUNNING) { if (_current->oInfo.v86Task == 0x1) irqDisable(0x0); diff --git a/sys/i386/spinlock.c b/sys/i386/spinlock.c index 6cf0b88..db6653d 100644 --- a/sys/i386/spinlock.c +++ b/sys/i386/spinlock.c @@ -68,3 +68,4 @@ sched_yield(); } } + diff --git a/sys/i386/trap.c b/sys/i386/trap.c index 150144d..bcb4139 100644 --- a/sys/i386/trap.c +++ b/sys/i386/trap.c @@ -32,6 +32,7 @@ #include #include #include +#include #define KERNEL_STACK 0x2000 @@ -79,8 +80,7 @@ int i; unsigned long esp; unsigned short ss; - unsigned long *stack, addr, module_start, module_end; - char *_etext = 0x300a0; + unsigned long *stack; esp = (unsigned long) ®s->tf_esp; @@ -104,10 +104,10 @@ kprintf("cs: 0x%X ds: 0x%X es: 0x%X fs: 0x%X gs: 0x%X ss: 0x%X\n", regs->tf_cs, regs->tf_ds, regs->tf_es, regs->tf_fs, regs->tf_gs, ss); kprintf("cr0: 0x%X, cr2: 0x%X, cr3: 0x%X, cr4: 0x%X\n", rcr0(), rcr2(), rcr3(), rcr4()); + /* struct gdtDescriptor *taskLDT = (struct gdtDescriptor *)(VMM_USER_LDT + sizeof(struct gdtDescriptor)); uint32_t data_addr = 0x0; - /* data_addr += taskLDT->baseLow; data_addr += taskLDT->baseMed << 16; data_addr += taskLDT->baseHigh << 24; @@ -134,8 +134,6 @@ u_int trap_code; u_int cr2 = 0; - struct thread *td = &_current->td; - trap_code = frame->tf_trapno; cr2 = rcr2(); diff --git a/sys/include/sys/descrip.h b/sys/include/sys/descrip.h index bee0145..9953efd 100644 --- a/sys/include/sys/descrip.h +++ b/sys/include/sys/descrip.h @@ -91,12 +91,21 @@ struct fileOps; struct file; +struct uio; //TMP +struct ucred; //TMP /* Function Protos */ typedef int fo_rdwr_t(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td); typedef int fo_stat_t(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td); typedef int fo_close_t(struct file *fp, struct thread *td); +struct ucred { + char pad; +}; + +struct uio { + char pad; +}; struct file { uint32_t f_flag; diff --git a/sys/include/sys/sysproto_posix.h b/sys/include/sys/sysproto_posix.h index 7b10839..80d1f15 100644 --- a/sys/include/sys/sysproto_posix.h +++ b/sys/include/sys/sysproto_posix.h @@ -32,6 +32,7 @@ #include #include + /* TEMP */ #include diff --git a/sys/include/ubixos/spinlock.h b/sys/include/ubixos/spinlock.h index 09ee164..2ebfa2a 100644 --- a/sys/include/ubixos/spinlock.h +++ b/sys/include/ubixos/spinlock.h @@ -34,7 +34,7 @@ #define LOCKED 1 #define UNLOCKED 0 #define SPIN_LOCK_INITIALIZER {NULL, 0} -#define LLOCK_FLAG (void *)1 +#define LLOCK_FLAG 1 //typedef volatile int spinLock_t; diff --git a/sys/include/ubixos/syscall_posix.h b/sys/include/ubixos/syscall_posix.h index a553a0e..65b2f09 100644 --- a/sys/include/ubixos/syscall_posix.h +++ b/sys/include/ubixos/syscall_posix.h @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _UBIXOS_SYSCALL_POXIX_H +#ifndef _UBIXOS_SYSCALL_POSIX_H #define _UBIXOS_SYSCALL_POSIX_H #include diff --git a/sys/include/ubixos/wait.h b/sys/include/ubixos/wait.h index 6b00444..9c9f703 100644 --- a/sys/include/ubixos/wait.h +++ b/sys/include/ubixos/wait.h @@ -29,11 +29,10 @@ #ifndef _UBIXOS_WAIT_H #define _UBIXOS_WAIT_H - -struct kTask_t; +struct taskStruct; struct wait_queue { - struct kTask_t *task; + struct taskStruct *task; struct wait_queue *next; }; diff --git a/sys/kernel/endtask.c b/sys/kernel/endtask.c index 0203bd7..1771a6f 100644 --- a/sys/kernel/endtask.c +++ b/sys/kernel/endtask.c @@ -43,10 +43,8 @@ ************************************************************************/ void endTask(pidType pid) { - sched_setStatus(pid, DEAD); sched_yield(); - while (1) asm("hlt"); diff --git a/sys/kernel/gen_calls.c b/sys/kernel/gen_calls.c index 5898b77..96475fe 100644 --- a/sys/kernel/gen_calls.c +++ b/sys/kernel/gen_calls.c @@ -154,22 +154,21 @@ int children = _current->children; + sched_setStatus(_current->id, WAIT); while (_current->children == children) { - schedSetStatus(_current->id, WAIT); sched_yield(); } td->td_retval[0] = _current->last_exit; td->td_retval[1] = 0x8; - return (0x0); } else { kTask_t *tmpTask = schedFindTask(args->pid); if (tmpTask != 0x0) { + sched_setStatus(_current->id, WAIT); while (tmpTask != 0x0) { - schedSetStatus(_current->id, WAIT); sched_yield(); tmpTask = schedFindTask(args->pid); } @@ -180,6 +179,7 @@ error = -1; } } + kprintf("w4: %i", td->td_retval[0]); return (error); } diff --git a/sys/sys/idt.c b/sys/sys/idt.c index 98b8a2b..233c3f7 100644 --- a/sys/sys/idt.c +++ b/sys/sys/idt.c @@ -60,8 +60,6 @@ ************************************************************************/ int idt_init() { - int i = 0x0; - struct tssStruct *sfTSS = (struct tssStruct *) 0x6200; struct tssStruct *gpfTSS = (struct tssStruct *) 0x4200; @@ -175,7 +173,7 @@ kprintf("Invalid Interrupt[%i]\n", _current->id); } -asm volatile( +asm( ".globl _int0 \n" "_int0: \n" " pushl $0x0 \n" @@ -232,7 +230,7 @@ sched_yield(); } -asm volatile( +asm( ".globl _int6 \n" "_int6: \n" " pushl $0x0 \n" diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c index 64b70e3..7f7be0d 100644 --- a/sys/vmm/paging.c +++ b/sys/vmm/paging.c @@ -599,7 +599,6 @@ uint32_t *pageDir = 0x0; pageDir = (uint32_t *) PD_BASE_ADDR; - kprintf("PDE*PS: 0x%X", (PD_ENTRIES * PAGE_SIZE)); for (x = (addr / (PD_ENTRIES * PAGE_SIZE)); x <= PD_INDEX(VMM_USER_END); x++) { if ((pageDir[x] & PAGE_PRESENT) == PAGE_PRESENT) {