Mercurial > sos > sos
changeset 109:b3fe51f1d753
Added an ls program, fixed plenty of bugs
Added an ls program which displays all files on the disk
Moved all the file system structures to a separate file, fsstructs
Added finfo system call which is a nice wrapper for the getFInfo function
The kernel stack start and program stack start are both defined correctly now (*facepalm*)
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sun, 05 Jun 2011 17:33:54 -0400 |
parents | bda048879e28 |
children | f0bd97df958b |
files | .hgignore Makefile include/os/fs.h include/os/fsStructs.h include/svcCalls.h src/ls.c src/os/scall.c src/shell.c |
diffstat | 8 files changed, 86 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Jun 05 15:41:51 2011 -0400 +++ b/.hgignore Sun Jun 05 17:33:54 2011 -0400 @@ -7,6 +7,7 @@ ^testFS$ ^shell$ ^osTest$ +^ls$ ^loader\.bin$ ^cscope\.out$ \.swp$
--- a/Makefile Sun Jun 05 15:41:51 2011 -0400 +++ b/Makefile Sun Jun 05 17:33:54 2011 -0400 @@ -11,13 +11,14 @@ CXXFLAGS=$(CFLAGS) LDFLAGS=-m elf64_s390 -BINS=sarpn dynamic testFS shell osTest +BINS=sarpn dynamic testFS shell osTest ls sarpn_OBJS=src/sarpn.o src/std.o src/string.o src/stack.o src/operations.o src/math.o arch/arch.a dynamic_OBJS=src/dynamic.o src/std.o src/string.o src/stack.o arch/arch.a testFS_OBJS=src/testFS.o src/std.o src/string.o src/os/fs.o arch/arch.a shell_OBJS=src/shell.o src/std.o src/os/fs.o src/string.o src/stdio.o src/os/scall.o arch/arch.a osTest_OBJS=src/osTest.o +ls_OBJS=src/ls.o ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.o \ arch/svc.o arch/svcint.o @@ -50,6 +51,8 @@ $(LD) $(LDFLAGS) -T scripts/linker.script -o $@ $^ osTest: $(osTest_OBJS) $(LD) $(LDFLAGS) -T scripts/linkerProg.script -o $@ $^ +ls: $(ls_OBJS) + $(LD) $(LDFLAGS) -T scripts/linkerProg.script -o $@ $^ arch/arch.a: $(ARCH_OBJS) $(AR) rc $@ $^ @@ -101,16 +104,20 @@ # DO NOT DELETE src/dynamic.o: include/std.h include/die.h include/string.h include/stack.h +src/ls.o: include/os/fsStructs.h include/svcCalls.h include/svc_prog.h +src/ls.o: include/os/svcNums.h include/error.h src/operations.o: include/operations.h include/std.h include/die.h src/operations.o: include/stack.h include/string.h include/math.h -src/osTest.o: include/svcCalls.h include/svc_prog.h +src/osTest.o: include/svcCalls.h include/svc_prog.h include/os/svcNums.h +src/osTest.o: include/error.h src/sarpn.o: include/std.h include/die.h include/string.h src/sarpn.o: include/operations.h include/stack.h src/shell.o: include/std.h include/die.h include/string.h include/stdio.h -src/shell.o: include/error.h include/os/fs.h include/elf.h include/psw.h -src/shell.o: include/svc.h include/os/scall.h +src/shell.o: include/error.h include/os/fs.h include/os/fsStructs.h +src/shell.o: include/elf.h include/psw.h include/svc.h include/os/scall.h src/stack.o: include/stack.h include/std.h include/die.h src/std.o: include/std.h include/die.h include/string.h src/stdio.o: include/stdio.h include/std.h include/die.h include/string.h src/stdio.o: include/stdarg.h src/testFS.o: include/std.h include/die.h include/os/fs.h include/error.h +src/testFS.o: include/os/fsStructs.h
--- a/include/os/fs.h Sun Jun 05 15:41:51 2011 -0400 +++ b/include/os/fs.h Sun Jun 05 17:33:54 2011 -0400 @@ -1,55 +1,16 @@ #include <std.h> #include <error.h> +#include <os/fsStructs.h> #ifndef __FS_H #define __FS_H #define CACHESPACE 1 //percentage of heap to use for the FS Cache -#define FNAMELEN 28 //How long the filenames are -#define FSBLKSIZE 1024 -#define DSKBLKSIZE 512 -#define MAXBLOCKS 248 #define FSMAGICNUM 0x42420374 #define DEPBLK (FSBLKSIZE / sizeof(Direntry)) //director entries per block #define ERR_FSBLKREADFAIL mkError(MODFS, BLKREADFAIL, ERROR) -struct SUPERBLOCK { - u32 magic; // == 0x42420374 - u32 root_inode; // the disk block containing the root inode - u32 nblocks; // number of block on the disk - u32 _pad[253]; // unused (should be '\0' filled) -}; -typedef struct SUPERBLOCK Superblock; - -struct INODE { - u32 size; // file length in bytes - u32 _pad0; // unused (should be 0) - u64 ctime; // creation time stamp - u64 mtime; // last modification time stamp - u16 nblocks; // number of data blocks in this file - u16 _pad1; // unused (should be 0) - u32 _pad2; // unused (should be 0) - u32 blocks[MAXBLOCKS]; // file block ptrs -}; -typedef struct INODE Inode; - -struct FSBLK { - u8 blocks[FSBLKSIZE]; -}; -typedef struct FSBLK FSBlk; - -struct DSKBLK { - u8 blocks[DSKBLKSIZE]; -}; -typedef struct DSKBLK DskBlk; - -struct DIRENTRY { //32 bytes - char fname[FNAMELEN]; - u32 inode; -}; -typedef struct DIRENTRY Direntry; - ErrCode init_fs(u32 devnum, u64 __memsize); ErrCode getFInfo(u32 n, void* de); ErrCode lookupFile(char *fname, u32 *fid);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/os/fsStructs.h Sun Jun 05 17:33:54 2011 -0400 @@ -0,0 +1,40 @@ +#ifndef __FSSTRUCTS_H +#define __FSSTRUCTS_H + +#define FNAMELEN 28 //How long the filenames are +#define FSBLKSIZE 1024 +#define DSKBLKSIZE 512 +#define MAXBLOCKS 248 //max blocks in an inode + +typedef struct { + u32 magic; // == 0x42420374 + u32 root_inode; // the disk block containing the root inode + u32 nblocks; // number of block on the disk + u32 _pad[253]; // unused (should be '\0' filled) +} Superblock; + +struct { + u32 size; // file length in bytes + u32 _pad0; // unused (should be 0) + u64 ctime; // creation time stamp + u64 mtime; // last modification time stamp + u16 nblocks; // number of data blocks in this file + u16 _pad1; // unused (should be 0) + u32 _pad2; // unused (should be 0) + u32 blocks[MAXBLOCKS]; // file block ptrs +} Inode; + +typedef struct { + u8 blocks[FSBLKSIZE]; +} FSBlk; + +typedef struct { + u8 blocks[DSKBLKSIZE]; +} DskBlk; + +typedef struct { //32 bytes + char fname[FNAMELEN]; + u32 inode; +} Direntry; + +#endif //__FSSTRUCTS_H
--- a/include/svcCalls.h Sun Jun 05 15:41:51 2011 -0400 +++ b/include/svcCalls.h Sun Jun 05 17:33:54 2011 -0400 @@ -3,6 +3,7 @@ #include <svc_prog.h> #include <os/svcNums.h> +#include <error.h> static inline void exit() { @@ -14,5 +15,10 @@ return invoke_svc2(SVC_PRINT, buf, len); } +static inline ErrCode finfo(u32 n, void* de) +{ + return invoke_svc2(SVC_FINFO, n, de); +} + #endif //__SVCCALLS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ls.c Sun Jun 05 17:33:54 2011 -0400 @@ -0,0 +1,16 @@ +#include <os/fsStructs.h> +#include <svcCalls.h> + +void start() +{ + size_t i; + for(i = 0; 1; i++) { + Direntry de; + ErrCode err = finfo(i, &de); + if(err == mkError(MODFS, OUTOFRANGE, WARN)) break; + else if(isError(err)) exit(); + printLine(de.fname, 28); + printLine("\n", 1); + } + exit(); +}
--- a/src/os/scall.c Sun Jun 05 15:41:51 2011 -0400 +++ b/src/os/scall.c Sun Jun 05 17:33:54 2011 -0400 @@ -1,6 +1,11 @@ #include <os/scall.h> #include <os/svcNums.h> +#include <os/fs.h> #include <svc.h> +/* +#include <stdio.h> +#include <string.h> +*/ u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d) { @@ -14,6 +19,9 @@ case SVC_PRINT: //print registers[2] = putline((char*)a, (u32)b); break; + case SVC_FINFO: + registers[2] = getFInfo(a, (void*) b); + break; default: registers[2] = -1; //TODO HACK break;
--- a/src/shell.c Sun Jun 05 15:41:51 2011 -0400 +++ b/src/shell.c Sun Jun 05 17:33:54 2011 -0400 @@ -9,7 +9,8 @@ #include <svc.h> #include <os/scall.h> -#define KERNEL_STACK_START 0x400000 - 160 //this is correctt, ignore the documentation +#define PROGRAM_STACK_START 0x400000 - 160 //this is correct, ignore the documentation +#define KERNEL_STACK_START 0x380000 - 160 //this is correct, ignore the documentation void start(u64 __memsize) { @@ -58,7 +59,7 @@ u64 registers[16]; memset(&psw, 0, sizeof(psw)); memset(registers, 0, sizeof(registers)); - registers[15] = KERNEL_STACK_START; + registers[15] = PROGRAM_STACK_START; psw.p = 1; psw.ea = 1; psw.ba = 1;