]> git.ipfire.org Git - thirdparty/qemu.git/blame - hw/s390x/sclp.h
s390: sclp base support
[thirdparty/qemu.git] / hw / s390x / sclp.h
CommitLineData
f6c98f92
HG
1/*
2 * SCLP Support
3 *
4 * Copyright IBM, Corp. 2012
5 *
6 * Authors:
7 * Christian Borntraeger <borntraeger@de.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or (at your
10 * option) any later version. See the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef HW_S390_SCLP_H
15#define HW_S390_SCLP_H
16
17#include <hw/sysbus.h>
18#include <hw/qdev.h>
19
20/* SCLP command codes */
21#define SCLP_CMDW_READ_SCP_INFO 0x00020001
22#define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001
23
24/* SCLP response codes */
25#define SCLP_RC_NORMAL_READ_COMPLETION 0x0010
26#define SCLP_RC_INVALID_SCLP_COMMAND 0x01f0
27
28/* Service Call Control Block (SCCB) and its elements */
29
30#define SCCB_SIZE 4096
31
32/*
33 * Normally packed structures are not the right thing to do, since all code
34 * must take care of endianess. We cant use ldl_phys and friends for two
35 * reasons, though:
36 * - some of the embedded structures below the SCCB can appear multiple times
37 * at different locations, so there is no fixed offset
38 * - we work on a private copy of the SCCB, since there are several length
39 * fields, that would cause a security nightmare if we allow the guest to
40 * alter the structure while we parse it. We cannot use ldl_p and friends
41 * either without doing pointer arithmetics
42 * So we have to double check that all users of sclp data structures use the
43 * right endianess wrappers.
44 */
45typedef struct SCCBHeader {
46 uint16_t length;
47 uint8_t function_code;
48 uint8_t control_mask[3];
49 uint16_t response_code;
50} QEMU_PACKED SCCBHeader;
51
52#define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
53
54typedef struct ReadInfo {
55 SCCBHeader h;
56 uint16_t rnmax;
57 uint8_t rnsize;
58} QEMU_PACKED ReadInfo;
59
60typedef struct SCCB {
61 SCCBHeader h;
62 char data[SCCB_DATA_LEN];
63 } QEMU_PACKED SCCB;
64
65typedef struct S390SCLPDevice {
66 SysBusDevice busdev;
67} S390SCLPDevice;
68
69typedef struct S390SCLPDeviceClass {
70 DeviceClass qdev;
71 int (*init)(S390SCLPDevice *sdev);
72} S390SCLPDeviceClass;
73
74void sclp_service_interrupt(uint32_t sccb);
75
76#endif