loader: remove shouting from ORB's variable name
[hvf.git] / cp / guest / intercept.c
blob10f75d5403d71dcc3ccf84ae82eddc2ca8efcd1c
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 <dat.h>
11 #include <shell.h>
13 static int handle_noop(struct virt_sys *sys)
15 return 0;
18 static int handle_program(struct virt_sys *sys)
20 con_printf(sys->con, "INTRCPT: PROG\n");
21 sys->cpu->state = GUEST_STOPPED;
22 return 0;
25 static int handle_instruction_and_program(struct virt_sys *sys)
27 con_printf(sys->con, "INTRCPT: INST+PROG\n");
28 sys->cpu->state = GUEST_STOPPED;
29 return 0;
32 static int handle_ext_req(struct virt_sys *sys)
34 con_printf(sys->con, "INTRCPT: EXT REQ\n");
35 sys->cpu->state = GUEST_STOPPED;
36 return 0;
39 static int handle_ext_int(struct virt_sys *sys)
41 con_printf(sys->con, "INTRCPT: EXT INT\n");
42 sys->cpu->state = GUEST_STOPPED;
43 return 0;
46 static int handle_io_req(struct virt_sys *sys)
48 con_printf(sys->con, "INTRCPT: IO REQ\n");
49 sys->cpu->state = GUEST_STOPPED;
50 return 0;
53 static int handle_wait(struct virt_sys *sys)
55 con_printf(sys->con, "INTRCPT: WAIT\n");
56 return 0;
59 static int handle_validity(struct virt_sys *sys)
61 con_printf(sys->con, "INTRCPT: VALIDITY\n");
62 sys->cpu->state = GUEST_STOPPED;
63 return 0;
66 static int handle_stop(struct virt_sys *sys)
68 atomic_clear_mask(CPUSTAT_STOP_INT, &sys->cpu->sie_cb.cpuflags);
69 return 0;
72 static int handle_oper_except(struct virt_sys *sys)
74 con_printf(sys->con, "INTRCPT: OPER EXCEPT\n");
75 sys->cpu->state = GUEST_STOPPED;
76 return 0;
79 static int handle_exp_run(struct virt_sys *sys)
81 con_printf(sys->con, "INTRCPT: EXP RUN\n");
82 sys->cpu->state = GUEST_STOPPED;
83 return 0;
86 static int handle_exp_timer(struct virt_sys *sys)
88 con_printf(sys->con, "INTRCPT: EXP TIMER\n");
89 sys->cpu->state = GUEST_STOPPED;
90 return 0;
93 static const intercept_handler_t intercept_funcs[0x4c >> 2] = {
94 [0x00 >> 2] = handle_noop,
95 [0x04 >> 2] = handle_instruction,
96 [0x08 >> 2] = handle_program,
97 [0x0c >> 2] = handle_instruction_and_program,
98 [0x10 >> 2] = handle_ext_req,
99 [0x14 >> 2] = handle_ext_int,
100 [0x18 >> 2] = handle_io_req,
101 [0x1c >> 2] = handle_wait,
102 [0x20 >> 2] = handle_validity,
103 [0x28 >> 2] = handle_stop,
104 [0x2c >> 2] = handle_oper_except,
105 [0x44 >> 2] = handle_exp_run,
106 [0x48 >> 2] = handle_exp_timer,
109 void handle_interception(struct virt_sys *sys)
111 struct virt_cpu *cpu = sys->cpu;
112 intercept_handler_t h;
113 int err = -EINVAL;
115 h = intercept_funcs[cpu->sie_cb.icptcode >> 2];
116 if (h)
117 err = h(sys);
119 if (err) {
120 cpu->state = GUEST_STOPPED;
121 con_printf(sys->con, "Unknown/mis-handled intercept code %02x, err = %d\n",
122 cpu->sie_cb.icptcode, err);