view gsm-fw/gpf/osl/os_pro_fl.c @ 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
children 2f88c5b89113
line wrap: on
line source

/*
 * 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);
}