comparison L1/cust0/ind_os.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * IND_OS.C
4 *
5 * Filename ind_os.c
6 * Version 1.1
7 * Date 04/26/00
8 *
9 ************* Revision Controle System Header *************/
10
11 #include "../../include/config.h"
12
13 // Nucleus include files.
14 #include "../../nucleus/nucleus.h"
15 #include "../../nucleus/tc_defs.h"
16 #include "../../include/sys_types.h"
17 #include "ind_os.h"
18
19 #include "l1_confg.h"
20 // Layer1 and debug include files.
21 #include "l1_types.h"
22 #include "l1_const.h"
23
24 #if (L1_GTT == 1)
25 #include "l1gtt_const.h"
26 #include "l1gtt_defty.h"
27 #endif
28
29 /* the newer LoCosto cust1 version has these lines commented out */
30 //#if ((ANALOG == 1) || (ANALOG == 2))
31 // #include "spi_drv.h"
32 //#endif
33
34 #if TESTMODE
35 #include "l1tm_defty.h"
36 #endif
37
38 #include "l1audio_const.h"
39 #include "l1audio_cust.h"
40 #include "l1audio_defty.h"
41 #include "l1_defty.h"
42 #include "l1_msgty.h"
43 #include "l1_varex.h"
44
45 #if (CHIPSET == 2 || CHIPSET == 3 || CHIPSET == 4 || CHIPSET == 5 || CHIPSET == 6 || CHIPSET == 7 || CHIPSET == 8 || CHIPSET == 10 || CHIPSET == 11 || CHIPSET == 12)
46 #include "../../bsp/ulpd.h"
47 #endif
48
49 extern UWORD32 TCD_Priority_Groups;
50 extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES];
51 extern VOID *TCD_Current_Thread;
52 extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES];
53 extern INT TMD_Timer_State;
54 extern UWORD32 TMD_Timer; // for big sleep
55 extern TC_PROTECT TCD_System_Protect;
56
57
58 /*-------------------------------------------------------*/
59 /* int ind_os_sleep() */
60 /*-------------------------------------------------------*/
61 /* Parameters : none */
62 /* Return : */
63 /* Functionality : Suspend the thread an interval */
64 /* of millisecs. */
65 /* Limitation : */
66 /*-------------------------------------------------------*/
67
68 T_OS_RETURN ind_os_sleep (SYS_UWORD32 millisecs)
69 {
70 NU_Sleep ((SYS_UWORD32) millisecs);
71 return OS_OK;
72 }
73
74
75 /*-------------------------------------------------------*/
76 /* int OS_get_inactivity_ticks() */
77 /*-------------------------------------------------------*/
78 /* Parameters : none */
79 /* Return : Number of ticks of inactivity */
80 /* 0 means immediate activity planned */
81 /* -1 means no activity planned */
82 /* Functionality : Evaluates the OS activity planned */
83 /* by looking at ready tasks, activated */
84 /* HISR and the elapsed time of the timers*/
85 /* Limitation : Must be protected from H/W interrupts */
86 /*-------------------------------------------------------*/
87 int OS_get_inactivity_ticks(void)
88 {
89 int i;
90
91 // Returns immediate activity if a task is ready
92 if (TCD_Priority_Groups)
93 return 0;
94
95 //for all HISR priorities
96 for (i = 0; i < TC_HISR_PRIORITIES ; i++)
97 {
98 // if no hisr of priority "i" ==> go to next priority
99 if (TCD_Active_HISR_Heads[i] == 0)
100 continue;
101
102 // the first hisr is NOT the current one (frame hisr) so it may be
103 // with other priority ==> abort
104 if (TCD_Active_HISR_Heads[i] != TCD_Current_Thread)
105 return 0;
106
107 // the last hisr is NOT the current one (frame hisr) so there is
108 // at least another hisr with same priority ==> abort
109 if (TCD_Active_HISR_Tails[i] != TCD_Current_Thread)
110 return 0;
111
112 // the first and last hisrs are the current one (frame hisr) but
113 // there are several occurences of it ! ==> abort
114 if ( (TCD_Active_HISR_Heads[i]->tc_activation_count != 1))
115 return 0;
116 }
117
118 // Returns remaining ticks number if any timer is active
119 if (TMD_Timer_State == TM_ACTIVE) // any active timer ?
120 {
121 if (TMD_Timer <= MIN_SLEEP_TIME)
122 return(0);
123 else
124 return TMD_Timer;
125 }
126
127 // Returns not activity if no timer active
128 if (TMD_Timer_State == TM_NOT_ACTIVE)
129 return -1;
130 else
131 // otherwise, returns immediate activity if a timer is expired (TM_EXPIRED)
132 return(0);
133 }
134
135 /*-------------------------------------------------------*/
136 /* int OS_system_protect() */
137 /*-------------------------------------------------------*/
138 /* Parameters : none */
139 /* Return : The Thread Control Block of the thread */
140 /* which already owns the protection or */
141 /* 0 if no protection */
142 /* Functionality : Checks whether the system structures */
143 /* are already protected or not */
144 /*-------------------------------------------------------*/
145 void OS_system_protect (void)
146 {
147 NU_Protect((NU_PROTECT*) &TCD_System_Protect);
148 }
149
150 /*-------------------------------------------------------*/
151 /* int OS_system_Unprotect() */
152 /*-------------------------------------------------------*/
153 /* Parameters : none */
154 /* Return : */
155 /* Functionality : unprotect the system structures */
156 /*-------------------------------------------------------*/
157 void OS_system_Unprotect (void)
158 {
159 NU_Unprotect();
160 }