source: svn/newcon3bcm2_21bu/magnum/basemodules/int/bint.h @ 43

Last change on this file since 43 was 43, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 13.6 KB
Line 
1/***************************************************************************
2 *         Copyright (c) 2003-2009, Broadcom Corporation
3 *         All Rights Reserved
4 *         Confidential Property of Broadcom Corporation
5 *
6 *      THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *      AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *      EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bint.h $
11 * $brcm_Revision: Hydra_Software_Devel/30 $
12 * $brcm_Date: 3/30/09 3:15p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/int/bint.h $
19 *
20 * Hydra_Software_Devel/30   3/30/09 3:15p erickson
21 * PR35457: update comments, especially regarding BINT_Id
22 *
23 * Hydra_Software_Devel/29   5/25/06 4:13p albertl
24 * PR21392:  BINT_Stats functions now split off into bint_stats.h to solve
25 * BTMR circular dependency.
26 *
27 * Hydra_Software_Devel/28   5/24/06 6:56p albertl
28 * PR21392:  Changed BINT stats tracking to use timers from TMR module.
29 * Added BINT_Stats_Enable and BINT_Stats_Disable.
30 *
31 * Hydra_Software_Devel/27   2/15/06 5:30p vsilyaev
32 * PR 19693: Added support for acquiring interrupt rate
33 *
34 * Hydra_Software_Devel/26   9/12/05 7:18p darnstein
35 * PR16885: include bstd.h.
36 *
37 * Hydra_Software_Devel/25   4/13/05 5:16p albertl
38 * PR10596:  Moved bDefaultBins to BINT_Stats_CallbackStats.
39 *
40 * Hydra_Software_Devel/24   4/11/05 5:29p albertl
41 * PR10596:  Added BINT_Stats_DestroyBins and BINT_Stats_Reset.
42 * BINT_STATS_ENABLE now tied to BDBG_DEBUG_BUILD.
43 *
44 * Hydra_Software_Devel/23   4/7/05 4:15p albertl
45 * PR10596:  Changed BINT_STATS_TRACK to BINT_STATS_ENABLE.
46 *
47 * Hydra_Software_Devel/22   4/6/05 2:26p albertl
48 * PR10596:  Removed unnecessary #ifdef BINT_STATS_TRACK cases for better
49 * readability.
50 *
51 * Hydra_Software_Devel/21   4/5/05 7:13p albertl
52 * PR10596:  Added new statistics tracking functionality.
53 *
54 * Hydra_Software_Devel/20   4/16/04 5:08p marcusk
55 * PR10666: Merged from B0 branch to keep API compatible.
56 *
57 * Hydra_Software_Devel/Refsw_Devel_7038_B0/2   4/16/04 4:55p marcusk
58 * PR10666: Do not clear interrupts when enabling and added
59 * BINT_ClearCallback() routines.
60 *
61 * Hydra_Software_Devel/19   12/29/03 3:58p marcusk
62 * PR9117: Updated with changes required to support interrupt ids rather
63 * than strings.
64 *
65 * Hydra_Software_Devel/18   12/1/03 4:52p jasonh
66 * Added documentation for interrupt clearing.
67 *
68 * Hydra_Software_Devel/17   9/16/03 10:30a marcusk
69 * Updated to comply with DocJet requirements. Fixes for PR8055.
70 *
71 * Hydra_Software_Devel/16   8/13/03 1:28p marcusk
72 * Added naming convention note.
73 *
74 * Hydra_Software_Devel/15   6/18/03 3:25p dlwin
75 * Updated comments.
76 *
77 * Hydra_Software_Devel/14   6/11/03 3:07p marcusk
78 * Updated verbage to include only standarized L2 interrupt registers.
79 *
80 * Hydra_Software_Devel/13   4/2/03 10:39a marcusk
81 * Updated to support flag to specify if the interrupt can be triggered by
82 * the CPU.
83 *
84 * Hydra_Software_Devel/11   3/31/03 1:11p marcusk
85 * Clarified some comments.
86 *
87 * Hydra_Software_Devel/10   3/21/03 6:30p marcusk
88 * Minor updates.
89 *
90 * Hydra_Software_Devel/9   3/19/03 4:57p marcusk
91 * Added int value parameter that is returned when an interrupt triggers.
92 *
93 * Hydra_Software_Devel/8   3/19/03 4:03p marcusk
94 * Removed some spaces from module overview.
95 *
96 * Hydra_Software_Devel/7   3/19/03 4:02p marcusk
97 * Used comments instead of spaces in module overview (twiki test).
98 *
99 * Hydra_Software_Devel/6   3/19/03 3:41p marcusk
100 * Slightly modified comments.
101 *
102 * Hydra_Software_Devel/5   3/19/03 11:20a marcusk
103 * Added module overview.
104 *
105 * Hydra_Software_Devel/4   3/17/03 9:06a marcusk
106 * Updated with const strings and removed un-needed typedef.
107 *
108 * Hydra_Software_Devel/3   3/13/03 3:22p marcusk
109 * Added a couple new function and updated comments.
110 *
111 * Hydra_Software_Devel/2   3/13/03 2:45p marcusk
112 * Updated comments.
113 *
114 * Hydra_Software_Devel/1   3/11/03 5:42p marcusk
115 * Initial version.
116 *
117 ***************************************************************************/
118
119/*= Module Overview *********************************************************
120
121The InterruptInterface is used to provide an abstraction that can be
122used by software modules to provide the following functionality for
123various L2 interrupts found in the system:
124
125        1 Assign ISR callback routines to specific interrupts.
126                * Multiple callbacks can be installed for a single interrupt.
127        2 Enable and disable callbacks.
128                * The InterruptInterface will only manage L2 interrupt registers and
129              will not touch bits that are not enabled through the exposed interface.
130                  This allows platform specific code to "share" L1 interrupt bits between
131                  platform specific code and the interrupt interface.
132                * The implementation of the InterruptInterface will automatically
133              mask the L2 hardware interrupt when all callbacks using that specific
134                  interrupt bit have been disabled.  Likewise it will un-mask an L2
135                  interrupt when one or more callbacks are enabled for a specific interrupt.
136        3 Trigger an interrupt (software controlled and if hardware supports it).
137        4 Uses interrupt names to specify specific interrupt (calling modules do
138      not need to know the layout of each interrupt bit, only the standard
139          name of the interrupt).
140                * Strings are used to identify interrupts which allows code to select
141              the proper interrupt when multiple instances of an interrupt exist.
142                  This is easily be accomplished through [[KernelInterface][BKNI_Snprintf]]
143                  that allows a number value to be inserted into a string.
144        5 To support various L2 implementations that may appear on a system
145          (ie, Bcm7028 and Bcm3250 chip in one system), the board/chip-specific code
146          must be provide functions to set/clear interrupts,
147          set/clear interrupt masks,  and process L2 interrupt.
148
149*Interrupt Naming Convention*
150
151The following naming convention should be used when defining interrupt
152names:
153
154BXXX_INTERRUPT_NAME
155
156Where BXXX is the PortingInterface module that owns the interrupt.
157
158***************************************************************************/
159
160#ifndef BINT_H
161#define BINT_H
162
163#include "bstd.h"
164
165#ifdef __cplusplus
166extern "C" {
167#endif
168
169/*
170Summary:
171The BINT_Id typedef specifies the ID an interrupt.
172
173Description:
174Each BINT_Id value corresponds to one bit in an L2 interrupt register.
175The value of BINT_Id contains both the L2 register address and the shift value for the interrupt bit in that L2 in a packed format.
176Use the BCHP_INT_ID_CREATE macro (see bchp.h) to build a BINT_Id value.
177*/
178typedef uint32_t BINT_Id;
179
180/*
181Summary:
182This structure defines an opaque handle that is used for InterruptInterface function calls.
183*/
184typedef struct BINT_P_Context *BINT_Handle;
185
186/*
187Summary:
188This structure defines an opaque handle that is used for InterruptInterface function calls.
189*/
190typedef struct BINT_P_Callback *BINT_CallbackHandle;
191
192/*
193Summary:
194This defines the function prototype that is used for InterruptInterface callbacks.
195*/
196typedef void (*BINT_CallbackFunc)( void * pParm1, int parm2 );
197
198/*
199Summary:
200This function creates a callback.
201
202Description:
203After this function is used to create a callback, the BINT_EnableCallback()
204function must be used before the callback will actually be enabled.  When
205the specified interrupt triggers, the func specified will be called with the
206pParm passed into this function.
207
208The first time an callback is created for a specific interrupt, the interrupt
209status will be cleared.
210*/
211BERR_Code BINT_CreateCallback(
212                                                          BINT_CallbackHandle *pCbHandle, /* [out] Returns handle */
213                                                          BINT_Handle handle, /* [in] InterruptInterface handle */
214                                                          BINT_Id intId, /* [in] Id of the interrupt to associate with callback function */
215                                                          BINT_CallbackFunc func, /* [in] Callback function that should be called when the specified interrupt triggers */
216                                                          void * pParm1, /* [in] Parameter that is returned to callback function when interrupt triggers */
217                                                          int parm2 /* [in] Parameter that is returned to callback function when interrupt triggers */
218                                                          );
219
220/*
221Summary:
222This function destroys a callback and frees any resources associated
223with the callback.
224
225Description:
226If the specified callback is enabled when this function is called, the
227callback may be called at any time until this function returns.
228*/
229BERR_Code BINT_DestroyCallback(
230                                                           BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
231                                                           );
232
233/*
234Summary:
235This function enables a callback.
236
237Description:
238The callback may be called any number of times before this function returns!
239*/
240BERR_Code BINT_EnableCallback(
241                                                          BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
242                                                          );
243
244/*
245Summary:
246This function enables a callback in ISR context.
247
248Description:
249The callback may be called any number of times before this function returns!
250*/
251BERR_Code BINT_EnableCallback_isr(
252                                                                  BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
253                                                                  );
254
255/*
256Summary:
257This function disables a callback.
258
259Description:
260The callback may be called at any time until the function returns.
261*/
262BERR_Code BINT_DisableCallback(
263                                                           BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
264                                                           );
265
266
267/*
268Summary:
269This function disables a callback in ISR context.
270
271Description:
272The callback may be called at any time until the function returns.
273*/
274BERR_Code BINT_DisableCallback_isr(
275                                                                   BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
276                                                                   );
277
278/*
279Summary:
280This functions clears a pending interrupt specified by the callback.
281
282Description:
283The interrupt will only be cleared if there are no callbacks currently
284enabled for the interrupt associated with the specified callback.
285*/
286BERR_Code BINT_ClearCallback(
287                                                          BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
288                                                          );
289
290/*
291Summary:
292This functions clears a pending interrupt specified by the callback.
293
294Description:
295The interrupt will only be cleared if there are no callbacks currently
296enabled for the interrupt associated with the specified callback.
297*/
298BERR_Code BINT_ClearCallback_isr(
299                                                          BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
300                                                          );
301
302/*
303Summary:
304This function triggers a hardware interrupt.
305
306Description:
307The interrupt triggers the hardware specified by the BINT_CallbackHandle.
308The callback handle is used directly trigger the interrupt.
309
310Interrupts must be flagged as CPU trigger-able before this function will allow the interrupt
311to be triggered (this flag exists in the BINT_P_intDef structure).  This allows specific
312platforms and environments to prevent software from triggering interrupts they should not be.
313*/
314BERR_Code BINT_TriggerInterruptByHandle(
315                                                                BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
316                                                                );
317
318/*
319Summary:
320This function triggers a hardware interrupt.
321
322Description:
323The interrupt triggers the hardware specified by the BINT_CallbackHandle.
324The callback handle is used directly trigger the interrupt.
325
326Interrupts must be flagged as CPU trigger-able before this function will allow the interrupt
327to be triggered (this flag exists in the BINT_P_intDef structure).  This allows specific
328platforms and environments to prevent software from triggering interrupts they should not be.
329*/
330BERR_Code BINT_TriggerInterruptByHandle_isr(
331                                                                        BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
332                                                                        );
333
334/*
335Summary:
336Gets the first registered callback.
337
338Description:
339Gets the first callback handle stored in the INT module. used with BINT_GetCallbackNext
340to traverse through all installed callbacks.
341*/
342BINT_CallbackHandle BINT_GetCallbackFirst(
343                                                                                  BINT_Handle intHandle /* [in] Interrupt handle */
344                                                                                  );
345
346/*
347Summary:
348Gets the next registered callback.
349
350Description:
351Returns the next callback handle after cbHandle. Order of callbacks returned is in
352order of callback creation.
353*/
354BINT_CallbackHandle BINT_GetCallbackNext(
355                                                                                 BINT_CallbackHandle cbHandle /* [in] Callback handle returned by BINT_CreateCallback() */
356                                                                                 );
357/*
358Summary:
359Gets the interrupt ID for this callback.
360
361Description:
362Returns the interrupt ID for the specific callback in pIntId. Used with the above
363traversal functions to identify a callback hooked to a specific interrupt.
364*/
365BERR_Code BINT_GetInterruptId(
366                                                          BINT_CallbackHandle cbHandle, /* [in] Callback handle returned by BINT_CreateCallback() */
367                                                          BINT_Id *pIntId /* [out] Pointer to storage for the interrupt ID */
368                                                          );
369
370/*
371Summary:
372Gets callback's active status.
373
374Description:
375Gets the status of a callback and returns whether it is active or not in pbEnabled.
376*/
377BERR_Code BINT_GetCallbackStatus(
378                                                                 BINT_CallbackHandle cbHandle,  /* [in] Callback handle returned by BINT_CreateCallback() */
379                                                                 bool *pbEnabled /* [out] Pointer to storage for the callback's active status */
380                                                                 );
381
382/*
383Summary:
384This function outputs statistics of the interrupt interface.
385
386Description:
387Prints out statistics, using message level debug output and then resets accumulated information.
388*/
389void BINT_DumpInfo(BINT_Handle intHandle);
390#if BDBG_DEBUG_BUILD
391/* {secret} */
392BERR_Code BINT_P_CreateCallback_Tag(
393                                                          BINT_CallbackHandle *pCbHandle,
394                                                          BINT_Handle handle,
395                                                          BINT_Id intId,
396                                                          BINT_CallbackFunc func,
397                                                          void * pParm1,
398                                                          int parm2,
399                                                          const char *callbackName
400                                                          );
401#define BINT_CreateCallback(cbh, h, id, f, p1, p2) BINT_P_CreateCallback_Tag((cbh), (h), (id), (f), (p1), (p2), #f)
402#endif
403
404#ifdef __cplusplus
405}
406#endif
407
408#endif
409/* End of File */
410
411
412
Note: See TracBrowser for help on using the repository browser.