1/*
2 * FreeRTOS Kernel V11.1.0
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
26 *
27 */
28
29#include "FreeRTOSConfig.h"
30#include "ISR_Support.h"
31
32    .global    _vPortYield
33    .global    _vPortStartFirstTask
34    .global    _vPortTickISR
35
36    .extern    _vTaskSwitchContext
37    .extern    _xTaskIncrementTick
38
39    .text
40    .align 2
41
42/* FreeRTOS yield handler.  This is installed as the BRK software interrupt
43handler. */
44_vPortYield:
45    /* Save the context of the current task. */
46    portSAVE_CONTEXT
47    /* Call the scheduler to select the next task. */
48    call      !!_vTaskSwitchContext
49    /* Restore the context of the next task to run. */
50    portRESTORE_CONTEXT
51    retb
52
53
54/* Starts the scheduler by restoring the context of the task that will execute
55first. */
56    .align 2
57_vPortStartFirstTask:
58    /* Restore the context of whichever task will execute first. */
59    portRESTORE_CONTEXT
60    /* An interrupt stack frame is used so the task is started using RETI. */
61    reti
62
63/* FreeRTOS tick handler.  This is installed as the interval timer interrupt
64handler. */
65    .align 2
66_vPortTickISR:
67
68    /* Save the context of the currently executing task. */
69    portSAVE_CONTEXT
70    /* Call the RTOS tick function. */
71    call      !!_xTaskIncrementTick
72#if configUSE_PREEMPTION == 1
73    /* Select the next task to run. */
74    call      !!_vTaskSwitchContext
75#endif
76    /* Retore the context of whichever task will run next. */
77    portRESTORE_CONTEXT
78    reti
79
80    .end
81