ipmi_si_sm.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * ipmi_si_sm.h
  3. *
  4. * State machine interface for low-level IPMI system management
  5. * interface state machines. This code is the interface between
  6. * the ipmi_smi code (that handles the policy of a KCS, SMIC, or
  7. * BT interface) and the actual low-level state machine.
  8. *
  9. * Author: MontaVista Software, Inc.
  10. * Corey Minyard <minyard@mvista.com>
  11. * source@mvista.com
  12. *
  13. * Copyright 2002 MontaVista Software Inc.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  27. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  29. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  30. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * You should have received a copy of the GNU General Public License along
  33. * with this program; if not, write to the Free Software Foundation, Inc.,
  34. * 675 Mass Ave, Cambridge, MA 02139, USA.
  35. */
  36. /*
  37. * This is defined by the state machines themselves, it is an opaque
  38. * data type for them to use.
  39. */
  40. struct si_sm_data;
  41. /*
  42. * The structure for doing I/O in the state machine. The state
  43. * machine doesn't have the actual I/O routines, they are done through
  44. * this interface.
  45. */
  46. struct si_sm_io {
  47. unsigned char (*inputb)(const struct si_sm_io *io, unsigned int offset);
  48. void (*outputb)(const struct si_sm_io *io,
  49. unsigned int offset,
  50. unsigned char b);
  51. /*
  52. * Generic info used by the actual handling routines, the
  53. * state machine shouldn't touch these.
  54. */
  55. void __iomem *addr;
  56. int regspacing;
  57. int regsize;
  58. int regshift;
  59. int addr_type;
  60. long addr_data;
  61. };
  62. /* Results of SMI events. */
  63. enum si_sm_result {
  64. SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
  65. SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
  66. SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
  67. SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
  68. SI_SM_IDLE, /* The SM is in idle state. */
  69. SI_SM_HOSED, /* The hardware violated the state machine. */
  70. /*
  71. * The hardware is asserting attn and the state machine is
  72. * idle.
  73. */
  74. SI_SM_ATTN
  75. };
  76. /* Handlers for the SMI state machine. */
  77. struct si_sm_handlers {
  78. /*
  79. * Put the version number of the state machine here so the
  80. * upper layer can print it.
  81. */
  82. char *version;
  83. /*
  84. * Initialize the data and return the amount of I/O space to
  85. * reserve for the space.
  86. */
  87. unsigned int (*init_data)(struct si_sm_data *smi,
  88. struct si_sm_io *io);
  89. /*
  90. * Start a new transaction in the state machine. This will
  91. * return -2 if the state machine is not idle, -1 if the size
  92. * is invalid (to large or too small), or 0 if the transaction
  93. * is successfully completed.
  94. */
  95. int (*start_transaction)(struct si_sm_data *smi,
  96. unsigned char *data, unsigned int size);
  97. /*
  98. * Return the results after the transaction. This will return
  99. * -1 if the buffer is too small, zero if no transaction is
  100. * present, or the actual length of the result data.
  101. */
  102. int (*get_result)(struct si_sm_data *smi,
  103. unsigned char *data, unsigned int length);
  104. /*
  105. * Call this periodically (for a polled interface) or upon
  106. * receiving an interrupt (for a interrupt-driven interface).
  107. * If interrupt driven, you should probably poll this
  108. * periodically when not in idle state. This should be called
  109. * with the time that passed since the last call, if it is
  110. * significant. Time is in microseconds.
  111. */
  112. enum si_sm_result (*event)(struct si_sm_data *smi, long time);
  113. /*
  114. * Attempt to detect an SMI. Returns 0 on success or nonzero
  115. * on failure.
  116. */
  117. int (*detect)(struct si_sm_data *smi);
  118. /* The interface is shutting down, so clean it up. */
  119. void (*cleanup)(struct si_sm_data *smi);
  120. /* Return the size of the SMI structure in bytes. */
  121. int (*size)(void);
  122. };
  123. /* Current state machines that we can use. */
  124. extern const struct si_sm_handlers kcs_smi_handlers;
  125. extern const struct si_sm_handlers smic_smi_handlers;
  126. extern const struct si_sm_handlers bt_smi_handlers;