Пример #1
0
/*
 *  OS�̋N��
 */
void
StartOS(AppModeType mode)
{
	volatile FP startuphook_adr;

	LOG_STAOS_ENTER(mode);

	/*
	 *  �A�v���P�[�V�������[�h�̐ݒ�
	 */
	appmode = mode;

	/*
	 *  �^�[�Q�b�g�ˑ��̏�����
	 */
	cpu_initialize();
	sys_initialize();
	tool_initialize();

	/*
	 *  �e���W���[���̏�����
	 */
	object_initialize();

	/*
	 *  StartupHook �̌Ăяo��
	 *  
	 *  C�����̋K�i�ł͊֐��̃A�h���X��0�ɂȂ��Ȃ��Ƃ����O�񂩂�,
	 *  �R���p�C���̍œK���ɂ���StartupHook�̃A�h���X���蕪����
	 *  �폜�����Ă��܂��ꍇ�����邽��, volatile�w�肵�����[�J���ϐ���
	 *  �A�h���X���������Ă��画�肵�Ă����D
	 *
	 */
	startuphook_adr = (FP)StartupHook;
	
	if (startuphook_adr != NULL) {
		/*
		 *  StartupHook �̒��ŁCSuspendAllInterrupts ���Ă΂�
		 *  �Ă������v�Ȃ悤�ɁCsus_all_cnt �����[���ɂ��Ă����D
		 */
		callevel = TCL_STARTUP;
		sus_all_cnt++;
		StartupHook();
		sus_all_cnt--;
	}
	callevel = TCL_TASK;

	LOG_STAOS_LEAVE();

	start_dispatch();
}
Пример #2
0
/*
 *  OSの起動
 */
void
StartOS(AppModeType mode)
{
	volatile FP startuphook_adr;

	LOG_STAOS_ENTER(mode);

	/*
	 *  アプリケーションモードの設定
	 */
	appmode = mode;

	/*
	 *  ターゲット依存の初期化
	 */
	cpu_initialize();
	sys_initialize();
	tool_initialize();

	/*
	 *  各モジュールの初期化
	 */
	object_initialize();

	/*
	 *  StartupHook の呼び出し
	 *  
	 *  C言語の規格では関数のアドレスは0にならないという前提から,
	 *  コンパイラの最適化によりStartupHookのアドレス判定分岐が
	 *  削除されてしまう場合があるため, volatile指定したローカル変数に
	 *  アドレスを代入してから判定している.
	 *
	 */
	startuphook_adr = (FP)StartupHook;
	
	if (startuphook_adr != NULL) {
		/*
		 *  StartupHook の中で,SuspendAllInterrupts が呼ばれ
		 *  ても大丈夫なように,sus_all_cnt を非ゼロにしておく.
		 */
		callevel = TCL_STARTUP;
		sus_all_cnt++;
		StartupHook();
		sus_all_cnt--;
	}
	callevel = TCL_TASK;

	LOG_STAOS_LEAVE();
	start_dispatch();
}
Пример #3
0
/*
 *  OS Start
 */
