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