0
|
1 |
/*
|
|
2 |
* context.h
|
|
3 |
*
|
|
4 |
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* This program and the accompanying materials are made available under the
|
|
8 |
* terms of the Eclipse Public License v1.0 or BSD License which accompanies
|
|
9 |
* this distribution. The Eclipse Public License is available at
|
|
10 |
* http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.
|
|
11 |
*
|
|
12 |
* Redistribution and use in source and binary forms, with or without
|
|
13 |
* modification, are permitted provided that the following conditions
|
|
14 |
* are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in
|
|
20 |
* the documentation and/or other materials provided with the
|
|
21 |
* distribution.
|
|
22 |
* * Neither the name Texas Instruments nor the names of its
|
|
23 |
* contributors may be used to endorse or promote products derived
|
|
24 |
* from this software without specific prior written permission.
|
|
25 |
*
|
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37 |
*/
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
/** \file context.h
|
|
42 |
* \brief context module header file.
|
|
43 |
*
|
|
44 |
* \see context.c
|
|
45 |
*/
|
|
46 |
|
|
47 |
#ifndef _CONTEXT_H_
|
|
48 |
#define _CONTEXT_H_
|
|
49 |
|
|
50 |
#define MAX_CLIENTS 8 /* Maximum number of clients using context services */
|
|
51 |
#define MAX_NAME_SIZE 16 /* Maximum client's name string size */
|
|
52 |
|
|
53 |
#ifdef TI_DBG
|
|
54 |
typedef struct
|
|
55 |
{
|
|
56 |
TI_UINT32 uSize; /* Clients' name string size */
|
|
57 |
char sName [MAX_NAME_SIZE]; /* Clients' name string */
|
|
58 |
} TClientName;
|
|
59 |
#endif /* TI_DBG */
|
|
60 |
|
|
61 |
/* The callback function type for context clients */
|
|
62 |
typedef void (*TContextCbFunc)(TI_HANDLE hCbHndl);
|
|
63 |
|
|
64 |
/* context module structure */
|
|
65 |
typedef struct
|
|
66 |
{
|
|
67 |
TI_HANDLE hOs;
|
|
68 |
TI_HANDLE hReport;
|
|
69 |
|
|
70 |
TI_HANDLE hProtectionLock; /* Handle of protection lock used by context clients */
|
|
71 |
TI_UINT32 uNumClients; /* Number of registered clients */
|
|
72 |
TContextCbFunc aClientCbFunc [MAX_CLIENTS]; /* Clients' callback functions */
|
|
73 |
TI_HANDLE aClientCbHndl [MAX_CLIENTS]; /* Clients' callback handles */
|
|
74 |
TI_BOOL aClientEnabled[MAX_CLIENTS]; /* Clients' enable/disable flags */
|
|
75 |
TI_BOOL aClientPending[MAX_CLIENTS]; /* Clients' pending flags */
|
|
76 |
|
|
77 |
#ifdef TI_DBG
|
|
78 |
TClientName aClientName [MAX_CLIENTS]; /* Clients' name string */
|
|
79 |
TI_UINT32 aRequestCount [MAX_CLIENTS]; /* Clients' schedule requests counter*/
|
|
80 |
TI_UINT32 aInvokeCount [MAX_CLIENTS]; /* Clients' invocations counter */
|
|
81 |
#endif
|
|
82 |
|
|
83 |
} TContext;
|
|
84 |
|
|
85 |
|
|
86 |
/* Macros */
|
|
87 |
/* =======*/
|
|
88 |
/**
|
|
89 |
* \fn CONTEXT_ENTER_CRITICAL_SECTION / CONTEXT_LEAVE_CRITICAL_SECTION
|
|
90 |
* \brief Lock / Unlock context related critical sections
|
|
91 |
*
|
|
92 |
* The context clients should use these macros for protecting their critical sections
|
|
93 |
* when handling context transition to driver context.
|
|
94 |
*
|
|
95 |
* \note
|
|
96 |
* \param hContext - The module handle
|
|
97 |
* \return void
|
|
98 |
* \sa
|
|
99 |
*/
|
|
100 |
/* Start critical section protection */
|
|
101 |
#define CONTEXT_ENTER_CRITICAL_SECTION(hContext) \
|
|
102 |
OS_ENTER_CRITICAL_SECTION(((TContext *)hContext)->hOs, ((TContext *)hContext)->hProtectionLock);
|
|
103 |
|
|
104 |
/* Stop critical section protection */
|
|
105 |
#define CONTEXT_LEAVE_CRITICAL_SECTION(hContext) \
|
|
106 |
OS_LEAVE_CRITICAL_SECTION(((TContext *)hContext)->hOs, ((TContext *)hContext)->hProtectionLock);
|
|
107 |
|
|
108 |
|
|
109 |
/* External Functions Prototypes */
|
|
110 |
/* ============================= */
|
|
111 |
TI_HANDLE context_Create (TI_HANDLE hOs);
|
|
112 |
TI_STATUS context_Destroy (TI_HANDLE hContext);
|
|
113 |
void context_Init (TI_HANDLE hContext, TI_HANDLE hOs, TI_HANDLE hReport);
|
|
114 |
|
|
115 |
TI_UINT32 context_RegisterClient (TI_HANDLE hContext,
|
|
116 |
TContextCbFunc fCbFunc,
|
|
117 |
TI_HANDLE hCbHndl,
|
|
118 |
TI_BOOL bEnable,
|
|
119 |
char *sName,
|
|
120 |
TI_UINT32 uNameSize);
|
|
121 |
|
|
122 |
void context_RequestSchedule (TI_HANDLE hContext, TI_UINT32 uClientId);
|
|
123 |
void context_DriverTask (TI_HANDLE hContext);
|
|
124 |
void context_EnableClient (TI_HANDLE hContext, TI_UINT32 uClientId);
|
|
125 |
void context_DisableClient (TI_HANDLE hContext, TI_UINT32 uClientId);
|
|
126 |
void context_DisableClient (TI_HANDLE hContext, TI_UINT32 uClientId);
|
|
127 |
void context_EnableClient (TI_HANDLE hContext, TI_UINT32 uClientId);
|
|
128 |
#ifdef TI_DBG
|
|
129 |
void context_Print (TI_HANDLE hContext);
|
|
130 |
#endif /* TI_DBG */
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
#endif /* _CONTEXT_H_ */
|
|
135 |
|
|
136 |
|