made a copy

This commit is contained in:
Richard Barry 2008-02-13 10:36:35 +00:00
parent bb7dc7c37f
commit e20f132f48
2632 changed files with 751681 additions and 0 deletions

View file

@ -0,0 +1,23 @@
#include "FreeRTOSConfig.h"
#include <stdlib.h>
static long brk_siz = 0;
// #if configTOTAL_HEAP_SIZE != 0
typedef int _heep_t;
#define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
#define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
/* #else
extern char *_heep;
extern long _heep_size;
#endif
*/
extern char *sbrk(int size)
{
if (brk_siz + size > _heep_size || brk_siz + size < 0)
return((char*)-1);
brk_siz += size;
return( (char*)_heep + brk_siz - size);
}

View file

@ -0,0 +1,397 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
#include "FreeRTOS.h"
#include "task.h"
#include "mb91467d.h"
/*-----------------------------------------------------------*/
/* We require the address of the pxCurrentTCB variable, but don't want to know
any details of its type. */
typedef void tskTCB;
extern volatile tskTCB * volatile pxCurrentTCB;
/* Constants required to handle critical sections. */
#define portNO_CRITICAL_NESTING ( ( unsigned portBASE_TYPE ) 0 )
volatile unsigned portLONG ulCriticalNesting = 9999UL;
/*-----------------------------------------------------------*/
#pragma asm
#macro SaveContext
ORCCR #0x20 ;Switch to user stack
ST RP,@-R15 ;Store RP
STM0 (R7,R6,R5,R4,R3,R2,R1,R0) ;Store R7-R0
STM1 (R14,R13,R12,R11,R10,R9,R8) ;Store R14-R8
ST MDH, @-R15 ;Store MDH
ST MDL, @-R15 ;Store MDL
LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter
LD @R0, R0 ;Get the value of the critical nesting counter
ST R0, @-R15 ;Store the critical nesting value to the user stack.
ANDCCR #0xDF ;Switch back to system stack
LD @R15+,R0 ;Store PC to R0
ORCCR #0x20 ;Switch to user stack
ST R0,@-R15 ;Store PC to User stack
ANDCCR #0xDF ;Switch back to system stack
LD @R15+,R0 ;Store PS to R0
ORCCR #0x20 ;Switch to user stack
ST R0,@-R15 ;Store PS to User stack
LDI #_pxCurrentTCB, R0 ;Get pxCurrentTCB address
LD @R0, R0 ;Get the pxCurrentTCB->pxTopOfStack address
ST R15,@R0 ;Store USP to pxCurrentTCB->pxTopOfStack
ANDCCR #0xDF ;Switch back to system stack for the rest of tick ISR
#endm
#macro RestoreContext
LDI #_pxCurrentTCB, R0 ;Get pxCurrentTCB address
LD @R0, R0 ;Get the pxCurrentTCB->pxTopOfStack address
ORCCR #0x20 ;Switch to user stack
LD @R0, R15 ;Restore USP from pxCurrentTCB->pxTopOfStack
LD @R15+,R0 ;Store PS to R0
ANDCCR #0xDF ;Switch to system stack
ST R0,@-R15 ;Store PS to system stack
ORCCR #0x20 ;Switch to user stack
LD @R15+,R0 ;Store PC to R0
ANDCCR #0xDF ;Switch to system stack
ST R0,@-R15 ;Store PC to system stack
ORCCR #0x20 ;Switch back to retreive the remaining context
LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter
LD @R15+, R1 ;Get the saved critical nesting value
ST R1, @R0 ;Save the critical nesting value into the ulCriticalNesting variable
LD @R15+, MDL ;Restore MDL
LD @R15+, MDH ;Restore MDH
LDM1 (R14,R13,R12,R11,R10,R9,R8) ;Restore R14-R8
LDM0 (R7,R6,R5,R4,R3,R2,R1,R0) ;Restore R7-R0
LD @R15+, RP ;Restore RP
ANDCCR #0xDF ;Switch back to system stack for the rest of tick ISR
#endm
#pragma endasm
/*-----------------------------------------------------------*/
/*
* Perform hardware setup to enable ticks from timer 1,
*/
static void prvSetupTimerInterrupt( void );
/*-----------------------------------------------------------*/
/*
* Initialise the stack of a task to look exactly as if a call to
* portSAVE_CONTEXT had been called.
*
* See the header file portable.h.
*/
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
/* Place a few bytes of known values on the bottom of the stack.
This is just useful for debugging. */
*pxTopOfStack = 0x11111111;
pxTopOfStack--;
*pxTopOfStack = 0x22222222;
pxTopOfStack--;
*pxTopOfStack = 0x33333333;
pxTopOfStack--;
/* This is a redundant push to the stack, it may be required if in some implentation of the compiler
the parameter to the task is passed on to the stack rather than in R4 register*/
*pxTopOfStack = (portSTACK_TYPE)(pvParameters);
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00000000; /* RP */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00007777; /* R7 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00006666; /* R6 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00005555; /* R5 */
pxTopOfStack--;
/* In the current implemention of the compiler the first
parameter to the task(or function) is passed via R4 parameter
to the task, hennce the pvParameters pointer is copied in R4
regsiter. See compiler manual section 4.6.2 for more information.*/
*pxTopOfStack = ( portSTACK_TYPE ) (pvParameters); /* R4 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00003333; /* R3 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00002222; /* R2 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00001111; /* R1 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00000001; /* R0 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x0000EEEE; /* R14 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x0000DDDD; /* R13 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x0000CCCC; /* R12 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x0000BBBB; /* R11 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x0000AAAA; /* R10 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00009999; /* R9 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x00008888; /* R8 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x11110000; /* MDH */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x22220000; /* MDL */
pxTopOfStack--;
/* The task starts with its ulCriticalNesting variable set to 0, interrupts
being enabled. */
*pxTopOfStack = portNO_CRITICAL_NESTING;
pxTopOfStack--;
/* The start of the task code. */
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
pxTopOfStack--;
/* PS - User Mode, USP, ILM=31, Interrupts enabled */
*pxTopOfStack = ( portSTACK_TYPE ) 0x001F0030; /* PS */
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
portBASE_TYPE xPortStartScheduler( void )
{
/* Setup the hardware to generate the tick. */
prvSetupTimerInterrupt();
/* Restore the context of the first task that is going to run. */
#pragma asm
RestoreContext
#pragma endasm
/* Simulate a function call end as generated by the compiler. We will now
jump to the start of the task the context of which we have just restored. */
__asm(" reti ");
/* Should not get here. */
return pdTRUE;
}
/*-----------------------------------------------------------*/
void vPortEndScheduler( void )
{
/* Not implemented - unlikely to ever be required as there is nothing to
return to. */
}
/*-----------------------------------------------------------*/
/*
* Setup RLT0 to generate a tick interrupt.
*/
static void prvSetupTimerInterrupt( void )
{
/* The peripheral clock divided by 32 is used by the timer. */
const unsigned portSHORT usReloadValue = ( unsigned portSHORT ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );
TMCSR0_CNTE=0; /* Count Disable */
TMCSR0_CSL=0x2; /* CLKP/32 */
TMCSR0_MOD=0; /* Software trigger */
TMCSR0_RELD=1; /* Reload */
TMCSR0_UF=0; /* Clear underflow flag */
TMRLR0=usReloadValue;
TMCSR0_INTE=1; /* Interrupt Enable */
TMCSR0_CNTE=1; /* Count Enable */
TMCSR0_TRG=1; /* Trigger */
PORTEN = 0x3; /* Port Enable */
}
/*-----------------------------------------------------------*/
#if configUSE_PREEMPTION == 1
/*
* Tick ISR for preemptive scheduler. The tick count is incremented
* after the context is saved. Then the context is switched if required,
* at last the context of the task which is to be resume is restored.
*/
#pragma asm
.global _ReloadTimer0_IRQHandler
_ReloadTimer0_IRQHandler:
ANDCCR #0xEF ;Disable Interrupts
SaveContext ;Save context
ORCCR #0x10 ;Re-enable Interrupts
LDI #0xFFFB,R1
LDI #_tmcsr0, R0
AND R1,@R0 ;Clear RLT0 interrupt flag
CALL32 _vTaskIncrementTick,R12 ;Increment Tick
CALL32 _vTaskSwitchContext,R12 ;Switch context if required
ANDCCR #0xEF ;Disable Interrupts
RestoreContext ;Restore context
ORCCR #0x10 ;Re-enable Interrupts
RETI
#pragma endasm
#else
/*
* Tick ISR for the cooperative scheduler. All this does is increment the
* tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD();
*/
__interrupt void ReloadTimer0_IRQHandler( void )
{
/* Clear RLT0 interrupt flag */
TMCSR0_UF = 0;
vTaskIncrementTick();
}
#endif
/*
* Manual context switch. We can use a __nosavereg attribute as the context
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
* the context of the new task is restored saved.
*/
#pragma asm
.global _vPortYieldDelayed
_vPortYieldDelayed:
ANDCCR #0xEF ;Disable Interrupts
SaveContext ;Save context
ORCCR #0x10 ;Re-enable Interrupts
LDI #_dicr, R0
BANDL #0x0E, @R0 ;Clear Delayed interrupt flag
CALL32 _vTaskSwitchContext,R12 ;Switch context if required
ANDCCR #0xEF ;Disable Interrupts
RestoreContext ;Restore context
ORCCR #0x10 ;Re-enable Interrupts
RETI
#pragma endasm
/*
* Manual context switch. We can use a __nosavereg attribute as the context
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
* the context of the new task is restored saved.
*/
#pragma asm
.global _vPortYield
_vPortYield:
SaveContext ;Save context
CALL32 _vTaskSwitchContext,R12 ;Switch context if required
RestoreContext ;Restore context
RETI
#pragma endasm
/*-----------------------------------------------------------*/
void vPortEnterCritical( void )
{
/* Disable interrupts */
portDISABLE_INTERRUPTS();
/* Now interrupts are disabled ulCriticalNesting can be accessed
directly. Increment ulCriticalNesting to keep a count of how many times
portENTER_CRITICAL() has been called. */
ulCriticalNesting++;
}
/*-----------------------------------------------------------*/
void vPortExitCritical( void )
{
if( ulCriticalNesting > portNO_CRITICAL_NESTING )
{
ulCriticalNesting--;
if( ulCriticalNesting == portNO_CRITICAL_NESTING )
{
/* Enable all interrupt/exception. */
portENABLE_INTERRUPTS();
}
}
}
/*-----------------------------------------------------------*/

