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 "ISR_Support.h"
30;------------------------------------------------------------------------------
31
32#if __CORE__ != __78K0R__
33    #error "This file is only for 78K0R Devices"
34#endif
35
36#define CS                    0xFFFFC
37#define ES                    0xFFFFD
38
39; Functions implemented in this file
40;------------------------------------------------------------------------------
41    PUBLIC    vPortYield
42    PUBLIC    vPortStart
43
44; Functions used by scheduler
45;------------------------------------------------------------------------------
46    EXTERN    vTaskSwitchContext
47    EXTERN    xTaskIncrementTick
48
49; Tick ISR Prototype
50;------------------------------------------------------------------------------
51;   EXTERN    ?CL78K0R_V2_L00
52
53    PUBWEAK   `??MD_INTTM05??INTVEC 68`
54    PUBLIC    MD_INTTM05
55
56MD_INTTM05    SYMBOL "MD_INTTM05"
57`??MD_INTTM05??INTVEC 68` SYMBOL "??INTVEC 68", MD_INTTM05
58
59
60
61;------------------------------------------------------------------------------
62;   Yield to another task.  Implemented as a software interrupt.  The return
63;   address and PSW will have been saved to the stack automatically before
64;   this code runs.
65;
66;   Input:  NONE
67;
68;   Call:   CALL    vPortYield
69;
70;   Output: NONE
71;
72;------------------------------------------------------------------------------
73    RSEG CODE:CODE
74vPortYield:
75    portSAVE_CONTEXT                ; Save the context of the current task.
76    call      vTaskSwitchContext    ; Call the scheduler to select the next task.
77    portRESTORE_CONTEXT             ; Restore the context of the next task to run.
78    retb
79
80
81;------------------------------------------------------------------------------
82;   Restore the context of the first task that is going to run.
83;
84;   Input:  NONE
85;
86;   Call:   CALL    vPortStart
87;
88;   Output: NONE
89;
90;------------------------------------------------------------------------------
91    RSEG CODE:CODE
92vPortStart:
93    portRESTORE_CONTEXT             ; Restore the context of whichever task the ...
94    reti                            ; An interrupt stack frame is used so the task
95                                    ; is started using a RETI instruction.
96
97;------------------------------------------------------------------------------
98;   Perform the necessary steps of the Tick Count Increment and Task Switch
99;   depending on the chosen kernel configuration
100;
101;   Input:  NONE
102;
103;   Call:   ISR
104;
105;   Output: NONE
106;
107;------------------------------------------------------------------------------
108
109MD_INTTM05:
110
111    portSAVE_CONTEXT                ; Save the context of the current task.
112    call      xTaskIncrementTick    ; Call the timer tick function.
113#if configUSE_PREEMPTION == 1
114    call      vTaskSwitchContext    ; Call the scheduler to select the next task.
115#endif
116    portRESTORE_CONTEXT             ; Restore the context of the next task to run.
117    reti
118
119
120
121;   REQUIRE ?CL78K0R_V2_L00
122    COMMON INTVEC:CODE:ROOT(1)      ; Set ISR location to the Interrupt vector table.
123    ORG 68
124`??MD_INTTM05??INTVEC 68`:
125    DW MD_INTTM05
126
127    COMMON INTVEC:CODE:ROOT(1)      ; Set ISR location to the Interrupt vector table.
128    ORG 126
129`??vPortYield??INTVEC 126`:
130    DW vPortYield
131
132                                    ; Set value for the usCriticalNesting.
133    RSEG NEAR_ID:CONST:SORT:NOROOT(1)
134`?<Initializer for usCriticalNesting>`:
135    DW 10
136
137;#endif
138
139      END
140