]> git.proxmox.com Git - qemu.git/blame - hw/s390x/s390-virtio-hcall.c
s390: Move hw files to hw/s390x
[qemu.git] / hw / s390x / s390-virtio-hcall.c
CommitLineData
28e942f8
CH
1/*
2 * Support for virtio hypercalls on s390
3 *
4 * Copyright 2012 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 *
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.
10 */
11
12#include "cpu.h"
b73d3531 13#include "hw/s390x/s390-virtio.h"
28e942f8
CH
14
15#define MAX_DIAG_SUBCODES 255
16
17static s390_virtio_fn s390_diag500_table[MAX_DIAG_SUBCODES];
18
19void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn)
20{
21 assert(code < MAX_DIAG_SUBCODES);
22 assert(!s390_diag500_table[code]);
23
24 s390_diag500_table[code] = fn;
25}
26
27int s390_virtio_hypercall(CPUS390XState *env)
28{
29 s390_virtio_fn fn = s390_diag500_table[env->regs[1]];
30
31 if (!fn) {
32 return -EINVAL;
33 }
34
35 return fn(&env->regs[2]);
36}