View file

@ -0,0 +1,111 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "mb91467d.h"
#include <stddef.h>
/*-----------------------------------------------------------
* Port specific definitions.
*
* The settings in this file configure FreeRTOS correctly for the
* given hardware and compiler.
*
* These settings should not be altered.
*-----------------------------------------------------------
*/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE unsigned portLONG
#define portBASE_TYPE long
/* This is required since SOFTUNE doesn't support inline directive as is. */
#define inline
#if( configUSE_16_BIT_TICKS == 1 )
typedef unsigned portSHORT portTickType;
#define portMAX_DELAY ( portTickType ) 0xffff
#else
typedef unsigned portLONG portTickType;
#define portMAX_DELAY ( portTickType ) 0xffffffff
#endif
/*-----------------------------------------------------------*/
/* Critical section management. */
void vPortEnterCritical( void );
void vPortExitCritical( void );
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
#define portDISABLE_INTERRUPTS() __DI();
#define portENABLE_INTERRUPTS() __EI();
/*-----------------------------------------------------------*/
/* Architecture specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 4
#define portNOP() __asm( " nop " );
/*-----------------------------------------------------------*/
/* portYIELD() uses SW interrupt */
#define portYIELD() __asm( " INT #40H " );
/* portYIELD_FROM_ISR() uses delayed interrupt */
#define portYIELD_FROM_ISR() DICR_DLYI = 1
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
#endif /* PORTMACRO_H */

