1 /*
2  * ipmi_kcs_sm.h
3  *
4  * State machine for handling IPMI KCS interfaces.
5  *
6  * Author: MontaVista Software, Inc.
7  *         Corey Minyard <minyard@mvista.com>
8  *         source@mvista.com
9  *
10  * Copyright 2002 MontaVista Software Inc.
11  *
12  *  This program is free software; you can redistribute it and/or modify it
13  *  under the terms of the GNU General Public License as published by the
14  *  Free Software Foundation; either version 2 of the License, or (at your
15  *  option) any later version.
16  *
17  *
18  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  *  You should have received a copy of the GNU General Public License along
30  *  with this program; if not, write to the Free Software Foundation, Inc.,
31  *  675 Mass Ave, Cambridge, MA 02139, USA.
32  */
33 
34 struct kcs_data;
35 
36 void init_kcs_data(struct kcs_data *kcs,
37 		   unsigned int    port,
38 		   unsigned char   *addr);
39 
40 /* Start a new transaction in the state machine.  This will return -2
41    if the state machine is not idle, -1 if the size is invalid (to
42    large or too small), or 0 if the transaction is successfully
43    completed. */
44 int start_kcs_transaction(struct kcs_data *kcs, char *data, unsigned int size);
45 
46 /* Return the results after the transaction.  This will return -1 if
47    the buffer is too small, zero if no transaction is present, or the
48    actual length of the result data. */
49 int kcs_get_result(struct kcs_data *kcs, unsigned char *data, int length);
50 
51 enum kcs_result
52 {
53 	KCS_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
54 	KCS_CALL_WITH_DELAY,	/* Delay some before calling again. */
55 	KCS_TRANSACTION_COMPLETE, /* A transaction is finished. */
56 	KCS_SM_IDLE,		/* The SM is in idle state. */
57 	KCS_SM_HOSED,		/* The hardware violated the state machine. */
58 	KCS_ATTN		/* The hardware is asserting attn and the
59 				   state machine is idle. */
60 };
61 
62 /* Call this periodically (for a polled interface) or upon receiving
63    an interrupt (for a interrupt-driven interface).  If interrupt
64    driven, you should probably poll this periodically when not in idle
65    state.  This should be called with the time that passed since the
66    last call, if it is significant.  Time is in microseconds. */
67 enum kcs_result kcs_event(struct kcs_data *kcs, long time);
68 
69 /* Return the size of the KCS structure in bytes. */
70 int kcs_size(void);
71