diff options
Diffstat (limited to 'lib/chibios/os/common/ports/e200/compilers/CW')
3 files changed, 421 insertions, 0 deletions
diff --git a/lib/chibios/os/common/ports/e200/compilers/CW/chcoreasm.s b/lib/chibios/os/common/ports/e200/compilers/CW/chcoreasm.s new file mode 100644 index 000000000..058a0cb87 --- /dev/null +++ b/lib/chibios/os/common/ports/e200/compilers/CW/chcoreasm.s | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | ||
3 | 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | ||
4 | |||
5 | This file is part of ChibiOS. | ||
6 | |||
7 | ChibiOS is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation version 3 of the License. | ||
10 | |||
11 | ChibiOS is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file e200/compilers/GCC/chcoreasm.s | ||
22 | * @brief Power Architecture port low level code. | ||
23 | * | ||
24 | * @addtogroup PPC_GCC_CORE | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | /*===========================================================================*/ | ||
29 | /* Module constants. */ | ||
30 | /*===========================================================================*/ | ||
31 | |||
32 | #if !defined(FALSE) || defined(__DOXYGEN__) | ||
33 | #define FALSE 0 | ||
34 | #endif | ||
35 | |||
36 | #if !defined(TRUE) || defined(__DOXYGEN__) | ||
37 | #define TRUE 1 | ||
38 | #endif | ||
39 | |||
40 | /*===========================================================================*/ | ||
41 | /* Code section. */ | ||
42 | /*===========================================================================*/ | ||
43 | |||
44 | /* | ||
45 | * Imports the PPC configuration headers. | ||
46 | */ | ||
47 | #define _FROM_ASM_ | ||
48 | #include "chlicense.h" | ||
49 | #include "chconf.h" | ||
50 | #include "chcore.h" | ||
51 | |||
52 | #if !defined(__DOXYGEN__) | ||
53 | |||
54 | /* | ||
55 | * RTOS-specific context offset. | ||
56 | */ | ||
57 | #if defined(_CHIBIOS_RT_CONF_) | ||
58 | #define CONTEXT_OFFSET 12 | ||
59 | #elif defined(_CHIBIOS_NIL_CONF_) | ||
60 | #define CONTEXT_OFFSET 0 | ||
61 | #else | ||
62 | #error "invalid chconf.h" | ||
63 | #endif | ||
64 | |||
65 | #if defined(_CHIBIOS_RT_CONF_) | ||
66 | .extern chThdExit | ||
67 | #endif | ||
68 | |||
69 | #if PPC_USE_VLE == TRUE | ||
70 | .section .text_vle, 16 | ||
71 | |||
72 | .align 2 | ||
73 | .globl _port_switch | ||
74 | .type _port_switch, @function | ||
75 | _port_switch: | ||
76 | e_subi r1, r1, 80 | ||
77 | se_mflr r0 | ||
78 | e_stw r0, 84(r1) | ||
79 | mfcr r0 | ||
80 | se_stw r0, 0(r1) | ||
81 | e_stmw r14, 4(r1) | ||
82 | |||
83 | se_stw r1, 12(r4) | ||
84 | se_lwz r1, 12(r3) | ||
85 | |||
86 | e_lmw r14, 4(r1) | ||
87 | se_lwz r0, 0(r1) | ||
88 | mtcr r0 | ||
89 | e_lwz r0, 84(r1) | ||
90 | se_mtlr r0 | ||
91 | e_addi r1, r1, 80 | ||
92 | se_blr | ||
93 | |||
94 | .align 2 | ||
95 | .globl _port_thread_start | ||
96 | .type _port_thread_start, @function | ||
97 | _port_thread_start: | ||
98 | #if CH_DBG_SYSTEM_STATE_CHECK | ||
99 | bl _dbg_check_unlock | ||
100 | #endif | ||
101 | #if CH_DBG_STATISTICS | ||
102 | bl _stats_stop_measure_crit_thd | ||
103 | #endif | ||
104 | wrteei 1 | ||
105 | mr r3, r31 | ||
106 | mtctr r30 | ||
107 | se_bctrl | ||
108 | se_li r0, 0 | ||
109 | e_bl chThdExit | ||
110 | |||
111 | #else /* PPC_USE_VLE == FALSE */ | ||
112 | |||
113 | #error "non-VLE mode not yet implemented" | ||
114 | |||
115 | #endif /* PPC_USE_VLE == FALSE */ | ||
116 | |||
117 | #endif /* !defined(__DOXYGEN__) */ | ||
118 | |||
119 | /** @} */ | ||
diff --git a/lib/chibios/os/common/ports/e200/compilers/CW/chtypes.h b/lib/chibios/os/common/ports/e200/compilers/CW/chtypes.h new file mode 100644 index 000000000..656b90557 --- /dev/null +++ b/lib/chibios/os/common/ports/e200/compilers/CW/chtypes.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | ||
3 | 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | ||
4 | |||
5 | This file is part of ChibiOS. | ||
6 | |||
7 | ChibiOS is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation version 3 of the License. | ||
10 | |||
11 | ChibiOS is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file e200/compilers/CW/chtypes.h | ||
22 | * @brief Power e200 port system types. | ||
23 | * | ||
24 | * @addtogroup PPC_CW_CORE | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | #ifndef CHTYPES_H | ||
29 | #define CHTYPES_H | ||
30 | |||
31 | #include <stddef.h> | ||
32 | #include <stdint.h> | ||
33 | #include <stdbool.h> | ||
34 | |||
35 | /** | ||
36 | * @name Kernel types | ||
37 | * @{ | ||
38 | */ | ||
39 | typedef uint32_t rtcnt_t; /**< Realtime counter. */ | ||
40 | typedef uint64_t rttime_t; /**< Realtime accumulator. */ | ||
41 | typedef uint32_t syssts_t; /**< System status word. */ | ||
42 | typedef uint8_t tmode_t; /**< Thread flags. */ | ||
43 | typedef uint8_t tstate_t; /**< Thread state. */ | ||
44 | typedef uint8_t trefs_t; /**< Thread references counter. */ | ||
45 | typedef uint8_t tslices_t; /**< Thread time slices counter.*/ | ||
46 | typedef uint32_t tprio_t; /**< Thread priority. */ | ||
47 | typedef int32_t msg_t; /**< Inter-thread message. */ | ||
48 | typedef int32_t eventid_t; /**< Numeric event identifier. */ | ||
49 | typedef uint32_t eventmask_t; /**< Mask of event identifiers. */ | ||
50 | typedef uint32_t eventflags_t; /**< Mask of event flags. */ | ||
51 | typedef int32_t cnt_t; /**< Generic signed counter. */ | ||
52 | typedef uint32_t ucnt_t; /**< Generic unsigned counter. */ | ||
53 | /** @} */ | ||
54 | |||
55 | /** | ||
56 | * @brief ROM constant modifier. | ||
57 | * @note It is set to use the "const" keyword in this port. | ||
58 | */ | ||
59 | #define ROMCONST const | ||
60 | |||
61 | /** | ||
62 | * @brief Makes functions not inlineable. | ||
63 | * @note If the compiler does not support such attribute then some | ||
64 | * time-dependent services could be degraded. | ||
65 | */ | ||
66 | #define NOINLINE __attribute__((noinline)) | ||
67 | |||
68 | /** | ||
69 | * @brief Optimized thread function declaration macro. | ||
70 | */ | ||
71 | #define PORT_THD_FUNCTION(tname, arg) void tname(void *arg) | ||
72 | |||
73 | /** | ||
74 | * @brief Packed variable specifier. | ||
75 | */ | ||
76 | #define PACKED_VAR __attribute__((packed)) | ||
77 | |||
78 | /** | ||
79 | * @brief Memory alignment enforcement for variables. | ||
80 | */ | ||
81 | #define ALIGNED_VAR(n) __attribute__((aligned(n))) | ||
82 | |||
83 | /** | ||
84 | * @brief Size of a pointer. | ||
85 | * @note To be used where the sizeof operator cannot be used, preprocessor | ||
86 | * expressions for example. | ||
87 | */ | ||
88 | #define SIZEOF_PTR 4 | ||
89 | |||
90 | /** | ||
91 | * @brief True if alignment is low-high in current architecture. | ||
92 | */ | ||
93 | #define REVERSE_ORDER 0 | ||
94 | |||
95 | #endif /* CHTYPES_H */ | ||
96 | |||
97 | /** @} */ | ||
diff --git a/lib/chibios/os/common/ports/e200/compilers/CW/ivor.s b/lib/chibios/os/common/ports/e200/compilers/CW/ivor.s new file mode 100644 index 000000000..7c546f28f --- /dev/null +++ b/lib/chibios/os/common/ports/e200/compilers/CW/ivor.s | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | ||
3 | 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | ||
4 | |||
5 | This file is part of ChibiOS. | ||
6 | |||
7 | ChibiOS is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation version 3 of the License. | ||
10 | |||
11 | ChibiOS is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file ivor.s | ||
22 | * @brief Kernel ISRs. | ||
23 | * | ||
24 | * @addtogroup PPC_CORE | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | /*===========================================================================*/ | ||
29 | /* Module constants. */ | ||
30 | /*===========================================================================*/ | ||
31 | |||
32 | #if !defined(FALSE) || defined(__DOXYGEN__) | ||
33 | #define FALSE 0 | ||
34 | #endif | ||
35 | |||
36 | #if !defined(TRUE) || defined(__DOXYGEN__) | ||
37 | #define TRUE 1 | ||
38 | #endif | ||
39 | |||
40 | /*===========================================================================*/ | ||
41 | /* Code section. */ | ||
42 | /*===========================================================================*/ | ||
43 | |||
44 | /* | ||
45 | * Imports the PPC configuration headers. | ||
46 | */ | ||
47 | #define _FROM_ASM_ | ||
48 | #include "chlicense.h" | ||
49 | #include "chconf.h" | ||
50 | #include "chcore.h" | ||
51 | |||
52 | #if !defined(__DOXYGEN__) | ||
53 | |||
54 | .extern _stats_start_measure_crit_thd | ||
55 | .extern _stats_stop_measure_crit_thd | ||
56 | .extern _dbg_check_lock | ||
57 | .extern _dbg_check_unlock | ||
58 | .extern chSchIsPreemptionRequired | ||
59 | .extern chSchDoReschedule | ||
60 | .extern chSysTimerHandlerI | ||
61 | |||
62 | .section .handlers, text_vle | ||
63 | |||
64 | #if PPC_USE_VLE == TRUE | ||
65 | |||
66 | #if PPC_SUPPORTS_DECREMENTER | ||
67 | /* | ||
68 | * _IVOR10 handler (Book-E decrementer). | ||
69 | */ | ||
70 | .align 16 | ||
71 | .globl _IVOR10 | ||
72 | .type _IVOR10, @function | ||
73 | _IVOR10: | ||
74 | /* Saving the external context (port_extctx structure).*/ | ||
75 | e_stwu r1, -80(r1) | ||
76 | e_stmvsrrw 8(r1) /* Saves PC, MSR. */ | ||
77 | e_stmvsprw 16(r1) /* Saves CR, LR, CTR, XER. */ | ||
78 | e_stmvgprw 32(r1) /* Saves GPR0, GPR3...GPR12. */ | ||
79 | |||
80 | /* Increasing the SPGR0 register.*/ | ||
81 | mfspr r0, 272 | ||
82 | se_addi r0, 1 | ||
83 | mtspr 272, r0 | ||
84 | |||
85 | /* Reset DIE bit in TSR register.*/ | ||
86 | e_lis r3, 0x0800 /* DIS bit mask. */ | ||
87 | mtspr 336, r3 /* TSR register. */ | ||
88 | |||
89 | /* Restoring pre-IRQ MSR register value.*/ | ||
90 | mfSRR1 r0 | ||
91 | #if !PPC_USE_IRQ_PREEMPTION | ||
92 | /* No preemption, keeping EE disabled.*/ | ||
93 | se_bclri r0, 16 /* EE = bit 16. */ | ||
94 | #endif | ||
95 | mtMSR r0 | ||
96 | |||
97 | #if CH_DBG_SYSTEM_STATE_CHECK | ||
98 | bl _dbg_check_enter_isr | ||
99 | bl _dbg_check_lock_from_isr | ||
100 | #endif | ||
101 | /* System tick handler invocation.*/ | ||
102 | e_bl chSysTimerHandlerI | ||
103 | #if CH_DBG_SYSTEM_STATE_CHECK | ||
104 | bl _dbg_check_unlock_from_isr | ||
105 | bl _dbg_check_leave_isr | ||
106 | #endif | ||
107 | |||
108 | #if PPC_USE_IRQ_PREEMPTION | ||
109 | /* Prevents preemption again.*/ | ||
110 | wrteei 0 | ||
111 | #endif | ||
112 | |||
113 | /* Jumps to the common IVOR epilogue code.*/ | ||
114 | se_b _ivor_exit | ||
115 | #endif /* PPC_SUPPORTS_DECREMENTER */ | ||
116 | |||
117 | /* | ||
118 | * _IVOR4 handler (Book-E external interrupt). | ||
119 | */ | ||
120 | .align 16 | ||
121 | .globl _IVOR4 | ||
122 | .type _IVOR4, @function | ||
123 | _IVOR4: | ||
124 | /* Saving the external context (port_extctx structure).*/ | ||
125 | e_stwu r1, -80(r1) | ||
126 | e_stmvsrrw 8(r1) /* Saves PC, MSR. */ | ||
127 | e_stmvsprw 16(r1) /* Saves CR, LR, CTR, XER. */ | ||
128 | e_stmvgprw 32(r1) /* Saves GPR0, GPR3...GPR12. */ | ||
129 | |||
130 | /* Increasing the SPGR0 register.*/ | ||
131 | mfspr r0, 272 | ||
132 | se_addi r0, 1 | ||
133 | mtspr 272, r0 | ||
134 | |||
135 | /* Software vector address from the INTC register.*/ | ||
136 | e_lis r3, INTC_IACKR_ADDR@h | ||
137 | e_or2i r3, INTC_IACKR_ADDR@l /* IACKR register address. */ | ||
138 | se_lwz r3, 0(r3) /* IACKR register value. */ | ||
139 | se_lwz r3, 0(r3) | ||
140 | mtCTR r3 /* Software handler address. */ | ||
141 | |||
142 | /* Restoring pre-IRQ MSR register value.*/ | ||
143 | mfSRR1 r0 | ||
144 | #if !PPC_USE_IRQ_PREEMPTION | ||
145 | /* No preemption, keeping EE disabled.*/ | ||
146 | se_bclri r0, 16 /* EE = bit 16. */ | ||
147 | #endif | ||
148 | mtMSR r0 | ||
149 | |||
150 | /* Exectes the software handler.*/ | ||
151 | se_bctrl | ||
152 | |||
153 | #if PPC_USE_IRQ_PREEMPTION | ||
154 | /* Prevents preemption again.*/ | ||
155 | wrteei 0 | ||
156 | #endif | ||
157 | |||
158 | /* Informs the INTC that the interrupt has been served.*/ | ||
159 | mbar 0 | ||
160 | e_lis r3, INTC_EOIR_ADDR@h | ||
161 | e_or2i r3, INTC_EOIR_ADDR@l | ||
162 | se_stw r3, 0(r3) /* Writing any value should do. */ | ||
163 | |||
164 | /* Common IVOR epilogue code, context restore.*/ | ||
165 | .globl _ivor_exit | ||
166 | _ivor_exit: | ||
167 | /* Decreasing the SPGR0 register.*/ | ||
168 | mfspr r0, 272 | ||
169 | se_subi r0, 1 | ||
170 | mtspr 272, r0 | ||
171 | |||
172 | #if CH_DBG_STATISTICS | ||
173 | e_bl _stats_start_measure_crit_thd | ||
174 | #endif | ||
175 | #if CH_DBG_SYSTEM_STATE_CHECK | ||
176 | e_bl _dbg_check_lock | ||
177 | #endif | ||
178 | e_bl chSchIsPreemptionRequired | ||
179 | e_cmpli cr0, r3, 0 | ||
180 | se_beq .noresch | ||
181 | e_bl chSchDoReschedule | ||
182 | .noresch: | ||
183 | #if CH_DBG_SYSTEM_STATE_CHECK | ||
184 | e_bl _dbg_check_unlock | ||
185 | #endif | ||
186 | #if CH_DBG_STATISTICS | ||
187 | e_bl _stats_stop_measure_crit_thd | ||
188 | #endif | ||
189 | |||
190 | /* Restoring the external context.*/ | ||
191 | e_lmvgprw 32(r1) /* Restores GPR0, GPR3...GPR12. */ | ||
192 | e_lmvsprw 16(r1) /* Restores CR, LR, CTR, XER. */ | ||
193 | e_lmvsrrw 8(r1) /* Restores PC, MSR. */ | ||
194 | e_addi r1, r1, 80 /* Back to the previous frame. */ | ||
195 | se_rfi | ||
196 | |||
197 | #else /* PPC_USE_VLE == FALSE */ | ||
198 | |||
199 | #error "non-VLE mode not yet implemented" | ||
200 | |||
201 | #endif /* PPC_USE_VLE == FALSE */ | ||
202 | |||
203 | #endif /* !defined(__DOXYGEN__) */ | ||
204 | |||
205 | /** @} */ | ||