• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CmdQueue.h
3  *
4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  *  * Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *  * Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *  * Neither the name Texas Instruments nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 
35 /** \file CmdQueue.h
36  *  \brief CmdQueue internal defenitions
37  *
38  *  \see CmdQueue.c
39  */
40 
41 #ifndef _CMDQUEUE_H_
42 #define _CMDQUEUE_H_
43 
44 
45 
46 
47 /*****************************************************************************
48  **         Defines                                                         **
49  *****************************************************************************/
50 #define CMDQUEUE_QUEUE_DEPTH          30
51 #define CMDQUEUE_HISTORY_DEPTH        5
52 #define CMDQUEUE_INFO_ELEM_HEADER_LEN 4
53 
54 
55 #define RC_CONVERT(rc) \
56     (rc == TXN_STATUS_OK || rc == TXN_STATUS_COMPLETE || rc == TXN_STATUS_PENDING || rc == TI_OK) ? TI_OK : TI_NOK
57 
58 
59 /*****************************************************************************
60  **         Enums                                                           **
61  *****************************************************************************/
62 typedef enum
63 {
64     CMDQUEUE_EVENT_RUN,
65     CMDQUEUE_EVENT_COMPLETE,
66     CMDQUEUE_EVENT_NUM
67 
68 } ECmdQueueSmEvents;
69 
70 
71 typedef enum
72 {
73     CMDQUEUE_STATE_IDLE,
74     CMDQUEUE_STATE_WAIT_FOR_COMPLETION
75 
76 } ECmdQueueSmStates;
77 
78 
79 /*****************************************************************************
80  **         Structures                                                      **
81  *****************************************************************************/
82 /*  CmdQueue Node */
83 typedef struct
84 {
85     /* Command Type Config/interrogat ... */
86     Command_e               cmdType;
87     TI_UINT32               uParamsLen;
88     void*                   fCb;
89     TI_HANDLE               hCb;
90     /* Param for config */
91     TI_UINT8                aParamsBuf[MAX_CMD_PARAMS];
92     /* A returned value buffer */
93     TI_UINT8*               pInterrogateBuf;
94 
95 } TCmdQueueNode;
96 
97 
98 /*  Saved CallBack Node In case of Recovery*/
99 typedef struct
100 {
101     void*                   fCb;
102     TI_HANDLE               hCb;
103     /* A returned value buffer */
104     TI_UINT8*               pInterrogateBuf;
105 
106 } TCmdQueueRecoveryNode;
107 
108 
109 typedef void (*TCmdQueueCb) (TI_HANDLE handle, TI_UINT16 uMboxStatus);
110 
111 
112 typedef void (*TCmdQueueGenericCb)(TI_HANDLE handle, TI_UINT16 uCmdType, TI_UINT16 uCmdID, TI_UINT32 status);
113 
114 
115 /** \struct TCmdQueue
116  * \brief CmdQueue structure
117  *
118  * \par Description
119  *
120  * \sa
121  */
122 typedef struct
123 {
124     /* Handles */
125     TI_HANDLE               hOs;
126     TI_HANDLE               hReport;
127     TI_HANDLE               hCmdMBox;
128     TI_HANDLE               hTwIf;
129 
130     /* SM */
131     ECmdQueueSmStates       state;
132     TCmdQueueGenericCb      fCmdCompleteCb;
133     TI_HANDLE               hCmdCompleteCb;
134     TCmdQueueCb             fFailureCb;
135     TI_HANDLE               hFailureCb;
136 
137     /* Queues */
138     TCmdQueueNode           aCmdQueue [CMDQUEUE_QUEUE_DEPTH];
139     TCmdQueueRecoveryNode   aRecoveryQueue [CMDQUEUE_QUEUE_DEPTH];
140 
141     /* Indexes & counters */
142     TI_UINT32               head;
143     TI_UINT32               tail;
144     TI_UINT32               uNumberOfCommandInQueue;
145     TI_UINT32               uMaxNumberOfCommandInQueue;
146     TI_UINT32               uNumberOfRecoveryNodes;
147     #ifdef TI_DBG
148         TI_UINT32               uCmdSendCounter;
149         TI_UINT32               uCmdCompltCounter;
150     #endif
151 
152     /* Error handling */
153     TI_BOOL                 bErrorFlag;
154     /* Mbox status */
155     TI_BOOL                 bMboxEnabled;
156     /* Notify that we have already awaken the chip */
157     TI_BOOL                 bAwake;
158 
159 } TCmdQueue;
160 
161 #endif
162 
163