void
StartOS(AppModeType mode)
{
    volatile FP startuphook_adr;

    LOG_STAOS_ENTER(mode);

    /*
     *  Store
     */
    appmode = mode;

    /*
     *  Do the needed initialize
     */
    cpu_initialize();  /* implemented in cpu_context.c */
    sys_initialize();  /* user defined interface */
    tool_initialize(); /* user defined interface */

    /*
     *  Initialize OSEK OS objects.
     */
    object_initialize();

    /*
     *  StartupHook の呼び出し
     *
     *  C言語の規格では関数のアドレスは0にならないという前提から,
     *  コンパイラの最適化によりStartupHookのアドレス判定分岐が
     *  削除されてしまう場合があるため, volatile指定したローカル変数に
     *  アドレスを代入してから判定している.
     *
     */
    startuphook_adr = (FP)StartupHook;

    if (startuphook_adr != NULL) {
        /*
         *  StartupHook の中で,SuspendAllInterrupts が呼ばれ
         *  ても大丈夫なように,sus_all_cnt を非ゼロにしておく.
         */
        callevel = TCL_STARTUP;
        sus_all_cnt++;
        StartupHook();
        sus_all_cnt--;
    }
    callevel = TCL_TASK;

    LOG_STAOS_LEAVE();
    start_dispatch();
}
Пример #4
0
void StartOS( AppModeType Mode )
{

	memset(knl_alarm_cb,0u,sizeof(knl_alarm_cb));
	knl_bitmap = 0u;

	StartupHook();

	Irq_Enable();
	
	for(;;)
	{
		(void)Schedule();
	}
}
Пример #5
0
/* |------------------+------------------------------------------------------| */
EXPORT void StartOS ( AppModeType AppMode )
{
	DISABLE_INTERRUPT();
	knl_dispatch_disabled = 1; /* Dispatch disable */
#if defined( OpenOSEKStartupHook )
	OpenOSEKStartupHook();
#endif
	knl_appmode = AppMode;
	knl_task_init();
#if(cfgOS_ALARM_NUM > 0)
	knl_alarm_counter_init();
#endif
	knl_resource_init();
#if(cfgOS_STARTUPHOOK == 1)
	StartupHook();
#endif
    knl_force_dispatch();
    
}
Пример #6
0
EXTERN_C void StartOS(void)
{
  StartupHook();

  os::start_os();
}
Пример #7
0
/* 
 * StartOS API call.
 * This service is called to start the operating system in a specific mode.
 */
