sclp.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/ebcdic.h>
  14. /* maximum number of pages concerning our own memory management */
  15. #define MAX_KMEM_PAGES (sizeof(unsigned long) << 3)
  16. #define MAX_CONSOLE_PAGES 4
  17. #define EvTyp_OpCmd 0x01
  18. #define EvTyp_Msg 0x02
  19. #define EvTyp_StateChange 0x08
  20. #define EvTyp_PMsgCmd 0x09
  21. #define EvTyp_CntlProgOpCmd 0x20
  22. #define EvTyp_CntlProgIdent 0x0B
  23. #define EvTyp_SigQuiesce 0x1D
  24. #define EvTyp_VT220Msg 0x1A
  25. #define EvTyp_OpCmd_Mask 0x80000000
  26. #define EvTyp_Msg_Mask 0x40000000
  27. #define EvTyp_StateChange_Mask 0x01000000
  28. #define EvTyp_PMsgCmd_Mask 0x00800000
  29. #define EvTyp_CtlProgOpCmd_Mask 0x00000001
  30. #define EvTyp_CtlProgIdent_Mask 0x00200000
  31. #define EvTyp_SigQuiesce_Mask 0x00000008
  32. #define EvTyp_VT220Msg_Mask 0x00000040
  33. #define GnrlMsgFlgs_DOM 0x8000
  34. #define GnrlMsgFlgs_SndAlrm 0x4000
  35. #define GnrlMsgFlgs_HoldMsg 0x2000
  36. #define LnTpFlgs_CntlText 0x8000
  37. #define LnTpFlgs_LabelText 0x4000
  38. #define LnTpFlgs_DataText 0x2000
  39. #define LnTpFlgs_EndText 0x1000
  40. #define LnTpFlgs_PromptText 0x0800
  41. typedef unsigned int sclp_cmdw_t;
  42. #define SCLP_CMDW_READDATA 0x00770005
  43. #define SCLP_CMDW_WRITEDATA 0x00760005
  44. #define SCLP_CMDW_WRITEMASK 0x00780005
  45. #define GDS_ID_MDSMU 0x1310
  46. #define GDS_ID_MDSRouteInfo 0x1311
  47. #define GDS_ID_AgUnWrkCorr 0x1549
  48. #define GDS_ID_SNACondReport 0x1532
  49. #define GDS_ID_CPMSU 0x1212
  50. #define GDS_ID_RoutTargInstr 0x154D
  51. #define GDS_ID_OpReq 0x8070
  52. #define GDS_ID_TextCmd 0x1320
  53. #define GDS_KEY_SelfDefTextMsg 0x31
  54. typedef u32 sccb_mask_t; /* ATTENTION: assumes 32bit mask !!! */
  55. struct sccb_header {
  56. u16 length;
  57. u8 function_code;
  58. u8 control_mask[3];
  59. u16 response_code;
  60. } __attribute__((packed));
  61. struct gds_subvector {
  62. u8 length;
  63. u8 key;
  64. } __attribute__((packed));
  65. struct gds_vector {
  66. u16 length;
  67. u16 gds_id;
  68. } __attribute__((packed));
  69. struct evbuf_header {
  70. u16 length;
  71. u8 type;
  72. u8 flags;
  73. u16 _reserved;
  74. } __attribute__((packed));
  75. struct sclp_req {
  76. struct list_head list; /* list_head for request queueing. */
  77. sclp_cmdw_t command; /* sclp command to execute */
  78. void *sccb; /* pointer to the sccb to execute */
  79. char status; /* status of this request */
  80. int start_count; /* number of SVCs done for this req */
  81. /* Callback that is called after reaching final status. */
  82. void (*callback)(struct sclp_req *, void *data);
  83. void *callback_data;
  84. };
  85. #define SCLP_REQ_FILLED 0x00 /* request is ready to be processed */
  86. #define SCLP_REQ_QUEUED 0x01 /* request is queued to be processed */
  87. #define SCLP_REQ_RUNNING 0x02 /* request is currently running */
  88. #define SCLP_REQ_DONE 0x03 /* request is completed successfully */
  89. #define SCLP_REQ_FAILED 0x05 /* request is finally failed */
  90. /* function pointers that a high level driver has to use for registration */
  91. /* of some routines it wants to be called from the low level driver */
  92. struct sclp_register {
  93. struct list_head list;
  94. /* event masks this user is registered for */
  95. sccb_mask_t receive_mask;
  96. sccb_mask_t send_mask;
  97. /* actually present events */
  98. sccb_mask_t sclp_receive_mask;
  99. sccb_mask_t sclp_send_mask;
  100. /* called if event type availability changes */
  101. void (*state_change_fn)(struct sclp_register *);
  102. /* called for events in cp_receive_mask/sclp_receive_mask */
  103. void (*receiver_fn)(struct evbuf_header *);
  104. };
  105. /* externals from sclp.c */
  106. int sclp_add_request(struct sclp_req *req);
  107. void sclp_sync_wait(void);
  108. int sclp_register(struct sclp_register *reg);
  109. void sclp_unregister(struct sclp_register *reg);
  110. int sclp_remove_processed(struct sccb_header *sccb);
  111. int sclp_deactivate(void);
  112. int sclp_reactivate(void);
  113. /* useful inlines */
  114. /* VM uses EBCDIC 037, LPAR+native(SE+HMC) use EBCDIC 500 */
  115. /* translate single character from ASCII to EBCDIC */
  116. static inline unsigned char
  117. sclp_ascebc(unsigned char ch)
  118. {
  119. return (MACHINE_IS_VM) ? _ascebc[ch] : _ascebc_500[ch];
  120. }
  121. /* translate string from EBCDIC to ASCII */
  122. static inline void
  123. sclp_ebcasc_str(unsigned char *str, int nr)
  124. {
  125. (MACHINE_IS_VM) ? EBCASC(str, nr) : EBCASC_500(str, nr);
  126. }
  127. /* translate string from ASCII to EBCDIC */
  128. static inline void
  129. sclp_ascebc_str(unsigned char *str, int nr)
  130. {
  131. (MACHINE_IS_VM) ? ASCEBC(str, nr) : ASCEBC_500(str, nr);
  132. }
  133. #endif /* __SCLP_H__ */