Ejemplo n.º 1
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6;
	TickType TickType_inst_5, TickType_inst_6, TickType_inst_7;
	TickType TickType_inst_1 = OSMAXALLOWEDVALUE_Software_Counter + 1;
	TickType TickType_inst_2 = OSMAXALLOWEDVALUE_Software_Counter + 1;
	TickType TickType_inst_3 = OSMAXALLOWEDVALUE_Software_Counter + 1;
	TickType TickType_inst_4 = OSMAXALLOWEDVALUE_Hardware_Counter + 1;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = IncrementCounter(Hardware_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_ID, result_inst_1);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = IncrementCounter(INVALID_COUNTER);	
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_ID, result_inst_2);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_3 = GetCounterValue(INVALID_COUNTER, &TickType_inst_1);	
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_ID, result_inst_3);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_4 = GetElapsedCounterValue(Software_Counter, &TickType_inst_2, &TickType_inst_3);	
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_VALUE, result_inst_4);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_5 = GetElapsedCounterValue(Hardware_Counter, &TickType_inst_4, &TickType_inst_5);	
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_VALUE, result_inst_5);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_6 = GetElapsedCounterValue(INVALID_COUNTER, &TickType_inst_6, &TickType_inst_7);	
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_ID, result_inst_6);
}
Ejemplo n.º 2
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_isr1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9;
	TickType TickType_inst_1, TickType_inst_2;
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_1 = GetCounterValue(Software_Counter, &TickType_inst_1);	
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2,E_OK, result_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,0, TickType_inst_1);

	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = SetRelAlarm(Alarm_ActivateTask, 2, 0);	
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_2);	
		
	SCHEDULING_CHECK_INIT(4);
	result_inst_3 = IncrementCounter(Software_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_3);

	SCHEDULING_CHECK_INIT(5);
	result_inst_4 = IncrementCounter(Software_Counter);	
	/* alarm expiration */
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_4);
	/* force scheduling */
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_5 = SetRelAlarm(Alarm_SetEvent_suspendedtask, 2, 0);	
	SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK, result_inst_5);	
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_6 = IncrementCounter(Software_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_7 = IncrementCounter(Software_Counter);
	/*alarm expires*/
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_7);
	
	/*force rescheduling*/
	
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_8 = GetCounterValue(Software_Counter_By_Alarm, &TickType_inst_2);	
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(11,E_OK, result_inst_8);
	SCHEDULING_CHECK_AND_EQUAL_INT(11,0, TickType_inst_2);
	
	
	SCHEDULING_CHECK_INIT(12);
	result_inst_9 = SetRelAlarm(Alarm_ActivateTask, 0, 0);	
	SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OS_VALUE, result_inst_9);	
	
	
}
Ejemplo n.º 3
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_isr1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9;
	TickType TickType_inst_1, TickType_inst_2, TickType_inst_3, TickType_inst_4, TickType_inst_5;
	
	/*s1*/
	SCHEDULING_CHECK_INIT(2);
	result_inst_1 = GetCounterValue(Software_Counter, &TickType_inst_1);	
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2,E_OK, result_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,0, TickType_inst_1);

	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = SetRelAlarm(Alarm1, 2, 0);	
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_2);	
		
	SCHEDULING_CHECK_INIT(4);
	result_inst_3 = IncrementCounter(Software_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_3);

	SCHEDULING_CHECK_INIT(5);
	result_inst_4 = IncrementCounter(Software_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK, result_inst_4);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_5 = GetCounterValue(Software_Counter, &TickType_inst_2);	
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(6,E_OK, result_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT(6,1, TickType_inst_2);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_6 = IncrementCounter(Software_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_7 = IncrementCounter(Software_Counter);
	/*alarm expires*/
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_7);
	
	/*force rescheduling*/
			
	SCHEDULING_CHECK_INIT(11);
	result_inst_8 = GetCounterValue(Software_Counter, &TickType_inst_3);	
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(11,E_OK, result_inst_8);
	SCHEDULING_CHECK_AND_EQUAL_INT(11,2, TickType_inst_3);
		
	SCHEDULING_CHECK_INIT(12);
	TickType_inst_4 = 0;
	result_inst_9 = GetElapsedCounterValue(Software_Counter, &TickType_inst_4, &TickType_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(12,E_OK , result_inst_9);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(12,2 , TickType_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT(12,2 , TickType_inst_5);
		
}
Ejemplo n.º 4
0
///////////////////////////////////////////////////////////////
//
// CServerIdManagerImpl::GetServerIdInfo
//
//
//
///////////////////////////////////////////////////////////////
const CServerIdInfo& CServerIdManagerImpl::GetServerIdInfo ( const SString& strServerId )
{
    // Find
    CServerIdKey findKey;
    findKey.strId = strServerId;
    CServerIdInfo* pInfo = MapFind ( m_ServerIdMap, findKey );
    if ( !pInfo )
    {
        // Add if missing

        // Use part of serverid for directory name
        SString strDir = strServerId.Left ( 6 );

        // Ensure the item does not exist in the map
        bool bAgain = true;
        while ( bAgain )
        {
            bAgain = false;
            for ( std::map < CServerIdKey, CServerIdInfo >::iterator it = m_ServerIdMap.begin () ; it != m_ServerIdMap.end () ; ++it )
            {
                const CServerIdInfo& info = it->second;
                if ( strDir == info.strDir )
                {
                    strDir = IncrementCounter ( strDir );
                    bAgain = true;
                    break;
                }
            }
        }

        // Ensure the directory does not exist
        while ( DirectoryExists ( PathJoin ( m_strServerIdLookupBaseDir, strDir ) ) )
        {
            strDir = IncrementCounter ( strDir );
        }

        // Add new item
        {
            CServerIdInfo info;
            info.strDir = strDir;
            MapSet ( m_ServerIdMap, findKey, info );

            m_bListChanged = true;
            SaveServerIdMap ();
        }

        pInfo = MapFind ( m_ServerIdMap, findKey ); 
    }

    return *pInfo;
}
Ejemplo n.º 5
0
/* NOTE: not supported */
EXPORT ISR(SystemTick)
{
    EnterISR();
    knl_timer_handler();
    (void)IncrementCounter(0);
    ExitISR();
} 
CheckScopeTime::CheckScopeTime(const char* _name)
    :   name    (_name),
        running (false)
{
    Start();
    IncrementCounter(name);
};
Ejemplo n.º 7
0
/* Cortex-M0 core of LPC4337 uses RIT Timer for periodic IRQ */
void RIT_IRQHandler(void)
{
   if(Chip_RIT_GetIntStatus(LPC_RITIMER) == SET)
   {
      /* Store the calling context in a variable. */
      ContextType actualContext = GetCallingContext();

      /* Set ISR2 context. */
      SetActualContext(CONTEXT_ISR2);

#if (ALARMS_COUNT != 0)

      /* Counter increment. */
      static CounterIncrementType CounterIncrement = 1; /* TODO remove me. */

      (void)CounterIncrement; /* This avoids a compiler warning because the variable is not being used. */

      /*
       * Enter critical section.
       * */
      IntSecure_Start();

      /*
       * The the RTOS counter increment handler.
       * */
      CounterIncrement = IncrementCounter(0, 1 /* CounterIncrement */); /* TODO FIXME */

      /*
       * Exit the critical section.
       * */
      IntSecure_End();

#endif /* #if (ALARMS_COUNT != 0) */

      /* reset context */
      SetActualContext(actualContext);

#if (NON_PREEMPTIVE == OSEK_DISABLE)

      /*
       * Check if the currently active task is preemptive;
       * if it is, call schedule().
       * */

      if ( ( CONTEXT_TASK == actualContext ) &&
            ( TasksConst[GetRunningTask()].ConstFlags.Preemtive ) )
      {
         /* This shall force a call to the scheduler. */
         PostIsr2_Arch(isr);
      }

#endif /* #if (NON_PREEMPTIVE == OSEK_DISABLE) */

      Chip_RIT_ClearInt(LPC_RITIMER);

      NVIC_ClearPendingIRQ(RITIMER_IRQn);
   }
}
Ejemplo n.º 8
0
/*******************************************************************************
**                                                                            **
** FUNC-NAME     :                                                            **
**                                                                            **
** DESCRIPTION   :                                                            **
**                                                                            **
** PRECONDITIONS :                                                            **
**                                                                            **
** PARAMETER     :                                                            **
**                                                                            **
** RETURN        :                                                            **
**                                                                            **
** REMARKS       :                                                            **
**                                                                            **
*******************************************************************************/
StatusType IAdvanceCounter(CounterType CounterID)
{
    // 1. Check if the call is from ISR or system context
    // GetCallingContext()
    // 2. Check if the interrupts are enabled - they have to be disabled
    // 3. Check if the referenced counter is valid
    // 4. -> Then OK - increment the counter by one, becasue this is the system quant
    (void)IncrementCounter(CounterID, 1); // We don't care about the return value,since it could be

    // zero, when increment just by one
	return E_OK;
}
void OsAlm_NotifyAlarm(AlarmType AlarmID)
#endif /* KOS_MEMORY_MAPPING */
{
    AlarmConfigurationType const * const Alarm = (AlarmConfigurationType *)&OS_AlarmConf[AlarmID];

#if defined(OS_EXTENDED_STATUS) && defined(OS_FEATURE_CALLEVEL_CHECK)
    OsCallevelType CallevelSaved;
#endif

    DISABLE_ALL_OS_INTERRUPTS();

    if (OS_AlarmValue[AlarmID].CycleCounter != (TickType)0) {
        /* cyclic Alarm. */
        OS_AlarmValue[AlarmID].ExpireCounter = OS_AlarmValue[AlarmID].CycleCounter;
    } else {
        /* one-shot Alarm. */
        OsAlm_StopAlarm(AlarmID);  /* OS_AlarmValue[AlarmID].State=ALM_STOPPED; */
    }

/*    printf("Alarm %u.\n", AlarmID); */

    ENABLE_ALL_OS_INTERRUPTS();

    switch (Alarm->ActionType) {
        case ALM_SETEVENT:
            (void)OsEvtSetEvent(Alarm->Action.Event->TaskID, Alarm->Action.Event->Mask);
            break;
        case ALM_ACTIVATETASK:
            (void)OsTask_Activate((TaskType)Alarm->Action.TaskID);
            break;
        case ALM_CALLBACK:
            DISABLE_ALL_OS_INTERRUPTS();
            #if defined(OS_EXTENDED_STATUS) && defined(OS_FEATURE_CALLEVEL_CHECK)
            CallevelSaved = OS_GET_CALLEVEL();
            #endif
            OS_SET_CALLEVEL(OS_CL_ALARM_CALLBACK);
            (Alarm->Action.AlarmCallback)();
            #if defined(OS_EXTENDED_STATUS) && defined(OS_FEATURE_CALLEVEL_CHECK)
            OS_SET_CALLEVEL(CallevelSaved);
            #endif
            ENABLE_ALL_OS_INTERRUPTS();
            break;
#if 0
        case ALM_COUNTER:
            (void)IncrementCounter(Alarm->Action.CounterID);
            break;
#endif
        default:
            ASSERT(FALSE);
    }
}
Ejemplo n.º 10
0
/* Periodic Interrupt Timer, included in all Cortex-M4 processors */
void SysTick_Handler(void)
{
#if (ALARMS_COUNT != 0)
	/* to save the context during the interrupt */
	ContextType context;
	/* counter increment */
	static CounterIncrementType CounterIncrement = 1;
   (void)CounterIncrement; /* TODO remove me */

	/* increment the disable interrupt conter to avoid enable the interrupts */
	IntSecure_Start();

	/* save actual context */
	context = GetCallingContext();

	/* set context to CONTEXT_DBG */
	SetActualContext(CONTEXT_DBG);

	/* call counter interrupt handler */
	CounterIncrement = IncrementCounter(0, 1 /* CounterIncrement */); /* TODO FIXME */

	/* interrupt has to be called first after so many CounterIncrement */
	/* SetCounterTime(CounterIncrement); */ /* TODO FIXME */

	/* set context back */
	SetActualContext(context);

	/* set the disable interrupt counter back */
	IntSecure_End();

#endif /* #if (ALARMS_COUNT != 0) */

	/* clear timer interrupt flag */
	//not necessary for Cortex-M3
	//ClearTimerInterrupt_Cpu();

#if 0 /* TODO */
#if (NON_PREEMPTIVE == DISABLE)
		/* check if interrupt a Task Context */
		if ( GetCallingContext() ==  CONTEXT_TASK )
		{
			if ( TasksConst[GetRunningTask()].ConstFlags.Preemtive )
			{
				/* \req TODO Rescheduling shall take place only if interrupt a
				 * preemptable task. */
				(void)Schedule();
			}
		}
#endif /* #if (NON_PREEMPTIVE == ENABLE) */
#endif
}
Ejemplo n.º 11
0
void SEAL::ProcessString(byte *outString, const byte *inString, unsigned int length)
{
	while (length >= L/8-position)
	{
		xorbuf(outString, inString, buffer+position, L/8-position);
		length -= L/8-position;
		inString += L/8-position;
		outString += L/8-position;
		IncrementCounter();
	}

	xorbuf(outString, inString, buffer+position, length);
	position += length;
}
Ejemplo n.º 12
0
//作成PATのバッファポインタを取得
//戻り値:作成PATのバッファポインタ
BOOL CCreatePATPacket::GetPacket(
	BYTE** pbBuff,				//[OUT] 作成したPATパケットへのポインタ(次回呼び出し時まで有効)
	DWORD* pdwSize,				//[OUT] pbBuffのサイズ
	BOOL incrementFlag			//[IN] TSパケットのCounterをインクリメントするかどうか(TRUE:する、FALSE:しない)
)
{
	if( incrementFlag == TRUE ){
		IncrementCounter();
	}
	if( this->packet != NULL ){
		*pbBuff = this->packet;
		*pdwSize = (DWORD)this->packetSize;
	}else{
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 13
0
//作成PMTのバッファポインタを取得
//戻り値:
// 作成PMTのバッファポインタ
//引数:
// buff					[OUT]作成したPMTパケットへのポインタ(次回呼び出し時まで有効)
// size					[OUT]buffのサイズ
// incrementFlag		[IN]TSパケットのCounterをインクリメントするかどうか(TRUE:する、FALSE:しない)
BOOL CCreatePMTPacket::GetPacket(
	BYTE** buff,
	DWORD* size,
	BOOL incrementFlag
)
{
	if( incrementFlag == TRUE ){
		IncrementCounter();
	}
	if( this->createPacket != NULL ){
		*buff = this->createPacket;
		*size = (DWORD)this->createPacketSize;
	}else{
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 14
0
void Object2Send_MSG ( GameObject * _self, M m, int var1, int var2 )
{
  // Create temporary casted self
  Object2 *self = CAST( _self, Object2 );

  switch(m)
  {
  case M_TEST1:
      printf( "Object2: Recieved message : M_TEST1\n" );
      break;
  case M_TEST2_1PARAM:
      printf( "Object2: Recieved message : M_TEST2_1PARAM\n" );
      printf( "  Param: %d\n", var1 );
      break;
  case M_INCREMENT:
      IncrementCounter( self, var1 );
      break;
  }
}
Ejemplo n.º 15
0
/* Periodic Interrupt Timer, included in all Cortex-M4 processors */
void SysTick_Handler(void)
{
   /* store the calling context in a variable */
   ContextType actualContext = GetCallingContext();
   /* set isr 2 context */
   SetActualContext(CONTEXT_ISR2);

#if (ALARMS_COUNT != 0)
   /* counter increment */
   static CounterIncrementType CounterIncrement = 1;
   (void)CounterIncrement; /* TODO remove me */

   /* increment the disable interrupt conter to avoid enable the interrupts */
   IntSecure_Start();

   /* call counter interrupt handler */
   CounterIncrement = IncrementCounter(0, 1 /* CounterIncrement */); /* TODO FIXME */

   /* set the disable interrupt counter back */
   IntSecure_End();

#endif /* #if (ALARMS_COUNT != 0) */

   /* reset context */
   SetActualContext(actualContext);

#if (NON_PREEMPTIVE == OSEK_DISABLE)
   /* check if the actual task is preemptive */
   if ( ( CONTEXT_TASK == actualContext ) &&
        ( TasksConst[GetRunningTask()].ConstFlags.Preemtive ) )
   {
      /* indicate that the scheduler will be called from isr2 */
//      OSEK_ISR2_SchedulerCall = 1;
      OSEK_ISR2_SchedulerCall++;

      /* this shall force a call to the scheduler */
      PostIsr2_Arch(isr);
   }
#endif /* #if (NON_PREEMPTIVE == OSEK_DISABLE) */
}
Ejemplo n.º 16
0
// -------------------------------------------------------------------------------------------------
static void* ThreadMainFunction
(
    void* objPtr
)
// -------------------------------------------------------------------------------------------------
{
    Context_t* contextPtr = objPtr;

    LE_INFO("Thread '%s' started.", le_thread_GetMyName());

    IncrementCounter();

    if (contextPtr->depth < DEPTH)
    {
        LE_INFO("Thread '%s' spawning children.", le_thread_GetMyName());

        SpawnChildren(contextPtr->depth + 1, contextPtr->completionObjPtr);
    }

    LE_INFO("Thread '%s' terminating.", le_thread_GetMyName());

    return contextPtr->completionObjPtr;
}
Ejemplo n.º 17
0
static void AnalyzeArrival(Item *ip_addresses, long iteration, char *arrival, double *cf_this)
{
    char src[CF_BUFSIZE], dest[CF_BUFSIZE], flag = '.', *arr;
    int isme_dest, isme_src;

    src[0] = dest[0] = '\0';

    if (strstr(arrival, "listening"))
    {
        return;
    }

    if (Chop(arrival, CF_EXPANDSIZE) == -1)
    {
        Log(LOG_LEVEL_ERR, "Chop was called on a string that seemed to have no terminator");
    }

/* Most hosts have only a few dominant services, so anomalies will
   show up even in the traffic without looking too closely. This
   will apply only to the main interface .. not multifaces

   New format in tcpdump

   IP (tos 0x10, ttl 64, id 14587, offset 0, flags [DF], proto TCP (6), length 692) 128.39.89.232.22 > 84.215.40.125.48022: P 1546432:1547072(640) ack 1969 win 1593 <nop,nop,timestamp 25662737 1631360>
   IP (tos 0x0, ttl 251, id 14109, offset 0, flags [DF], proto UDP (17), length 115) 84.208.20.110.53 > 192.168.1.103.32769: 45266 NXDomain 0/1/0 (87)
   arp who-has 192.168.1.1 tell 192.168.1.103
   arp reply 192.168.1.1 is-at 00:1d:7e:28:22:c6
   IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.1.103 > 128.39.89.10: ICMP echo request, id 48474, seq 1, length 64
   IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.1.103 > 128.39.89.10: ICMP echo request, id 48474, seq 2, length 64
*/

    for (arr = strstr(arrival, "length"); (arr != NULL) && (*arr != ')'); arr++)
    {
    }

    if (arr == NULL)
    {
        arr = arrival;
    }
    else
    {
        arr++;
    }

    if ((strstr(arrival, "proto TCP")) || (strstr(arrival, "ack")))
    {
        sscanf(arr, "%s %*c %s %c ", src, dest, &flag);
        DePort(src);
        DePort(dest);
        isme_dest = IsInterfaceAddress(ip_addresses, dest);
        isme_src = IsInterfaceAddress(ip_addresses, src);

        switch (flag)
        {
        case 'S':
            Log(LOG_LEVEL_DEBUG, "%ld: TCP new connection from '%s' to '%s' - i am '%s'", iteration, src, dest, VIPADDRESS);
            if (isme_dest)
            {
                cf_this[ob_tcpsyn_in]++;
                IncrementCounter(&(NETIN_DIST[IP_TYPES_TCP_SYN]), src);
            }
            else if (isme_src)
            {
                cf_this[ob_tcpsyn_out]++;
                IncrementCounter(&(NETOUT_DIST[IP_TYPES_TCP_SYN]), dest);
            }
            break;

        case 'F':
            Log(LOG_LEVEL_DEBUG, "%ld: TCP end connection from '%s' to '%s'", iteration, src, dest);
            if (isme_dest)
            {
                cf_this[ob_tcpfin_in]++;
                IncrementCounter(&(NETIN_DIST[IP_TYPES_TCP_FIN]), src);
            }
            else if (isme_src)
            {
                cf_this[ob_tcpfin_out]++;
                IncrementCounter(&(NETOUT_DIST[IP_TYPES_TCP_FIN]), dest);
            }
            break;

        default:
            Log(LOG_LEVEL_DEBUG, "%ld: TCP established from '%s' to '%s'", iteration, src, dest);

            if (isme_dest)
            {
                cf_this[ob_tcpack_in]++;
                IncrementCounter(&(NETIN_DIST[IP_TYPES_TCP_ACK]), src);
            }
            else if (isme_src)
            {
                cf_this[ob_tcpack_out]++;
                IncrementCounter(&(NETOUT_DIST[IP_TYPES_TCP_ACK]), dest);
            }
            break;
        }
    }
    else if (strstr(arrival, ".53"))
    {
        sscanf(arr, "%s %*c %s %c ", src, dest, &flag);
        DePort(src);
        DePort(dest);
        isme_dest = IsInterfaceAddress(ip_addresses, dest);
        isme_src = IsInterfaceAddress(ip_addresses, src);

        Log(LOG_LEVEL_DEBUG, "%ld: DNS packet from '%s' to '%s'", iteration, src, dest);
        if (isme_dest)
        {
            cf_this[ob_dns_in]++;
            IncrementCounter(&(NETIN_DIST[IP_TYPES_DNS]), src);
        }
        else if (isme_src)
        {
            cf_this[ob_dns_out]++;
            IncrementCounter(&(NETOUT_DIST[IP_TYPES_TCP_ACK]), dest);
        }
    }
    else if (strstr(arrival, "proto UDP"))
    {
        sscanf(arr, "%s %*c %s %c ", src, dest, &flag);
        DePort(src);
        DePort(dest);
        isme_dest = IsInterfaceAddress(ip_addresses, dest);
        isme_src = IsInterfaceAddress(ip_addresses, src);

        Log(LOG_LEVEL_DEBUG, "%ld: UDP packet from '%s' to '%s'", iteration, src, dest);
        if (isme_dest)
        {
            cf_this[ob_udp_in]++;
            IncrementCounter(&(NETIN_DIST[IP_TYPES_UDP]), src);
        }
        else if (isme_src)
        {
            cf_this[ob_udp_out]++;
            IncrementCounter(&(NETOUT_DIST[IP_TYPES_UDP]), dest);
        }
    }
    else if (strstr(arrival, "proto ICMP"))
    {
        sscanf(arr, "%s %*c %s %c ", src, dest, &flag);
        DePort(src);
        DePort(dest);
        isme_dest = IsInterfaceAddress(ip_addresses, dest);
        isme_src = IsInterfaceAddress(ip_addresses, src);

        Log(LOG_LEVEL_DEBUG, "%ld: ICMP packet from '%s' to '%s'", iteration, src, dest);

        if (isme_dest)
        {
            cf_this[ob_icmp_in]++;
            IncrementCounter(&(NETIN_DIST[IP_TYPES_ICMP]), src);
        }
        else if (isme_src)
        {
            cf_this[ob_icmp_out]++;
            IncrementCounter(&(NETOUT_DIST[IP_TYPES_ICMP]), src);
        }
    }
    else
    {
        Log(LOG_LEVEL_DEBUG, "%ld: Miscellaneous undirected packet (%.100s)", iteration, arrival);

        cf_this[ob_tcpmisc_in]++;

        /* Here we don't know what source will be, but .... */

        sscanf(arrival, "%s", src);

        if (!isdigit((int) *src))
        {
            Log(LOG_LEVEL_DEBUG, "Assuming continuation line...");
            return;
        }

        DePort(src);

        if (strstr(arrival, ".138"))
        {
            snprintf(dest, CF_BUFSIZE - 1, "%s NETBIOS", src);
        }
        else if (strstr(arrival, ".2049"))
        {
            snprintf(dest, CF_BUFSIZE - 1, "%s NFS", src);
        }
        else
        {
            strncpy(dest, src, 60);
            dest[60] = '\0';
        }
        IncrementCounter(&(NETIN_DIST[IP_TYPES_TCP_MISC]), dest);
    }
}
Ejemplo n.º 18
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10;
	StatusType result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19, result_inst_20;
	StatusType result_inst_21, result_inst_22, result_inst_23, result_inst_24, result_inst_25, result_inst_26, result_inst_27, result_inst_28, result_inst_29, result_inst_30;
	StatusType result_inst_31, result_inst_32, result_inst_33, result_inst_34, result_inst_35, result_inst_36, result_inst_37, result_inst_38, result_inst_39;
	ScheduleTableStatusType ScheduleTableStatusType_inst_1, ScheduleTableStatusType_inst_2, ScheduleTableStatusType_inst_3, ScheduleTableStatusType_inst_4, ScheduleTableStatusType_inst_5;
	ScheduleTableStatusType ScheduleTableStatusType_inst_6, ScheduleTableStatusType_inst_7, ScheduleTableStatusType_inst_8, ScheduleTableStatusType_inst_9, ScheduleTableStatusType_inst_10, ScheduleTableStatusType_inst_11;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = StartScheduleTableSynchron(sched_explicit);
	SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1);
		
	SCHEDULING_CHECK_INIT(2);
	result_inst_2 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2, SCHEDULETABLE_WAITING , ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_2);
		
	SCHEDULING_CHECK_INIT(3);
	result_inst_3 = SyncScheduleTable(sched_explicit, 8);
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_3);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_4 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(4, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_4);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_5 = IncrementCounter(Software_Counter1);
	/*offset = 1 (sc) - 9 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK, result_inst_5);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_6 = IncrementCounter(Software_Counter1);
	/*offset = 2 (sc) - 0 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_7 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(7, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK, result_inst_7);
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_8 = SetScheduleTableAsync(sched_explicit);
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_8);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_9 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(9, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_9);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_10 = IncrementCounter(Software_Counter1);
	/*offset = 3 (sc) - 1 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_10);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_11 = IncrementCounter(Software_Counter1);
	/*offset = 4 (sc) - 2 (st) -> t2 activated */
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK, result_inst_11);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_12 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(13, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_12);
	
	SCHEDULING_CHECK_INIT(14);
	result_inst_13 = IncrementCounter(Software_Counter1);
	/*offset = 5 (sc) - 3 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_13);
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_14 = IncrementCounter(Software_Counter1);
	/*offset = 6 (sc) - 4 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK, result_inst_14);
	
	SCHEDULING_CHECK_INIT(16);
	result_inst_15 = IncrementCounter(Software_Counter1);
	/*offset = 7 (sc) - 5 (st) -> t2 received Event1 */
	SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OK, result_inst_15);
	
	SCHEDULING_CHECK_INIT(19);
	result_inst_16 = IncrementCounter(Software_Counter1);
	/*offset = 8 (sc) - 6 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(19,E_OK, result_inst_16);
	
	SCHEDULING_CHECK_INIT(20);
	result_inst_17 = IncrementCounter(Software_Counter1);
	/*offset = 9 (sc) - 7 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK, result_inst_17);
	
	SCHEDULING_CHECK_INIT(21);
	result_inst_18 = IncrementCounter(Software_Counter1);
	/*offset = 10 (sc) - 8 (st) -> t2 received Event1 */
	SCHEDULING_CHECK_AND_EQUAL_INT(22,E_OK, result_inst_18);
	
	SCHEDULING_CHECK_INIT(23);
	result_inst_19 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_6);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(23, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_6);
	SCHEDULING_CHECK_AND_EQUAL_INT(23,E_OK, result_inst_19);
	
	SCHEDULING_CHECK_INIT(24);
	result_inst_20 = SyncScheduleTable(sched_explicit, 8);
	SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OK, result_inst_20);
		
	SCHEDULING_CHECK_INIT(25);
	result_inst_21 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_7);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(25, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_7);
	SCHEDULING_CHECK_AND_EQUAL_INT(25,E_OK, result_inst_21);
	
	SCHEDULING_CHECK_INIT(26);
	result_inst_22 = IncrementCounter(Software_Counter1);
	/*offset = 11 (sc) - 9 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OK, result_inst_22);
	
	SCHEDULING_CHECK_INIT(27);
	result_inst_23 = IncrementCounter(Software_Counter1);
	/*offset = 12 (sc) - 0 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(27,E_OK, result_inst_23);
	
	SCHEDULING_CHECK_INIT(28);
	result_inst_24 = IncrementCounter(Software_Counter1);
	/*offset = 13 (sc) - 1 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OK, result_inst_24);
	
	SCHEDULING_CHECK_INIT(29);
	result_inst_25 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_8);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(29, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_8);
	SCHEDULING_CHECK_AND_EQUAL_INT(29,E_OK, result_inst_25);
	
	SCHEDULING_CHECK_INIT(30);
	result_inst_26 = SyncScheduleTable(sched_explicit, 4);
	SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OK, result_inst_26);
	
	SCHEDULING_CHECK_INIT(31);
	result_inst_27 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_9);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(31, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_9);
	SCHEDULING_CHECK_AND_EQUAL_INT(31,E_OK, result_inst_27);
	
	SCHEDULING_CHECK_INIT(32);
	result_inst_28 = IncrementCounter(Software_Counter1);
	/*offset = 14 (sc) - 5 (st) -> t2 activated */
	SCHEDULING_CHECK_AND_EQUAL_INT(33,E_OK, result_inst_28);
	
	SCHEDULING_CHECK_INIT(34);
	result_inst_29 = SetScheduleTableAsync(sched_explicit);
	SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OK, result_inst_29);
	
	SCHEDULING_CHECK_INIT(35);
	result_inst_30 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_10);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(35, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_10);
	SCHEDULING_CHECK_AND_EQUAL_INT(35,E_OK, result_inst_30);
	
	SCHEDULING_CHECK_INIT(36);
	result_inst_31 = IncrementCounter(Software_Counter1);
	/*offset = 15 (sc) - 6->5 (st) -> t2 receive Event1 */
	SCHEDULING_CHECK_AND_EQUAL_INT(38,E_OK, result_inst_31);
	
	SCHEDULING_CHECK_INIT(39);
	result_inst_32 = IncrementCounter(Software_Counter1);
	/*offset = 16 (sc) - 6 (st)  */
	SCHEDULING_CHECK_AND_EQUAL_INT(39,E_OK, result_inst_32);
	
	SCHEDULING_CHECK_INIT(40);
	result_inst_33 = IncrementCounter(Software_Counter1);
	/*offset = 17 (sc) - 7 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(40,E_OK, result_inst_33);
	
	SCHEDULING_CHECK_INIT(41);
	result_inst_34 = IncrementCounter(Software_Counter1);
	/*offset = 18 (sc) - 8 (st) -> t2 received Event1 */
	SCHEDULING_CHECK_AND_EQUAL_INT(42,E_OK, result_inst_34);
	
	SCHEDULING_CHECK_INIT(43);
	result_inst_35 = IncrementCounter(Software_Counter1);
	/*offset = 19 (sc) - 9 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(43,E_OK, result_inst_35);
	
	SCHEDULING_CHECK_INIT(44);
	result_inst_36 = IncrementCounter(Software_Counter1);
	/*offset = 20 (sc) - 0 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(44,E_OK, result_inst_36);
	
	SCHEDULING_CHECK_INIT(45);
	result_inst_37 = IncrementCounter(Software_Counter1);
	/*offset = 21 (sc) - 1 (st) */
	SCHEDULING_CHECK_AND_EQUAL_INT(45,E_OK, result_inst_37);
	
	SCHEDULING_CHECK_INIT(46);
	result_inst_38 = IncrementCounter(Software_Counter1);
	/*offset = 22 (sc) - 2 (st) -> t2 activated */
	SCHEDULING_CHECK_AND_EQUAL_INT(47,E_OK, result_inst_38);
	
	SCHEDULING_CHECK_INIT(48);
	result_inst_39 = GetScheduleTableStatus(sched_explicit, &ScheduleTableStatusType_inst_11);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(48, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_11);
	SCHEDULING_CHECK_AND_EQUAL_INT(48,E_OK, result_inst_39);
	
	
}
Ejemplo n.º 19
0
AlarmIncrementType IncrementAlarm(AlarmType AlarmID, AlarmIncrementType Increment)
{
	AlarmIncrementType RestIncrements;
	AlarmIncrementType AlarmCount;
	CounterIncrementType CounterIncrement;    

	/* init arlarms count */
	AlarmCount = 0;

	/* check if the increment is smaller than the expiration time */
	if ( AlarmsVar[AlarmID].AlarmTime > Increment )
	{
		/* decrement the alarm*/
		AlarmsVar[AlarmID].AlarmTime -= Increment;

		/* alarm doesn't expires now */
		RestIncrements = AlarmsVar[AlarmID].AlarmTime;
	}
	else
	{
		/* increment is graeter or equal than the alarm time, the alarm may
			expire one or more times */

		/* check if new alarm time has to be set */
		if(AlarmsVar[AlarmID].AlarmCycleTime == 0)
		{
			/* in case of a non cyclic alarm */

			/* alarm has expires 1 time */
			AlarmCount = 1;

			/* set alarm to 0 */
			AlarmsVar[AlarmID].AlarmTime = 0;

			/* disable alarm */
			AlarmsVar[AlarmID].AlarmState = 0;

			/* set rest increments to zero */
			RestIncrements = 0;
		}
		else
		{
			/* the alarm is cyclic */

			/* decrement alarm */
			while ( AlarmsVar[AlarmID].AlarmTime <= Increment )
			{
				/* add cycle time */
				AlarmsVar[AlarmID].AlarmTime += AlarmsVar[AlarmID].AlarmCycleTime;

				/* increment Alarms expiration times */
				AlarmCount++;
			}

			/* decrement the increments of this alarm */
			AlarmsVar[AlarmID].AlarmTime -= Increment;

			/* store the rest increments */
			RestIncrements = AlarmsVar[AlarmID].AlarmTime;
		}

		if (AlarmsConst[AlarmID].AlarmAction == INCREMENT)
		{
			/* call counter function */
			CounterIncrement = IncrementCounter(AlarmsConst[AlarmID].AlarmActionInfo.Counter, AlarmCount);

			/* re-calculate the rest of the increments */
			RestIncrements += AlarmsVar[AlarmID].AlarmCycleTime * ( CounterIncrement-1 );
		}
		else
		{
			/* execute the alarm so many times as needed */
			for ( ;AlarmCount > 0; AlarmCount--)
			{
				/* check alarm actions differents to INCREMENT */
				switch(AlarmsConst[AlarmID].AlarmAction)
				{
					case ACTIVATETASK:
						/* activate task */
                        ActivateTask(AlarmsConst[AlarmID].AlarmActionInfo.TaskID);
						break;
					case ALARMCALLBACK:
						/* callback */
						if(AlarmsConst[AlarmID].AlarmActionInfo.CallbackFunction != NULL)
						{
							AlarmsConst[AlarmID].AlarmActionInfo.CallbackFunction();
						}
						break;
#if (NO_EVENTS == DISABLE)
					case SETEVENT:
                        // TODO: Kristian enable this, when task is ready.
                        /* set event */
						// SetEvent(AlarmsConst[AlarmID].AlarmActionInfo.TaskID, AlarmsConst[AlarmID].AlarmActionInfo.Event);
						break;
#endif /* #if (NO_EVENTS == DISABLE) */
					default:
						/* some error */
						/* possibly TODO, report an error */
						break;
				}
			}
		}
	}

	return RestIncrements;
}
Ejemplo n.º 20
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_isr1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11;
	TickType TickType_inst_1, TickType_inst_2, TickType_inst_3, TickType_inst_4, TickType_inst_6, TickType_inst_8, TickType_inst_9, TickType_inst_10, tick_temp;
	TickType TickType_inst_5 = OSMAXALLOWEDVALUE_Software_Counter + 1;
	TickType TickType_inst_7 = OSMAXALLOWEDVALUE_Hardware_Counter + 1;
	TickType alarm_increment = 2;
	EventMaskType EventMaskType_inst_1;

	SCHEDULING_CHECK_INIT(2);
	result_inst_1 = GetCounterValue(Hardware_Counter, &TickType_inst_1);	
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_1);
	
	WaitCounterDeltaValue(Hardware_Counter, 3);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = GetCounterValue(Hardware_Counter, &TickType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(3, (TickType_inst_1 + 3)%(OSMAXALLOWEDVALUE_Hardware_Counter + 1) , TickType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK , result_inst_2);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_3 = SetRelAlarm(Alarm1, alarm_increment, 0);	
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_3);	
	
	WaitActivationOneShotAlarm(Alarm1);
		
	SCHEDULING_CHECK_INIT(5);
	tick_temp = TickType_inst_2;
	result_inst_4 = GetElapsedCounterValue(Hardware_Counter, &TickType_inst_2, &TickType_inst_3);	   
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5,E_OK , result_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5,(tick_temp + alarm_increment)%(OSMAXALLOWEDVALUE_Hardware_Counter + 1) , TickType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(5,alarm_increment , TickType_inst_3);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_5 = GetEvent(t1, &EventMaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(6,Event1 , EventMaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK , result_inst_5);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_6 = IncrementCounter(Hardware_Counter);	
	SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OS_ID, result_inst_6);
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_7 = IncrementCounter(INVALID_COUNTER);	
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_ID, result_inst_7);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_8 = GetCounterValue(INVALID_COUNTER, &TickType_inst_4);	
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OS_ID, result_inst_8);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_9 = GetElapsedCounterValue(Software_Counter, &TickType_inst_5, &TickType_inst_6);	
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_VALUE, result_inst_9);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_10 = GetElapsedCounterValue(Hardware_Counter, &TickType_inst_7, &TickType_inst_8);	
	SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_VALUE, result_inst_10);
	
	SCHEDULING_CHECK_INIT(12);
	result_inst_11 = GetElapsedCounterValue(INVALID_COUNTER, &TickType_inst_9, &TickType_inst_10);	
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_ID, result_inst_11);
		
}
Ejemplo n.º 21
0
byte SEAL::GenerateByte()
{
	if (position == L/8)
		IncrementCounter();
	return buffer[position++];
}
Ejemplo n.º 22
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15;
	ScheduleTableStatusType ScheduleTableStatusType_inst_1, ScheduleTableStatusType_inst_2, ScheduleTableStatusType_inst_3, ScheduleTableStatusType_inst_4, ScheduleTableStatusType_inst_5, ScheduleTableStatusType_inst_6;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = ActivateTask(t3);
	SCHEDULING_CHECK_AND_EQUAL_INT(2, E_OK, result_inst_1);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(3, SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_2);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_3 = StartScheduleTableRel(sched1, 1);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_3);

	SCHEDULING_CHECK_INIT(5);
	result_inst_4 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK, result_inst_4);
	
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_5 = IncrementCounter(Software_Counter);
	/*start schedule table (because StartScheduleTabelRel(x, 1))*/
	/*offset = 0+offset_sched -> t5 and t3 */
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_5);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_6 = IncrementCounter(Software_Counter);
	/*offset = 1+offset_sched -> t4 and t3 */
	SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(14);
	result_inst_7 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(14, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_7);
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_8 = IncrementCounter(Software_Counter);
	/*offset = 2+offset_sched*/
	SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK, result_inst_8);
	
	SCHEDULING_CHECK_INIT(16);
	result_inst_9 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(16, SCHEDULETABLE_RUNNING , ScheduleTableStatusType_inst_4);
	SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OK, result_inst_9);
	
	SCHEDULING_CHECK_INIT(17);
	result_inst_10 = IncrementCounter(Software_Counter);
	/*offset = 3+offset_sched*/
	SCHEDULING_CHECK_AND_EQUAL_INT(17,E_OK, result_inst_10);
	
	SCHEDULING_CHECK_INIT(18);
	result_inst_11 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(18, SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_5);
	SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OK, result_inst_11);
	
	
	SCHEDULING_CHECK_INIT(19);
	result_inst_12 = StartScheduleTableRel(sched2, 1);
	SCHEDULING_CHECK_AND_EQUAL_INT(19,E_OK, result_inst_12);
	
	SCHEDULING_CHECK_INIT(20);
	result_inst_13 = IncrementCounter(Software_Counter);
	/*start schedule table (because StartScheduleTabelRel(x, 1))*/
	SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK, result_inst_13);
	
	SCHEDULING_CHECK_INIT(21);
	result_inst_14 = IncrementCounter(Software_Counter);
	/*offset = 1+offset_sched -> t3 and t2 */
	SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OK, result_inst_14);
	
	SCHEDULING_CHECK_INIT(25);
	result_inst_15 = GetScheduleTableStatus(sched2, &ScheduleTableStatusType_inst_6);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(25, SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_6);
	SCHEDULING_CHECK_AND_EQUAL_INT(25,E_OK, result_inst_15);
	
	
}
Ejemplo n.º 23
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	ApplicationType ApplicationType_inst_1, ApplicationType_inst_2;
	ISRType ISRType_inst_1;
	ObjectAccessType ObjectAccessType_inst_1;
	ScheduleTableStatusType ScheduleTableStatusType_inst_1;
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12;
	TickType TickType_inst_1, TickType_inst_2;
	
	SCHEDULING_CHECK_STEP(1);
	DisableAllInterrupts();
	
	SCHEDULING_CHECK_INIT(2);
	ApplicationType_inst_1 = GetApplicationID();
	SCHEDULING_CHECK_AND_EQUAL_INT(3, app1, ApplicationType_inst_1);
	
	SCHEDULING_CHECK_INIT(4);
	ISRType_inst_1 = GetISRID();
	SCHEDULING_CHECK_AND_EQUAL_INT(5, INVALID_ISR, ISRType_inst_1);
	
	SCHEDULING_CHECK_INIT(6);
	ObjectAccessType_inst_1 = CheckObjectAccess(app1, OBJECT_TASK, t1);
	SCHEDULING_CHECK_AND_EQUAL_INT(7, ACCESS, ObjectAccessType_inst_1);

	SCHEDULING_CHECK_INIT(8);
	ApplicationType_inst_2 = CheckObjectOwnership(OBJECT_TASK, t1);
	SCHEDULING_CHECK_AND_EQUAL_INT(9, app1, ApplicationType_inst_2);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_1 = StartScheduleTableRel(sched1, 1);
	SCHEDULING_CHECK_AND_EQUAL_INT(11, E_OS_DISABLEDINT, result_inst_1);

	SCHEDULING_CHECK_INIT(12);
	result_inst_2 = StartScheduleTableAbs(sched1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(13, E_OS_DISABLEDINT, result_inst_2);
		
	SCHEDULING_CHECK_INIT(14);
	result_inst_3 = StopScheduleTable(sched1);
	SCHEDULING_CHECK_AND_EQUAL_INT(15, E_OS_DISABLEDINT, result_inst_3);
	
	SCHEDULING_CHECK_INIT(16);
	result_inst_4 = NextScheduleTable(sched1, sched2);
	SCHEDULING_CHECK_AND_EQUAL_INT(17, E_OS_DISABLEDINT, result_inst_4);
		
	SCHEDULING_CHECK_INIT(18);
	result_inst_5 = StartScheduleTableSynchron(sched1);
	SCHEDULING_CHECK_AND_EQUAL_INT(19, E_OS_DISABLEDINT, result_inst_5);
	
	SCHEDULING_CHECK_INIT(20);
	result_inst_6 = SyncScheduleTable(sched1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(21, E_OS_DISABLEDINT, result_inst_6);
	
	SCHEDULING_CHECK_INIT(22);
	result_inst_7 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(23, E_OS_DISABLEDINT, result_inst_7);
	
	SCHEDULING_CHECK_INIT(24);
	result_inst_8 = SetScheduleTableAsync(sched1);
	SCHEDULING_CHECK_AND_EQUAL_INT(25, E_OS_DISABLEDINT, result_inst_8);
	
	SCHEDULING_CHECK_INIT(26);
	result_inst_9 = IncrementCounter(Software_Counter1);
	SCHEDULING_CHECK_AND_EQUAL_INT(27, E_OS_DISABLEDINT, result_inst_9);
	
	SCHEDULING_CHECK_INIT(28);
	result_inst_10 = GetCounterValue(Software_Counter1, &TickType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(29, E_OS_DISABLEDINT, result_inst_10);
	
	SCHEDULING_CHECK_INIT(30);
	result_inst_11 = GetElapsedCounterValue(Software_Counter1, &TickType_inst_1, &TickType_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(31, E_OS_DISABLEDINT, result_inst_11);
	
	SCHEDULING_CHECK_INIT(32);
	result_inst_12 = TerminateApplication(app1, NO_RESTART);
	SCHEDULING_CHECK_AND_EQUAL_INT(33, E_OS_DISABLEDINT, result_inst_12);

	SCHEDULING_CHECK_STEP(34);	
	EnableAllInterrupts();
	
	/*
	 Missing :
		- CallTrustedFunction
		- CheckISRMemoryAccess
		- CheckTaskMemoryAccess
		- GetActiveApplicationMode (OS tests)
	 Ok but not tested :
		- StartOS (OS tests)
		- ShutdownOS (OS tests)
	 */
}
Ejemplo n.º 24
0
//=============================================================================
// API Functions
//=============================================================================
//-----------------------------------------------------------------------------
// CTR_EncryptDecrypt()
//
// parameters:
//    operation       - decryption/encrypt & 128/192/256 options
//    plainText       - xdata pointer to plainText
//    cipherText      - xdata pointer to cipherText
//    counter         - xdata pointer to counter
//    encryptionKey   - xdata pointer to encryption key
//
// returns:
//    status         - 0 for success
//                   - 1 for ERROR - Invalid operation parameter.
//
// description:
//
// This function performs Counter (CTR) Mode Encryption or Decryption of a
// specified number of 16-byte blocks.
//
// The plaintext, and encryption key must be stored in xdata prior to calling
// an encryption operation.
//
// Note that the plainText pointer is a pointer to the source data for an
// encryption operation and a pointer to the destination data for a decryption
// operation.
//
// The ciphertext and encryption key must be stored in xdata prior to calling
// an decryption operation. The CTR mode decryption operation uses the AES
// core in encryption mode. So the encryption key is always used for any CTR
// operation.
//
// The counter should be initialized using a nonce at the start of an
// encryption sequence.
//
// This function will return an error if the operation parameter is invalid.
// Using the error code is optional, but will aid in debugging.
//
// The AES code examples uses four channels as defined in the DMA-defs.h file.
// The channel assignments are static and fixed at compile time. They are
// not assigned dynamically.
//
// This function puts the MCU core into idle mode while encryption/decryption
// is in process. This function is blocking. The function does not return
// until after the encryption/decryption operation has completed.
//
// A interrupt is needed to wake up from Idle mode. This requires that the
// global interrupts are enabled. Also, a small DMA ISR that disables EIE2
// bit 5 is required in the main module.
//
// Note that CTR encryption/decryption requires one DMA transfer per block.
// It is not possible to encrypt/decrypt multiple blocks using a single DMA
// transfer because the counter must be incremented between blocks.
//
//-----------------------------------------------------------------------------
CTR_ENCRYPT_DECRYPT_STATUS
   CTR_EncryptDecrypt (CTR_ENCRYPT_DECRYPT_OPERATION operation,
   VARIABLE_SEGMENT_POINTER(plainText, U8, SEG_XDATA),
   VARIABLE_SEGMENT_POINTER(cipherText, U8, SEG_XDATA),
   VARIABLE_SEGMENT_POINTER(counter, U8, SEG_XDATA),
   VARIABLE_SEGMENT_POINTER(encryptionKey, U8, SEG_XDATA),
   U16 blocks)
{
   // Unions used for compiler independent endianness.
   UU16 length;                        // Length in bytes for all blocks.
   UU16 addr;                          // Union used to access pointer bytes.

   U8 keyLength;                       // Used to calculate key length in bytes.

   // Check first for valid operation.
   if((operation == DECRYPTION_UNDEFINED)||(operation >= ENCRYPTION_UNDEFINED))
   {
      return ERROR_INVALID_PARAMETER;
   }
   else
   {
      // Calculate key length in bytes based on operation parameter.
      keyLength = (((operation & 0x03) + 2) << 3);
   }

   // Calculate plaintext and ciphertext total length.
   // Using <<4 in lieu of * 16 for code efficiency.
   length.U16 = (blocks << 4);

   // From this point on, "blocks" is used to count remaining blocks.
   blocks--;

   SFRPAGE = DPPE_PAGE;

   AES0BCFG = 0x00;                      // disable, for now
   AES0DCFG = 0x00;                      // disable for now

   // Disable AES0KIN, AES0BIN, AES0XIN, & AES0YOUT channels.
   DMA0EN &= ~AES0_KBXY_MASK;

   // Configure AES key input channel using key pointer.
   // Set length to calculated key length.
   // Set DMA0NMD to disable Key wrapping.
   // This is necessary because we want the Key DMA channel
   // to stop after the first block.

   addr.U16 = (U16)(encryptionKey);
   DMA0SEL = AES0KIN_CHANNEL;
   DMA0NCF = AES0KIN_PERIPHERAL_REQUEST;
   DMA0NMD = NO_WRAPPING;
   DMA0NBAL = addr.U8[LSB];
   DMA0NBAH = addr.U8[MSB];
   DMA0NSZH = 0;
   DMA0NSZL = keyLength;
   DMA0NAOL = 0;
   DMA0NAOH = 0;

   // AES block input is always the counter value for both CTR encryption
   // and decryption. Set length to 16 for first block only.
   // Clear DMA0NMD to disable counter wrapping.
   // This is necessary because we want the Counter DMA channel
   // to stop after the first block.

   DMA0SEL = AES0BIN_CHANNEL;
   DMA0NCF = AES0BIN_PERIPHERAL_REQUEST;
   DMA0NMD = NO_WRAPPING;
   addr.U16 = (U16)(counter);
   DMA0NBAL = addr.U8[LSB];
   DMA0NBAH = addr.U8[MSB];
   DMA0NSZL = 16;                      // one block
   DMA0NSZH = 0;
   DMA0NAOL = 0;
   DMA0NAOH = 0;

   // AES XOR input is plaintext for encryption operation or ciphertext
   // for decryption operation.

   if(operation & ENCRYPTION_MODE)
      addr.U16 = (U16)(plainText);
   else
      addr.U16 = (U16)(cipherText);

   // Configure AES XOR input channel using corresponding address.
   // Clear DMA0NMD to disable wrapping.

   DMA0SEL = AES0XIN_CHANNEL;
   DMA0NCF = AES0XIN_PERIPHERAL_REQUEST;
   DMA0NMD = NO_WRAPPING;
   DMA0NBAL = addr.U8[LSB];
   DMA0NBAH = addr.U8[MSB];
   DMA0NSZL = 16;                      // one block
   DMA0NSZH = 0;
   DMA0NAOL = 0;
   DMA0NAOH = 0;

   // AES Y output is ciphertext  for encryption operation or
   // plaintext for decryption operation.

   if(operation & ENCRYPTION_MODE)
      addr.U16 = (U16)(cipherText);
   else
      addr.U16 = (U16)(plainText);

   // Configure AES Y output channel using corresponding address
   // Set length to 16 for first block only.
   // Clear DMA0NMD to disable wrapping.

   DMA0SEL = AES0YOUT_CHANNEL;
   DMA0NCF = AES0YOUT_PERIPHERAL_REQUEST|DMA_INT_EN;
   DMA0NMD = NO_WRAPPING;

   DMA0NBAL = addr.U8[LSB];
   DMA0NBAH = addr.U8[MSB];
   DMA0NSZL = 16;                      // one block
   DMA0NSZH = 0;
   DMA0NAOH = 0;
   DMA0NAOL = 0;

   // Clear KBXY (Key, Block, X in, and Y out) bits in DMA0INT sfr using mask.
   DMA0INT &= ~AES0_KBXY_MASK;


   // Set KBXY (Key, Block, Xin, and Y out) bits in DMA0EN sfr using mask.
   // This enables the DMA. But the encryption/decryption operation
   // won't start until the AES block is enabled.
   DMA0EN  |=  AES0_KBXY_MASK;

   // Configure data path for XOR on output. CTR mode always has the
   // XOR on the output for both encryption and decryption.
   AES0DCFG = XOR_ON_OUTPUT;

   // Configure AES0BCFG for encryption/decryption and requested key size.
   // Note the encryption mode bit is set explicitly.
   AES0BCFG = operation;
   AES0BCFG |= ENCRYPTION_MODE;
   AES0BCFG |= AES_ENABLE;

    // Enable DMA interrupt to terminate Idle mode.
    EIE2 |= 0x20;

   // This do...while loop ensures that the CPU will remain in Idle mode
   // until AES0YOUT DMA channel transfer is complete.
   do
   {
      #ifdef DMA_TRANSFERS_USE_IDLE
      PCON |= 0x01;                    // go to Idle mode
      #endif
   }  while((DMA0INT&AES0YOUT_MASK)==0);

   while(blocks--)                     // if blocks remaining
   {
      // It is necessary to either pause the AES DMA channels
      // or disable the AES block while changing the setup.
      // Both steps are taken in this example to be extra safe.

      // Disable AES block.
      // This also clears the AES contents and resets the state machine.
      // It is not necessary to reset the AES core between blocks.
      // But it is recommended to disable the core while changing the set-up.

      AES0BCFG &= ~AES_ENABLE;

      // Pause DMA channels used by AES block.
      DMA0EN &= ~AES0_KBXY_MASK;

      IncrementCounter(counter);

      SFRPAGE = DPPE_PAGE;

      // AESKIN DMA channel reset address offset
      DMA0SEL = AES0KIN_CHANNEL;
      DMA0NAOL = 0;
      DMA0NAOH = 0;

      // AESBIN DMA channel reset address offset
      DMA0SEL = AES0BIN_CHANNEL;
      DMA0NAOL = 0;
      DMA0NAOH = 0;

      // Ch 2 AES0XIN increment size by 16 bytes
      DMA0SEL = AES0XIN_CHANNEL;
      length.U8[LSB] = DMA0NSZL;
      length.U8[MSB] = DMA0NSZH;
      length.U16 += 16;
      DMA0NSZL = length.U8[LSB];
      DMA0NSZH = length.U8[MSB];

     // Ch 3 AESYOUT increment size by 16 bytes
      DMA0SEL = AES0YOUT_CHANNEL;
      length.U8[LSB] = DMA0NSZL;
      length.U8[MSB] = DMA0NSZH;
      length.U16 += 16;
      DMA0NSZL = length.U8[LSB];
      DMA0NSZH = length.U8[MSB];

      // Clear KBXY (Key, Block, X in, and Y out) bits in DMA0INT sfr using mask.
      DMA0INT &= ~AES0_KBXY_MASK;

      // Set KBXY (Key, Block, Xin, and Y out) bits in DMA0EN sfr using mask.
      // This enables the DMA. But the encryption/decryption operation
      // won't start until the AES block is enabled.
      DMA0EN  |=  AES0_KBXY_MASK;

      // Enabled AES module to start encryption/decryption operation.
      AES0BCFG |= AES_ENABLE;

      // enable DMA interrupt to terminate Idle mode
      EIE2 |= 0x20;

      // This do...while loop ensures that the CPU will remain in Idle mode
      // until AES0YOUT DMA channel transfer is complete.
      do
      {
         #ifdef DMA_TRANSFERS_USE_IDLE
         PCON |= 0x01;                 // go to Idle mode
         #endif
      }  while((DMA0INT & AES0YOUT_MASK)==0);
   }

   //Clear AES Block
   AES0BCFG = 0x00;
   AES0DCFG = 0x00;

   // Clear KXBY (Key, Block, XOR, and Y out) bits in DMA0EN sfr using mask.
   DMA0EN &= ~AES0_KBXY_MASK;

   // Clear KBY (Key, Block, and Y out) bits in DMA0INT sfr using mask.
   DMA0INT &= ~AES0_KBXY_MASK;

   return SUCCESS;
}
Ejemplo n.º 25
0
/*test case:test the reaction of the system called with
 an activation of a task*/
static void test_t1_instance(void)
{
    StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11;
    StatusType result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19, result_inst_20, result_inst_21, result_inst_22, result_inst_23, result_inst_24;
    ScheduleTableStatusType ScheduleTableStatusType_inst_1, ScheduleTableStatusType_inst_2, ScheduleTableStatusType_inst_3, ScheduleTableStatusType_inst_4, ScheduleTableStatusType_inst_5, ScheduleTableStatusType_inst_6;

    SCHEDULING_CHECK_INIT(1);
    result_inst_1 = StartScheduleTableAbs(sched1, 1);
    SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1);

    SCHEDULING_CHECK_INIT(2);
    result_inst_2 = StartScheduleTableAbs(sched2, 1);
    SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_2);

    SCHEDULING_CHECK_INIT(3);
    result_inst_3 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_1);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(3, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_1);
    SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_3);

    SCHEDULING_CHECK_INIT(4);
    result_inst_4 = GetScheduleTableStatus(sched2, &ScheduleTableStatusType_inst_2);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(4, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_2);
    SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_4);

    SCHEDULING_CHECK_INIT(5);
    result_inst_5 = IncrementCounter(Software_Counter1);
    /*offset = 1 -> sched1 starts */
    SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK, result_inst_5);

    SCHEDULING_CHECK_INIT(6);
    result_inst_6 = IncrementCounter(Software_Counter2);
    /*offset = 1 -> sched2 starts and event1 can't be set -> errorhook*/
    SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK, result_inst_6);

    SCHEDULING_CHECK_INIT(8);
    result_inst_7 = IncrementCounter(Software_Counter1);
    /*offset = 2 -> t2 starts */
    SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_7);

    SCHEDULING_CHECK_INIT(10);
    result_inst_8 = IncrementCounter(Software_Counter2);
    /*offset = 2 */
    SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_8);

    SCHEDULING_CHECK_INIT(11);
    result_inst_9 = IncrementCounter(Software_Counter1);
    /*offset = 3  */
    SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OK, result_inst_9);

    SCHEDULING_CHECK_INIT(12);
    result_inst_10 = IncrementCounter(Software_Counter2);
    /*offset = 3 -> */
    SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK, result_inst_10);

    SCHEDULING_CHECK_INIT(13);
    result_inst_11 = IncrementCounter(Software_Counter1);
    /*offset = 4 -> sched2 restarts */
    SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_11);

    SCHEDULING_CHECK_INIT(14);
    result_inst_12 = IncrementCounter(Software_Counter2);
    /*offset = 4 -> */
    SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_12);

    SCHEDULING_CHECK_INIT(15);
    result_inst_13 = IncrementCounter(Software_Counter1);
    /*offset = 5 -> t2 can't start -> errorhook */
    SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OK, result_inst_13);

    SCHEDULING_CHECK_INIT(17);
    result_inst_14 = IncrementCounter(Software_Counter2);
    /*offset = 5 */
    SCHEDULING_CHECK_AND_EQUAL_INT(17,E_OK, result_inst_14);

    SCHEDULING_CHECK_INIT(18);
    result_inst_15 = IncrementCounter(Software_Counter1);
    /*offset = 6 */
    SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OK, result_inst_15);

    SCHEDULING_CHECK_INIT(19);
    result_inst_16 = IncrementCounter(Software_Counter2);
    /*offset = 6 -> t2 received event1 */
    SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK, result_inst_16);

    SCHEDULING_CHECK_INIT(21);
    result_inst_17 = IncrementCounter(Software_Counter1);
    /*offset = 7 */
    SCHEDULING_CHECK_AND_EQUAL_INT(21,E_OK, result_inst_17);

    SCHEDULING_CHECK_INIT(22);
    result_inst_18 = IncrementCounter(Software_Counter2);
    /*offset = 7 -> t2 can't received event1 -> errorhook */
    SCHEDULING_CHECK_AND_EQUAL_INT(23,E_OK, result_inst_18);

    SCHEDULING_CHECK_INIT(24);
    result_inst_19 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_3);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(24, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_3);
    SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OK, result_inst_19);

    SCHEDULING_CHECK_INIT(25);
    result_inst_20 = GetScheduleTableStatus(sched2, &ScheduleTableStatusType_inst_4);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(25, SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS , ScheduleTableStatusType_inst_4);
    SCHEDULING_CHECK_AND_EQUAL_INT(25,E_OK, result_inst_20);

    SCHEDULING_CHECK_INIT(26);
    result_inst_21 = StopScheduleTable(sched1);
    SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OK, result_inst_21);

    SCHEDULING_CHECK_INIT(27);
    result_inst_22 = StopScheduleTable(sched2);
    SCHEDULING_CHECK_AND_EQUAL_INT(27,E_OK, result_inst_22);

    SCHEDULING_CHECK_INIT(28);
    result_inst_23 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_5);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28, SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_5);
    SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OK, result_inst_23);

    SCHEDULING_CHECK_INIT(29);
    result_inst_24 = GetScheduleTableStatus(sched2, &ScheduleTableStatusType_inst_6);
    SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(29, SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_6);
    SCHEDULING_CHECK_AND_EQUAL_INT(29,E_OK, result_inst_24);


}