sclp.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * drivers/s390/char/sclp.h
  3. *
  4. * S390 version
  5. * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Martin Peschke <mpeschke@de.ibm.com>
  7. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  8. */
  9. #ifndef __SCLP_H__
  10. #define __SCLP_H__
  11. #include <linux/types.h>
  12. #include <linux/list.h>
  13. #include <asm/sclp.h>
  14. #include <asm/ebcdic.h>
  15. /* maximum number of pages concerning our own memory management */
  16. #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
  17. #define MAX_CONSOLE_PAGES 4
  18. #define EVTYP_OPCMD 0x01
  19. #define EVTYP_MSG 0x02
  20. #define EVTYP_STATECHANGE 0x08
  21. #define EVTYP_PMSGCMD 0x09
  22. #define EVTYP_CNTLPROGOPCMD 0x20
  23. #define EVTYP_CNTLPROGIDENT 0x0B
  24. #define EVTYP_SIGQUIESCE 0x1D
  25. #define EVTYP_VT220MSG 0x1A
  26. #define EVTYP_CONFMGMDATA 0x04
  27. #define EVTYP_SDIAS 0x1C
  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 GNRLMSGFLGS_DOM 0x8000
  39. #define GNRLMSGFLGS_SNDALRM 0x4000
  40. #define GNRLMSGFLGS_HOLDMSG 0x2000
  41. #define LNTPFLGS_CNTLTEXT 0x8000
  42. #define LNTPFLGS_LABELTEXT 0x4000
  43. #define LNTPFLGS_DATATEXT 0x2000
  44. #define LNTPFLGS_ENDTEXT 0x1000
  45. #define LNTPFLGS_PROMPTTEXT 0x0800
  46. typedef unsigned int sclp_cmdw_t;
  47. #define SCLP_CMDW_READ_EVENT_DATA 0x00770005
  48. #define SCLP_CMDW_WRITE_EVENT_DATA 0x00760005
  49. #define SCLP_CMDW_WRITE_EVENT_MASK 0x00780005
  50. #define GDS_ID_MDSMU 0x1310
  51. #define GDS_ID_MDSROUTEINFO 0x1311
  52. #define GDS_ID_AGUNWRKCORR 0x1549
  53. #define GDS_ID_SNACONDREPORT 0x1532
  54. #define GDS_ID_CPMSU 0x1212
  55. #define GDS_ID_ROUTTARGINSTR 0x154D
  56. #define GDS_ID_OPREQ 0x8070
  57. #define GDS_ID_TEXTCMD 0x1320
  58. #define GDS_KEY_SELFDEFTEXTMSG 0x31
  59. typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
  60. struct sccb_header {
  61. u16 length;
  62. u8 function_code;
  63. u8 control_mask[3];
  64. u16 response_code;
  65. } __attribute__((packed));
  66. extern u64 sclp_facilities;
  67. #define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
  68. #define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
  69. #define SCLP_HAS_CPU_INFO (sclp_facilities & 0x0800000000000000ULL)
  70. #define SCLP_HAS_CPU_RECONFIG (sclp_facilities & 0x0400000000000000ULL)
  71. struct gds_subvector {
  72. u8 length;
  73. u8 key;
  74. } __attribute__((packed));
  75. struct gds_vector {
  76. u16 length;
  77. u16 gds_id;
  78. } __attribute__((packed));
  79. struct evbuf_header {
  80. u16 length;
  81. u8 type;
  82. u8 flags;
  83. u16 _reserved;
  84. } __attribute__((packed));
  85. struct sclp_req {
  86. struct list_head list; /* list_head for request queueing. */
  87. sclp_cmdw_t command; /* sclp command to execute */
  88. void *sccb; /* pointer to the sccb to execute */
  89. char status; /* status of this request */
  90. int start_count; /* number of SVCs done for this req */
  91. /* Callback that is called after reaching final status. */
  92. void (*callback)(struct sclp_req *, void *data);
  93. void *callback_data;
  94. };
  95. #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
  96. #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
  97. #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
  98. #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
  99. #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
  100. /* function pointers that a high level driver has to use for registration */
  101. /* of some routines it wants to be called from the low level driver */
  102. struct sclp_register {
  103. struct list_head list;
  104. /* User wants to receive: */
  105. sccb_mask_t receive_mask;
  106. /* User wants to send: */
  107. sccb_mask_t send_mask;
  108. /* H/W can receive: */
  109. sccb_mask_t sclp_receive_mask;
  110. /* H/W can send: */
  111. sccb_mask_t sclp_send_mask;
  112. /* called if event type availability changes */
  113. void (*state_change_fn)(struct sclp_register *);
  114. /* called for events in cp_receive_mask/sclp_receive_mask */
  115. void (*receiver_fn)(struct evbuf_header *);
  116. };
  117. /* externals from sclp.c */
  118. int sclp_add_request(struct sclp_req *req);
  119. void sclp_sync_wait(void);
  120. int sclp_register(struct sclp_register *reg);
  121. void sclp_unregister(struct sclp_register *reg);
  122. int sclp_remove_processed(struct sccb_header *sccb);
  123. int sclp_deactivate(void);
  124. int sclp_reactivate(void);
  125. int sclp_service_call(sclp_cmdw_t command, void *sccb);
  126. int sclp_sdias_init(void);
  127. void sclp_sdias_exit(void);
  128. /* useful inlines */
  129. /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
  130. /* translate single character from ASCII to EBCDIC */
  131. static inline unsigned char
  132. sclp_ascebc(unsigned char ch)
  133. {
  134. return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
  135. }
  136. /* translate string from EBCDIC to ASCII */
  137. static inline void
  138. sclp_ebcasc_str(unsigned char *str, int nr)
  139. {
  140. (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
  141. }
  142. /* translate string from ASCII to EBCDIC */
  143. static inline void
  144. sclp_ascebc_str(unsigned char *str, int nr)
  145. {
  146. (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
  147. }
  148. #endif /* __SCLP_H__ */