void os_StartOS(AppModeType appmode)
{
	os_ipl save_ipl;
	
	OS_SAVE_IPL(save_ipl);									/* Save IPL on entry so can restore on exit, side-effect: assigns back to save_ipl */
	
	ENTER_KERNEL_DIRECT();								/* Set IPL to kernel level while setting up OS variables etc. */
	OS_API_TRACE_START_OS();
	INIT_STACKCHECK_TO_OFF();							/* Make sure stack checking is turned off so that when/if dispatch() is called there are no stack errors
														 * Note that this requires the kernel stack (i.e. main()'s stack) is big enough to support this call to
														 * StartOS plus a call to dispatch() and the entry into the subsequent task
														 */
#ifndef NDEBUG
	assert_initialized();								/* assert the C runtime startup has setup all vars to startup state */
#endif
	
	/* Saving a jmp_buf (os_startosenv) so that the entire OS can be terminated via a longjmp call inside a ShutdownOS call */
	/* $Req: artf1216 artf1219 $ */
	if (SETJMP(os_startosenv) == 0) {					
														/* This half of the 'if' is the half that is the run-on continuation */
		/* $Req: artf1214 artf1094 $ */
		os_appmode = appmode;							/* Store application mode in which the OS was started */

		/* setup the tasks and alarms that are to be autostarted for the given app mode */													
		start_tasks(appmode);
		
		/* Initialize all counters in the system to start running */
		start_counters();
		
		/* Autostart alarms */
		if(appmode->start_alarms_singleton) {
			appmode->start_alarms_singleton(appmode);
		}

		if(appmode->start_alarms_multi) {
			appmode->start_alarms_multi(appmode);
		}
		
		/* Autostarted schedule tables are autostarted implicitly by the underlying alarms being autostarted */

#ifdef STACK_CHECKING	
		os_curtos = OS_KS_TOP;
#endif

		/* Call startup hook if required to do so */
		/* $Req: artf1215 $ */
		if (os_flags.startuphook) {						/* check if need to call the startuphook handler */
														/* hook needs calling */
			ENABLE_STACKCHECK();						/* enable stack checking */
			/* @todo check that we really need to raise IPL to lock out all interrupts (both CAT1 and CAT2) within the hook */			
			OS_SET_IPL_MAX();							/* raise IPL to lock out all interrupts (both CAT1 and CAT2) within the hook */
			MARK_OUT_KERNEL();							/* drop out of the kernel, keeping IPL at max level  */
			/* $Req: artf1117 $ */
			StartupHook();								/* call the hook routine with IPL set to kernel level and stack checking on */
			MARK_IN_KERNEL();							/* go back into the kernel */
			OS_SET_IPL_KERNEL();						/* set IPL back to kernel level */
			DISABLE_STACKCHECK();						/* disable stack checking */
		}

		/* Start the scheduling activity */
		if (TASK_SWITCH_PENDING(os_curpri)) {
			os_ks_dispatch();
		}
		
		ENABLE_STACKCHECK();
		LEAVE_KERNEL();

		/* now running as the body of the os_idle task, with IPL at level 0 and priority of IDLEPRI */
		/* $Req: artf1116 $ */
		/* Note that interrupts will be enabled prior to here because the os_ks_dispatch() call above
		 * might switch to running autostarted tasks, which will lower interrupts to level 0
		 */		
		for ( ; ; ) {
			os_idle();										/* call the os_idle task entry function */
		}
		
		NOT_REACHED();
	}
	else {
														/* This half of the 'if' is the half that is RETURNING from a longjmp */
														/* We have come back from a ShutdownOS() call */
	}
	
	/* Reached here because ShutdownOS(E_OK) was called.
	 * 
	 * $Req: artf1219 $
	 */
	assert(KERNEL_LOCKED());
	assert(STACKCHECK_OFF());							/* Stack checking turned off prior to longjmp in shutdown() */
		
	/* Would normally stop the counters, reinitialise the kernel variables, etc. in case StartOS() were to be called again,
	 * but OS424 (artf1375) requires that StartOS() doesn't return, but instead goes into an infinite loop.
	 * Similarly, OS425 (artf1376) requires that interrupts are disabled before entering the loop.
	 * 
	 * If StartOS() is ever required to return to caller, see revision 568 of this file (startos.c) for the
	 * original code that did this.
	 * 
	 * $Req: artf1375 $
	 * $Req: artf1376 $
	 */
	OS_SET_IPL_MAX();
	for(;;)
		;
}
Пример #8
0
/*==================[external functions definition]==========================*/
void StartOS
(
   AppModeType Mode
)
{
   /* \req OSEK_SYS_3.25 The system service void
    ** StartOS ( AppModeType Mode ) shall be defined */

   /* \req OSEK_SYS_3.25.1 This system service shall starts the operating
    ** system */
   uint8f loopi;

   IntSecure_Start();

   /* save the aplication mode */
   ApplicationMode = Mode;

   /* StartOs_Arch */
   StartOs_Arch();


   /* init every task */
   for( loopi = 0; loopi < TASKS_COUNT; loopi++)
   {
      /* \req OSEK_SYS_3.1.2-2/3 The operating system shall ensure that the task
       ** code is being executed from the first statement. */
      SetEntryPoint(loopi); /* set task entry point */
   }

   /* set sys context */
   SetActualContext(CONTEXT_SYS);

   /* set actual task to invalid task */
   SetRunningTask(INVALID_TASK);

   /* add to ready the corresponding tasks for this
    * Application Mode */
   for (loopi = 0; loopi < AutoStart[Mode].TotalTasks; loopi++)
   {
      /* activate task */
      ActivateTask(AutoStart[Mode].TasksRef[loopi]);
   }

   for (loopi = 0; loopi < ALARM_AUTOSTART_COUNT; loopi++)
   {
      if (AutoStartAlarm[loopi].Mode == Mode)
      {
         (void)SetRelAlarm(AutoStartAlarm[loopi].Alarm, AutoStartAlarm[loopi].AlarmTime, AutoStartAlarm[loopi].AlarmCycleTime);
      }
   }

#if (HOOK_STARTUPHOOK == OSEK_ENABLE)
   StartupHook();
#endif

   IntSecure_End();

   /* enable all OS interrupts */
   EnableOSInterrupts();

   /* enable interrupts */
   EnableInterrupts();

   /* call Scheduler */
   (void)Schedule();

   /* this function shall never return */
   while(1);
}