diff --git a/sys/armv6/exec.c b/sys/armv6/exec.c index 873cbf6..3af2f28 100644 --- a/sys/armv6/exec.c +++ b/sys/armv6/exec.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include #include @@ -53,66 +53,64 @@ //#define AUXARGS_ENTRY(pos, id, val) {memcpy((void *)pos++,(void *)id,sizeof(long)); memcpy((void *)pos++,(void *)val,sizeof(long));} #define AUXARGS_ENTRY(pos, id, val) {*pos = id;pos++; *pos = val;pos++;} - - /***************************************************************************************** Function: execThread(void (*)(void),int,char *); Description: This function will create a thread from code in the current memory space Notes: - - 05/19/04 - This does not work the way I want it to it still makes a copy of kernel space - so do not use out side of kernel space -*****************************************************************************************/ -uInt32 execThread(void (* tproc)(void),uInt32 stack,char *arg) { + 05/19/04 - This does not work the way I want it to it still makes a copy of kernel space + so do not use out side of kernel space + + *****************************************************************************************/ +uInt32 execThread(void (*tproc)(void), uInt32 stack, char *arg) { kTask_t * newProcess = 0x0; /* Find A New Thread */ newProcess = schedNewTask(); - assert(newProcess); + assert(newProcess); if (stack < 0x100000) - kpanic("exec: stack not in valid area: [0x%X]\n",stack); + kpanic("exec: stack not in valid area: [0x%X]\n", stack); /* Set All The Correct Thread Attributes */ - newProcess->tss.back_link = 0x0; - newProcess->tss.esp0 = 0x0; - newProcess->tss.ss0 = 0x0; - newProcess->tss.esp1 = 0x0; - newProcess->tss.ss1 = 0x0; - newProcess->tss.esp2 = 0x0; - newProcess->tss.ss2 = 0x0; - newProcess->tss.cr3 = (unsigned int)kernelPageDirectory; - newProcess->tss.eip = (unsigned int)tproc; - newProcess->tss.eflags = 0x206; - newProcess->tss.esp = stack; - newProcess->tss.ebp = stack; - newProcess->tss.esi = 0x0; - newProcess->tss.edi = 0x0; + newProcess->tss.back_link = 0x0; + newProcess->tss.esp0 = 0x0; + newProcess->tss.ss0 = 0x0; + newProcess->tss.esp1 = 0x0; + newProcess->tss.ss1 = 0x0; + newProcess->tss.esp2 = 0x0; + newProcess->tss.ss2 = 0x0; + newProcess->tss.cr3 = (unsigned int) kernelPageDirectory; + newProcess->tss.eip = (unsigned int) tproc; + newProcess->tss.eflags = 0x206; + newProcess->tss.esp = stack; + newProcess->tss.ebp = stack; + newProcess->tss.esi = 0x0; + newProcess->tss.edi = 0x0; /* Set these up to be ring 3 tasks */ /* - newProcess->tss.es = 0x30+3; - newProcess->tss.cs = 0x28+3; - newProcess->tss.ss = 0x30+3; - newProcess->tss.ds = 0x30+3; - newProcess->tss.fs = 0x30+3; - newProcess->tss.gs = 0x30+3; - */ + newProcess->tss.es = 0x30+3; + newProcess->tss.cs = 0x28+3; + newProcess->tss.ss = 0x30+3; + newProcess->tss.ds = 0x30+3; + newProcess->tss.fs = 0x30+3; + newProcess->tss.gs = 0x30+3; + */ - newProcess->tss.es = 0x10; - newProcess->tss.cs = 0x08; - newProcess->tss.ss = 0x10; - newProcess->tss.ds = 0x10; - newProcess->tss.fs = 0x10; - newProcess->tss.gs = 0x10; + newProcess->tss.es = 0x10; + newProcess->tss.cs = 0x08; + newProcess->tss.ss = 0x10; + newProcess->tss.ds = 0x10; + newProcess->tss.fs = 0x10; + newProcess->tss.gs = 0x10; - newProcess->tss.ldt = 0x18; + newProcess->tss.ldt = 0x18; newProcess->tss.trace_bitmap = 0x0000; - newProcess->tss.io_map = 0x8000; - newProcess->oInfo.vmStart = 0x6400000; - - newProcess->imageFd = 0x0; + newProcess->tss.io_map = 0x8000; + newProcess->oInfo.vmStart = 0x6400000; + + //newProcess->imageFd = 0x0; /* Set up default stack for thread here filled with arg list 3 times */ asm volatile( @@ -129,46 +127,46 @@ "popa \n" : : "b" (arg),"m" (newProcess->tss.esp) - ); + ); /* Put new thread into the READY state */ - sched_setStatus(newProcess->id,READY); + sched_setStatus(newProcess->id, READY); /* Return with the new process ID */ - return((uInt32)newProcess); - } + return ((uInt32) newProcess); +} /***************************************************************************************** Function: void execFile(char *file); Description: This Function Executes A Kile Into A New VM Space With Out - Having To Fork + Having To Fork Notes: 07/30/02 - I Have Made Some Heavy Changes To This As Well As Fixed A Few - Memory Leaks The Memory Allocated To Load The Binary Into Is - Now Unmapped So It Can Be Used Again And Not Held Onto Until - The Program Exits + Memory Leaks The Memory Allocated To Load The Binary Into Is + Now Unmapped So It Can Be Used Again And Not Held Onto Until + The Program Exits 07/30/02 - Now I Have To Make A Better Memory Allocator So We Can Set Up - The Freshly Allocated Pages With The Correct Permissions + The Freshly Allocated Pages With The Correct Permissions -*****************************************************************************************/ -void execFile(char *file,int argc,char **argv,int console) { + *****************************************************************************************/ +void execFile(char *file, int argc, char **argv, int console) { - int i = 0x0; - int x = 0x0; - uint32_t *tmp = 0x0; + int i = 0x0; + int x = 0x0; + uint32_t *tmp = 0x0; - fileDescriptor *tmpFd = 0x0; - elfHeader *binaryHeader = 0x0; + fileDescriptor *tmpFd = 0x0; + elfHeader *binaryHeader = 0x0; elfProgramHeader *programHeader = 0x0; /* Get A New Task For This Proccess */ _current = schedNewTask(); assert(_current); - _current->gid = 0x0; - _current->uid = 0x0; + _current->gid = 0x0; + _current->uid = 0x0; _current->term = tty_find(console); if (_current->term == 0x0) kprintf("Error: invalid console\n"); @@ -177,37 +175,35 @@ _current->term->owner = _current->id; /* Now We Must Create A Virtual Space For This Proccess To Run In */ - _current->tss.cr3 = (uInt32)vmmCreateVirtualSpace(_current->id); + _current->tss.cr3 = (uInt32) vmmCreateVirtualSpace(_current->id); /* To Better Load This Application We Will Switch Over To Its VM Space */ asm volatile( "movl %0,%%eax \n" "movl %%eax,%%cr3 \n" : : "d" ((uInt32 *)(_current->tss.cr3)) - ); + ); /* Lets Find The File */ - tmpFd = fopen(file,"r"); + tmpFd = fopen(file, "r"); /* If We Dont Find the File Return */ if (tmpFd == 0x0) { kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; - } + } if (tmpFd->perms == 0x0) { kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; - } + } /* Load ELF Header */ - binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader)); - + binaryHeader = (elfHeader *) kmalloc(sizeof(elfHeader)); //kprintf(">a:%i:0x%X:0x%X<",sizeof(elfHeader),binaryHeader,tmpFd); - fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - + fread(binaryHeader, sizeof(elfHeader), 1, tmpFd); /* Check If App Is A Real Application */ if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { @@ -215,126 +211,125 @@ kfree(binaryHeader); fclose(tmpFd); return; - } + } else if (binaryHeader->eType != 2) { kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; - } + } else if (binaryHeader->eEntry == 0x300000) { kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; - } + } /* Load The Program Header(s) */ - programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum); - fseek(tmpFd,binaryHeader->ePhoff,0); + programHeader = (elfProgramHeader *) kmalloc(sizeof(elfProgramHeader) * binaryHeader->ePhnum); + fseek(tmpFd, binaryHeader->ePhoff, 0); //kprintf(">c:%i:0x%X:0x%X<",sizeof(elfProgramHeader)*binaryHeader->ePhnum,programHeader,tmpFd); - fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd); + fread(programHeader, (sizeof(elfProgramHeader) * binaryHeader->ePhnum), 1, tmpFd); //kprintf(">d<"); /* Loop Through The Header And Load Sections Which Need To Be Loaded */ - for (i=0;iePhnum;i++) { + for (i = 0; i < binaryHeader->ePhnum; i++) { if (programHeader[i].phType == 1) { /* - Allocate Memory Im Going To Have To Make This Load Memory With Correct - Settings so it helps us in the future - */ - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { + Allocate Memory Im Going To Have To Make This Load Memory With Correct + Settings so it helps us in the future + */ + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { /* Make readonly and read/write !!! */ - if (vmm_remapPage(vmm_findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x),PAGE_DEFAULT) == 0x0) + if (vmm_remapPage(vmm_findFreePage(_current->id), ((programHeader[i].phVaddr & 0xFFFFF000) + x), PAGE_DEFAULT) == 0x0) K_PANIC("Remap Page Failed"); - memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); - } + memset((void *) ((programHeader[i].phVaddr & 0xFFFFF000) + x), 0x0, 0x1000); + } _current->oInfo.vmStart = 0x80000000; - _current->td.vm_daddr = (char *)(programHeader[i].phVaddr & 0xFFFFF000); + _current->td.vm_daddr = (char *) (programHeader[i].phVaddr & 0xFFFFF000); /* Now Load Section To Memory */ - fseek(tmpFd,programHeader[i].phOffset,0); - fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); + fseek(tmpFd, programHeader[i].phOffset, 0); + fread((void *) programHeader[i].phVaddr, programHeader[i].phFilesz, 1, tmpFd); if ((programHeader[i].phFlags & 0x2) != 0x2) { - kprintf("pH: [0x%X]\n",programHeader[i].phMemsz); - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { - if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x,PAGE_PRESENT | PAGE_USER)) != 0x0) - kpanic("Error: vmm_setPageAttributes failed, File: %s, Line: %i\n",__FILE__,__LINE__); - } + kprintf("pH: [0x%X]\n", programHeader[i].phMemsz); + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { + if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x, PAGE_PRESENT | PAGE_USER)) != 0x0) + kpanic("Error: vmm_setPageAttributes failed, File: %s, Line: %i\n", __FILE__, __LINE__); } } } + } /* Set Virtual Memory Start */ _current->oInfo.vmStart = 0x80000000; - _current->td.vm_daddr = (char *)(programHeader[i].phVaddr & 0xFFFFF000); + _current->td.vm_daddr = (char *) (programHeader[i].phVaddr & 0xFFFFF000); /* Set Up Stack Space */ - for (x = 1;x < 100;x++) { - vmm_remapPage(vmm_findFreePage(_current->id),STACK_ADDR - (x * 0x1000),PAGE_DEFAULT | PAGE_STACK); - } + for (x = 1; x < 100; x++) { + vmm_remapPage(vmm_findFreePage(_current->id), STACK_ADDR - (x * 0x1000), PAGE_DEFAULT | PAGE_STACK); + } /* Kernel Stack 0x2000 bytes long */ - vmm_remapPage(vmm_findFreePage(_current->id),0x5BC000,KERNEL_PAGE_DEFAULT | PAGE_STACK); - vmm_remapPage(vmm_findFreePage(_current->id),0x5BB000,KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmm_findFreePage(_current->id), 0x5BC000, KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmm_findFreePage(_current->id), 0x5BB000, KERNEL_PAGE_DEFAULT | PAGE_STACK); /* Set All The Proper Information For The Task */ - _current->tss.back_link = 0x0; - _current->tss.esp0 = 0x5BC000; - _current->tss.ss0 = 0x10; - _current->tss.esp1 = 0x0; - _current->tss.ss1 = 0x0; - _current->tss.esp2 = 0x0; - _current->tss.ss2 = 0x0; - _current->tss.eip = (long)binaryHeader->eEntry; - _current->tss.eflags = 0x206; - _current->tss.esp = STACK_ADDR - 12; - _current->tss.ebp = STACK_ADDR; - _current->tss.esi = 0x0; - _current->tss.edi = 0x0; + _current->tss.back_link = 0x0; + _current->tss.esp0 = 0x5BC000; + _current->tss.ss0 = 0x10; + _current->tss.esp1 = 0x0; + _current->tss.ss1 = 0x0; + _current->tss.esp2 = 0x0; + _current->tss.ss2 = 0x0; + _current->tss.eip = (long) binaryHeader->eEntry; + _current->tss.eflags = 0x206; + _current->tss.esp = STACK_ADDR - 12; + _current->tss.ebp = STACK_ADDR; + _current->tss.esi = 0x0; + _current->tss.edi = 0x0; /* Set these up to be ring 3 tasks */ - _current->tss.es = 0x30+3; - _current->tss.cs = 0x28+3; - _current->tss.ss = 0x30+3; - _current->tss.ds = 0x30+3; - _current->tss.fs = 0x30+3; - _current->tss.gs = 0x30+3; + _current->tss.es = 0x30 + 3; + _current->tss.cs = 0x28 + 3; + _current->tss.ss = 0x30 + 3; + _current->tss.ds = 0x30 + 3; + _current->tss.fs = 0x30 + 3; + _current->tss.gs = 0x30 + 3; - _current->tss.ldt = 0x18; + _current->tss.ldt = 0x18; _current->tss.trace_bitmap = 0x0000; - _current->tss.io_map = 0x8000; + _current->tss.io_map = 0x8000; - sched_setStatus(_current->id,READY); + sched_setStatus(_current->id, READY); kfree(binaryHeader); kfree(programHeader); fclose(tmpFd); - tmp = (uInt32 *)_current->tss.esp0 - 5; + tmp = (uInt32 *) _current->tss.esp0 - 5; tmp[0] = binaryHeader->eEntry; tmp[3] = STACK_ADDR - 12; - tmp = (uInt32 *)STACK_ADDR - 2; + tmp = (uInt32 *) STACK_ADDR - 2; if (_current->id > 4) - kprintf("argv[0]: [%s]\n",argv[0]); - kprintf("argv: [0x%X]\n",argv); - tmp[0] = (uint32_t)argv; - tmp[1] = (uint32_t)argv; - + kprintf("argv[0]: [%s]\n", argv[0]); + kprintf("argv: [0x%X]\n", argv); + tmp[0] = (uint32_t) argv; + tmp[1] = (uint32_t) argv; /* Switch Back To The Kernels VM Space */ asm volatile( "movl %0,%%eax \n" "movl %%eax,%%cr3 \n" : : "d" ((uInt32 *)(kernelPageDirectory)) - ); + ); /* Finally Return */ return; - } +} /***************************************************************************************** @@ -344,45 +339,45 @@ Notes: 04-22-03 - It Now Loads Sections Not The Full File -*****************************************************************************************/ -void sysExec(char *file,char *ap) { - int i = 0x0; - int x = 0x0; - int argc = 0x0; - unsigned int *tmp = 0x0; - uInt32 ldAddr = 0x0; - uInt32 seg_size = 0x0; - uInt32 seg_addr = 0x0; - char *interp = 0x0; - char **argv = 0x0; - char **argvNew = 0x0; - char *args = 0x0; + *****************************************************************************************/ +void sysExec(char *file, char *ap) { + int i = 0x0; + int x = 0x0; + int argc = 0x0; + unsigned int *tmp = 0x0; + uInt32 ldAddr = 0x0; + uInt32 seg_size = 0x0; + uInt32 seg_addr = 0x0; + char *interp = 0x0; + char **argv = 0x0; + char **argvNew = 0x0; + char *args = 0x0; - fileDescriptor *tmpFd = 0x0; - elfHeader *binaryHeader = 0x0; - elfProgramHeader *programHeader = 0x0; - elfSectionHeader *sectionHeader = 0x0; - elfDynamic *elfDynamicS = 0x0; - struct i386_frame *iFrame = 0x0; + fileDescriptor *tmpFd = 0x0; + elfHeader *binaryHeader = 0x0; + elfProgramHeader *programHeader = 0x0; + elfSectionHeader *sectionHeader = 0x0; + elfDynamic *elfDynamicS = 0x0; + struct i386_frame *iFrame = 0x0; - tmpFd = fopen(file,"r"); - _current->imageFd = tmpFd; + tmpFd = fopen(file, "r"); + _current->files[0] = tmpFd; /* If We Dont Find the File Return */ if (tmpFd == 0x0) { return; - } + } if (tmpFd->perms == 0) { kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; - } + } /* Load ELF Header */ - if ((binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader))) == 0x0) + if ((binaryHeader = (elfHeader *) kmalloc(sizeof(elfHeader))) == 0x0) endTask(_current->id); - fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - /* Set sectionHeader To Point To Loaded Binary To We Can Gather Info */ + fread(binaryHeader, sizeof(elfHeader), 1, tmpFd); + /* Set sectionHeader To Point To Loaded Binary To We Can Gather Info */ /* Check If App Is A Real Application */ if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { @@ -391,301 +386,300 @@ fclose(tmpFd); return; - } + } else if (binaryHeader->eType != 2) { kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; - } + } else if (binaryHeader->eEntry == 0x300000) { kprintf("Exec Format Error: Binary File Not Executable.\n"); kfree(binaryHeader); fclose(tmpFd); return; - } + } /* Load The Program Header(s) */ - if ((programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum)) == 0x0) + if ((programHeader = (elfProgramHeader *) kmalloc(sizeof(elfProgramHeader) * binaryHeader->ePhnum)) == 0x0) endTask(_current->id); assert(programHeader); - fseek(tmpFd,binaryHeader->ePhoff,0); - fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd); + fseek(tmpFd, binaryHeader->ePhoff, 0); + fread(programHeader, (sizeof(elfProgramHeader) * binaryHeader->ePhnum), 1, tmpFd); - if ((sectionHeader = (elfSectionHeader *)kmalloc(sizeof(elfSectionHeader)*binaryHeader->eShnum)) == 0x0) + if ((sectionHeader = (elfSectionHeader *) kmalloc(sizeof(elfSectionHeader) * binaryHeader->eShnum)) == 0x0) endTask(_current->id); assert(sectionHeader); - fseek(tmpFd,binaryHeader->eShoff,0); - fread(sectionHeader,sizeof(elfSectionHeader)*binaryHeader->eShnum,1,tmpFd); + fseek(tmpFd, binaryHeader->eShoff, 0); + fread(sectionHeader, sizeof(elfSectionHeader) * binaryHeader->eShnum, 1, tmpFd); /* Loop Through The Header And Load Sections Which Need To Be Loaded */ - for (i=0;iePhnum;i++) { + for (i = 0; i < binaryHeader->ePhnum; i++) { switch (programHeader[i].phType) { case PT_LOAD: seg_addr = trunc_page(programHeader[i].phVaddr); seg_size = round_page(programHeader[i].phMemsz + programHeader[i].phVaddr - seg_addr); /* - Allocate Memory Im Going To Have To Make This Load Memory With Correct - Settings so it helps us in the future - */ - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { + Allocate Memory Im Going To Have To Make This Load Memory With Correct + Settings so it helps us in the future + */ + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { /* Make readonly and read/write !!! */ - if (vmm_remapPage(vmm_findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x),PAGE_DEFAULT) == 0x0) + if (vmm_remapPage(vmm_findFreePage(_current->id), ((programHeader[i].phVaddr & 0xFFFFF000) + x), PAGE_DEFAULT) == 0x0) K_PANIC("Error: Remap Page Failed"); - memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); - } + memset((void *) ((programHeader[i].phVaddr & 0xFFFFF000) + x), 0x0, 0x1000); + } /* Now Load Section To Memory */ - fseek(tmpFd,programHeader[i].phOffset,0); - fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); + fseek(tmpFd, programHeader[i].phOffset, 0); + fread((void *) programHeader[i].phVaddr, programHeader[i].phFilesz, 1, tmpFd); if ((programHeader[i].phFlags & 0x2) != 0x2) { - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { - if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x,PAGE_PRESENT | PAGE_USER)) != 0x0) - kpanic("Error: vmm_setPageAttributes failed, File: %s,Line: %i\n",__FILE__,__LINE__); - } + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { + if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x, PAGE_PRESENT | PAGE_USER)) != 0x0) + kpanic("Error: vmm_setPageAttributes failed, File: %s,Line: %i\n", __FILE__, __LINE__); } + } kprintf("setting daddr\n"); if (binaryHeader->eEntry >= programHeader[i].phVaddr && binaryHeader->eEntry < (programHeader[i].phVaddr + programHeader[i].phMemsz)) { /* We're suposed to do something here? */ - } + } else { _current->td.vm_dsize = seg_size >> PAGE_SHIFT; - _current->td.vm_daddr = (char *)seg_addr; - } + _current->td.vm_daddr = (char *) seg_addr; + } _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0xA900000); - break; + break; case PT_DYNAMIC: //newLoc = (char *)programHeader[i].phVaddr; - elfDynamicS = (elfDynamic *)programHeader[i].phVaddr; - fseek(tmpFd,programHeader[i].phOffset,0); - fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); - break; + elfDynamicS = (elfDynamic *) programHeader[i].phVaddr; + fseek(tmpFd, programHeader[i].phOffset, 0); + fread((void *) programHeader[i].phVaddr, programHeader[i].phFilesz, 1, tmpFd); + break; case PT_INTERP: - interp = (char *)kmalloc(programHeader[i].phFilesz); - fseek(tmpFd,programHeader[i].phOffset,0); - fread((void *)interp,programHeader[i].phFilesz,1,tmpFd); - kprintf("Interp: [%s]\n",interp); + interp = (char *) kmalloc(programHeader[i].phFilesz); + fseek(tmpFd, programHeader[i].phOffset, 0); + fread((void *) interp, programHeader[i].phFilesz, 1, tmpFd); + kprintf("Interp: [%s]\n", interp); ldAddr = ldEnable(); - break; + break; default: - break; - } + break; } + } /* What is this doing? 11/23/06 */ if (elfDynamicS != 0x0) { - for (i=0;i<12;i++) { + for (i = 0; i < 12; i++) { if (elfDynamicS[i].dynVal == 0x3) { - tmp = (void *)elfDynamicS[i].dynPtr; + tmp = (void *) elfDynamicS[i].dynPtr; if (tmp == 0x0) kpanic("tmp: NULL\n"); - tmp[2] = (uInt32)ldAddr; - tmp[1] = (uInt32)tmpFd; + tmp[2] = (uInt32) ldAddr; + tmp[1] = (uInt32) tmpFd; break; - } -/* - else { - kprintf("dyn_val: %i",elfDynamicS[i].dynVal); - } -*/ } + /* + else { + kprintf("dyn_val: %i",elfDynamicS[i].dynVal); + } + */ } + } _current->td.vm_dsize = seg_size >> PAGE_SHIFT; - _current->td.vm_daddr = (char *)seg_addr; + _current->td.vm_daddr = (char *) seg_addr; argv = ≈ if (argv[1] != 0x0) { - argc = (int)argv[0]; - args = (char *)vmmGetFreeVirtualPage(_current->id,1,VM_TASK); -memset(args,0x0,0x1000); + argc = (int) argv[0]; + args = (char *) vmmGetFreeVirtualPage(_current->id, 1, VM_TASK); + memset(args, 0x0, 0x1000); x = 0x0; - argvNew = (char **)kmalloc(sizeof(char *) * argc); - for (i = 0x0;i < argc;i++) { - strcpy(args + x,argv[i + 1]); + argvNew = (char **) kmalloc(sizeof(char *) * argc); + for (i = 0x0; i < argc; i++) { + strcpy(args + x, argv[i + 1]); argvNew[i] = args + x; x += strlen(argv[i + 1]) + 1; //args[x] = '\0'; //x++; - } - argv = argvNew; } + argv = argvNew; + } //! Clean the virtual of COW pages left over from the fork vmm_cleanVirtualSpace(_current->td.vm_daddr + (_current->td.vm_dsize << PAGE_SIZE)); //! Adjust iframe - iFrame = (struct i386_frame *)_current->tss.esp0 - sizeof(struct i386_frame); + iFrame = (struct i386_frame *) _current->tss.esp0 - sizeof(struct i386_frame); iFrame->ebp = STACK_ADDR; iFrame->eip = binaryHeader->eEntry; iFrame->user_esp = STACK_ADDR - 12; //if (_current->id > 3) { - iFrame->user_esp = ((uint32_t)STACK_ADDR) - (sizeof(uint32_t) * (argc + 3)); - tmp = (void *)iFrame->user_esp; + iFrame->user_esp = ((uint32_t) STACK_ADDR) - (sizeof(uint32_t) * (argc + 3)); + tmp = (void *) iFrame->user_esp; - //! build argc and argv[] - tmp[0] = argc; - for (i = 0;i < argc;i++) { - tmp[i + 1] = (u_int)argv[i]; - } - tmp[argc + 1] = 0x0; - tmp[argc + 2] = 0x1; - //} + //! build argc and argv[] + tmp[0] = argc; + for (i = 0; i < argc; i++) { + tmp[i + 1] = (u_int) argv[i]; + } + tmp[argc + 1] = 0x0; + tmp[argc + 2] = 0x1; + //} //else { - //tmp = (uint32_t *)STACK_ADDR - 2; - //tmp[0] = 0x1; - //tmp[1] = 0x0; - //tmp[1] = (uint32_t)argv; - //} + //tmp = (uint32_t *)STACK_ADDR - 2; + //tmp[0] = 0x1; + //tmp[1] = 0x0; + //tmp[1] = (uint32_t)argv; + //} kfree(argvNew); - /* Now That We Relocated The Binary We Can Unmap And Free Header Info */ + /* Now That We Relocated The Binary We Can Unmap And Free Header Info */ kfree(binaryHeader); kfree(programHeader); return; - } +} /*! * \brief New exec... * */ -void sys_exec(char *file,char *ap) { - int error = 0x0; - int i = 0x0; - int x = 0x0; - int argc = 0x0; - uint32_t *tmp = 0x0; - uint32_t seg_size = 0x0; - uint32_t seg_addr = 0x0; - uint32_t addr = 0x0; - uint32_t eip = 0x0; - uint32_t proghdr = 0x0; - char *args = 0x0; - char *interp = 0x0; - char **argv = 0x0; - char **argvNew = 0x0; - elfHeader *binaryHeader = 0x0; - elfProgramHeader *programHeader = 0x0; - struct i386_frame *iFrame = 0x0; - Elf_Auxargs *auxargs = 0x0; +void sys_exec(char *file, char *ap) { + int error = 0x0; + int i = 0x0; + int x = 0x0; + int argc = 0x0; + uint32_t *tmp = 0x0; + uint32_t seg_size = 0x0; + uint32_t seg_addr = 0x0; + uint32_t addr = 0x0; + uint32_t eip = 0x0; + uint32_t proghdr = 0x0; + char *args = 0x0; + char *interp = 0x0; + char **argv = 0x0; + char **argvNew = 0x0; + elfHeader *binaryHeader = 0x0; + elfProgramHeader *programHeader = 0x0; + struct i386_frame *iFrame = 0x0; + //Elf_Auxargs *auxargs = 0x0; - _current->imageFd = fopen(file,"r"); - if (_current->imageFd == 0x0) - return(-1); + _current->files[0] = fopen(file, "r"); + if (_current->files[0] == 0x0) + return; //We Need To Set errno /* Load the ELF header */ - if ((binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader))) == 0x0) + if ((binaryHeader = (elfHeader *) kmalloc(sizeof(elfHeader))) == 0x0) K_PANIC("malloc failed!"); - fread(binaryHeader,sizeof(elfHeader),1,_current->imageFd); + fread(binaryHeader, sizeof(elfHeader), 1, _current->files[0]); /* Check If App Is A Real Application */ if (((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) || (binaryHeader->eType != ET_EXEC)) { kfree(binaryHeader); - fclose(_current->imageFd); - return(-1); - } + fclose(_current->files[0]); + return; //We Need To Set errno + } /* Load The Program Header(s) */ - if ((programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum)) == 0x0) + if ((programHeader = (elfProgramHeader *) kmalloc(sizeof(elfProgramHeader) * binaryHeader->ePhnum)) == 0x0) K_PANIC("malloc failed!"); - fseek(_current->imageFd,binaryHeader->ePhoff,0); - fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,_current->imageFd); + fseek(_current->files[0], binaryHeader->ePhoff, 0); + fread(programHeader, (sizeof(elfProgramHeader) * binaryHeader->ePhnum), 1, _current->files[0]); /* Loop Through The Header And Load Sections Which Need To Be Loaded */ - for (i = 0x0;i < binaryHeader->ePhnum;i++) { + for (i = 0x0; i < binaryHeader->ePhnum; i++) { switch (programHeader[i].phType) { case PT_LOAD: seg_addr = trunc_page(programHeader[i].phVaddr); seg_size = round_page(programHeader[i].phMemsz + programHeader[i].phVaddr - seg_addr); /* - Allocate Memory Im Going To Have To Make This Load Memory With Correct - Settings so it helps us in the future - */ - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { + Allocate Memory Im Going To Have To Make This Load Memory With Correct + Settings so it helps us in the future + */ + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { /* Make readonly and read/write !!! */ - if (vmm_remapPage(vmm_findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x),PAGE_DEFAULT) == 0x0) + if (vmm_remapPage(vmm_findFreePage(_current->id), ((programHeader[i].phVaddr & 0xFFFFF000) + x), PAGE_DEFAULT) == 0x0) K_PANIC("Error: Remap Page Failed"); - memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); - } + memset((void *) ((programHeader[i].phVaddr & 0xFFFFF000) + x), 0x0, 0x1000); + } /* Now Load Section To Memory */ - fseek(_current->imageFd,programHeader[i].phOffset,0); - fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,_current->imageFd); + fseek(_current->files[0], programHeader[i].phOffset, 0); + fread((void *) programHeader[i].phVaddr, programHeader[i].phFilesz, 1, _current->files[0]); if ((programHeader[i].phFlags & 0x2) != 0x2) { - for (x = 0x0;x < (programHeader[i].phMemsz);x += 0x1000) { - if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x,PAGE_PRESENT | PAGE_USER)) != 0x0) + for (x = 0x0; x < (programHeader[i].phMemsz); x += 0x1000) { + if ((vmm_setPageAttributes((programHeader[i].phVaddr & 0xFFFFF000) + x, PAGE_PRESENT | PAGE_USER)) != 0x0) K_PANIC("vmm_setPageAttributes failed"); - } } + } if (binaryHeader->eEntry >= programHeader[i].phVaddr && binaryHeader->eEntry < (programHeader[i].phVaddr + programHeader[i].phMemsz)) { /* We're suposed to do something here? */ - } + } else { _current->td.vm_dsize = seg_size >> PAGE_SHIFT; - _current->td.vm_daddr = (char *)seg_addr; - } + _current->td.vm_daddr = (char *) seg_addr; + } _current->oInfo.vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + 0xA900000); - break; + break; case PT_INTERP: - interp = (char *)kmalloc(programHeader[i].phFilesz); + interp = (char *) kmalloc(programHeader[i].phFilesz); if (interp == 0x0) - K_PANIC("malloc failed"); + K_PANIC("malloc failed") + ; - fseek(_current->imageFd,programHeader[i].phOffset,0); - fread((void *)interp,programHeader[i].phFilesz,1,_current->imageFd); - kprintf("Interp: [%s]\n",interp); + fseek(_current->files[0], programHeader[i].phOffset, 0); + fread((void *) interp, programHeader[i].phFilesz, 1, _current->files[0]); + kprintf("Interp: [%s]\n", interp); //ldAddr = ldEnable(); - break; + break; case PT_PHDR: - proghdr = programHeader[i].phVaddr; - break; + proghdr = programHeader[i].phVaddr; + break; default: - break; - } + break; } + } addr = LD_START; - if (interp != 0x0) { //kprintf("TEST"); - elf_loadfile(_current,interp,&addr,&eip); - } + elf_loadfile(_current, interp, &addr, &eip); + } //kprintf("[0x%X][0x%X]\n",eip,addr); _current->td.vm_dsize = seg_size >> PAGE_SHIFT; - _current->td.vm_daddr = (char *)seg_addr; + _current->td.vm_daddr = (char *) seg_addr; //! copy in arg strings argv = ap; if (argv[1] != 0x0) { argc = argv[0]; - args = (char *)vmmGetFreeVirtualPage(_current->id,1,VM_TASK); - memset(args,0x0,0x1000); + args = (char *) vmmGetFreeVirtualPage(_current->id, 1, VM_TASK); + memset(args, 0x0, 0x1000); x = 0x0; - argvNew = (char **)kmalloc(sizeof(char *) * argc); - for (i = 0x0;i < argc;i++) { - strcpy(args + x,argv[i + 1]); + argvNew = (char **) kmalloc(sizeof(char *) * argc); + for (i = 0x0; i < argc; i++) { + strcpy(args + x, argv[i + 1]); argvNew[i] = args + x; x += strlen(argv[i + 1]) + 1; - } - argv = argvNew; } + argv = argvNew; + } //! Clean the virtual of COW pages left over from the fork vmm_cleanVirtualSpace(_current->td.vm_daddr + (_current->td.vm_dsize << PAGE_SIZE)); - //! Adjust iframe iFrame = _current->tss.esp0 - sizeof(struct i386_frame); iFrame->ebp = STACK_ADDR; @@ -693,65 +687,63 @@ //if (_current->id > 3) { - iFrame->user_esp = ((uint32_t)STACK_ADDR) - (sizeof(uint32_t) * (argc + 4 + (sizeof(Elf_Auxargs) * 2))); - kprintf("\n\n\nuser_esp: [0x%X]\n",iFrame->user_esp); + iFrame->user_esp = ((uint32_t) STACK_ADDR) - (sizeof(uint32_t) * (argc + 4)); // + (sizeof(Elf_Auxargs) * 2))); + kprintf("\n\n\nuser_esp: [0x%X]\n", iFrame->user_esp); tmp = iFrame->user_esp; //! build argc and argv[] tmp[0] = argc; - for (i = 0;i < argc;i++) { + for (i = 0; i < argc; i++) { tmp[i + 1] = argv[i]; - } + } //! Build ENV - args = (char *)vmmGetFreeVirtualPage(_current->id,1,VM_TASK); - memset(args,0x0,0x1000); - strcpy(args,"LIBRARY_PATH=/lib"); + args = (char *) vmmGetFreeVirtualPage(_current->id, 1, VM_TASK); + memset(args, 0x0, 0x1000); + strcpy(args, "LIBRARY_PATH=/lib"); tmp[argc + 2] = args; - kprintf("env: [0x%X][0x%X]\n",(uInt32)tmp + argc + 2,tmp[argc + 2]); + kprintf("env: [0x%X][0x%X]\n", (uInt32) tmp + argc + 2, tmp[argc + 2]); tmp[argc + 3] = 0x0; - kprintf("env: [0x%X][0x%X]\n",(uInt32)tmp + argc + 2,tmp[argc + 2]); + kprintf("env: [0x%X][0x%X]\n", (uInt32) tmp + argc + 2, tmp[argc + 2]); //auxargs = iFrame->user_esp + argc + 3; tmp = iFrame->user_esp; tmp += argc + 4; + /* + auxargs->execfd = -1; + auxargs->phdr = proghdr; + auxargs->phent = binaryHeader->ePhentsize; + auxargs->phnum = binaryHeader->ePhnum; + auxargs->pagesz = PAGE_SIZE; + auxargs->base = addr; + auxargs->flags = 0x0; + auxargs->entry = binaryHeader->eEntry; + auxargs->trace = 0x0; - auxargs->execfd = -1; - auxargs->phdr = proghdr; - auxargs->phent = binaryHeader->ePhentsize; - auxargs->phnum = binaryHeader->ePhnum; - auxargs->pagesz = PAGE_SIZE; - auxargs->base = addr; - auxargs->flags = 0x0; - auxargs->entry = binaryHeader->eEntry; - auxargs->trace = 0x0; + AUXARGS_ENTRY(tmp, AT_PHDR, auxargs->phdr); + AUXARGS_ENTRY(tmp, AT_PHENT, auxargs->phent); + AUXARGS_ENTRY(tmp, AT_PHNUM, auxargs->phnum); + AUXARGS_ENTRY(tmp, AT_PAGESZ, auxargs->pagesz); + AUXARGS_ENTRY(tmp, AT_FLAGS, auxargs->flags); + AUXARGS_ENTRY(tmp, AT_ENTRY, auxargs->entry); + AUXARGS_ENTRY(tmp, AT_BASE, auxargs->base); + AUXARGS_ENTRY(tmp, AT_NULL, 0); - AUXARGS_ENTRY(tmp, AT_PHDR, auxargs->phdr); - AUXARGS_ENTRY(tmp, AT_PHENT, auxargs->phent); - AUXARGS_ENTRY(tmp, AT_PHNUM, auxargs->phnum); - AUXARGS_ENTRY(tmp, AT_PAGESZ, auxargs->pagesz); - AUXARGS_ENTRY(tmp, AT_FLAGS, auxargs->flags); - AUXARGS_ENTRY(tmp, AT_ENTRY, auxargs->entry); - AUXARGS_ENTRY(tmp, AT_BASE, auxargs->base); - AUXARGS_ENTRY(tmp, AT_NULL, 0); - - kprintf("AT_BASE: [0x%X]\n",auxargs->base); + kprintf("AT_BASE: [0x%X]\n",auxargs->base); + */ //iFrame->ebx = 0x0; //iFrame->ebx = 0x0; - //iFrame->eip = binaryHeader->eEntry; //kprintf("\n\nDOH: [0x%X]\n\n",iFrame->eip); - //while (1); - - //while (1); -/* - error = elf_loadfile(_current,file,0x0,0x0); - if (error) - K_PANIC("elf_loadfile failed"); -*/ + //while (1); + /* + error = elf_loadfile(_current,file,0x0,0x0); + if (error) + K_PANIC("elf_loadfile failed"); + */ return; - } +} /*** END diff --git a/sys/armv6/kpanic.c b/sys/armv6/kpanic.c index 57c4920..e4b43c7 100644 --- a/sys/armv6/kpanic.c +++ b/sys/armv6/kpanic.c @@ -40,7 +40,7 @@ */ void kpanic(const char *fmt, ...) { char buf[512]; - vaList args; + va_list args; vaStart(args, fmt); vsprintf(buf, fmt, args); diff --git a/sys/armv6/syscall.c b/sys/armv6/syscall.c index b371ff5..e20bb17 100644 --- a/sys/armv6/syscall.c +++ b/sys/armv6/syscall.c @@ -29,9 +29,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -46,9 +46,9 @@ #include #include -long fuword(const void *base); +//long fuword(const void *base); -void sdeTestThread(); +//void sdeTestThread(); asm( ".globl _sysCallNew \n" @@ -71,189 +71,175 @@ " call InvalidSystemCall \n" "doneNew: \n" " pop %gs \n" - " pop %fs \n" + " pop %fs \n" " pop %es \n" " pop %ds \n" " pop %ss \n" " popa \n" " iret \n" - ); +); -void InvalidSystemCall() -{ - kprintf("attempt was made to an invalid system call\n"); - return; +void InvalidSystemCall() { + kprintf("attempt was made to an invalid system call\n"); + return; } typedef struct _UbixUser UbixUser; -struct _UbixUser -{ - char *username; - char *password; - int uid; - int gid; - char *home; - char *shell; +struct _UbixUser { + char *username; + char *password; + int uid; + int gid; + char *home; + char *shell; }; -void sysAuth(UbixUser *uu) -{ - kprintf("authenticating user %s\n", uu->username); +void sysAuth(UbixUser *uu) { + kprintf("authenticating user %s\n", uu->username); - /* MrOlsen 2016-01-01 uh? - if(uu->username == "root" && uu->password == "user") - { - uu->uid = 0; - uu->gid = 0; - } -*/ - uu->uid = -1; - uu->gid = -1; - return; + /* MrOlsen 2016-01-01 uh? + if(uu->username == "root" && uu->password == "user") + { + uu->uid = 0; + uu->gid = 0; + } + */ + uu->uid = -1; + uu->gid = -1; + return; } -void sysPasswd(char *passwd) -{ - kprintf("changing user password for user %d\n", _current->uid); - return; +void sysPasswd(char *passwd) { + kprintf("changing user password for user %d\n", _current->uid); + return; } -void sysAddModule() -{ - return; +void sysAddModule() { + return; } -void sysRmModule() -{ - return; +void sysRmModule() { + return; } -void sysGetpid(int *pid) -{ - if (pid) - *pid = _current->id; - return; +void sysGetpid(int *pid) { + if (pid) + *pid = _current->id; + return; } void sysGetUid(int *uid) { if (uid) *uid = _current->uid; return; - } +} void sysGetGid(int *gid) { if (gid) *gid = _current->gid; return; - } +} -void sysSetUid(int uid,int *status) { +void sysSetUid(int uid, int *status) { if (_current->uid == 0x0) { _current->uid = uid; if (status) *status = 0x0; - } + } else { if (status) *status = 1; - } - return; } + return; +} -void sysSetGid(int gid,int *status) { +void sysSetGid(int gid, int *status) { if (_current->gid == 0x0) { _current->gid = gid; if (status) *status = 0x0; - } + } else { if (status) *status = 1; - } + } return; - } - -void sysExit(int status) -{ - endTask(_current->id); } -void sysCheckPid(int pid,int *ptr) -{ - kTask_t *tmpTask = schedFindTask(pid); - if ((tmpTask != 0x0) && (ptr != 0x0)) - *ptr = tmpTask->state; - else - *ptr = 0x0; - return; +void sysExit(int status) { + endTask(_current->id); +} + +void sysCheckPid(int pid, int *ptr) { + kTask_t *tmpTask = schedFindTask(pid); + if ((tmpTask != 0x0) && (ptr != 0x0)) + *ptr = tmpTask->state; + else + *ptr = 0x0; + return; } /************************************************************************ -Function: void sysGetFreePage(); -Description: Allocs A Page To The Users VM Space -Notes: + Function: void sysGetFreePage(); + Description: Allocs A Page To The Users VM Space + Notes: -************************************************************************/ -void sysGetFreePage(long *ptr,int count,int type) { + ************************************************************************/ +void sysGetFreePage(long *ptr, int count, int type) { if (ptr) { if (type == 2) - *ptr = (long) vmmGetFreeVirtualPage(_current->id,count,VM_THRD); + *ptr = (long) vmmGetFreeVirtualPage(_current->id, count, VM_THRD); else - *ptr = (long) vmmGetFreeVirtualPage(_current->id,count,VM_TASK); - } - return; + *ptr = (long) vmmGetFreeVirtualPage(_current->id, count, VM_TASK); } - -void sysGetDrives(uInt32 *ptr) -{ - if (ptr) - *ptr = 0x0;//(uInt32)devices; - return; + return; } -void sysGetUptime(uInt32 *ptr) -{ - if (ptr) - *ptr = systemVitals->sysTicks; - return; +void sysGetDrives(uInt32 *ptr) { + if (ptr) + *ptr = 0x0; //(uInt32)devices; + return; } -void sysGetTime(uInt32 *ptr) -{ - if (ptr) - *ptr = systemVitals->sysUptime + systemVitals->timeStart; - return; +void sysGetUptime(uInt32 *ptr) { + if (ptr) + *ptr = systemVitals->sysTicks; + return; } +void sysGetTime(uInt32 *ptr) { + if (ptr) + *ptr = systemVitals->sysUptime + systemVitals->timeStart; + return; +} -void sysGetCwd(char *data,int len) -{ - if (data) - sprintf(data,"%s", _current->oInfo.cwd); - return; +void sysGetCwd(char *data, int len) { + if (data) + sprintf(data, "%s", _current->oInfo.cwd); + return; } void sysSchedYield() { sched_yield(); - } +} void sysStartSDE() { int i = 0x0; - for (i=0;i<1400;i++) { + for (i = 0; i < 1400; i++) { asm("hlt"); - } - //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); - for (i=0;i<1400;i++) { - asm("hlt"); - } - return; } + //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + for (i = 0; i < 1400; i++) { + asm("hlt"); + } + return; +} void invalidCall(int sys_call) { - kprintf("Invalid System Call #[%i]\n",sys_call); + kprintf("Invalid System Call #[%i]\n", sys_call); return; - } +} /*** END diff --git a/sys/armv6/systemtask.c b/sys/armv6/systemtask.c index 10fe017..c0a999e 100644 --- a/sys/armv6/systemtask.c +++ b/sys/armv6/systemtask.c @@ -76,7 +76,7 @@ break; case 31337: kprintf("system: backdoor opened\n"); - break; + break; case 0x80: if (!strcmp(myMsg.data,"sdeStart")) { kprintf("Starting SDE\n"); @@ -98,21 +98,21 @@ } /* - Here we get the next task from the delete task queue - we first check to see if it has an fd attached for the binary and after that - we free the pages for the process and then free the task + Here we get the next task from the delete task queue + we first check to see if it has an fd attached for the binary and after that + we free the pages for the process and then free the task */ - tmpTask = sched_getDelTask(); + tmpTask = sched_getDelTask(); if (tmpTask != 0x0) { - if (tmpTask->imageFd != 0x0) - fclose(tmpTask->imageFd); + if (tmpTask->files[0] != 0x0) + fclose(tmpTask->files[0]); vmmFreeProcessPages(tmpTask->id); kfree(tmpTask); } - videoBuffer[0] = systemVitals->sysTicks; + videoBuffer[0] = systemVitals->sysTicks; sched_yield(); - } - + } + return; } diff --git a/sys/boot/arm/uboot/conf.c b/sys/boot/arm/uboot/conf.c index 5519606..26cbeb1 100644 --- a/sys/boot/arm/uboot/conf.c +++ b/sys/boot/arm/uboot/conf.c @@ -26,7 +26,8 @@ */ #include -__FBSDID("$FreeBSD: releng/10.2/sys/boot/arm/uboot/conf.c 235537 2012-05-17 10:11:18Z gber $"); + +#ifdef _IGNORE #include #include "bootstrap.h" @@ -38,57 +39,49 @@ struct devsw *devsw[] = { #if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) - &uboot_storage, + &uboot_storage, #endif #if defined(LOADER_NET_SUPPORT) - &netdev, + &netdev, #endif - NULL -}; + NULL}; struct fs_ops *file_system[] = { #if defined(LOADER_UFS_SUPPORT) - &ufs_fsops, + &ufs_fsops, #endif #if defined(LOADER_CD9660_SUPPORT) - &cd9660_fsops, + &cd9660_fsops, #endif #if defined(LOADER_EXT2FS_SUPPORT) - &ext2fs_fsops, + &ext2fs_fsops, #endif #if defined(LOADER_NANDFS_SUPPORT) - &nandfs_fsops, + &nandfs_fsops, #endif #if defined(LOADER_NFS_SUPPORT) - &nfs_fsops, + &nfs_fsops, #endif #if defined(LOADER_TFTP_SUPPORT) - &tftp_fsops, + &tftp_fsops, #endif #if defined(LOADER_GZIP_SUPPORT) - &gzipfs_fsops, + &gzipfs_fsops, #endif #if defined(LOADER_BZIP2_SUPPORT) - &bzipfs_fsops, + &bzipfs_fsops, #endif - NULL -}; + NULL}; struct netif_driver *netif_drivers[] = { #if defined(LOADER_NET_SUPPORT) - &uboot_net, + &uboot_net, #endif - NULL, -}; + NULL,}; -struct file_format *file_formats[] = { - &uboot_elf, - NULL -}; +struct file_format *file_formats[] = {&uboot_elf, NULL}; extern struct console uboot_console; -struct console *consoles[] = { - &uboot_console, - NULL -}; +struct console *consoles[] = {&uboot_console, NULL}; +#endif diff --git a/sys/fs/common/gpt.c b/sys/fs/common/gpt.c index 55212b6..87ab8da 100644 --- a/sys/fs/common/gpt.c +++ b/sys/fs/common/gpt.c @@ -46,7 +46,11 @@ #include "gpt.h" */ -#define MAXTBLENTS 128 +#define MAXTBLENTS 128 + +#ifndef BOOTPROG +#define BOOTPROG "Unknown" +#endif static struct gpt_hdr hdr_primary, hdr_backup, *gpthdr; static u_int64_t hdr_primary_lba, hdr_backup_lba; diff --git a/sys/fs/vfs/namei.c b/sys/fs/vfs/namei.c index 396fddf..139bb9c 100644 --- a/sys/fs/vfs/namei.c +++ b/sys/fs/vfs/namei.c @@ -78,6 +78,7 @@ perm = permission(dir, MAY_EXEC); if (len == 2 && name[0] == '.' && name[1] == '.') { + #ifdef _IGNORE if (dir == _current->root) { *result = dir; @@ -92,6 +93,7 @@ dir->i_count++; } #endif + } if (!dir->i_op || !dir->i_op->lookup) { diff --git a/sys/fs/vfs/stat.c b/sys/fs/vfs/stat.c index 86e4755..94ed89e 100644 --- a/sys/fs/vfs/stat.c +++ b/sys/fs/vfs/stat.c @@ -37,6 +37,7 @@ //NOTE: Should we verify that the memory is writable? kprintf("SYS_STAT {%s}", path); + /* switch (flags) { case STAT_LSTAT: @@ -60,6 +61,7 @@ break; } */ + fileDescriptor *fd = fopen(path, "rb"); kprintf("FD: 0x%X", fd); @@ -85,7 +87,6 @@ return(error); } - /* Return stat of path do not follow if link return stat of link */ int sys_lstat(struct thread *td, struct sys_lstat_args *args) { td->td_retval[0] = sys_stat(args->path, args->sb, STAT_LSTAT); diff --git a/sys/i386/systemtask.c b/sys/i386/systemtask.c index f8f111e..f4c5c27 100644 --- a/sys/i386/systemtask.c +++ b/sys/i386/systemtask.c @@ -104,19 +104,13 @@ we free the pages for the process and then free the task */ tmpTask = sched_getDelTask(); -<<<<<<< HEAD + if (tmpTask != 0x0) { - if (tmpTask->imageFd != 0x0) - fclose(tmpTask->imageFd); + if (tmpTask->files[0] != 0x0) + fclose(tmpTask->files[0]); vmm_freeProcessPages(tmpTask->id); kfree(tmpTask); -======= - if ( tmpTask != 0x0 ) { - if ( tmpTask->files[0] != 0x0 ) - fclose( tmpTask->files[0] ); - vmm_freeProcessPages( tmpTask->id ); - kfree( tmpTask ); ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git + } videoBuffer[0] = systemVitals->sysTicks; sched_yield(); @@ -124,8 +118,3 @@ return; } - -/*** - END - ***/ - diff --git a/sys/i386/trap.c b/sys/i386/trap.c index 77677fc..a91a728 100644 --- a/sys/i386/trap.c +++ b/sys/i386/trap.c @@ -33,8 +33,6 @@ #include #include -int kmain(uint32_t); - #define KERNEL_STACK 0x2000 static void trap_end_task(char *string, struct trapframe *regs, long error_code); diff --git a/sys/include/isa/atkbd.h b/sys/include/isa/atkbd.h new file mode 100644 index 0000000..c1e41d9 --- /dev/null +++ b/sys/include/isa/atkbd.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ISA_ATKBD_H +#define _ISA_ATKBD_H + +#define shiftKey 1 +#define controlKey 2 +#define altKey 4 +#define ledNumlock 2 +#define ledScrolllock 1 +#define ledCapslock 4 + +int atkbd_init(); +void atkbd_isr(); + +void keyboardHandler(); +void setLED(); + + +#endif /* END _ISA_ATKBD_H */ diff --git a/sys/include/net/netif.h b/sys/include/net/netif.h index f7b0941..1b30d2e 100644 --- a/sys/include/net/netif.h +++ b/sys/include/net/netif.h @@ -55,7 +55,7 @@ char *buffer; }; -struct nicBuffer *tmpBuf; +extern struct nicBuffer *tmpBuf; #ifdef __cplusplus extern "C" { diff --git a/sys/include/objgfx/objgfx30.h b/sys/include/objgfx/objgfx30.h new file mode 100644 index 0000000..d961d0b --- /dev/null +++ b/sys/include/objgfx/objgfx30.h @@ -0,0 +1,236 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * objgfx30.h + * + * Created on: Jan 12, 2018 + * Author: cwolsen + */ + +#ifndef SYS_INCLUDE_OBJGFX_OBJGFX30_H_ +#define SYS_INCLUDE_OBJGFX_OBJGFX30_H_ + +#include // for NULL + +#define RadToDeg 180.0/3.14159265358979; + +typedef signed char Int8; +typedef signed short int Int16; +typedef signed long int Int32; + +typedef unsigned char uInt8; +typedef unsigned short int uInt16; +typedef unsigned long int uInt32; + +enum ogDataState { + ogNONE, ogOWNER, ogALIASING +}; + +typedef struct { + uInt8 red; + uInt8 green; + uInt8 blue; +} TRGB; + +typedef struct { + uInt8 red; + uInt8 green; + uInt8 blue; + uInt8 alpha; +} TRGBA; + +typedef struct { + uInt16 ModeAttributes; + uInt8 WindowAFlags; + uInt8 WindowBFlags; + uInt16 Granularity; + uInt16 WindowSize; + uInt16 WindowASeg; + uInt16 WindowBSeg; + void* BankSwitch; + uInt16 BytesPerLine; + uInt16 xRes, yRes; + uInt8 CharWidth; + uInt8 CharHeight; + uInt8 NumBitPlanes; + uInt8 BitsPerPixel; + uInt8 NumberOfBanks; + uInt8 MemoryModel; + uInt8 BankSize; + uInt8 NumOfImagePages; + uInt8 Reserved; + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uInt8 RedMaskSize; + uInt8 RedFieldPosition; + uInt8 GreenMaskSize; + uInt8 GreenFieldPosition; + uInt8 BlueMaskSize; + uInt8 BlueFieldPosition; + uInt8 AlphaMaskSize; + uInt8 AlphaFieldPosition; + uInt8 DirectColourMode; + // VESA 2.0 specific fields + uInt32 PhysBasePtr; + void* OffScreenMemOffset; + uInt16 OffScreenMemSize; + uInt8 paddington[461]; +} TMode_Rec; + +typedef struct { + char VBESignature[4]; + uInt8 minVersion; + uInt8 majVersion; + char * OEMStringPtr; + uInt32 Capabilities; + uInt16* VideoModePtr; + uInt16 TotalMemory; + // VESA 2.0 specific fields + uInt16 OEMSoftwareRev; + char * OEMVendorNamePtr; + char * OEMProductNamePtr; + char * OEMProductRevPtr; + uInt8 paddington[474]; +} TVESA_Rec; + +typedef struct { + Int32 x; + Int32 y; +} TPoint; + +typedef struct { + uInt8 BPP; + uInt8 RedFieldPosition; + uInt8 GreenFieldPosition; + uInt8 BlueFieldPosition; + uInt8 AlphaFieldPosition; + uInt8 RedMaskSize; + uInt8 GreenMaskSize; + uInt8 BlueMaskSize; + uInt8 AlphaMaskSize; +} TPixelFmt; + +// Default pixel formats + +const TPixelFmt NULL_PIXFMT = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const TPixelFmt DEF_PIXFMT_8BPP = { 8, 0, 0, 0, 0, 0, 0, 0, 0 }; +const TPixelFmt DEF_PIXFMT_15BPP = { 15, 10, 5, 0, 15, 5, 5, 5, 1 }; +const TPixelFmt DEF_PIXFMT_16BPP = { 16, 11, 5, 0, 0, 5, 6, 5, 0 }; +const TPixelFmt DEF_PIXFMT_24BPP = { 24, 16, 8, 0, 8, 8, 8 }; +const TPixelFmt DEF_PIXFMT_32BPP = { 32, 16, 8, 0, 24, 8, 8, 8, 8 }; +const TPixelFmt DEF_MAC_PIXFMT_16BPP = { 16, 8, 4, 0, 12, 4, 4, 4, 4 }; + +#include "defpal.inc" + +class TGfx0 { + protected: + TGfx0* Owner; + uInt32 xRes, yRes; + uInt32 MaxX, MaxY; + uInt32 bSize; // buffer size (in bytes) + uInt32 lSize; // LineOfs size (in bytes) + uInt32 TransparentColor; + ogDataState DataState; + uInt8 BPP; // bits per pixel + uInt8 RedFieldPosition; + uInt8 GreenFieldPosition; + uInt8 BlueFieldPosition; + uInt8AlphaFieldPosition; + uInt8 RedShifter; + uInt8 GreenShifter; + uInt8 BlueShifter; + uInt8AlphaShifter; + bool AntiAlias; + bool clipLine(Int32&, Int32&, Int32&, Int32&); + void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + void aaRawLine(uInt32, uInt32, uInt32, uInt32, uInt32); + public: + void* Buffer; + uInt32* LineOfs; + TRGB* pal; + TGfx0(void); + bool ogAlias(TGfx0&, uInt32, uInt32, uInt32, uInt32); + void ogArc(Int32, Int32, uInt32, uInt32, uInt32, uInt32); + void ogBSpline(uInt32, TPoint*, uInt32, uInt32); + void ogCircle(Int32, Int32, uInt32, uInt32); + void ogClear(uInt32); + bool ogClone(TGfx0&); + void ogCopy(TGfx0&); + void ogCopyBuf(Int32, Int32, TGfx0&, Int32, Int32, Int32, Int32); + bool ogCreate(uInt32, uInt32, TPixelFmt); + void ogCubicBezierCurve(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, uInt32, uInt32); + void ogCurve(Int32, Int32, Int32, Int32, Int32, Int32, uInt32, uInt32); + void ogFillCircle(Int32, Int32, uInt32, uInt32); + void ogFillConvexPolygon(uInt32, TPoint*, uInt32); + void ogFillPolygon(uInt32, TPoint*, uInt32); + void ogFillRect(Int32, Int32, Int32, Int32, uInt32); + void ogFillTriangle(Int32, Int32, Int32, Int32, Int32, Int32, uInt32); + bool ogGetAntiAlias(void); + uInt8 ogGetBPP(void); + ogDataState ogGetDataState(void); + uInt32 ogGetMaxX(void); + uInt32 ogGetMaxY(void); + void ogGetPal(void); + void ogGetPixFmt(TPixelFmt&); + uInt32 ogGetPixel(Int32, Int32); + uInt32 ogGetTransparentColor(void); + void ogHFlip(void); + void ogHLine(Int32, Int32, Int32, uInt32); + void ogLine(Int32, Int32, Int32, Int32, uInt32); + void ogLoadPal(const char *); + void ogPolygon(uInt32, TPoint*, uInt32); + void ogRect(Int32, Int32, Int32, Int32, uInt32); + uInt32 ogRGB(uInt8, uInt8, uInt8); + void ogSavePal(const char *); + void ogScaleBuf(Int32, Int32, Int32, Int32, TGfx0&, Int32, Int32, Int32, Int32); + bool ogSetAntiAlias(bool); + void ogSetPixel(uInt32, uInt32, uInt32); + void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8); + uInt32 ogSetTransparentColor(uInt32); + void ogSpline(uInt32, TPoint*, uInt32, uInt32); + void ogTriangle(Int32, Int32, Int32, Int32, Int32, Int32, uInt32); + void ogUnpackRGB(uInt32, uInt8&, uInt8&, uInt8&); + void ogVFlip(void); + void ogVLine(Int32, Int32, Int32, uInt32); + ~TGfx0(void); +}; +// TGfx0 + +class TScreen: public TGfx0 { + protected: + TVESA_Rec* VESARec; + TMode_Rec* ModeRec; + bool InGraphics; + public: + TScreen(void); + void setupMode(uInt16); + ~TScreen(void); +}; +// TScreen + +#endif /* END SYS_INCLUDE_OBJGFX_OBJGFX30_H_ */ diff --git a/sys/include/objgfx/ogDisplay_VESA.h b/sys/include/objgfx/ogDisplay_VESA.h index 83410c0..9633de3 100755 --- a/sys/include/objgfx/ogDisplay_VESA.h +++ b/sys/include/objgfx/ogDisplay_VESA.h @@ -26,12 +26,11 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef OGDISPLAY_VESA_H -#define OGDISPLAY_VESA_H +#ifndef _OBJGFX_OGDISPLAY_VESA_H +#define _OBJGFX_OGDISPLAY_VESA_H #include - -#include "objgfx30.h" +#include struct TMode_Rec { uInt16 ModeAttributes __attribute__((packed)); @@ -66,7 +65,7 @@ uInt8 DirectColourMode __attribute__((packed)); // VESA 2.0 specific fields uInt32 physBasePtr __attribute__((packed)); - void* OffScreenMemOffset __attribute__((packed)); + void *OffScreenMemOffset __attribute__((packed)); uInt16 OffScreenMemSize __attribute__((packed)); uInt8 paddington[461] __attribute__((packed)); }; diff --git a/sys/include/stdatomic.h b/sys/include/stdatomic.h deleted file mode 100644 index f03022f..0000000 --- a/sys/include/stdatomic.h +++ /dev/null @@ -1,392 +0,0 @@ -/*- - * Copyright (c) 2011 Ed Schouten - * David Chisnall - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: releng/11.1/sys/sys/stdatomic.h 263998 2014-04-01 14:46:11Z tijl $ - */ - -#ifndef _STDATOMIC_H_ -#define _STDATOMIC_H_ - -#include -#include - -#if __has_extension(c_atomic) || __has_extension(cxx_atomic) -#define __CLANG_ATOMICS -#elif __GNUC_PREREQ__(4, 7) -#define __GNUC_ATOMICS -#elif defined(__GNUC__) -#define __SYNC_ATOMICS -#else -#error "stdatomic.h does not support your compiler" -#endif - -/* - * 7.17.1 Atomic lock-free macros. - */ - -#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE -#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE -#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE -#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE -#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE -#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE -#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_INT_LOCK_FREE -#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_LONG_LOCK_FREE -#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE -#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE -#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE -#endif - -/* - * 7.17.2 Initialization. - */ - -#if defined(__CLANG_ATOMICS) -#define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __c11_atomic_init(obj, value) -#else -#define ATOMIC_VAR_INIT(value) { .__val = (value) } -#define atomic_init(obj, value) ((void)((obj)->__val = (value))) -#endif - -/* - * Clang and recent GCC both provide predefined macros for the memory - * orderings. If we are using a compiler that doesn't define them, use the - * clang values - these will be ignored in the fallback path. - */ - -#ifndef __ATOMIC_RELAXED -#define __ATOMIC_RELAXED 0 -#endif -#ifndef __ATOMIC_CONSUME -#define __ATOMIC_CONSUME 1 -#endif -#ifndef __ATOMIC_ACQUIRE -#define __ATOMIC_ACQUIRE 2 -#endif -#ifndef __ATOMIC_RELEASE -#define __ATOMIC_RELEASE 3 -#endif -#ifndef __ATOMIC_ACQ_REL -#define __ATOMIC_ACQ_REL 4 -#endif -#ifndef __ATOMIC_SEQ_CST -#define __ATOMIC_SEQ_CST 5 -#endif - -/* - * 7.17.3 Order and consistency. - * - * The memory_order_* constants that denote the barrier behaviour of the - * atomic operations. - */ - -typedef enum { - memory_order_relaxed = __ATOMIC_RELAXED, memory_order_consume = __ATOMIC_CONSUME, memory_order_acquire = __ATOMIC_ACQUIRE, memory_order_release = __ATOMIC_RELEASE, memory_order_acq_rel = __ATOMIC_ACQ_REL, memory_order_seq_cst = __ATOMIC_SEQ_CST -} memory_order; - -/* - * 7.17.4 Fences. - */ - -static __inline void atomic_thread_fence(memory_order __order __unused) { - -#ifdef __CLANG_ATOMICS - __c11_atomic_thread_fence(__order); -#elif defined(__GNUC_ATOMICS) - __atomic_thread_fence(__order); -#else - __sync_synchronize(); -#endif -} - -static __inline void atomic_signal_fence(memory_order __order __unused) { - -#ifdef __CLANG_ATOMICS - __c11_atomic_signal_fence(__order); -#elif defined(__GNUC_ATOMICS) - __atomic_signal_fence(__order); -#else - __asm volatile ("" ::: "memory"); -#endif -} - -/* - * 7.17.5 Lock-free property. - */ - -#if defined(_KERNEL) -/* Atomics in kernelspace are always lock-free. */ -#define atomic_is_lock_free(obj) \ - ((void)(obj), (_Bool)1) -#elif defined(__CLANG_ATOMICS) -#define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof(*(obj)), obj) -#elif defined(__GNUC_ATOMICS) -#define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) -#else -#define atomic_is_lock_free(obj) \ - ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) -#endif - -/* - * 7.17.6 Atomic integer types. - */ - -typedef _Atomic(_Bool) atomic_bool; -typedef _Atomic(char) atomic_char; -typedef _Atomic(signed char) atomic_schar; -typedef _Atomic(unsigned char) atomic_uchar; -typedef _Atomic(short) atomic_short; -typedef _Atomic(unsigned short) atomic_ushort; -typedef _Atomic(int) atomic_int; -typedef _Atomic(unsigned int) atomic_uint; -typedef _Atomic(long) atomic_long; -typedef _Atomic(unsigned long) atomic_ulong; -typedef _Atomic(long long) atomic_llong; -typedef _Atomic(unsigned long long) atomic_ullong; -typedef _Atomic(__char16_t) atomic_char16_t; -typedef _Atomic(__char32_t) atomic_char32_t; -typedef _Atomic(___wchar_t) atomic_wchar_t; -typedef _Atomic(__int_least8_t) atomic_int_least8_t; -typedef _Atomic(__uint_least8_t) atomic_uint_least8_t; -typedef _Atomic(__int_least16_t) atomic_int_least16_t; -typedef _Atomic(__uint_least16_t) atomic_uint_least16_t; -typedef _Atomic(__int_least32_t) atomic_int_least32_t; -typedef _Atomic(__uint_least32_t) atomic_uint_least32_t; -typedef _Atomic(__int_least64_t) atomic_int_least64_t; -typedef _Atomic(__uint_least64_t) atomic_uint_least64_t; -typedef _Atomic(__int_fast8_t) atomic_int_fast8_t; -typedef _Atomic(__uint_fast8_t) atomic_uint_fast8_t; -typedef _Atomic(__int_fast16_t) atomic_int_fast16_t; -typedef _Atomic(__uint_fast16_t) atomic_uint_fast16_t; -typedef _Atomic(__int_fast32_t) atomic_int_fast32_t; -typedef _Atomic(__uint_fast32_t) atomic_uint_fast32_t; -typedef _Atomic(__int_fast64_t) atomic_int_fast64_t; -typedef _Atomic(__uint_fast64_t) atomic_uint_fast64_t; -typedef _Atomic(__intptr_t) atomic_intptr_t; -typedef _Atomic(__uintptr_t) atomic_uintptr_t; -typedef _Atomic(__size_t) atomic_size_t; -typedef _Atomic(__ptrdiff_t) atomic_ptrdiff_t; -typedef _Atomic(__intmax_t) atomic_intmax_t; -typedef _Atomic(__uintmax_t) atomic_uintmax_t; - -/* - * 7.17.7 Operations on atomic types. - */ - -/* - * Compiler-specific operations. - */ - -#if defined(__CLANG_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_strong(object, expected, desired, \ - success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_weak(object, expected, desired, \ - success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __c11_atomic_exchange(object, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __c11_atomic_fetch_add(object, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __c11_atomic_fetch_and(object, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __c11_atomic_fetch_or(object, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __c11_atomic_fetch_sub(object, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __c11_atomic_fetch_xor(object, operand, order) -#define atomic_load_explicit(object, order) \ - __c11_atomic_load(object, order) -#define atomic_store_explicit(object, desired, order) \ - __c11_atomic_store(object, desired, order) -#elif defined(__GNUC_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 0, success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 1, success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __atomic_exchange_n(&(object)->__val, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(&(object)->__val, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __atomic_fetch_and(&(object)->__val, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __atomic_fetch_or(&(object)->__val, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(&(object)->__val, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __atomic_fetch_xor(&(object)->__val, operand, order) -#define atomic_load_explicit(object, order) \ - __atomic_load_n(&(object)->__val, order) -#define atomic_store_explicit(object, desired, order) \ - __atomic_store_n(&(object)->__val, desired, order) -#else -#define __atomic_apply_stride(object, operand) \ - (((__typeof__((object)->__val))0) + (operand)) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) __extension__ ({ \ - __typeof__(expected) __ep = (expected); \ - __typeof__(*__ep) __e = *__ep; \ - (void)(success); (void)(failure); \ - (_Bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ - __e, desired)) == __e); \ -}) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) -#if __has_builtin(__sync_swap) -/* Clang provides a full-barrier atomic exchange - use it if available. */ -#define atomic_exchange_explicit(object, desired, order) \ - ((void)(order), __sync_swap(&(object)->__val, desired)) -#else -/* - * __sync_lock_test_and_set() is only an acquire barrier in theory (although in - * practice it is usually a full barrier) so we need an explicit barrier before - * it. - */ -#define atomic_exchange_explicit(object, desired, order) \ -__extension__ ({ \ - __typeof__(object) __o = (object); \ - __typeof__(desired) __d = (desired); \ - (void)(order); \ - __sync_synchronize(); \ - __sync_lock_test_and_set(&(__o)->__val, __d); \ -}) -#endif -#define atomic_fetch_add_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_add(&(object)->__val, \ - __atomic_apply_stride(object, operand))) -#define atomic_fetch_and_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) -#define atomic_fetch_or_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) -#define atomic_fetch_sub_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ - __atomic_apply_stride(object, operand))) -#define atomic_fetch_xor_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) -#define atomic_load_explicit(object, order) \ - ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) -#define atomic_store_explicit(object, desired, order) \ - ((void)atomic_exchange_explicit(object, desired, order)) -#endif - -/* - * Convenience functions. - * - * Don't provide these in kernel space. In kernel space, we should be - * disciplined enough to always provide explicit barriers. - */ - -#ifndef _KERNEL -#define atomic_compare_exchange_strong(object, expected, desired) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_exchange(object, desired) \ - atomic_exchange_explicit(object, desired, memory_order_seq_cst) -#define atomic_fetch_add(object, operand) \ - atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_and(object, operand) \ - atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_or(object, operand) \ - atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_sub(object, operand) \ - atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_xor(object, operand) \ - atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) -#define atomic_load(object) \ - atomic_load_explicit(object, memory_order_seq_cst) -#define atomic_store(object, desired) \ - atomic_store_explicit(object, desired, memory_order_seq_cst) -#endif /* !_KERNEL */ - -/* - * 7.17.8 Atomic flag type and operations. - * - * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some - * kind of compiler built-in type we could use? - */ - -typedef struct { - atomic_bool __flag; -} atomic_flag; - -#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } - -static __inline _Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, memory_order __order) { - return (atomic_exchange_explicit(&__object->__flag, 1, __order)); -} - -static __inline void atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) { - - atomic_store_explicit(&__object->__flag, 0, __order); -} - -#ifndef _KERNEL -static __inline _Bool atomic_flag_test_and_set(volatile atomic_flag *__object) { - - return (atomic_flag_test_and_set_explicit(__object, memory_order_seq_cst)); -} - -static __inline void atomic_flag_clear(volatile atomic_flag *__object) { - - atomic_flag_clear_explicit(__object, memory_order_seq_cst); -} -#endif /* !_KERNEL */ - -#endif /* !_STDATOMIC_H_ */ diff --git a/sys/include/ubixos/ubthread.h b/sys/include/ubixos/ubthread.h index 8d71349..deb7125 100644 --- a/sys/include/ubixos/ubthread.h +++ b/sys/include/ubixos/ubthread.h @@ -30,7 +30,6 @@ #define _UBTHREAD_H #include -#include #include #include @@ -46,7 +45,7 @@ typedef struct ubthread_mutex *ubthread_mutex_t; struct ubthread { - kTask_t *task; + struct taskStruct *task; }; struct ubthread_cond { @@ -75,12 +74,12 @@ ubthread_mutex_t *mutex; }; -kTask_t *ubthread_self(); +struct taskStruct *ubthread_self(); int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr); int ubthread_mutex_init(ubthread_mutex_t *mutex, const uInt32 attr); int ubthread_cond_destroy(ubthread_cond_t *cond); int ubthread_mutex_destroy(ubthread_mutex_t *mutex); -int ubthread_create(kTask_t **thread, const uInt32 *attr, void (*tproc)(void), void *arg); +int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void (*tproc)(void), void *arg); int ubthread_mutex_lock(ubthread_mutex_t *mutex); int ubthread_mutex_unlock(ubthread_mutex_t *mutex); int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime); diff --git a/sys/isa/atkbd.c b/sys/isa/atkbd.c index 46d0f59..687f800 100644 --- a/sys/isa/atkbd.c +++ b/sys/isa/atkbd.c @@ -152,6 +152,7 @@ ************************************************************************/ int atkbd_init() { + /* Insert the IDT vector for the keyboard handler */ setVector(&atkbd_isr, mVec + 0x1, dPresent + dInt + dDpl0); diff --git a/sys/isa/ne2k.c b/sys/isa/ne2k.c index ffe2dfe..f215329 100644 --- a/sys/isa/ne2k.c +++ b/sys/isa/ne2k.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include @@ -294,7 +295,8 @@ static int dp_pkt2user(struct device *dev, int page, int length) { int last = 0x0; - struct nicBuffer *tmpBuf = 0x0; + + struct nicBuffer *tBuf = 0x0; last = page + (length - 1) / DP_PAGESIZE; @@ -302,8 +304,8 @@ kprintf("FOOK STOP PAGE!!!"); } else { - tmpBuf = ne2kAllocBuffer(length); - NICtoPC(dev, tmpBuf->buffer, length, page * DP_PAGESIZE + sizeof(dp_rcvhdr_t)); + tBuf = ne2kAllocBuffer(length); + NICtoPC(dev, tBuf->buffer, length, page * DP_PAGESIZE + sizeof(dp_rcvhdr_t)); } return (OK); } diff --git a/sys/kernel/access.c b/sys/kernel/access.c index 0f60ee6..2e5df39 100644 --- a/sys/kernel/access.c +++ b/sys/kernel/access.c @@ -80,21 +80,11 @@ if (grp == _current->egid) return 1; -<<<<<<< HEAD - for (i = 0; i < NGROUPS; i++) { - if (_current->groups[i] == NOGROUP) + for (i = 0; i < NR_GROUPS; i++) { + if (_current->groups[i] == NO_GROUP) break; if (_current->groups[i] == grp) return 1; } return 0; -======= - for (i = 0; i < NR_GROUPS; i++) { - if (_current->groups[i] == NO_GROUP) - break; - if (_current->groups[i] == grp) - return 1; - } - return 0; ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git } diff --git a/sys/kernel/kern_sysctl.c b/sys/kernel/kern_sysctl.c index 58e7d2e..b444472 100644 --- a/sys/kernel/kern_sysctl.c +++ b/sys/kernel/kern_sysctl.c @@ -190,19 +190,10 @@ endTask(_current->id); } -<<<<<<< HEAD if ((uint32_t) uap->oldlenp < tmpCtl->val_len) - memcpy(uap->old, tmpCtl->value, (uInt32) uap->oldlenp); -======= - if ( (uint32_t) uap->oldlenp < tmpCtl->val_len ) - memcpy( uap->oldp, tmpCtl->value, (uInt32) uap->oldlenp ); ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git + memcpy(uap->oldp, tmpCtl->value, (uInt32) uap->oldlenp); else -<<<<<<< HEAD - memcpy(uap->old, tmpCtl->value, tmpCtl->val_len); -======= - memcpy( uap->oldp, tmpCtl->value, tmpCtl->val_len ); ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git + memcpy(uap->oldp, tmpCtl->value, tmpCtl->val_len); td->td_retval[0] = 0x0; diff --git a/sys/kmods/kmod.c b/sys/kmods/kmod.c index 518b54f..7b76bbe 100644 --- a/sys/kmods/kmod.c +++ b/sys/kmods/kmod.c @@ -138,9 +138,11 @@ /* Tells us if the stack should be executable. Failsafe to executable until we add checking */ break; +#ifdef _IGNORE case PT_PAX_FLAGS: /* Not sure... */ break; +#endif default: kprintf("Unhandled Header : %08x\n", programHeader[i].phType); break; diff --git a/sys/pci/lnc.c b/sys/pci/lnc.c index f9dfeb6..67b3b13 100644 --- a/sys/pci/lnc.c +++ b/sys/pci/lnc.c @@ -41,11 +41,13 @@ struct lncInfo *lnc = 0x0; -static struct spinLock lnc_intSpinLock = SPIN_LOCK_INITIALIZER; +//static struct spinLock lnc_intSpinLock = SPIN_LOCK_INITIALIZER; -static char const * const nicIdent[] = { "Unknown", "BICC", "NE2100", "DEPCA", "CNET98S" }; +static const char * const nicIdent[] = { "Unknown", "BICC", "NE2100", "DEPCA", "CNET98S" }; -static char const * const icIdent[] = { "Unknown", "LANCE", "C-LANCE", "PCnet-ISA", "PCnet-ISA+", "PCnet-ISA II", "PCnet-32 VL-Bus", "PCnet-PCI", "PCnet-PCI II", "PCnet-FAST", "PCnet-FAST+", "PCnet-Home", }; +static const char * const icIdent[] = { "Unknown", "LANCE", "C-LANCE", "PCnet-ISA", "PCnet-ISA+", "PCnet-ISA II", "PCnet-32 VL-Bus", "PCnet-PCI", "PCnet-PCI II", "PCnet-FAST", "PCnet-FAST+", "PCnet-Home", }; + +struct nicBuffer *tmpBuf; void lnc_writeCSR(struct lncInfo *lnc, uint16_t port, uint16_t val) { outportWord(lnc->ioAddr + RAP, port); diff --git a/sys/sde/main.cc b/sys/sde/main.cc index 6656340..11b9735 100644 --- a/sys/sde/main.cc +++ b/sys/sde/main.cc @@ -66,13 +66,13 @@ switch (tmp->status) { case registerWindow: buf = (ogSurface *) tmp->buf; - buf->buffer = (void *) vmmMapFromTask(tmp->pid, buf->buffer, buf->bSize); + buf->buffer = (void *) vmm_mapFromTask(tmp->pid, buf->buffer, buf->bSize); if (buf->buffer == 0x0) { kprintf("Error: buf->buffer\n"); while (1) ; } - buf->lineOfs = (uInt32 *) vmmMapFromTask(tmp->pid, buf->lineOfs, buf->lSize); + buf->lineOfs = (uInt32 *) vmm_mapFromTask(tmp->pid, buf->lineOfs, buf->lSize); if (buf->lineOfs == 0x0) { kprintf("Error: buf->lineOfs\n"); while (1) diff --git a/sys/sde/ogDisplay_UbixOS.cc b/sys/sde/ogDisplay_UbixOS.cc index 886c193..650d6ca 100755 --- a/sys/sde/ogDisplay_UbixOS.cc +++ b/sys/sde/ogDisplay_UbixOS.cc @@ -172,7 +172,7 @@ printOff = 0; for (i = 0x0; i < ((size) / 4096); i++) { - if ((vmm_remapPage(modeInfo->physBasePtr + (i * 0x1000), modeInfo->physBasePtr + (i * 0x1000), KERNEL_PAGE_DEFAULT)) == 0x0) + if ((vmm_remapPage(modeInfo->physBasePtr + (i * 0x1000), modeInfo->physBasePtr + (i * 0x1000), KERNEL_PAGE_DEFAULT, -2)) == 0x0) kpanic("Error: vmm_remapPage failed\n"); } // for i