root / hw / spapr_hcall.c @ 9fdf0c29
History | View | Annotate | Download (981 Bytes)
1 |
#include "sysemu.h" |
---|---|
2 |
#include "cpu.h" |
3 |
#include "qemu-char.h" |
4 |
#include "hw/spapr.h" |
5 |
|
6 |
spapr_hcall_fn hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; |
7 |
|
8 |
void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn)
|
9 |
{ |
10 |
spapr_hcall_fn old_fn; |
11 |
|
12 |
assert(opcode <= MAX_HCALL_OPCODE); |
13 |
assert((opcode & 0x3) == 0); |
14 |
|
15 |
old_fn = hypercall_table[opcode / 4];
|
16 |
|
17 |
assert(!old_fn || (fn == old_fn)); |
18 |
|
19 |
hypercall_table[opcode / 4] = fn;
|
20 |
} |
21 |
|
22 |
target_ulong spapr_hypercall(CPUState *env, target_ulong opcode, |
23 |
target_ulong *args) |
24 |
{ |
25 |
if (msr_pr) {
|
26 |
hcall_dprintf("Hypercall made with MSR[PR]=1\n");
|
27 |
return H_PRIVILEGE;
|
28 |
} |
29 |
|
30 |
if ((opcode <= MAX_HCALL_OPCODE)
|
31 |
&& ((opcode & 0x3) == 0)) { |
32 |
spapr_hcall_fn fn = hypercall_table[opcode / 4];
|
33 |
|
34 |
if (fn) {
|
35 |
return fn(env, spapr, opcode, args);
|
36 |
} |
37 |
} |
38 |
|
39 |
hcall_dprintf("Unimplemented hcall 0x" TARGET_FMT_lx "\n", opcode); |
40 |
return H_FUNCTION;
|
41 |
} |