comparison src/cs/layer1/cust0/ind_os.c @ 0:4e78acac3d88

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