#define OS_C
/******************************************************************************
 *
 *       (C) Copyright 2006, Freescale Semiconductor, Inc. All Rights Reserved.
 *
 *       THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
 *       BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
 *       Freescale Semiconductor, Inc.
 *
 * Filename:     $Source: /u/OSEK/src/os2000/src/osesys/src/os.c,v $
 * Author:       $Author: bobi001 $
 * Revision:     $Revision: 1.11 $
 *
 * Functions:    
 *
 * History:      Use the CVS command rlog to display revision history
 *               information.
 *
 * Description:  Main module of the OSEK OS  
 *
 * Notes:        
 *
 ******************************************************************************/
#if !defined(OSPROPH)
#include "osprop.h"                     /* OS Properties */
#else                                   /* !defined(OSPROPH)    */
#include OSPROPH                        /* OS Properties */
#endif                                  /* !defined(OSPROPH)    */

#include <osapi.h>

#if !defined(OSNOBUILDNUMBER)

#define OSBUILDNUMBER                   "2.2.1.82"

const OSBYTE OsBuildNumber[] = OSBUILDNUMBER; /* build number */

#endif                                  /* !defined(OSNOBUILDNUMBER) */

#if (OSORTIDEBUGLEVEL > 0 )
StatusType OsLastError;
extern unsigned char _stack_addr[];     /* starting address for stack */
OSDWORD _OsOrtiStart = (OSDWORD)_stack_addr;
OSDWORD _OsOrtiStackStart = (OSDWORD)_stack_end;

#endif                                  /* (OSORTIDEBUGLEVEL > 0 ) */

#if defined(OSGETSERVICEID) || defined(OSPARAMETERACCESS)

OSServiceIdType OsService;              /* for OSErrorGetServiceId() from ErrorHook */
OSDWORD OsObjId;                        /* for first parameter                      */
#endif                                  /* defined(OSGETSERVICEID) || defined(OSPARAMETERACCESS) */

#if (OSORTIDEBUGLEVEL > 0) || (OSNAPPMODES > 1)
AppModeType OsCurAppMode;
#endif                                  /* (OSORTIDEBUGLEVEL > 0)  || (OSNAPPMODES > 1) */

#if defined(OSORTIRUNNINGISRID) && defined(OSISRENTRYEXIT)
/* ORTI support for tracing ISR */
volatile OSBYTE OsOrtiRunningISRId;     /* the index of currently running ISR */

#endif                                  /* defined(OSORTIRUNNINGISRID) */

#if defined(OSORTICURRENTSERVICEID)

volatile OSBYTE OsOrtiRunningServiceId;
volatile OSBYTE OsOrtiOldServiceId;

#endif                                  /* defined(OSORTICURRENTSERVICEID) */

#if defined(OSSTKCHECK_U)
volatile OSDWORD* OsMainTOS;            /* top margin of main stack for OS  */
#endif

#if defined(LOCALMESSAGESONLY)
#if (OSNMSGS > 0)

OSMSGCBtype* OsRcvPtr[OSNSNDMSGS];      /* sending messages pointer to (1st) receiving  */
COMApplicationModeType OsCOMmode;       /* COM startup mode     */
OSMSGCBtype OsMessages[OSNRCVMSGS];     /* control blocks for messages ( initalized in StartOS )    */

#if defined(OSCOMGETSERVICEID)
OSDWORD OsComObjId;
COMServiceIdType OsComService;
#endif                                  /* defined(OSCOMGETSERVICEID)    */

#endif                                  /* OSNMSGS > 0  */
#endif                                  /* defined(LOCALMESSAGESONLY) */

