changeset 42:c75be274ce23

Now functioning arch code
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 07 Apr 2011 23:29:10 -0400
parents 216ad602944f
children c1212be83114
files Makefile arch/channel.h arch/cons.c arch/io.c arch/ioint.S include/system.h
diffstat 6 files changed, 71 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Apr 07 22:08:31 2011 -0400
+++ b/Makefile	Thu Apr 07 23:29:10 2011 -0400
@@ -15,7 +15,7 @@
 
 sarpn_OBJS=src/init.o arch/arch.a
 
-ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o
+ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.o
 
 .PHONY: all build clean tags
 
--- a/arch/channel.h	Thu Apr 07 22:08:31 2011 -0400
+++ b/arch/channel.h	Thu Apr 07 23:29:10 2011 -0400
@@ -1,8 +1,6 @@
 #ifndef __CHANNEL_H
 #define __CHANNEL_H
 
-#define CON_LEN 132
-
 struct pmcw {
 	/* word 0 */
 	u32 interrupt_param;	/* Interruption Parameter */
--- a/arch/cons.c	Thu Apr 07 22:08:31 2011 -0400
+++ b/arch/cons.c	Thu Apr 07 23:29:10 2011 -0400
@@ -3,6 +3,8 @@
 
 #include <die.h>
 
+#define CON_LEN 132
+
 static u32 consch;
 
 int putline(char *buf, int len)
@@ -71,3 +73,15 @@
 
 	return i;
 }
+
+void init_console()
+{
+	u32 sch;
+
+	sch = find_dev(CON_DEV);
+
+	if (!sch)
+		die();
+
+	consch = sch;
+}
--- a/arch/io.c	Thu Apr 07 22:08:31 2011 -0400
+++ b/arch/io.c	Thu Apr 07 23:29:10 2011 -0400
@@ -1,12 +1,6 @@
 #include "channel.h"
 #include <die.h>
 
-/* console I/O functions */
-
-static struct irb irb;
-static struct orb orb;
-static struct ccw ccw;
-
 u32 find_dev(int devnum)
 {
 	struct schib schib;
@@ -22,10 +16,12 @@
 		if (schib.pmcw.dev_num != devnum)
 			continue;
 
-		schib.pmcw.e = 1;
+		if (!schib.pmcw.e) {
+			schib.pmcw.e = 1;
 
-		if (modify_sch(sch, &schib))
-			continue;
+			if (modify_sch(sch, &schib))
+				continue;
+		}
 
 		return sch;
 	}
@@ -33,54 +29,16 @@
 	return 0;
 }
 
-static void enable_cons(int devnum)
+extern void IOINT(void);
+
+void init_io_int()
 {
 	struct psw psw;
-	u32 sch;
-
-	sch = find_dev(devnum);
-
-	if (!sch)
-		die();
-
-	// found it
 
 	// set up the IO interrupt handler
 	psw.ea  = 1;
 	psw.ba  = 1;
-
-	asm volatile(
-		"       larl    %%r1,0f\n"
-		"       stg     %%r1,%0\n"
-		"	brc	15,1f\n"
-		/* IO handler code begins */
-		"0:\n"
-		"	l	%%r1,0xb8\n"
-		"	larl	%%r2,irb\n"
-		"	tsch	0(%%r2)\n"
-		"	l	%%r1,5(%%r2)\n"
-		"	nill	%%r1,0x04\n"
-		"	brc	8,2f\n" // done?
-		"	lg	%%r1,0x178\n" // yes.
-		"	bcr	15,%%r1\n"
-		"2:\n"
-		"	l	%%r1,5(%%r2)\n"
-		"	nill	%%r1,0x80\n"
-		"	brc	8,3f\n" // attention?
-		"	lg	%%r1,0x178\n" // yes.
-		"	bcr	15,%%r1\n"
-		"3:\n"
-		"	lpswe	0x170\n"
-		/* IO handler code ends */
-		"1:\n"
-	: /* output */
-	  "=m" (psw.ptr),
-	  "=m" (irb)
-	: /* input */
-	  "a" (&irb)
-	: /* clobbered */
-	  "r1", "r2"
-	);
+	psw.ptr = (u64) &IOINT;
 
 	__builtin_memcpy(((void*) 0x1f0), &psw, sizeof(struct psw));
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/arch/ioint.S	Thu Apr 07 23:29:10 2011 -0400
@@ -0,0 +1,44 @@
+.text
+	.align	4
+.globl IOINT
+	.type	IOINT, @function
+IOINT:
+	stmg	%r1,%r2,512
+
+	l	%r1,0xb8
+	larl	%r2,irb
+	tsch	0(%r2)
+
+	l	%r1,5(%r2)
+	nill	%r1,0x04
+	brc	7,4f		# device end
+
+	l	%r1,5(%r2)
+	nill	%r1,0x80
+	brc	7,4f		# attention
+
+	l	%r1,5(%r2)
+	nill	%r1,0x03
+	brc	7,4f		# ucheck or uexcept
+
+4:
+	la	%r1,1
+	st	%r1,0x170
+3:
+	mvc	0x210(1,%r0),8(%r2)
+	lmg	%r1,%r2,512
+	lpswe	0x170
+
+irb:
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
+	.8byte 0x00
--- a/include/system.h	Thu Apr 07 22:08:31 2011 -0400
+++ b/include/system.h	Thu Apr 07 23:29:10 2011 -0400
@@ -21,6 +21,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+	extern void init_io_int(void);
+	extern void init_console(void);
+
 	extern int putline(char *buf, int len);
 	extern int getline(char *buf, int len);