comparison gsm-fw/L1/cust1/ind_os.c @ 517:eafadfee35b2

gsm-fw/L1/cust?: imported Leonardo, LoCosto and MV100 versions
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 10 Jul 2014 03:43:04 +0000
parents
children
comparison
equal deleted inserted replaced
516:78495749970a 517:eafadfee35b2
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 (L1_MP3 == 1)
29 #include "l1mp3_defty.h"
30 #endif
31
32 #if (L1_MIDI == 1)
33 #include "l1midi_defty.h"
34 #endif
35
36 //#if ((ANALOG == 1) || (ANALOG == 2))
37 // #include "spi_drv.h"
38 //#endif
39
40 #if TESTMODE
41 #include "l1tm_defty.h"
42 #endif
43
44 #include "l1audio_const.h"
45 #include "l1audio_cust.h"
46 #include "l1audio_defty.h"
47 #if (L1_MP3 == 1)
48 #include "l1mp3_defty.h"
49 #endif
50 #if (L1_MIDI == 1)
51 #include "l1midi_defty.h"
52 #endif
53 #include "l1_defty.h"
54 #include "l1_msgty.h"
55 #include "l1_varex.h"
56
57 #if (CHIPSET == 2 || CHIPSET == 3 || CHIPSET == 4 || CHIPSET == 5 || CHIPSET == 6 || CHIPSET == 7 || CHIPSET == 8 || CHIPSET == 10 || CHIPSET == 11 || CHIPSET == 12) || (CHIPSET == 15)
58 #include "ulpd.h"
59 #endif
60
61 extern UWORD32 TCD_Priority_Groups;
62 extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES];
63 extern VOID *TCD_Current_Thread;
64 extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES];
65 extern INT TMD_Timer_State;
66 extern UWORD32 TMD_Timer; // for big sleep
67 extern TC_PROTECT TCD_System_Protect;
68
69
70 /*-------------------------------------------------------*/
71 /* int ind_os_sleep() */
72 /*-------------------------------------------------------*/
73 /* Parameters : none */
74 /* Return : */
75 /* Functionality : Suspend the thread an interval */
76 /* of millisecs. */
77 /* Limitation : */
78 /*-------------------------------------------------------*/
79
80 T_OS_RETURN ind_os_sleep (SYS_UWORD32 millisecs)
81 {
82 NU_Sleep ((SYS_UWORD32) millisecs);
83 return OS_OK;
84 }
85
86
87 /*-------------------------------------------------------*/
88 /* int OS_get_inactivity_ticks() */
89 /*-------------------------------------------------------*/
90 /* Parameters : none */
91 /* Return : Number of ticks of inactivity */
92 /* 0 means immediate activity planned */
93 /* -1 means no activity planned */
94 /* Functionality : Evaluates the OS activity planned */
95 /* by looking at ready tasks, activated */
96 /* HISR and the elapsed time of the timers*/
97 /* Limitation : Must be protected from H/W interrupts */
98 /*-------------------------------------------------------*/
99 int OS_get_inactivity_ticks(void)
100 {
101 #if (CODE_VERSION != SIMULATION)
102 int i;
103
104 // Returns immediate activity if a task is ready
105 if (TCD_Priority_Groups)
106 return 0;
107
108 //for all HISR priorities
109 for (i = 0; i < TC_HISR_PRIORITIES ; i++)
110 {
111 // if no hisr of priority "i" ==> go to next priority
112 if (TCD_Active_HISR_Heads[i] == 0)
113 continue;
114
115 // the first hisr is NOT the current one (frame hisr) so it may be
116 // with other priority ==> abort
117 if (TCD_Active_HISR_Heads[i] != TCD_Current_Thread)
118 return 0;
119
120 // the last hisr is NOT the current one (frame hisr) so there is
121 // at least another hisr with same priority ==> abort
122 if (TCD_Active_HISR_Tails[i] != TCD_Current_Thread)
123 return 0;
124
125 // the first and last hisrs are the current one (frame hisr) but
126 // there are several occurences of it ! ==> abort
127 if ( (TCD_Active_HISR_Heads[i]->tc_activation_count != 1))
128 return 0;
129 }
130
131 // Returns remaining ticks number if any timer is active
132 if (TMD_Timer_State == TM_ACTIVE) // any active timer ?
133 return TMD_Timer;
134
135 // Returns not activity if no timer active
136 else if (TMD_Timer_State == TM_NOT_ACTIVE)
137 return -1;
138 else
139 // otherwise, returns immediate activity if a timer is expired (TM_EXPIRED)
140 return(0);
141 #else // Simulation part
142 // the L3 simulator return the FN for the next L3 message
143 UWORD32 time;
144 time = (next_message_FN() - l1s.debug_time + MAX_FN)% MAX_FN;
145 return(time);
146 #endif
147 }
148
149 /*-------------------------------------------------------*/
150 /* int OS_system_protect() */
151 /*-------------------------------------------------------*/
152 /* Parameters : none */
153 /* Return : The Thread Control Block of the thread */
154 /* which already owns the protection or */
155 /* 0 if no protection */
156 /* Functionality : Checks whether the system structures */
157 /* are already protected or not */
158 /*-------------------------------------------------------*/
159 void OS_system_protect (void)
160 {
161 NU_Protect((NU_PROTECT*) &TCD_System_Protect);
162 }
163
164 /*-------------------------------------------------------*/
165 /* int OS_system_Unprotect() */
166 /*-------------------------------------------------------*/
167 /* Parameters : none */
168 /* Return : */
169 /* Functionality : unprotect the system structures */
170 /*-------------------------------------------------------*/
171 void OS_system_Unprotect (void)
172 {
173 NU_Unprotect();
174 }