FreeCalypso > hg > freecalypso-sw
changeset 339:2f88c5b89113
OSL reconstruction: got to os_GetTaskData()
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 02 May 2014 23:44:12 +0000 |
parents | 42bc1d7068ac |
children | de7141ad907e |
files | gsm-fw/gpf/osl/os_pro_fl.c |
diffstat | 1 files changed, 85 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_pro_fl.c Fri May 02 06:36:17 2014 +0000 +++ b/gsm-fw/gpf/osl/os_pro_fl.c Fri May 02 23:44:12 2014 +0000 @@ -17,10 +17,13 @@ typedef unsigned char u_char; extern T_OS_TASK_TABLE_ENTRY TaskTable[]; +extern VOID *TCD_Current_Thread; /* .bss */ static NU_SEMAPHORE ProSemCB; +#define OS_NU_TASK_MAGIC 0xdeafbeef + static int os_GetTaskEntry(USHORT Index, OS_HANDLE *Handle) { @@ -52,12 +55,12 @@ USHORT Untouched; if (os_GetTaskEntry(Index, &Handle) < 0) - return(-1); + return(OS_ERROR); if (NU_Task_Information(&TaskTable[Handle].TaskCB.TCB, Name, &TaskStatus, &Count, &Prio, &Preempt, &TimeSlice, (VOID **) &StackBase, &Size, &MinStack) != NU_SUCCESS) - return(-1); + return(OS_ERROR); Untouched = 0; for (sp = StackBase; sp < StackBase + Size; sp++) { if (*sp != 0xFE) @@ -67,6 +70,84 @@ sprintf(Buffer, "Name:%s Stat:%d Count:%ld Prio:%d Stack:%lx Size:%ld Untouched:%d", Name, TaskStatus, Count, 255 - Prio, (ULONG) StackBase, - (ULONG) Size, Untouched); - return(0); + (LONG) Size, Untouched); + return(OS_OK); +} + +GLOBAL LONG +os_StopTask(OS_HANDLE Caller, OS_HANDLE TaskHandle) +{ + if (NU_Suspend_Task(&TaskTable[TaskHandle].TaskCB.TCB) == NU_SUCCESS) + return(OS_OK); + else + return(OS_ERROR); +} + +GLOBAL LONG +os_StartTask(OS_HANDLE Caller, OS_HANDLE TaskHandle, ULONG Value) +{ + if (NU_Resume_Task(&TaskTable[TaskHandle].TaskCB.TCB) == NU_SUCCESS) + return(OS_OK); + else + return(OS_ERROR); +} + +GLOBAL LONG +os_ProInit(void) +{ + USHORT i; + + if (NU_Create_Semaphore(&ProSemCB, "PROSEM", 1, NU_PRIORITY) + != NU_SUCCESS) + return(OS_ERROR); + for (i = 1; i <= MaxTasks; i++) + bzero(&TaskTable[i], sizeof(T_OS_TASK_TABLE_ENTRY)); + return(OS_OK); } + +GLOBAL unsigned char +os_GetTaskState(OS_HANDLE Caller, OS_HANDLE Handle) +{ + if (TaskTable[Handle].Name[0]) + return(TaskTable[Handle].TaskCB.TCB.tc_status); + else + return(255); +} + +GLOBAL LONG +os_GetTaskHandle(OS_HANDLE Caller, char *Name, OS_HANDLE *TaskHandle) +{ + USHORT i; + + if (!Name) { + OS_NU_TASK *os_nu_task = (OS_NU_TASK *) TCD_Current_Thread; + + if (os_nu_task && os_nu_task->magic_nr == OS_NU_TASK_MAGIC) + *TaskHandle = os_nu_task->handle; + else + *TaskHandle = OS_NOTASK; + return(OS_OK); + } + for (i = 1; i <= MaxTasks; i++) + if (TaskTable[i].Name[0] && + !strncmp(Name, TaskTable[i].Name, RESOURCE_NAMELEN - 1)) { + *TaskHandle = i; + return(OS_OK); + } + return(OS_ERROR); +} + +GLOBAL LONG +os_GetTaskData(OS_HANDLE Handle, unsigned **tcb, + u_char **stackbegin, u_char **stackend) +{ + NU_TASK *task; + + if (!TaskTable[Handle].Name[0]) + return(OS_ERROR); + task = &TaskTable[Handle].TaskCB.TCB; + *tcb = (unsigned *) task; + *stackbegin = (u_char *) task->tc_stack_start; + *stackend = (u_char *) task->tc_stack_end; + return(OS_OK); +}