^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright IBM Corp. 1999,2012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Author(s): Martin Peschke <mpeschke@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Martin Schwidefsky <schwidefsky@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef __SCLP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define __SCLP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/sclp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/ebcdic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* maximum number of pages concerning our own memory management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define SCLP_CONSOLE_PAGES 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SCLP_EVTYP_MASK(T) (1UL << (sizeof(sccb_mask_t) * BITS_PER_BYTE - (T)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define EVTYP_OPCMD 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define EVTYP_MSG 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define EVTYP_CONFMGMDATA 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define EVTYP_DIAG_TEST 0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define EVTYP_STATECHANGE 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define EVTYP_PMSGCMD 0x09
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define EVTYP_ASYNC 0x0A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define EVTYP_CTLPROGIDENT 0x0B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define EVTYP_STORE_DATA 0x0C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define EVTYP_ERRNOTIFY 0x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define EVTYP_VT220MSG 0x1A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define EVTYP_SDIAS 0x1C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define EVTYP_SIGQUIESCE 0x1D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define EVTYP_OCF 0x1E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define EVTYP_OPCMD_MASK SCLP_EVTYP_MASK(EVTYP_OPCMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define EVTYP_MSG_MASK SCLP_EVTYP_MASK(EVTYP_MSG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define EVTYP_CONFMGMDATA_MASK SCLP_EVTYP_MASK(EVTYP_CONFMGMDATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define EVTYP_DIAG_TEST_MASK SCLP_EVTYP_MASK(EVTYP_DIAG_TEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define EVTYP_STATECHANGE_MASK SCLP_EVTYP_MASK(EVTYP_STATECHANGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define EVTYP_PMSGCMD_MASK SCLP_EVTYP_MASK(EVTYP_PMSGCMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define EVTYP_ASYNC_MASK SCLP_EVTYP_MASK(EVTYP_ASYNC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define EVTYP_CTLPROGIDENT_MASK SCLP_EVTYP_MASK(EVTYP_CTLPROGIDENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define EVTYP_STORE_DATA_MASK SCLP_EVTYP_MASK(EVTYP_STORE_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define EVTYP_ERRNOTIFY_MASK SCLP_EVTYP_MASK(EVTYP_ERRNOTIFY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define EVTYP_VT220MSG_MASK SCLP_EVTYP_MASK(EVTYP_VT220MSG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define EVTYP_SDIAS_MASK SCLP_EVTYP_MASK(EVTYP_SDIAS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define EVTYP_SIGQUIESCE_MASK SCLP_EVTYP_MASK(EVTYP_SIGQUIESCE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define EVTYP_OCF_MASK SCLP_EVTYP_MASK(EVTYP_OCF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define GNRLMSGFLGS_DOM 0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define GNRLMSGFLGS_SNDALRM 0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define GNRLMSGFLGS_HOLDMSG 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define LNTPFLGS_CNTLTEXT 0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define LNTPFLGS_LABELTEXT 0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define LNTPFLGS_DATATEXT 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define LNTPFLGS_ENDTEXT 0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define LNTPFLGS_PROMPTTEXT 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) typedef unsigned int sclp_cmdw_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define SCLP_CMDW_READ_CPU_INFO 0x00010001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define SCLP_CMDW_READ_SCP_INFO 0x00020001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define SCLP_CMDW_READ_STORAGE_INFO 0x00040001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define GDS_ID_MDSMU 0x1310
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define GDS_ID_MDSROUTEINFO 0x1311
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define GDS_ID_AGUNWRKCORR 0x1549
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define GDS_ID_SNACONDREPORT 0x1532
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define GDS_ID_CPMSU 0x1212
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define GDS_ID_ROUTTARGINSTR 0x154D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define GDS_ID_OPREQ 0x8070
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define GDS_ID_TEXTCMD 0x1320
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define GDS_KEY_SELFDEFTEXTMSG 0x31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) enum sclp_pm_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) SCLP_PM_EVENT_FREEZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) SCLP_PM_EVENT_THAW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) SCLP_PM_EVENT_RESTORE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define SCLP_PANIC_PRIO 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define SCLP_PANIC_PRIO_CLIENT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) typedef u64 sccb_mask_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct sccb_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u8 function_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) u8 control_mask[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u16 response_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct init_sccb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct sccb_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u16 _reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u16 mask_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u8 masks[4 * 1021]; /* variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * u8 receive_mask[mask_length];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * u8 send_mask[mask_length];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * u8 sclp_receive_mask[mask_length];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * u8 sclp_send_mask[mask_length];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define SCLP_MASK_SIZE_COMPAT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static inline sccb_mask_t sccb_get_mask(u8 *masks, size_t len, int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) sccb_mask_t res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) memcpy(&res, masks + i * len, min(sizeof(res), len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static inline void sccb_set_mask(u8 *masks, size_t len, int i, sccb_mask_t val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) memset(masks + i * len, 0, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) memcpy(masks + i * len, &val, min(sizeof(val), len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define sccb_get_generic_mask(sccb, i) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) __typeof__(sccb) __sccb = sccb; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) sccb_get_mask(__sccb->masks, __sccb->mask_length, i); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define sccb_get_recv_mask(sccb) sccb_get_generic_mask(sccb, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define sccb_get_send_mask(sccb) sccb_get_generic_mask(sccb, 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define sccb_get_sclp_recv_mask(sccb) sccb_get_generic_mask(sccb, 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define sccb_get_sclp_send_mask(sccb) sccb_get_generic_mask(sccb, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define sccb_set_generic_mask(sccb, i, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __typeof__(sccb) __sccb = sccb; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) sccb_set_mask(__sccb->masks, __sccb->mask_length, i, val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define sccb_set_recv_mask(sccb, val) sccb_set_generic_mask(sccb, 0, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define sccb_set_send_mask(sccb, val) sccb_set_generic_mask(sccb, 1, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define sccb_set_sclp_recv_mask(sccb, val) sccb_set_generic_mask(sccb, 2, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define sccb_set_sclp_send_mask(sccb, val) sccb_set_generic_mask(sccb, 3, val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct read_cpu_info_sccb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct sccb_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u16 nr_configured;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u16 offset_configured;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) u16 nr_standby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u16 offset_standby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) u8 reserved[4096 - 16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) } __attribute__((packed, aligned(PAGE_SIZE)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct read_info_sccb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct sccb_header header; /* 0-7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) u16 rnmax; /* 8-9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) u8 rnsize; /* 10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) u8 _pad_11[16 - 11]; /* 11-15 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) u16 ncpurl; /* 16-17 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) u16 cpuoff; /* 18-19 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u8 _pad_20[24 - 20]; /* 20-23 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) u8 loadparm[8]; /* 24-31 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) u8 _pad_32[42 - 32]; /* 32-41 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) u8 fac42; /* 42 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) u8 fac43; /* 43 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) u8 _pad_44[48 - 44]; /* 44-47 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) u64 facilities; /* 48-55 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) u8 _pad_56[66 - 56]; /* 56-65 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) u8 fac66; /* 66 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) u8 _pad_67[76 - 67]; /* 67-83 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) u32 ibc; /* 76-79 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) u8 _pad80[84 - 80]; /* 80-83 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) u8 fac84; /* 84 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) u8 fac85; /* 85 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) u8 _pad_86[91 - 86]; /* 86-90 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u8 fac91; /* 91 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u8 _pad_92[98 - 92]; /* 92-97 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) u8 fac98; /* 98 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) u8 hamaxpow; /* 99 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u32 rnsize2; /* 100-103 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u64 rnmax2; /* 104-111 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u32 hsa_size; /* 112-115 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) u8 fac116; /* 116 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u8 fac117; /* 117 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) u8 fac118; /* 118 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) u8 fac119; /* 119 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u16 hcpua; /* 120-121 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) u8 _pad_122[124 - 122]; /* 122-123 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u32 hmfai; /* 124-127 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u8 _pad_128[134 - 128]; /* 128-133 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) u8 byte_134; /* 134 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u8 cpudirq; /* 135 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u16 cbl; /* 136-137 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) u8 _pad_138[4096 - 138]; /* 138-4095 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) } __packed __aligned(PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct read_storage_sccb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct sccb_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) u16 max_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) u16 assigned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) u16 standby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) u16 :16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) u32 entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static inline void sclp_fill_core_info(struct sclp_core_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct read_cpu_info_sccb *sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) char *page = (char *) sccb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) memset(info, 0, sizeof(*info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) info->configured = sccb->nr_configured;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) info->standby = sccb->nr_standby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) info->combined = sccb->nr_configured + sccb->nr_standby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) memcpy(&info->core, page + sccb->offset_configured,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) info->combined * sizeof(struct sclp_core_entry));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define SCLP_HAS_CHP_INFO (sclp.facilities & 0x8000000000000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #define SCLP_HAS_CHP_RECONFIG (sclp.facilities & 0x2000000000000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define SCLP_HAS_CPU_INFO (sclp.facilities & 0x0800000000000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #define SCLP_HAS_CPU_RECONFIG (sclp.facilities & 0x0400000000000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define SCLP_HAS_PCI_RECONFIG (sclp.facilities & 0x0000000040000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #define SCLP_HAS_AP_RECONFIG (sclp.facilities & 0x0000000100000000ULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct gds_subvector {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) u8 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) u8 key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) struct gds_vector {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) u16 gds_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct evbuf_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) u16 _reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct sclp_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct list_head list; /* list_head for request queueing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) sclp_cmdw_t command; /* sclp command to execute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) void *sccb; /* pointer to the sccb to execute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) char status; /* status of this request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int start_count; /* number of SVCs done for this req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /* Callback that is called after reaching final status. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) void (*callback)(struct sclp_req *, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void *callback_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int queue_timeout; /* request queue timeout (sec), set by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) caller of sclp_add_request(), if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* Internal fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) unsigned long queue_expires; /* request queue timeout (jiffies) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #define SCLP_REQ_QUEUED_TIMEOUT 0x06 /* request on queue timed out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #define SCLP_QUEUE_INTERVAL 5 /* timeout interval for request queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /* function pointers that a high level driver has to use for registration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /* of some routines it wants to be called from the low level driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct sclp_register {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* User wants to receive: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) sccb_mask_t receive_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /* User wants to send: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) sccb_mask_t send_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /* H/W can receive: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) sccb_mask_t sclp_receive_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /* H/W can send: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) sccb_mask_t sclp_send_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /* called if event type availability changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) void (*state_change_fn)(struct sclp_register *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /* called for events in cp_receive_mask/sclp_receive_mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) void (*receiver_fn)(struct evbuf_header *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* called for power management events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) /* pm event posted flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int pm_event_posted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* externals from sclp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) int sclp_add_request(struct sclp_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) void sclp_sync_wait(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int sclp_register(struct sclp_register *reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void sclp_unregister(struct sclp_register *reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int sclp_remove_processed(struct sccb_header *sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) int sclp_deactivate(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int sclp_reactivate(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) int sclp_sync_request(sclp_cmdw_t command, void *sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) int sclp_sync_request_timeout(sclp_cmdw_t command, void *sccb, int timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int sclp_sdias_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) sclp_init_state_uninitialized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) sclp_init_state_initializing,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) sclp_init_state_initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) extern int sclp_init_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) extern int sclp_console_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) extern int sclp_console_drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) extern unsigned long sclp_console_full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) extern bool sclp_mask_compat_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) extern char *sclp_early_sccb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) void sclp_early_wait_irq(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int sclp_early_cmd(sclp_cmdw_t cmd, void *sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) unsigned int sclp_early_con_check_linemode(struct init_sccb *sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) unsigned int sclp_early_con_check_vt220(struct init_sccb *sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) int sclp_early_set_event_mask(struct init_sccb *sccb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) sccb_mask_t receive_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) sccb_mask_t send_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) int sclp_early_get_info(struct read_info_sccb *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /* useful inlines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /* Perform service call. Return 0 on success, non-zero otherwise. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static inline int sclp_service_call(sclp_cmdw_t command, void *sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) int cc = 4; /* Initialize for program check handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) asm volatile(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) "0: .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) "1: ipm %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) " srl %0,28\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) "2:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) EX_TABLE(0b, 2b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) EX_TABLE(1b, 2b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) : "+&d" (cc) : "d" (command), "a" ((unsigned long)sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) : "cc", "memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (cc == 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (cc == 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (cc == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) /* translate single character from ASCII to EBCDIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static inline unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) sclp_ascebc(unsigned char ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /* translate string from EBCDIC to ASCII */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) sclp_ebcasc_str(char *str, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /* translate string from ASCII to EBCDIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) sclp_ascebc_str(char *str, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static inline struct gds_vector *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) sclp_find_gds_vector(void *start, void *end, u16 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct gds_vector *v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) for (v = start; (void *) v < end; v = (void *) v + v->length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) if (v->gds_id == id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) static inline struct gds_subvector *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) sclp_find_gds_subvector(void *start, void *end, u8 key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) struct gds_subvector *sv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) for (sv = start; (void *) sv < end; sv = (void *) sv + sv->length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) if (sv->key == key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return sv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) #endif /* __SCLP_H__ */