sclp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 SCLP_CMDW_READ_SCP_INFO 0x00020001
  51. #define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001
  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. typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
  62. struct sccb_header {
  63. u16 length;
  64. u8 function_code;
  65. u8 control_mask[3];
  66. u16 response_code;
  67. } __attribute__((packed));
  68. extern u64 sclp_facilities;
  69. #define SCLP_HAS_CHP_INFO (sclp_facilities & 0x8000000000000000ULL)
  70. #define SCLP_HAS_CHP_RECONFIG (sclp_facilities & 0x2000000000000000ULL)
  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. /* event masks this user is registered for */
  105. sccb_mask_t receive_mask;
  106. sccb_mask_t send_mask;
  107. /* actually present events */
  108. sccb_mask_t sclp_receive_mask;
  109. sccb_mask_t sclp_send_mask;
  110. /* called if event type availability changes */
  111. void (*state_change_fn)(struct sclp_register *);
  112. /* called for events in cp_receive_mask/sclp_receive_mask */
  113. void (*receiver_fn)(struct evbuf_header *);
  114. };
  115. /* externals from sclp.c */
  116. int sclp_add_request(struct sclp_req *req);
  117. void sclp_sync_wait(void);
  118. int sclp_register(struct sclp_register *reg);
  119. void sclp_unregister(struct sclp_register *reg);
  120. int sclp_remove_processed(struct sccb_header *sccb);
  121. int sclp_deactivate(void);
  122. int sclp_reactivate(void);
  123. int sclp_service_call(sclp_cmdw_t command, void *sccb);
  124. int sclp_sdias_init(void);
  125. void sclp_sdias_exit(void);
  126. /* useful inlines */
  127. /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
  128. /* translate single character from ASCII to EBCDIC */
  129. static inline unsigned char
  130. sclp_ascebc(unsigned char ch)
  131. {
  132. return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
  133. }
  134. /* translate string from EBCDIC to ASCII */
  135. static inline void
  136. sclp_ebcasc_str(unsigned char *str, int nr)
  137. {
  138. (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
  139. }
  140. /* translate string from ASCII to EBCDIC */
  141. static inline void
  142. sclp_ascebc_str(unsigned char *str, int nr)
  143. {
  144. (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
  145. }
  146. #endif /* __SCLP_H__ */