target/arm: Tidy scr_write
[qemu/ar7.git] / hw / s390x / s390-virtio-hcall.c
blobec7cf8beb3f7b072bc5e8f984a341dad1eb79609
1 /*
2 * Support for virtio hypercalls on s390
4 * Copyright 2012 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
7 * This work is licensed under the terms of the GNU GPL, version 2 or (at
8 * your option) any later version. See the COPYING file in the top-level
9 * directory.
12 #include "qemu/osdep.h"
13 #include "cpu.h"
14 #include "hw/s390x/s390-virtio-hcall.h"
16 #define MAX_DIAG_SUBCODES 255
18 static s390_virtio_fn s390_diag500_table[MAX_DIAG_SUBCODES];
20 void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn)
22 assert(code < MAX_DIAG_SUBCODES);
23 assert(!s390_diag500_table[code]);
25 s390_diag500_table[code] = fn;
28 int s390_virtio_hypercall(CPUS390XState *env)
30 s390_virtio_fn fn;
32 if (env->regs[1] < MAX_DIAG_SUBCODES) {
33 fn = s390_diag500_table[env->regs[1]];
34 if (fn) {
35 env->regs[2] = fn(&env->regs[2]);
36 return 0;
40 return -EINVAL;