changeset 103:963bed9f5592

Attempted to set up the syscall handler
author Jonathan Pevarnek <pevarnj@gmail.com>
date Mon, 30 May 2011 22:55:19 -0400
parents 14d96c95dd56
children 1144f2491a39
files Makefile include/os/scall.h src/os/scall.c src/shell.c
diffstat 4 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun May 29 19:35:17 2011 -0400
+++ b/Makefile	Mon May 30 22:55:19 2011 -0400
@@ -16,7 +16,7 @@
 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/fs.o arch/arch.a
-shell_OBJS=src/shell.o src/std.o src/fs.o src/string.o src/stdio.o arch/arch.a
+shell_OBJS=src/shell.o src/std.o src/fs.o src/string.o src/stdio.o src/os/scall.o arch/arch.a
 infLoop_OBJS=src/infLoop.o
 
 ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.o \
@@ -109,7 +109,7 @@
 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/fs.h include/elf.h include/psw.h
-src/shell.o: include/svc.h
+src/shell.o: 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/os/scall.h	Mon May 30 22:55:19 2011 -0400
@@ -0,0 +1,11 @@
+#ifndef __SCALL_H
+#define __SCALL_H
+
+#include <psw.h>
+
+Psw shellPsw; //XXX No idea if this is correct XXX
+u64 shellRegisters[16];
+
+u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d);
+
+#endif //__SCALL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/os/scall.c	Mon May 30 22:55:19 2011 -0400
@@ -0,0 +1,16 @@
+#include <os/scall.h>
+#include <svc.h>
+
+u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d)
+{
+	switch(callCode) {
+		case 0: //exit
+			setcontext(&shellPsw, shellRegisters);
+			break; //to the best of my knowledge, this is not needed.
+			       //If this is wrong, my understanding of what I am doing is non-existent
+		case 1: //print
+			putline((char*)a, (u32)b);
+			break;
+	}
+	return 0; //TODO HACK
+}
--- a/src/shell.c	Sun May 29 19:35:17 2011 -0400
+++ b/src/shell.c	Mon May 30 22:55:19 2011 -0400
@@ -7,6 +7,9 @@
 #include <elf.h>
 #include <psw.h>
 #include <svc.h>
+#include <os/scall.h>
+
+#define KERNEL_STACK_START 0x400000 - 8
 
 void start(u64 __memsize)
 {
@@ -14,6 +17,9 @@
 	if(isError(init_fs(0x100, __memsize))) die();
 	char buffer[1024];
 	ErrCode err;
+	//set up the svc call handler
+	set_svc_handler(svc_handler, (void*)KERNEL_STACK_START);
+	
 	while(1) {
 		sPrint("$ ");
 		sGet(buffer, 78);
@@ -43,18 +49,19 @@
 					if(diff) memset(toLoc + pHdr->p_filesz, 0, diff);
 				}
 			}
+
 			Psw psw;
 			u64 registers[16];
 			memset(&psw, 0, sizeof(psw));
 			memset(registers, 0, sizeof(registers));
-			registers[15] = 0x400000 - 8;
+			registers[15] = KERNEL_STACK_START;
 			psw.p = 1;
 			psw.ea = 1;
 			psw.ba = 1;
 			psw.ptr = eHdr->e_entry;
 			sprintf(buffer, "Going to memory address %i\n", eHdr->e_entry);
 			sPrint(buffer);
-			setcontext(&psw, registers);
+			swapcontext(&shellPsw, shellRegisters, &psw, registers);
 		loopCont:
 			free(data);
 		}