sclp.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright IBM Corp. 1999, 2009
  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 MAX_CONSOLE_PAGES 6
  16. #define EVTYP_OPCMD 0x01
  17. #define EVTYP_MSG 0x02
  18. #define EVTYP_STATECHANGE 0x08
  19. #define EVTYP_PMSGCMD 0x09
  20. #define EVTYP_CNTLPROGOPCMD 0x20
  21. #define EVTYP_CNTLPROGIDENT 0x0B
  22. #define EVTYP_SIGQUIESCE 0x1D
  23. #define EVTYP_VT220MSG 0x1A
  24. #define EVTYP_CONFMGMDATA 0x04
  25. #define EVTYP_SDIAS 0x1C
  26. #define EVTYP_ASYNC 0x0A
  27. #define EVTYP_OCF 0x1E
  28. #define EVTYP_OPCMD_MASK 0x80000000
  29. #define EVTYP_MSG_MASK 0x40000000
  30. #define EVTYP_STATECHANGE_MASK 0x01000000
  31. #define EVTYP_PMSGCMD_MASK 0x00800000
  32. #define EVTYP_CTLPROGOPCMD_MASK 0x00000001
  33. #define EVTYP_CTLPROGIDENT_MASK 0x00200000
  34. #define EVTYP_SIGQUIESCE_MASK 0x00000008
  35. #define EVTYP_VT220MSG_MASK 0x00000040
  36. #define EVTYP_CONFMGMDATA_MASK 0x10000000
  37. #define EVTYP_SDIAS_MASK 0x00000010
  38. #define EVTYP_ASYNC_MASK 0x00400000
  39. #define EVTYP_OCF_MASK 0x00000004
  40. #define GNRLMSGFLGS_DOM 0x8000
  41. #define GNRLMSGFLGS_SNDALRM 0x4000
  42. #define GNRLMSGFLGS_HOLDMSG 0x2000
  43. #define LNTPFLGS_CNTLTEXT 0x8000
  44. #define LNTPFLGS_LABELTEXT 0x4000
  45. #define LNTPFLGS_DATATEXT 0x2000
  46. #define LNTPFLGS_ENDTEXT 0x1000
  47. #define LNTPFLGS_PROMPTTEXT 0x0800
  48. typedef unsigned int sclp_cmdw_t;
  49. #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
  50. #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
  51. #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
  52. #define GDS_ID_MDSMU 0x1310
  53. #define GDS_ID_MDSROUTEINFO 0x1311
  54. #define GDS_ID_AGUNWRKCORR 0x1549
  55. #define GDS_ID_SNACONDREPORT 0x1532
  56. #define GDS_ID_CPMSU 0x1212
  57. #define GDS_ID_ROUTTARGINSTR 0x154D
  58. #define GDS_ID_OPREQ 0x8070
  59. #define GDS_ID_TEXTCMD 0x1320
  60. #define GDS_KEY_SELFDEFTEXTMSG 0x31
  61. enum sclp_pm_event {
  62. SCLP_PM_EVENT_FREEZE,
  63. SCLP_PM_EVENT_THAW,
  64. SCLP_PM_EVENT_RESTORE,
  65. };
  66. #define SCLP_PANIC_PRIO 1
  67. #define SCLP_PANIC_PRIO_CLIENT 0
  68. typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
  69. struct sccb_header {
  70. u16 length;
  71. u8 function_code;
  72. u8 control_mask[3];
  73. u16 response_code;
  74. } __attribute__((packed));
  75. extern u64 sclp_facilities;
  76. #define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
  77. #define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
  78. #define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL)
  79. #define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL)
  80. struct gds_subvector {
  81. u8 length;
  82. u8 key;
  83. } __attribute__((packed));
  84. struct gds_vector {
  85. u16 length;
  86. u16 gds_id;
  87. } __attribute__((packed));
  88. struct evbuf_header {
  89. u16 length;
  90. u8 type;
  91. u8 flags;
  92. u16 _reserved;
  93. } __attribute__((packed));
  94. struct sclp_req {
  95. struct list_head list; /* list_head for request queueing. */
  96. sclp_cmdw_t command; /* sclp command to execute */
  97. void *sccb; /* pointer to the sccb to execute */
  98. char status; /* status of this request */
  99. int start_count; /* number of SVCs done for this req */
  100. /* Callback that is called after reaching final status. */
  101. void (*callback)(struct sclp_req *, void *data);
  102. void *callback_data;
  103. };
  104. #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
  105. #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
  106. #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
  107. #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
  108. #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
  109. /* function pointers that a high level driver has to use for registration */
  110. /* of some routines it wants to be called from the low level driver */
  111. struct sclp_register {
  112. struct list_head list;
  113. /* User wants to receive: */
  114. sccb_mask_t receive_mask;
  115. /* User wants to send: */
  116. sccb_mask_t send_mask;
  117. /* H/W can receive: */
  118. sccb_mask_t sclp_receive_mask;
  119. /* H/W can send: */
  120. sccb_mask_t sclp_send_mask;
  121. /* called if event type availability changes */
  122. void (*state_change_fn)(struct sclp_register *);
  123. /* called for events in cp_receive_mask/sclp_receive_mask */
  124. void (*receiver_fn)(struct evbuf_header *);
  125. /* called for power management events */
  126. void (*pm_event_fn)(struct sclp_register *, enum sclp_pm_event);
  127. /* pm event posted flag */
  128. int pm_event_posted;
  129. };
  130. /* externals from sclp.c */
  131. int sclp_add_request(struct sclp_req *req);
  132. void sclp_sync_wait(void);
  133. int sclp_register(struct sclp_register *reg);
  134. void sclp_unregister(struct sclp_register *reg);
  135. int sclp_remove_processed(struct sccb_header *sccb);
  136. int sclp_deactivate(void);
  137. int sclp_reactivate(void);
  138. int sclp_service_call(sclp_cmdw_t command, void *sccb);
  139. int sclp_sdias_init(void);
  140. void sclp_sdias_exit(void);
  141. /* useful inlines */
  142. /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
  143. /* translate single character from ASCII to EBCDIC */
  144. static inline unsigned char
  145. sclp_ascebc(unsigned char ch)
  146. {
  147. return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
  148. }
  149. /* translate string from EBCDIC to ASCII */
  150. static inline void
  151. sclp_ebcasc_str(unsigned char *str, int nr)
  152. {
  153. (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
  154. }
  155. /* translate string from ASCII to EBCDIC */
  156. static inline void
  157. sclp_ascebc_str(unsigned char *str, int nr)
  158. {
  159. (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
  160. }
  161. static inline struct gds_vector *
  162. sclp_find_gds_vector(void *start, void *end, u16 id)
  163. {
  164. struct gds_vector *v;
  165. for (v = start; (void *) v < end; v = (void *) v + v->length)
  166. if (v->gds_id == id)
  167. return v;
  168. return NULL;
  169. }
  170. static inline struct gds_subvector *
  171. sclp_find_gds_subvector(void *start, void *end, u8 key)
  172. {
  173. struct gds_subvector *sv;
  174. for (sv = start; (void *) sv < end; sv = (void *) sv + sv->length)
  175. if (sv->key == key)
  176. return sv;
  177. return NULL;
  178. }
  179. #endif /* __SCLP_H__ */