vio.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. /*
  52. * Each subtype can register a handler to process their events.
  53. * The handler must have this interface.
  54. */
  55. typedef void (vio_event_handler_t) (struct HvLpEvent * event);
  56. extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
  57. extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
  58. extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
  59. extern int vio_clearHandler(int subtype);
  60. extern int viopath_isactive(HvLpIndex lp);
  61. extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
  62. extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
  63. extern void vio_set_hostlp(void);
  64. extern void *vio_get_event_buffer(int subtype);
  65. extern void vio_free_event_buffer(int subtype, void *buffer);
  66. extern HvLpIndex viopath_hostLp;
  67. extern HvLpIndex viopath_ourLp;
  68. #define VIOCHAR_MAX_DATA 200
  69. #define VIOMAJOR_SUBTYPE_MASK 0xff00
  70. #define VIOMINOR_SUBTYPE_MASK 0x00ff
  71. #define VIOMAJOR_SUBTYPE_SHIFT 8
  72. #define VIOVERSION 0x0101
  73. /*
  74. * This is the general structure for VIO errors; each module should have
  75. * a table of them, and each table should be terminated by an entry of
  76. * { 0, 0, NULL }. Then, to find a specific error message, a module
  77. * should pass its local table and the return code.
  78. */
  79. struct vio_error_entry {
  80. u16 rc;
  81. int errno;
  82. const char *msg;
  83. };
  84. extern const struct vio_error_entry *vio_lookup_rc(
  85. const struct vio_error_entry *local_table, u16 rc);
  86. enum viosubtypes {
  87. viomajorsubtype_monitor = 0x0100,
  88. viomajorsubtype_blockio = 0x0200,
  89. viomajorsubtype_chario = 0x0300,
  90. viomajorsubtype_config = 0x0400,
  91. viomajorsubtype_cdio = 0x0500,
  92. viomajorsubtype_tape = 0x0600,
  93. viomajorsubtype_scsi = 0x0700
  94. };
  95. enum vioconfigsubtype {
  96. vioconfigget = 0x0001,
  97. };
  98. enum viorc {
  99. viorc_good = 0x0000,
  100. viorc_noConnection = 0x0001,
  101. viorc_noReceiver = 0x0002,
  102. viorc_noBufferAvailable = 0x0003,
  103. viorc_invalidMessageType = 0x0004,
  104. viorc_invalidRange = 0x0201,
  105. viorc_invalidToken = 0x0202,
  106. viorc_DMAError = 0x0203,
  107. viorc_useError = 0x0204,
  108. viorc_releaseError = 0x0205,
  109. viorc_invalidDisk = 0x0206,
  110. viorc_openRejected = 0x0301
  111. };
  112. /*
  113. * The structure of the events that flow between us and OS/400 for chario
  114. * events. You can't mess with this unless the OS/400 side changes too.
  115. */
  116. struct viocharlpevent {
  117. struct HvLpEvent event;
  118. u32 reserved;
  119. u16 version;
  120. u16 subtype_result_code;
  121. u8 virtual_device;
  122. u8 len;
  123. u8 data[VIOCHAR_MAX_DATA];
  124. };
  125. #define VIOCHAR_WINDOW 10
  126. enum viocharsubtype {
  127. viocharopen = 0x0001,
  128. viocharclose = 0x0002,
  129. viochardata = 0x0003,
  130. viocharack = 0x0004,
  131. viocharconfig = 0x0005
  132. };
  133. enum viochar_rc {
  134. viochar_rc_ebusy = 1
  135. };
  136. struct device;
  137. extern struct device *iSeries_vio_dev;
  138. #endif /* _ASM_POWERPC_ISERIES_VIO_H */