2006-06-08 17:16:29 +08:00
|
|
|
/*
|
2021-05-26 12:44:10 +08:00
|
|
|
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
|
2021-05-26 12:46:15 +08:00
|
|
|
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-11-30 00:53:26 +08:00
|
|
|
*
|
2021-06-02 03:01:32 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2017-11-30 00:53:26 +08:00
|
|
|
* 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
|
2017-12-19 06:54:18 +08:00
|
|
|
* copies or substantial portions of the Software.
|
2017-11-30 00:53:26 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2020-08-21 05:59:28 +08:00
|
|
|
* https://www.FreeRTOS.org
|
|
|
|
* https://github.com/FreeRTOS
|
2017-11-30 00:53:26 +08:00
|
|
|
*
|
|
|
|
*/
|
2007-06-05 17:56:16 +08:00
|
|
|
|
2006-06-08 17:16:29 +08:00
|
|
|
#include <FreeRTOSConfig.h>
|
2007-06-05 17:56:16 +08:00
|
|
|
|
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:
|
2013-12-12 22:07:20 +08:00
|
|
|
mrs r0, psp
|
|
|
|
isb
|
2008-03-23 23:53:37 +08:00
|
|
|
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */
|
2013-12-12 22:07:20 +08:00
|
|
|
ldr r2, [r3]
|
2008-03-23 23:53:37 +08:00
|
|
|
|
2008-07-25 10:34:31 +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. */
|
|
|
|
|
2008-07-25 10:34:31 +08:00
|
|
|
stmdb sp!, {r3, r14}
|
|
|
|
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
|
|
|
|
msr basepri, r0
|
2016-02-19 01:11:14 +08:00
|
|
|
dsb
|
|
|
|
isb
|
2013-12-12 22:07:20 +08:00
|
|
|
bl vTaskSwitchContext
|
2008-07-25 10:34:31 +08:00
|
|
|
mov r0, #0
|
|
|
|
msr basepri, r0
|
|
|
|
ldmia sp!, {r3, r14}
|
2008-03-23 23:53:37 +08:00
|
|
|
|
2013-12-12 22:07:20 +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. */
|
2008-07-25 10:34:31 +08:00
|
|
|
ldmia r0!, {r4-r11} /* Pop the registers. */
|
2013-12-12 22:07:20 +08:00
|
|
|
msr psp, r0
|
|
|
|
isb
|
|
|
|
bx r14
|
2008-03-23 23:53:37 +08:00
|
|
|
|
2007-06-05 17:56:16 +08:00
|
|
|
|
2006-06-08 17:16:29 +08:00
|
|
|
/*-----------------------------------------------------------*/
|
2007-06-05 17:56:16 +08:00
|
|
|
|
2012-10-16 15:55:40 +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]
|
2012-10-16 15:55:40 +08:00
|
|
|
/* Pop the core registers. */
|
2008-07-25 10:34:31 +08:00
|
|
|
ldmia r0!, {r4-r11}
|
2008-03-23 23:53:37 +08:00
|
|
|
msr psp, r0
|
2013-12-12 22:07:20 +08:00
|
|
|
isb
|
2008-04-06 22:41:04 +08:00
|
|
|
mov r0, #0
|
|
|
|
msr basepri, r0
|
2008-03-23 23:53:37 +08:00
|
|
|
orr r14, r14, #13
|
|
|
|
bx r14
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
vPortStartFirstTask
|
2008-07-25 10:40:35 +08:00
|
|
|
/* 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
|
2014-06-14 21:56:25 +08:00
|
|
|
/* Call SVC to start the first task, ensuring interrupts are enabled. */
|
2010-12-23 18:39:02 +08:00
|
|
|
cpsie i
|
2014-06-14 21:56:25 +08:00
|
|
|
cpsie f
|
2013-12-12 22:07:20 +08:00
|
|
|
dsb
|
|
|
|
isb
|
2008-03-23 23:53:37 +08:00
|
|
|
svc 0
|
|
|
|
|
2007-06-05 17:56:16 +08:00
|
|
|
END
|