changeset 138:ea2136c52c35

Moved some stuff out of arch, added some usefulness to program interrupt catching
author Jonathan Pevarnek <pevarnj@gmail.com>
date Thu, 22 Sep 2011 13:42:10 -0400
parents 773af52f9811
children adeb47dd7040
files Makefile arch/except.c arch/progint.S arch/progint.h include/os/progint.h src/os/except.c
diffstat 6 files changed, 59 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Sep 22 12:59:05 2011 -0400
+++ b/Makefile	Thu Sep 22 13:42:10 2011 -0400
@@ -14,7 +14,7 @@
 OSBINS=shell
 PROGBINS=hello ls echo dynamic rpn broken
 
-shell_OBJS=src/os/shell.o src/os/std.o src/os/fs.o src/os/string.o src/os/stdio.o src/os/scall.o src/os/heap.o src/os/memStack.o arch/arch.a
+shell_OBJS=src/os/shell.o src/os/std.o src/os/fs.o src/os/string.o src/os/stdio.o src/os/scall.o src/os/heap.o src/os/memStack.o src/os/except.o arch/arch.a
 hello_OBJS=src/prog/hello.o src/prog/std.o src/prog/string.o
 ls_OBJS=src/prog/ls.o
 echo_OBJS=src/prog/echo.o src/prog/std.o src/prog/string.o
@@ -25,7 +25,7 @@
 testFS_OBJS=src/testFS.o src/std.o src/string.o src/os/fs.o arch/arch.a
 
 ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.o \
-	  arch/svc.o arch/svcint.o arch/progint.o arch/except.o
+	  arch/svc.o arch/svcint.o arch/progint.o
 
 .PHONY: all build clean tags
 
--- a/arch/except.c	Thu Sep 22 12:59:05 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#include <os/psw.h>
-#include <die.h>
-#include "progint.h"
-
-extern void PROGINT(void);
-
-void init_prog_int()
-{
-	Psw psw;
-	__builtin_memset(&psw, 0, sizeof(psw));
-	psw.ea = 1;
-	psw.ba = 1;
-	psw.ptr = (u64) &PROGINT;
-	__builtin_memcpy(((void*) PROGINT_PSW_NEW), &psw, sizeof(psw));
-}
-
-void prog_int_handler() {
-	Psw psw;
-	__builtin_memset(&psw, 0, sizeof(Psw)); //I am going to use the builtin ones
-	                                       //for a bit longer while I think
-	psw.w = 1;
-	psw.ea = 1;
-	psw.ba = 1;
-	psw.ptr = 0xd1e;
-	asm volatile(
-		"lpswe %0\n"
-		: /* no output */
-		: "m" (psw)
-	);
-}
--- a/arch/progint.S	Thu Sep 22 12:59:05 2011 -0400
+++ b/arch/progint.S	Thu Sep 22 13:42:10 2011 -0400
@@ -1,4 +1,4 @@
-#include "progint.h"
+#include <os/progint.h>
 
 .text
 	.align 4
--- a/arch/progint.h	Thu Sep 22 12:59:05 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#ifndef __PROGINT_H
-#define __PROGINT_H
-
-#define PROGINT_REG_LOC 0x300
-
-#define PROGINT_PSW_OLD 0x150
-#define PROGINT_PSW_NEW 0x1D0
-
-#define PROGINT_STACK 0x300000
-#define PROGINT_STACK_SHIFT 0x30
-#define PROGINT_STACK_SHIFT_OFFSET 16
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/os/progint.h	Thu Sep 22 13:42:10 2011 -0400
@@ -0,0 +1,15 @@
+#ifndef __PROGINT_H
+#define __PROGINT_H
+
+#define NUM_REGS 16
+
+#define PROGINT_REG_LOC 0x300
+
+#define PROGINT_PSW_OLD 0x150
+#define PROGINT_PSW_NEW 0x1D0
+
+#define PROGINT_STACK 0x300000
+#define PROGINT_STACK_SHIFT 0x30
+#define PROGINT_STACK_SHIFT_OFFSET 16
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/os/except.c	Thu Sep 22 13:42:10 2011 -0400
@@ -0,0 +1,41 @@
+#include <os/psw.h>
+#include <os/progint.h>
+#include <std.h>
+#include <stdio.h>
+
+extern void PROGINT(void);
+
+void init_prog_int()
+{
+	Psw psw;
+	__builtin_memset(&psw, 0, sizeof(psw));
+	psw.ea = 1;
+	psw.ba = 1;
+	psw.ptr = (u64) &PROGINT;
+	__builtin_memcpy(((void*) PROGINT_PSW_NEW), &psw, sizeof(psw));
+}
+
+void prog_int_handler() {
+	Psw psw;
+	size_t i;
+	char buffer[512];
+	__builtin_memset(&psw, 0, sizeof(Psw)); //I am going to use the builtin ones
+	                                        //for a bit longer while I think
+	u64 *regStore = (u64*)PROGINT_REG_LOC;
+	u64 regLoc[NUM_REGS];
+	__builtin_memcpy((void*)regLoc, regStore, NUM_REGS*sizeof(u64));
+	for(i = 0; i < NUM_REGS; i++) {
+		sprintf(buffer, "REG %x: %x\n", i, regLoc[i]);
+		sPrint(buffer);
+	}
+	
+	psw.w = 1;
+	psw.ea = 1;
+	psw.ba = 1;
+	psw.ptr = 0xdead;
+	asm volatile(
+		"lpswe %0\n"
+		: /* no output */
+		: "m" (psw)
+	);
+}