diff --git a/bin/Makefile.incl b/bin/Makefile.incl index 47986f7..5ced5b5 100644 --- a/bin/Makefile.incl +++ b/bin/Makefile.incl @@ -1,4 +1,5 @@ # 'bin' options +BUILD_DIR?=${SRCTOP}/build CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -Wno-unused-command-line-argument diff --git a/bin/cat/Makefile b/bin/cat/Makefile index e92c8fd..d2ac0b5 100644 --- a/bin/cat/Makefile +++ b/bin/cat/Makefile @@ -21,7 +21,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../../build/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) #strip $(BINARY) # Compile the source files @@ -45,4 +45,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) ../../build/bin/$(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/bin/launcher/Makefile b/bin/launcher/Makefile index 21974b0..955a179 100644 --- a/bin/launcher/Makefile +++ b/bin/launcher/Makefile @@ -23,7 +23,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../build/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) strip $(BINARY) # Compile the source files @@ -47,4 +47,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) $(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/bin/login/Makefile b/bin/login/Makefile index 01e2f78..931be85 100644 --- a/bin/login/Makefile +++ b/bin/login/Makefile @@ -41,7 +41,7 @@ $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< .S.o: - $(CC) -Wall $(CLFAGS) $(INCLUDES) -c -o $@ $< + $(CC) -Wall $(CFLAGS) $(INCLUDES) -c -o $@ $< # Clean Up The junk clean: diff --git a/bin/ls/Makefile b/bin/ls/Makefile index 55ec9fd..53379b1 100644 --- a/bin/ls/Makefile +++ b/bin/ls/Makefile @@ -21,7 +21,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../../build/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) #strip $(BINARY) # Compile the source files diff --git a/bin/mount/Makefile b/bin/mount/Makefile index a860e2d..cc104b0 100644 --- a/bin/mount/Makefile +++ b/bin/mount/Makefile @@ -21,7 +21,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../../build/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) strip $(BINARY) # Compile the source files @@ -42,4 +42,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) ../../build/bin/$(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/bin/muffin/Makefile b/bin/muffin/Makefile index 7d52000..8e8fa19 100644 --- a/bin/muffin/Makefile +++ b/bin/muffin/Makefile @@ -28,7 +28,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../../build/bin/$@ $(STARTUP) $(LIBRARIES) $(LIBRARIES2) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(LIBRARIES2) $(OBJS) strip $(BINARY) # Compile the source files @@ -49,4 +49,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) ../../build/bin/$(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/bin/sh/Makefile b/bin/sh/Makefile index 47eeb1d..262aa61 100644 --- a/bin/sh/Makefile +++ b/bin/sh/Makefile @@ -25,7 +25,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../../build/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) #strip $(BINARY) # Compile the source files @@ -46,4 +46,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) ../../build/bin/$(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/bin/shell/Makefile b/bin/shell/Makefile index dbf897e..867ca4f 100644 --- a/bin/shell/Makefile +++ b/bin/shell/Makefile @@ -17,12 +17,12 @@ #Objects OBJS = main.o error.o commands.o exec.o input.o -LIBRARIES = ../../build/lib/libc_old.so ../../build/lib/ubix_api.so +#LIBRARIES = ../../build/lib/libc_old.so ../../build/lib/ubix_api.so # Link The Binary $(BINARY) : $(OBJS) $(CC) $(CFLAGS) -o $(BUILD_DIR)/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) - strip ${BUILD_DIR}/bin/$(BINARY) +# strip ${BUILD_DIR}/bin/$(BINARY) # Compile the source files .cpp.o: @@ -41,7 +41,7 @@ $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< .S.o: - $(CC) -Wall $(CLFAGS) $(INCLUDES) -c -o $@ $< + $(CC) -Wall $(CFLAGS) $(INCLUDES) -c -o $@ $< # Clean Up The junk clean: diff --git a/bin/shell/main.c b/bin/shell/main.c index 36d564e..07a965e 100644 --- a/bin/shell/main.c +++ b/bin/shell/main.c @@ -34,22 +34,28 @@ char *cwc = 0x0; int main() { + unsigned int *segbase = 0x0; + + __asm __volatile("movl %%gs:0, %0" : "=r" (segbase)); + + printf("Segbase: 0x%X - 0x%X\n", segbase, &segbase); char *buffer = (char *) malloc( 512 ); inputBuffer *inBuf = (inputBuffer *) malloc( sizeof(inputBuffer) ); machine = (char *) malloc( 32 ); cwd = (char *) malloc( 1024 ); + memset(cwd, 'A', 1024); + cwd[1022] = '\n'; + cwd[1023] = '\0'; sprintf( machine, "uBixCube" ); getcwd( cwd, 1024 ); -printf("Is this My ERROR?"); - - //MrOlsen 2017-11-17 printf( "[0x%X]\n", ubix_test() ); - while ( 1 ) { - aGain: printf( "%s@%s# ", machine, cwd ); + aGain: + + printf( "%s@%s# ", machine, cwd ); gets( (char *) buffer ); if ( buffer[0] == 0x0 ) diff --git a/bin/views/Makefile b/bin/views/Makefile index 1de7a94..9e0e330 100644 --- a/bin/views/Makefile +++ b/bin/views/Makefile @@ -25,7 +25,7 @@ # Link The Binary $(BINARY) : $(OBJS) - $(CC) $(CFLAGS) -o ../build/$@ $(STARTUP) $(LIBRARIES) $(OBJS) + $(CC) $(CFLAGS) -o ${BUILD_DIR}/bin/$@ $(STARTUP) $(LIBRARIES) $(OBJS) strip $(BINARY) # Compile the source files @@ -46,4 +46,4 @@ # Clean Up The junk clean: - $(REMOVE) $(OBJS) ../build/$(BINARY) + $(REMOVE) $(OBJS) ${BUILD_DIR}/bin/$(BINARY) diff --git a/lib/libc_old/generic/getcwd.c b/lib/libc_old/generic/getcwd.c index 2fb53af..2d44c31 100644 --- a/lib/libc_old/generic/getcwd.c +++ b/lib/libc_old/generic/getcwd.c @@ -23,16 +23,19 @@ #include -asm( - ".text \n" - ".globl getcwd \n" - ".type getcwd,@function \n" - "getcwd: \n" - "movl $326,%eax \n" - "int $0x80 \n" - "ret \n" -); +char *_getcwd(char *buf, size_t size); +asm( + ".globl _getcwd\n" + "_getcwd:\n" + "movl $0x146,%eax\n" + "int $0x80\n" + "ret\n" + ); + +char *getcwd(char *buf, size_t size) { + return(_getcwd(buf,size)); +} /* char *getcwd(char *cwd,uInt32 len) { diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index 026b162..b7c8308 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -840,6 +840,10 @@ case PT_PHDR: proghdr = programHeader[i].phVaddr; break; + case PT_TLS: + kprintf("Thread Local Storage: [0x%X]", programHeader[i].phVaddr); + //iFrame->gs = programHeader[i].phVaddr; + break; default: break; } diff --git a/sys/i386/syscall.c b/sys/i386/syscall.c index 98aa225..0e3c627 100644 --- a/sys/i386/syscall.c +++ b/sys/i386/syscall.c @@ -157,9 +157,15 @@ } int sys_getcwd(struct thread *td, struct sys_getcwd_args *args) { - if ( args->buf ) - sprintf( args->buf, "%s", _current->oInfo.cwd ); -kprintf("[CWD: %s]", _current->oInfo.cwd); + char *buf = (char *)args->buf; + kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); + if ( args->buf ) { + sprintf(buf, "%s", _current->oInfo.cwd ); + buf[strlen(_current->oInfo.cwd)] = '\0'; + //MrOlsen (2018-01-01) - Why is sprintf not null terminating + } + kprintf("GETCWD: [%s][0x%X]\n", _current->oInfo.cwd, args->buf); + kprintf("[%s]", args->buf); return (0); } diff --git a/sys/include/sys/elf.h b/sys/include/sys/elf.h index 348489a..1f08379 100644 --- a/sys/include/sys/elf.h +++ b/sys/include/sys/elf.h @@ -86,6 +86,7 @@ #define PT_NOTE 4 #define PT_SHLIB 5 #define PT_PHDR 6 +#define PT_TLS 7 #define PT_LOOS 0x60000000 #define PT_HIOS 0x6fffffff #define PT_LOPROC 0x70000000 diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h index e96fe4a..a7e433b 100644 --- a/sys/include/sys/sysproto.h +++ b/sys/include/sys/sysproto.h @@ -132,9 +132,10 @@ }; struct sys_getcwd_args { - char buf_l_[PADL_( char * )]; - char *buf; - char buf_r_[PADR_( char * )]; + char buf_l_[PADL_( const void * )]; + void *buf; + char buf_r_[PADR_( const void * )]; + char size_l_[PADL_( uint32_t )]; uint32_t size; char size_r_[PADR_( uint32_t )]; diff --git a/sys/kernel/syscall_new.c b/sys/kernel/syscall_new.c index dad7679..76ab262 100644 --- a/sys/kernel/syscall_new.c +++ b/sys/kernel/syscall_new.c @@ -61,7 +61,7 @@ } if ( code > totalCalls ) { - kprintf( "Invalid Call: [%i]\n", frame->tf_eax ); + kprintf( "Invalid Call: [%i:%i]\n", frame->tf_eax, totalCalls ); kpanic("PID: %i", _current->id); } else if ( (uint32_t) systemCalls[code].sc_status == SYSCALL_INVALID ) {