View file

@ -0,0 +1,33 @@
/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
/* ELIGIBILITY FOR ANY PURPOSES. */
/* (C) Fujitsu Microelectronics Europe GmbH */
/*---------------------------------------------------------------------------
__STD_LIB_sbrk.C
- Used by heap_3.c for memory accocation and deletion.
/*---------------------------------------------------------------------------*/
#include "FreeRTOSConfig.h"
#include <stdlib.h>
static long brk_siz = 0;
// #if configTOTAL_HEAP_SIZE != 0
typedef int _heep_t;
#define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
#define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
/* #else
extern char *_heep;
extern long _heep_size;
#endif
*/
extern char *sbrk(int size)
{
if (brk_siz + size > _heep_size || brk_siz + size < 0)
return((char*)-1);
brk_siz += size;
return( (char*)_heep + brk_siz - size);
}

View file

@ -0,0 +1,589 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
#include "FreeRTOS.h"
#include "task.h"
#include "mb96348hs.h"
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the 16FX port.
*----------------------------------------------------------*/
/*
* Get current value of DPR and ADB registers
*/
portSTACK_TYPE xGet_DPR_ADB_bank( void );
/*
* Get current value of DTB and PCB registers
*/
portSTACK_TYPE xGet_DTB_PCB_bank( void );
/*
* Get current register pointer
*/
portCHAR xGet_RP( void );
/*
* Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but
* can be done using any given RLT.
*/
static void prvSetupRLT0Interrupt( void );
/*-----------------------------------------------------------*/
/*
* We require the address of the pxCurrentTCB variable, but don't want to know
* any details of its type.
*/
typedef void tskTCB;
extern volatile tskTCB * volatile pxCurrentTCB;
/* Constants required to handle critical sections. */
#define portNO_CRITICAL_NESTING ( ( unsigned portBASE_TYPE ) 0 )
volatile unsigned portBASE_TYPE uxCriticalNesting = 9999UL;
/*-----------------------------------------------------------*/
/*
* Macro to save a task context to the task stack. This macro copies the
* saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from the system
* stack to task stack pointed by user stack pointer ( USP for SMALL and
* MEDIUM memory model amd USB:USP for COMPACT and LARGE memory model ),
* then it pushes the general purpose registers RW0-RW7 on to the task
* stack. Finally the resultant stack pointer value is saved into the
* task control block so it can be retrieved the next time the task
* executes.
*/
#if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
#define portSAVE_CONTEXT() \
{ __asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
\
/* Save the critical nesting count to the stack. */ \
__asm(" MOVW RW0, _uxCriticalNesting "); \
__asm(" PUSHW (RW0) "); \
\
__asm(" MOVW A, _pxCurrentTCB "); \
__asm(" MOVW A, SP "); \
__asm(" SWAPW "); \
__asm(" MOVW @AL, AH "); \
__asm(" OR CCR,#H'20 "); \
}
/*
* Macro to restore a task context from the task stack. This is effecti-
* vely the reverse of SAVE_CONTEXT(). First the stack pointer value
* (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT and
* LARGE memory model ) is loaded from the task control block. Next the
* value of all the general purpose registers RW0-RW7 is retrieved. Fina-
* lly it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS) of
* the task to be executed upon RETI from user stack to system stack.
*/
#define portRESTORE_CONTEXT() \
{ __asm(" MOVW A, _pxCurrentTCB "); \
__asm(" MOVW A, @A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" MOVW SP, A "); \
\
/* Load the saved uxCriticalNesting value into RW0. */ \
__asm(" POPW (RW0) "); \
\
/* Save the loaded value into the uxCriticalNesting variable. */ \
__asm(" MOVW _uxCriticalNesting, RW0 "); \
\
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
}
#elif (configMEMMODEL == portCOMPACT || configMEMMODEL == portLARGE)
#define portSAVE_CONTEXT() \
{ __asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" MOVL A, _pxCurrentTCB "); \
__asm(" MOVL RL2, A "); \
__asm(" MOVW A, SP "); \
__asm(" MOVW @RL2+0, A "); \
__asm(" MOV A, USB "); \
__asm(" MOV @RL2+2, A "); \
}
#define portRESTORE_CONTEXT() \
{ __asm(" MOVL A, _pxCurrentTCB "); \
__asm(" MOVL RL2, A "); \
__asm(" MOVW A, @RL2+0 "); \
__asm(" AND CCR,#H'DF "); \
__asm(" MOVW SP, A "); \
__asm(" MOV A, @RL2+2 "); \
__asm(" MOV USB, A "); \
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
}
#endif
/*-----------------------------------------------------------*/
/*
* The below are the functions for getting the current value of DPR:ADB,
* DTB:PCB bank registers
*/
#pragma asm
.GLOBAL _xGet_DPR_ADB_bank
.GLOBAL _xGet_DTB_PCB_bank
.GLOBAL _xGet_RP
.SECTION CODE, CODE, ALIGN=1
_xGet_DPR_ADB_bank:
MOV A, DPR
SWAP
MOV A, ADB
ORW A
#if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE
RETP
#elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
RET
#endif
_xGet_DTB_PCB_bank:
MOV A, DTB
SWAP
MOV A, PCB
ORW A
#if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE
RETP
#elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
RET
#endif
_xGet_RP:
PUSHW PS
POPW A
SWAP
ANDW A,#0x1f
#if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE
RETP
#elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
RET
#endif
#pragma endasm
/*-----------------------------------------------------------*/
/*
* Initialise the stack of a task to look exactly as if a call to
* portSAVE_CONTEXT had been called.
*
* See the header file portable.h.
*/
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
/* Place a few bytes of known values on the bottom of the stack.
This is just useful for debugging. */
*pxTopOfStack = 0x1111;
pxTopOfStack--;
*pxTopOfStack = 0x2222;
pxTopOfStack--;
*pxTopOfStack = 0x3333;
pxTopOfStack--;
/* Once the task is called the task would push the pointer to the
parameter on to the stack. Hence here the pointer would be copied first
to the stack. In case of COMPACT or LARGE memory model such pointer
would be 24 bit and in case of SMALL or MEDIUM memory model such pointer
would be 16 bit */
#if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( portSTACK_TYPE ) ( ( unsigned portLONG ) ( pvParameters ) >> 16 );
pxTopOfStack--;
}
#endif
*pxTopOfStack = ( portSTACK_TYPE ) ( pvParameters );
pxTopOfStack--;
/* This is redundant push to the stack. This is required in order to introduce
an offset so that the task accesses a parameter correctly that is passed on to
the task stack. */
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--;
}
#endif
/* This is redundant push to the stack. This is required in order to introduce
an offset so that the task accesses a parameter correctly that is passed on to
the task stack. */
*pxTopOfStack = ( portSTACK_TYPE ) ( pxCode );
pxTopOfStack--;
/* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */
*pxTopOfStack = 0xE0C0;
pxTopOfStack--;
/* PC */
*pxTopOfStack = ( portSTACK_TYPE ) ( pxCode );
pxTopOfStack--;
/* DTB | PCB */
#if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
{
*pxTopOfStack = xGet_DTB_PCB_bank();
pxTopOfStack--;
}
#endif
/* DTB | PCB, in case of portMEDIUM or portLARGE memory model PCB would be used
along with PC to indicate the start address of the functiom */
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--;
}
#endif
/* DPR | ADB */
*pxTopOfStack = xGet_DPR_ADB_bank();
pxTopOfStack--;
/* AL */
*pxTopOfStack = ( portSTACK_TYPE ) 0x9999;
pxTopOfStack--;
/* AH */
*pxTopOfStack = ( portSTACK_TYPE ) 0xAAAA;
pxTopOfStack--;
/* Next the general purpose registers. */
*pxTopOfStack = ( portSTACK_TYPE ) 0x7777; /* RW7 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x6666; /* RW6 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x5555; /* RW5 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x4444; /* RW4 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x3333; /* RW3 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222; /* RW2 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111; /* RW1 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x8888; /* RW0 */
pxTopOfStack--;
/* The task starts with its uxCriticalNesting variable set to 0, interrupts
being enabled. */
*pxTopOfStack = portNO_CRITICAL_NESTING;
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
static void prvSetupRLT0Interrupt( void )
{
/* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */
TMRLR0 = 0x88B7;
/* prescaler 1:16, reload, interrupt enable, count enable, trigger */
TMCSR0 = 0x041B;
}
/*-----------------------------------------------------------*/
portBASE_TYPE xPortStartScheduler( void )
{
/* Setup the hardware to generate the tick. */
prvSetupRLT0Interrupt();
/* Restore the context of the first task that is going to run. */
portRESTORE_CONTEXT();
/* Simulate a function call end as generated by the compiler. We will now
jump to the start of the task the context of which we have just restored. */
__asm(" reti ");
/* Should not get here. */
return pdTRUE;
}
/*-----------------------------------------------------------*/
void vPortEndScheduler( void )
{
/* Not implemented - unlikely to ever be required as there is nothing to
return to. */
}
/*-----------------------------------------------------------*/
/*
* The interrupt service routine used depends on whether the pre-emptive
* scheduler is being used or not.
*/
#if configUSE_PREEMPTION == 1
/*
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute
* as the context would be saved by PortSAVE_CONTEXT(). The tick count
* is incremented after the context is saved.
*/
__nosavereg __interrupt void prvRLT0_TICKISR( void )
{
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
__DI();
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Enable interrupts */
__EI();
/* Clear RLT0 interrupt flag */
TMCSR0_UF = 0;
/* Increment the tick count then switch to the highest priority task
that is ready to run. */
vTaskIncrementTick();
vTaskSwitchContext();
/* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */
__DI();
/* Restore the context of the new task. */
portRESTORE_CONTEXT();
/* Enable interrupts */
__EI();
}
#else
/*
* Tick ISR for the cooperative scheduler. All this does is increment the
* tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD();
*/
__interrupt void prvRLT0_TICKISR( void )
{
/* Clear RLT0 interrupt flag */
TMCSR0_UF = 0;
vTaskIncrementTick();
}
#endif
/*-----------------------------------------------------------*/
/*
* Manual context switch. We can use a __nosavereg attribute as the context
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
* the context of the new task is restored saved.
*/
__nosavereg __interrupt void vPortYield( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext();
/* Restore the context of the new task. */
portRESTORE_CONTEXT();
}
/*-----------------------------------------------------------*/
__nosavereg __interrupt void vPortYieldDelayed( void )
{
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
__DI();
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Enable interrupts */
__EI();
/* Clear delayed interrupt flag */
__asm (" CLRB 03A4H:0 ");
/* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext();
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
__DI();
/* Restore the context of the new task. */
portRESTORE_CONTEXT();
/* Enable interrupts */
__EI();
}
/*-----------------------------------------------------------*/
void vPortEnterCritical( void )
{
/* Disable interrupts */
portDISABLE_INTERRUPTS();
/* Now interrupts are disabled uxCriticalNesting can be accessed
directly. Increment uxCriticalNesting to keep a count of how many times
portENTER_CRITICAL() has been called. */
uxCriticalNesting++;
}
/*-----------------------------------------------------------*/
void vPortExitCritical( void )
{
if( uxCriticalNesting > portNO_CRITICAL_NESTING )
{
uxCriticalNesting--;
if( uxCriticalNesting == portNO_CRITICAL_NESTING )
{
/* Enable all interrupt/exception. */
portENABLE_INTERRUPTS();
}
}
}
/*-----------------------------------------------------------*/

