diff --git a/src/bin/Makefile b/src/bin/Makefile index aeae246..8313bf2 100644 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -1,7 +1,7 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin login-bin shell-bin ls-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin ttyd-bin stat-bin +all: init-bin login-bin shell-bin ls-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin ttyd-bin stat-bin mount-bin # test-bin pwd-bin cat-bin de-bin goofball-bin init-bin: init @@ -67,6 +67,9 @@ stat-bin: stat (cd stat;make) +mount-bin: mount + (cd mount;make) + clean: (cd cp;make clean) (cd fdisk;make clean) @@ -83,3 +86,4 @@ (cd edit;make clean) (cd ttyd;make clean) (cd stat;make clean) + (cd mount;make clean) diff --git a/src/bin/mount/Makefile b/src/bin/mount/Makefile new file mode 100644 index 0000000..f54faa5 --- /dev/null +++ b/src/bin/mount/Makefile @@ -0,0 +1,45 @@ +# $Id$ +# Application Makefile (C) 2002-2004 The UbixOS Project + +# Include Global 'Source' Options +include ../../Makefile.inc +include ../Makefile.inc + +#Linker +LD = ld + +#Binary File Name +BINARY = mount + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +LIBRARIES = ../../lib/libc_old/libc_old.so + +# Link The Binary +$(BINARY) : $(OBJS) + $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + strip $(BINARY) + +# Compile the source files +.cc.o: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.cc.s: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.c.o: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.c.s: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.S.o: + $(CC) -Wall $(CLFAGS) $(INCLUDES) -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/mount/main.c b/src/bin/mount/main.c new file mode 100644 index 0000000..75a03f1 --- /dev/null +++ b/src/bin/mount/main.c @@ -0,0 +1,28 @@ +#include +#include + +void usage(); + +int main(int argc,char * const argv[]) { + int ch = 0x0; + while ((ch = getopt(argc, argv, "adlF:fo:prwt:uv")) != -1) { + printf("[%i]\n",ch); + switch (ch) { + default: + usage(); + } + argc -= optind; + argv += optind; + } + return(0x0); + } + +void usage() { + + (void)printf("%s\n%s\n%s\n", +"usage: mount [-adflpruvw] [-F fstab] [-o options] [-t ufs | external_type]", +" mount [-dfpruvw] special | node", +" mount [-dfpruvw] [-o options] [-t ufs | external_type] special node"); + exit(1); +} + diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 93e935a..326b74d 100644 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -43,6 +43,8 @@ sprintf(machine,"uBixCube"); getcwd(cwd,1024); + + printf("Oh\n"); printf("[0x%X]\n",ubix_test()); diff --git a/src/include/ansi.h b/src/include/ansi.h new file mode 100644 index 0000000..825b4a6 --- /dev/null +++ b/src/include/ansi.h @@ -0,0 +1,58 @@ +/* The header attempts to decide whether the compiler has enough + * conformance to Standard C for Minix to take advantage of. If so, the + * symbol _ANSI is defined (as 31415). Otherwise _ANSI is not defined + * here, but it may be defined by applications that want to bend the rules. + * The magic number in the definition is to inhibit unnecessary bending + * of the rules. (For consistency with the new '#ifdef _ANSI" tests in + * the headers, _ANSI should really be defined as nothing, but that would + * break many library routines that use "#if _ANSI".) + + * If _ANSI ends up being defined, a macro + * + * _PROTOTYPE(function, params) + * + * is defined. This macro expands in different ways, generating either + * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie) + * prototypes, as needed. Finally, some programs use _CONST, _VOIDSTAR etc + * in such a way that they are portable over both ANSI and K&R compilers. + * The appropriate macros are defined here. + */ + +#ifndef _ANSI_H +#define _ANSI_H + +#if __STDC__ == 1 +#define _ANSI 31459 /* compiler claims full ANSI conformance */ +#endif + +#ifdef __GNUC__ +#define _ANSI 31459 /* gcc conforms enough even in non-ANSI mode */ +#endif + +#ifdef _ANSI + +/* Keep everything for ANSI prototypes. */ +#define _PROTOTYPE(function, params) function params +#define _ARGS(params) params + +#define _VOIDSTAR void * +#define _VOID void +#define _CONST const +#define _VOLATILE volatile +#define _SIZET size_t + +#else + +/* Throw away the parameters for K&R prototypes. */ +#define _PROTOTYPE(function, params) function() +#define _ARGS(params) () + +#define _VOIDSTAR void * +#define _VOID void +#define _CONST +#define _VOLATILE +#define _SIZET int + +#endif /* _ANSI */ + +#endif /* ANSI_H */ diff --git a/src/lib/libc_old/stdio/gets.c b/src/lib/libc_old/stdio/gets.c index 235b15f..cd44811 100644 --- a/src/lib/libc_old/stdio/gets.c +++ b/src/lib/libc_old/stdio/gets.c @@ -31,7 +31,7 @@ char *gets(char *string) { int count=0,ch=0; - while (1) { + while (1) { ch = fgetc(stdin); if(ch == 10) { printf("\n"); @@ -49,6 +49,9 @@ /*** $Log$ + Revision 1.1.1.1 2006/06/01 12:46:10 reddawg + ubix2 + Revision 1.2 2005/10/12 00:13:36 reddawg Removed diff --git a/src/lib/libc_old/stdlib/Makefile b/src/lib/libc_old/stdlib/Makefile index db318b8..73d8ade 100644 --- a/src/lib/libc_old/stdlib/Makefile +++ b/src/lib/libc_old/stdlib/Makefile @@ -6,7 +6,7 @@ include ../../Makefile.inc #Objects -OBJS = strtol.o atoi.o abs.o exit.o malloc.o rand.o +OBJS = strtol.o atoi.o abs.o exit.o malloc.o rand.o getopt.o #Output OUTPUT = libc.so diff --git a/src/lib/libc_old/stdlib/getopt.c b/src/lib/libc_old/stdlib/getopt.c new file mode 100644 index 0000000..4a4c430 --- /dev/null +++ b/src/lib/libc_old/stdlib/getopt.c @@ -0,0 +1,95 @@ +#include +#include +#include + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +int getopt(nargc, nargv, ostr) + int nargc; + char * const nargv[]; + const char *ostr; +{ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + if (optreset || *place == 0) { /* update scanning pointer */ + optreset = 0; + place = nargv[optind]; + if (optind >= nargc || *place++ != '-') { + /* Argument is absent or is not an option */ + place = EMSG; + return (-1); + } + optopt = *place++; + if (optopt == '-' && *place == 0) { + /* "--" => end of options */ + ++optind; + place = EMSG; + return (-1); + } + if (optopt == 0) { + /* Solitary '-', treat as a '-' option + if the program (eg su) is looking for it. */ + place = EMSG; + if (strchr(ostr, '-') == NULL) + return (-1); + optopt = '-'; + } + } else + optopt = *place++; + + /* See if option letter is one the caller wanted... */ + if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) { + if (*place == 0) + ++optind; + if (opterr && *ostr != ':') { + printf("%s: illegal option -- %c\n",_getprogname(),optopt); + /* + (void)fprintf(stderr, + "%s: illegal option -- %c\n", _getprogname(), + optopt); + */ + } + return (BADCH); + } + + + /* Does this option need an argument? */ + if (oli[1] != ':') { + /* don't need argument */ + optarg = NULL; + if (*place == 0) + ++optind; + } else { + /* Option-argument is either the rest of this argument or the + entire next argument. */ + if (*place) + optarg = place; + else if (nargc > ++optind) + optarg = nargv[optind]; + else { + /* option-argument absent */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + _getprogname(), optopt); + return (BADCH); + } + place = EMSG; + ++optind; + } + return (optopt); /* return option letter */ + + + } diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 1e6c525..c12fa02 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -95,7 +95,7 @@ /* New Root Mount Point */ //Old 2 new 10 - if (vfs_mount(0x1,10,0x0,0xAA,"sys","rw") != 0x0) { + if (vfs_mount(0x1,2,0x0,0xAA,"sys","rw") != 0x0) { kprintf("Problem Mounting sys Mount Point\n"); } diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index 23b69de..3e15827 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -40,6 +40,9 @@ #include #include #include +#include + +static int atkbd_scan(); static unsigned int keyMap = 0x0; static unsigned int ledStatus = 0x0; @@ -47,6 +50,8 @@ static uInt16 stdinSize; static uInt32 controlKeys = 0x0; +static spinLock_t atkbdSpinLock = SPIN_LOCK_INITIALIZER; + static unsigned int keyboardMap[255][8] = { /* Ascii, Shift, Ctrl, Alt, Num, Caps, Shift Caps, Shift Num */ { 0, 0, 0, 0, 0, 0, 0, 0}, @@ -155,6 +160,9 @@ /* Set the LEDS to their defaults */ setLED(); + /* Clear Keyboard */ + atkbd_scan(); + /* Turn on the keyboard vector */ irqEnable(0x1); @@ -173,25 +181,24 @@ ".globl atkbd_isr \n" "atkbd_isr: \n" " pusha \n" /* Save all registers */ - " push %ss \n" - " push %ds \n" - " push %es \n" - " push %fs \n" - " push %gs \n" + " push %ss \n" + " push %ds \n" + " push %es \n" + " push %fs \n" + " push %gs \n" " call keyboardHandler \n" " mov $0x20,%dx \n" " mov $0x20,%ax \n" " outb %al,%dx \n" - /* " sti \n" */ - " pop %gs \n" - " pop %fs \n" - " pop %es \n" - " pop %ds \n" - " pop %ss \n" - " popa \n" + " pop %gs \n" + " pop %fs \n" + " pop %es \n" + " pop %ds \n" + " pop %ss \n" + " popa \n" " iret \n" /* Exit interrupt */ ); - + static int atkbd_scan() { int code = 0x0; int val = 0x0; @@ -206,8 +213,12 @@ } void keyboardHandler() { + int key = 0x0; - int key = atkbd_scan(); + if (!spinTryLock(&atkbdSpinLock)) + return; + + key = atkbd_scan(); if (key > 255) return; @@ -297,6 +308,7 @@ } /* Return */ + spinUnlock(&atkbdSpinLock); return; } @@ -312,9 +324,25 @@ uInt8 retKey = 0x0; uInt32 i = 0x0; + /* + if ((stdinSize <= 0) && (tty_foreground == 0x0)) { + sched_yield(); + } + if ((tty_foreground != 0x0) && (tty_foreground->stdinSize <= 0x0)) { + sched_yield(); + } + */ + + /* + if (!spinTryLock(&atkbdSpinLock)) + return(0x0); +*/ + if (tty_foreground == 0x0) { - if (stdinSize == 0x0) + if (stdinSize == 0x0) { + // spinUnlock(&atkbdSpinLock); return(0x0); + } retKey = stdinBuffer[0]; stdinSize--; @@ -324,8 +352,10 @@ } } else { - if (tty_foreground->stdinSize == 0x0) + if (tty_foreground->stdinSize == 0x0) { + // spinUnlock(&atkbdSpinLock); return(0x0); + } retKey = tty_foreground->stdin[0]; tty_foreground->stdinSize--; @@ -334,12 +364,16 @@ tty_foreground->stdin[i] = tty_foreground->stdin[i+0x1]; } } + //spinUnlock(&atkbdSpinLock); return(retKey); } /*** $Log$ + Revision 1.1.1.1 2006/06/01 12:46:12 reddawg + ubix2 + Revision 1.2 2005/10/12 00:13:37 reddawg Removed diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index b8e420d..fb488d5 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -73,14 +73,24 @@ 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 = 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; diff --git a/src/sys/kernel/sys_call.S b/src/sys/kernel/sys_call.S index 2fe2020..bcbe000 100644 --- a/src/sys/kernel/sys_call.S +++ b/src/sys/kernel/sys_call.S @@ -27,36 +27,25 @@ *****************************************************************************************/ -.globl _sysCall,invalidCall +.globl _sysCall .text .code32 _sysCall: cmpl totalCalls,%eax jae invalidSysCall + pushl %edx pushl %ecx pushl %ebx call *systemCalls(,%eax,4) - jmp syscall_done -invalidSysCall: - call invalidCall -syscall_done: popl %ebx popl %ecx popl %edx /* Restore Registers */ iret -invalidCall: - /* mov $drive,%eax - push %eax */ - - call InvalidSystemCall - popl %ebx - popl %ecx - popl %edx +invalidSysCall: + movl $-1,%eax iret -drive: - .ascii "Invalid System Call\n\0" /*** END diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index df79554..e87a394 100644 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -241,6 +241,11 @@ return; } +void invalidCall() { + kprintf("Invalid System Call #0\n"); + return; + } + /*** END ***/ diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index 4e992b7..f4ac9de 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -41,6 +41,9 @@ #include #include +static unsigned char *videoBuffer = (char *)0xB8000; + + void systemTask() { mpi_message_t myMsg; uInt32 counter = 0x0; @@ -106,7 +109,7 @@ vmmFreeProcessPages(tmpTask->id); kfree(tmpTask); } - + videoBuffer[0] = systemVitals->sysTicks; sched_yield(); } diff --git a/src/sys/sys/idt.c b/src/sys/sys/idt.c index 12b873d..844501d 100644 --- a/src/sys/sys/idt.c +++ b/src/sys/sys/idt.c @@ -101,7 +101,7 @@ setTaskVector(13, dPresent + dTask + dDpl0, 0x38); setVector(_vmm_pageFault, 14, dPresent + dInt + dDpl0); setVector(_sysCall, 128, dPresent + dTrap + dDpl3); - setVector(_sysCallNew, 0x90, dPresent + dTrap + dDpl3); + //setVector(_sysCallNew, 0x90, dPresent + dTrap + dDpl3); setVector(timerInt, 0x68, (dInt + dPresent + dDpl0)); diff --git a/src/tools/Makefile b/src/tools/Makefile index 936aecf..0773753 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -44,6 +44,7 @@ (cp ../bin/clock/clock /mnts/ubix/bin) (cp ../bin/fdisk/fdisk /mnts/ubix/bin) (cp ../bin/edit/edit /mnts/ubix/bin) + (cp ../bin/mount/mount /mnts/ubix/bin) (cp ../bin/ld/ld.so /mnts/ubix/lib) (cp ../lib/libc_old/libc_old.so /mnts/ubix/lib) (cp ../lib/ubix_api/ubix_api.so /mnts/ubix/lib)