mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Still a work in progress. Need to add flop support.
This commit is contained in:
parent
1aa471d0ec
commit
188a2c0cc1
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -102,60 +102,84 @@ pxTopOfStack--;
|
||||||
*pxTopOfStack = portINITIAL_SR;
|
*pxTopOfStack = portINITIAL_SR;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* PC then MACL, MACH. */
|
/* PC. */
|
||||||
// *pxTopOfStack = ( unsigned long ) pxCode;
|
*pxTopOfStack = ( unsigned long ) pxCode;
|
||||||
// pxTopOfStack -= 3;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( unsigned long ) pxCode;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0xffffUL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0xeeeeUL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
/* GBR then PR, R14-R5. */
|
/* PR. */
|
||||||
// *pxTopOfStack = ulPortGetGBR();
|
*pxTopOfStack = 15;
|
||||||
// pxTopOfStack -= 12;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x00UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x11UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x22UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x33UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x44UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x55UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x66UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x77UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x88UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x99UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0xaaUL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0xbbUL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
|
/* 14. */
|
||||||
|
*pxTopOfStack = 14;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* Parameters in R4 then R3-R0. */
|
/* R13. */
|
||||||
// *pxTopOfStack = ( unsigned long ) pvParameters;
|
*pxTopOfStack = 13;
|
||||||
// pxTopOfStack -= 5;
|
pxTopOfStack--;
|
||||||
|
|
||||||
*pxTopOfStack = 0x1UL;
|
/* R12. */
|
||||||
pxTopOfStack--;
|
*pxTopOfStack = 12;
|
||||||
*pxTopOfStack = 0x2UL;
|
pxTopOfStack--;
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x3UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x4UL;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x5UL;
|
|
||||||
//pxTopOfStack--;
|
|
||||||
|
|
||||||
|
/* R11. */
|
||||||
|
*pxTopOfStack = 11;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R10. */
|
||||||
|
*pxTopOfStack = 10;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R9. */
|
||||||
|
*pxTopOfStack = 9;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R8. */
|
||||||
|
*pxTopOfStack = 8;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R7. */
|
||||||
|
*pxTopOfStack = 7;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R6. */
|
||||||
|
*pxTopOfStack = 6;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R5. */
|
||||||
|
*pxTopOfStack = 5;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R4. */
|
||||||
|
*pxTopOfStack = ( unsigned long ) pvParameters;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R3. */
|
||||||
|
*pxTopOfStack = 3;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R2. */
|
||||||
|
*pxTopOfStack = 2;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R1. */
|
||||||
|
*pxTopOfStack = 1;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* R0 */
|
||||||
|
*pxTopOfStack = 0;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* MACL. */
|
||||||
|
*pxTopOfStack = 16;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* MACH. */
|
||||||
|
*pxTopOfStack = 17;
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
/* GBR. */
|
||||||
|
*pxTopOfStack = ulPortGetGBR();
|
||||||
|
|
||||||
/* GBR = global base register.
|
/* GBR = global base register.
|
||||||
VBR = vector base register.
|
VBR = vector base register.
|
||||||
|
@ -169,7 +193,7 @@ pxTopOfStack--;
|
||||||
portBASE_TYPE xPortStartScheduler( void )
|
portBASE_TYPE xPortStartScheduler( void )
|
||||||
{
|
{
|
||||||
/* Start the tick interrupt. */
|
/* Start the tick interrupt. */
|
||||||
// prvSetupTimerInterrupt();
|
prvSetupTimerInterrupt();
|
||||||
|
|
||||||
/* Start the first task. */
|
/* Start the first task. */
|
||||||
trapa( 32 );
|
trapa( 32 );
|
||||||
|
@ -207,3 +231,6 @@ extern void vApplicationSetupTimerInterrupt( void );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;/*
|
;/*
|
||||||
; FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
; FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||||
;
|
;
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; * *
|
; * *
|
||||||
|
@ -53,43 +53,25 @@
|
||||||
|
|
||||||
.import _pxCurrentTCB
|
.import _pxCurrentTCB
|
||||||
.import _vTaskSwitchContext
|
.import _vTaskSwitchContext
|
||||||
|
.import _vTaskIncrementTick
|
||||||
|
|
||||||
.export _vPortStartFirstTask
|
.export _vPortStartFirstTask
|
||||||
.export _ulPortGetGBR
|
.export _ulPortGetGBR
|
||||||
.export _vPortYield
|
.export _vPortYield
|
||||||
|
.export _vPortPreemptiveTick
|
||||||
|
.export _vPortCooperativeTick
|
||||||
|
|
||||||
.section P
|
.section P
|
||||||
|
|
||||||
_vPortStartFirstTask:
|
.macro portSAVE_CONTEXT
|
||||||
|
|
||||||
; Get the address of the pxCurrentTCB variable.
|
; Save r0 to r14 and pr.
|
||||||
mov.l #_pxCurrentTCB, r15
|
movml.l r15, @-r15
|
||||||
|
|
||||||
; Get the address of the task stack from pxCurrentTCB.
|
; Save mac1, mach and gbr
|
||||||
mov.l @r15, r15
|
|
||||||
|
|
||||||
; Get the task stack itself into the stack pointer.
|
|
||||||
mov.l @r15, r15
|
|
||||||
|
|
||||||
; Restore r0 to PR (PR is used in place of r15).
|
|
||||||
movml.l @r15+, r15
|
|
||||||
|
|
||||||
; Restore system registers.
|
|
||||||
ldc.l @r15+, gbr
|
|
||||||
lds.l @r15+, mach
|
|
||||||
lds.l @r15+, macl
|
|
||||||
|
|
||||||
; Pop the SR and PC to jump to the start of the task.
|
|
||||||
rte
|
|
||||||
nop
|
|
||||||
|
|
||||||
_vPortYield:
|
|
||||||
|
|
||||||
; Save registers in the same order used by the CPU itself.
|
|
||||||
sts.l macl, @-r15
|
sts.l macl, @-r15
|
||||||
sts.l mach, @-r15
|
sts.l mach, @-r15
|
||||||
stc.l gbr, @-r15
|
stc.l gbr, @-r15
|
||||||
movml.l r15, @-r15
|
|
||||||
|
|
||||||
; Get the address of pxCurrentTCB
|
; Get the address of pxCurrentTCB
|
||||||
mov.l #_pxCurrentTCB, r0
|
mov.l #_pxCurrentTCB, r0
|
||||||
|
@ -100,31 +82,93 @@ _vPortYield:
|
||||||
; Save the stack pointer in pxTopOfStack.
|
; Save the stack pointer in pxTopOfStack.
|
||||||
mov.l r15, @r0
|
mov.l r15, @r0
|
||||||
|
|
||||||
mov.l #_vTaskSwitchContext, r0
|
.endm
|
||||||
jsr @r0
|
|
||||||
nop
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
.macro portRESTORE_CONTEXT
|
||||||
|
|
||||||
; Get the address of the pxCurrentTCB variable.
|
; Get the address of the pxCurrentTCB variable.
|
||||||
mov.l #_pxCurrentTCB, r15
|
mov.l #_pxCurrentTCB, r0
|
||||||
|
|
||||||
; Get the address of the task stack from pxCurrentTCB.
|
; Get the address of the task stack from pxCurrentTCB.
|
||||||
mov.l @r15, r15
|
mov.l @r0, r0
|
||||||
|
|
||||||
; Get the task stack itself into the stack pointer.
|
; Get the task stack itself into the stack pointer.
|
||||||
mov.l @r15, r15
|
mov.l @r0, r15
|
||||||
|
|
||||||
; Restore r0 to PR (PR is used in place of r15).
|
|
||||||
movml.l @r15+, r15
|
|
||||||
|
|
||||||
; Restore system registers.
|
; Restore system registers.
|
||||||
ldc.l @r15+, gbr
|
ldc.l @r15+, gbr
|
||||||
lds.l @r15+, mach
|
lds.l @r15+, mach
|
||||||
lds.l @r15+, macl
|
lds.l @r15+, macl
|
||||||
|
|
||||||
|
; Restore r0 to r14 and PR
|
||||||
|
movml.l @r15+, r15
|
||||||
|
|
||||||
; Pop the SR and PC to jump to the start of the task.
|
; Pop the SR and PC to jump to the start of the task.
|
||||||
rte
|
rte
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
.endm
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
_vPortStartFirstTask:
|
||||||
|
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
_vPortYield:
|
||||||
|
|
||||||
|
; Push r0 so it can be used.
|
||||||
|
mov.l r0, @-r15
|
||||||
|
|
||||||
|
; Set the interrupt mask in the status register.
|
||||||
|
stc sr, r0
|
||||||
|
or #240,r0
|
||||||
|
ldc r0, sr
|
||||||
|
|
||||||
|
; Restore r0 so its original value can be saved by the movml.l instruction
|
||||||
|
; below, without ending up with two copies on the stack.
|
||||||
|
mov.l @r15+, r0
|
||||||
|
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
|
mov.l #_vTaskSwitchContext, r0
|
||||||
|
jsr @r0
|
||||||
|
nop
|
||||||
|
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
_vPortPreemptiveTick
|
||||||
|
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
|
mov.l #_vTaskIncrementTick, r0
|
||||||
|
jsr @r0
|
||||||
|
nop
|
||||||
|
|
||||||
|
mov.l #_vTaskSwitchContext, r0
|
||||||
|
jsr @r0
|
||||||
|
nop
|
||||||
|
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
|
_vPortCooperativeTick
|
||||||
|
|
||||||
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
|
mov.l #_vTaskIncrementTick, r0
|
||||||
|
jsr @r0
|
||||||
|
nop
|
||||||
|
|
||||||
|
portRESTORE_CONTEXT
|
||||||
|
|
||||||
|
;-----------------------------------------------------------
|
||||||
|
|
||||||
_ulPortGetGBR:
|
_ulPortGetGBR:
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -98,14 +98,15 @@ extern "C" {
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#define portENABLE_INTERRUPTS() set_imask( 0x00 )
|
#define portENABLE_INTERRUPTS() set_imask( 0x00 )
|
||||||
#define portDISABLE_INTERRUPTS() set_imask( 0x0F )
|
#define portDISABLE_INTERRUPTS() set_imask( configMAX_SYSCALL_INTERRUPT_PRIORITY )
|
||||||
|
|
||||||
/* Critical section handling. */
|
/* Critical section handling. */
|
||||||
#define portCRITICAL_NESTING_IN_TCB ( 1 )
|
#define portCRITICAL_NESTING_IN_TCB ( 1 )
|
||||||
extern void vTaskEnterCritical( void );
|
extern void vTaskEnterCritical( void );
|
||||||
extern void vTaskExitCritical( void );
|
extern void vTaskExitCritical( void );
|
||||||
#define portENTER_CRITICAL() vTaskEnterCritical();
|
#define portENTER_CRITICAL() vTaskEnterCritical();
|
||||||
#define portEXIT_CRITICAL() vTaskExitCritical();
|
#define portEXIT_CRITICAL() vTaskExitCritical();
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||||
|
|
Loading…
Reference in a new issue