int32_t xPortStartScheduler()

in GCC/TriCore_38xa/port.c [198:263]


int32_t xPortStartScheduler( void )
{
	extern void vTrapInstallHandlers( void );
	uint32_t ulMFCR = 0UL;
	uint32_t *pulUpperCSA = NULL;
	uint32_t *pulLowerCSA = NULL;

	/* prevent compiler warnings */
	(void)pulUpperCSA;

	/* Interrupts at or below configMAX_SYSCALL_INTERRUPT_PRIORITY are disable
	when this function is called. */

	/* Set-up the ERU interrupt. */
	prvSetupERUInterrupt();

	/* Set-up the timer interrupt. */
	prvSetupTimerInterrupt();

	/* Install the Trap Handlers. */
	// vTrapInstallHandlers();

	/* Install the Syscall Handler for yield calls. */
	// if( 0 == _install_trap_handler( portSYSCALL_TRAP, prvTrapYield ) )
	// {
	// 	/* Failed to install the yield handler, force an assert. */
	// 	configASSERT( ( ( volatile void * ) NULL ) );
	// }

	/* Enable and install the priority 1 interrupt for pending context switches from an ISR. */
	InterruptInstall(GPSRs[CPU_ID], prvInterruptYield, configKERNEL_YIELD_PRIORITY, 0);       //ATEN

	_disable();

	/* Load the initial SYSCON. */
	_mtcr( $SYSCON, portINITIAL_SYSCON );
	_isync();

	/* ENDINIT has already been applied in the 'cstart.c' code. */

	/* Clear the PSW.CDC to enable the use of an RFE without it generating an
	exception because this code is not genuinely in an exception. */
	ulMFCR = __MFCR( $PSW );
	ulMFCR &= portRESTORE_PSW_MASK;
	_dsync();
	_mtcr( $PSW, ulMFCR );
	_isync();

	/* Finally, perform the equivalent of a portRESTORE_CONTEXT() */
	pulLowerCSA = portCSA_TO_ADDRESS( ( *pxCurrentTCB ) );
	pulUpperCSA = portCSA_TO_ADDRESS( pulLowerCSA[0] );

	_dsync();
	_mtcr( $PCXI, *pxCurrentTCB );
	_isync();
	_nop();
	_rslcx();
	_nop();


	/* Return to the first task selected to execute. */
	__asm volatile( "rfe" );

	/* Will not get here. */
	return 0;
}