FreeCalypso > hg > fc-magnetite
annotate src/gpf2/osl/os_pro_ir.c @ 673:62a5285e014a
Lorekeeping: allow tpudrv-leonardo.lib on Leonardo/Tango
Back in 2015 the Mother's idea was to produce a FreeCalypso development
board that would be a clone of TI Leonardo, including the original
quadband RFFE; one major additional stipulation was that this board
needed to be able to run original unmodified TCS211-20070608 firmware
with all blobs intact, with only minimal binary patches to main.lib
and tpudrv.lib. The necessary patched libs were produced at that time
in the tcs211-patches repository.
That plan was changed and we produced FCDEV3B instead, with Openmoko's
triband RFFE instead of Leonardo quadband, but when FC Magnetite started
in 2016, a TPUDRV_blob= provision was still made, allowing the possibility
of patching OM's tpudrv.lib for a restored Leonardo RFFE.
Now in 2020 we have FC Tango which is essentially a verbatim clone of
Leonardo core, including the original quadband RFFE. We have also
deblobbed our firmware so much that we have absolutely no real need
for a blob version of tpudrv.lib - but I thought it would be neat to put
the ancient TPUDRV_blob= mechanism (classic config) to its originally
intended use, just for the heck of it.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 29 May 2020 03:55:36 +0000 |
parents | dfa8771e84b1 |
children |
rev | line source |
---|---|
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C module is a reconstruction based on the disassembly of |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * os_pro.obj in frame_na7_db_ir.lib from the Leonardo package. |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 /* set of included headers from COFF symtab: */ |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
498
dfa8771e84b1
OSL: os_pro_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
9 #include "nucleus.h" |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "typedefs.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "os.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "gdi.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "os_types.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "os_glob.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern VOID *TCD_Current_Thread; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern T_OS_TASK_TABLE_ENTRY TaskTable[]; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern unsigned os_time_to_tick_multiplier; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #define OS_NU_TASK_MAGIC 0xdeafbeef |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 VOID |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 os_TaskEntry(UNSIGNED TaskHandle, VOID *argv) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 TaskTable[TaskHandle].TaskEntry(TaskHandle, 0); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 os_SuspendTask(OS_HANDLE Caller, ULONG Time) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 UNSIGNED SuspendTicks; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 SuspendTicks = TIME_TO_SYSTEM_TICKS(Time); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (!SuspendTicks) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 SuspendTicks = 1; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 NU_Sleep(SuspendTicks); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return (OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 os_ResumeTask(OS_HANDLE task_handle) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (NU_Resume_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 else |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 os_Relinquish(void) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 NU_Relinquish(); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 GLOBAL OS_HANDLE |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 os_MyHandle(void) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 OS_NU_TASK *os_nu_task = (OS_NU_TASK *) TCD_Current_Thread; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 if (os_nu_task && os_nu_task->magic_nr == OS_NU_TASK_MAGIC) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 return(os_nu_task->handle); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 else |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 return(OS_NOTASK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 os_GetTaskName(OS_HANDLE Caller, OS_HANDLE TaskHandle, char *Name) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (TaskHandle) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (TaskHandle > MaxTasks || !TaskTable[TaskHandle].Name[0]) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 strcpy(Name, TaskTable[TaskHandle].Name); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } else if (TCD_Current_Thread) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 NU_TASK *curtask = TCD_Current_Thread; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 strcpy(Name, curtask->tc_name); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } else |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 strcpy(Name, "ROOT"); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 os_DeferTask(OS_HANDLE task_handle, OS_TIME time) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 if (NU_Suspend_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 else |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 os_CheckTaskStack(OS_HANDLE Handle) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 { |
498
dfa8771e84b1
OSL: os_pro_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
94 #ifdef __GNUC__ |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 register void *sp asm("sp"); |
498
dfa8771e84b1
OSL: os_pro_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
96 #endif |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 if (*TaskTable[Handle].Stack != GUARD_PATTERN) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 return(OS_ERROR); |
498
dfa8771e84b1
OSL: os_pro_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
100 #ifdef __GNUC__ |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 if (TCD_Current_Thread) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 NU_TASK *curtask = TCD_Current_Thread; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 if (sp < curtask->tc_stack_start) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
498
dfa8771e84b1
OSL: os_pro_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
106 #endif |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |