FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/gpf/osl/os_pro_ir.c @ 345:460ed6748e4c
OSL: os_pro_ir.c done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 07 May 2014 18:45:50 +0000 |
parents | c51d6b3748c3 |
children | fdeea3d6582d |
rev | line source |
---|---|
343
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This C module is a reconstruction based on the disassembly of |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * os_pro.obj in frame_na7_db_ir.lib from the Leonardo package. |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 /* set of included headers from COFF symtab: */ |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include "gpfconf.h" /* FreeCalypso addition */ |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "../../nucleus/nucleus.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "typedefs.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "os.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "gdi.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "os_types.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "os_glob.h" |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 typedef unsigned char u_char; |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 extern VOID *TCD_Current_Thread; |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 extern T_OS_TASK_TABLE_ENTRY TaskTable[]; |
344
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
21 extern unsigned os_time_to_tick_multiplier; |
343
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
345
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
23 #define OS_NU_TASK_MAGIC 0xdeafbeef |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
24 |
343
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 VOID |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 os_TaskEntry(UNSIGNED TaskHandle, VOID *argv) |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 { |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 TaskTable[TaskHandle].TaskEntry(TaskHandle, 0); |
e3a2e6e875de
OSL reconstruction: beginning of os_pro_ir.c
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 } |
344
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
30 |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
31 GLOBAL LONG |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
32 os_SuspendTask(OS_HANDLE Caller, ULONG Time) |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
33 { |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
34 UNSIGNED SuspendTicks; |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
35 |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
36 SuspendTicks = TIME_TO_SYSTEM_TICKS(Time); |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
37 if (!SuspendTicks) |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
38 SuspendTicks = 1; |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
39 NU_Sleep(SuspendTicks); |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
40 return (OS_OK); |
c51d6b3748c3
OSL: os_SuspendTask() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
343
diff
changeset
|
41 } |
345
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
42 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
43 GLOBAL LONG |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
44 os_ResumeTask(OS_HANDLE task_handle) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
45 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
46 if (NU_Resume_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
47 return(OS_OK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
48 else |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
49 return(OS_ERROR); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
50 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
51 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
52 GLOBAL LONG |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
53 os_Relinquish(void) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
54 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
55 NU_Relinquish(); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
56 return(OS_OK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
57 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
58 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
59 GLOBAL OS_HANDLE |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
60 os_MyHandle(void) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
61 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
62 OS_NU_TASK *os_nu_task = (OS_NU_TASK *) TCD_Current_Thread; |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
63 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
64 if (os_nu_task && os_nu_task->magic_nr == OS_NU_TASK_MAGIC) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
65 return(os_nu_task->handle); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
66 else |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
67 return(OS_NOTASK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
68 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
69 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
70 GLOBAL LONG |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
71 os_GetTaskName(OS_HANDLE Caller, OS_HANDLE TaskHandle, char *Name) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
72 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
73 if (TaskHandle) { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
74 if (TaskHandle > MaxTasks || !TaskTable[TaskHandle].Name[0]) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
75 return(OS_ERROR); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
76 strcpy(Name, TaskTable[TaskHandle].Name); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
77 } else if (TCD_Current_Thread) { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
78 NU_TASK *curtask = TCD_Current_Thread; |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
79 strcpy(Name, curtask->tc_name); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
80 } else |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
81 strcpy(Name, "ROOT"); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
82 return(OS_OK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
83 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
84 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
85 GLOBAL LONG |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
86 os_DeferTask(OS_HANDLE task_handle, OS_TIME time) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
87 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
88 if (NU_Suspend_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
89 return(OS_OK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
90 else |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
91 return(OS_ERROR); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
92 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
93 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
94 GLOBAL LONG |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
95 os_CheckTaskStack(OS_HANDLE Handle) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
96 { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
97 register void *sp asm("sp"); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
98 |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
99 if (*TaskTable[Handle].Stack != GUARD_PATTERN) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
100 return(OS_ERROR); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
101 if (TCD_Current_Thread) { |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
102 NU_TASK *curtask = TCD_Current_Thread; |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
103 if (sp < curtask->tc_stack_start) |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
104 return(OS_ERROR); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
105 } |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
106 return(OS_OK); |
460ed6748e4c
OSL: os_pro_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
344
diff
changeset
|
107 } |