Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * ipmi_si_sm.h
0004  *
0005  * State machine interface for low-level IPMI system management
0006  * interface state machines.  This code is the interface between
0007  * the ipmi_smi code (that handles the policy of a KCS, SMIC, or
0008  * BT interface) and the actual low-level state machine.
0009  *
0010  * Author: MontaVista Software, Inc.
0011  *         Corey Minyard <minyard@mvista.com>
0012  *         source@mvista.com
0013  *
0014  * Copyright 2002 MontaVista Software Inc.
0015  */
0016 
0017 #ifndef __IPMI_SI_SM_H__
0018 #define __IPMI_SI_SM_H__
0019 
0020 #include "ipmi_si.h"
0021 
0022 /*
0023  * This is defined by the state machines themselves, it is an opaque
0024  * data type for them to use.
0025  */
0026 struct si_sm_data;
0027 
0028 /* Results of SMI events. */
0029 enum si_sm_result {
0030     SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
0031     SI_SM_CALL_WITH_DELAY,  /* Delay some before calling again. */
0032     SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
0033     SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
0034     SI_SM_IDLE,     /* The SM is in idle state. */
0035     SI_SM_HOSED,        /* The hardware violated the state machine. */
0036 
0037     /*
0038      * The hardware is asserting attn and the state machine is
0039      * idle.
0040      */
0041     SI_SM_ATTN
0042 };
0043 
0044 /* Handlers for the SMI state machine. */
0045 struct si_sm_handlers {
0046     /*
0047      * Put the version number of the state machine here so the
0048      * upper layer can print it.
0049      */
0050     char *version;
0051 
0052     /*
0053      * Initialize the data and return the amount of I/O space to
0054      * reserve for the space.
0055      */
0056     unsigned int (*init_data)(struct si_sm_data *smi,
0057                   struct si_sm_io   *io);
0058 
0059     /*
0060      * Start a new transaction in the state machine.  This will
0061      * return -2 if the state machine is not idle, -1 if the size
0062      * is invalid (to large or too small), or 0 if the transaction
0063      * is successfully completed.
0064      */
0065     int (*start_transaction)(struct si_sm_data *smi,
0066                  unsigned char *data, unsigned int size);
0067 
0068     /*
0069      * Return the results after the transaction.  This will return
0070      * -1 if the buffer is too small, zero if no transaction is
0071      * present, or the actual length of the result data.
0072      */
0073     int (*get_result)(struct si_sm_data *smi,
0074               unsigned char *data, unsigned int length);
0075 
0076     /*
0077      * Call this periodically (for a polled interface) or upon
0078      * receiving an interrupt (for a interrupt-driven interface).
0079      * If interrupt driven, you should probably poll this
0080      * periodically when not in idle state.  This should be called
0081      * with the time that passed since the last call, if it is
0082      * significant.  Time is in microseconds.
0083      */
0084     enum si_sm_result (*event)(struct si_sm_data *smi, long time);
0085 
0086     /*
0087      * Attempt to detect an SMI.  Returns 0 on success or nonzero
0088      * on failure.
0089      */
0090     int (*detect)(struct si_sm_data *smi);
0091 
0092     /* The interface is shutting down, so clean it up. */
0093     void (*cleanup)(struct si_sm_data *smi);
0094 
0095     /* Return the size of the SMI structure in bytes. */
0096     int (*size)(void);
0097 };
0098 
0099 /* Current state machines that we can use. */
0100 extern const struct si_sm_handlers kcs_smi_handlers;
0101 extern const struct si_sm_handlers smic_smi_handlers;
0102 extern const struct si_sm_handlers bt_smi_handlers;
0103 
0104 #endif /* __IPMI_SI_SM_H__ */