RM48 port layer without FPU saving completed.

pull/1/head
Richard Barry 13 years ago
parent 1112439c58
commit fe2163ede4

@ -1,159 +0,0 @@
;-------------------------------------------------
;
.def vRegTestTask1
.ref usRegTest1Counter
.text
.arm
;
vRegTestTask1:
; Fill each general purpose register with a known value.
mov r0, #0xFF
mov r1, #0x11
mov r2, #0x22
mov r3, #0x33
mov r4, #0x44
mov r5, #0x55
mov r6, #0x66
mov r7, #0x77
mov r8, #0x88
mov r9, #0x99
mov r10, #0xAA
mov r11, #0xBB
mov r12, #0xCC
mov r14, #0xEE
regTestLoop1:
; Force yeild
swi #0
; Test each general purpose register to check that it still contains the
; expected known value, jumping to vRegTest1Error if any register contains
; an unexpected value.
cmp r0, #0xFF
bne regTestError1
cmp r1, #0x11
bne regTestError1
cmp r2, #0x22
bne regTestError1
cmp r3, #0x33
bne regTestError1
cmp r4, #0x44
bne regTestError1
cmp r5, #0x55
bne regTestError1
cmp r6, #0x66
bne regTestError1
cmp r7, #0x77
bne regTestError1
cmp r8, #0x88
bne regTestError1
cmp r9, #0x99
bne regTestError1
cmp r10, #0xAA
bne regTestError1
cmp r11, #0xBB
bne regTestError1
cmp r12, #0xCC
bne regTestError1
cmp r14, #0xEE
bne regTestError1
; This task is still running without jumping to vRegTest1Error, so increment
; the loop counter so the check task knows the task is running error free.
stmfd sp!, { r0-r1 }
ldr r0, count1
ldr r1, [r0]
add r1, r1, #1
str r1, [r0]
ldmfd sp!, { r0-r1 }
; Loop again, performing the same tests.
b regTestLoop1
count1 .word usRegTest1Counter
regTestError1:
b regTestError1
;-------------------------------------------------
;
.def vRegTestTask2
.ref usRegTest2Counter
.text
.arm
;
vRegTestTask2:
; Fill each general purpose register with a known value.
mov r0, #0xFF000000
mov r1, #0x11000000
mov r2, #0x22000000
mov r3, #0x33000000
mov r4, #0x44000000
mov r5, #0x55000000
mov r6, #0x66000000
mov r7, #0x77000000
mov r8, #0x88000000
mov r9, #0x99000000
mov r10, #0xAA000000
mov r11, #0xBB000000
mov r12, #0xCC000000
mov r14, #0xEE000000
regTestLoop2:
; Force yeild
swi #0
; Test each general purpose register to check that it still contains the
; expected known value, jumping to vRegTest1Error if any register contains
; an unexpected value.
cmp r0, #0xFF000000
bne regTestError2
cmp r1, #0x11000000
bne regTestError2
cmp r2, #0x22000000
bne regTestError2
cmp r3, #0x33000000
bne regTestError2
cmp r4, #0x44000000
bne regTestError2
cmp r5, #0x55000000
bne regTestError2
cmp r6, #0x66000000
bne regTestError2
cmp r7, #0x77000000
bne regTestError2
cmp r8, #0x88000000
bne regTestError2
cmp r9, #0x99000000
bne regTestError2
cmp r10, #0xAA000000
bne regTestError2
cmp r11, #0xBB000000
bne regTestError2
cmp r12, #0xCC000000
bne regTestError2
cmp r14, #0xEE000000
bne regTestError2
; This task is still running without jumping to vRegTest1Error, so increment
; the loop counter so the check task knows the task is running error free.
stmfd sp!, { r0-r1 }
ldr r0, count2
ldr r1, [r0]
add r1, r1, #1
str r1, [r0]
ldmfd sp!, { r0-r1 }
; Loop again, performing the same tests.
b regTestLoop2
count2 .word usRegTest2Counter
regTestError2:
b regTestError2
;-------------------------------------------------

