#include "RTDS_Startup_decl.h"

/* ***************************************************************** */
/* $(RTDS_HOME)/share/ccg/vxworks/bricks/RTDS_Startup_begin.c begins */
/* Copyright (C) 2002 PragmaDev */

/* Pointers to global list of information on processes and semaphores */
RTDS_GlobalProcessInfo		*RTDS_globalProcessInfo=NULL;
RTDS_GlobalSemaphoreInfo	*RTDS_globalSemaphoreInfo=NULL;
#ifdef RTDS_SIMULATOR
void						*RTDS_globalMessageUniqueIdPool=NULL;
RTDS_GlobalTraceInfo		RTDS_globalTraceEntry={0,NULL};
#endif

RTDS_START_SYNCHRO_DECL;
RTDS_CRITICAL_SECTION_DECL;


void RTDS_Start(void)
{

RTDS_GlobalProcessInfo *RTDS_currentContext;


#ifdef RTDS_SIMULATOR
/* Set up the message unique id pool */
RTDS_globalMessageUniqueIdPool = RTDS_MALLOC(RTDS_MESSAGE_UNIQUE_ID_POOL_SIZE);
	{
	int i;
	unsigned char *index;

	index = RTDS_globalMessageUniqueIdPool;
	for(i=0;i<RTDS_MESSAGE_UNIQUE_ID_POOL_SIZE;i++)
		{
		*index=0x00;
		index++;
		}
	}

#endif


/* Set up the process context needed to create tasks */

RTDS_currentContext = (RTDS_GlobalProcessInfo *)RTDS_MALLOC(sizeof(RTDS_GlobalProcessInfo));
if ( RTDS_currentContext == NULL )
  RTDS_SYSTEM_ERROR(RTDS_ERROR_STARTUP_CONTEXT_MALLOC);
RTDS_currentContext->name = NULL;
RTDS_currentContext->sdlState	= 0;
RTDS_currentContext->next = NULL;
RTDS_currentContext->parentQueueId	= NULL;
RTDS_currentContext->offspringQueueId	= NULL;
RTDS_currentContext->currentMessage	= NULL;
RTDS_currentContext->timerList = NULL;
RTDS_currentContext->myQueueId	= NULL;

RTDS_CRITICAL_SECTION_INIT;
RTDS_START_SYNCHRO_INIT;
/* $(RTDS_HOME)/share/ccg/vxworks/bricks/RTDS_Startup_begin.c ends */
/* *************************************************************** */

/* SEMAPHORE CREATIONS */

/* PROCESS CREATIONS */
RTDS_STARTUP_PROCESS_CREATE("RTDS_Env", RTDS_Env, 150);
RTDS_STARTUP_PROCESS_CREATE("pCentral", pCentral, 150);
/* *************************************************************** */
/* $(RTDS_HOME)/share/ccg/vxworks/bricks/RTDS_Startup_end.c begins */
/* Copyright (C) 2002 PragmaDev */

RTDS_SIMULATOR_TRACE(RTDS_initDone, NULL, NULL);

/* Let all the created process run now */
#ifndef RTDS_SIMULATOR
	RTDS_START_SYNCHRO_GO;
#endif

/* To call for clean exit of the system by the last task */
/*
RTDS_CRITICAL_SECTION_POSTAMBLE;
RTDS_START_SYNCHRO_POSTAMBLE;
*/
}

/* $(RTDS_HOME)/share/ccg/vxworks/bricks/RTDS_Startup_end.c ends */
/* ************************************************************* */