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