changeset 466:678579f3a83b

installer: the end of media generates a unit exception Closes bug #185. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 11 Apr 2011 22:34:24 -0400
parents 5f48776756db
children 25199ff67309
files installer/cpio.c installer/loader_asm.S installer/loader_c.c
diffstat 3 files changed, 45 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/installer/cpio.c	Sat Apr 09 13:15:09 2011 -0400
+++ b/installer/cpio.c	Mon Apr 11 22:34:24 2011 -0400
@@ -91,9 +91,13 @@
 
 static void readcard(u8 *buf)
 {
+	static int eof;
 	int ret;
 	struct ccw ccw;
 
+	if (eof)
+		return;
+
 	ccw.cmd   = 0x02;
 	ccw.flags = 0;
 	ccw.count = 80;
@@ -105,6 +109,11 @@
 	ORB.addr  = ADDR31(&ccw);
 
 	ret = __do_io(ipl_sch);
+	if (ret == 0x01) {
+		eof = 1;
+		return;  // end of media
+	}
+
 	if (ret)
 		die();
 }
--- a/installer/loader_asm.S	Sat Apr 09 13:15:09 2011 -0400
+++ b/installer/loader_asm.S	Mon Apr 11 22:34:24 2011 -0400
@@ -1,35 +1,35 @@
 #
-# Copyright (c) 2007 Josef 'Jeff' Sipek
+# Copyright (c) 2007-2011 Josef 'Jeff' Sipek
 #
 
 #include "loader.h"
 
 .text
 	.align	4
-.globl __do_io
-	.type	__do_io, @function
-__do_io:
-	LGR	%r1,%r2			# load subsystem ID
-
-	LA	%r2, 1			# error return code
-
-	LARL	%r4,ORB
-	SSCH	0(%r4)			# issue IO
-	BCR	7, %r14			# return on error
-
-	LARL	%r4,WAITPSW		# wait for the interrupt
-	LPSWE	0(%r4)
-
-.text
-	.align	4
 .globl __wait_for_attn
 	.type	__wait_for_attn, @function
 __wait_for_attn:
 	LARL	%r4,WAITPSW		# wait for the interrupt
 	LPSWE	0(%r4)
 
+# int __do_io(u32 sch);
+	.align	4
+.globl __do_io
+	.type	__do_io, @function
+__do_io:
+	LGR	%r1,%r2			# load subsystem ID
+
+	LA	%r2,0xfff		# error return code
+
+	LARL	%r4,ORB
+	SSCH	0(%r4)			# issue IO
+	BCR	7, %r14			# return on error
+
+	LARL	%r4,WAITPSW		# wait for the interrupt
+	LPSWE	0(%r4)
+
 #
-# The IO interrupt handler
+# The IO interrupt handler; it's very much like a continuation of __do_io
 #
 .globl IOHANDLER
 IOHANDLER:
@@ -46,33 +46,26 @@
 	LARL	%r4,IRB
 	TSCH	0(%r4)
 
-	# load status
+	# check the Channel Status for != 0
 	XGR	%r2,%r2
-	IC	%r2,8(%r4)
-
-	# attention?
-	LR	%r1,%r2
-	NILL	%r1,0x80
-	BCR	4,%r14			# attention => return
-
-	# unit check?
-	LR	%r1,%r2
-	NILL	%r1,0x02
-	BCR	4,%r14			# unit check => return
+	IC	%r2,9(%r4)
+	NILL	%r2,0xbf		# get rid of SLI
+	LTR	%r2,%r2
+	BCR	7,%r14			# error, let's bail
 
-	# device end?
-	LR	%r1,%r2
-	XGR	%r2,%r2			# zero the return code
-	NILL	%r1,0x04
-	BCR	4,%r14			# device end => return
+	# check the Device Status
+	XGR	%r1,%r1
+	IC	%r1,8(%r4)
 
-/*
-FIXME: we should do more checking!
+	# unit check, unit except?
+	LR	%r2,%r1
+	NILL	%r2,0x03
+	BCR	4,%r14			# error return
 
-11) If Unit check or Channel Status|=0 : An I/O error occurred and act accordingly
-12) If unit exception : End of media (for tape & cards) and act accordingly
-13) If device end : I/O Completed.. Perform post I/O stuff (like advancing your pointers) and back to step 3
-*/
+	# attention, DE?
+	XGR	%r2,%r2
+	NILL	%r1,0x84
+	BCR	4,%r14			# ok return
 
 IONOTDONE:
 	LPSWE	0x170
--- a/installer/loader_c.c	Sat Apr 09 13:15:09 2011 -0400
+++ b/installer/loader_c.c	Mon Apr 11 22:34:24 2011 -0400
@@ -110,7 +110,7 @@
 	struct senseid_struct id;
 
 	ccw.cmd   = 0xe4;
-	ccw.flags = 0;
+	ccw.flags = CCW_FLAG_SLI;
 	ccw.count = sizeof(struct senseid_struct);
 	ccw.addr  = ADDR31(&id);
 
@@ -228,7 +228,7 @@
 
 	/* read user input */
 	ccw.cmd   = 0x0a;
-	ccw.flags = 0;
+	ccw.flags = CCW_FLAG_SLI;
 	ccw.count = buflen;
 	ccw.addr  = ADDR31(inp);