loader: remove shouting from ORB's variable name
[hvf.git] / cp / shell / init.c
blobc7fd3d835dc098074779d3f42bc5f92860f2cdf0
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 <directory.h>
9 #include <sched.h>
10 #include <errno.h>
11 #include <page.h>
12 #include <buddy.h>
13 #include <slab.h>
14 #include <dat.h>
15 #include <clock.h>
16 #include <ebcdic.h>
17 #include <cpu.h>
18 #include <vcpu.h>
19 #include <vdevice.h>
20 #include <mutex.h>
21 #include <vsprintf.h>
22 #include <shell.h>
24 /* This is used to con_printf to the operator about various async events -
25 * e.g., user logon
27 struct console *oper_con;
29 static void process_cmd(struct virt_sys *sys)
31 u8 cmd[128];
32 int ret;
34 // FIXME: read a line from the console
35 // ret = con_read(sys->con, cmd, 128);
36 ret = -1;
38 if (ret == -1)
39 return; /* no lines to read */
41 if (!ret) {
42 con_printf(sys->con, "CP\n");
43 return; /* empty line */
46 ebcdic2ascii(cmd, ret);
49 * we got a command to process!
51 ret = invoke_shell_cmd(sys, (char*) cmd, ret);
52 switch (ret) {
53 case 0:
54 /* all fine */
55 break;
56 case -ENOENT:
57 con_printf(sys->con, "Invalid CP command: %s\n", cmd);
58 break;
59 case -ESUBENOENT:
60 con_printf(sys->con, "Invalid CP sub-command: %s\n", cmd);
61 break;
62 case -EINVAL:
63 con_printf(sys->con, "Operand missing or invalid\n");
64 break;
65 case -EPERM:
66 con_printf(sys->con, "Not authorized\n");
67 break;
68 default:
69 con_printf(sys->con, "RC=%d (%s)\n", ret,
70 errstrings[ret]);
71 break;
75 int shell_start(void *data)
77 struct virt_sys *sys = data;
78 struct virt_cpu *cpu = sys->cpu;
79 struct datetime dt;
82 * load guest's address space into the host's PASCE
84 load_as(&sys->as);
86 get_parsed_tod(&dt);
87 con_printf(sys->con, "LOGON FOR %s AT %02d:%02d:%02d UTC %04d-%02d-%02d\n",
88 sys->directory->userid, dt.th, dt.tm, dt.ts, dt.dy, dt.dm, dt.dd);
90 for (;;) {
92 * - process any console input
93 * - if the guest is running
94 * - issue any pending interruptions
95 * - continue executing it
96 * - process any intercepts from SIE
97 * - else, schedule()
100 process_cmd(sys);
102 if (cpu->state == GUEST_OPERATING)
103 run_guest(sys);
104 else
105 schedule();
108 return 0;