This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
FreeRTOS-Kernel/portable/IAR/ARM_CM3/portasm.s

104 lines
2.9 KiB
ArmAsm
Raw Normal View History

2006-06-08 17:16:29 +08:00
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
* 1 tab == 4 spaces!
*/
2006-06-08 17:16:29 +08:00
#include <FreeRTOSConfig.h>
2008-01-23 02:43:03 +08:00
RSEG CODE:CODE(2)
thumb
2006-06-08 17:16:29 +08:00
EXTERN pxCurrentTCB
2008-03-23 23:53:37 +08:00
EXTERN vTaskSwitchContext
2006-06-08 17:16:29 +08:00
PUBLIC xPortPendSVHandler
2008-03-23 23:53:37 +08:00
PUBLIC vPortSVCHandler
PUBLIC vPortStartFirstTask
2006-06-08 17:16:29 +08:00
/*-----------------------------------------------------------*/
xPortPendSVHandler:
mrs r0, psp
isb
2008-03-23 23:53:37 +08:00
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */
ldr r2, [r3]
2008-03-23 23:53:37 +08:00
stmdb r0!, {r4-r11} /* Save the remaining registers. */
2008-03-23 23:53:37 +08:00
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
stmdb sp!, {r3, r14}
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
msr basepri, r0
dsb
isb
bl vTaskSwitchContext
mov r0, #0
msr basepri, r0
ldmia sp!, {r3, r14}
2008-03-23 23:53:37 +08:00
ldr r1, [r3]
2008-03-23 23:53:37 +08:00
ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */
ldmia r0!, {r4-r11} /* Pop the registers. */
msr psp, r0
isb
bx r14
2008-03-23 23:53:37 +08:00
2006-06-08 17:16:29 +08:00
/*-----------------------------------------------------------*/
vPortSVCHandler:
/* Get the location of the current TCB. */
2008-03-23 23:53:37 +08:00
ldr r3, =pxCurrentTCB
ldr r1, [r3]
ldr r0, [r1]
/* Pop the core registers. */
ldmia r0!, {r4-r11}
2008-03-23 23:53:37 +08:00
msr psp, r0
isb
mov r0, #0
msr basepri, r0
2008-03-23 23:53:37 +08:00
orr r14, r14, #13
bx r14
/*-----------------------------------------------------------*/
vPortStartFirstTask
/* Use the NVIC offset register to locate the stack. */
ldr r0, =0xE000ED08
ldr r0, [r0]
ldr r0, [r0]
/* Set the msp back to the start of the stack. */
2008-03-23 23:53:37 +08:00
msr msp, r0
/* Call SVC to start the first task, ensuring interrupts are enabled. */
cpsie i
cpsie f
dsb
isb
2008-03-23 23:53:37 +08:00
svc 0
END