diff --git a/src/bin/edit/Makefile b/src/bin/edit/Makefile index 4743ca9..9ad8dfb 100644 --- a/src/bin/edit/Makefile +++ b/src/bin/edit/Makefile @@ -26,7 +26,7 @@ # Link The Binary $(BINARY) : $(OBJS) $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) - strip $(BINARY) + #strip $(BINARY) # Compile the source files .cc.o: diff --git a/src/bin/edit/main.c b/src/bin/edit/main.c index b034054..3262664 100644 --- a/src/bin/edit/main.c +++ b/src/bin/edit/main.c @@ -30,36 +30,13 @@ #include int main(int argc,char **argv) { - char data[512]; FILE *out; printf("UbixOS Text Editor\n"); - /* - out = fopen("sys:/test.txt","w"); - fread(data,4,1,out); - data[4] = '\0'; - printf("Data: [%s]\n",data); - fwrite("Test Line\n",9,1,out); - fclose(out); - */ + printf("V1.0\n"); return(0); } /*** - $Log$ - Revision 1.2 2006/10/16 13:20:34 reddawg - Tweaks - - Revision 1.1.1.1 2006/06/01 12:46:09 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:28 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:13:58 reddawg - no message - - Revision 1.1 2004/06/04 17:58:03 reddawg - Start of a text editor if i can pull this off there is no holding us back - END ***/ + diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index ce88c66..a87e380 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -144,7 +144,7 @@ else if (memcmp(data->args->arg,"id",2) == 0x0) { printf("UID: %i, GID: %i\n",getuid(),getgid()); } - else if (!strcmp(data->argv[0],"reboot")) { + else if (!strcmp(data->argv[1],"reboot")) { cmdMsg.header = 1000; cmdMsg.data[0] = '\0'; mpi_postMessage("system",0x1,&cmdMsg); diff --git a/src/lib/csu/crt1.c b/src/lib/csu/crt1.c index 5b1e959..1c4423c 100644 --- a/src/lib/csu/crt1.c +++ b/src/lib/csu/crt1.c @@ -43,7 +43,7 @@ extern void _fini(void); extern void _init(void); extern int main(int, char **, char **); -extern void _start(char **, ...); +extern void _start(char *, ...); #ifdef GCRT extern void _mcleanup(void); @@ -69,10 +69,12 @@ } /* The entry function. */ -void _start(char **argv, ...) { +void +_start(char *ap, ...) +{ fptr cleanup; int argc; - //char **argv; + char **argv; char **env; const char *s; @@ -80,8 +82,7 @@ __asm__("and $0xfffffff0,%esp"); #endif cleanup = get_rtld_cleanup(); - //≈ HACK - //argv = ≈ + argv = ≈ argc = *(long *)(void *)(argv - 1); env = argv + argc + 1; environ = env; @@ -91,6 +92,7 @@ if (*s == '/') __progname = s + 1; } + if (&_DYNAMIC != NULL) atexit(cleanup); else diff --git a/src/lib/libc/gen/tls.c b/src/lib/libc/gen/tls.c index e769255..d4a0fd0 100644 --- a/src/lib/libc/gen/tls.c +++ b/src/lib/libc/gen/tls.c @@ -266,8 +266,6 @@ int i; void *tls; - __sys_write(1,"TLS"); - sp = (Elf_Addr *) environ; while (*sp++ != 0) ; diff --git a/src/lib/libc/stdio/fvwrite.c b/src/lib/libc/stdio/fvwrite.c index fd12da1..b3ea910 100644 --- a/src/lib/libc/stdio/fvwrite.c +++ b/src/lib/libc/stdio/fvwrite.c @@ -127,6 +127,7 @@ fp->_p = fp->_bf._base + blen; } w = fp->_w; + if (fp->_flags & __SSTR) { if (len < w) w = len; diff --git a/src/lib/libc/stdio/makebuf.c b/src/lib/libc/stdio/makebuf.c index 9667705..6fbfa9e 100644 --- a/src/lib/libc/stdio/makebuf.c +++ b/src/lib/libc/stdio/makebuf.c @@ -70,9 +70,7 @@ fp->_bf._size = 1; return; } - __sys_write(1,"__swhatbuf"); flags = __swhatbuf(fp, &size, &couldbetty); - __sys_write(1,"__swhatbuf!"); if ((p = malloc(size)) == NULL) { fp->_flags |= __SNBF; fp->_bf._base = fp->_p = fp->_nbuf; @@ -83,8 +81,9 @@ flags |= __SMBF; fp->_bf._base = fp->_p = p; fp->_bf._size = size; - if (couldbetty && isatty(fp->_file)) - flags |= __SLBF; + if (couldbetty && isatty(fp->_file)) { + flags |= __SLBF; + } fp->_flags |= flags; } @@ -98,13 +97,12 @@ int *couldbetty; { struct stat st; - __sys_write(1,"_fstat"); + if (fp->_file < 0 || _fstat(fp->_file, &st) < 0) { *couldbetty = 0; *bufsize = BUFSIZ; return (__SNPT); } - __sys_write(1,"_fstat!"); /* could be a tty iff it is a character device */ *couldbetty = (st.st_mode & S_IFMT) == S_IFCHR; diff --git a/src/lib/libc/stdio/stdio.c b/src/lib/libc/stdio/stdio.c index 233427c..d3f7125 100644 --- a/src/lib/libc/stdio/stdio.c +++ b/src/lib/libc/stdio/stdio.c @@ -71,7 +71,6 @@ int n; { FILE *fp = cookie; - return (_write(fp->_file, buf, (size_t)n)); } @@ -135,6 +134,7 @@ errno = serrno; } ret = (*fp->_write)(fp->_cookie, buf, n); + /* __SOFF removed even on success in case O_APPEND mode is set. */ if (ret >= 0) { if ((fp->_flags & (__SAPP|__SOFF)) == (__SAPP|__SOFF) && diff --git a/src/lib/libc/stdio/vfprintf.c b/src/lib/libc/stdio/vfprintf.c index 67932d0..44b5b66 100644 --- a/src/lib/libc/stdio/vfprintf.c +++ b/src/lib/libc/stdio/vfprintf.c @@ -125,7 +125,6 @@ __sprint(FILE *fp, struct __suio *uio) { int err; - if (uio->uio_resid == 0) { uio->uio_iovcnt = 0; return (0); @@ -405,6 +404,7 @@ FLOCKFILE(fp); ret = __vfprintf(fp, fmt0, ap); FUNLOCKFILE(fp); + return (ret); } @@ -649,16 +649,13 @@ decimal_point = localeconv()->decimal_point; #endif /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ -__sys_write(1,"AAAAA"); if (prepwrite(fp) != 0) return (EOF); -__sys_write(1,"BBBBBBBBBBBBBBBBBBB"); /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) return (__sbprintf(fp, fmt0, ap)); -__sys_write(1,"ABABABC"); fmt = (char *)fmt0; argtable = NULL; nextarg = 1; @@ -667,7 +664,6 @@ uio.uio_resid = 0; uio.uio_iovcnt = 0; ret = 0; - /* * Scan the format for conversions (`%' character). */ @@ -1137,7 +1133,6 @@ sign = '\0'; break; } -__sys_write(1,"HERE?"); /* * All reasonable formats wind up here. At this point, `cp' * points to a string which (if not flags&LADJUST) should be diff --git a/src/lib/libc/stdio/wsetup.c b/src/lib/libc/stdio/wsetup.c index f165d63..a604584 100644 --- a/src/lib/libc/stdio/wsetup.c +++ b/src/lib/libc/stdio/wsetup.c @@ -55,10 +55,9 @@ FILE *fp; { /* make sure stdio is set up */ - __sys_write(1,"__swsetup"); - if (!__sdidinit) + if (!__sdidinit) { __sinit(); - __sys_write(1,"__swsetup!"); + } /* * If we are not writing, we had better be reading and writing. */ @@ -81,10 +80,9 @@ /* * Make a buffer if necessary, then set _w. */ - __sys_write(1,"smakebuf"); - if (fp->_bf._base == NULL) + if (fp->_bf._base == NULL) { __smakebuf(fp); - __sys_write(1,"smakebuf!"); + } if (fp->_flags & __SLBF) { /* * It is line buffered, so make _lbfsize be -_bufsize diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index e71b3db..d2f83ad 100644 --- a/src/lib/libc/stdlib/exit.c +++ b/src/lib/libc/stdlib/exit.c @@ -61,6 +61,8 @@ exit(status) int status; { + //HACK + _exit(status); /* Ensure that the auto-initialization routine is linked in: */ extern int _thread_autoinit_dummy_decl; diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index fe7420e..bd67e70 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c @@ -1091,7 +1091,6 @@ r = irealloc(ptr, size); err = (r == NULL); } - __sys_write(1,""); UTRACE(ptr, size, r); malloc_active = 0; _MALLOC_UNLOCK(); diff --git a/src/lib/libc/uthread/uthread_fd.c b/src/lib/libc/uthread/uthread_fd.c index 534939e..532e275 100644 --- a/src/lib/libc/uthread/uthread_fd.c +++ b/src/lib/libc/uthread/uthread_fd.c @@ -329,11 +329,9 @@ * Check that the file descriptor table is initialised for this * entry: */ - __sys_write(1,"_thread_fd_table_init"); if ((ret = _thread_fd_table_init(fd)) == 0) { /* Clear the interrupted flag: */ curthread->interrupted = 0; -__sys_write(1,"UBU"); /* * Lock the file descriptor table entry to prevent * other threads for clashing with the current @@ -510,7 +508,6 @@ } } - __sys_write(1,"_thread_fd_table_init"); /* Return the completion status: */ return (ret); } diff --git a/src/lib/libc/uthread/uthread_fstat.c b/src/lib/libc/uthread/uthread_fstat.c index b8371ff..2801ab0 100644 --- a/src/lib/libc/uthread/uthread_fstat.c +++ b/src/lib/libc/uthread/uthread_fstat.c @@ -48,16 +48,12 @@ int ret; /* Lock the file descriptor for read: */ - __sys_write(1,"_FD_LOCK"); if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { /* Get the file status: */ - __sys_write(1,"__sys_fstat"); ret = __sys_fstat(fd, buf); - __sys_write(1,"__sys_fstat!"); /* Unlock the file descriptor: */ _FD_UNLOCK(fd, FD_READ); } - __sys_write(1,"_FD_LOCK!"); return (ret); } diff --git a/src/lib/libc/uthread/uthread_init.c b/src/lib/libc/uthread/uthread_init.c index 1324715..72d2906 100644 --- a/src/lib/libc/uthread/uthread_init.c +++ b/src/lib/libc/uthread/uthread_init.c @@ -216,14 +216,12 @@ struct clockinfo clockinfo; struct sigaction act; -__sys_write(1,"UBOO",strlen("UBOO")); /* Check if this function has already been called: */ if (_thread_initial) /* Only initialise the threaded application once. */ return; _pthread_page_size = getpagesize(); - __sys_write(1,"getpagesize",strlen("getpagesize")); _pthread_guard_default = _pthread_page_size; sched_stack_size = 4 * _pthread_page_size; if (sizeof(void *) == 8) { @@ -277,7 +275,6 @@ __sys_dup2(fd, 2) == -1) PANIC("Can't dup2"); } - __sys_write(1,"getpid!",strlen("getpid!")); /* Get the standard I/O flags before messing with them : */ for (i = 0; i < 3; i++) { if (((_pthread_stdio_flags[i] = @@ -344,7 +341,6 @@ else if ((_thread_kern_sched_stack = malloc(sched_stack_size)) == NULL) PANIC("Failed to allocate stack for scheduler"); else { - __sys_write(1,"else!!!",strlen("else!!!")); /* Zero the global kernel thread structure: */ memset(&_thread_kern_thread, 0, sizeof(struct pthread)); _thread_kern_thread.flags = PTHREAD_FLAGS_PRIVATE; @@ -378,7 +374,6 @@ _pthread_guard_default, _pthread_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); - __sys_write(1,"mmap!",strlen("mmap!")); /* Set the main thread stack pointer. */ _thread_initial->stack = _usrstack - _pthread_stack_initial; diff --git a/src/lib/libc/uthread/uthread_write.c b/src/lib/libc/uthread/uthread_write.c index 908a2ab..ff1cd1d 100644 --- a/src/lib/libc/uthread/uthread_write.c +++ b/src/lib/libc/uthread/uthread_write.c @@ -60,7 +60,7 @@ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { /* Get the read/write mode type: */ type = _thread_fd_getflags(fd) & O_ACCMODE; - +type = O_RDWR; /* Check if the file is not open for write: */ if (type != O_WRONLY && type != O_RDWR) { /* File is not open for write: */ @@ -69,6 +69,7 @@ return (-1); } + /* Check if file operations are to block */ blocking = ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0); diff --git a/src/sys/include/sys/_types.h b/src/sys/include/sys/_types.h index 9ea9e08..9d4f3ae 100644 --- a/src/sys/include/sys/_types.h +++ b/src/sys/include/sys/_types.h @@ -30,7 +30,7 @@ #ifndef __TYPES_H #define __TYPES_H -#include +//#include typedef __signed char __int8_t; typedef unsigned char __uint8_t; @@ -43,29 +43,24 @@ typedef unsigned long __clock_t; -typedef long __time_t; +//typedef long __time_t; typedef __uint32_t __ino_t; typedef __int32_t __ssize_t; +/* stat types */ +typedef __uint32_t __dev_t; /* device number */ +typedef __uint16_t __mode_t; +typedef __uint16_t __nlink_t; /* link count */ +typedef __uint32_t __uid_t; +typedef __uint32_t __gid_t; +typedef __int32_t __time_t; +typedef __int64_t __blkcnt_t; /* file block count */ +typedef __uint32_t __blksize_t; /* file block size */ +typedef __uint32_t __fflags_t; /* file flags */ + #endif /*** - $Log$ - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:53 reddawg - no message - - Revision 1.4 2004/07/05 23:06:32 reddawg - Fixens - - Revision 1.3 2004/07/05 21:06:53 reddawg - Needed - - Revision 1.2 2004/05/21 15:12:17 reddawg - Cleaned up - - END ***/ + diff --git a/src/sys/include/sys/kern_descrip.h b/src/sys/include/sys/kern_descrip.h index 9c5c934..e57b761 100644 --- a/src/sys/include/sys/kern_descrip.h +++ b/src/sys/include/sys/kern_descrip.h @@ -33,6 +33,9 @@ #include #include +typedef __mode_t mode_t; +typedef __nlink_t nlink_t; + /* command values */ #define F_DUPFD 0 /* duplicate file descriptor */ #define F_GETFD 1 /* get file descriptor flags */ @@ -89,11 +92,66 @@ int f_flag; }; +/* TEMP */ +struct __timespec { + __time_t tv_sec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +}; + +struct stat { + __dev_t st_dev; /* inode's device */ + ino_t st_ino; /* inode's number */ + mode_t st_mode; /* inode protection mode */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of the file's owner */ + gid_t st_gid; /* group ID of the file's group */ + __dev_t st_rdev; /* device type */ +#if __BSD_VISIBLE + struct timespec st_atimespec; /* time of last access */ + struct timespec st_mtimespec; /* time of last data modification */ + struct timespec st_ctimespec; /* time of last file status change */ +#else + time_t st_atime; /* time of last access */ + long __st_atimensec; /* nsec of last access */ + time_t st_mtime; /* time of last data modification */ + long __st_mtimensec; /* nsec of last data modification */ + time_t st_ctime; /* time of last file status change */ + long __st_ctimensec; /* nsec of last file status change */ +#endif + off_t st_size; /* file size, in bytes */ + blkcnt_t st_blocks; /* blocks allocated for file */ + blksize_t st_blksize; /* optimal blocksize for I/O */ + fflags_t st_flags; /* user defined flags for file */ + __uint32_t st_gen; /* file generation number */ + __int32_t st_lspare; +#if __BSD_VISIBLE + struct timespec st_birthtimespec; /* time of file creation */ + /* + * Explicitly pad st_birthtimespec to 16 bytes so that the size of + * struct stat is backwards compatible. We use bitfields instead + * of an array of chars so that this doesn't require a C99 compiler + * to compile if the size of the padding is 0. We use 2 bitfields + * to cover up to 64 bits on 32-bit machines. We assume that + * CHAR_BIT is 8... + */ + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); +#else + time_t st_birthtime; /* time of file creation */ + long st_birthtimensec; /* nsec of file creation */ + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); +#endif +}; + int fcntl(struct thread *, struct fcntl_args *); int close(struct thread *,struct close_args *); int falloc(struct thread *, struct file **, int *); int getdtablesize(struct thread *, struct getdtablesize_args *); +int fstat(struct thread *, struct fstat_args *); +int ioctl(struct thread *, struct ioctl_args *); + #endif diff --git a/src/sys/include/sys/kern_sig.h b/src/sys/include/sys/kern_sig.h index ffc208e..914f5c9 100644 --- a/src/sys/include/sys/kern_sig.h +++ b/src/sys/include/sys/kern_sig.h @@ -33,23 +33,8 @@ #include #include -#define _SIG_WORDS 4 -#define _SIG_MAXSIG 128 -#define _SIG_IDX(sig) ((sig) - 1) -#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) -#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) -#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) - -typedef struct __sigset { - __uint32_t __bits[_SIG_WORDS]; - } __sigset_t; - - -typedef __sigset_t sigset_t; - - -int sigaction(struct thread *,register struct sigaction_args *); -int sigprocmask(register struct thread *, struct sigprocmask_args *); +int sigaction(struct thread *,struct sigaction_args *); +int sigprocmask(struct thread *, struct sigprocmask_args *); #endif diff --git a/src/sys/include/sys/signal.h b/src/sys/include/sys/signal.h new file mode 100644 index 0000000..cf5b79e --- /dev/null +++ b/src/sys/include/sys/signal.h @@ -0,0 +1,12 @@ +#define _SIG_WORDS 4 +#define _SIG_MAXSIG 128 +#define _SIG_IDX(sig) ((sig) - 1) +#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) +#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) +#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) + +typedef struct __sigset { + __uint32_t __bits[_SIG_WORDS]; + } __sigset_t; + +typedef __sigset_t sigset_t; diff --git a/src/sys/include/sys/sysproto.h b/src/sys/include/sys/sysproto.h index 2b1bf9a..70865ef 100644 --- a/src/sys/include/sys/sysproto.h +++ b/src/sys/include/sys/sysproto.h @@ -30,7 +30,7 @@ #ifndef _SYSPROTO_H #define _SYSPROTO_H -#include +#include typedef int register_t; @@ -109,10 +109,10 @@ }; struct sigaction_args { - char sig_l_[PADL_(int)]; int sig; char sig_r_[PADR_(int)]; - char act_l_[PADL_(const struct sigaction *)]; const struct sigaction * act; char act_r_[PADR_(const struct sigaction *)]; - char oact_l_[PADL_(struct sigaction *)]; struct sigaction * oact; char oact_r_[PADR_(struct sigaction *)]; -}; + char sig_l_[PADL_(int)]; int sig; char sig_r_[PADR_(int)]; + char act_l_[PADL_(const struct sigaction *)]; const struct sigaction * act; char act_r_[PADR_(const struct sigaction *)]; + char oact_l_[PADL_(struct sigaction *)]; struct sigaction * oact; char oact_r_[PADR_(struct sigaction *)]; + }; struct getdtablesize_args { register_t dummy; @@ -132,10 +132,15 @@ char tp_l_[PADL_(struct timeval *)]; struct timeval * tp; char tp_r_[PADR_(struct timeval *)]; char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; }; - - - - +struct fstat_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char sb_l_[PADL_(struct stat *)]; struct stat * sb; char sb_r_[PADR_(struct stat *)]; +}; +struct ioctl_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char com_l_[PADL_(u_long)]; u_long com; char com_r_[PADR_(u_long)]; + char data_l_[PADL_(caddr_t)]; caddr_t data; char data_r_[PADR_(caddr_t)]; +}; #endif diff --git a/src/sys/include/ubixos/syscalls_new.h b/src/sys/include/ubixos/syscalls_new.h index d88dce3..e585fa6 100644 --- a/src/sys/include/ubixos/syscalls_new.h +++ b/src/sys/include/ubixos/syscalls_new.h @@ -48,6 +48,8 @@ int munmap(); int sigprocmask(); int gettimeofday_new(); +int fstat(); +int ioctl(); #define invalid_call 0x0 #define PSL_C 0x00000001 /* carry bit */ @@ -111,7 +113,7 @@ invalid_call, /** 51 **/ invalid_call, /** 52 **/ invalid_call, /** 53 **/ - invalid_call, /** 54 **/ + ioctl, /** 54 **/ invalid_call, /** 55 **/ invalid_call, /** 56 **/ invalid_call, /** 57 **/ @@ -246,7 +248,7 @@ invalid_call, /** 186 **/ invalid_call, /** 187 **/ invalid_call, /** 188 **/ - invalid_call, /** 189 **/ + fstat, /** 189 **/ invalid_call, /** 190 **/ invalid_call, /** 191 **/ invalid_call, /** 192 **/ diff --git a/src/sys/include/ubixos/types.h b/src/sys/include/ubixos/types.h index c53dc30..f5a7344 100644 --- a/src/sys/include/ubixos/types.h +++ b/src/sys/include/ubixos/types.h @@ -98,6 +98,18 @@ typedef __int64_t off_t; typedef __uint32_t vm_offset_t; +typedef __uid_t uid_t; /* user id */ +typedef __gid_t gid_t; /* group id */ +typedef __blkcnt_t blkcnt_t; +typedef __blksize_t blksize_t; +typedef __fflags_t fflags_t; + +#ifndef _TIME_T_DECLARED +typedef __time_t time_t; +#define _TIME_T_DECLARED +#endif + + #endif /*** diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index 8281961..944f3e2 100644 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -40,10 +40,10 @@ #define pageLength 0x00000400 #define pageSize 4096 #define pageEntries (pageSize/4) -#define pageCow 0x00000200 #define tablesBaseAddress 0xBFC00000 #define parentPageDirAddr 0x100000 +#define PAGE_COW 0x00000200 #define PAGE_STACK 0x00000400 #define PAGE_WIRED 0x00000600 #define PAGE_PRESENT 0x00000001 diff --git a/src/sys/init/main.c b/src/sys/init/main.c index acabdcc..d53fc35 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -101,11 +101,13 @@ int kmain(uInt32 rootdev) { /* Set up counter for startup routine */ int i = 0x0; - uInt32 *sysTask; - + uInt32 *sysTask = 0x0; + /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */ clearScreen(); - + kprint("AAA"); + kprint("BBB"); +kprintf("TEST"); /* Modify src/sys/include/ubixos/init.h to add a startup routine */ for (i=0x0;ifreePages); break; + case 0x9: + kprintf("REBOOTING"); + while(inportByte(0x64) & 0x02); + outportByte(0x64, 0xFE); + break; default: if (tty_foreground == 0x0) { stdinBuffer[stdinSize] = keyboardMap[key][keyMap]; @@ -371,6 +376,9 @@ /*** $Log$ + Revision 1.2 2006/10/19 17:52:17 reddawg + Working On Userland + Revision 1.1.1.1 2006/06/01 12:46:12 reddawg ubix2 diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 3f557be..996a9ff 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -144,7 +144,6 @@ int i = 0x0; int x = 0x0; u_int32_t *tmp = 0x0; - u_int32_t stackAddr = 0x0; fileDescriptor *tmpFd = 0x0; elfHeader *binaryHeader = 0x0; @@ -158,7 +157,7 @@ _current->term = tty_find(console); if (_current->term == 0x0) kprintf("Error: invalid console\n"); - + /* Set tty ownership */ _current->term->owner = _current->id; @@ -529,8 +528,10 @@ tmp = (uInt32 *)STACK_ADDR - 2;//0xCBE8000 - 2;//0x5DD000 - 2; //tmp[0] = argc; //1 + /* if (_current->id > 4) kprintf("argv[0]: [%s]\n",argv[0]); + */ kprintf("argv: [0x%X]\n",argv); tmp[0] = (u_int32_t)argv; tmp[1] = (u_int32_t)argv; diff --git a/src/sys/kernel/gen_calls.c b/src/sys/kernel/gen_calls.c index 2283e58..b983cc2 100644 --- a/src/sys/kernel/gen_calls.c +++ b/src/sys/kernel/gen_calls.c @@ -53,9 +53,18 @@ } int sys_write(struct thread *td, struct write_args *uap) { + char *buffer = 0x0; + char *in = 0x0; if (uap->fd == 2) { kprintf("stderr: %s",uap->buf); } + if (uap->fd == 1) { + in = uap->buf; + buffer = kmalloc(1024); + memcpy(buffer,uap->buf,uap->nbyte); + kprintf("%s",buffer); + kfree(buffer); + } else { kprintf("(%i) %s",uap->fd,uap->buf); } diff --git a/src/sys/kernel/kern_descrip.c b/src/sys/kernel/kern_descrip.c index 12c2f56..f4be4ac 100644 --- a/src/sys/kernel/kern_descrip.c +++ b/src/sys/kernel/kern_descrip.c @@ -27,10 +27,10 @@ *****************************************************************************************/ +#include #include #include #include -#include #include #include #include @@ -38,36 +38,26 @@ int fcntl(struct thread *td, struct fcntl_args *uap) { struct file *fp = 0x0; - //kprintf("fcntl: [%i:%i]\n",uap->cmd,uap->fd); - if (uap->fd == 0) { - td->td_retval[0] = 0x2; + //kprintf("fcntl: [%i:%i:0x%X]",uap->cmd,uap->fd,uap->arg); + + if (td->o_files[uap->fd] == 0x0) { + kprintf("ERROR!!!\n"); + return(-1); } - else if (uap->fd == 1) { - td->td_retval[0] = 0x1; + + fp = (struct file *)td->o_files[uap->fd]; + switch (uap->cmd) { + case 3: + td->td_retval[0] = fp->f_flag; + break; + case 4: + fp->f_flag &= ~FCNTLFLAGS; + fp->f_flag |= FFLAGS(uap->arg & ~O_ACCMODE) & FCNTLFLAGS; + break; + default: + kprintf("ERROR DEFAULT"); } - else if (uap->fd == 2) { - td->td_retval[0] = 0x2; - } - else { - if (td->o_files[uap->fd] == -1) { - kprintf("Descriptor Broken: [%i][%i], Ending task.\n",uap->fd,td->o_files[uap->fd]); - endTask(_current->id); - } - else { - fp = (struct file *)td->o_files[uap->fd]; - } - switch (uap->cmd) { - case F_GETFL: - td->td_retval[0] = fp->f_flag; - break; - case F_SETFL: - fp->f_flag &= ~FCNTLFLAGS; - fp->f_flag |= FFLAGS(uap->arg & ~O_ACCMODE) & FCNTLFLAGS; - break; - default: - kprintf("Unsupported fcntl cmd: [%i]\n",uap->cmd); - } - } + return(0x0); } @@ -91,6 +81,7 @@ } int close(struct thread *td,struct close_args *uap) { + //kprintf("fd: [%i]\n",uap->fd); kfree((void *)td->o_files[uap->fd]); td->o_files[uap->fd] = 0x0; td->td_retval[0] = 0x0; @@ -104,6 +95,21 @@ return (0); } +int fstat(struct thread *td, struct fstat_args *uap) { + struct file *fp = 0x0; + kprintf("fd: %i",uap->fd); + fp = _current->td.o_files[uap->fd]; + uap->sb->st_mode = 0x2180; + uap->sb->st_blksize = 0x1000; + return(0x0); + } + +int ioctl(struct thread *td, struct ioctl_args *uap) { + kprintf("ioctl HACK"); + td->td_retval[0] = 0x0; + return(0x0); + } + /*** diff --git a/src/sys/kernel/pipe.c b/src/sys/kernel/pipe.c index f47bfc3..95dccac 100644 --- a/src/sys/kernel/pipe.c +++ b/src/sys/kernel/pipe.c @@ -38,6 +38,7 @@ int pipe(struct thread *td, struct pipe_args *uap) { struct file *rf, *wf; int fd = 0x0; + kprintf("PIPE"); falloc(td,&rf,&fd); rf->f_flag = FREAD | FWRITE; td->td_retval[0] = fd; diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 2a7c050..fcd23a9 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -141,7 +142,9 @@ kTask_t *schedNewTask() { + int i = 0; kTask_t *tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); + struct file *fp = 0x0; if (tmpTask == 0x0) kpanic("Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"); @@ -150,6 +153,13 @@ tmpTask->usedMath = 0x0; tmpTask->state = NEW; + /* HACK */ + for (i=0;i<3;i++) { + fp = kmalloc(sizeof(struct file)); + tmpTask->td.o_files[i] = fp; + fp->f_flag = 0x4; + } + spinLock(&schedulerSpinLock); tmpTask->id = nextID++; tmpTask->next = taskList; diff --git a/src/sys/lib/kprintf.c b/src/sys/lib/kprintf.c index 89bb0ca..1b00e91 100644 --- a/src/sys/lib/kprintf.c +++ b/src/sys/lib/kprintf.c @@ -36,20 +36,15 @@ int ogprintOff = 0x1; int kprintf(const char *fmt, ...) { - char buf[1024]; + char buf[512]; vaList args; int i = 0x0; vaStart(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsprintf(buf,fmt,args); vaEnd(args); - if (printOff == 0x0) { + if (printOff == 0x0) kprint(buf); - } - /* - if (ogprintOff == 0x0) { - ogPrintf(buf); - } - */ + return(i); } @@ -63,48 +58,6 @@ } /*** - $Log$ - Revision 1.1.1.1 2006/06/01 12:46:16 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:24:12 reddawg - no message - - Revision 1.7 2004/07/21 10:02:09 reddawg - devfs: renamed functions - device system: renamed functions - fdc: fixed a few potential bugs and cleaned up some unused variables - strol: fixed definition - endtask: made it print out freepage debug info - kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost - ld: fixed a pointer conversion - file: cleaned up a few unused variables - sched: broke task deletion - kprintf: fixed ogPrintf definition - - Revision 1.6 2004/07/20 22:58:33 reddawg - retiring to the laptop for the night must sync in work to resume from there - - Revision 1.5 2004/07/20 22:29:55 reddawg - assert: remade assert - - Revision 1.4 2004/07/18 03:01:44 reddawg - Few changes to spinlock hopefully it will cure our deadlock - - Revision 1.3 2004/07/17 02:45:55 reddawg - Modified assert it now invokes kPanic it is very nifty - - Revision 1.2 2004/07/17 01:30:52 reddawg - assert: you have assert I believe - - Revision 1.1.1.1 2004/04/15 12:07:10 reddawg - UbixOS v1.0 - - Revision 1.13 2004/04/13 16:36:33 reddawg - Changed our copyright, it is all now under a BSD-Style license - END ***/ + diff --git a/src/sys/vmm/copyvirtualspace.c b/src/sys/vmm/copyvirtualspace.c index 673ef46..c1dc549 100644 --- a/src/sys/vmm/copyvirtualspace.c +++ b/src/sys/vmm/copyvirtualspace.c @@ -116,9 +116,9 @@ } else { /* Set Page To COW In Parent And Child Space */ - newPageTable[i] = (((uInt32) parentPageTable[i] & 0xFFFFF000) | (PAGE_DEFAULT | pageCow)); + newPageTable[i] = (((uInt32) parentPageTable[i] & 0xFFFFF000) | (PAGE_DEFAULT | PAGE_COW)); /* Increment The COW Counter For This Page */ - if (((uInt32) parentPageTable[i] & pageCow) == pageCow) { + if (((uInt32) parentPageTable[i] & PAGE_COW) == PAGE_COW) { adjustCowCounter(((uInt32) parentPageTable[i] & 0xFFFFF000), 1); } else { @@ -163,9 +163,9 @@ /* If Page Is Avaiable Map It */ if ((parentPageTable[x] & 0xFFFFF000) != 0x0) { /* Set Pages To COW */ - newPageTable[x] = (((uInt32) parentPageTable[x] & 0xFFFFF000) | (PAGE_DEFAULT | pageCow)); + newPageTable[x] = (((uInt32) parentPageTable[x] & 0xFFFFF000) | (PAGE_DEFAULT | PAGE_COW)); /* Increment The COW Counter For This Page */ - if (((uInt32) parentPageTable[x] & pageCow) == pageCow) { + if (((uInt32) parentPageTable[x] & PAGE_COW) == PAGE_COW) { adjustCowCounter(((uInt32) parentPageTable[x] & 0xFFFFF000), 1); } else { adjustCowCounter(((uInt32) parentPageTable[x] & 0xFFFFF000), 2); @@ -207,6 +207,9 @@ /*** $Log$ + Revision 1.2 2006/11/06 19:10:12 reddawg + Lots Of Updates... Still having issues with brk(); + Revision 1.1.1.1 2006/06/01 12:46:13 reddawg ubix2 diff --git a/src/sys/vmm/getfreevirtualpage.c b/src/sys/vmm/getfreevirtualpage.c index 6f28c5f..f4b3056 100644 --- a/src/sys/vmm/getfreevirtualpage.c +++ b/src/sys/vmm/getfreevirtualpage.c @@ -63,7 +63,7 @@ start_page = (u_int32_t)(_current->td.vm_daddr + ctob(_current->td.vm_dsize)); } else if (type == VM_TASK) { - kprintf("vmStart"); + //kprintf("vmStart"); start_page = _current->oInfo.vmStart; } else @@ -93,21 +93,21 @@ } for (y = 0; y < 1024; y++) { /* Loop Through The Page Table Find An UnAllocated Page */ - if ((pageTableSrc[y] & pageCow) == pageCow) { - //kprintf("COW"); + if ((pageTableSrc[y] & PAGE_COW) == PAGE_COW) { + kprintf("COW"); //_current->td.vm_dsize += btoc(0x1000); /* HACK MEMORY LEAK */ - pageTableSrc[y] = 0x0; + //pageTableSrc[y] = 0x0; } if ((uInt32) pageTableSrc[y] == (uInt32) 0x0) { if (count > 0x1) { for (c = 0; c < count; c++) { if (y + c < 1024) { - if ((pageTableSrc[y + c] & pageCow) == pageCow) { - //kprintf("COW"); + if ((pageTableSrc[y + c] & PAGE_COW) == PAGE_COW) { + kprintf("COW"); //_current->td.vm_dsize += btoc(0x1000); /* HACK MEMORY LEAK */ - pageTableSrc[y + c] = 0x0; + //pageTableSrc[y + c] = 0x0; } if ((uInt32) pageTableSrc[y + c] != (uInt32) 0x0) { diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index cb75c37..dae8bd2 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -306,7 +306,7 @@ /* Check The Page Table For COW Pages */ for (x=0;x old) { - for (i = old + 0x1000;i <= new;i+= 0x1000) { + for (i = old;i < new;i+= 0x1000) { if (vmm_remapPage(vmmFindFreePage(_current->id),i,PAGE_DEFAULT) == 0x0) K_PANIC("remap Failed"); } @@ -525,6 +525,40 @@ return(0x0); } +int vmm_cleanVirtualSpace(u_int32_t addr) { + int x = 0x0; + int y = 0x0; + u_int32_t *pageTableSrc = 0x0; + u_int32_t *pageDir = 0x0; + + pageDir = (uInt32 *) parentPageDirAddr; + + kprintf("CVS: [0x%X]\n",addr); + + for (x = (addr / (1024 * 4096)); x < 770; x++) { + if ((pageDir[x] & PAGE_PRESENT) == PAGE_PRESENT) { + pageTableSrc = (uInt32 *) (tablesBaseAddress + (0x1000 * x)); + for (y = 0;y < 1024;y++) { + if (pageTableSrc[y] != 0x0) { + if ((pageTableSrc[y] & PAGE_COW) == PAGE_COW) { + //kprintf("COWi*"); + pageTableSrc[y] = 0x0; + } + else if ((pageTableSrc[y] & PAGE_STACK) == PAGE_STACK) { + //pageTableSrc[y] = 0x0; + //kprintf("STACK: (%i:%i)",x,y); + } + else { + kprintf("+"); + } + } + } + } + } + + return(0x0); + } + /*** END diff --git a/ubix2.kdevelop b/ubix2.kdevelop new file mode 100644 index 0000000..2afe967 --- /dev/null +++ b/ubix2.kdevelop @@ -0,0 +1,214 @@ + + + + Christopher Olsen + cwolsen@ubixos.com + 0.1 + KDevCustomProject + C + + + C + Linux + Kernel + + kdevcvsservice + . + false + + + + + + + false + false + + + *.o,*.lo,CVS + false + false + + + + + + make + + + + true + 1 + false + + + + + 0 + + + default + + + + executable + / + + + false + true + + + + + + ada + ada_bugs_gcc + bash + bash_bugs + clanlib + w3c-dom-level2-html + fortran_bugs_gcc + gnome1 + gnustep + gtk + gtk_bugs + haskell + haskell_bugs_ghc + java_bugs_gcc + java_bugs_sun + kde2book + libstdc++ + opengl + pascal_bugs_fp + php + php_bugs + perl + perl_bugs + python + python_bugs + qt-kdev3 + ruby + ruby_bugs + sdl + stl + w3c-svg + sw + w3c-uaag10 + wxwidgets_bugs + + + Guide to the Qt Translation Tools + Qt Assistant Manual + Qt Designer Manual + Qt Reference Documentation + qmake User Guide + + + KDE Libraries (Doxygen) + + + + + Doxygen Documentation Collection + ubix2.tag + + + + + ubix2 + ubix2 + Ubix2 + UBIX2 + Christopher Olsen + cwolsen@ubixos.com + Custom + 0.1 + 2006 + /home/reddawg/ubix2 + + + + + true + true + true + false + true + true + true + 250 + 400 + 250 + + + false + 3 + + + + + set + m_,_ + theValue + true + true + + + + false + false + + UbixOS + 0.1 + + + + + + + + + false + false + false + 0 + false + false + false + false + + + + + .h + .cpp + + + + + + + + + + + true + false + false + + + false + true + 10 + + + + + + + + + + + diff --git a/ubix2.kdevses b/ubix2.kdevses new file mode 100644 index 0000000..6f1405a --- /dev/null +++ b/ubix2.kdevses @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +