diff --git a/bin/shell/exec.c b/bin/shell/exec.c index 2ebe057..13acd4f 100644 --- a/bin/shell/exec.c +++ b/bin/shell/exec.c @@ -34,8 +34,8 @@ int boo = 0x0; -static char *argv_init[2] = { "init", NULL, }; // ARGV For Initial Proccess -static char *envp_init[7] = { "HOME=/", "PWD=/", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", "LD_DEBUG=all", NULL, }; //ENVP For Initial Proccess +static char *argv_init[2] = { "/bin/cat", NULL, }; // ARGV For Initial Proccess +static char *envp_init[8] = { "HOME=/", "PWD=/", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", "LD_DEBUG=all", "LD_LIBRARY_PATH=/lib", NULL, }; //ENVP For Initial Proccess void execProgram(inputBuffer *data) { diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index cf9eb34..2035970 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD: releng/11.1/libexec/rtld-elf/Makefile 319016 2017-05-28 00:13:44Z rgrimes $ - # Use the following command to build local debug version of dynamic # linker: # make DEBUG_FLAGS=-g DEBUG=-DDEBUG WITHOUT_TESTS=yes all diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index bffcff1..69d4d91 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -5022,8 +5022,7 @@ } for (;;) { if (vd->vd_version != VER_DEF_CURRENT) { - _rtld_error("%s: Unsupported version %d of Elf_Verdef entry", - depobj->path, vd->vd_version); + _rtld_error("%s: Unsupported version %d:%d of Elf_Verdef entry", depobj->path, vd->vd_version, VER_DEF_CURRENT); return (-1); } if (vna->vna_hash == vd->vd_hash) { @@ -5066,8 +5065,7 @@ vn = obj->verneed; while (vn != NULL) { if (vn->vn_version != VER_NEED_CURRENT) { - _rtld_error("%s: Unsupported version %d of Elf_Verneed entry", - obj->path, vn->vn_version); + _rtld_error("%s: Unsupported version %d of Elf_Verneed entry", obj->path, vn->vn_version); return (-1); } vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux); @@ -5087,8 +5085,7 @@ vd = obj->verdef; while (vd != NULL) { if (vd->vd_version != VER_DEF_CURRENT) { - _rtld_error("%s: Unsupported version %d of Elf_Verdef entry", - obj->path, vd->vd_version); + _rtld_error("%s: Unsupported version %d:%d of Elf_Verdef entry", obj->path, vd->vd_version, VER_DEF_CURRENT); return (-1); } vernum = VER_DEF_IDX(vd->vd_ndx); diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile index 29f3b6c..3ac216f 100644 --- a/libexec/rtld-elf/tests/Makefile +++ b/libexec/rtld-elf/tests/Makefile @@ -6,4 +6,4 @@ ATF_TESTS_C= ld_library_pathfds WARNS?= 3 -.include +.include diff --git a/sys/fs/devfs/devfs.c b/sys/fs/devfs/devfs.c index 8c1998f..4bc603c 100644 --- a/sys/fs/devfs/devfs.c +++ b/sys/fs/devfs/devfs.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include /* Spinlock for devfs we should start converting to sem/mutex */ diff --git a/sys/fs/ubixfs/dirCache.c b/sys/fs/ubixfs/dirCache.c index cc3e75e..d4a483d 100644 --- a/sys/fs/ubixfs/dirCache.c +++ b/sys/fs/ubixfs/dirCache.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include diff --git a/sys/fs/ubixfs/directory.c b/sys/fs/ubixfs/directory.c index c407cac..179c8fa 100644 --- a/sys/fs/ubixfs/directory.c +++ b/sys/fs/ubixfs/directory.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include static dirList_t dirList = 0x0; diff --git a/sys/fs/ubixfs/ubixfs.c b/sys/fs/ubixfs/ubixfs.c index 1a1e069..bddfc30 100644 --- a/sys/fs/ubixfs/ubixfs.c +++ b/sys/fs/ubixfs/ubixfs.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/fs/ufs/ffs.c b/sys/fs/ufs/ffs.c index 200508e..500a4c5 100644 --- a/sys/fs/ufs/ffs.c +++ b/sys/fs/ufs/ffs.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include diff --git a/sys/fs/ufs/ufs.c b/sys/fs/ufs/ufs.c index 94f6bf9..fe72a95 100644 --- a/sys/fs/ufs/ufs.c +++ b/sys/fs/ufs/ufs.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #define VBLKSHIFT 12 #define VBLKSIZE (1 << VBLKSHIFT) diff --git a/sys/fs/vfs/file.c b/sys/fs/vfs/file.c index 8a7a19c..f13ee0c 100644 --- a/sys/fs/vfs/file.c +++ b/sys/fs/vfs/file.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -211,15 +211,28 @@ size_t fread( void *ptr, size_t size, size_t nmemb, fileDescriptor *fd ) { size_t i = 0x0; + + asm("nop"); + asm("nop"); if ( fd == 0x0 ) return (0x0); + asm("nop"); + asm("nop"); if ( nmemb == 0x0 ) nmemb = 1; //Temp Fix + asm("nop"); + asm("nop"); assert( fd ); + asm("nop"); + asm("nop"); assert( fd->mp ); + asm("nop"); + asm("nop"); assert( fd->mp->fs ); + asm("nop"); + asm("nop"); i = fd->mp->fs->vfsRead( fd, ptr, fd->offset, size * nmemb ); diff --git a/sys/fs/vfs/mount.c b/sys/fs/vfs/mount.c index a62aef8..4363a75 100644 --- a/sys/fs/vfs/mount.c +++ b/sys/fs/vfs/mount.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include /************************************************************************ diff --git a/sys/fs/vfs/stat.c b/sys/fs/vfs/stat.c index 94ed89e..76f2c37 100644 --- a/sys/fs/vfs/stat.c +++ b/sys/fs/vfs/stat.c @@ -30,13 +30,14 @@ #include #include #include +#include +#include int sys_stat(char *path, struct stat *sb, int flags) { int error = 0; - struct inode *inode; + //struct inode *inode; - //NOTE: Should we verify that the memory is writable? - kprintf("SYS_STAT {%s}", path); + //MrOlsen kprintf("SYS_STAT {%s}", path); /* switch (flags) { @@ -53,17 +54,17 @@ sb->st_atime = inode->i_atime; sb->st_mtime = inode->i_mtime; sb->st_ctime = inode->i_ctime; - kprintf("LSTAT(%i): st_ino 0x%X, st_mode: 0x%X, st_uid %i, st_gid %i, st_size: 0x%X", error, sb->st_ino, sb->st_mode, sb->st_uid, sb->st_gid, sb->st_size); + //MrOlsen kprintf("LSTAT(%i)=st_ino 0x%X, st_mode=0x%X, st_uid %i, st_gid %i, st_size=0x%X", error, sb->st_ino, sb->st_mode, sb->st_uid, sb->st_gid, sb->st_size); break; default: - kprintf("STAT ERROR: {%s}", path); + kprintf("STAT ERROR={%s}", path); error = -1; break; } */ fileDescriptor *fd = fopen(path, "rb"); - kprintf("FD: 0x%X", fd); + //MrOlsen kprintf("FD=0x%X", fd); if (fd == 0) { error = -1; @@ -80,13 +81,105 @@ sb->st_atime = fd->inode.u.ufs2_i.di_atime; sb->st_mtime = fd->inode.u.ufs2_i.di_mtime; sb->st_ctime = fd->inode.u.ufs2_i.di_ctime; - kprintf("LSTAT(%i): st_ino 0x%X, st_mode: 0x%X, st_uid %i, st_gid %i, st_size: 0x%X", error, sb->st_ino, sb->st_mode, sb->st_uid, sb->st_gid, sb->st_size); + //MrOlsen kprintf("LSTAT(%i)=st_ino 0x%X, st_mode=0x%X, st_uid %i, st_gid %i, st_size=0x%X", error, sb->st_ino, sb->st_mode, sb->st_uid, sb->st_gid, sb->st_size); fclose(fd); } return(error); } + +int sys_fstat(struct thread *td, struct sys_fstat_args *args) { + int error = 0; + + struct file *fdd = 0x0; + fileDescriptor *fd = 0x0; + + getfd(td, &fdd, args->fd); + + fd = fdd->fd; + + if (fdd == 0 || fdd->fd == 0x0) { + error = -1; + } + else { + args->sb->st_dev = 0xDEADBEEF; + args->sb->st_ino = fd->ino; + args->sb->st_mode = fd->inode.u.ufs2_i.di_mode; + args->sb->st_nlink = fd->inode.u.ufs2_i.di_nlink; + args->sb->st_uid = fd->inode.u.ufs2_i.di_uid; + args->sb->st_gid = fd->inode.u.ufs2_i.di_gid; + args->sb->st_rdev = 0xBEEFDEAD; + args->sb->st_size = fd->inode.u.ufs2_i.di_size; + args->sb->st_atime = fd->inode.u.ufs2_i.di_atime; + args->sb->st_mtime = fd->inode.u.ufs2_i.di_mtime; + args->sb->st_ctime = fd->inode.u.ufs2_i.di_ctime; + //MrOlsen kprintf("FSTAT(%i)=st_ino 0x%X, st_mode=0x%X, st_uid %i, st_gid %i, st_size=0x%X:0x%X", args->fd, args->sb->st_ino, args->sb->st_mode, args->sb->st_uid, args->sb->st_gid, args->sb->st_size, fd->size); + } + + td->td_retval[0] = error; + return(error); +} + +int sys_fstatfs(struct thread *td, struct sys_fstatfs_args *args) { + int error = 0; + + struct file *fd = 0x0; + + getfd(td, &fd, args->fd); + + if (fd == 0) { + error = -1; + } + else { + /* + args->buf->st_dev = 0xDEADBEEF; + args->buf->st_ino = fd->fd->ino; + args->buf->st_mode = fd->fd->inode.u.ufs2_i.di_mode; + args->buf->st_nlink = fd->fd->inode.u.ufs2_i.di_nlink; + args->buf->st_uid = fd->fd->inode.u.ufs2_i.di_uid; + args->buf->st_gid = fd->fd->inode.u.ufs2_i.di_gid; + args->buf->st_rdev = 0xBEEFDEAD; + args->buf->st_size = fd->fd->inode.u.ufs2_i.di_size; + args->buf->st_atime = fd->fd->inode.u.ufs2_i.di_atime; + args->buf->st_mtime = fd->fd->inode.u.ufs2_i.di_mtime; + args->buf->st_ctime = fd->fd->inode.u.ufs2_i.di_ctime; + //MrOlsen kprintf("LSTAT(%i)=st_ino 0x%X, st_mode=0x%X, st_uid %i, st_gid %i, st_size=0x%X", error, args->buf->st_ino, args->buf->st_mode, args->buf->st_uid, args->buf->st_gid, args->buf->st_size); + //fclose(fd); + */ + +args->buf->f_version=0x20030518; +args->buf->f_type=0x35; +args->buf->f_flags=0x1000; +args->buf->f_bsize=0x1000; +args->buf->f_iosize=0x8000; +args->buf->f_blocks=0x7bf9d; +args->buf->f_bfree=0x73c0c; +args->buf->f_bavail=0x69d5c; +args->buf->f_files=0x3fffe; +args->buf->f_ffree=0x3d3f0; +args->buf->f_syncwrites=0x75232; +args->buf->f_asyncwrites=0x2b804; +args->buf->f_syncreads=0x2edea; +args->buf->f_asyncreads=0x6182; +args->buf->f_namemax=0xFF; +args->buf->f_owner=0x0; +args->buf->f_fsid.val[0]=0x5A31F4F0; +args->buf->f_fsid.val[1]=0x65E7C98F; +//args->buf->f_charspare= {""}; +sprintf(args->buf->f_fstypename, "ufs"); +sprintf(args->buf->f_mntfromname, "/dev/ada0s1a"); +sprintf(args->buf->f_mntonname,"/"); + + + } + + td->td_retval[0] = error; + 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/fs/vfs/vfs.c b/sys/fs/vfs/vfs.c index a74963f..8fc62e4 100644 --- a/sys/fs/vfs/vfs.c +++ b/sys/fs/vfs/vfs.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include /************************************************************************ @@ -185,7 +185,7 @@ else { for (index = 0; index < 256;index++) { if (td->o_files[index] == 0x0) { - td->o_files[index] = nfp->fd; + td->o_files[index] = nfp;//->fd; td->td_retval[0] = index;//nfp->fd->ino;//MrOlsen 2018index; break; } @@ -201,16 +201,6 @@ } -/* HACK */ -int fstatfs(struct thread *td, struct fstatfs_args *args) { - int error = 0x0; - args->buf->f_mntonname[0] = '/'; - args->buf->f_mntonname[1] = '\0'; - args->buf->f_flags = 0x0; - return(error); - } - /*** END ***/ - diff --git a/sys/i386/bioscall.c b/sys/i386/bioscall.c index bd4d4e5..1e17018 100644 --- a/sys/i386/bioscall.c +++ b/sys/i386/bioscall.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index 37c4f7f..65120c3 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -39,6 +39,7 @@ #include #include #include +#include #define ENVP_PAGE 0x100 #define ARGV_PAGE 0x100 @@ -603,10 +604,10 @@ /* Make readonly and read/write !!! */ if (vmm_remapPage(vmm_findFreePage(_current->id), ((programHeader[i].p_vaddr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id) == 0x0) { K_PANIC("Error: Remap Page Failed"); - } /* + } else { - kprintf("rP[0x%X]", (programHeader[i].phVaddr & 0xFFFFF000) + x); - } */ + kprintf("rP[0x%X]", (programHeader[i].p_vaddr & 0xFFFFF000) + x); + } memset((void *) ((programHeader[i].p_vaddr & 0xFFFFF000) + x), 0x0, 0x1000); @@ -707,8 +708,13 @@ uint32_t sp = 0x0; + char *EXECP = 0x0; + for (i = 1; i <= argc; i++) { tmp[i] = (uint32_t) STACK_ADDR - ARGV_PAGE + sp; + if (i == 1) { + EXECP = tmp[i]; + } strcpy((char *) tmp[i], (char *) argv_out[i]); sp += strlen(argv_out[i]) + 1; } @@ -735,9 +741,19 @@ i = i + x + 1; + struct file *tFP = 0x0; + int *tFD = 0x0; + + fseek(_current->files[0], 0x0, 0x0); // Reset File Position + falloc(&_current->td, &tFP, &tFD); + + tFP->fd = _current->files[0]; + + tmp[i++] = 2; - tmp[i++] = -1; // _current->imageFd; - kprintf("AT_EXECFD: [%i]", tmp[i - 1]); + tmp[i++] = -1;// tFD; // _current->imageFd; + _current->td.o_files[4] = _current->files[0]; + kprintf("AT_EXECFD: [%i:%i]", tmp[i - 1], tFD); tmp[i++] = 3; tmp[i++] = binaryHeader->e_phoff + 0x08048000; @@ -776,6 +792,9 @@ tmp[i++] = 14; tmp[i++] = 0x0; + tmp[i++] = 15; + tmp[i++] = EXECP; + tmp[i++] = 0; tmp[i++] = 0; diff --git a/sys/i386/syscall.c b/sys/i386/syscall.c index 1730aca..e26a9ad 100644 --- a/sys/i386/syscall.c +++ b/sys/i386/syscall.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/include/fs/common/gpt.h b/sys/include/fs/common/gpt.h index 460b6f6..673f0c9 100644 --- a/sys/include/fs/common/gpt.h +++ b/sys/include/fs/common/gpt.h @@ -31,7 +31,7 @@ #include #include -#include +#include #define bcopy(src, dst, len) memcpy((dst), (src), (len)) #define bzero(buf, size) memset((buf), 0, (size)) diff --git a/sys/include/i386/asmacros.h b/sys/include/i386/asmacros.h index acfb1d5..1c48c28 100644 --- a/sys/include/i386/asmacros.h +++ b/sys/include/i386/asmacros.h @@ -43,10 +43,13 @@ * language name. */ #define CNAME(csym) csym +#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ #define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ .type CNAME(name),@function; CNAME(name): #define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT +#define MCOUNT nop +#define END(name) .size name, . - name #endif /* END _I386_ASMACROS_H_ */ diff --git a/sys/include/string.h b/sys/include/string.h index 5f9dfa4..ffc5559 100644 --- a/sys/include/string.h +++ b/sys/include/string.h @@ -39,7 +39,7 @@ void *memset(void * dst, int c, size_t length); int strlen(const char * string); int memcmp(const void * dst, const void * src, size_t length); -void strncpy(char * dest, const char * src, size_t size); +char *strncpy(char * __restrict, const char * __restrict, size_t); char *strtok(char *str, const char *sep); char *strtok_r(char *str, const char *sep, char **last); char *strstr(const char *s, char *find); diff --git a/sys/include/sys/_types.h b/sys/include/sys/_types.h index 55a9c44..7990e5e 100644 --- a/sys/include/sys/_types.h +++ b/sys/include/sys/_types.h @@ -39,16 +39,45 @@ typedef unsigned long long __uint64_t; typedef unsigned long __clock_t; -typedef __uint32_t __ino_t; typedef __int32_t __ssize_t;/* stat types */ +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 __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 */ -typedef __int8_t __int_fast8_t; typedef __uint8_t __uint_fast8_t; typedef __int16_t __int_fast16_t; typedef __uint16_t __uint_fast16_t; typedef __int32_t __int_fast32_t; typedef __uint32_t __uint_fast32_t; typedef __int64_t __int_fast64_t; typedef __uint64_t __uint_fast64_t; typedef __int32_t __intptr_t; typedef __uint32_t __uintptr_t; typedef __uint32_t __size_t; typedef __int64_t __intmax_t; typedef __uint64_t __uintmax_t; typedef __int32_t __ptrdiff_t; typedef __uint8_t __uint_least8_t; typedef __uint16_t __uint_least16_t; typedef __uint32_t __uint_least32_t; typedef __uint64_t __uint_least64_t; typedef __int8_t __int_least8_t; typedef __int16_t __int_least16_t; typedef __int32_t __int_least32_t; typedef __int64_t __int_least64_t; typedef -int ___wchar_t; +typedef __int8_t __int_fast8_t; + typedef __uint8_t __uint_fast8_t; + typedef __int16_t __int_fast16_t; + typedef __uint16_t __uint_fast16_t; + typedef __int32_t __int_fast32_t; + typedef __uint32_t __uint_fast32_t; + typedef __int64_t __int_fast64_t; + typedef __uint64_t __uint_fast64_t; + typedef __int32_t __intptr_t; + typedef __uint32_t __uintptr_t; +typedef __uint32_t __uintfptr_t; + typedef __uint32_t __size_t; + typedef __int64_t __intmax_t; + typedef __uint64_t __uintmax_t; +typedef __int32_t __ptrdiff_t; + typedef __uint8_t __uint_least8_t; + typedef __uint16_t __uint_least16_t; + typedef __uint32_t __uint_least32_t; + typedef __uint64_t __uint_least64_t; + typedef __int8_t __int_least8_t; + typedef __int16_t __int_least16_t; + typedef __int32_t __int_least32_t; + typedef __int64_t __int_least64_t; + typedef int ___wchar_t; #if !defined(__clang__) || !defined(__cplusplus) -typedef __uint_least16_t __char16_t; typedef __uint_least32_t __char32_t; +typedef __uint_least16_t __char16_t; + typedef __uint_least32_t __char32_t; #endif + #endif diff --git a/sys/include/sys/kern_descrip.h b/sys/include/sys/kern_descrip.h index 0b3c1de..86d607c 100644 --- a/sys/include/sys/kern_descrip.h +++ b/sys/include/sys/kern_descrip.h @@ -150,7 +150,7 @@ 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 fstat(struct thread *, struct sys_fstat_args *); int ioctl(struct thread *, struct ioctl_args *); int getfd(struct thread *td, struct file **fp, int fd); diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h index 42df622..fb8b554 100644 --- a/sys/include/sys/sysproto.h +++ b/sys/include/sys/sysproto.h @@ -260,7 +260,7 @@ char flags_r_[PADR_(int)]; }; -struct fstatfs_args { +struct sys_fstatfs_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; @@ -352,27 +352,12 @@ }; struct sys_mmap_args { - char addr_l_[PADL_(caddr_t)]; - caddr_t addr; - char addr_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char pad_l_[PADL_(int)]; - int pad; - char pad_r_[PADR_(int)]; - char pos_l_[PADL_(off_t)]; - off_t pos; - char pos_r_[PADR_(off_t)]; + char addr_l_[PADL_(caddr_t)]; caddr_t addr; char addr_r_[PADR_(caddr_t)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(int)]; int prot; char prot_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char pos_l_[PADL_(off_t)]; off_t pos; char pos_r_[PADR_(off_t)]; }; struct sys_lstat_args { @@ -406,7 +391,7 @@ register_t dummy; }; -struct munmap_args { +struct sys_munmap_args { char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; @@ -434,7 +419,7 @@ struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; }; -struct fstat_args { +struct sys_fstat_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; @@ -503,16 +488,19 @@ int sys_getcwd(struct thread *td, struct sys_getcwd_args *); int sys_mmap(struct thread *td, struct sys_mmap_args *); +int sys_munmap(struct thread *td, struct sys_munmap_args *); int sys_sysctl(struct thread *td, struct sys_sysctl_args *); int sys_issetugid(struct thread *td, struct sys_issetugid_args *); int setitimer(struct thread *td, struct setitimer_args *uap); int access(struct thread *td, struct access_args *uap); -int fstatfs(struct thread *td, struct fstatfs_args *uap); +int fstatfs(struct thread *td, struct sys_fstatfs_args *uap); int mprotect(struct thread *td, struct mprotect_args *uap); +int sys_fstatfs(struct thread *td, struct sys_fstatfs_args *); int sys_lstat(struct thread *td, struct sys_lstat_args *); +int sys_fstat(struct thread *td, struct sys_fstat_args *); int sys_openat(struct thread *td, struct sys_openat_args *); #endif diff --git a/sys/include/sys/types.h b/sys/include/sys/types.h index 3eb1faf..7e170f7 100644 --- a/sys/include/sys/types.h +++ b/sys/include/sys/types.h @@ -37,6 +37,8 @@ #define NULL 0x0 #endif +typedef __uintfptr_t uintfptr_t; + typedef char *caddr_t; /* unsigned integrals */ diff --git a/sys/kernel/gen_calls.c b/sys/kernel/gen_calls.c index 987555a..017676f 100644 --- a/sys/kernel/gen_calls.c +++ b/sys/kernel/gen_calls.c @@ -35,6 +35,7 @@ #include #include #include +#include /* Exit Syscall */ int sys_exit( struct thread *td, struct sys_exit_args *args ) { @@ -78,7 +79,13 @@ #endif if ( uap->fd == 2 ) { - kprintf( "stderr: %s", uap->buf ); + printColor += 1; + buffer = kmalloc( 1024 ); + memcpy( buffer, uap->buf, uap->nbyte ); + //kprintf( "stderr: [%s]", buffer ); + kprint(buffer); + kfree( buffer ); + printColor = defaultColor; } else if ( uap->fd == 1 ) { /* This is Horrible! */ diff --git a/sys/kernel/kern_descrip.c b/sys/kernel/kern_descrip.c index 2e85f83..11c576e 100644 --- a/sys/kernel/kern_descrip.c +++ b/sys/kernel/kern_descrip.c @@ -107,7 +107,7 @@ } /* HACK */ -int fstat(struct thread *td, struct fstat_args *uap) { +int fstat(struct thread *td, struct sys_fstat_args *uap) { struct file *fp = 0x0; #ifdef DEBUG diff --git a/sys/kernel/syscall_new.c b/sys/kernel/syscall_new.c index 9298d23..c09349f 100644 --- a/sys/kernel/syscall_new.c +++ b/sys/kernel/syscall_new.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/kernel/syscalls.c b/sys/kernel/syscalls.c index 086a157..6943f76 100644 --- a/sys/kernel/syscalls.c +++ b/sys/kernel/syscalls.c @@ -104,7 +104,7 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 70 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 71 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 72 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 73 - Invalid */ + { ARG_COUNT(sys_munmap_args), "MUNMAP", sys_munmap, SYSCALL_VALID }, /* 73 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 74 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 75 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 76 - Invalid */ @@ -220,7 +220,7 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 186 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 187 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 188 - Invalid */ - { ARG_COUNT(sys_lstat_args), "LSTAT", (sys_call_t *) sys_lstat, SYSCALL_VALID }, /* 189 - sys_fstat */ + { ARG_COUNT(sys_fstat_args), "FSTAT", (sys_call_t *) sys_fstat, SYSCALL_VALID }, /* 189 - sys_fstat */ { ARG_COUNT(sys_lstat_args), "LSTAT", (sys_call_t *) sys_lstat, SYSCALL_VALID }, /* 190 - sys_lstat */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 191 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 192 - Invalid */ @@ -428,88 +428,88 @@ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 384 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 385 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 386 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 387 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 388 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 389 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 390 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 391 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 392 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 393 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 394 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 395 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 396 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 397 - Invalid */ +{ ARG_COUNT(sys_fstatfs_args), "fstatfs", (sys_call_t *) sys_fstatfs, SYSCALL_VALID }, /* 397 fstatfs */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 398 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 399 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 400 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 357 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 352 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 353 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 354 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 355 - Invalid */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 356 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 401 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 402 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 403 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 404 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 405 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 306 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 307 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 308 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 409 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 410 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 411 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 412 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 413 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 414 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 415 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 416 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 417 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 418 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 419 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 410 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 421 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 422 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 423 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 424 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 425 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 426 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 427 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 428 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 429 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 430 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 431 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 432 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 433 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 434 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 435 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 436 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 437 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 438 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 439 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 440 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 441 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 442 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 443 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 444 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 445 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 446 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 447 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 448 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 449 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 450 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 451 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 452 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 453 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 454 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 455 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 456 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 457 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 458 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 459 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 460 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 461 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 462 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 463 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 464 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 465 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 466 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 467 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 468 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 469 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 470 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 471 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 472 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 473 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 474 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 475 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 476 - Invalid */ { ARG_COUNT(sys_mmap_args), "MMAP", (sys_call_t *) sys_mmap, SYSCALL_VALID }, /* 477 - sys_mmap */ - { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 358 - Invalid */ + { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 478 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 359 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 350 - Invalid */ { 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 351 - Invalid */ diff --git a/sys/kernel/ubthread.c b/sys/kernel/ubthread.c index 787e2af..31449c2 100644 --- a/sys/kernel/ubthread.c +++ b/sys/kernel/ubthread.c @@ -37,6 +37,7 @@ #include #include #include +#include struct ubthread_cond_list *conds = 0x0; struct ubthread_mutex_list *mutex = 0x0; diff --git a/sys/lib/Makefile b/sys/lib/Makefile index 0be78db..fc308de 100644 --- a/sys/lib/Makefile +++ b/sys/lib/Makefile @@ -8,7 +8,7 @@ INCLUDES += -I../../lib/objgfx40/ # Objects -OBJS = strlen.o strncpy.o assert.o sqrt.o atan.o divdi3.o libcpp.o strtok.o kmalloc.o kprintf.o vsprintf.o string.o net.o strtol.o +OBJS = strstr.o strlen.o strncpy.o assert.o sqrt.o atan.o divdi3.o libcpp.o strtok.o kmalloc.o kprintf.o vsprintf.o string.o net.o strtol.o #ogprintf.o all: $(OBJS) diff --git a/sys/lib/kprintf.c b/sys/lib/kprintf.c index 36c9cce..9675f15 100644 --- a/sys/lib/kprintf.c +++ b/sys/lib/kprintf.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include diff --git a/sys/lib/net.c b/sys/lib/net.c index dc8cf68..40292f3 100644 --- a/sys/lib/net.c +++ b/sys/lib/net.c @@ -57,13 +57,6 @@ } */ -void bcopy(const void *src, void *dest, int len) { - memcpy(dest, src, len); -} - -void bzero(void *data, int n) { - memset(data, 0, n); -} #ifdef _INET_ATON int inet_aton(cp, addr) diff --git a/sys/lib/strlen.c b/sys/lib/strlen.c index f96a4c0..fccb7a8 100644 --- a/sys/lib/strlen.c +++ b/sys/lib/strlen.c @@ -27,6 +27,7 @@ */ #include +#include /* Magic numbers for the algorithm */ #if LONG_BIT == 32 diff --git a/sys/lib/vsprintf.c b/sys/lib/vsprintf.c index 4fc3c03..7cd6daa 100644 --- a/sys/lib/vsprintf.c +++ b/sys/lib/vsprintf.c @@ -32,7 +32,7 @@ */ #include -#include +#include /* we use this so that we can do without the ctype library */ #define is_digit(c) ((c) >= '0' && (c) <= '9') diff --git a/sys/mpi/system.c b/sys/mpi/system.c index 4d683ea..1af8b3b 100644 --- a/sys/mpi/system.c +++ b/sys/mpi/system.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include static mpi_mbox_t *mboxList = 0x0; diff --git a/sys/vmm/getfreevirtualpage.c b/sys/vmm/getfreevirtualpage.c index 1182aa0..ac3975a 100644 --- a/sys/vmm/getfreevirtualpage.c +++ b/sys/vmm/getfreevirtualpage.c @@ -60,19 +60,13 @@ kpanic("Invalid vmStart\n"); kprintf("type: %i ", type); - type = 0; /* Get Our Starting Address */ if (type == VM_THRD) { start_page = (uint32_t) (_current->td.vm_daddr + ctob(_current->td.vm_dsize)); } -<<<<<<< HEAD else if (type == VM_TASK) { //kprintf("vmStart"); -======= - else if ( type == VM_TASK ) { - kprintf("vmStart"); ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git start_page = _current->oInfo.vmStart; } else @@ -89,23 +83,27 @@ /* * Lets Start Allocating Pages */ -<<<<<<< HEAD - - for (counter = 0; counter < count; counter++) { -======= - kprintf("Count: %i ", count); for ( counter = 0; counter < count; counter++ ) { ->>>>>>> branch 'master' of http://Git.BrainChurts.com:8080/git/MrOlsen/UbixOS.git /* Locate Initial Page Table */ pdI = ((start_page + (counter * 0x1000)) / 0x400000); + //kprintf("PAGE IS"); /* If Page Directory Is Not Yet Allocated Allocate It */ if ((pageDir[pdI] & PAGE_PRESENT) != PAGE_PRESENT) { + //kprintf("PAGE NOT %i,", __LINE__); pageDir[pdI] = (uInt32) vmm_findFreePage(_current->id) | PAGE_DEFAULT; + //kprintf("PAGE NOT %i,", __LINE__); - /* Also Add It To Virtual Space So We Can Make Changes Later */ - pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (4096 * 767)); - pageTableSrc[pdI] = pageDir[pdI]; + //kprintf("PAGE NOT %i,", __LINE__); + + /* Also Add It To Virtual Space So We Can Make Changes Later */ + pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (PD_INDEX( PT_BASE_ADDR ) * 0x1000)); /* Table that maps that 4b */ + pageTableSrc[pdI] = (pageDir[pdI] & 0xFFFFF000) | PAGE_DEFAULT; /* Is This Why Page Needs To Be User As Well? */ + pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (pdI * 0x1000)); + + + + //kprintf("PAGE NOT %i,", __LINE__); /* Reload Page Directory */ asm( @@ -113,17 +111,21 @@ "movl %eax,%cr3\n" ); + //kprintf("PAGE NOT %i,", __LINE__); pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pdI)); + //kprintf("PAGE NOT %i,", __LINE__); /* Initialize The New Page Table To Prevent Dirty Bits */ for (y = 0x0; y < PD_ENTRIES; y++) { pageTableSrc[y] = (uInt32) 0x0; } + //kprintf("PAGE NOT %i,", __LINE__); } else { pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pdI)); } +//kprintf("HERE?"); ptI = ((start_page - (pdI * 0x400000)) / 0x1000); diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c index c8e173d..278c749 100644 --- a/sys/vmm/paging.c +++ b/sys/vmm/paging.c @@ -563,12 +563,6 @@ return (0x0); } -int munmap(struct thread *td, struct munmap_args *uap) { - /* HACK */ - kprintf("munmap"); - return (0x0); -} - int vmm_cleanVirtualSpace(uint32_t addr) { int x = 0x0; int y = 0x0; diff --git a/sys/vmm/vmm_mmap.c b/sys/vmm/vmm_mmap.c index eba19eb..072d864 100644 --- a/sys/vmm/vmm_mmap.c +++ b/sys/vmm/vmm_mmap.c @@ -152,23 +152,37 @@ return (0x0); } +int sys_munmap(struct thread *td, struct sys_munmap_args *uap) { + //TEMP + td->td_retval[0] = 0; + return(0); +}; + int sys_mmap(struct thread *td, struct sys_mmap_args *uap) { vm_offset_t addr = 0x0; char *tmp = 0x0; struct file *fd = 0x0; + int x; addr = (vm_offset_t) uap->addr; - if (uap->addr != 0x0) { - kprintf("Address hints are not supported yet.\n"); - td->td_retval[0] = 0x0; - return (-1); - } if (uap->fd == -1) { + if (uap->addr != 0x0) { + for (x = 0x0; x < round_page(uap->len); x += 0x1000) { + vmm_unmapPage(((uint32_t)uap->addr & 0xFFFFF000) + x, 1); + /* Make readonly and read/write !!! */ + if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t)uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id) == 0x0) + K_PANIC("Remap Page Failed"); + + } + tmp = uap->addr; + td->td_retval[0] = (uint32_t)tmp; + return (0x0); + } //td->td_retval[0] = (int) vmm_getFreeVirtualPage( _current->id, uap->len / 0x1000, VM_TASK ); //td->td_retval[0] = (int) - td->td_retval[0] = vmm_getFreeVirtualPage(_current->id, round_page( uap->len ) / 0x1000, VM_THRD); + td->td_retval[0] = vmm_getFreeVirtualPage(_current->id, round_page( uap->len ) / 0x1000, VM_TASK); return (0x0); //vmm_getFreeVirtualPage(_current->id, round_page( uap->len ) / 0x1000, VM_THRD)); } else { @@ -181,10 +195,25 @@ //kprintf("uap->pos: [0x%X]\n", uap->pos); //K_PANIC("NOT YET\n"); getfd(td, &fd, uap->fd); + if (uap->addr == 0x0) tmp = (char *) vmm_getFreeVirtualPage(_current->id, round_page(uap->len) / 0x1000, VM_TASK); - fread(tmp, uap->len, 0x1, fd->fd); + else { + for (x = 0x0; x < round_page(uap->len); x += 0x1000) { + vmm_unmapPage(((uint32_t)uap->addr & 0xFFFFF000) + x, 1); + /* Make readonly and read/write !!! */ + if (vmm_remapPage(vmm_findFreePage(_current->id), (((uint32_t)uap->addr & 0xFFFFF000) + x), PAGE_DEFAULT, _current->id) == 0x0) + K_PANIC("Remap Page Failed"); - td->td_retval[0] = (int) tmp; + } + tmp = uap->addr; + + } + fseek(fd->fd, uap->pos, 0x0); + kprintf("FREAD: %i", fread(tmp, uap->len, 0x1, fd->fd)); + td->td_retval[0] = (uint32_t) tmp; + //MrOlsen kprintf("tmp: %i. ", td->td_retval[0]); + if (td->td_retval[0] == (caddr_t)-1) + kpanic("BALLS"); } return (0x0); }