diff --git a/src/bin/ls/main.c b/src/bin/ls/main.c index 0858520..05f97b1 100755 --- a/src/bin/ls/main.c +++ b/src/bin/ls/main.c @@ -39,6 +39,7 @@ int main() { int i = 0x0; + char *pwd = (char *)malloc(256); FILE *fd; struct directoryEntry *dirEntry = (struct directoryEntry *)malloc(4096); if (!(fd = fopen("/","r"))) { @@ -46,8 +47,12 @@ exit(1); } fread(dirEntry,4096,1,fd); + if (!fclose(fd)) { + printf("Error Closing Directory\n"); + } + pwd[0] = '/'; for (i=0;i<(4096/sizeof(struct directoryEntry));i++) { - if (dirEntry[i].fileName[0] > 0) { + if ((dirEntry[i].fileName[0] > 0) && (dirEntry[i].fileName[0] != '/') && (dirEntry[i].fileName[0] != '.')) { printf("%i %i %i %i %s\n",dirEntry[i].permissions,dirEntry[i].uid,dirEntry[i].gid,dirEntry[i].size,dirEntry[i].fileName); } } diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 1008258..856dc63 100755 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -39,9 +39,9 @@ } if (0 == memcmp(tmp, "uname", 5)) printf("UbixOS v0.01a " __DATE__" " __TIME__ " \n"); - if (0 == memcmp(tmp, "exit", 4)) + else if (0 == memcmp(tmp, "exit", 4)) exit(1); - if (0 == memcmp(tmp, "mypid", 5)) + else if (0 == memcmp(tmp, "mypid", 5)) printf("My Pid: [%i]\n",getpid()); else if (memcmp(tmp,"stress", 6) == 0) { while (1) { diff --git a/src/lib/libc/include/stdio.h b/src/lib/libc/include/stdio.h index 4b05046..bcaa035 100755 --- a/src/lib/libc/include/stdio.h +++ b/src/lib/libc/include/stdio.h @@ -55,5 +55,6 @@ int sprintf(char *string, const char *format, ...); char *gets(char *string); size_t fread(void *pointer,size_t size,size_t count, FILE *stream); +int fclose(FILE *fp); #endif \ No newline at end of file diff --git a/src/lib/libc/stdio/Makefile b/src/lib/libc/stdio/Makefile index 52467b7..09eb7ac 100755 --- a/src/lib/libc/stdio/Makefile +++ b/src/lib/libc/stdio/Makefile @@ -15,7 +15,7 @@ REMOVE = rm -f #Objects -OBJS = printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o +OBJS = printf.o vsprintf.o fd.o vfprintf.o fopen.o fread.o fwrite.o fgetc.o sprintf.o gets.o fclose.o #Output OUTPUT = libc.so diff --git a/src/lib/libc/stdio/fopen.c b/src/lib/libc/stdio/fopen.c index 8bd3e05..554c46c 100755 --- a/src/lib/libc/stdio/fopen.c +++ b/src/lib/libc/stdio/fopen.c @@ -27,7 +27,6 @@ FILE *fopen(const char *file,const char *mode) { FILE *fp = malloc(sizeof(FILE)); fp->fd = -1; - //printf("fp->fd: [%i]\n",fp->fd); asm( "int %0\n" : : "i" (0x80),"a" (8),"b" (file),"c" (mode),"d" (fp) diff --git a/src/sys/boot/bootsec.asm b/src/sys/boot/bootsec.asm index f0d8c47..81a911a 100755 --- a/src/sys/boot/bootsec.asm +++ b/src/sys/boot/bootsec.asm @@ -156,9 +156,30 @@ ; Re-enter protected mode ! A20 is already enabled -;mov ax, 0x4f0a +;mov ax,0x4F01 +;mov cx,0x4020 +;mov bx,0x100 +;mov es,bx +;xor di,di ;xor bx,bx ;int 0x10 + + +;mov ax,0x4F02 +;mov bx,0x4020 +;int 0x10 + +;mov ax,0x4F00 +;mov bx,0x100 +;mov es,bx +;xor di,di +;xor bx,bx +;mov byte [es:0],'V' +;mov byte [es:1],'E' +;mov byte [es:2],'S' +;mov byte [es:3],'A' +;int 0x10 + ;xor eax,eax ;mov ax,es ;mov bx,di diff --git a/src/sys/compile/Makefile b/src/sys/compile/Makefile index 21ec586..e2d1c45 100755 --- a/src/sys/compile/Makefile +++ b/src/sys/compile/Makefile @@ -20,7 +20,7 @@ # Link the kernel statically with fixed text+data address @1M $(KERNEL) : $(OBJS) - $(LD) -o $@ $(OBJS) ../init/*.o ../kernel/*.o ../drivers/*.o ../vmm/*.o ../ubixfs/*.o -Ttext 0x10000 + $(LD) -o $@ $(OBJS) ../init/*.o ../kernel/*.o ../drivers/*.o ../vmm/*.o ../ubixfs/*.o -Ttext 0x40000 /usr/bin/strip $@ # Compile the source files diff --git a/src/sys/include/ubixos/syscalls.h b/src/sys/include/ubixos/syscalls.h index 58be1b3..1f4dd1a 100755 --- a/src/sys/include/ubixos/syscalls.h +++ b/src/sys/include/ubixos/syscalls.h @@ -34,12 +34,13 @@ void sysGetFreePage(); void sysFopen(); void sysFread(); +void sysFclose(); typedef void (*functionPTR)(); functionPTR systemCalls[] = { sysFwrite,sysGetpid,sysExit,sysExec,sysFork,sysFgetc,sysCheckPid, - sysGetFreePage,sysFopen,sysFread, + sysGetFreePage,sysFopen,sysFread,sysFclose, }; int totalCalls = sizeof(systemCalls)/sizeof(functionPTR); diff --git a/src/sys/init/main.c b/src/sys/init/main.c index c1bbe40..71d0553 100755 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -51,6 +51,67 @@ union descriptorTableunion *gdt __attribute__ ((packed)); } loadGdt = { (5 * sizeof(union descriptorTableunion) - 1), GDT }; +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; + +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 RsvdMaskSize; + UInt8 RsvdFieldPosition; + 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; + int main(); void _start(void) { @@ -84,6 +145,12 @@ ************************************************************************/ int main() { + /* + long i = 0x0; + long xx = 0x0,yy = 0x0,zz = 0x0; + uLong *testBuffer = 0x40000000; + TMode_Rec *testVesa = 0x1000; + */ initMmap(); //Initialize Memory Map clearScreen(); //Clear The Screen outputVersion(); //Display Version Info @@ -95,6 +162,55 @@ initScheduler(); //Initialize Scheduler initFloppy(); //Initialize Floppy Controller initUbixFS(); //Initialize File System + /* + kprintf("PhysBasePtr: [%i]\n",testVesa->PhysBasePtr); + kprintf("BytesPerLine: [%i]\n",testVesa->BytesPerLine); + kprintf("xRes: [%i]\n",testVesa->xRes); + kprintf("yRes: [%i]\n",testVesa->yRes); + kprintf("BitsPerPixel: [%i]\n",testVesa->BitsPerPixel); + kprintf("NumberOfBanks: [%i]\n",testVesa->NumberOfBanks); + while(1); + + //testVesa->PhysBasePtr = 0x40151C80; + testVesa->PhysBasePtr -= (0x1000 * 16); + for (i=0;i<=(((testVesa->xRes*testVesa->yRes)*(testVesa->BitsPerPixel/1))+(0x1000-1));i+=0x1000) { + remapPage((testVesa->PhysBasePtr + i),(0x40000000 + i)); + } + */ + /* + while (1) { + for (zz=0; zz<64; zz++) + for (yy=-128; yy<=128; yy++) + for (xx=-128; xx<=128; xx++) + testBuffer[(yy+128)*(800*2)+((xx+128)*2)]=xx*yy*zz; + for (zz=0; zz<64; zz++) + for (yy=128; yy>=-128;yy --) + for (xx=128; xx>=-128; xx--) + testBuffer[(yy+128)*(800*2)+((xx+128)*2)]=xx*yy*zz; + } + */ + /* + for (yy = 0;yy < 256;yy++) { + for (xx = 0;xx < 256;xx++) { + testBuffer[yy*800+xx] = (char)xx; + } + } + */ + /* + for (i=0;i<((testVesa->xRes*testVesa->yRes)*4);i++) { + for (zz=0;zz<=0x10;zz++) { + for (xx=0;xx<=0x10;xx++); + } + testBuffer[i] = i; + } + + for (i=0;i<((testVesa->xRes*testVesa->yRes)*4);i++) { + for (zz=0;zz<=0x10;zz++) { + for (xx=0;xx<=0x10;xx++); + } + testBuffer[i] = (i/2); + } + */ execThread(idleThread,0xAFFF,"Idle Thread"); execFile("init"); //kprintf("Free Pages: [%i]\n",freePages); diff --git a/src/sys/ubixfs/file.c b/src/sys/ubixfs/file.c index 4ccf3e1..5149f4c 100755 --- a/src/sys/ubixfs/file.c +++ b/src/sys/ubixfs/file.c @@ -180,7 +180,7 @@ Description: Opens A File Descriptor For A User Task Notes: -************************************************************************/ +************************************************************************/ void sysFopen() { char *file = 0x0,*flags = 0x0; userFileDescriptor *userFd = 0x0; @@ -193,6 +193,13 @@ return; } +/************************************************************************ + +Function: void sysFread(); +Description: Reads SIZE Bytes From The userFd Into DATA +Notes: + +************************************************************************/ void sysFread() { int i = 0x0; char *data = 0x0; @@ -207,4 +214,20 @@ } //Return return; - } \ No newline at end of file + } + +/************************************************************************ + +Function: void sysFclse(); +Description: Closes A File Descriptor For A User Task +Notes: + +************************************************************************/ +void sysFclose() { + int *status = 0x0; + userFileDescriptor *userFd = 0x0; + asm("":"=b" (userFd),"=c" (status)); + *status = fclose(userFd->fd); + //Return + return; + } \ No newline at end of file diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 35d3a2a..3f7622d 100755 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -36,7 +36,6 @@ unsigned short memKb=0; unsigned char irq1State, irq2State; unsigned long cr0; - /* Save States Of IRQ 1 & 2 */ irq1State=inportByte(0x21); irq2State=inportByte(0xA1); diff --git a/ubixos.kdevprj b/ubixos.kdevprj index 35ba869..24ecae6 100755 --- a/ubixos.kdevprj +++ b/ubixos.kdevprj @@ -309,12 +309,18 @@ type=DATA [src/lib/libc/stdio/Makefile.am] -files=src/lib/libc/stdio/printf.c,src/lib/libc/stdio/fprintf.c,src/lib/libc/stdio/fd.c,src/lib/libc/stdio/vfprintf.c,src/lib/libc/stdio/vsprintf.c,src/lib/libc/stdio/fopen.c,src/lib/libc/stdio/fwrite.c,src/lib/libc/stdio/Makefile,src/lib/libc/stdio/fgetc.c,src/lib/libc/stdio/sprintf.c,src/lib/libc/stdio/gets.c,src/lib/libc/stdio/fread.c +files=src/lib/libc/stdio/printf.c,src/lib/libc/stdio/fprintf.c,src/lib/libc/stdio/fd.c,src/lib/libc/stdio/vfprintf.c,src/lib/libc/stdio/vsprintf.c,src/lib/libc/stdio/fopen.c,src/lib/libc/stdio/fwrite.c,src/lib/libc/stdio/Makefile,src/lib/libc/stdio/fgetc.c,src/lib/libc/stdio/sprintf.c,src/lib/libc/stdio/gets.c,src/lib/libc/stdio/fread.c,src/lib/libc/stdio/fclose.c sharedlib_LDFLAGS=-version-info 0:0:1 sharedlib_rootname=stdio sub_dirs= type=static_library +[src/lib/libc/stdio/fclose.c] +dist=true +install=false +install_location= +type=SOURCE + [src/lib/libc/stdio/fd.c] dist=true install=false