FreeCalypso > hg > leo2moko-debug
comparison gpf/INC/os.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +------------------------------------------------------------------------------ | |
3 | File: os.h | |
4 +------------------------------------------------------------------------------ | |
5 | Copyright 2002 Texas Instruments Berlin, AG | |
6 | All rights reserved. | |
7 | | |
8 | This file is confidential and a trade secret of Texas | |
9 | Instruments Berlin, AG | |
10 | The receipt of or possession of this file does not convey | |
11 | any rights to reproduce or disclose its contents or to | |
12 | manufacture, use, or sell anything it may describe, in | |
13 | whole, or in part, without the specific written consent of | |
14 | Texas Instruments Berlin, AG. | |
15 +----------------------------------------------------------------------------- | |
16 | Purpose : Definitions for the OS adaptation layer. | |
17 +----------------------------------------------------------------------------- | |
18 */ | |
19 | |
20 #ifndef __OS_H__ | |
21 #define __OS_H__ | |
22 | |
23 #include "os_const.h" | |
24 | |
25 /*==== CONSTANTS ===================================================*/ | |
26 typedef int OS_HANDLE; | |
27 typedef BOOL OS_INT_STATE; | |
28 typedef ULONG OS_TIME; | |
29 typedef ULONG OS_TICK; | |
30 | |
31 #define OS_NOTASK 0 | |
32 | |
33 #define FIRST_ENTRY 0xff | |
34 #define NEXT_ENTRY 0xfe | |
35 | |
36 #define OS_EVENT 0x1 | |
37 #define OS_NO_EVENT 0x0 | |
38 /* | |
39 * pattern to initialize task/osisr stacks | |
40 */ | |
41 #define INITIAL_STACK_VALUE 0xfe | |
42 | |
43 /* | |
44 * constants to access the object information functions | |
45 */ | |
46 #define OS_OBJSYS 0 | |
47 #define OS_OBJTASK 1 | |
48 #define OS_OBJQUEUE 2 | |
49 #define OS_OBJPARTITIONGROUP 3 | |
50 #define OS_OBJMEMORYPOOL 4 | |
51 #define OS_OBJTIMER 5 | |
52 #define OS_OBJSEMAPHORE 6 | |
53 | |
54 /* | |
55 * return values | |
56 */ | |
57 #define OS_OK 0 | |
58 #define OS_WAITED 1 | |
59 #define OS_NEW_PROCESS 2 | |
60 #define OS_PARTITION_FREE 3 | |
61 #define OS_ALLOCATED_BIGGER 4 | |
62 #define OS_ERROR (-1) | |
63 #define OS_TIMEOUT (-2) | |
64 #define OS_PARTITION_GUARD_PATTERN_DESTROYED (-3) | |
65 #define OS_INVALID_QUEUE (-4) | |
66 | |
67 /* | |
68 * message priorities | |
69 */ | |
70 #define OS_NORMAL 1 | |
71 #define OS_URGENT 2 | |
72 #define OS_MIN_PRIORITY OS_NORMAL | |
73 #define OS_MAX_PRIORITY OS_URGENT | |
74 | |
75 /* | |
76 * OS ISR priority range | |
77 */ | |
78 #define OS_ISR_MIN_PRIO 0 | |
79 #define OS_ISR_MAX_PRIO 2 | |
80 | |
81 /* | |
82 * flags | |
83 */ | |
84 #define OS_QFPARTITION 0x01 | |
85 | |
86 /* | |
87 * error codes | |
88 */ | |
89 #define OS_SYST_ERR 0x8000 | |
90 #define OS_SYST_ERR_QUEUE_CREATE 0x8001 | |
91 #define OS_SYST_ERR_MAX_TIMER 0x8002 | |
92 #define OS_SYST_ERR_MAX_TASK 0x8003 | |
93 #define OS_SYST_ERR_STACK_OVERFLOW 0x8004 | |
94 #define OS_SYST_ERR_PCB_PATTERN 0x8005 | |
95 #define OS_SYST_ERR_NO_PARTITION 0x8006 | |
96 #define OS_SYST_ERR_STR_TOO_LONG 0x8007 | |
97 #define OS_SYST_ERR_OVERSIZE 0x8008 | |
98 #define OS_SYST_ERR_TASK_TIMER 0x8009 | |
99 #define OS_SYST_ERR_SIMUL_TIMER 0x800A | |
100 #define OS_SYST_ERR_QUEUE_FULL 0x800B | |
101 #define OS_SYST_ERR_MAX_SEMA 0x800C | |
102 #define OS_SYST_ERR_NO_MEMORY 0x800D | |
103 #define OS_SYST_ERR_BIG_PARTITION 0x800E | |
104 | |
105 /* | |
106 * warning codes | |
107 */ | |
108 #define OS_SYST_WRN 0x0000 | |
109 #define OS_SYST_WRN_WAIT_PARTITION 0x0001 | |
110 #define OS_SYST_WRN_WAIT_QUEUE 0x0002 | |
111 #define OS_SYST_WRN_BIG_PARTITION 0x0003 | |
112 #define OS_SYST_WRN_MULTIPLE_FREE 0x0004 | |
113 #define OS_SYST_WRN_REQ_TRUNCATED 0x0004 | |
114 #define OS_SYST_WRN_FREE_FAILED 0x0005 | |
115 | |
116 /*==== TYPES =======================================================*/ | |
117 | |
118 typedef struct | |
119 { | |
120 USHORT flags; | |
121 USHORT data16; | |
122 ULONG data32; | |
123 #ifdef _TOOLS_ | |
124 ULONG len; | |
125 #endif | |
126 ULONG time; | |
127 LONG e_id; | |
128 T_VOID_STRUCT * ptr; | |
129 } OS_QDATA; | |
130 | |
131 /*==== PROTOTYPES ==================================================*/ | |
132 | |
133 /* Task API */ | |
134 GLOBAL LONG os_CreateTask (OS_HANDLE Caller, char *Name, void (*TaskEntry)(OS_HANDLE, ULONG), ULONG StackSize, | |
135 USHORT Priority, OS_HANDLE *TaskHandle, OS_HANDLE MemPoolHandle); | |
136 GLOBAL LONG os_DestroyTask (OS_HANDLE Caller, OS_HANDLE TaskHandle); | |
137 GLOBAL LONG os_StartTask (OS_HANDLE Caller, OS_HANDLE TaskHandle, ULONG Value); | |
138 GLOBAL LONG os_StopTask (OS_HANDLE Caller, OS_HANDLE TaskHandle); | |
139 GLOBAL LONG os_SuspendTask (OS_HANDLE Caller, ULONG Time); | |
140 GLOBAL LONG os_DeferTask (OS_HANDLE task_handle, OS_TIME time); | |
141 GLOBAL LONG os_ResumeTask (OS_HANDLE task_handle); | |
142 GLOBAL LONG os_Relinquish (void); | |
143 GLOBAL LONG os_GetTaskName (OS_HANDLE Caller, OS_HANDLE TaskHandle, char * Name); | |
144 GLOBAL LONG os_GetTaskHandle (OS_HANDLE Caller, char * Name, OS_HANDLE *TaskHandle); | |
145 GLOBAL LONG os_TaskInformation (USHORT Handle, char *Buffer); | |
146 GLOBAL LONG os_ProInit (void); | |
147 GLOBAL LONG os_ChangePreemption (char preempt); | |
148 GLOBAL OS_HANDLE os_MyHandle (void); | |
149 #ifdef _NUCLEUS_ | |
150 GLOBAL LONG os_CheckTaskStack (OS_HANDLE Handle); | |
151 /* Task internal */ | |
152 GLOBAL LONG os_GetTaskData (OS_HANDLE Handle, unsigned int **tcb, unsigned char **stackbegin, unsigned char **stackend ); | |
153 GLOBAL unsigned char os_GetTaskState (OS_HANDLE Caller, OS_HANDLE Handle); | |
154 #endif | |
155 | |
156 /* Queue API */ | |
157 GLOBAL LONG os_CreateQueue (OS_HANDLE Caller, OS_HANDLE ComHandle, char *Name, USHORT Entries, | |
158 OS_HANDLE *ActHandle, OS_HANDLE MemPoolHandle ); | |
159 GLOBAL LONG os_DestroyQueue (OS_HANDLE Caller, OS_HANDLE ComHandle ); | |
160 GLOBAL LONG os_OpenQueue (OS_HANDLE Caller, char *Name, OS_HANDLE *ComHandle); | |
161 GLOBAL LONG os_CloseQueue (OS_HANDLE Caller, OS_HANDLE ComHandle); | |
162 GLOBAL LONG os_SendToQueue (OS_HANDLE Caller, OS_HANDLE ComHandle, USHORT Priority, | |
163 ULONG Suspend, OS_QDATA *Msg ); | |
164 GLOBAL LONG os_ReceiveFromQueue (OS_HANDLE Caller, OS_HANDLE ComHandle, OS_QDATA *msg, ULONG Timeout ); | |
165 GLOBAL LONG os_GetQueueName (OS_HANDLE Caller, OS_HANDLE ComHandle, char * Name); | |
166 GLOBAL LONG os_GetQueueHandle (OS_HANDLE Caller, char *Name, OS_HANDLE *ComHandle); | |
167 GLOBAL LONG os_QueueInformation (USHORT Handle, char *Buffer); | |
168 GLOBAL LONG os_ComInit (void); | |
169 /* Queue internal */ | |
170 #ifdef _NUCLEUS_ | |
171 GLOBAL LONG os_GetQueueState (OS_HANDLE Caller, OS_HANDLE Handle, ULONG *Used, ULONG *Free); | |
172 GLOBAL unsigned char *os_FindSuspendingQueue (unsigned int *tcb); | |
173 GLOBAL LONG os_GetQueueData (OS_HANDLE Caller, OS_HANDLE Handle, USHORT Index, | |
174 USHORT *Type, ULONG *opc, ULONG *ptr, ULONG *time ); | |
175 #endif | |
176 #ifdef _TOOLS_ | |
177 extern LONG os_create_extq (const char* name, OS_HANDLE* comhandle); | |
178 extern LONG os_destroy_extq (const char* name); | |
179 #endif /* _TOOLS_ */ | |
180 | |
181 /* Memory API */ | |
182 GLOBAL LONG os_CreatePartitionPool (OS_HANDLE Caller, char *GroupName, void *Addr, USHORT Num, ULONG Size, | |
183 OS_HANDLE *GroupHandle); | |
184 GLOBAL LONG os_CreatePartitionPool_fixed_pool_size (OS_HANDLE TaskHandle, char *GroupName, void *Addr, USHORT PoolSize, | |
185 ULONG PartitionSize, OS_HANDLE *GroupHandle, ULONG *NumCreated); | |
186 GLOBAL LONG os_AllocatePartition (OS_HANDLE Caller, T_VOID_STRUCT **Buffer, ULONG Size, | |
187 ULONG Suspend, OS_HANDLE GroupHandle); | |
188 GLOBAL LONG os_DeallocatePartition (OS_HANDLE Caller, T_VOID_STRUCT *Buffer); | |
189 GLOBAL LONG os_CreateMemoryPool (OS_HANDLE Caller, char *Name, void *Addr, ULONG PoolSize, | |
190 OS_HANDLE *PoolHandle); | |
191 GLOBAL LONG os_AllocateMemory (OS_HANDLE Caller, T_VOID_STRUCT **Buffer, ULONG Size, | |
192 ULONG Suspend, OS_HANDLE PoolHandle); | |
193 GLOBAL LONG os_DeallocateMemory (OS_HANDLE Caller, T_VOID_STRUCT *Buffer); | |
194 GLOBAL LONG os_PartitionInformation (USHORT Handle, char *Buffer); | |
195 GLOBAL LONG os_MemoryInformation (USHORT Handle, char *Buffer); | |
196 GLOBAL LONG os_MemInit (void); | |
197 GLOBAL LONG os_SetPoolHandles (OS_HANDLE ext_pool_handle, OS_HANDLE int_pool_handle); | |
198 GLOBAL LONG os_GetPartitionGroupHandle(OS_HANDLE Caller, char *Name, OS_HANDLE *GroupHandle); | |
199 | |
200 GLOBAL LONG os_GetPartitionPoolStatus (ULONG size, OS_HANDLE gr_hndl, USHORT *free, USHORT *alloc); | |
201 /* Memory internal */ | |
202 GLOBAL LONG os_is_valid_partition (T_VOID_STRUCT *Buffer); | |
203 #ifdef _NUCLEUS_ | |
204 GLOBAL LONG os_PartitionCheck (ULONG *ptr); | |
205 GLOBAL const ULONG *os_GetPrimpoolCB (int grp,int id); | |
206 #endif | |
207 | |
208 /* Timer API */ | |
209 GLOBAL LONG os_CreateTimer (OS_HANDLE TaskHandle, void(*TimeoutProc)(OS_HANDLE,OS_HANDLE,USHORT), | |
210 OS_HANDLE *TimerHandle, OS_HANDLE MemPoolHandle); | |
211 GLOBAL LONG os_DestroyTimer (OS_HANDLE TaskHandle, OS_HANDLE TimerHandle); | |
212 GLOBAL LONG os_StartTimer (OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, USHORT Index, | |
213 OS_TIME InitialTime, OS_TIME RescheduleTime ); | |
214 GLOBAL LONG os_StopTimer (OS_HANDLE TaskHandle, OS_HANDLE TimerHandle); | |
215 GLOBAL LONG os_QueryTimer (OS_HANDLE TaskHandle, OS_HANDLE TimerHandle, OS_TIME *RemainingTime); | |
216 GLOBAL LONG os_TimerInformation (USHORT Handle, char *Buffer); | |
217 GLOBAL LONG os_TimInit (void); | |
218 GLOBAL LONG os_set_tick (int os_system_tick); | |
219 GLOBAL LONG os_InactivityTicks (int *next_event, OS_TICK *next_event_ticks); | |
220 GLOBAL LONG os_IncrementTick (OS_TICK ticks); | |
221 GLOBAL LONG os_GetScheduleCount (OS_HANDLE task_handle, int * schedule_count); | |
222 GLOBAL LONG os_RecoverTick (OS_TICK ticks); | |
223 | |
224 /* Semaphore API */ | |
225 GLOBAL LONG os_CreateSemaphore (OS_HANDLE TaskHandle, char *Name, USHORT Count, | |
226 OS_HANDLE *Semhandle, OS_HANDLE MemPoolHandle); | |
227 GLOBAL LONG os_DestroySemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle); | |
228 GLOBAL LONG os_ResetSemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle, USHORT Count); | |
229 GLOBAL LONG os_OpenSemaphore (OS_HANDLE TaskHandle, char *Name, OS_HANDLE *SemHandle); | |
230 GLOBAL LONG os_CloseSemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle); | |
231 GLOBAL LONG os_ObtainSemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle, ULONG Timeout); | |
232 GLOBAL LONG os_ReleaseSemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle); | |
233 GLOBAL LONG os_QuerySemaphore (OS_HANDLE TaskHandle, OS_HANDLE SemHandle, USHORT *Count); | |
234 GLOBAL LONG os_SemaphoreInformation (USHORT Handle, char *Buffer); | |
235 GLOBAL LONG os_SemInit (void); | |
236 /* Semaphore internal */ | |
237 #ifdef _NUCLEUS_ | |
238 GLOBAL unsigned char *os_FindSuspendingSema (unsigned int *tcb); | |
239 #endif | |
240 | |
241 /* Interrupt API */ | |
242 GLOBAL LONG os_CreateOSISR (char *name, void (*OSISR_entry)(void), int stacksize, int priority, | |
243 int flags, OS_HANDLE *osisr_handle ); | |
244 GLOBAL LONG os_DeleteOSISR (OS_HANDLE osisr_handle); | |
245 GLOBAL LONG os_ActivateOSISR (OS_HANDLE osisr_handle); | |
246 GLOBAL LONG os_SetInterruptState (OS_INT_STATE new_state, OS_INT_STATE *old_state); | |
247 GLOBAL LONG os_EnableInterrupts (OS_INT_STATE *old_state); | |
248 GLOBAL LONG os_DisableInterrupts (OS_INT_STATE *old_state); | |
249 GLOBAL LONG os_isr_init (void); | |
250 | |
251 /* Event group API */ | |
252 GLOBAL LONG os_CreateEventGroup (char *evt_grp_name, OS_HANDLE *evt_grp_handle); | |
253 GLOBAL LONG os_DeleteEventGroup (OS_HANDLE evt_grp_handle); | |
254 GLOBAL LONG os_EventGroupInformation (OS_HANDLE evt_grp_handle, char *Name, unsigned* mask_evt, unsigned* tasks_waiting, OS_HANDLE* first_task); | |
255 GLOBAL LONG os_SetEvents (OS_HANDLE evt_grp_handle, unsigned event_flags); | |
256 GLOBAL LONG os_ClearEvents (OS_HANDLE evt_grp_handle, unsigned event_flags); | |
257 GLOBAL LONG os_RetrieveEvents (OS_HANDLE evt_grp_handle, unsigned event_flags, char option, unsigned* retrieved_events, unsigned suspend); | |
258 GLOBAL LONG os_EvGrpInit (void); | |
259 GLOBAL LONG os_GetEventGroupHandle (char *evt_grp_name, OS_HANDLE *evt_grp_handle); | |
260 | |
261 /* Miscellaneous */ | |
262 GLOBAL LONG os_GetTime (OS_HANDLE TaskHandle, OS_TIME *Time); | |
263 GLOBAL LONG os_Initialize (void); | |
264 GLOBAL LONG os_ObjectInformation (OS_HANDLE Caller, USHORT Id, USHORT Handle, USHORT len, void *Buffer); | |
265 void os_SystemError (OS_HANDLE Caller, USHORT cause, char *buffer ); | |
266 LONG os_dar_register (const void *dar_properties); | |
267 #ifdef _NUCLEUS_ | |
268 LONG os_dar_set_filter (void); | |
269 LONG os_read_dar_ffs_data (USHORT entry, char *buffer, USHORT len); | |
270 #endif | |
271 #if defined (_NUCLEUS_) && defined (_TARGET_) | |
272 #include "gdi.h" | |
273 GLOBAL LONG os_CreateCallback (void); | |
274 GLOBAL LONG os_ExecuteCallback (OS_HANDLE Caller, void (*Callback)(T_DRV_SIGNAL*), T_DRV_SIGNAL *Signal); | |
275 #endif | |
276 #ifdef CTB | |
277 GLOBAL void os_Tick (void); | |
278 GLOBAL void os_StartTicking (void); | |
279 GLOBAL void os_StopTicking (void); | |
280 GLOBAL ULONG os_GetProcessId (void); | |
281 #endif | |
282 | |
283 /*==== END OF OS.H =================================================*/ | |
284 #endif |