vio.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* -*- linux-c -*-
  2. *
  3. * iSeries Virtual I/O Message Path header
  4. *
  5. * Authors: Dave Boutcher <boutcher@us.ibm.com>
  6. * Ryan Arnold <ryanarn@us.ibm.com>
  7. * Colin Devilbiss <devilbis@us.ibm.com>
  8. *
  9. * (C) Copyright 2000 IBM Corporation
  10. *
  11. * This header file is used by the iSeries virtual I/O device
  12. * drivers. It defines the interfaces to the common functions
  13. * (implemented in drivers/char/viopath.h) as well as defining
  14. * common functions and structures. Currently (at the time I
  15. * wrote this comment) the iSeries virtual I/O device drivers
  16. * that use this are
  17. * drivers/block/viodasd.c
  18. * drivers/char/viocons.c
  19. * drivers/char/viotape.c
  20. * drivers/cdrom/viocd.c
  21. *
  22. * The iSeries virtual ethernet support (veth.c) uses a whole
  23. * different set of functions.
  24. *
  25. * This program is free software; you can redistribute it and/or
  26. * modify it under the terms of the GNU General Public License as
  27. * published by the Free Software Foundation; either version 2 of the
  28. * License, or (at your option) anyu later version.
  29. *
  30. * This program is distributed in the hope that it will be useful, but
  31. * WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  33. * General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU General Public License
  36. * along with this program; if not, write to the Free Software Foundation,
  37. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  38. *
  39. */
  40. #ifndef _ASM_POWERPC_ISERIES_VIO_H
  41. #define _ASM_POWERPC_ISERIES_VIO_H
  42. #include <asm/iseries/hv_types.h>
  43. #include <asm/iseries/hv_lp_event.h>
  44. /*
  45. * iSeries virtual I/O events use the subtype field in
  46. * HvLpEvent to figure out what kind of vio event is coming
  47. * in. We use a table to route these, and this defines
  48. * the maximum number of distinct subtypes
  49. */
  50. #define VIO_MAX_SUBTYPES 8
  51. struct viocdlpevent {
  52. struct HvLpEvent event;
  53. u32 reserved;
  54. u16 version;
  55. u16 sub_result;
  56. u16 disk;
  57. u16 flags;
  58. u32 token;
  59. u64 offset; /* On open, max number of disks */
  60. u64 len; /* On open, size of the disk */
  61. u32 block_size; /* Only set on open */
  62. u32 media_size; /* Only set on open */
  63. };
  64. enum viocdsubtype {
  65. viocdopen = 0x0001,
  66. viocdclose = 0x0002,
  67. viocdread = 0x0003,
  68. viocdwrite = 0x0004,
  69. viocdlockdoor = 0x0005,
  70. viocdgetinfo = 0x0006,
  71. viocdcheck = 0x0007
  72. };
  73. struct viotapelpevent {
  74. struct HvLpEvent event;
  75. u32 reserved;
  76. u16 version;
  77. u16 sub_type_result;
  78. u16 tape;
  79. u16 flags;
  80. u32 token;
  81. u64 len;
  82. union {
  83. struct {
  84. u32 tape_op;
  85. u32 count;
  86. } op;
  87. struct {
  88. u32 type;
  89. u32 resid;
  90. u32 dsreg;
  91. u32 gstat;
  92. u32 erreg;
  93. u32 file_no;
  94. u32 block_no;
  95. } get_status;
  96. struct {
  97. u32 block_no;
  98. } get_pos;
  99. } u;
  100. };
  101. enum viotapesubtype {
  102. viotapeopen = 0x0001,
  103. viotapeclose = 0x0002,
  104. viotaperead = 0x0003,
  105. viotapewrite = 0x0004,
  106. viotapegetinfo = 0x0005,
  107. viotapeop = 0x0006,
  108. viotapegetpos = 0x0007,
  109. viotapesetpos = 0x0008,
  110. viotapegetstatus = 0x0009
  111. };
  112. /*
  113. * Each subtype can register a handler to process their events.
  114. * The handler must have this interface.
  115. */
  116. typedef void (vio_event_handler_t) (struct HvLpEvent * event);
  117. extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
  118. extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
  119. extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
  120. extern int vio_clearHandler(int subtype);
  121. extern int viopath_isactive(HvLpIndex lp);
  122. extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
  123. extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
  124. extern void vio_set_hostlp(void);
  125. extern void *vio_get_event_buffer(int subtype);
  126. extern void vio_free_event_buffer(int subtype, void *buffer);
  127. extern HvLpIndex viopath_hostLp;
  128. extern HvLpIndex viopath_ourLp;
  129. #define VIOCHAR_MAX_DATA 200
  130. #define VIOMAJOR_SUBTYPE_MASK 0xff00
  131. #define VIOMINOR_SUBTYPE_MASK 0x00ff
  132. #define VIOMAJOR_SUBTYPE_SHIFT 8
  133. #define VIOVERSION 0x0101
  134. /*
  135. * This is the general structure for VIO errors; each module should have
  136. * a table of them, and each table should be terminated by an entry of
  137. * { 0, 0, NULL }. Then, to find a specific error message, a module
  138. * should pass its local table and the return code.
  139. */
  140. struct vio_error_entry {
  141. u16 rc;
  142. int errno;
  143. const char *msg;
  144. };
  145. extern const struct vio_error_entry *vio_lookup_rc(
  146. const struct vio_error_entry *local_table, u16 rc);
  147. enum viosubtypes {
  148. viomajorsubtype_monitor = 0x0100,
  149. viomajorsubtype_blockio = 0x0200,
  150. viomajorsubtype_chario = 0x0300,
  151. viomajorsubtype_config = 0x0400,
  152. viomajorsubtype_cdio = 0x0500,
  153. viomajorsubtype_tape = 0x0600,
  154. viomajorsubtype_scsi = 0x0700
  155. };
  156. enum vioconfigsubtype {
  157. vioconfigget = 0x0001,
  158. };
  159. enum viorc {
  160. viorc_good = 0x0000,
  161. viorc_noConnection = 0x0001,
  162. viorc_noReceiver = 0x0002,
  163. viorc_noBufferAvailable = 0x0003,
  164. viorc_invalidMessageType = 0x0004,
  165. viorc_invalidRange = 0x0201,
  166. viorc_invalidToken = 0x0202,
  167. viorc_DMAError = 0x0203,
  168. viorc_useError = 0x0204,
  169. viorc_releaseError = 0x0205,
  170. viorc_invalidDisk = 0x0206,
  171. viorc_openRejected = 0x0301
  172. };
  173. /*
  174. * The structure of the events that flow between us and OS/400 for chario
  175. * events. You can't mess with this unless the OS/400 side changes too.
  176. */
  177. struct viocharlpevent {
  178. struct HvLpEvent event;
  179. u32 reserved;
  180. u16 version;
  181. u16 subtype_result_code;
  182. u8 virtual_device;
  183. u8 len;
  184. u8 data[VIOCHAR_MAX_DATA];
  185. };
  186. #define VIOCHAR_WINDOW 10
  187. enum viocharsubtype {
  188. viocharopen = 0x0001,
  189. viocharclose = 0x0002,
  190. viochardata = 0x0003,
  191. viocharack = 0x0004,
  192. viocharconfig = 0x0005
  193. };
  194. enum viochar_rc {
  195. viochar_rc_ebusy = 1
  196. };
  197. #endif /* _ASM_POWERPC_ISERIES_VIO_H */