vio.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* -*- linux-c -*-
  2. * drivers/char/vio.h
  3. *
  4. * iSeries Virtual I/O Message Path header
  5. *
  6. * Authors: Dave Boutcher <boutcher@us.ibm.com>
  7. * Ryan Arnold <ryanarn@us.ibm.com>
  8. * Colin Devilbiss <devilbis@us.ibm.com>
  9. *
  10. * (C) Copyright 2000 IBM Corporation
  11. *
  12. * This header file is used by the iSeries virtual I/O device
  13. * drivers. It defines the interfaces to the common functions
  14. * (implemented in drivers/char/viopath.h) as well as defining
  15. * common functions and structures. Currently (at the time I
  16. * wrote this comment) the iSeries virtual I/O device drivers
  17. * that use this are
  18. * drivers/block/viodasd.c
  19. * drivers/char/viocons.c
  20. * drivers/char/viotape.c
  21. * drivers/cdrom/viocd.c
  22. *
  23. * The iSeries virtual ethernet support (veth.c) uses a whole
  24. * different set of functions.
  25. *
  26. * This program is free software; you can redistribute it and/or
  27. * modify it under the terms of the GNU General Public License as
  28. * published by the Free Software Foundation; either version 2 of the
  29. * License, or (at your option) anyu later version.
  30. *
  31. * This program is distributed in the hope that it will be useful, but
  32. * WITHOUT ANY WARRANTY; without even the implied warranty of
  33. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  34. * General Public License for more details.
  35. *
  36. * You should have received a copy of the GNU General Public License
  37. * along with this program; if not, write to the Free Software Foundation,
  38. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  39. *
  40. */
  41. #ifndef _ISERIES_VIO_H
  42. #define _ISERIES_VIO_H
  43. #include <asm/iSeries/HvTypes.h>
  44. #include <asm/iSeries/HvLpEvent.h>
  45. /*
  46. * iSeries virtual I/O events use the subtype field in
  47. * HvLpEvent to figure out what kind of vio event is coming
  48. * in. We use a table to route these, and this defines
  49. * the maximum number of distinct subtypes
  50. */
  51. #define VIO_MAX_SUBTYPES 8
  52. /*
  53. * Each subtype can register a handler to process their events.
  54. * The handler must have this interface.
  55. */
  56. typedef void (vio_event_handler_t) (struct HvLpEvent * event);
  57. extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
  58. extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
  59. extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
  60. extern int vio_clearHandler(int subtype);
  61. extern int viopath_isactive(HvLpIndex lp);
  62. extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
  63. extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
  64. extern void vio_set_hostlp(void);
  65. extern void *vio_get_event_buffer(int subtype);
  66. extern void vio_free_event_buffer(int subtype, void *buffer);
  67. extern HvLpIndex viopath_hostLp;
  68. extern HvLpIndex viopath_ourLp;
  69. #define VIOCHAR_MAX_DATA 200
  70. #define VIOMAJOR_SUBTYPE_MASK 0xff00
  71. #define VIOMINOR_SUBTYPE_MASK 0x00ff
  72. #define VIOMAJOR_SUBTYPE_SHIFT 8
  73. #define VIOVERSION 0x0101
  74. /*
  75. * This is the general structure for VIO errors; each module should have
  76. * a table of them, and each table should be terminated by an entry of
  77. * { 0, 0, NULL }. Then, to find a specific error message, a module
  78. * should pass its local table and the return code.
  79. */
  80. struct vio_error_entry {
  81. u16 rc;
  82. int errno;
  83. const char *msg;
  84. };
  85. extern const struct vio_error_entry *vio_lookup_rc(
  86. const struct vio_error_entry *local_table, u16 rc);
  87. enum viosubtypes {
  88. viomajorsubtype_monitor = 0x0100,
  89. viomajorsubtype_blockio = 0x0200,
  90. viomajorsubtype_chario = 0x0300,
  91. viomajorsubtype_config = 0x0400,
  92. viomajorsubtype_cdio = 0x0500,
  93. viomajorsubtype_tape = 0x0600,
  94. viomajorsubtype_scsi = 0x0700
  95. };
  96. enum vioconfigsubtype {
  97. vioconfigget = 0x0001,
  98. };
  99. enum viorc {
  100. viorc_good = 0x0000,
  101. viorc_noConnection = 0x0001,
  102. viorc_noReceiver = 0x0002,
  103. viorc_noBufferAvailable = 0x0003,
  104. viorc_invalidMessageType = 0x0004,
  105. viorc_invalidRange = 0x0201,
  106. viorc_invalidToken = 0x0202,
  107. viorc_DMAError = 0x0203,
  108. viorc_useError = 0x0204,
  109. viorc_releaseError = 0x0205,
  110. viorc_invalidDisk = 0x0206,
  111. viorc_openRejected = 0x0301
  112. };
  113. struct device;
  114. extern struct device *iSeries_vio_dev;
  115. #endif /* _ISERIES_VIO_H */