include: move lpswe() to the top-level include
[hvf.git] / nss / login / main.c
blob7cc0a7e3bc25936e8498eeae1483e541a78f93c8
1 /*
2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #include <arch.h>
9 #include <string.h>
10 #include <int.h>
11 #include <misc.h>
14 * This guest OS has a very simple purpose. It is responsible for
15 * displaying the login splash, prompting the user for a username and
16 * password, and then querying CP to verify that the password is correct.
17 * If correct, CP will detach the rdev from this guest, and attach it to the
18 * user's guest.
20 * +------------------------------------------------+
21 * | +------------------------------------+ |
22 * | | virt_sys | |
23 * | | +--------+ +-------+ +---------+ | +----+|
24 * | | |virt_cpu| |storage| |virt_cons|<--+-->|rdev||
25 * | | +--------+ +-------+ +---------+ | +----+|
26 * | | /\ | |
27 * | | || | |
28 * | | \/ | |
29 * | | +--------+ +--------+ +--------+ | |
30 * | | |virt_dev| |virt_dev| |virt_dev| | |
31 * | | +--------+ +--------+ +--------+ | |
32 * | +------------------------------------+ |
33 * | |
34 * | +------------------------------------+ |
35 * | | virt_sys | |
36 * | | +--------+ +-------+ +---------+ | +----+|
37 * | | |virt_cpu| |storage| |virt_cons|<--+-->|rdev||
38 * | | +--------+ +-------+ +---------+ | +----+|
39 * | | /\ | |
40 * | | || | |
41 * | | \/ | |
42 * | | +--------+ +--------+ +--------+ | |
43 * | | |virt_dev| |virt_dev| |virt_dev| | |
44 * | | +--------+ +--------+ +--------+ | |
45 * | +------------------------------------+ |
46 * | |
47 * | : |
48 * | : |
49 * | : |
50 * | |
51 * | +------------------------------------+ |
52 * | | virt_sys (*LOGIN) | |
53 * | | +--------+ +-------+ +---------+ | |
54 * | | |virt_cpu| |storage| |virt_cons| | |
55 * | | +--------+ +-------+ +---------+ | |
56 * | | +--------+ | +----+|
57 * | | |virt_dev|<--+-->|rdev||
58 * | | +--------+ | +----+|
59 * | | +--------+ | +----+|
60 * | | |virt_dev|<--+-->|rdev||
61 * | | +--------+ | +----+|
62 * | | +--------+ | +----+|
63 * | | |virt_dev|<--+-->|rdev||
64 * | | +--------+ | +----+|
65 * | +------------------------------------+ |
66 * +------------------------------------------------+
69 * In other words, here are the actions that CP takes:
71 * host IPL:
72 * - ipl *LOGIN
73 * - attach operator console to *LOGIN
75 * login:
76 * - alloc virt sys, virt cpu, virt devices, virt cons, storage
77 * - detach console rdev from *LOGIN
78 * - attach console rdev to virt cons
80 * logout/force:
81 * - free virt sys, virt cpu, virt devices, virt cons, storage
82 * - attach console rdev to *LOGIN
84 * disconnect:
85 * - detach console rdev from virt cons
86 * - attach console rdev to *LOGIN
88 * reconnect:
89 * - detach console rdev from *LOGIN
90 * - attach console rdev to virt cons
93 struct psw disabled_wait = { .w = 1, .ea = 1, .ba = 1, .ptr = 0xfafafa, };
94 struct psw enabled_wait = { .io = 1, .m = 1, .w = 1, .ea = 1, .ba = 1, };
96 static struct psw __new_rst = { .ea = 1, .ba = 1, .ptr = ADDR64(&rst_int), };
97 static struct psw __new_ext = { .ea = 1, .ba = 1, .ptr = ADDR64(&ext_int), };
98 static struct psw __new_svc = { .ea = 1, .ba = 1, .ptr = ADDR64(&svc_int), };
99 static struct psw __new_prg = { .ea = 1, .ba = 1, .ptr = ADDR64(&prg_int), };
100 static struct psw __new_mch = { .ea = 1, .ba = 1, .ptr = ADDR64(&mch_int), };
101 static struct psw __new_io = { .ea = 1, .ba = 1, .ptr = ADDR64(&io_int), };
103 static void init_io(void)
105 u64 cr6;
107 cr6 = get_cr(6);
109 /* enable all I/O interrupt classes */
110 cr6 |= BIT64(32);
111 cr6 |= BIT64(33);
112 cr6 |= BIT64(34);
113 cr6 |= BIT64(35);
114 cr6 |= BIT64(36);
115 cr6 |= BIT64(37);
116 cr6 |= BIT64(38);
117 cr6 |= BIT64(39);
119 set_cr(6, cr6);
122 void start()
124 /* set up interrupt PSWs */
125 memcpy(&psw_rst_new, &__new_rst, sizeof(struct psw));
126 memcpy(&psw_ext_new, &__new_ext, sizeof(struct psw));
127 memcpy(&psw_svc_new, &__new_svc, sizeof(struct psw));
128 memcpy(&psw_prg_new, &__new_prg, sizeof(struct psw));
129 memcpy(&psw_mch_new, &__new_mch, sizeof(struct psw));
130 memcpy(&psw_io_new, &__new_io, sizeof(struct psw));
132 /* enable all 8 I/O classes */
133 init_io();
135 /* enable Channel-Report-Pending Machine Check Interruption subclass */
136 set_cr(14, get_cr(14) | BIT64(35));
138 /* this enables I/O & MCH interrupts */
139 lpswe(&enabled_wait);
141 die();