128e942f8SCornelia Huck /* 228e942f8SCornelia Huck * Support for virtio hypercalls on s390 328e942f8SCornelia Huck * 428e942f8SCornelia Huck * Copyright 2012 IBM Corp. 528e942f8SCornelia Huck * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 628e942f8SCornelia Huck * 728e942f8SCornelia Huck * This work is licensed under the terms of the GNU GPL, version 2 or (at 828e942f8SCornelia Huck * your option) any later version. See the COPYING file in the top-level 928e942f8SCornelia Huck * directory. 1028e942f8SCornelia Huck */ 1128e942f8SCornelia Huck 1228e942f8SCornelia Huck #include "cpu.h" 13*b73d3531SAlexander Graf #include "hw/s390x/s390-virtio.h" 1428e942f8SCornelia Huck 1528e942f8SCornelia Huck #define MAX_DIAG_SUBCODES 255 1628e942f8SCornelia Huck 1728e942f8SCornelia Huck static s390_virtio_fn s390_diag500_table[MAX_DIAG_SUBCODES]; 1828e942f8SCornelia Huck 1928e942f8SCornelia Huck void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn) 2028e942f8SCornelia Huck { 2128e942f8SCornelia Huck assert(code < MAX_DIAG_SUBCODES); 2228e942f8SCornelia Huck assert(!s390_diag500_table[code]); 2328e942f8SCornelia Huck 2428e942f8SCornelia Huck s390_diag500_table[code] = fn; 2528e942f8SCornelia Huck } 2628e942f8SCornelia Huck 2728e942f8SCornelia Huck int s390_virtio_hypercall(CPUS390XState *env) 2828e942f8SCornelia Huck { 2928e942f8SCornelia Huck s390_virtio_fn fn = s390_diag500_table[env->regs[1]]; 3028e942f8SCornelia Huck 3128e942f8SCornelia Huck if (!fn) { 3228e942f8SCornelia Huck return -EINVAL; 3328e942f8SCornelia Huck } 3428e942f8SCornelia Huck 3528e942f8SCornelia Huck return fn(&env->regs[2]); 3628e942f8SCornelia Huck } 37