changeset 606:165e37f95fb8

nss/login: set up interrupt handlers Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 09 Dec 2011 21:22:53 -0500
parents 2dc1a4364955
children 1b796ccc6e1f
files nss/login/CMakeLists.txt nss/login/die.s nss/login/int.h nss/login/int.s nss/login/io.c nss/login/linker.script nss/login/main.c nss/login/mch.c nss/login/misc.h nss/login/prg.c nss/login/psa.s
diffstat 11 files changed, 308 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/nss/login/CMakeLists.txt	Fri Dec 09 21:05:17 2011 -0500
+++ b/nss/login/CMakeLists.txt	Fri Dec 09 21:22:53 2011 -0500
@@ -1,3 +1,5 @@
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I ${CMAKE_CURRENT_SOURCE_DIR}")
+
 set(CMAKE_EXE_LINKER_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.script")
 
-add_executable(login entry.s main.c)
+add_executable(login entry.s psa.s int.s die.s main.c io.c mch.c prg.c)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/die.s	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+.text
+
+	.align	4
+.globl die
+	.type	die, @function
+die:
+	larl	%r1,disabled_wait
+	lpswe	0(%r1)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/int.h	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+#ifndef __INT_H
+#define __INT_H
+
+extern void rst_int();
+extern void ext_int();
+extern void svc_int();
+extern void prg_int();
+extern void mch_int();
+extern void io_int();
+
+extern struct psw psw_rst_old;
+extern struct psw psw_ext_old;
+extern struct psw psw_svc_old;
+extern struct psw psw_prg_old;
+extern struct psw psw_mch_old;
+extern struct psw psw_io_old;
+extern struct psw psw_rst_new;
+extern struct psw psw_ext_new;
+extern struct psw psw_svc_new;
+extern struct psw psw_prg_new;
+extern struct psw psw_mch_new;
+extern struct psw psw_io_new;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/int.s	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,32 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+.text
+
+/* we should never get a reset interrupt */
+	.align	4
+.globl rst_int
+	.type	rst_int, @function
+rst_int:
+	larl	%r1,disabled_wait
+	lpswe	0(%r1)
+
+/* we should never get an external interrupt */
+	.align	4
+.globl ext_int
+	.type	ext_int, @function
+ext_int:
+	larl	%r1,disabled_wait
+	lpswe	0(%r1)
+
+/* we should never get a svc interrupt */
+	.align	4
+.globl svc_int
+	.type	svc_int, @function
+svc_int:
+	larl	%r1,disabled_wait
+	lpswe	0(%r1)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/io.c	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+#include <misc.h>
+
+void io_int()
+{
+	die();
+}
--- a/nss/login/linker.script	Fri Dec 09 21:05:17 2011 -0500
+++ b/nss/login/linker.script	Fri Dec 09 21:22:53 2011 -0500
@@ -2,6 +2,9 @@
 {
   ENTRY(START)
 
+  . = 0;
+  .psa : { *psa.s.o(.data) }
+
   . = 0x100000 - 160;
   .stack : { *entry.s.o(.data) }
 
--- a/nss/login/main.c	Fri Dec 09 21:05:17 2011 -0500
+++ b/nss/login/main.c	Fri Dec 09 21:22:53 2011 -0500
@@ -5,8 +5,120 @@
  * details.
  */
 
+#include <arch.h>
+#include <string.h>
+#include <int.h>
+#include <misc.h>
+
+/*
+ * This guest OS has a very simple purpose.  It is responsible for
+ * displaying the login splash, prompting the user for a username and
+ * password, and then querying CP to verify that the password is correct.
+ * If correct, CP will detach the rdev from this guest, and attach it to the
+ * user's guest.
+ *
+ *         +------------------------------------------------+
+ *         | +------------------------------------+         |
+ *         | | virt_sys                           |         |
+ *         | | +--------+ +-------+ +---------+   |   +----+|
+ *         | | |virt_cpu| |storage| |virt_cons|<--+-->|rdev||
+ *         | | +--------+ +-------+ +---------+   |   +----+|
+ *         | |                           /\       |         |
+ *         | |                           ||       |         |
+ *         | |                           \/       |         |
+ *         | | +--------+ +--------+ +--------+   |         |
+ *         | | |virt_dev| |virt_dev| |virt_dev|   |         |
+ *         | | +--------+ +--------+ +--------+   |         |
+ *         | +------------------------------------+         |
+ *         |                                                |
+ *         | +------------------------------------+         |
+ *         | | virt_sys                           |         |
+ *         | | +--------+ +-------+ +---------+   |   +----+|
+ *         | | |virt_cpu| |storage| |virt_cons|<--+-->|rdev||
+ *         | | +--------+ +-------+ +---------+   |   +----+|
+ *         | |                           /\       |         |
+ *         | |                           ||       |         |
+ *         | |                           \/       |         |
+ *         | | +--------+ +--------+ +--------+   |         |
+ *         | | |virt_dev| |virt_dev| |virt_dev|   |         |
+ *         | | +--------+ +--------+ +--------+   |         |
+ *         | +------------------------------------+         |
+ *         |                                                |
+ *         |                   :                            |
+ *         |                   :                            |
+ *         |                   :                            |
+ *         |                                                |
+ *         | +------------------------------------+         |
+ *         | | virt_sys (*LOGIN)                  |         |
+ *         | | +--------+ +-------+ +---------+   |         |
+ *         | | |virt_cpu| |storage| |virt_cons|   |         |
+ *         | | +--------+ +-------+ +---------+   |         |
+ *         | |                       +--------+   |   +----+|
+ *         | |                       |virt_dev|<--+-->|rdev||
+ *         | |                       +--------+   |   +----+|
+ *         | |                       +--------+   |   +----+|
+ *         | |                       |virt_dev|<--+-->|rdev||
+ *         | |                       +--------+   |   +----+|
+ *         | |                       +--------+   |   +----+|
+ *         | |                       |virt_dev|<--+-->|rdev||
+ *         | |                       +--------+   |   +----+|
+ *         | +------------------------------------+         |
+ *         +------------------------------------------------+
+ *
+ *
+ * In other words, here are the actions that CP takes:
+ *
+ * host IPL:
+ *  - ipl *LOGIN
+ *  - attach operator console to *LOGIN
+ *
+ * login:
+ *  - alloc virt sys, virt cpu, virt devices, virt cons, storage
+ *  - detach console rdev from *LOGIN
+ *  - attach console rdev to virt cons
+ *
+ * logout/force:
+ *  - free virt sys, virt cpu, virt devices, virt cons, storage
+ *  - attach console rdev to *LOGIN
+ *
+ * disconnect:
+ *  - detach console rdev from virt cons
+ *  - attach console rdev to *LOGIN
+ *
+ * reconnect:
+ *  - detach console rdev from *LOGIN
+ *  - attach console rdev to virt cons
+ */
+
+struct psw disabled_wait = { .w = 1, .ea = 1, .ba = 1, .ptr = 0xfafafa, };
+struct psw enabled_wait = { .io = 1, .m = 1, .w = 1, .ea = 1, .ba = 1, };
+
+static struct psw __new_rst = { .ea = 1, .ba = 1, .ptr = ADDR64(&rst_int), };
+static struct psw __new_ext = { .ea = 1, .ba = 1, .ptr = ADDR64(&ext_int), };
+static struct psw __new_svc = { .ea = 1, .ba = 1, .ptr = ADDR64(&svc_int), };
+static struct psw __new_prg = { .ea = 1, .ba = 1, .ptr = ADDR64(&prg_int), };
+static struct psw __new_mch = { .ea = 1, .ba = 1, .ptr = ADDR64(&mch_int), };
+static struct psw __new_io  = { .ea = 1, .ba = 1, .ptr = ADDR64(&io_int), };
+
 void start()
 {
-	for(;;)
-		;
+	/* set up interrupt PSWs */
+	memcpy(&psw_rst_new, &__new_rst, sizeof(struct psw));
+	memcpy(&psw_ext_new, &__new_ext, sizeof(struct psw));
+	memcpy(&psw_svc_new, &__new_svc, sizeof(struct psw));
+	memcpy(&psw_prg_new, &__new_prg, sizeof(struct psw));
+	memcpy(&psw_mch_new, &__new_mch, sizeof(struct psw));
+	memcpy(&psw_io_new,  &__new_io,  sizeof(struct psw));
+
+	// FIXME: enable all 8 I/O classes (cr6?)
+
+	/* this enables I/O & MCH interrupts */
+	asm volatile(
+		"lpswe	%0\n"
+	: /* output */
+	: /* input */
+	  "m" (enabled_wait)
+	);
+
+	die();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/mch.c	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+#include <misc.h>
+
+void mch_int()
+{
+	die();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/misc.h	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+#ifndef __MISC_H
+#define __MISC_H
+
+#define ADDR64(x)	((u64) (x))
+
+extern void die();
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/prg.c	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+#include <misc.h>
+
+void prg_int()
+{
+	die();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nss/login/psa.s	Fri Dec 09 21:22:53 2011 -0500
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2007-2011  Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * This file is released under the GPLv2.  See the COPYING file for more
+ * details.
+ */
+
+.data
+.org 0x120
+.globl psw_rst_old
+psw_rst_old:
+
+.org 0x130
+.globl psw_ext_old
+psw_ext_old:
+
+.org 0x140
+.globl psw_svc_old
+psw_svc_old:
+
+.org 0x150
+.globl psw_prg_old
+psw_prg_old:
+
+.org 0x160
+.globl psw_mch_old
+psw_mch_old:
+
+.org 0x170
+.globl psw_io_old
+psw_io_old:
+
+.org 0x1a0
+.globl psw_rst_new
+psw_rst_new:
+
+.org 0x1b0
+.globl psw_ext_new
+psw_ext_new:
+
+.org 0x1c0
+.globl psw_svc_new
+psw_svc_new:
+
+.org 0x1d0
+.globl psw_prg_new
+psw_prg_new:
+
+.org 0x1e0
+.globl psw_mch_new
+psw_mch_new:
+
+.org 0x1f0
+.globl psw_io_new
+psw_io_new:
+