changeset 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
files gsm-fw/gpf/osl/os_pro_ir.c
diffstat 1 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_pro_ir.c	Sat May 03 19:20:05 2014 +0000
+++ b/gsm-fw/gpf/osl/os_pro_ir.c	Wed May 07 18:45:50 2014 +0000
@@ -20,6 +20,8 @@
 extern T_OS_TASK_TABLE_ENTRY TaskTable[];
 extern unsigned os_time_to_tick_multiplier;
 
+#define	OS_NU_TASK_MAGIC	0xdeafbeef
+
 VOID
 os_TaskEntry(UNSIGNED TaskHandle, VOID *argv)
 {
@@ -37,3 +39,69 @@
 	NU_Sleep(SuspendTicks);
 	return (OS_OK);
 }
+
+GLOBAL LONG
+os_ResumeTask(OS_HANDLE task_handle)
+{
+	if (NU_Resume_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS)
+		return(OS_OK);
+	else
+		return(OS_ERROR);
+}
+
+GLOBAL LONG
+os_Relinquish(void)
+{
+	NU_Relinquish();
+	return(OS_OK);
+}
+
+GLOBAL OS_HANDLE
+os_MyHandle(void)
+{
+	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)
+		return(os_nu_task->handle);
+	else
+		return(OS_NOTASK);
+}
+
+GLOBAL LONG
+os_GetTaskName(OS_HANDLE Caller, OS_HANDLE TaskHandle, char *Name)
+{
+	if (TaskHandle) {
+		if (TaskHandle > MaxTasks || !TaskTable[TaskHandle].Name[0])
+			return(OS_ERROR);
+		strcpy(Name, TaskTable[TaskHandle].Name);
+	} else if (TCD_Current_Thread) {
+		NU_TASK *curtask = TCD_Current_Thread;
+		strcpy(Name, curtask->tc_name);
+	} else
+		strcpy(Name, "ROOT");
+	return(OS_OK);
+}
+
+GLOBAL LONG
+os_DeferTask(OS_HANDLE task_handle, OS_TIME time)
+{
+	if (NU_Suspend_Task(&TaskTable[task_handle].TaskCB.TCB) == NU_SUCCESS)
+		return(OS_OK);
+	else
+		return(OS_ERROR);
+}
+
+GLOBAL LONG
+os_CheckTaskStack(OS_HANDLE Handle)
+{
+	register void *sp asm("sp");
+
+	if (*TaskTable[Handle].Stack != GUARD_PATTERN)
+		return(OS_ERROR);
+	if (TCD_Current_Thread) {
+		NU_TASK *curtask = TCD_Current_Thread;
+		if (sp < curtask->tc_stack_start)
+			return(OS_ERROR);
+	}
+	return(OS_OK);
+}