From: richardbarry Date: Mon, 25 Feb 2008 18:53:23 +0000 (+0000) Subject: More work in progress (PPC). X-Git-Tag: V4.8.0~61 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eb8151c96bd37aa3ff53af571f4af4fcaa212c48;p=freertos More work in progress (PPC). git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@220 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/portable/GCC/PPC405/port.c b/Source/portable/GCC/PPC405/port.c index 774ad9285..07b90fea5 100644 --- a/Source/portable/GCC/PPC405/port.c +++ b/Source/portable/GCC/PPC405/port.c @@ -41,7 +41,7 @@ */ /*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the MicroBlaze port. + * Implementation of functions defined in portable.h for the PPC405 port. *----------------------------------------------------------*/ @@ -50,7 +50,6 @@ #include "task.h" /* Library includes. */ -#include "xexception_l.h" #include "xtime_l.h" /* Standard includes. */ @@ -58,20 +57,17 @@ /*-----------------------------------------------------------*/ -#define portCRITICAL_INTERRUPT_ENABLE ( 1UL << 14UL ) -#define portEXTERNAL_INTERRUPT_ENABLE ( 1UL << 16UL ) -#define portMACHINE_CHECK_ENABLE ( 1UL << 19UL ) +#define portCRITICAL_INTERRUPT_ENABLE ( 0UL << 17UL ) +#define portEXTERNAL_INTERRUPT_ENABLE ( 1UL << 15UL ) +#define portMACHINE_CHECK_ENABLE ( 0UL << 12UL ) #define portINITIAL_MSR ( portCRITICAL_INTERRUPT_ENABLE | portEXTERNAL_INTERRUPT_ENABLE | portMACHINE_CHECK_ENABLE ) - /* */ static void prvSetupTimerInterrupt( void ); -extern void vStartFirstTask( void ); -/*-----------------------------------------------------------*/ - -static void prvTickISR( void ); +extern void vPortTickISR( void ); extern void vPortYield( void ); +extern void vPortStartFirstTask( void ); /* * Initialise the stack of a task to look exactly as if a call to @@ -156,13 +152,13 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack--; *pxTopOfStack = 0x00000000UL; /* CTR. */ pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) vStartFirstTask; /* LR. */ + *pxTopOfStack = ( portSTACK_TYPE ) vPortStartFirstTask; /* LR. */ pxTopOfStack--; *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* SRR0. */ pxTopOfStack--; *pxTopOfStack = portINITIAL_MSR;/* SRR1. */ pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) vStartFirstTask;/* Next LR. */ + *pxTopOfStack = ( portSTACK_TYPE ) vPortStartFirstTask;/* Next LR. */ pxTopOfStack--; *pxTopOfStack = 0x00000000UL;;/* Backchain. */ // pxTopOfStack--; @@ -178,12 +174,14 @@ extern void *pxCurrentTCB; XExc_Init(); XExc_mDisableExceptions( XEXC_NON_CRITICAL ) ; -// prvSetupTimerInterrupt(); + prvSetupTimerInterrupt(); + XExc_RegisterHandler( XEXC_ID_SYSTEM_CALL, ( XExceptionHandler ) vPortYield, ( void * ) 0 ); - XExc_mEnableExceptions( XEXC_NON_CRITICAL ) ; - vStartFirstTask(); - +// XExc_mEnableExceptions( XEXC_NON_CRITICAL ); + + vPortStartFirstTask(); + /* Should not get here as the tasks are now running! */ return pdFALSE; } @@ -198,11 +196,18 @@ void vPortEndScheduler( void ) /* * Hardware initialisation to generate the RTOS tick. */ +static void prvTickISR( void ); static void prvSetupTimerInterrupt( void ) { const unsigned portLONG ulInterval = ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL ); - XExc_RegisterHandler( XEXC_ID_PIT_INT, ( XExceptionHandler ) prvTickISR, ( void * ) 0 ); + XTime_PITClearInterrupt(); + XTime_FITClearInterrupt(); + XTime_WDTClearInterrupt(); + XTime_WDTDisableInterrupt(); + XTime_FITDisableInterrupt(); + + XExc_RegisterHandler( XEXC_ID_PIT_INT, ( XExceptionHandler ) vPortTickISR, ( void * ) 0 ); XTime_PITEnableAutoReload(); XTime_PITSetInterval( ulInterval ); @@ -221,9 +226,6 @@ static unsigned portLONG ulTicks = 0; ulTicks = 0; } XTime_PITClearInterrupt(); - - #if configUSE_PREEMPTION == 1 - #endif } /*-----------------------------------------------------------*/ diff --git a/Source/portable/GCC/PPC405/portasm.s b/Source/portable/GCC/PPC405/portasm.s index da8d9f6d7..3810a8811 100644 --- a/Source/portable/GCC/PPC405/portasm.s +++ b/Source/portable/GCC/PPC405/portasm.s @@ -2,9 +2,11 @@ .extern pxCurrentTCB .extern vTaskSwitchContext + .extern vTaskIncrementTick - .global vStartFirstTask + .global vPortStartFirstTask .global vPortYield + .global vPortTickISR .set portCONTEXT_SIZE, 156 .set portR0_OFFSET, 152 @@ -196,12 +198,12 @@ .endm -vStartFirstTask: +vPortStartFirstTask: int_epilogue rfi -#vStartFirstTask: +#vPortStartFirstTask: # portRESTORE_CONTEXT # rfi @@ -214,5 +216,19 @@ vPortYield: portEXIT_SWITCHING_ISR blr - NOP - NOP +vPortTickISR: + + portENTER_SWITCHING_ISR + bl vTaskIncrementTick + #if configUSE_PREEMPTION == 1 + bl vTaskSwitchContext + #endif + + # Clear the interrupt + lis R0, 2048 + mttsr R0 + + portEXIT_SWITCHING_ISR + blr + + diff --git a/Source/portable/GCC/PPC405/portmacro.h b/Source/portable/GCC/PPC405/portmacro.h index dc895d215..5b6be119a 100644 --- a/Source/portable/GCC/PPC405/portmacro.h +++ b/Source/portable/GCC/PPC405/portmacro.h @@ -43,6 +43,8 @@ #ifndef PORTMACRO_H #define PORTMACRO_H +#include "xexception_l.h" + #ifdef __cplusplus extern "C" { #endif @@ -75,16 +77,19 @@ extern "C" { #endif /*-----------------------------------------------------------*/ +#define portCRITICAL_NESTING_IN_TCB 1 + /* Interrupt control macros. */ -#define portDISABLE_INTERRUPTS() -#define portENABLE_INTERRUPTS() +#define portDISABLE_INTERRUPTS() XExc_mDisableExceptions( XEXC_NON_CRITICAL ); +#define portENABLE_INTERRUPTS() XExc_mEnableExceptions( XEXC_NON_CRITICAL ); + /*-----------------------------------------------------------*/ /* Critical section macros. */ -void vPortEnterCritical( void ); -void vPortExitCritical( void ); -#define portENTER_CRITICAL() -#define portEXIT_CRITICAL() +void vTaskEnterCritical( void ); +void vTaskExitCritical( void ); +#define portENTER_CRITICAL() vTaskEnterCritical() +#define portEXIT_CRITICAL() vTaskExitCritical() /*-----------------------------------------------------------*/