tizen 2.4 release
[kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8810 / int_hisr.h
1 /******************************************************************************
2  ** File Name:    int_hisr.h                                             *
3  ** Author:       Steve.Zhan                                                  *
4  ** DATE:         06/29/2010                                                  *
5  ** Copyright:    2010 Spreatrum, Incoporated. All Rights Reserved.           *
6  ** Description:                                                              *
7  ******************************************************************************/
8 /******************************************************************************
9  **                   Edit    History                                         *
10  **---------------------------------------------------------------------------*
11  ** DATE                   NAME               DESCRIPTION                     *
12  ** 06/29/2010         Steve.Zhan       Create.                               *
13  ******************************************************************************/
14 #ifndef __INT_HISR_H__
15 #define __INT_HISR_H__
16
17 #include "os_api.h"
18 #include "isr_drvapi.h"
19
20 /*----------------------------------------------------------------------------*
21  **                         Dependencies                                      *
22  **------------------------------------------------------------------------- */
23
24 /**---------------------------------------------------------------------------*
25  **                             Compiler Flag                                 *
26  **--------------------------------------------------------------------------*/
27 #ifdef   __cplusplus
28 extern   "C"
29 {
30 #endif
31
32 /**---------------------------------------------------------------------------*
33 **                               Micro Define                                **
34 **---------------------------------------------------------------------------*/
35 /*****************************************************************************/
36 //  Description:    Circular Buffer Function MACROS..
37 //  Is used to hold characters that arrive before the application is ready for them
38 //  Author:         steve.zhan
39 //  Note:  Use these three MACROS together..
40 /*****************************************************************************/
41 #define INPUT_BUFFER_INIT(VALUE_TYPE, _MAX_SIZE)\
42     static VALUE_TYPE input_buffer[_MAX_SIZE]; \
43     static VALUE_TYPE*  input_write_ptr  = &input_buffer[0];\
44     static VALUE_TYPE*  input_read_ptr = &input_buffer[0];\
45     static int MaxSize = _MAX_SIZE; \
46     LOCAL void IsrWriteBuffer(VALUE_TYPE value) \
47     { \
48         VALUE_TYPE *save_ptr = input_write_ptr; \
49         *input_write_ptr++ = value; \
50         if (input_write_ptr > &input_buffer[MaxSize-1]) \
51             input_write_ptr = &input_buffer[0]; \
52         if (input_write_ptr == input_read_ptr) \
53             input_write_ptr = save_ptr; \
54     } \
55     LOCAL BOOLEAN threadReadBuffer(VALUE_TYPE* value) \
56     { \
57         if (input_read_ptr != input_write_ptr) \
58         { \
59             *value = *input_read_ptr++; \
60             if (input_read_ptr > &input_buffer[MaxSize-1]) \
61                 input_read_ptr = &input_buffer[0]; \
62             return FALSE; \
63         } \
64         return TRUE; \
65     }
66
67 /**----------------------------------------------------------------------------*
68 **                         Local Function Prototype                           **
69 **----------------------------------------------------------------------------*/
70
71 typedef enum
72 {
73     CHIPDRV_HISR_START_ID = 0x50,
74     CHIPDRV_HISR_0,
75     CHIPDRV_HISR_1,
76     CHIPDRV_HISR_2,
77     CHIPDRV_HISR_3,
78
79     
80     CHIPDRV_HISR_LAST_ID
81
82 } CHIPDRV_HISR_ID_E;
83
84
85 typedef struct Hisr_T
86 {
87     hisr_func_t            *hisr_func;
88     void                   *data;
89     CHIPDRV_HISR_PRI_E     pri;
90     
91     struct Hisr_T* volatile  next_hisr;
92     volatile uint32          hisr_count;
93 } Hisr_T;
94
95 /**----------------------------------------------------------------------------*
96 **                           Function Prototype                               **
97 **----------------------------------------------------------------------------*/
98
99 /*****************************************************************************/
100 // Description :    This function is used to create HISR
101 // Global resource dependence :
102 // Author : steve.zhan
103 // Note :
104 /*****************************************************************************/
105 PUBLIC void CHIPDRVHISR_Create (const uint8 *HisrName, CHIPDRV_HISR_ID_E ThreadId, void (*entry) (uint32, void *),
106                                 CHIPDRV_HISR_PRI_E Priority, int queueNum);
107
108
109 /*****************************************************************************/
110 // Description :    This function is used in task to get semaphore.
111 // Global resource dependence :
112 // Author : steve.zhan
113 // Note :
114 /*****************************************************************************/
115 PUBLIC  uint32  CHIPDRVHISR_WaitActive (CHIPDRV_HISR_ID_E ThreadId);
116
117
118 /*****************************************************************************/
119 // Description :    This function is used to activate the HISR to process some 
120 //                  Delay isr things.
121 // Global resource dependence :
122 // Author : steve.zhan
123 // Note :
124 /*****************************************************************************/
125 PUBLIC void CHIPDRVHISR_Activate (CHIPDRV_HISR_ID_E ThreadId);
126
127
128
129 /*****************************************************************************/
130 // Description :    This function Init Hisr data struct.                  
131 // Global resource dependence :
132 // Author : steve.zhan
133 // Note :
134 /*****************************************************************************/
135 PUBLIC void Hisr_init(void);
136
137
138 /*****************************************************************************/
139 // Description :    Invoked by ISR.
140 // Global resource dependence :
141 // Author : steve.zhan
142 // Note :
143 /*****************************************************************************/
144 PUBLIC void Hisr_put(int Intpri);
145
146
147
148 /*****************************************************************************/
149 // Description :    Invokedy by interrupt module, register Hisr callback 
150 //                  function and the priority to HISR.
151 // Global resource dependence :
152 // Author : steve.zhan
153 // Note :
154 /*****************************************************************************/
155 PUBLIC uint32 Hisr_RegHandler (
156                                      uint32 priIndex,
157                                      hisr_func_t *pHisrFunc,
158                                      CHIPDRV_HISR_PRI_E hisrPri,
159                                      void *            pHisrData
160 );
161
162 /**----------------------------------------------------------------------------*
163 **                         Compiler Flag                                      **
164 **----------------------------------------------------------------------------*/
165 #ifdef   __cplusplus
166 }
167 #endif
168 /**---------------------------------------------------------------------------*/
169 #endif
170 // End
171