changeset 338:42bc1d7068ac

OSL reconstruction: os_pro_fl.c started
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 02 May 2014 06:36:17 +0000
parents a26470040d89
children 2f88c5b89113
files gsm-fw/gpf/Makefile gsm-fw/gpf/osl/Makefile gsm-fw/gpf/osl/os_pro_fl.c
diffstat 3 files changed, 83 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/Makefile	Tue Apr 22 07:42:40 2014 +0000
+++ b/gsm-fw/gpf/Makefile	Fri May 02 06:36:17 2014 +0000
@@ -1,4 +1,4 @@
-SUBDIR=	frame misc tst_drv tst_pei
+SUBDIR=	frame misc osl tst_drv tst_pei
 
 all:	${SUBDIR}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gsm-fw/gpf/osl/Makefile	Fri May 02 06:36:17 2014 +0000
@@ -0,0 +1,10 @@
+CC=	arm-elf-gcc
+CFLAGS=	-O2 -fno-builtin -mthumb-interwork -mthumb
+CPPFLAGS=-I../inc -DRUN_FLASH
+
+XOBJS=	os_pro_fl.o
+
+all:	${XOBJS}
+
+clean:
+	rm -f *.[oa] *errs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gsm-fw/gpf/osl/os_pro_fl.c	Fri May 02 06:36:17 2014 +0000
@@ -0,0 +1,72 @@
+/*
+ * This C module is a reconstruction based on the disassembly of
+ * os_pro.obj in frame_na7_db_fl.lib from the Leonardo package.
+ */
+
+/* set of included headers from COFF symtab: */
+#include <stdio.h>
+#include <string.h>
+#include "gpfconf.h"	/* FreeCalypso addition */
+#include "../../nucleus/nucleus.h"
+#include "typedefs.h"
+#include "os.h"
+#include "gdi.h"
+#include "os_types.h"
+#include "os_glob.h"
+
+typedef unsigned char u_char;
+
+extern T_OS_TASK_TABLE_ENTRY TaskTable[];
+
+/* .bss */
+static NU_SEMAPHORE ProSemCB;
+
+static int
+os_GetTaskEntry(USHORT Index, OS_HANDLE *Handle)
+{
+	static USHORT Idx;
+
+	if (Index == FIRST_ENTRY)
+		Idx = 0;
+	if (Index == FIRST_ENTRY || Index == NEXT_ENTRY) {
+		while (++Idx <= MaxTasks && !TaskTable[Idx].Name[0])
+			;
+	} else
+		Idx = Index;
+	if (Idx <= MaxTasks && TaskTable[Idx].Name[0]) {
+		*Handle = Idx;
+		return(0);
+	} else
+		return(-1);
+}
+
+GLOBAL LONG
+os_TaskInformation(USHORT Index, char *Buffer)
+{
+	DATA_ELEMENT TaskStatus;
+	OPTION Prio, Preempt;
+	UNSIGNED Count, TimeSlice, Size, MinStack;
+	OS_HANDLE Handle;
+	CHAR Name[NU_MAX_NAME];
+	u_char *StackBase, *sp;
+	USHORT Untouched;
+
+	if (os_GetTaskEntry(Index, &Handle) < 0)
+		return(-1);
+	if (NU_Task_Information(&TaskTable[Handle].TaskCB.TCB, Name,
+				&TaskStatus, &Count, &Prio, &Preempt,
+				&TimeSlice, (VOID **) &StackBase,
+				&Size, &MinStack) != NU_SUCCESS)
+		return(-1);
+	Untouched = 0;
+	for (sp = StackBase; sp < StackBase + Size; sp++) {
+		if (*sp != 0xFE)
+			break;
+		Untouched++;
+	}
+	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);
+}