sclp.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * Copyright IBM Corp. 1999,2012
  3. *
  4. * Author(s): Martin Peschke <mpeschke@de.ibm.com>
  5. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  6. */
  7. #ifndef __SCLP_H__
  8. #define __SCLP_H__
  9. #include <linux/types.h>
  10. #include <linux/list.h>
  11. #include <asm/sclp.h>
  12. #include <asm/ebcdic.h>
  13. /* maximum number of pages concerning our own memory management */
  14. #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
  15. #define SCLP_CONSOLE_PAGES 6
  16. #define SCLP_EVTYP_MASK(T) (1U << (32 - (T)))
  17. #define EVTYP_OPCMD 0x01
  18. #define EVTYP_MSG 0x02
  19. #define EVTYP_CONFMGMDATA 0x04
  20. #define EVTYP_DIAG_TEST 0x07
  21. #define EVTYP_STATECHANGE 0x08
  22. #define EVTYP_PMSGCMD 0x09
  23. #define EVTYP_ASYNC 0x0A
  24. #define EVTYP_CTLPROGIDENT 0x0B
  25. #define EVTYP_ERRNOTIFY 0x18
  26. #define EVTYP_VT220MSG 0x1A
  27. #define EVTYP_SDIAS 0x1C
  28. #define EVTYP_SIGQUIESCE 0x1D
  29. #define EVTYP_OCF 0x1E
  30. #define EVTYP_OPCMD_MASK SCLP_EVTYP_MASK(EVTYP_OPCMD)
  31. #define EVTYP_MSG_MASK SCLP_EVTYP_MASK(EVTYP_MSG)
  32. #define EVTYP_CONFMGMDATA_MASK SCLP_EVTYP_MASK(EVTYP_CONFMGMDATA)
  33. #define EVTYP_DIAG_TEST_MASK SCLP_EVTYP_MASK(EVTYP_DIAG_TEST)
  34. #define EVTYP_STATECHANGE_MASK SCLP_EVTYP_MASK(EVTYP_STATECHANGE)
  35. #define EVTYP_PMSGCMD_MASK SCLP_EVTYP_MASK(EVTYP_PMSGCMD)
  36. #define EVTYP_ASYNC_MASK SCLP_EVTYP_MASK(EVTYP_ASYNC)
  37. #define EVTYP_CTLPROGIDENT_MASK SCLP_EVTYP_MASK(EVTYP_CTLPROGIDENT)
  38. #define EVTYP_ERRNOTIFY_MASK SCLP_EVTYP_MASK(EVTYP_ERRNOTIFY)
  39. #define EVTYP_VT220MSG_MASK SCLP_EVTYP_MASK(EVTYP_VT220MSG)
  40. #define EVTYP_SDIAS_MASK SCLP_EVTYP_MASK(EVTYP_SDIAS)
  41. #define EVTYP_SIGQUIESCE_MASK SCLP_EVTYP_MASK(EVTYP_SIGQUIESCE)
  42. #define EVTYP_OCF_MASK SCLP_EVTYP_MASK(EVTYP_OCF)
  43. #define GNRLMSGFLGS_DOM 0x8000
  44. #define GNRLMSGFLGS_SNDALRM 0x4000
  45. #define GNRLMSGFLGS_HOLDMSG 0x2000
  46. #define LNTPFLGS_CNTLTEXT 0x8000
  47. #define LNTPFLGS_LABELTEXT 0x4000
  48. #define LNTPFLGS_DATATEXT 0x2000
  49. #define LNTPFLGS_ENDTEXT 0x1000
  50. #define LNTPFLGS_PROMPTTEXT 0x0800
  51. typedef unsigned int sclp_cmdw_t;
  52. #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
  53. #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
  54. #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
  55. #define GDS_ID_MDSMU 0x1310
  56. #define GDS_ID_MDSROUTEINFO 0x1311
  57. #define GDS_ID_AGUNWRKCORR 0x1549
  58. #define GDS_ID_SNACONDREPORT 0x1532
  59. #define GDS_ID_CPMSU 0x1212
  60. #define GDS_ID_ROUTTARGINSTR 0x154D
  61. #define GDS_ID_OPREQ 0x8070
  62. #define GDS_ID_TEXTCMD 0x1320
  63. #define GDS_KEY_SELFDEFTEXTMSG 0x31
  64. enum sclp_pm_event {
  65. SCLP_PM_EVENT_FREEZE,
  66. SCLP_PM_EVENT_THAW,
  67. SCLP_PM_EVENT_RESTORE,
  68. };
  69. #define SCLP_PANIC_PRIO 1
  70. #define SCLP_PANIC_PRIO_CLIENT 0
  71. typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
  72. struct sccb_header {
  73. u16 length;
  74. u8 function_code;
  75. u8 control_mask[3];
  76. u16 response_code;
  77. } __attribute__((packed));
  78. struct init_sccb {
  79. struct sccb_header header;
  80. u16 _reserved;
  81. u16 mask_length;
  82. sccb_mask_t receive_mask;
  83. sccb_mask_t send_mask;
  84. sccb_mask_t sclp_receive_mask;
  85. sccb_mask_t sclp_send_mask;
  86. } __attribute__((packed));
  87. #define SCLP_HAS_CHP_INFO (sclp.facilities & 0x8000000000000000ULL)
  88. #define SCLP_HAS_CHP_RECONFIG (sclp.facilities & 0x2000000000000000ULL)
  89. #define SCLP_HAS_CPU_INFO (sclp.facilities & 0x0800000000000000ULL)
  90. #define SCLP_HAS_CPU_RECONFIG (sclp.facilities & 0x0400000000000000ULL)
  91. #define SCLP_HAS_PCI_RECONFIG (sclp.facilities & 0x0000000040000000ULL)
  92. struct gds_subvector {
  93. u8 length;
  94. u8 key;
  95. } __attribute__((packed));
  96. struct gds_vector {
  97. u16 length;
  98. u16 gds_id;
  99. } __attribute__((packed));
  100. struct evbuf_header {
  101. u16 length;
  102. u8 type;
  103. u8 flags;
  104. u16 _reserved;
  105. } __attribute__((packed));
  106. struct sclp_req {
  107. struct list_head list; /* list_head for request queueing. */
  108. sclp_cmdw_t command; /* sclp command to execute */
  109. void *sccb; /* pointer to the sccb to execute */
  110. char status; /* status of this request */
  111. int start_count; /* number of SVCs done for this req */
  112. /* Callback that is called after reaching final status. */
  113. void (*callback)(struct sclp_req *, void *data);
  114. void *callback_data;
  115. int queue_timeout; /* request queue timeout (sec), set by
  116. caller of sclp_add_request(), if
  117. needed */
  118. /* Internal fields */
  119. unsigned long queue_expires; /* request queue timeout (jiffies) */
  120. };
  121. #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
  122. #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
  123. #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
  124. #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
  125. #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
  126. #define SCLP_REQ_QUEUED_TIMEOUT 0x06 /* request on queue timed out */
  127. #define SCLP_QUEUE_INTERVAL 5 /* timeout interval for request queue */
  128. /* function pointers that a high level driver has to use for registration */
  129. /* of some routines it wants to be called from the low level driver */
  130. struct sclp_register {
  131. struct list_head list;
  132. /* User wants to receive: */
  133. sccb_mask_t receive_mask;
  134. /* User wants to send: */
  135. sccb_mask_t send_mask;
  136. /* H/W can receive: */
  137. sccb_mask_t sclp_receive_mask;
  138. /* H/W can send: */
  139. sccb_mask_t sclp_send_mask;
  140. /* called if event type availability changes */
  141. void (*state_change_fn)(struct sclp_register *);
  142. /* called for events in cp_receive_mask/sclp_receive_mask */
  143. void (*receiver_fn)(struct evbuf_header *);
  144. /* called for power management events */
  145. void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
  146. /* pm event posted flag */
  147. int pm_event_posted;
  148. };
  149. /* externals from sclp.c */
  150. int sclp_add_request(struct sclp_req *req);
  151. void sclp_sync_wait(void);
  152. int sclp_register(struct sclp_register *reg);
  153. void sclp_unregister(struct sclp_register *reg);
  154. int sclp_remove_processed(struct sccb_header *sccb);
  155. int sclp_deactivate(void);
  156. int sclp_reactivate(void);
  157. int sclp_service_call(sclp_cmdw_t command, void *sccb);
  158. int sclp_sync_request(sclp_cmdw_t command, void *sccb);
  159. int sclp_sync_request_timeout(sclp_cmdw_t command, void *sccb, int timeout);
  160. int sclp_sdias_init(void);
  161. void sclp_sdias_exit(void);
  162. extern int sclp_console_pages;
  163. extern int sclp_console_drop;
  164. extern unsigned long sclp_console_full;
  165. /* useful inlines */
  166. /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
  167. /* translate single character from ASCII to EBCDIC */
  168. static inline unsigned char
  169. sclp_ascebc(unsigned char ch)
  170. {
  171. return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
  172. }
  173. /* translate string from EBCDIC to ASCII */
  174. static inline void
  175. sclp_ebcasc_str(unsigned char *str, int nr)
  176. {
  177. (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
  178. }
  179. /* translate string from ASCII to EBCDIC */
  180. static inline void
  181. sclp_ascebc_str(unsigned char *str, int nr)
  182. {
  183. (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
  184. }
  185. static inline struct gds_vector *
  186. sclp_find_gds_vector(void *start, void *end, u16 id)
  187. {
  188. struct gds_vector *v;
  189. for (v = start; (void *) v < end; v = (void *) v + v->length)
  190. if (v->gds_id == id)
  191. return v;
  192. return NULL;
  193. }
  194. static inline struct gds_subvector *
  195. sclp_find_gds_subvector(void *start, void *end, u8 key)
  196. {
  197. struct gds_subvector *sv;
  198. for (sv = start; (void *) sv < end; sv = (void *) sv + sv->length)
  199. if (sv->key == key)
  200. return sv;
  201. return NULL;
  202. }
  203. #endif /* __SCLP_H__ */