View file

@ -0,0 +1,116 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "mb96348hs.h"
#include <stddef.h>
#define portSMALL 0
#define portMEDIUM 1
#define portCOMPACT 2
#define portLARGE 3
/*-----------------------------------------------------------
* Port specific definitions.
*
* The settings in this file configure FreeRTOS correctly for the
* given hardware and compiler.
*
* These settings should not be altered.
*-----------------------------------------------------------
*/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE unsigned portSHORT
#define portBASE_TYPE portSHORT
#if( configUSE_16_BIT_TICKS == 1 )
typedef unsigned portSHORT portTickType;
#define portMAX_DELAY ( portTickType ) 0xffff
#else
typedef unsigned portLONG portTickType;
#define portMAX_DELAY ( portTickType ) 0xffffffff
#endif
/*-----------------------------------------------------------*/
/* Critical section handling. */
#define portDISABLE_INTERRUPTS() __DI();
#define portENABLE_INTERRUPTS() __EI();
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/*-----------------------------------------------------------*/
/* Architecture specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 2
#define portNOP() __asm( " NOP " );
/*-----------------------------------------------------------*/
/* portYIELD() uses SW interrupt */
#define portYIELD() __asm( " INT #122 " );
/* portYIELD_FROM_ISR() uses delayed interrupt */
#define portYIELD_FROM_ISR() __asm( " SETB 03A4H:0 " );
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
/* Remove the inline declaration from within the kernel code. */
#define inline
#endif /* PORTMACRO_H */