@ -1,4 +1,3 @@
#if 1
/*
FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.
@ -199,445 +198,3 @@ void vApplicationTickHook( void )
}
/*-----------------------------------------------------------*/
#else
/*
FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.
***************************************************************************
* *
* FreeRTOS tutorial books are available in pdf and paperback. *
* Complete, revised, and edited pdf reference manuals are also *
* available. *
* *
* Purchasing FreeRTOS documentation will not only help you, by *
* ensuring you get running as quickly as possible and with an *
* in-depth knowledge of how to use FreeRTOS, it will also help *
* the FreeRTOS project to continue with its mission of providing *
* professional grade, cross platform, de facto standard solutions *
* for microcontrollers - completely free of charge! *
* *
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
* *
* Thank you for using FreeRTOS, and thank you for your support! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
>>>NOTE<<< The modification to the GPL is included to allow you to
distribute a combined work that includes FreeRTOS without being obliged to
provide the source code for proprietary components outside of the FreeRTOS
kernel. FreeRTOS 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 and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site.
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong? *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, training, latest information,
license and contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool.
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
the code with commercial support, indemnification, and middleware, under
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
provide a safety engineered and independently SIL3 certified version under
the SafeRTOS brand: http://www.SafeRTOS.com.
*/
/* Standard includes. */
#include <stdio.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "queue.h"
/* Library includes. */
#include "gio.h"
/* Demo application includes. */
#include "TimerDemo.h"
#include "countsem.h"
#include "GenQTest.h"
#include "dynamic.h"
/*
* "Check" callback function - Called each time the 'check' timer expires. The
* check timer executes every five seconds. Its main function is to check that
* all the standard demo tasks are still operational. Each time it executes it
* sends a status code to the LCD task. The LCD task interprets the code and
* displays an appropriate message - which will be PASS if no tasks have
* reported any errors, or a message stating which task has reported an error.
*
* "Reg test" tasks - These fill the registers with known values, then check
* that each register still contains its expected value. Each task uses
* different values. The tasks run with very low priority so get preempted
* very frequently. A check variable is incremented on each iteration of the
* test loop. A register containing an unexpected value is indicative of an
* error in the context switching mechanism and will result in a branch to a
* null loop - which in turn will prevent the check variable from incrementing
* any further and allow the check timer callback (described a above) to
* determine that an error has occurred. The nature of the reg test tasks
* necessitates that they are written in assembly code.
*
* Tick hook function - called inside the RTOS tick function, this simple
* example does nothing but toggle an LED.
*
*/
/* Codes sent within messages to the LCD task so the LCD task can interpret
exactly what the message it just received was. These are sent in the
cMessageID member of the message structure (defined below). */
#define mainERROR_DYNAMIC_TASKS ( pdPASS + 1 )
#define mainERROR_GEN_QUEUE_TEST ( pdPASS + 3 )
#define mainERROR_REG_TEST ( pdPASS + 4 )
#define mainERROR_TIMER_TEST ( pdPASS + 5 )
#define mainERROR_COUNT_SEM_TEST ( pdPASS + 6 )
/* Priorities used by the test and demo tasks. */
#define mainPRINT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainGENERIC_QUEUE_TEST_PRIORITY ( tskIDLE_PRIORITY )
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainSTAT_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* Just used to ensure parameters are passed into tasks correctly. */
#define mainTASK_PARAMETER_CHECK_VALUE ( ( void * ) 0xDEADBEEF )
/* The length of the queue (the number of items the queue can hold) that is used
to send messages from tasks and interrupts the the Print task. */
#define mainQUEUE_LENGTH ( 5 )
/* The base period used by the timer test tasks. */
#define mainTIMER_TEST_PERIOD ( 50 / portTICK_RATE_MS )
/* The frequency at which the check timer (described in the comments at the top
of this file) will call its callback function. */
#define mainCHECK_TIMER_PERIOD ( 5000UL / ( unsigned long ) portTICK_RATE_MS )
/* A block time of 0 simply means "don't block". */
#define mainDONT_BLOCK ( 0 )
/*
* The register check tasks, as decribed in the comments at the top of this
* file. The nature of the tasks necessitates that they are written in
* assembler.
*/
extern void vRegTestTask1(void *pvParameters);
extern void vRegTestTask2(void *pvParameters);
/*
* Definition of the Print task described in the comments at the top of this
* file.
*/
static void prvPrintTask( void *pvParameters );
/*
* Defines the 'check' functionality as described at the top of this file. This
* function is the callback function for the 'check' timer. */
static void vCheckTimerCallback( xTimerHandle xTimer );
extern void vLedTask( void * pvParameters );
void vStatsTask(void *pvParameters);
/*-----------------------------------------------------------*/
/* variable incremente in the IDLE hook */
volatile unsigned usIdleCounter = 0;
/* Variables that are incremented on each iteration of the reg test tasks -
provided the tasks have not reported any errors. The check task inspects these
variables to ensure they are still incrementing as expected. If a variable
stops incrementing then it is likely that its associate task has stalled. */
volatile unsigned usRegTest1Counter = 0, usRegTest2Counter = 0;
/* The handle of the queue used to send messages from tasks and interrupts to
the Print task. */
static xQueueHandle xPrintQueue = NULL;
/* The 'check' timer, as described at the top of this file. */
static xTimerHandle xCheckTimer = NULL;
/*-----------------------------------------------------------*/
void main()
{
/* initalise DIO ports */
gioInit();
/* Create the queue used by tasks and interrupts to send strings to the
print task. */
xPrintQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
/* If the queue could not be created then don't create any tasks that might
attempt to use the queue. */
if( xPrintQueue != NULL )
{
/* Create STATS task, this prints out a summary of running tasks every 15s */
xTaskCreate(vStatsTask, (signed char *)"STATS..", 600, NULL, mainSTAT_TASK_PRIORITY, NULL);
/* Create LED task, this will flash the LEDs on the USB stick */
xTaskCreate(vLedTask, (signed char *)"LEDS...", configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY, NULL);
/* Create the standard demo tasks. */
vStartDynamicPriorityTasks();
vStartGenericQueueTasks( mainGENERIC_QUEUE_TEST_PRIORITY );
vStartCountingSemaphoreTasks();
/* Note that creating the timer test/demo tasks will fill the timer
command queue. This is intentional, and forms part of the test the tasks
perform. It does mean however that, after this function is called, no
more timer commands can be sent until after the scheduler has been
started (at which point the timer daemon will drained the timer command
queue, freeing up space for more commands to be received). */
vStartTimerDemoTask(mainTIMER_TEST_PERIOD);
/* Create the Print and register test tasks. */
xTaskCreate(prvPrintTask, (signed char *)"Print..", 500, mainTASK_PARAMETER_CHECK_VALUE, mainPRINT_TASK_PRIORITY, NULL );
xTaskCreate(vRegTestTask1, (signed char *)"REG1...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
xTaskCreate(vRegTestTask2, (signed char *)"REG2...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
/* Create the 'check' timer - the timer that periodically calls the
check function as described at the top of this file. Note that, for
the reasons stated in the comments above the call to
vStartTimerDemoTask(), that the check timer is not actually started
until after the scheduler has been started. */
xCheckTimer = xTimerCreate( ( const signed char * ) "Check Timer", mainCHECK_TIMER_PERIOD, pdTRUE, ( void * ) 0, vCheckTimerCallback );
/* start FreeRTOS Scheduler */
vTaskStartScheduler();
}
/* If all is well then this line will never be reached. If it is reached
then it is likely that there was insufficient (FreeRTOS) heap memory space
to create the idle task. This may have been trapped by the malloc() failed
hook function, if one is configured. */
for (;;);
}
/*-----------------------------------------------------------*/
void vStatsTask(void *pvParameters)
{
/* Buffer used to hold the table of run time statistics. This is static so it
does not overflow the task stack. */
static signed char cStatsBuffer[ 1024 ];
const portTickType x15Seconds = 15000 / portTICK_RATE_MS;
printf("**** Task Statistics Started\n");
for (;;)
{
vTaskDelay( x15Seconds );
vTaskGetRunTimeStats( cStatsBuffer );
printf("%s\n", cStatsBuffer );
}
}
/*-----------------------------------------------------------*/
static void prvPrintTask( void *pvParameters )
{
unsigned long ulReceivedMessage;
static signed char cPrintBuffer[ 50 ];
printf( "**** Print Task Started\n" );
/* Now the scheduler has been started (it must have been for this task to
be running), start the check timer too. The call to xTimerStart() will
block until the command has been accepted. */
if( xCheckTimer != NULL )
{
xTimerStart( xCheckTimer, portMAX_DELAY );
}
/* First print out the number of bytes that remain in the FreeRTOS heap. This
is done after a short delay to ensure all the demo tasks have created all
the objects they are going to use. */
vTaskDelay( mainTIMER_TEST_PERIOD * 10 );
printf( "**** %d heap free\n", ( int ) xPortGetFreeHeapSize() );
/* Just as a test of the port, and for no functional reason, check the task
parameter contains its expected value. */
if( pvParameters != mainTASK_PARAMETER_CHECK_VALUE )
{
printf("**** Invalid parameter ****\n\n");
}
for( ;; )
{
/* Wait for a message to be received. Using portMAX_DELAY as the block
time will result in an indefinite wait provided INCLUDE_vTaskSuspend is
set to 1 in FreeRTOSConfig.h, therefore there is no need to check the
function return value and the function will only return when a value
has been received. */
xQueueReceive( xPrintQueue, &ulReceivedMessage, portMAX_DELAY );
/* What is this message? What does it contain? */
switch( ulReceivedMessage )
{
case pdPASS : sprintf( ( char * ) cPrintBuffer, "Status = PASS" );
break;
case mainERROR_DYNAMIC_TASKS : sprintf( ( char * ) cPrintBuffer, "Err: Dynamic tsks" );
break;
case mainERROR_GEN_QUEUE_TEST : sprintf( ( char * ) cPrintBuffer, "Error: Gen Q test" );
break;
case mainERROR_REG_TEST : sprintf( ( char * ) cPrintBuffer, "Error: Reg test" );
break;
case mainERROR_TIMER_TEST : sprintf( ( char * ) cPrintBuffer, "Error: Tmr test" );
break;
case mainERROR_COUNT_SEM_TEST : sprintf( ( char * ) cPrintBuffer, "Error: Count sem" );
break;
default : sprintf( ( char * ) cPrintBuffer, "Unknown status" );
break;
}
/* Output the message that was placed into the cBuffer array within the
switch statement above, then move onto the next line ready for the next
message to arrive on the queue. */
printf( "**** Message Received: %s\n", cPrintBuffer );
}
}
/* ----------------------------------------------------------------------------------------------------------- */
static void vCheckTimerCallback( xTimerHandle xTimer )
{
static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;
/* Define the status message that is sent to the LCD task. By default the
status is PASS. */
unsigned long ulStatus = pdPASS;
/* This is the callback function used by the 'check' timer, as described
at the top of this file. */
/* The parameter is not used. */
( void ) xTimer;
/* See if the standard demo tasks are executing as expected, changing
the message that is sent to the LCD task from PASS to an error code if
any tasks set reports an error. */
if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
{
ulStatus = mainERROR_DYNAMIC_TASKS;
}
if( xAreGenericQueueTasksStillRunning() != pdPASS )
{
ulStatus = mainERROR_GEN_QUEUE_TEST;
}
if( xAreCountingSemaphoreTasksStillRunning() != pdPASS )
{
ulStatus = mainERROR_COUNT_SEM_TEST;
}
if( xAreTimerDemoTasksStillRunning( ( portTickType ) mainCHECK_TIMER_PERIOD ) != pdPASS )
{
ulStatus = mainERROR_TIMER_TEST;
}
/* Check the reg test tasks are still cycling. They will stop
incrementing their loop counters if they encounter an error. */
if( usRegTest1Counter == usLastRegTest1Counter )
{
ulStatus = mainERROR_REG_TEST;
}
if( usRegTest2Counter == usLastRegTest2Counter )
{
ulStatus = mainERROR_REG_TEST;
}
usLastRegTest1Counter = usRegTest1Counter;
usLastRegTest2Counter = usRegTest2Counter;
/* This is called from a timer callback so must not block! */
xQueueSendToBack( xPrintQueue, &ulStatus, mainDONT_BLOCK );
}
/* ----------------------------------------------------------------------------------------------------------- */
void vApplicationTickHook( void )
{
static unsigned long ulCounter = 0;
/* Is it time to toggle the pin again? */
ulCounter++;
/* Just periodically toggle a pin to show that the tick interrupt is
running. */
if( ( ulCounter & 0xff ) == 0 )
{
gioSetBit(gioPORTA, 0, 1);
gioSetBit(gioPORTA, 0, 0);
}
}
/* ----------------------------------------------------------------------------------------------------------- */
void vApplicationMallocFailedHook( void )
{
/* Called if a call to pvPortMalloc() fails because there is insufficient
free memory available in the FreeRTOS heap. pvPortMalloc() is called
internally by FreeRTOS API functions that create tasks, queues or
semaphores. */
taskDISABLE_INTERRUPTS();
for( ;; );
}
/* ----------------------------------------------------------------------------------------------------------- */
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
{
/* Run time stack overflow checking is performed if
configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
for( ;; );
}
/* ----------------------------------------------------------------------------------------------------------- */
void vApplicationIdleHook(void)
{
usIdleCounter++;
}
/* ----------------------------------------------------------------------------------------------------------- */
#endif

@ -185,8 +185,8 @@ xTimerHandle xTimer = NULL;
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
/* Create the register test tasks, as described at the top of this file. */
xTaskCreate(vRegTestTask1, ( const signed char * ) "Reg1...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
xTaskCreate(vRegTestTask2, ( const signed char * ) "Reg2...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
xTaskCreate( vRegTestTask1, ( const signed char * ) "Reg1...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
xTaskCreate( vRegTestTask2, ( const signed char * ) "Reg2...", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
/* Create the software timer that performs the 'check' functionality,
as described at the top of this file. */

@ -1,6 +1,6 @@
/*
FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.
***************************************************************************
* *
@ -40,7 +40,7 @@
FreeRTOS WEB site.
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
@ -50,184 +50,208 @@
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, training, latest information,
http://www.FreeRTOS.org - Documentation, training, latest information,
license and contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool.
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
the code with commercial support, indemnification, and middleware, under
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
the code with commercial support, indemnification, and middleware, under
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
provide a safety engineered and independently SIL3 certified version under
provide a safety engineered and independently SIL3 certified version under
the SafeRTOS brand: http://www.SafeRTOS.com.
*/
/*----------------------------------------------------------------------------*/
/* Include Files */
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
/*----------------------------------------------------------------------------*/
/* Global Variables */
/*-----------------------------------------------------------*/
/* Count of the critical section nesting depth. */
unsigned portLONG ulCriticalNesting = 9999;
/*----------------------------------------------------------------------------*/
/* Macros */
/*-----------------------------------------------------------*/
/* Registers required to configure the RTI. */
#define portRTI_GCTRL_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC00 ) )
#define portRTI_TBCTRL_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC04 ) )
#define portRTI_COMPCTRL_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC0C ) )
#define portRTI_CNT0_FRC0_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC10 ) )
#define portRTI_CNT0_UC0_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC14 ) )
#define portRTI_CNT0_CPUC0_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC18 ) )
#define portRTI_CNT0_COMP0_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC50 ) )
#define portRTI_CNT0_UDCP0_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC54 ) )
#define portRTI_SETINTENA_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC80 ) )
#define portRTI_CLEARINTENA_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC84 ) )
#define portRTI_INTFLAG_REG ( * ( ( volatile unsigned long * ) 0xFFFFFC88 ) )
#define portINITIAL_SPSR ((portSTACK_TYPE) 0x1F)
#define portINITIAL_FPSCR ((portSTACK_TYPE) 0x00)
#define portINSTRUCTION_SIZE ((portSTACK_TYPE) 0x04)
#define portTHUMB_MODE_BIT ((portSTACK_TYPE) 0x20)
/* Constants required to set up the initial stack of each task. */
#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x1F )
#define portINITIAL_FPSCR ( ( portSTACK_TYPE ) 0x00 )
#define portINSTRUCTION_SIZE ( ( portSTACK_TYPE ) 0x04 )
#define portTHUMB_MODE_BIT ( ( portSTACK_TYPE ) 0x20 )
/*----------------------------------------------------------------------------*/
/* pxPortInitialiseStack */
/* The number of words on the stack frame between the saved Top Of Stack and
R0 (in which the parameters are passed. */
#define portSPACE_BETWEEN_TOS_AND_PARAMETERS ( 12 )
portSTACK_TYPE * pxPortInitialiseStack(portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters)
/*-----------------------------------------------------------*/
/* vPortStartFirstSTask() is defined in portASM.asm */
extern void vPortStartFirstTask( void );
/*-----------------------------------------------------------*/
/*
* See header file for description.
*/
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
portSTACK_TYPE *pxOriginalTOS = pxTopOfStack;
*pxTopOfStack-- = (portSTACK_TYPE) pxCode + portINSTRUCTION_SIZE;
*pxTopOfStack-- = (portSTACK_TYPE) 0xaaaaaaaa;
*pxTopOfStack-- = (portSTACK_TYPE) pxOriginalTOS;
*pxTopOfStack-- = (portSTACK_TYPE) 0x12121212;
*pxTopOfStack-- = (portSTACK_TYPE) 0x11111111;
*pxTopOfStack-- = (portSTACK_TYPE) 0x10101010;
*pxTopOfStack-- = (portSTACK_TYPE) 0x09090909;
*pxTopOfStack-- = (portSTACK_TYPE) 0x08080808;
*pxTopOfStack-- = (portSTACK_TYPE) 0x07070707;
*pxTopOfStack-- = (portSTACK_TYPE) 0x06060606;
*pxTopOfStack-- = (portSTACK_TYPE) 0x05050505;
*pxTopOfStack-- = (portSTACK_TYPE) 0x04040404;
*pxTopOfStack-- = (portSTACK_TYPE) 0x03030303;
*pxTopOfStack-- = (portSTACK_TYPE) 0x02020202;
*pxTopOfStack-- = (portSTACK_TYPE) 0x01010101;
*pxTopOfStack-- = (portSTACK_TYPE) pvParameters;
#if __TI_VFPV3D16_SUPPORT__
*pxTopOfStack-- = (portSTACK_TYPE) 0x3F3F3F3F;
*pxTopOfStack-- = (portSTACK_TYPE) 0x3E3E3E3E;
*pxTopOfStack-- = (portSTACK_TYPE) 0x3D3D3D3D;
*pxTopOfStack-- = (portSTACK_TYPE) 0x3C3C3C3C;
*pxTopOfStack-- = (portSTACK_TYPE) 0x3B3B3B3B;
*pxTopOfStack-- = (portSTACK_TYPE) 0x3A3A3A3A;
*pxTopOfStack-- = (portSTACK_TYPE) 0x39393939;
*pxTopOfStack-- = (portSTACK_TYPE) 0x38383838;
*pxTopOfStack-- = (portSTACK_TYPE) 0x37373737;
*pxTopOfStack-- = (portSTACK_TYPE) 0x36363636;
*pxTopOfStack-- = (portSTACK_TYPE) 0x35353535;
*pxTopOfStack-- = (portSTACK_TYPE) 0x34343434;
*pxTopOfStack-- = (portSTACK_TYPE) 0x33333333;
*pxTopOfStack-- = (portSTACK_TYPE) 0x32323232;
*pxTopOfStack-- = (portSTACK_TYPE) 0x31313131;
*pxTopOfStack-- = (portSTACK_TYPE) 0x30303030;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2F2F2F2F;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2E2E2E2E;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2D2D2D2D;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2C2C2C2C;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2B2B2B2B;
*pxTopOfStack-- = (portSTACK_TYPE) 0x2A2A2A2A;
*pxTopOfStack-- = (portSTACK_TYPE) 0x29292929;
*pxTopOfStack-- = (portSTACK_TYPE) 0x28282828;
*pxTopOfStack-- = (portSTACK_TYPE) 0x27272727;
*pxTopOfStack-- = (portSTACK_TYPE) 0x26262626;
*pxTopOfStack-- = (portSTACK_TYPE) 0x25252525;
*pxTopOfStack-- = (portSTACK_TYPE) 0x24242424;
*pxTopOfStack-- = (portSTACK_TYPE) 0x23232323;
*pxTopOfStack-- = (portSTACK_TYPE) 0x22222222;
*pxTopOfStack-- = (portSTACK_TYPE) 0x21212121;
*pxTopOfStack-- = (portSTACK_TYPE) 0x20202020;
*pxTopOfStack-- = (portSTACK_TYPE) portINITIAL_FPSCR;
#endif
portSTACK_TYPE *pxOriginalTOS;
pxOriginalTOS = pxTopOfStack;
*pxTopOfStack = (portSTACK_TYPE) ((_get_CPSR() & ~0xFF) | portINITIAL_SPSR);
/* Setup the initial stack of the task. The stack is set exactly as
expected by the portRESTORE_CONTEXT() macro. */
if (((unsigned long) pxCode & 0x01UL) != 0x00)
{
*pxTopOfStack |= portTHUMB_MODE_BIT;
}
/* First on the stack is the return address - which is the start of the as
the task has not executed yet. The offset is added to make the return
address appear as it would within an IRQ ISR. */
*pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE;
pxTopOfStack--;
return pxTopOfStack;
}
*pxTopOfStack = ( portSTACK_TYPE ) 0x00000000; /* R14 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
pxTopOfStack--;
#ifdef portPRELOAD_TASK_REGISTERS
{
*pxTopOfStack = ( portSTACK_TYPE ) 0x12121212; /* R12 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x11111111; /* R11 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x10101010; /* R10 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x09090909; /* R9 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x08080808; /* R8 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x07070707; /* R7 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x06060606; /* R6 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x05050505; /* R5 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x04040404; /* R4 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x03030303; /* R3 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x02020202; /* R2 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0x01010101; /* R1 */
pxTopOfStack--;
}
#else
{
pxTopOfStack -= portSPACE_BETWEEN_TOS_AND_PARAMETERS;
}
#endif
/* Function parameters are passed in R0. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack--;
/* The last thing onto the stack is the status register, which is set for
system mode, with interrupts enabled. */
*pxTopOfStack = ( portSTACK_TYPE ) ( ( _get_CPSR() & ~0xFF ) | portINITIAL_SPSR );
if( ( ( unsigned long ) pxCode & 0x01UL ) != 0x00 )
{
/* The task will start in thumb mode. */
*pxTopOfStack |= portTHUMB_MODE_BIT;
}
/*----------------------------------------------------------------------------*/
/* prvSetupTimerInterrupt */
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
static void prvSetupTimerInterrupt(void)
{
#if (configGENERATE_RUN_TIME_STATS == 1)
RTI->GCTRL &= ~0x00000001U;
#else
RTI->GCTRL = 0x00000000U;
#endif
RTI->TBCTRL = 0x00000000U;
RTI->COMPCTRL = 0x00000000U;
RTI->CNT[0U].UCx = 0x00000000U;
RTI->CNT[0U].FRCx = 0x00000000U;
RTI->CNT[0U].CPUCx = 0x00000001U;
RTI->CMP[0U].COMPx = configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ;
RTI->CMP[0U].UDCPx = configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ;
RTI->INTFLAG = 0x0007000FU;
RTI->CLEARINT = 0x00070F0FU;
RTI->SETINT = 0x00000001U;
RTI->GCTRL |= 0x00000001U;
}
/* Disable timer 0. */
portRTI_GCTRL_REG &= 0xFFFFFFFEUL;
/* Use the internal counter. */
portRTI_TBCTRL_REG = 0x00000000U;
/*----------------------------------------------------------------------------*/
/* vPortStartFirstTask */
/* COMPSEL0 will use the RTIFRC0 counter. */
portRTI_COMPCTRL_REG = 0x00000000U;
/* vPortStartFirstSTask() is defined in portASM.asm */
extern void vPortStartFirstTask(void);
/* Initialise the counter and the prescale counter registers. */
portRTI_CNT0_UC0_REG = 0x00000000U;
portRTI_CNT0_FRC0_REG = 0x00000000U;
/* Set Prescalar for RTI clock. */
portRTI_CNT0_CPUC0_REG = 0x00000001U;
portRTI_CNT0_COMP0_REG = ( configCPU_CLOCK_HZ / 2 ) / configTICK_RATE_HZ;
portRTI_CNT0_UDCP0_REG = ( configCPU_CLOCK_HZ / 2 ) / configTICK_RATE_HZ;
/*----------------------------------------------------------------------------*/
/* xPortStartScheduler */
/* Clear interrupts. */
portRTI_INTFLAG_REG = 0x0007000FU;
portRTI_CLEARINTENA_REG = 0x00070F0FU;
/* Enable the compare 0 interrupt. */
portRTI_SETINTENA_REG = 0x00000001U;
portRTI_GCTRL_REG |= 0x00000001U;
}
/*-----------------------------------------------------------*/
/*
* See header file for description.
*/
portBASE_TYPE xPortStartScheduler(void)
{
/* Start the timer that generates the tick ISR. */
prvSetupTimerInterrupt();
/* Enable critical sections */
ulCriticalNesting = 0;
prvSetupTimerInterrupt();
/* Reset the critical section nesting count read to execute the first task. */
ulCriticalNesting = 0;
/* Start the first task. This is done from portASM.asm as ARM mode must be
used. */
vPortStartFirstTask();
vPortStartFirstTask();
/* Should not get here! */
return 0;
return pdFAIL;
}
/*-----------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* vPortEndScheduler */
/*
* See header file for description.
*/
void vPortEndScheduler(void)
{
/* It is unlikely that the ARM port will require this function as there
is nothing to return to. If this is required - stop the tick ISR then
return back to main. */
/* It is unlikely that the port will require this function as there
is nothing to return to. */
}
/*----------------------------------------------------------------------------*/
/* vNonPreemptiveTick / vPreemptiveTick */
/*-----------------------------------------------------------*/
#if configUSE_PREEMPTION == 0
/* The cooperative scheduler requires a normal IRQ service routine to
/* The cooperative scheduler requires a normal IRQ service routine to
* simply increment the system tick. */
__interrupt void vNonPreemptiveTick( void )
__interrupt void vPortNonPreemptiveTick( void )
{
/* clear clock interrupt flag */
RTI->INTFLAG = 0x00000001;
/* clear clock interrupt flag */
RTI->INTFLAG = 0x00000001;
/* Increment the tick count - this may make a delaying task ready
to run - but a context switch is not performed. */
to run - but a context switch is not performed. */
vTaskIncrementTick();
}
@ -235,49 +259,51 @@ void vPortEndScheduler(void)
/*
**************************************************************************
* The preemptive scheduler ISR is written in assembler and can be found
* The preemptive scheduler ISR is written in assembler and can be found
* in the portASM.asm file. This will only get used if portUSE_PREEMPTION
* is set to 1 in portmacro.h
**************************************************************************
**************************************************************************
*/
void vPreemptiveTick(void);
void vPortPreemptiveTick( void );
#endif
/*-----------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* vPortEnterCritical */
void vPortEnterCritical(void)
/*
* Disable interrupts, and keep a count of the nesting depth.
*/
void vPortEnterCritical( void )
{
/* Disable interrupts as per portDISABLE_INTERRUPTS(); */
portDISABLE_INTERRUPTS();
/* Now interrupts are disabled ulCriticalNesting can be accessed
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++;
ulCriticalNesting++;
}
/*-----------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* vPortExitCritical */
void vPortExitCritical(void)
/*
* Decrement the critical nesting count, and if it has reached zero, re-enable
* interrupts.
*/
void vPortExitCritical( void )
{
if(ulCriticalNesting > 0)
{
if( ulCriticalNesting > 0 )
{
/* Decrement the nesting count as we are leaving a critical section. */
ulCriticalNesting--;
ulCriticalNesting--;
/* If the nesting level has reached zero then interrupts should be
re-enabled. */
if(ulCriticalNesting == 0)
{
/* If the nesting level has reached zero then interrupts should be
re-enabled. */
if( ulCriticalNesting == 0 )
{
/* Enable interrupts as per portENABLE_INTERRUPTS(). */
portENABLE_INTERRUPTS();
}
}
portENABLE_INTERRUPTS();
}
}
}
/*-----------------------------------------------------------*/
/*----------------------------------------------------------------------------*/

@ -144,10 +144,10 @@ vPortYeildWithinAPI
;-------------------------------------------------------------------------------
; Preemptive Tick
.def vPreemptiveTick
.def vPortPreemptiveTick
.ref vTaskIncrementTick
vPreemptiveTick
vPortPreemptiveTick
portSAVE_CONTEXT
; clear interrupt flag
movw r0, #0xFC88

@ -64,55 +64,20 @@
the SafeRTOS brand: http://www.SafeRTOS.com.
*/
#ifndef __OS_PORTMACRO_H__
#define __OS_PORTMACRO_H__
/*----------------------------------------------------------------------------*/
/* RTI Register Frame Definition */
struct rti
{
unsigned GCTRL;
unsigned TBCTRL;
unsigned CAPCTRL;
unsigned COMPCTRL;
struct
{
unsigned FRCx;
unsigned UCx;
unsigned CPUCx;
unsigned : 32;
unsigned CAFRCx;
unsigned CAUCx;
unsigned : 32;
unsigned : 32;
} CNT[2U];
struct
{
unsigned COMPx;
unsigned UDCPx;
} CMP[4U];
unsigned TBLCOMP;
unsigned TBHCOMP;
unsigned : 32;
unsigned : 32;
unsigned SETINT;
unsigned CLEARINT;
unsigned INTFLAG;
unsigned : 32;
unsigned DWDCTRL;
unsigned DWDPRLD;
unsigned WDSTATUS;
unsigned WDKEY;
unsigned WDCNTR;
};
#define RTI ((volatile struct rti *)0xFFFFFC00U)
/*----------------------------------------------------------------------------*/
/* Type Definitions */
#ifndef __PORTMACRO_H__
#define __PORTMACRO_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
@ -130,48 +95,29 @@ struct rti
#endif
/*----------------------------------------------------------------------------*/
/* Architecture Definitions */
/* Architecture specifics. */
#define portSTACK_GROWTH (-1)
#define portTICK_RATE_MS ((portTickType) 1000 / configTICK_RATE_HZ)
#define portBYTE_ALIGNMENT 8
/*----------------------------------------------------------------------------*/
/* External Functions */
/* Critical section handling. */
extern void vPortEnterCritical(void);
extern void vPortExitCritical(void);
/*----------------------------------------------------------------------------*/
/* Functions Macros */
#define portYIELD() _call_swi(0)
#define portYIELD_WITHIN_API() { *(volatile unsigned *)0xFFFFFFB0 = 0x7500; *(volatile unsigned *)0xFFFFFFB0; }
#define portYIELD_FROM_ISR() { *(volatile unsigned *)0xFFFFFFB0 = 0x7500; *(volatile unsigned *)0xFFFFFFB0; }
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
#define portDISABLE_INTERRUPTS() asm(" CPSID I")
#define portENABLE_INTERRUPTS() asm(" CPSIE I")
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
#define portDISABLE_INTERRUPTS() asm( " CPSID I" )
#define portENABLE_INTERRUPTS() asm( " CPSIE I" )
/* Scheduler utilities. */
#define portYIELD() _call_swi( 0 )
#define portSYS_SSIR1_REG ( * ( ( volatile unsigned long * ) 0xFFFFFFB0 ) )
#define portSYS_SSIR1_SSKEY ( 0x7500UL )
#define portYIELD_WITHIN_API() { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY; ( void ) portSYS_SSIR1_REG; }
#define portYIELD_FROM_ISR() { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY; ( void ) portSYS_SSIR1_REG; }
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters)
#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
#if (configGENERATE_RUN_TIME_STATS == 1)
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
{ \
RTI->GCTRL = 0x00000000U; \
RTI->TBCTRL = 0x00000000U; \
RTI->COMPCTRL = 0x00000000U; \
RTI->CNT[1U].UCx = 0x00000000U; \
RTI->CNT[1U].FRCx = 0x00000000U; \
RTI->CNT[1U].CPUCx = (configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ) / 16; \
RTI->CMP[1U].UDCPx = (configCPU_CLOCK_HZ / 2 / configTICK_RATE_HZ) / 16; \
RTI->GCTRL = 0x00000002U; \
}
#define portGET_RUN_TIME_COUNTER_VALUE() (RTI->CNT[1].FRCx)
#endif
#endif
#endif /* __PORTMACRO_H__ */
/*----------------------------------------------------------------------------*/

@ -54,7 +54,7 @@ static const t_isrFuncPTR s_vim_init[] =
phantomInterrupt,
phantomInterrupt,
phantomInterrupt,
vPreemptiveTick, /* RTI */
vPortPreemptiveTick, /* RTI */
phantomInterrupt,
phantomInterrupt,
phantomInterrupt,

@ -43,8 +43,8 @@ typedef void (*t_isrFuncPTR)();
extern void phantomInterrupt(void);
extern void esmHighLevelInterrupt(void);
extern void vPreemptiveTick(void);
extern void vNonPreemptiveTick(void);
extern void vPortPreemptiveTick(void);
extern void vPortNonPreemptiveTick(void);
extern void vPortYeildWithinAPI(void);

Loading…
Cancel
Save