├── FreeRTOS
├── Demo
│ └── CORTEX_A57_64-bit
│ │ ├── FreeRTOS_asm_vectors.S
│ │ ├── FreeRTOS_tick_config.c
│ │ ├── example.c
│ │ ├── exception.c
│ │ ├── gic_v3.c
│ │ ├── include
│ │ ├── FreeRTOSConfig.h
│ │ ├── board.h
│ │ ├── cpu.h
│ │ ├── example.h
│ │ ├── exception.h
│ │ ├── gic_v3.h
│ │ └── uart.h
│ │ ├── linker.ld
│ │ ├── main.c
│ │ ├── nostdlib.c
│ │ ├── printf-stdarg.c
│ │ ├── pstate.c
│ │ ├── start.S
│ │ ├── sysctrl.c
│ │ ├── uart.c
│ │ └── vectors.c
├── License
│ └── license.txt
├── Source
│ ├── croutine.c
│ ├── event_groups.c
│ ├── include
│ │ ├── FreeRTOS.h
│ │ ├── StackMacros.h
│ │ ├── croutine.h
│ │ ├── deprecated_definitions.h
│ │ ├── event_groups.h
│ │ ├── list.h
│ │ ├── message_buffer.h
│ │ ├── mpu_prototypes.h
│ │ ├── mpu_wrappers.h
│ │ ├── portable.h
│ │ ├── projdefs.h
│ │ ├── queue.h
│ │ ├── semphr.h
│ │ ├── stack_macros.h
│ │ ├── stdint.readme
│ │ ├── stream_buffer.h
│ │ ├── task.h
│ │ └── timers.h
│ ├── list.c
│ ├── portable
│ │ ├── GCC
│ │ │ └── ARM_CA57_64_BIT
│ │ │ │ ├── port.c
│ │ │ │ ├── portASM.S
│ │ │ │ └── portmacro.h
│ │ ├── MemMang
│ │ │ ├── ReadMe.url
│ │ │ ├── heap_1.c
│ │ │ ├── heap_2.c
│ │ │ ├── heap_3.c
│ │ │ ├── heap_4.c
│ │ │ └── heap_5.c
│ │ └── readme.txt
│ ├── queue.c
│ ├── readme.txt
│ ├── stream_buffer.c
│ ├── tasks.c
│ └── timers.c
├── links_to_doc_pages_for_the_demo_projects.url
└── readme.txt
├── Makefile
├── README.md
└── gen_tags.sh
/FreeRTOS/Demo/CORTEX_A57_64-bit/FreeRTOS_asm_vectors.S:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | *
3 | * Copyright (C) 2014 Xilinx, Inc. All rights reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * Use of the Software is limited solely to applications:
16 | * (a) running on a Xilinx device, or
17 | * (b) that interact with a Xilinx device through a bus or interconnect.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | *
27 | * Except as contained in this notice, the name of the Xilinx shall not be used
28 | * in advertising or otherwise to promote the sale, use or other dealings in
29 | * this Software without prior written authorization from Xilinx.
30 | *
31 | ******************************************************************************/
32 | /*****************************************************************************/
33 | /**
34 | * @file asm_vectors.s
35 | *
36 | * This file contains the initial vector table for the Cortex A53 processor
37 | * Currently NEON registers are not saved on stack if interrupt is taken.
38 | * It will be implemented.
39 | *
40 | *
41 | * MODIFICATION HISTORY:
42 | *
43 | * Ver Who Date Changes
44 | * ----- ------- -------- ---------------------------------------------------
45 | * 5.00 pkp 5/21/14 Initial version
46 | *
47 | *
48 | * @note
49 | *
50 | * None.
51 | *
52 | ******************************************************************************/
53 | #define ASM_FILE 1
54 |
55 | #include "exception.h"
56 |
57 | .org 0
58 | .text
59 |
60 | .globl _boot
61 | .globl _vector_table
62 | .globl _freertos_vector_table
63 |
64 | .globl FIQInterrupt
65 | .globl IRQInterrupt
66 | .globl SErrorInterrupt
67 | .globl SynchronousInterrupt
68 |
69 |
70 | .macro build_trapframe exc_type
71 | /*
72 | * store generic registers from (x29,x30) pair to (x1,x2) pair.
73 | */
74 | stp x29, x30, [sp, #-16]!
75 | stp x27, x28, [sp, #-16]!
76 | stp x25, x26, [sp, #-16]!
77 | stp x23, x24, [sp, #-16]!
78 | stp x21, x22, [sp, #-16]!
79 | stp x19, x20, [sp, #-16]!
80 | stp x17, x18, [sp, #-16]!
81 | stp x15, x16, [sp, #-16]!
82 | stp x13, x14, [sp, #-16]!
83 | stp x11, x12, [sp, #-16]!
84 | stp x9, x10, [sp, #-16]!
85 | stp x7, x8, [sp, #-16]!
86 | stp x5, x6, [sp, #-16]!
87 | stp x3, x4, [sp, #-16]!
88 | stp x1, x2, [sp, #-16]!
89 | /*
90 | * Store (spsr, x0)
91 | */
92 | mrs x21, spsr_el1
93 | stp x21, x0, [sp, #-16]!
94 | /*
95 | * Allocate a room for sp_el0 and store elr
96 | */
97 | mrs x21, elr_el1
98 | stp xzr, x21, [sp, #-16]!
99 | /*
100 | * store exception type and esr
101 | */
102 | mov x21, #(\exc_type)
103 | mrs x22, esr_el1
104 | stp x21, x22, [sp, #-16]!
105 | .endm
106 |
107 | .macro store_traped_sp
108 | mrs x21, sp_el0
109 | str x21, [sp, #EXC_EXC_SP_OFFSET]
110 | .endm
111 |
112 | .macro call_common_trap_handler
113 | mov x0, sp
114 | bl common_trap_handler
115 | .endm
116 |
117 | .macro store_nested_sp
118 | mov x21, sp
119 | add x21, x21, #EXC_FRAME_SIZE
120 | str x21, [sp, #EXC_EXC_SP_OFFSET]
121 | .endm
122 |
123 | .macro restore_traped_sp
124 | ldr x21, [sp, #EXC_EXC_SP_OFFSET]
125 | msr sp_el0, x21
126 | .endm
127 |
128 | .macro restore_trapframe
129 |
130 | /*
131 | * Drop exception type, esr,
132 | */
133 | add sp, sp, #16
134 | /*
135 | * Drop exception stack pointer and restore elr_el1
136 | */
137 | ldp x21, x22, [sp], #16
138 | msr elr_el1, x22
139 |
140 | /*
141 | * Retore spsr and x0
142 | */
143 | ldp x21, x0, [sp], #16
144 | msr spsr_el1, x21
145 |
146 | /*
147 | * Restore generic registers from (x29,x30) pair to (x1,x2) pair.
148 | */
149 | ldp x1, x2, [sp], #16
150 | ldp x3, x4, [sp], #16
151 | ldp x5, x6, [sp], #16
152 | ldp x7, x8, [sp], #16
153 | ldp x9, x10, [sp], #16
154 | ldp x11, x12, [sp], #16
155 | ldp x13, x14, [sp], #16
156 | ldp x15, x16, [sp], #16
157 | ldp x17, x18, [sp], #16
158 | ldp x19, x20, [sp], #16
159 | ldp x21, x22, [sp], #16
160 | ldp x23, x24, [sp], #16
161 | ldp x25, x26, [sp], #16
162 | ldp x27, x28, [sp], #16
163 | ldp x29, x30, [sp], #16
164 |
165 | eret
166 | .endm
167 |
168 |
169 | /*
170 | * Exception vectors.
171 | */
172 | .balign 2048
173 | .section .vectors
174 | _vector_table:
175 |
176 | .set VBAR, _vector_table
177 | /*
178 | * Current EL with SP0
179 | */
180 | .org VBAR
181 | /* b _boot */
182 | b _curr_el_sp0_sync /* Synchronous */
183 | .org (VBAR + 0x80)
184 | b _curr_el_sp0_irq /* IRQ/vIRQ */
185 | .org (VBAR + 0x100)
186 | b _curr_el_sp0_fiq /* FIQ/vFIQ */
187 | .org (VBAR + 0x180)
188 | b _curr_el_sp0_serror /* SError/vSError */
189 |
190 | /*
191 | * Current EL with SPx
192 | */
193 | .org (VBAR + 0x200)
194 | b _curr_el_spx_sync /* Synchronous */
195 | .org (VBAR + 0x280)
196 | b _curr_el_spx_irq /* IRQ/vIRQ */
197 | .org (VBAR + 0x300)
198 | b _curr_el_spx_fiq /* FIQ/vFIQ */
199 | .org (VBAR + 0x380)
200 | b _curr_el_spx_serror /* SError/vSError */
201 |
202 | /*
203 | * Lower EL using AArch64
204 | */
205 | .org (VBAR + 0x400)
206 | b _lower_el_aarch64_sync
207 | .org (VBAR + 0x480)
208 | b _lower_el_aarch64_irq
209 | .org (VBAR + 0x500)
210 | b _lower_el_aarch64_fiq
211 | .org (VBAR + 0x580)
212 | b _lower_el_aarch64_serror
213 |
214 | /*
215 | * Lower EL using AArch32
216 | */
217 | .org (VBAR + 0x600)
218 | b _lower_el_aarch32_sync
219 | .org (VBAR + 0x680)
220 | b _lower_el_aarch32_irq
221 | .org (VBAR + 0x700)
222 | b _lower_el_aarch32_fiq
223 | .org (VBAR + 0x780)
224 | b _lower_el_aarch32_serror
225 |
226 | text_align
227 | _curr_el_sp0_sync:
228 | build_trapframe AARCH64_EXC_SYNC_SP0
229 | store_traped_sp
230 | call_common_trap_handler
231 | restore_traped_sp
232 | restore_trapframe
233 |
234 | text_align
235 | _curr_el_sp0_irq:
236 | build_trapframe AARCH64_EXC_IRQ_SP0
237 | store_traped_sp
238 | call_common_trap_handler
239 | restore_traped_sp
240 | restore_trapframe
241 |
242 | text_align
243 | _curr_el_sp0_fiq:
244 | build_trapframe AARCH64_EXC_FIQ_SP0
245 | store_traped_sp
246 | call_common_trap_handler
247 | restore_traped_sp
248 | restore_trapframe
249 |
250 | text_align
251 | _curr_el_sp0_serror:
252 | build_trapframe AARCH64_EXC_SERR_SP0
253 | store_traped_sp
254 | call_common_trap_handler
255 | restore_traped_sp
256 | restore_trapframe
257 |
258 |
259 | text_align
260 | _curr_el_spx_sync:
261 | build_trapframe AARCH64_EXC_SYNC_SPX
262 | store_nested_sp
263 | call_common_trap_handler
264 | restore_trapframe
265 |
266 | text_align
267 | _curr_el_spx_irq:
268 | build_trapframe AARCH64_EXC_IRQ_SPX
269 | store_nested_sp
270 | call_common_trap_handler
271 | restore_trapframe
272 |
273 | text_align
274 | _curr_el_spx_fiq:
275 | build_trapframe AARCH64_EXC_FIQ_SPX
276 | store_nested_sp
277 | call_common_trap_handler
278 | restore_trapframe
279 |
280 | text_align
281 | _curr_el_spx_serror:
282 | build_trapframe AARCH64_EXC_SERR_SPX
283 | store_nested_sp
284 | call_common_trap_handler
285 | restore_trapframe
286 |
287 |
288 | text_align
289 | _lower_el_aarch64_sync:
290 | build_trapframe AARCH64_EXC_SYNC_AARCH64
291 | store_traped_sp
292 | call_common_trap_handler
293 | restore_traped_sp
294 | restore_trapframe
295 |
296 | text_align
297 | _lower_el_aarch64_irq:
298 | build_trapframe AARCH64_EXC_IRQ_AARCH64
299 | store_traped_sp
300 | call_common_trap_handler
301 | restore_traped_sp
302 | restore_trapframe
303 |
304 | text_align
305 | _lower_el_aarch64_fiq:
306 | build_trapframe AARCH64_EXC_FIQ_AARCH64
307 | store_traped_sp
308 | call_common_trap_handler
309 | restore_traped_sp
310 | restore_trapframe
311 |
312 | text_align
313 | _lower_el_aarch64_serror:
314 | build_trapframe AARCH64_EXC_SERR_AARCH64
315 | store_traped_sp
316 | call_common_trap_handler
317 | restore_traped_sp
318 | restore_trapframe
319 |
320 |
321 | text_align
322 | _lower_el_aarch32_sync:
323 | build_trapframe AARCH64_EXC_SYNC_AARCH32
324 | store_traped_sp
325 | call_common_trap_handler
326 | restore_traped_sp
327 | restore_trapframe
328 |
329 | text_align
330 | _lower_el_aarch32_irq:
331 | build_trapframe AARCH64_EXC_IRQ_AARCH32
332 | store_traped_sp
333 | call_common_trap_handler
334 | restore_traped_sp
335 | restore_trapframe
336 |
337 | text_align
338 | _lower_el_aarch32_fiq:
339 | build_trapframe AARCH64_EXC_FIQ_AARCH32
340 | store_traped_sp
341 | call_common_trap_handler
342 | restore_traped_sp
343 | restore_trapframe
344 |
345 | text_align
346 | _lower_el_aarch32_serror:
347 | build_trapframe AARCH64_EXC_SERR_AARCH32
348 | store_traped_sp
349 | call_common_trap_handler
350 | restore_traped_sp
351 | restore_trapframe
352 |
353 |
354 | /******************************************************************************
355 | * Vector table to use when FreeRTOS is running.
356 | *****************************************************************************/
357 | .set FREERTOS_VBAR, (VBAR+0x2000)
358 |
359 | .org(FREERTOS_VBAR)
360 | _freertos_vector_table:
361 | b FreeRTOS_SWI_Handler
362 |
363 | .org (FREERTOS_VBAR + 0x80)
364 | b FreeRTOS_IRQ_Handler
365 |
366 | .org (FREERTOS_VBAR + 0x100)
367 | b .
368 |
369 | .org (FREERTOS_VBAR + 0x180)
370 | b .
371 |
372 | .org (FREERTOS_VBAR + 0x200)
373 | b FreeRTOS_SWI_Handler
374 |
375 | .org (FREERTOS_VBAR + 0x280)
376 | b FreeRTOS_IRQ_Handler
377 |
378 | .org (FREERTOS_VBAR + 0x300)
379 | b .
380 |
381 | .org (FREERTOS_VBAR + 0x380)
382 | b .
383 |
384 | .org (FREERTOS_VBAR + 0x400)
385 | b .
386 |
387 | .org (FREERTOS_VBAR + 0x480)
388 | b .
389 |
390 | .org (FREERTOS_VBAR + 0x500)
391 | b .
392 |
393 | .org (FREERTOS_VBAR + 0x580)
394 | b .
395 |
396 | .org (FREERTOS_VBAR + 0x600)
397 | b .
398 |
399 | .org (FREERTOS_VBAR + 0x680)
400 | b .
401 |
402 | .org (FREERTOS_VBAR + 0x700)
403 | b .
404 |
405 | .org (FREERTOS_VBAR + 0x780)
406 | b .
407 |
408 | .org (FREERTOS_VBAR + 0x800)
409 |
410 |
411 |
412 |
413 | SynchronousInterruptHandler:
414 | stp X0,X1, [sp,#-0x10]!
415 | stp X2,X3, [sp,#-0x10]!
416 | stp X4,X5, [sp,#-0x10]!
417 | stp X6,X7, [sp,#-0x10]!
418 | stp X8,X9, [sp,#-0x10]!
419 | stp X10,X11, [sp,#-0x10]!
420 | stp X12,X13, [sp,#-0x10]!
421 | stp X14,X15, [sp,#-0x10]!
422 | stp X16,X17, [sp,#-0x10]!
423 | stp X18,X19, [sp,#-0x10]!
424 | stp X29,X30, [sp,#-0x10]!
425 |
426 | bl SynchronousInterrupt
427 |
428 | ldp X29,X30, [sp], #0x10
429 | ldp X18,X19, [sp], #0x10
430 | ldp X16,X17, [sp], #0x10
431 | ldp X14,X15, [sp], #0x10
432 | ldp X12,X13, [sp], #0x10
433 | ldp X10,X11, [sp], #0x10
434 | ldp X8,X9, [sp], #0x10
435 | ldp X6,X7, [sp], #0x10
436 | ldp X4,X5, [sp], #0x10
437 | ldp X2,X3, [sp], #0x10
438 | ldp X0,X1, [sp], #0x10
439 |
440 | eret
441 |
442 | IRQInterruptHandler:
443 | stp X0,X1, [sp,#-0x10]!
444 | stp X2,X3, [sp,#-0x10]!
445 | stp X4,X5, [sp,#-0x10]!
446 | stp X6,X7, [sp,#-0x10]!
447 | stp X8,X9, [sp,#-0x10]!
448 | stp X10,X11, [sp,#-0x10]!
449 | stp X12,X13, [sp,#-0x10]!
450 | stp X14,X15, [sp,#-0x10]!
451 | stp X16,X17, [sp,#-0x10]!
452 | stp X18,X19, [sp,#-0x10]!
453 | stp X29,X30, [sp,#-0x10]!
454 |
455 | bl IRQInterrupt
456 |
457 | ldp X29,X30, [sp], #0x10
458 | ldp X18,X19, [sp], #0x10
459 | ldp X16,X17, [sp], #0x10
460 | ldp X14,X15, [sp], #0x10
461 | ldp X12,X13, [sp], #0x10
462 | ldp X10,X11, [sp], #0x10
463 | ldp X8,X9, [sp], #0x10
464 | ldp X6,X7, [sp], #0x10
465 | ldp X4,X5, [sp], #0x10
466 | ldp X2,X3, [sp], #0x10
467 | ldp X0,X1, [sp], #0x10
468 |
469 | eret
470 |
471 | FIQInterruptHandler:
472 |
473 | stp X0,X1, [sp,#-0x10]!
474 | stp X2,X3, [sp,#-0x10]!
475 | stp X4,X5, [sp,#-0x10]!
476 | stp X6,X7, [sp,#-0x10]!
477 | stp X8,X9, [sp,#-0x10]!
478 | stp X10,X11, [sp,#-0x10]!
479 | stp X12,X13, [sp,#-0x10]!
480 | stp X14,X15, [sp,#-0x10]!
481 | stp X16,X17, [sp,#-0x10]!
482 | stp X18,X19, [sp,#-0x10]!
483 | stp X29,X30, [sp,#-0x10]!
484 |
485 | bl FIQInterrupt
486 |
487 | ldp X29,X30, [sp], #0x10
488 | ldp X18,X19, [sp], #0x10
489 | ldp X16,X17, [sp], #0x10
490 | ldp X14,X15, [sp], #0x10
491 | ldp X12,X13, [sp], #0x10
492 | ldp X10,X11, [sp], #0x10
493 | ldp X8,X9, [sp], #0x10
494 | ldp X6,X7, [sp], #0x10
495 | ldp X4,X5, [sp], #0x10
496 | ldp X2,X3, [sp], #0x10
497 | ldp X0,X1, [sp], #0x10
498 |
499 | eret
500 |
501 | SErrorInterruptHandler:
502 |
503 | stp X0,X1, [sp,#-0x10]!
504 | stp X2,X3, [sp,#-0x10]!
505 | stp X4,X5, [sp,#-0x10]!
506 | stp X6,X7, [sp,#-0x10]!
507 | stp X8,X9, [sp,#-0x10]!
508 | stp X10,X11, [sp,#-0x10]!
509 | stp X12,X13, [sp,#-0x10]!
510 | stp X14,X15, [sp,#-0x10]!
511 | stp X16,X17, [sp,#-0x10]!
512 | stp X18,X19, [sp,#-0x10]!
513 | stp X29,X30, [sp,#-0x10]!
514 |
515 | bl SErrorInterrupt
516 |
517 | ldp X29,X30, [sp], #0x10
518 | ldp X18,X19, [sp], #0x10
519 | ldp X16,X17, [sp], #0x10
520 | ldp X14,X15, [sp], #0x10
521 | ldp X12,X13, [sp], #0x10
522 | ldp X10,X11, [sp], #0x10
523 | ldp X8,X9, [sp], #0x10
524 | ldp X6,X7, [sp], #0x10
525 | ldp X4,X5, [sp], #0x10
526 | ldp X2,X3, [sp], #0x10
527 | ldp X0,X1, [sp], #0x10
528 |
529 | eret
530 |
531 | .end
532 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/FreeRTOS_tick_config.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | /* FreeRTOS includes. */
29 | #include "FreeRTOS.h"
30 | #include "task.h"
31 | #include "cpu.h"
32 | #include "uart.h"
33 |
34 | static uint32_t cntfrq; /* System frequency */
35 |
36 | /* Timer used to generate the tick interrupt. */
37 | void vConfigureTickInterrupt( void )
38 | {
39 | // Disable the timer
40 | disable_cntv();
41 | // Get system frequency
42 | cntfrq = raw_read_cntfrq_el0();
43 | // Set tick rate
44 | raw_write_cntv_tval_el0(cntfrq/configTICK_RATE_HZ);
45 | // Enable the timer
46 | enable_cntv();
47 | }
48 | /*-----------------------------------------------------------*/
49 |
50 | void vClearTickInterrupt( void )
51 | {
52 | raw_write_cntv_tval_el0(cntfrq/configTICK_RATE_HZ);
53 | }
54 | /*-----------------------------------------------------------*/
55 |
56 | void vApplicationIRQHandler( uint32_t ulICCIAR )
57 | {
58 | uint32_t ulInterruptID;
59 |
60 | /* Interrupts cannot be re-enabled until the source of the interrupt is
61 | cleared. The ID of the interrupt is obtained by bitwise ANDing the ICCIAR
62 | value with 0x3FF. */
63 | ulInterruptID = ulICCIAR & 0x3FFUL;
64 |
65 | /* call handler function */
66 | if( ulInterruptID == TIMER_IRQ) {
67 | /* Generic Timer */
68 | FreeRTOS_Tick_Handler();
69 | }else{
70 | printf("\n%s(): IRQ happend (%u)\n", __func__, ulInterruptID);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/example.c:
--------------------------------------------------------------------------------
1 | #include "FreeRTOSConfig.h"
2 | #include "FreeRTOS.h"
3 | #include "task.h"
4 | #include "queue.h"
5 | #include "semphr.h"
6 | #include "uart.h"
7 | #include "timers.h"
8 | #include "example.h"
9 |
10 |
11 | /* Queue Example */
12 | static xQueueHandle Global_Queue_Handle = 0;
13 |
14 | void sender_task(void *p)
15 | {
16 | (void)p;
17 | int i=0;
18 | while(1){
19 | printf("Send %d to receiver task.\n", i);
20 | if(!xQueueSend(Global_Queue_Handle, &i, 1000)){
21 | printf("Failed to send to queue.\n");
22 | }
23 | i++;
24 | vTaskDelay(3000);
25 | }
26 | }
27 |
28 | void receive_task(void *p)
29 | {
30 | int rx_int=0;
31 |
32 | (void)p;
33 | while(1){
34 | if(xQueueReceive(Global_Queue_Handle, &rx_int, 1000)){
35 | printf("Received %d.\n", rx_int);
36 | }else{
37 | printf("Failed to receive from queue.\n");
38 | }
39 | }
40 | }
41 |
42 | void test_queue(void)
43 | {
44 | Global_Queue_Handle = xQueueCreate(3, sizeof(int));
45 |
46 | /* Create Tasks */
47 | xTaskCreate(sender_task, "tx", 1024, NULL, 1, NULL);
48 | xTaskCreate(receive_task, "rx", 1024, NULL, 1, NULL);
49 | }
50 |
51 | /* Mutex Example */
52 | static xSemaphoreHandle gatekeeper = 0;
53 | static void access_precious_resource(void){}
54 |
55 | void user_1(void *p)
56 | {
57 | (void)p;
58 | while(1){
59 | if(xSemaphoreTake(gatekeeper, 1000)){
60 | printf("User 1 got access.\n");
61 | access_precious_resource();
62 | xSemaphoreGive(gatekeeper);
63 | }else{
64 | printf("User 1 failed to get access within 1 second.\n");
65 | }
66 | vTaskDelay(1000);
67 | }
68 | }
69 |
70 | void user_2(void *p)
71 | {
72 | (void)p;
73 | while(1){
74 | if(xSemaphoreTake(gatekeeper, 1000)){
75 | printf("User 2 got access.\n");
76 | access_precious_resource();
77 | xSemaphoreGive(gatekeeper);
78 | }else{
79 | printf("User 2 failed to get access within 1 second.\n");
80 | }
81 | vTaskDelay(1000);
82 | }
83 | }
84 |
85 | void test_semaphore(void)
86 | {
87 | gatekeeper = xSemaphoreCreateMutex();
88 |
89 | /* Create Tasks */
90 | xTaskCreate(user_1, "t1", 1024, NULL, 1, NULL);
91 | xTaskCreate(user_2, "t2", 1024, NULL, 1, NULL);
92 | }
93 |
94 | /* Binary Semaphore Example */
95 | static xSemaphoreHandle employee_signal = 0;
96 | static void employee_task(){}
97 |
98 | void boss(void *p)
99 | {
100 | (void)p;
101 | while(1){
102 | printf("Boss give the signal.\n");
103 | xSemaphoreGive(employee_signal);
104 | printf("Boss finished givin the signal.\n");
105 | vTaskDelay(2000);
106 | }
107 | }
108 |
109 | void employee(void *p)
110 | {
111 | (void)p;
112 | while(1){
113 | if(xSemaphoreTake(employee_signal, portMAX_DELAY)){
114 | employee_task();
115 | printf("Employee has finished its task.\n");
116 | }
117 | }
118 | }
119 |
120 | void test_binary_semaphore(void)
121 | {
122 | employee_signal = xSemaphoreCreateBinary();
123 |
124 | /* Create Tasks */
125 | /* Change the priority will affect the working flow */
126 | xTaskCreate(boss, "boss", 1024, NULL, 1, NULL);
127 | //xTaskCreate(employee, "employee", 1024, NULL, 1, NULL);
128 | xTaskCreate(employee, "employee", 1024, NULL, 2, NULL);
129 | }
130 |
131 | /* Software Timer Example */
132 | #define NUM_TIMERS 5
133 | /* An array to hold handles to the created timers. */
134 | TimerHandle_t xTimers[ NUM_TIMERS ];
135 |
136 | /* Define a callback function that will be used by multiple timer
137 | instances. The callback function does nothing but count the number
138 | of times the associated timer expires, and stop the timer once the
139 | timer has expired 10 times. The count is saved as the ID of the
140 | timer. */
141 | void vTimerCallback( TimerHandle_t pxTimer )
142 | {
143 | const uint32_t ulMaxExpiryCountBeforeStopping = 10;
144 | uint64_t ulCount;
145 |
146 | /* Optionally do something if the pxTimer parameter is NULL. */
147 | configASSERT( pxTimer );
148 |
149 | /* The number of times this timer has expired is saved as the
150 | timer's ID. Obtain the count. */
151 | ulCount = ( uint64_t ) pvTimerGetTimerID( pxTimer );
152 |
153 | /* Increment the count, then test to see if the timer has expired
154 | ulMaxExpiryCountBeforeStopping yet. */
155 | ulCount++;
156 |
157 | /* If the timer has expired 10 times then stop it from running. */
158 | if( ulCount >= ulMaxExpiryCountBeforeStopping )
159 | {
160 | /* Do not use a block time if calling a timer API function
161 | from a timer callback function, as doing so could cause a
162 | deadlock! */
163 | xTimerStop( pxTimer, 0 );
164 | printf("%s() Timer:%X Stop\n", __func__, pxTimer);
165 | } else {
166 | /* Store the incremented count back into the timer's ID field
167 | so it can be read back again the next time this software timer
168 | expires. */
169 | vTimerSetTimerID( pxTimer, ( void * ) ulCount );
170 | }
171 | }
172 |
173 | void TaskA(void *p)
174 | {
175 | (void) p;
176 | while(1){
177 | printf("%s() ticks:%d\n", __func__, xTaskGetTickCount());
178 | vTaskDelay(500 / portTICK_RATE_MS);
179 | }
180 | }
181 |
182 | void test_software_timer( void )
183 | {
184 | long x;
185 |
186 | printf("%s()\n", __func__);
187 | xTaskCreate(TaskA, "Task A", 512, NULL, tskIDLE_PRIORITY, NULL);
188 |
189 | /* Create then start some timers. Starting the timers before
190 | the RTOS scheduler has been started means the timers will start
191 | running immediately that the RTOS scheduler starts. */
192 | for( x = 0; x < NUM_TIMERS; x++ ) {
193 | xTimers[ x ] = xTimerCreate (
194 | "Timer", /* Just a text name, not used by the RTOS kernel. */
195 | ( 100 * x ) + 100, /* The timer period in ticks, must be greater than 0. */
196 | pdTRUE, /* The timers will auto-reload themselves when they expire. */
197 | ( void * ) 0, /* The ID is used to store a count of the number of times the timer has expired, which is initialised to 0. */
198 | vTimerCallback /* Each timer calls the same callback when it expires. */
199 | );
200 |
201 | if( xTimers[ x ] == NULL ) {
202 | /* The timer was not created. */
203 | printf("Timer[%d] failed to create.\n", x);
204 | } else {
205 | /* Start the timer. No block time is specified, and
206 | even if one was it would be ignored because the RTOS
207 | scheduler has not yet been started. */
208 | if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) {
209 | /* The timer could not be set into the Active state. */
210 | printf("Timer[%d] could not be set into the Active state.\n", x);
211 | }else{
212 | printf("Timer[%d]:%X is set into the Active state.\n", x, xTimers[x]);
213 | }
214 | }
215 | }
216 | }
217 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/exception.c:
--------------------------------------------------------------------------------
1 | /* -*- mode: c; coding:utf-8 -*- */
2 | /**********************************************************************/
3 | /* OS kernel sample */
4 | /* Copyright 2014 Takeharu KATO */
5 | /* */
6 | /* Exception handler */
7 | /* */
8 | /**********************************************************************/
9 | #include "exception.h"
10 | #include "uart.h"
11 |
12 | #if 1 //RyanYao
13 | void common_trap_handler(exception_frame *exc)
14 | {
15 | uart_puts("\nException Handler! ");
16 | uart_puthex(exc->exc_type);
17 | while(1){}
18 | return;
19 | }
20 | #else
21 | #include "uart.h"
22 | #include "psw.h"
23 | #include "board.h"
24 | #include "gic_v3.h"
25 |
26 | extern void timer_handler(void);
27 |
28 | void handle_exception(exception_frame *exc) {
29 | uart_puts("An exception occur:\n");
30 | uart_puts("exc_type: ");
31 | uart_puthex(exc->exc_type);
32 | uart_puts("\nESR: "); uart_puthex(exc->exc_esr);
33 | uart_puts(" SP: "); uart_puthex(exc->exc_sp);
34 | uart_puts(" ELR: "); uart_puthex(exc->exc_elr);
35 | uart_puts(" SPSR: "); uart_puthex(exc->exc_spsr);
36 | uart_puts("\n x0: "); uart_puthex(exc->x0);
37 | uart_puts(" x1: "); uart_puthex(exc->x1);
38 | uart_puts(" x2: "); uart_puthex(exc->x2);
39 | uart_puts(" x3: "); uart_puthex(exc->x3);
40 | uart_puts("\n x4: "); uart_puthex(exc->x4);
41 | uart_puts(" x5: "); uart_puthex(exc->x5);
42 | uart_puts(" x6: "); uart_puthex(exc->x6);
43 | uart_puts(" x7: "); uart_puthex(exc->x7);
44 | uart_puts("\n x8: "); uart_puthex(exc->x8);
45 | uart_puts(" x9: "); uart_puthex(exc->x9);
46 | uart_puts(" x10: "); uart_puthex(exc->x10);
47 | uart_puts(" x11: "); uart_puthex(exc->x11);
48 | uart_puts("\nx12: "); uart_puthex(exc->x12);
49 | uart_puts(" x13: "); uart_puthex(exc->x13);
50 | uart_puts(" x14: "); uart_puthex(exc->x14);
51 | uart_puts(" x15: "); uart_puthex(exc->x15);
52 | uart_puts("\nx16: "); uart_puthex(exc->x16);
53 | uart_puts(" x17: "); uart_puthex(exc->x17);
54 | uart_puts(" x18: "); uart_puthex(exc->x18);
55 | uart_puts(" x19: "); uart_puthex(exc->x19);
56 | uart_puts("\nx20: "); uart_puthex(exc->x20);
57 | uart_puts(" x21: "); uart_puthex(exc->x21);
58 | uart_puts(" x22: "); uart_puthex(exc->x22);
59 | uart_puts(" x23: "); uart_puthex(exc->x23);
60 | uart_puts("\nx24: "); uart_puthex(exc->x24);
61 | uart_puts(" x25: "); uart_puthex(exc->x25);
62 | uart_puts(" x26: "); uart_puthex(exc->x26);
63 | uart_puts(" x27: "); uart_puthex(exc->x27);
64 | uart_puts("\nx28: "); uart_puthex(exc->x28);
65 | uart_puts(" x29: "); uart_puthex(exc->x29);
66 | uart_puts(" x30: "); uart_puthex(exc->x30);
67 | }
68 |
69 | void irq_handle(exception_frame *exc)
70 | {
71 | psw_t psw;
72 | irq_no irq;
73 | int rc;
74 |
75 | psw_disable_and_save_interrupt(&psw);
76 | rc = gic_v3_find_pending_irq(exc, &irq);
77 | if ( rc != IRQ_FOUND ) {
78 | uart_puts("IRQ not found!\n");
79 | goto restore_irq_out;
80 | }else{
81 | uart_puts("IRQ found: ");
82 | uart_puthex(irq);
83 | uart_puts("\n");
84 | }
85 | gicd_disable_int(irq); /* Mask this irq */
86 | gic_v3_eoi(irq); /* Send EOI for this irq line */
87 | timer_handler();
88 | gicd_enable_int(irq); /* unmask this irq line */
89 |
90 | restore_irq_out:
91 | psw_restore_interrupt(&psw);
92 | }
93 |
94 | void common_trap_handler(exception_frame *exc)
95 | {
96 | uart_puts("\nException Handler! (");
97 | //handle_exception(exc);
98 |
99 | if ( ( exc->exc_type & 0xff ) == AARCH64_EXC_SYNC_SPX ) {
100 | uart_puts("AARCH64_EXC_SYNC_SPX)\n");
101 | handle_exception(exc);
102 | /*
103 | ti_update_preempt_count(ti, THR_EXCCNT_SHIFT, 1);
104 | psw_enable_interrupt();
105 | hal_handle_exception(exc);
106 | psw_disable_interrupt();
107 | ti_update_preempt_count(ti, THR_EXCCNT_SHIFT, -1);
108 | */
109 | }
110 |
111 | if ( ( exc->exc_type & 0xff ) == AARCH64_EXC_IRQ_SPX) {
112 | uart_puts("AARCH64_EXC_IRQ_SPX)\n");
113 | irq_handle(exc);
114 | }
115 | return;
116 | }
117 | #endif //RyanYao
118 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/gic_v3.c:
--------------------------------------------------------------------------------
1 | /* -*- mode: c; coding:utf-8 -*- */
2 | /**********************************************************************/
3 | /* OS kernel sample */
4 | /* Copyright 2014 Takeharu KATO */
5 | /* */
6 | /* Arm Generic Interrupt Controller(PL390) */
7 | /* */
8 | /**********************************************************************/
9 |
10 | /**********************************************************************/
11 | /* armv8-bare-metal */
12 | /* Copyright 2018 Nienfeng Yao */
13 | /* */
14 | /* Reference: ARM® Generic Interrupt Controller Architecture */
15 | /* Specification GIC architecture version 3.0 and version 4.0 */
16 | /* */
17 | /**********************************************************************/
18 | #include
19 | #include "board.h"
20 | #include "exception.h"
21 | #include "gic_v3.h"
22 | #include "uart.h"
23 |
24 |
25 | /* Initialize GIC Controller */
26 | static void init_gicc(void)
27 | {
28 | uint32_t pending_irq;
29 |
30 | /* Disable CPU interface */
31 | *REG_GIC_GICC_CTLR = GICC_CTLR_DISABLE;
32 |
33 | /* Set the priority level as the lowest priority */
34 | /* Note: Higher priority corresponds to a lower Priority field value in the GIC_PMR.
35 | * In addition to this, writing 255 to the GICC_PMR always sets it to the
36 | * largest supported priority field value.
37 | */
38 | *REG_GIC_GICC_PMR = GICC_PMR_PRIO_MIN;
39 |
40 | /* Handle all of interrupts in a single group */
41 | *REG_GIC_GICC_BPR = GICC_BPR_NO_GROUP;
42 |
43 | /* Clear all of the active interrupts */
44 | for(pending_irq = ( *REG_GIC_GICC_IAR & GICC_IAR_INTR_IDMASK );
45 | ( pending_irq != GICC_IAR_SPURIOUS_INTR );
46 | pending_irq = ( *REG_GIC_GICC_IAR & GICC_IAR_INTR_IDMASK ) )
47 | *REG_GIC_GICC_EOIR = *REG_GIC_GICC_IAR;
48 |
49 | /* Enable CPU interface */
50 | *REG_GIC_GICC_CTLR = GICC_CTLR_ENABLE;
51 | }
52 |
53 | static void init_gicd(void)
54 | {
55 | int32_t i, regs_nr;
56 |
57 | /* Diable distributor */
58 | *REG_GIC_GICD_CTLR = GIC_GICD_CTLR_DISABLE;
59 |
60 | /* Disable all IRQs */
61 | regs_nr = (GIC_INT_MAX + GIC_GICD_INT_PER_REG - 1) / GIC_GICD_INT_PER_REG;
62 | for (i = 0; regs_nr > i; ++i)
63 | *REG_GIC_GICD_ICENABLER(i) = ~((uint32_t)(0));
64 |
65 | /* Clear all pending IRQs */
66 | regs_nr = (GIC_INT_MAX + GIC_GICD_INT_PER_REG - 1) / GIC_GICD_INT_PER_REG;
67 | for (i = 0; regs_nr > i; ++i)
68 | *REG_GIC_GICD_ICPENDR(i) = ~((uint32_t)(0));
69 |
70 | /* Set all of interrupt priorities as the lowest priority */
71 | regs_nr = ( GIC_INT_MAX + GIC_GICD_IPRIORITY_PER_REG - 1) /
72 | GIC_GICD_IPRIORITY_PER_REG ;
73 | for (i = 0; regs_nr > i; i++)
74 | *REG_GIC_GICD_IPRIORITYR(i) = ~((uint32_t)(0));
75 |
76 | /* Set target of all of shared peripherals to processor 0 */
77 | for (i = GIC_INTNO_SPI0 / GIC_GICD_ITARGETSR_PER_REG;
78 | ( (GIC_INT_MAX + (GIC_GICD_ITARGETSR_PER_REG - 1) ) /
79 | GIC_GICD_ITARGETSR_PER_REG ) > i; ++i)
80 | *REG_GIC_GICD_ITARGETSR(i) =
81 | (uint32_t)GIC_GICD_ITARGETSR_CORE0_TARGET_BMAP;
82 |
83 | /* Set trigger type for all peripheral interrupts level triggered */
84 | for (i = GIC_INTNO_PPI0 / GIC_GICD_ICFGR_PER_REG;
85 | (GIC_INT_MAX + (GIC_GICD_ICFGR_PER_REG - 1)) / GIC_GICD_ICFGR_PER_REG > i; ++i)
86 | *REG_GIC_GICD_ICFGR(i) = GIC_GICD_ICFGR_LEVEL;
87 |
88 | /* Enable distributor */
89 | *REG_GIC_GICD_CTLR = GIC_GICD_CTLR_ENABLE;
90 | }
91 |
92 | /** Disable IRQ
93 | @param[in] irq IRQ number
94 | */
95 | void gicd_disable_int(irq_no irq) {
96 | *REG_GIC_GICD_ICENABLER( (irq / GIC_GICD_ICENABLER_PER_REG) ) =
97 | 1U << ( irq % GIC_GICD_ICENABLER_PER_REG );
98 | }
99 |
100 | /** Enable IRQ
101 | @param[in] irq IRQ number
102 | */
103 | void gicd_enable_int(irq_no irq) {
104 |
105 | *REG_GIC_GICD_ISENABLER( (irq / GIC_GICD_ISENABLER_PER_REG) ) =
106 | 1U << ( irq % GIC_GICD_ISENABLER_PER_REG );
107 |
108 | }
109 |
110 | /** Clear a pending interrupt
111 | @param[in] irq IRQ number
112 | */
113 | void gicd_clear_pending(irq_no irq) {
114 |
115 | *REG_GIC_GICD_ICPENDR( (irq / GIC_GICD_ICPENDR_PER_REG) ) =
116 | 1U << ( irq % GIC_GICD_ICPENDR_PER_REG );
117 | }
118 |
119 |
120 | /** Probe pending interrupt
121 | @param[in] irq IRQ number
122 | */
123 | static int gicd_probe_pending(irq_no irq) {
124 | int is_pending;
125 |
126 | is_pending = ( *REG_GIC_GICD_ISPENDR( (irq / GIC_GICD_ISPENDR_PER_REG) ) &
127 | ( 1U << ( irq % GIC_GICD_ISPENDR_PER_REG ) ) );
128 |
129 | return ( is_pending != 0 );
130 | }
131 |
132 | /** Set an interrupt target processor
133 | @param[in] irq IRQ number
134 | @param[in] p Target processor mask
135 | 0x1 processor 0
136 | 0x2 processor 1
137 | 0x4 processor 2
138 | 0x8 processor 3
139 | */
140 | static void gicd_set_target(irq_no irq, uint32_t p){
141 | uint32_t shift;
142 | uint32_t reg;
143 |
144 | shift = (irq % GIC_GICD_ITARGETSR_PER_REG) * GIC_GICD_ITARGETSR_SIZE_PER_REG;
145 |
146 | reg = *REG_GIC_GICD_ITARGETSR(irq / GIC_GICD_ITARGETSR_PER_REG);
147 | reg &= ~( ((uint32_t)(0xff)) << shift);
148 | reg |= (p << shift);
149 | *REG_GIC_GICD_ITARGETSR(irq / GIC_GICD_ITARGETSR_PER_REG) = reg;
150 | }
151 |
152 | /** Set an interrupt priority
153 | @param[in] irq IRQ number
154 | @param[in] prio Interrupt priority in Arm specific expression
155 | */
156 | static void gicd_set_priority(irq_no irq, uint32_t prio){
157 | uint32_t shift;
158 | uint32_t reg;
159 |
160 | shift = (irq % GIC_GICD_IPRIORITY_PER_REG) * GIC_GICD_IPRIORITY_SIZE_PER_REG;
161 | reg = *REG_GIC_GICD_IPRIORITYR(irq / GIC_GICD_IPRIORITY_PER_REG);
162 | reg &= ~(((uint32_t)(0xff)) << shift);
163 | reg |= (prio << shift);
164 | *REG_GIC_GICD_IPRIORITYR(irq / GIC_GICD_IPRIORITY_PER_REG) = reg;
165 | }
166 |
167 | /** Configure IRQ
168 | @param[in] irq IRQ number
169 | @param[in] config Configuration value for GICD_ICFGR
170 | */
171 | static void gicd_config(irq_no irq, unsigned int config)
172 | {
173 | uint32_t shift;
174 | uint32_t reg;
175 |
176 | shift = (irq % GIC_GICD_ICFGR_PER_REG) * GIC_GICD_ICFGR_SIZE_PER_REG; /* GICD_ICFGR has 16 fields, each field has 2bits. */
177 |
178 | reg = *REG_GIC_GICD_ICFGR( irq / GIC_GICD_ICFGR_PER_REG);
179 |
180 | reg &= ~( ( (uint32_t)(0x03) ) << shift ); /* Clear the field */
181 | reg |= ( ( (uint32_t)config ) << shift ); /* Set the value to the field correponding to irq */
182 | *REG_GIC_GICD_ICFGR( irq / GIC_GICD_ICFGR_PER_REG) = reg;
183 | }
184 |
185 | /** Send End of Interrupt to IRQ line for GIC
186 | @param[in] ctrlr IRQ controller information
187 | @param[in] irq IRQ number
188 | */
189 | void gic_v3_eoi(irq_no irq) {
190 | gicd_clear_pending(irq);
191 | }
192 |
193 | /* Initialize GIC IRQ controller */
194 | /* RyanYao: 2018/07/20
195 | * I supppose the current access is security, because GICD_CTLR.DS is 0b0 and
196 | * we can access.
197 | */
198 | void gic_v3_initialize(void)
199 | {
200 | init_gicd();
201 | init_gicc();
202 | gicd_config(TIMER_IRQ, GIC_GICD_ICFGR_EDGE);
203 | gicd_set_priority(TIMER_IRQ, 0 << GIC_PRI_SHIFT ); /* Set priority */
204 | gicd_set_target(TIMER_IRQ, 0x1); /* processor 0 */
205 | gicd_clear_pending(TIMER_IRQ);
206 | gicd_enable_int(TIMER_IRQ);
207 | }
208 |
209 |
210 | /** Find pending IRQ
211 | @param[in] exc An exception frame
212 | @param[in,out] irqp An IRQ number to be processed
213 | */
214 | int gic_v3_find_pending_irq(struct _exception_frame *exc __attribute__((unused)), irq_no *irqp) {
215 | int rc;
216 | irq_no i;
217 | for( i = 0; GIC_INT_MAX > i; ++i) {
218 | if ( gicd_probe_pending(i) ) {
219 |
220 | rc = IRQ_FOUND;
221 | *irqp = i;
222 | goto found;
223 | }
224 | }
225 |
226 | rc = IRQ_NOT_FOUND ;
227 | found:
228 | return rc;
229 | }
230 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef FREERTOS_CONFIG_H
29 | #define FREERTOS_CONFIG_H
30 |
31 | #include "board.h"
32 | #include "gic_v3.h"
33 |
34 | /*-----------------------------------------------------------
35 | * Application specific definitions.
36 | *
37 | * These definitions should be adjusted for your particular hardware and
38 | * application requirements.
39 | *
40 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
41 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
42 | *
43 | * See http://www.freertos.org/a00110.html.
44 | *----------------------------------------------------------*/
45 |
46 | /*
47 | * The FreeRTOS Cortex-A port implements a full interrupt nesting model.
48 | *
49 | * Interrupts that are assigned a priority at or below
50 | * configMAX_API_CALL_INTERRUPT_PRIORITY (which counter-intuitively in the ARM
51 | * generic interrupt controller [GIC] means a priority that has a numerical
52 | * value above configMAX_API_CALL_INTERRUPT_PRIORITY) can call FreeRTOS safe API
53 | * functions and will nest.
54 | *
55 | * Interrupts that are assigned a priority above
56 | * configMAX_API_CALL_INTERRUPT_PRIORITY (which in the GIC means a numerical
57 | * value below configMAX_API_CALL_INTERRUPT_PRIORITY) cannot call any FreeRTOS
58 | * API functions, will nest, and will not be masked by FreeRTOS critical
59 | * sections (although it is necessary for interrupts to be globally disabled
60 | * extremely briefly as the interrupt mask is updated in the GIC).
61 | *
62 | * FreeRTOS functions that can be called from an interrupt are those that end in
63 | * "FromISR". FreeRTOS maintains a separate interrupt safe API to enable
64 | * interrupt entry to be shorter, faster, simpler and smaller.
65 | *
66 | * For the purpose of setting configMAX_API_CALL_INTERRUPT_PRIORITY 255
67 | * represents the lowest priority.
68 | */
69 | #define configMAX_API_CALL_INTERRUPT_PRIORITY 18
70 |
71 | #define configCPU_CLOCK_HZ 100000000UL
72 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
73 | #define configUSE_TICKLESS_IDLE 0
74 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
75 | #define configPERIPHERAL_CLOCK_HZ ( 33333000UL )
76 | #define configUSE_PREEMPTION 1
77 | #if 1 //RyanYao
78 | #define configUSE_IDLE_HOOK 0
79 | #define configUSE_TICK_HOOK 0
80 | #else
81 | #define configUSE_IDLE_HOOK 1
82 | #define configUSE_TICK_HOOK 1
83 | #endif //RyanYao
84 | #define configMAX_PRIORITIES ( 8 )
85 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200 )
86 | #define configTOTAL_HEAP_SIZE ( 124 * 1024 )
87 | #define configMAX_TASK_NAME_LEN ( 10 )
88 | #define configUSE_16_BIT_TICKS 0
89 | #define configIDLE_SHOULD_YIELD 1
90 | #define configUSE_MUTEXES 1
91 | #define configQUEUE_REGISTRY_SIZE 8
92 | #if 0 //RyanYao
93 | #define configCHECK_FOR_STACK_OVERFLOW 2
94 | #endif //RyanYao
95 | #define configUSE_RECURSIVE_MUTEXES 1
96 | #if 0 //RyanYao
97 | #define configUSE_MALLOC_FAILED_HOOK 1
98 | #endif
99 | #define configUSE_APPLICATION_TASK_TAG 0
100 | #define configUSE_COUNTING_SEMAPHORES 1
101 | #define configUSE_QUEUE_SETS 1
102 |
103 | /* This demo creates RTOS objects using both static and dynamic allocation. */
104 | #if 1 //RyanYao
105 | #define configSUPPORT_STATIC_ALLOCATION 0
106 | #else
107 | #define configSUPPORT_STATIC_ALLOCATION 1
108 | #endif //RyanYao
109 | #define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Defaults to 1 anyway. */
110 |
111 | /* Co-routine definitions. */
112 | #define configUSE_CO_ROUTINES 0
113 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
114 |
115 | /* Software timer definitions. */
116 | #define configUSE_TIMERS 1
117 | #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
118 | #define configTIMER_QUEUE_LENGTH 5
119 | #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
120 |
121 | /* Set the following definitions to 1 to include the API function, or zero
122 | to exclude the API function. */
123 | #define INCLUDE_vTaskPrioritySet 1
124 | #define INCLUDE_uxTaskPriorityGet 1
125 | #define INCLUDE_vTaskDelete 1
126 | #define INCLUDE_vTaskCleanUpResources 1
127 | #define INCLUDE_vTaskSuspend 1
128 | #define INCLUDE_vTaskDelayUntil 1
129 | #define INCLUDE_vTaskDelay 1
130 | #define INCLUDE_xTimerPendFunctionCall 1
131 | #define INCLUDE_eTaskGetState 1
132 | #define INCLUDE_xTaskAbortDelay 1
133 | #if 0 //RyanYao
134 | #define INCLUDE_xTaskGetHandle 1
135 | #endif
136 |
137 | /* This demo makes use of one or more example stats formatting functions. These
138 | format the raw data provided by the uxTaskGetSystemState() function in to human
139 | readable ASCII form. See the notes in the implementation of vTaskList() within
140 | FreeRTOS/Source/tasks.c for limitations. */
141 | #define configUSE_STATS_FORMATTING_FUNCTIONS 0
142 |
143 | /* Run time stats are not generated. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS and
144 | portGET_RUN_TIME_COUNTER_VALUE must be defined if configGENERATE_RUN_TIME_STATS
145 | is set to 1. */
146 | #define configGENERATE_RUN_TIME_STATS 0
147 | #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
148 | #define portGET_RUN_TIME_COUNTER_VALUE()
149 |
150 | /* The size of the global output buffer that is available for use when there
151 | are multiple command interpreters running at once (for example, one on a UART
152 | and one on TCP/IP). This is done to prevent an output buffer being defined by
153 | each implementation - which would waste RAM. In this case, there is only one
154 | command interpreter running. */
155 | #define configCOMMAND_INT_MAX_OUTPUT_SIZE 2096
156 |
157 | /* Normal assert() semantics without relying on the provision of an assert.h
158 | header file. */
159 | void vMainAssertCalled( const char *pcFileName, uint32_t ulLineNumber );
160 | #define configASSERT( x ) if( ( x ) == 0 ) { vMainAssertCalled( __FILE__, __LINE__ ); }
161 |
162 | /* If configTASK_RETURN_ADDRESS is not defined then a task that attempts to
163 | return from its implementing function will end up in a "task exit error"
164 | function - which contains a call to configASSERT(). However this can give GCC
165 | some problems when it tries to unwind the stack, as the exit error function has
166 | nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */
167 | #define configTASK_RETURN_ADDRESS NULL
168 |
169 | /* Bump up the priority of recmuCONTROLLING_TASK_PRIORITY to prevent false
170 | positive errors being reported considering the priority of other tasks in the
171 | system. */
172 | #define recmuCONTROLLING_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
173 |
174 | /****** Hardware specific settings. *******************************************/
175 |
176 | /*
177 | * The application must provide a function that configures a peripheral to
178 | * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()
179 | * in FreeRTOSConfig.h to call the function. This file contains a function
180 | * that is suitable for use on the Zynq MPU. FreeRTOS_Tick_Handler() must
181 | * be installed as the peripheral's interrupt handler.
182 | */
183 | void vConfigureTickInterrupt( void );
184 | #define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt()
185 |
186 | void vClearTickInterrupt( void );
187 | #define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt()
188 |
189 | /* The following constant describe the hardware, and are correct for the
190 | QEMU-Virt. */
191 | #define configINTERRUPT_CONTROLLER_BASE_ADDRESS ( GIC_GICD_BASE )
192 | #define configUNIQUE_INTERRUPT_PRIORITIES 32
193 |
194 | #define fabs( x ) __builtin_fabs( x )
195 |
196 | #define configUSE_TRACE_FACILITY 0
197 |
198 | #endif /* FREERTOS_CONFIG_H */
199 |
200 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/board.h:
--------------------------------------------------------------------------------
1 | #if !defined(_BOARD_H)
2 | #define _BOARD_H
3 |
4 | /*
5 | * GIC on QEMU Virt
6 | */
7 | #define QEMU_VIRT_GIC_BASE (0x08000000)
8 | #define QEMU_VIRT_GIC_INT_MAX (64)
9 | #define QEMU_VIRT_GIC_PRIO_MAX (16)
10 | /* SGI: Interrupt IDs 0-15 */
11 | /* PPI: Interrupt IDs 16-31 */
12 | /* SPI: Interrupt IDs 32-63 */
13 | #define QEMU_VIRT_GIC_INTNO_SGIO (0)
14 | #define QEMU_VIRT_GIC_INTNO_PPIO (16)
15 | #define QEMU_VIRT_GIC_INTNO_SPIO (32)
16 |
17 | #define GIC_BASE (QEMU_VIRT_GIC_BASE)
18 | #define GIC_INT_MAX (QEMU_VIRT_GIC_INT_MAX)
19 | #define GIC_PRIO_MAX (QEMU_VIRT_GIC_PRIO_MAX)
20 | #define GIC_INTNO_SGI0 (QEMU_VIRT_GIC_INTNO_SGIO)
21 | #define GIC_INTNO_PPI0 (QEMU_VIRT_GIC_INTNO_PPIO)
22 | #define GIC_INTNO_SPI0 (QEMU_VIRT_GIC_INTNO_SPIO)
23 |
24 | #define GIC_PRI_SHIFT (4)
25 | #define GIC_PRI_MASK (0x0f)
26 |
27 | /* Timer */
28 | #define TIMER_IRQ (27) /** Timer IRQ */
29 |
30 | /* UART */
31 | #define QEMU_VIRT_UART_BASE (0x09000000)
32 |
33 |
34 | #endif /* _BOARD_H */
35 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/example.h:
--------------------------------------------------------------------------------
1 | #if !defined(_EXAMPLE_H)
2 | #define _EXAMPLE_H
3 |
4 | /* Queue Example */
5 | void test_queue(void);
6 | /* Mutex Example */
7 | void test_semaphore(void);
8 | /* Binary Semaphore Example */
9 | void test_binary_semaphore(void);
10 | /* Software Timer Example */
11 | void test_software_timer(void);
12 | #endif /* _EXAMPLE_H */
13 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/exception.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: asm; coding:utf-8 -*- */
2 | /************************************************************************/
3 | /* OS kernel sample */
4 | /* Copyright 2014 Takeharu KATO */
5 | /* */
6 | /************************************************************************/
7 |
8 | #if !defined(_EXCEPTION_H)
9 | #define _EXCEPTION_H
10 |
11 | /* Vector Table
12 | * see 5.1.1 Setting up a vector table in
13 | * Application Note Bare-metal Boot Code for ARMv8-A Processors Version 1.0
14 | */
15 |
16 | /*
17 | * AArch64 exception types
18 | */
19 | /* Current EL with SP0 */
20 | #define AARCH64_EXC_SYNC_SP0 (0x1) /* Synchronous */
21 | #define AARCH64_EXC_IRQ_SP0 (0x2) /* IRQ/vIRQ */
22 | #define AARCH64_EXC_FIQ_SP0 (0x3) /* FIQ/vFIQ */
23 | #define AARCH64_EXC_SERR_SP0 (0x4) /* SError/vSError */
24 | /* Current EL with SPx */
25 | #define AARCH64_EXC_SYNC_SPX (0x11)
26 | #define AARCH64_EXC_IRQ_SPX (0x12)
27 | #define AARCH64_EXC_FIQ_SPX (0x13)
28 | #define AARCH64_EXC_SERR_SPX (0x14)
29 | /* Lower EL using AArch64 */
30 | #define AARCH64_EXC_SYNC_AARCH64 (0x21)
31 | #define AARCH64_EXC_IRQ_AARCH64 (0x22)
32 | #define AARCH64_EXC_FIQ_AARCH64 (0x23)
33 | #define AARCH64_EXC_SERR_AARCH64 (0x24)
34 | /* Lower EL using AArch32 */
35 | #define AARCH64_EXC_SYNC_AARCH32 (0x31)
36 | #define AARCH64_EXC_IRQ_AARCH32 (0x32)
37 | #define AARCH64_EXC_FIQ_AARCH32 (0x33)
38 | #define AARCH64_EXC_SERR_AARCH32 (0x34)
39 |
40 | #if defined(ASM_FILE)
41 | #define vector_table_align .align 11 /* Vector tables must be placed at a 2KB-aligned address */
42 | #define vector_entry_align .align 7 /* Each entry is 128B in size*/
43 | #define text_align .align 2 /* Text alignment */
44 | #endif /* ASM_FILE */
45 |
46 |
47 | /*
48 | * exception_frame offset definitions
49 | */
50 | #define EXC_FRAME_SIZE (288) /* sizeof(struct _exception_frame) */
51 | #define EXC_EXC_TYPE_OFFSET (0) /* __asm_offsetof(struct _exception_frame, exc_type) */
52 | #define EXC_EXC_ESR_OFFSET (8) /* __asm_offsetof(struct _exception_frame, exc_esr) */
53 | #define EXC_EXC_SP_OFFSET (16) /* __asm_offsetof(struct _exception_frame, exc_sp) */
54 | #define EXC_EXC_ELR_OFFSET (24) /* __asm_offsetof(struct _exception_frame, exc_elr) */
55 | #define EXC_EXC_SPSR_OFFSET (32)/* __asm_offsetof(struct _exception_frame, exc_spsr) */
56 |
57 | /*
58 | * IRQ
59 | */
60 | #define IRQ_FOUND (0)
61 | #define IRQ_NOT_FOUND (1)
62 |
63 | #if !defined(ASM_FILE)
64 | #include
65 | typedef struct _exception_frame{
66 | uint64_t exc_type;
67 | uint64_t exc_esr;
68 | uint64_t exc_sp;
69 | uint64_t exc_elr;
70 | uint64_t exc_spsr;
71 | uint64_t x0;
72 | uint64_t x1;
73 | uint64_t x2;
74 | uint64_t x3;
75 | uint64_t x4;
76 | uint64_t x5;
77 | uint64_t x6;
78 | uint64_t x7;
79 | uint64_t x8;
80 | uint64_t x9;
81 | uint64_t x10;
82 | uint64_t x11;
83 | uint64_t x12;
84 | uint64_t x13;
85 | uint64_t x14;
86 | uint64_t x15;
87 | uint64_t x16;
88 | uint64_t x17;
89 | uint64_t x18;
90 | uint64_t x19;
91 | uint64_t x20;
92 | uint64_t x21;
93 | uint64_t x22;
94 | uint64_t x23;
95 | uint64_t x24;
96 | uint64_t x25;
97 | uint64_t x26;
98 | uint64_t x27;
99 | uint64_t x28;
100 | uint64_t x29;
101 | uint64_t x30;
102 | }exception_frame;
103 |
104 | void common_trap_handler(exception_frame *_exc);
105 | #endif /* !ASM_FILE */
106 | #endif /* _EXCEPTION_H */
107 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/gic_v3.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: c; coding:utf-8 -*- */
2 | /**********************************************************************/
3 | /* OS kernel sample */
4 | /* Copyright 2014 Takeharu KATO */
5 | /* */
6 | /* PrimeCell Generic Interrupt Controller (PL390) */
7 | /* */
8 | /**********************************************************************/
9 |
10 | /**********************************************************************/
11 | /* armv8-bare-metal */
12 | /* Copyright 2018 Nienfeng Yao */
13 | /* */
14 | /* Reference: ARM® Generic Interrupt Controller Architecture */
15 | /* Specification GIC architecture version 3.0 and version 4.0 */
16 | /* */
17 | /**********************************************************************/
18 | #if !defined(_GIC_V3_H)
19 | #define _GIC_V3_H
20 |
21 | #if !defined(_BOARD_H)
22 | #error "Include board.h before this header file."
23 | #endif /* !_BOARD_H */
24 |
25 | #include "exception.h"
26 |
27 | typedef int32_t irq_no; /* IRQ no */
28 |
29 | #define GIC_GICD_BASE (GIC_BASE) /* GICD MMIO base address */
30 | #define GIC_GICC_BASE (GIC_BASE + 0x10000) /* GICC MMIO base address */
31 |
32 | #define GIC_GICD_INT_PER_REG (32) /* 32 interrupts per reg */
33 | #define GIC_GICD_IPRIORITY_PER_REG (4) /* 4 priority per reg */
34 | #define GIC_GICD_IPRIORITY_SIZE_PER_REG (8) /* priority element size */
35 | #define GIC_GICD_ITARGETSR_CORE0_TARGET_BMAP (0x01010101) /* CPU interface 0 */
36 | #define GIC_GICD_ITARGETSR_PER_REG (4)
37 | #define GIC_GICD_ITARGETSR_SIZE_PER_REG (8)
38 | #define GIC_GICD_ICFGR_PER_REG (16)
39 | #define GIC_GICD_ICFGR_SIZE_PER_REG (2)
40 | #define GIC_GICD_ICENABLER_PER_REG (32)
41 | #define GIC_GICD_ISENABLER_PER_REG (32)
42 | #define GIC_GICD_ICPENDR_PER_REG (32)
43 | #define GIC_GICD_ISPENDR_PER_REG (32)
44 |
45 | /* 8.12 The GIC CPU interface register map */
46 | #define GIC_GICC_CTLR (GIC_GICC_BASE + 0x000) /* CPU Interface Control Register */
47 | #define GIC_GICC_PMR (GIC_GICC_BASE + 0x004) /* Interrupt Priority Mask Register */
48 | #define GIC_GICC_BPR (GIC_GICC_BASE + 0x008) /* Binary Point Register */
49 | #define GIC_GICC_IAR (GIC_GICC_BASE + 0x00C) /* Interrupt Acknowledge Register */
50 | #define GIC_GICC_EOIR (GIC_GICC_BASE + 0x010) /* End of Interrupt Register */
51 | #define GIC_GICC_RPR (GIC_GICC_BASE + 0x014) /* Running Priority Register */
52 | #define GIC_GICC_HPIR (GIC_GICC_BASE + 0x018) /* Highest Pending Interrupt Register */
53 | #define GIC_GICC_ABPR (GIC_GICC_BASE + 0x01C) /* Aliased Binary Point Register */
54 | #define GIC_GICC_IIDR (GIC_GICC_BASE + 0x0FC) /* CPU Interface Identification Register */
55 |
56 | /* 8.13.7 GICC_CTLR, CPU Interface Control Register */
57 | #define GICC_CTLR_ENABLE (0x1) /* Enable GICC */
58 | #define GICC_CTLR_DISABLE (0x0) /* Disable GICC */
59 |
60 | /* 8.13.14 GICC_PMR, CPU Interface Priority Mask Register */
61 | #define GICC_PMR_PRIO_MIN (0xff) /* The lowest level mask */
62 | #define GICC_PMR_PRIO_HIGH (0x0) /* The highest level mask */
63 |
64 | /* 8.13.6 GICC_BPR, CPU Interface Binary Point Register */
65 | /* In systems that support only one Security state, when GICC_CTLR.CBPR == 0,
66 | this register determines only Group 0 interrupt preemption. */
67 | #define GICC_BPR_NO_GROUP (0x0) /* handle all interrupts */
68 |
69 | /* 8.13.11 GICC_IAR, CPU Interface Interrupt Acknowledge Register */
70 | #define GICC_IAR_INTR_IDMASK (0x3ff) /* 0-9 bits means Interrupt ID */
71 | #define GICC_IAR_SPURIOUS_INTR (0x3ff) /* 1023 means spurious interrupt */
72 |
73 | /* 8.8 The GIC Distributor register map */
74 | #define GIC_GICD_CTLR (GIC_GICD_BASE + 0x000) /* Distributor Control Register */
75 | #define GIC_GICD_TYPER (GIC_GICD_BASE + 0x004) /* Interrupt Controller Type Register */
76 | #define GIC_GICD_IIDR (GIC_GICD_BASE + 0x008) /* Distributor Implementer Identification Register */
77 | #define GIC_GICD_IGROUPR(n) (GIC_GICD_BASE + 0x080 + ( (n) * 4 ) ) /* Interrupt Group Registers */
78 | #define GIC_GICD_ISENABLER(n) (GIC_GICD_BASE + 0x100 + ( (n) * 4 ) ) /* Interrupt Set-Enable Registers */
79 | #define GIC_GICD_ICENABLER(n) (GIC_GICD_BASE + 0x180 + ( (n) * 4 ) ) /* Interrupt Clear-Enable Registers */
80 | #define GIC_GICD_ISPENDR(n) (GIC_GICD_BASE + 0x200 + ( (n) * 4 ) ) /* Interrupt Set-Pending Registers */
81 | #define GIC_GICD_ICPENDR(n) (GIC_GICD_BASE + 0x280 + ( (n) * 4 ) ) /* Interrupt Clear-Pending Registers */
82 | #define GIC_GICD_ISACTIVER(n) (GIC_GICD_BASE + 0x300 + ( (n) * 4 ) ) /* Interrupt Set-Active Registers */
83 | #define GIC_GICD_ICACTIVER(n) (GIC_GICD_BASE + 0x380 + ( (n) * 4 ) ) /* Interrupt Clear-Active Registers */
84 | #define GIC_GICD_IPRIORITYR(n) (GIC_GICD_BASE + 0x400 + ( (n) * 4 ) ) /* Interrupt Priority Registers */
85 | #define GIC_GICD_ITARGETSR(n) (GIC_GICD_BASE + 0x800 + ( (n) * 4 ) ) /* Interrupt Processor Targets Registers */
86 | #define GIC_GICD_ICFGR(n) (GIC_GICD_BASE + 0xc00 + ( (n) * 4 ) ) /* Interrupt Configuration Registers */
87 | #define GIC_GICD_NSCAR(n) (GIC_GICD_BASE + 0xe00 + ( (n) * 4 ) ) /* Non-secure Access Control Registers */
88 | #define GIC_GICD_SGIR (GIC_GICD_BASE + 0xf00 ) /* Software Generated Interrupt Register */
89 | #define GIC_GICD_CPENDSGIR(n) (GIC_GICD_BASE + 0xf10 + ( (n) * 4 ) ) /* SGI Clear-Pending Registers */
90 | #define GIC_GICD_SPENDSGIR(n) (GIC_GICD_BASE + 0xf20 + ( (n) * 4 ) ) /* SGI Set-Pending Registers */
91 |
92 | /* 8.9.4 GICD_CTLR, Distributor Control Register */
93 | #define GIC_GICD_CTLR_ENABLE (0x1) /* Enable GICD */
94 | #define GIC_GICD_CTLR_DISABLE (0x0) /* Disable GICD */
95 |
96 | /* 8.9.7 GICD_ICFGR, Interrupt Configuration Registers */
97 | #define GIC_GICD_ICFGR_LEVEL (0x0) /* level-sensitive */
98 | #define GIC_GICD_ICFGR_EDGE (0x2) /* edge-triggered */
99 |
100 | /* Register access macros for GICC */
101 | #define REG_GIC_GICC_CTLR ((volatile uint32_t *)(uintptr_t)GIC_GICC_CTLR)
102 | #define REG_GIC_GICC_PMR ((volatile uint32_t *)(uintptr_t)GIC_GICC_PMR)
103 | #define REG_GIC_GICC_BPR ((volatile uint32_t *)(uintptr_t)GIC_GICC_BPR)
104 | #define REG_GIC_GICC_IAR ((volatile uint32_t *)(uintptr_t)GIC_GICC_IAR)
105 | #define REG_GIC_GICC_EOIR ((volatile uint32_t *)(uintptr_t)GIC_GICC_EOIR)
106 | #define REG_GIC_GICC_RPR ((volatile uint32_t *)(uintptr_t)GIC_GICC_RPR)
107 | #define REG_GIC_GICC_HPIR ((volatile uint32_t *)(uintptr_t)GIC_GICC_HPIR)
108 | #define REG_GIC_GICC_ABPR ((volatile uint32_t *)(uintptr_t)GIC_GICC_ABPR)
109 | #define REG_GIC_GICC_IIDR ((volatile uint32_t *)(uintptr_t)GIC_GICC_IIDR)
110 |
111 | /* Register access macros for GICD */
112 | #define REG_GIC_GICD_CTLR ((volatile uint32_t *)(uintptr_t)GIC_GICD_CTLR)
113 | #define REG_GIC_GICD_TYPE ((volatile uint32_t *)(uintptr_t)GIC_GICD_TYPE)
114 | #define REG_GIC_GICD_IIDR ((volatile uint32_t *)(uintptr_t)GIC_GICD_IIDR)
115 | #define REG_GIC_GICD_IGROUPR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_IGROUPR(n))
116 | #define REG_GIC_GICD_ISENABLER(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ISENABLER(n))
117 | #define REG_GIC_GICD_ICENABLER(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ICENABLER(n))
118 | #define REG_GIC_GICD_ISPENDR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ISPENDR(n))
119 | #define REG_GIC_GICD_ICPENDR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ICPENDR(n))
120 | #define REG_GIC_GICD_ISACTIVER(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ISACTIVER(n))
121 | #define REG_GIC_GICD_ICACTIVER(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ICACTIVER(n))
122 | #define REG_GIC_GICD_IPRIORITYR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_IPRIORITYR(n))
123 | #define REG_GIC_GICD_ITARGETSR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ITARGETSR(n))
124 | #define REG_GIC_GICD_ICFGR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_ICFGR(n))
125 | #define REG_GIC_GICD_NSCAR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_NSCAR(n))
126 | #define REG_GIC_GICD_SGIR ((volatile uint32_t *)(uintptr_t)GIC_GICD_SGIR)
127 | #define REG_GIC_GICD_CPENDSGIR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_CPENDSGIR(n))
128 | #define REG_GIC_GICD_SPENDSGIR(n) ((volatile uint32_t *)(uintptr_t)GIC_GICD_SPENDSGIR(n))
129 |
130 | void gic_v3_initialize(void);
131 | void gic_v3_eoi(irq_no irq);
132 | int gic_v3_find_pending_irq(struct _exception_frame *exc __attribute__((unused)), irq_no *irqp);
133 | void gicd_disable_int(irq_no irq);
134 | void gicd_enable_int(irq_no irq);
135 | void gicd_clear_pending(irq_no irq);
136 | #endif /* _GIC_V3_H */
137 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/include/uart.h:
--------------------------------------------------------------------------------
1 | #if !defined(_UART_H)
2 | #define _UART_H
3 | #include
4 | #include "board.h"
5 |
6 | #define UARTDR (QEMU_VIRT_UART_BASE)
7 | #define UARTFR (QEMU_VIRT_UART_BASE + 0x018)
8 |
9 | #define TEST_PRINTF 1 /* for test_printf(void); */
10 |
11 | void uart_putc(const char c);
12 | void uart_puthex(uint64_t n);
13 | void uart_puts(const char *s);
14 | int printf(const char *format, ...);
15 | int sprintf(char *out, const char *format, ...);
16 | #ifdef TEST_PRINTF
17 | int test_printf(void);
18 | #endif
19 |
20 | #endif /* _UART_H */
21 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/linker.ld:
--------------------------------------------------------------------------------
1 | ENTRY(_boot)
2 |
3 | STACKTOP = 0x41000000;
4 |
5 | SECTIONS
6 | {
7 | /* Starts at LOADER_ADDR. */
8 | . = 0x40000000;
9 | __start = .;
10 | __text_start = .;
11 | .text :
12 | {
13 | KEEP(*(.vectors))
14 | KEEP(*(.text.boot))
15 | *(.text)
16 | }
17 | . = ALIGN(4096); /* align to page size */
18 | __text_end = .;
19 |
20 | __data_start = .;
21 | .data :
22 | {
23 | *(.data)
24 | }
25 | . = ALIGN(4096); /* align to page size */
26 | __data_end = .;
27 |
28 | __bss_start = .;
29 | .bss :
30 | {
31 | bss = .;
32 | *(.bss)
33 | }
34 | . = ALIGN(4096); /* align to page size */
35 | __bss_end = .;
36 | __end = .;
37 |
38 | . = STACKTOP ; /* stack memory */
39 | stack_top = .;
40 | }
41 | __bss_size = (__bss_end - __bss_start)>>3;
42 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/main.c:
--------------------------------------------------------------------------------
1 | /* Standard includes. */
2 | #include
3 |
4 | /* Scheduler include files. */
5 | #include "FreeRTOS.h"
6 | #include "task.h"
7 |
8 | /* board include files. */
9 | #include "board.h"
10 | #include "gic_v3.h"
11 |
12 | /* driver includes. */
13 | #include "uart.h"
14 |
15 | #include "example.h"
16 |
17 | /* Configure the hardware as necessary */
18 | static void prvSetupHardware( void );
19 |
20 | static void prvSetupHardware( void )
21 | {
22 | /* Ensure no interrupts execute while the scheduler is in an inconsistent
23 | state. Interrupts are automatically enabled when the scheduler is
24 | started. */
25 | portDISABLE_INTERRUPTS();
26 |
27 | /* Initialize the GIC, including config of partial timer irq */
28 | gic_v3_initialize();
29 | }
30 |
31 | void vMainAssertCalled( const char *pcFileName, uint32_t ulLineNumber )
32 | {
33 | //xil_printf( "ASSERT! Line %lu of file %s\r\n", ulLineNumber, pcFileName );
34 | uart_puts("ASSERT! Line ");
35 | uart_puthex(ulLineNumber);
36 | uart_puts(" of file ");
37 | uart_puts( pcFileName );
38 | uart_puts("\n" );
39 | taskENTER_CRITICAL();
40 | for( ;; );
41 | }
42 |
43 | void hello_world_task(void *p)
44 | {
45 | int i=0;
46 |
47 | (void)p;
48 | while(2) {
49 | printf("%s() %d.\n", __func__, i++);
50 | vTaskDelay(1000);
51 | }
52 | }
53 |
54 | int main(void)
55 | {
56 | /* Configure the hardware ready to run */
57 | prvSetupHardware();
58 |
59 | uart_puts("Hello World main()!\n");
60 | //configASSERT(0);
61 |
62 | /* printf() test, have to enable TEST_PRINTF in uart.h */
63 | //test_printf();
64 |
65 | #if 1 /* Example Test */
66 | //test_queue();
67 | //test_semaphore();
68 | //test_binary_semaphore();
69 | test_software_timer();
70 | #else
71 | /* Create Tasks */
72 | xTaskCreate(hello_world_task, "hello_task", 2048, 0, 1, 0);
73 | #endif
74 |
75 | /* Start the scheduler */
76 | vTaskStartScheduler();
77 |
78 | /* Should not reach here. */
79 | for( ;; );
80 |
81 | return -1;
82 | }
83 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/nostdlib.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013, 2017, Jernej Kovacic
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
5 | * this software and associated documentation files (the "Software"), to deal in
6 | * the Software without restriction, including without limitation the rights to
7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 | * the Software, and to permit persons to whom the Software is furnished to do so,
9 | * subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software. If you wish to use our Amazon
13 | * FreeRTOS name, please do so in a fair use way that does not cause confusion.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | */
22 |
23 |
24 | /**
25 | * @file
26 | * A collection of stdlib "clones", required by FreeRTOS.
27 | *
28 | * If the standard C library is going to be linked to the application,
29 | * do not link this file!
30 | *
31 | * @author Jernej Kovacic
32 | */
33 |
34 | #include
35 |
36 | /* A convenience macro that defines the upper limit of 'size_t' */
37 | #define SIZE_T_MAX ( (size_t) (-1) )
38 |
39 |
40 | /*
41 | * @param x - first value
42 | * @param y - second value
43 | *
44 | * @return smaller of both input values
45 | */
46 | static inline size_t minval(size_t x, size_t y)
47 | {
48 | return ( x<=y ? x : y );
49 | }
50 |
51 |
52 | /**
53 | * Fill block of memory.
54 | *
55 | * Sets the first 'num' bytes of the block of memory pointed by 'ptr' to the
56 | * specified 'value' (interpreted as an unsigned char).
57 | *
58 | * @param ptr - pointer to the block of memory to fill
59 | * @param value - value to be set, passed as an int and converted to unsigned char
60 | * @param num - number of bytes to be set to the 'value'.
61 | *
62 | * @return 'ptr' is returned
63 | */
64 | void* memset(void* ptr, int value, size_t num )
65 | {
66 | unsigned char* p = (unsigned char*) ptr;
67 | size_t n = num;
68 |
69 | /* sanity check */
70 | if ( NULL==p )
71 | {
72 | goto endf;
73 | }
74 |
75 | /*
76 | * If destination block exceeds the range of 'size_t',
77 | * decrease 'num' accordingly.
78 | */
79 | if ( num > (size_t) ((unsigned char*) SIZE_T_MAX - p) )
80 | {
81 | n = (unsigned char*) SIZE_T_MAX - p;
82 | /* TODO or maybe just goto endf???? */
83 | }
84 |
85 | /* Set 'value' to each byte of the block: */
86 | while (n--)
87 | {
88 | *(p++) = (unsigned char) value;
89 | }
90 |
91 | endf:
92 | return ptr;
93 | }
94 |
95 |
96 | /**
97 | * Copy block of memory.
98 | *
99 | * Copies the values of 'num' bytes from the location pointed by 'source'
100 | * directly to the memory block pointed by 'destination'.
101 | *
102 | * The underlying type of the objects pointed by both the 'source' and
103 | * 'destination' pointers are irrelevant for this function; The result is
104 | * a binary copy of the data.
105 | *
106 | * The function does not check for any terminating null character in 'source' -
107 | * it always copies exactly 'num' bytes.
108 | *
109 | * If any block exceeds range of 'size_t', 'num' is decreased accordingly.
110 | *
111 | * The function copies the source block correctly even if both blocks overlap.
112 | *
113 | * @param destination - pointer to the destination array where the content is to be copied
114 | * @param source - pointer to the source of data to be copied
115 | * @param num - number of bytes to copy
116 | *
117 | * @return 'destination' is returned or NULL if any parameter equals NULL
118 | */
119 | void* memcpy(void* destination, const void* source, size_t num )
120 | {
121 | unsigned char* srcptr = (unsigned char*) source;
122 | unsigned char* destptr = (unsigned char*) destination;
123 | size_t n = num;
124 |
125 | /* sanity check */
126 | if ( NULL==srcptr || NULL==destptr )
127 | {
128 | return NULL;
129 | }
130 |
131 | /* Nothing to do if attempting to copy to itself: */
132 | if ( srcptr == destptr )
133 | {
134 | return destination;
135 | }
136 |
137 | /*
138 | * If any block exceeds the range of 'size_t',
139 | * decrease 'num' accordingly.
140 | */
141 | if ( num > (size_t) ((unsigned char*) SIZE_T_MAX-destptr) ||
142 | num > (size_t) ((unsigned char*) SIZE_T_MAX-srcptr) )
143 | {
144 | n = minval((unsigned char*) SIZE_T_MAX-destptr,
145 | (unsigned char*) SIZE_T_MAX-srcptr);
146 | /* TODO or maybe just return destination? */
147 | }
148 |
149 | if ( destptr=(srcptr+n) )
150 | {
151 | /*
152 | * If blocks do not overlap or or backwards copy is requested,
153 | * it is safe to copy the source block from begin to end.
154 | */
155 | while (n--)
156 | {
157 | *destptr++ = *srcptr++;
158 | }
159 | }
160 | else
161 | {
162 | /*
163 | * If forward copy is requested and blocks overlap, forward copy
164 | * (from block's begin to end) would cause a corruption.
165 | * Hence backward copy (from end to begin) is performed.
166 | */
167 | srcptr += n - 1;
168 | destptr += n - 1;
169 |
170 | while (n--)
171 | {
172 | *destptr-- = *srcptr--;
173 | }
174 | }
175 |
176 | return destination;
177 | }
178 |
179 | /**
180 | * Copy string.
181 | *
182 | * Copies the C string pointed by 'source' into the array pointed by
183 | * 'destination', including the terminating null character (and stopping
184 | * at that point).
185 | *
186 | * To avoid overflows, the size of the array pointed by destination shall be
187 | * long enough to contain the same C string as source (including the
188 | * terminating null character), and should not overlap in memory with source.
189 | *
190 | * @param destination - pointer to the destination array where the content is to be copied
191 | * @param source - C string to be copied
192 | *
193 | * @return 'destination' is returned or NULL if any parameter equals NULL
194 | */
195 | char* strcpy (char* destination, const char* source)
196 | {
197 | const char* srcptr = source;
198 | char* destptr = destination;
199 |
200 | /* sanity check */
201 | if ( NULL==destptr || NULL==srcptr )
202 | {
203 | return NULL;
204 | }
205 |
206 | while ( '\0' != *srcptr )
207 | {
208 | *destptr++ = *srcptr++;
209 | }
210 |
211 | /* Do not forget to append a '\0' at the end of destination! */
212 | *destptr = '\0';
213 |
214 | return destination;
215 | }
216 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/printf-stdarg.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2001, 2002 Georges Menie (www.menie.org)
3 | stdarg version contributed by Christian Ettinger
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation; either version 2 of the License, or
7 | (at your option) any later version.
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU Lesser General Public License for more details.
12 | You should have received a copy of the GNU Lesser General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 | */
16 |
17 | /*
18 | putchar is the only external dependency for this file,
19 | if you have a working putchar, leave it commented out.
20 | If not, uncomment the define below and
21 | replace outbyte(c) by your own function call.
22 | #define putchar(c) outbyte(c)
23 | */
24 | #include
25 | #include "uart.h"
26 |
27 |
28 | #define putchar(c) uart_putc(c)
29 | #define PAD_RIGHT 1
30 | #define PAD_ZERO 2
31 |
32 |
33 | static void printchar(char **str, int c)
34 | {
35 | if (str) {
36 | **str = c;
37 | ++(*str);
38 | }
39 | else (void)putchar((const char) c);
40 | }
41 |
42 | static int prints(char **out, const char *string, int width, int pad)
43 | {
44 | register int pc = 0, padchar = ' ';
45 |
46 | if (width > 0) {
47 | register int len = 0;
48 | register const char *ptr;
49 | for (ptr = string; *ptr; ++ptr) ++len;
50 | if (len >= width) width = 0;
51 | else width -= len;
52 | if (pad & PAD_ZERO) padchar = '0';
53 | }
54 | if (!(pad & PAD_RIGHT)) {
55 | for ( ; width > 0; --width) {
56 | printchar (out, padchar);
57 | ++pc;
58 | }
59 | }
60 | for ( ; *string ; ++string) {
61 | printchar (out, *string);
62 | ++pc;
63 | }
64 | for ( ; width > 0; --width) {
65 | printchar (out, padchar);
66 | ++pc;
67 | }
68 |
69 | return pc;
70 | }
71 |
72 | /* the following should be enough for 32 bit int */
73 | #define PRINT_BUF_LEN 12
74 |
75 | static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
76 | {
77 | char print_buf[PRINT_BUF_LEN];
78 | register char *s;
79 | register int t, neg = 0, pc = 0;
80 | register unsigned int u = i;
81 |
82 | if (i == 0) {
83 | print_buf[0] = '0';
84 | print_buf[1] = '\0';
85 | return prints (out, print_buf, width, pad);
86 | }
87 |
88 | if (sg && b == 10 && i < 0) {
89 | neg = 1;
90 | u = -i;
91 | }
92 |
93 | s = print_buf + PRINT_BUF_LEN-1;
94 | *s = '\0';
95 |
96 | while (u) {
97 | t = u % b;
98 | if( t >= 10 )
99 | t += letbase - '0' - 10;
100 | *--s = t + '0';
101 | u /= b;
102 | }
103 |
104 | if (neg) {
105 | if( width && (pad & PAD_ZERO) ) {
106 | printchar (out, '-');
107 | ++pc;
108 | --width;
109 | }
110 | else {
111 | *--s = '-';
112 | }
113 | }
114 |
115 | return pc + prints (out, s, width, pad);
116 | }
117 |
118 | static int print( char **out, const char *format, va_list args )
119 | {
120 | register int width, pad;
121 | register int pc = 0;
122 | char scr[2];
123 |
124 | for (; *format != 0; ++format) {
125 | if (*format == '%') {
126 | ++format;
127 | width = pad = 0;
128 | if (*format == '\0') break;
129 | if (*format == '%') goto out;
130 | if (*format == '-') {
131 | ++format;
132 | pad = PAD_RIGHT;
133 | }
134 | while (*format == '0') {
135 | ++format;
136 | pad |= PAD_ZERO;
137 | }
138 | for ( ; *format >= '0' && *format <= '9'; ++format) {
139 | width *= 10;
140 | width += *format - '0';
141 | }
142 | if( *format == 's' ) {
143 | //register char *s = (char *)va_arg( args, int );
144 | register char *s = (char *)va_arg( args, char *);
145 | pc += prints (out, s?s:"(null)", width, pad);
146 | continue;
147 | }
148 | if( *format == 'd' ) {
149 | pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
150 | continue;
151 | }
152 | if( *format == 'x' ) {
153 | pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
154 | continue;
155 | }
156 | if( *format == 'X' ) {
157 | pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
158 | continue;
159 | }
160 | if( *format == 'u' ) {
161 | pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
162 | continue;
163 | }
164 | if( *format == 'c' ) {
165 | /* char are converted to int then pushed on the stack */
166 | scr[0] = (char)va_arg( args, int );
167 | scr[1] = '\0';
168 | pc += prints (out, scr, width, pad);
169 | continue;
170 | }
171 | }else{
172 | out:
173 | printchar (out, *format);
174 | ++pc;
175 | }
176 | }
177 | if (out) **out = '\0';
178 | va_end( args );
179 | return pc;
180 | }
181 |
182 | int printf(const char *format, ...)
183 | {
184 | va_list args;
185 |
186 | va_start( args, format );
187 | return print( 0, format, args );
188 | }
189 |
190 | int sprintf(char *out, const char *format, ...)
191 | {
192 | va_list args;
193 |
194 | va_start( args, format );
195 | return print( &out, format, args );
196 | }
197 |
198 |
199 | int snprintf( char *buf, unsigned int count, const char *format, ... )
200 | {
201 | va_list args;
202 |
203 | ( void ) count;
204 |
205 | va_start( args, format );
206 | return print( &buf, format, args );
207 | }
208 |
209 |
210 | #ifdef TEST_PRINTF
211 | int test_printf(void)
212 | {
213 | char *ptr = "Hello world!";
214 | char *np = 0;
215 | int i = 5;
216 | unsigned int bs = sizeof(int)*8;
217 | int mi;
218 | char buf[80];
219 |
220 | mi = (1 << (bs-1)) + 1;
221 | printf("%s\n", ptr);
222 | printf("printf test\n");
223 | printf("%s is null pointer\n", np);
224 | printf("%d = 5\n", i);
225 | printf("%d = - max int\n", mi);
226 | printf("char %c = 'a'\n", 'a');
227 | printf("hex %x = ff\n", 0xff);
228 | printf("hex %02x = 00\n", 0);
229 | printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
230 | printf("%d %s(s)%", 0, "message");
231 | printf("\n");
232 | printf("%d %s(s) with %%\n", 0, "message");
233 | sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
234 | sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
235 | sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
236 | sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
237 | sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
238 | sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
239 | sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
240 | sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
241 |
242 | return 0;
243 | }
244 |
245 | /*
246 | * if you compile this file with
247 | * gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
248 | * you will get a normal warning:
249 | * printf.c:214: warning: spurious trailing `%' in format
250 | * this line is testing an invalid % at the end of the format string.
251 | *
252 | * this should display (on 32bit int machine) :
253 | *
254 | * Hello world!
255 | * printf test
256 | * (null) is null pointer
257 | * 5 = 5
258 | * -2147483647 = - max int
259 | * char a = 'a'
260 | * hex ff = ff
261 | * hex 00 = 00
262 | * signed -3 = unsigned 4294967293 = hex fffffffd
263 | * 0 message(s)
264 | * 0 message(s) with %
265 | * justif: "left "
266 | * justif: " right"
267 | * 3: 0003 zero padded
268 | * 3: 3 left justif.
269 | * 3: 3 right justif.
270 | * -3: -003 zero padded
271 | * -3: -3 left justif.
272 | * -3: -3 right justif.
273 | */
274 |
275 | #endif
276 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/pstate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the coreboot project.
3 | *
4 | * Copyright (C) 2014 Google Inc
5 | *
6 | * This program is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU General Public License as
8 | * published by the Free Software Foundation; version 2 of
9 | * the License.
10 | *
11 | * This program 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, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 | * MA 02110-1301 USA
20 | *
21 | * Reference: ARM Architecture Reference Manual, ARMv8-A edition
22 | * pstate.c: This file defines all the library functions for accessing
23 | * PSTATE and special purpose registers
24 | */
25 |
26 | #include
27 | #include "cpu.h"
28 |
29 | /* CurrentEL */
30 | uint32_t raw_read_current_el(void)
31 | {
32 | uint32_t current_el;
33 |
34 | __asm__ __volatile__("mrs %0, CurrentEL\n\t" : "=r" (current_el) : : "memory");
35 |
36 | return current_el;
37 | }
38 |
39 | uint32_t get_current_el(void)
40 | {
41 | uint32_t current_el = raw_read_current_el();
42 | return ((current_el >> CURRENT_EL_SHIFT) & CURRENT_EL_MASK);
43 | }
44 |
45 | /* DAIF */
46 | uint32_t raw_read_daif(void)
47 | {
48 | uint32_t daif;
49 |
50 | __asm__ __volatile__("mrs %0, DAIF\n\t" : "=r" (daif) : : "memory");
51 |
52 | return daif;
53 | }
54 |
55 | void raw_write_daif(uint32_t daif)
56 | {
57 | __asm__ __volatile__("msr DAIF, %0\n\t" : : "r" (daif) : "memory");
58 | }
59 |
60 | void enable_debug_exceptions(void)
61 | {
62 | __asm__ __volatile__("msr DAIFClr, %0\n\t" : : "i" (DAIF_DBG_BIT) : "memory");
63 | }
64 |
65 | void enable_serror_exceptions(void)
66 | {
67 | __asm__ __volatile__("msr DAIFClr, %0\n\t" : : "i" (DAIF_ABT_BIT) : "memory");
68 | }
69 |
70 | void enable_irq(void)
71 | {
72 | __asm__ __volatile__("msr DAIFClr, %0\n\t" : : "i" (DAIF_IRQ_BIT) : "memory");
73 | }
74 |
75 | void enable_fiq(void)
76 | {
77 | __asm__ __volatile__("msr DAIFClr, %0\n\t" : : "i" (DAIF_FIQ_BIT) : "memory");
78 | }
79 |
80 | void disable_debug_exceptions(void)
81 | {
82 | __asm__ __volatile__("msr DAIFSet, %0\n\t" : : "i" (DAIF_DBG_BIT) : "memory");
83 | }
84 |
85 | void disable_serror_exceptions(void)
86 | {
87 | __asm__ __volatile__("msr DAIFSet, %0\n\t" : : "i" (DAIF_ABT_BIT) : "memory");
88 | }
89 |
90 | void disable_irq(void)
91 | {
92 | __asm__ __volatile__("msr DAIFSet, %0\n\t" : : "i" (DAIF_IRQ_BIT) : "memory");
93 | }
94 |
95 | void disable_fiq(void)
96 | {
97 | __asm__ __volatile__("msr DAIFSet, %0\n\t" : : "i" (DAIF_FIQ_BIT) : "memory");
98 | }
99 |
100 | /* DLR_EL0 */
101 | uint64_t raw_read_dlr_el0(void)
102 | {
103 | uint64_t dlr_el0;
104 |
105 | __asm__ __volatile__("mrs %0, DLR_EL0\n\t" : "=r" (dlr_el0) : : "memory");
106 |
107 | return dlr_el0;
108 | }
109 | void raw_write_dlr_el0(uint64_t dlr_el0)
110 | {
111 | __asm__ __volatile__("msr DLR_EL0, %0\n\t" : : "r" (dlr_el0) : "memory");
112 | }
113 |
114 | /* DSPSR_EL0 */
115 | uint64_t raw_read_dspsr_el0(void)
116 | {
117 | uint64_t dspsr_el0;
118 |
119 | __asm__ __volatile__("mrs %0, DSPSR_EL0\n\t" : "=r" (dspsr_el0) : : "memory");
120 |
121 | return dspsr_el0;
122 | }
123 | void raw_write_dspsr_el0(uint64_t dspsr_el0)
124 | {
125 | __asm__ __volatile__("msr DSPSR_EL0, %0\n\t" : : "r" (dspsr_el0) : "memory");
126 | }
127 |
128 | /* ELR */
129 | uint64_t raw_read_elr_el1(void)
130 | {
131 | uint64_t elr_el1;
132 |
133 | __asm__ __volatile__("mrs %0, ELR_EL1\n\t" : "=r" (elr_el1) : : "memory");
134 |
135 | return elr_el1;
136 | }
137 |
138 | void raw_write_elr_el1(uint64_t elr_el1)
139 | {
140 | __asm__ __volatile__("msr ELR_EL1, %0\n\t" : : "r" (elr_el1) : "memory");
141 | }
142 |
143 | uint64_t raw_read_elr_el2(void)
144 | {
145 | uint64_t elr_el2;
146 |
147 | __asm__ __volatile__("mrs %0, ELR_EL2\n\t" : "=r" (elr_el2) : : "memory");
148 |
149 | return elr_el2;
150 | }
151 |
152 | void raw_write_elr_el2(uint64_t elr_el2)
153 | {
154 | __asm__ __volatile__("msr ELR_EL2, %0\n\t" : : "r" (elr_el2) : "memory");
155 | }
156 |
157 | uint64_t raw_read_elr_el3(void)
158 | {
159 | uint64_t elr_el3;
160 |
161 | __asm__ __volatile__("mrs %0, ELR_EL3\n\t" : "=r" (elr_el3) : : "memory");
162 |
163 | return elr_el3;
164 | }
165 |
166 | void raw_write_elr_el3(uint64_t elr_el3)
167 | {
168 | __asm__ __volatile__("msr ELR_EL3, %0\n\t" : : "r" (elr_el3) : "memory");
169 | }
170 |
171 | uint64_t raw_read_elr_current(void)
172 | {
173 | uint32_t el = get_current_el();
174 | return raw_read_elr(el);
175 | }
176 |
177 | void raw_write_elr_current(uint64_t elr)
178 | {
179 | uint32_t el = get_current_el();
180 | raw_write_elr(elr, el);
181 | }
182 |
183 | uint64_t raw_read_elr(uint32_t el)
184 | {
185 | SWITCH_CASE_READ(raw_read_elr, elr, uint64_t, el);
186 | }
187 |
188 | void raw_write_elr(uint64_t elr, uint32_t el)
189 | {
190 | SWITCH_CASE_WRITE(raw_write_elr, elr, el);
191 | }
192 |
193 | /* FPCR */
194 | uint32_t raw_read_fpcr(void)
195 | {
196 | uint32_t fpcr;
197 |
198 | __asm__ __volatile__("mrs %0, FPCR\n\t" : "=r" (fpcr) : : "memory");
199 |
200 | return fpcr;
201 | }
202 |
203 | void raw_write_fpcr(uint32_t fpcr)
204 | {
205 | __asm__ __volatile__("msr FPCR, %0\n\t" : : "r" (fpcr) : "memory");
206 | }
207 |
208 | /* FPSR */
209 | uint32_t raw_read_fpsr(void)
210 | {
211 | uint32_t fpsr;
212 |
213 | __asm__ __volatile__("mrs %0, FPSR\n\t" : "=r" (fpsr) : : "memory");
214 |
215 | return fpsr;
216 | }
217 |
218 | void raw_write_fpsr(uint32_t fpsr)
219 | {
220 | __asm__ __volatile__("msr FPSR, %0\n\t" : : "r" (fpsr) : "memory");
221 | }
222 |
223 | /* NZCV */
224 | uint32_t raw_read_nzcv(void)
225 | {
226 | uint32_t nzcv;
227 |
228 | __asm__ __volatile__("mrs %0, NZCV\n\t" : "=r" (nzcv) : : "memory");
229 |
230 | return nzcv;
231 | }
232 |
233 | void raw_write_nzcv(uint32_t nzcv)
234 | {
235 | __asm__ __volatile__("msr NZCV, %0\n\t" : : "r" (nzcv) : "memory");
236 | }
237 |
238 | /* SP */
239 | uint64_t raw_read_sp_el0(void)
240 | {
241 | uint64_t sp_el0;
242 |
243 | __asm__ __volatile__("mrs %0, SP_EL0\n\t" : "=r" (sp_el0) : : "memory");
244 |
245 | return sp_el0;
246 | }
247 |
248 | void raw_write_sp_el0(uint64_t sp_el0)
249 | {
250 | __asm__ __volatile__("msr SP_EL0, %0\n\t" : : "r" (sp_el0) : "memory");
251 | }
252 |
253 | uint64_t raw_read_sp_el1(void)
254 | {
255 | uint64_t sp_el1;
256 |
257 | __asm__ __volatile__("mrs %0, SP_EL1\n\t" : "=r" (sp_el1) : : "memory");
258 |
259 | return sp_el1;
260 | }
261 |
262 | void raw_write_sp_el1(uint64_t sp_el1)
263 | {
264 | __asm__ __volatile__("msr SP_EL1, %0\n\t" : : "r" (sp_el1) : "memory");
265 | }
266 |
267 | uint64_t raw_read_sp_el2(void)
268 | {
269 | uint64_t sp_el2;
270 |
271 | __asm__ __volatile__("mrs %0, SP_EL2\n\t" : "=r" (sp_el2) : : "memory");
272 |
273 | return sp_el2;
274 | }
275 |
276 | void raw_write_sp_el2(uint64_t sp_el2)
277 | {
278 | __asm__ __volatile__("msr SP_EL2, %0\n\t" : : "r" (sp_el2) : "memory");
279 | }
280 |
281 | /* SPSel */
282 | uint32_t raw_read_spsel(void)
283 | {
284 | uint32_t spsel;
285 |
286 | __asm__ __volatile__("mrs %0, SPSel\n\t" : "=r" (spsel) : : "memory");
287 |
288 | return spsel;
289 | }
290 |
291 | void raw_write_spsel(uint32_t spsel)
292 | {
293 | __asm__ __volatile__("msr SPSel, %0\n\t" : : "r" (spsel) : "memory");
294 | }
295 |
296 | uint64_t raw_read_sp_el3(void)
297 | {
298 | uint64_t sp_el3;
299 | uint32_t spsel;
300 |
301 | spsel = raw_read_spsel();
302 | if (!spsel)
303 | raw_write_spsel(1);
304 |
305 | __asm__ __volatile__("mov %0, sp\n\t" : "=r" (sp_el3) : : "memory");
306 |
307 | if (!spsel)
308 | raw_write_spsel(spsel);
309 |
310 | return sp_el3;
311 | }
312 |
313 | void raw_write_sp_el3(uint64_t sp_el3)
314 | {
315 | uint32_t spsel;
316 |
317 | spsel = raw_read_spsel();
318 | if (!spsel)
319 | raw_write_spsel(1);
320 |
321 | __asm__ __volatile__("mov sp, %0\n\t" : "=r" (sp_el3) : : "memory");
322 |
323 | if (!spsel)
324 | raw_write_spsel(spsel);
325 | }
326 |
327 | uint64_t raw_read_sp_elx(uint32_t el)
328 | {
329 | SWITCH_CASE_READ(raw_read_sp, sp, uint64_t, el);
330 | }
331 |
332 | void raw_write_sp_elx(uint64_t sp_elx, uint32_t el)
333 | {
334 | SWITCH_CASE_WRITE(raw_write_sp, sp_elx, el);
335 | }
336 |
337 | /* SPSR */
338 | uint32_t raw_read_spsr_abt(void)
339 | {
340 | uint32_t spsr_abt;
341 |
342 | __asm__ __volatile__("mrs %0, SPSR_abt\n\t" : "=r" (spsr_abt) : : "memory");
343 |
344 | return spsr_abt;
345 | }
346 |
347 | void raw_write_spsr_abt(uint32_t spsr_abt)
348 | {
349 | __asm__ __volatile__("msr SPSR_abt, %0\n\t" : : "r" (spsr_abt) : "memory");
350 | }
351 |
352 | uint32_t raw_read_spsr_el1(void)
353 | {
354 | uint32_t spsr_el1;
355 |
356 | __asm__ __volatile__("mrs %0, SPSR_EL1\n\t" : "=r" (spsr_el1) : : "memory");
357 |
358 | return spsr_el1;
359 | }
360 |
361 | void raw_write_spsr_el1(uint32_t spsr_el1)
362 | {
363 | __asm__ __volatile__("msr SPSR_EL1, %0\n\t" : : "r" (spsr_el1) : "memory");
364 | }
365 |
366 | uint32_t raw_read_spsr_el2(void)
367 | {
368 | uint32_t spsr_el2;
369 |
370 | __asm__ __volatile__("mrs %0, SPSR_EL2\n\t" : "=r" (spsr_el2) : : "memory");
371 |
372 | return spsr_el2;
373 | }
374 |
375 | void raw_write_spsr_el2(uint32_t spsr_el2)
376 | {
377 | __asm__ __volatile__("msr SPSR_EL2, %0\n\t" : : "r" (spsr_el2) : "memory");
378 | }
379 |
380 | uint32_t raw_read_spsr_el3(void)
381 | {
382 | uint32_t spsr_el3;
383 |
384 | __asm__ __volatile__("mrs %0, SPSR_EL3\n\t" : "=r" (spsr_el3) : : "memory");
385 |
386 | return spsr_el3;
387 | }
388 |
389 | void raw_write_spsr_el3(uint32_t spsr_el3)
390 | {
391 | __asm__ __volatile__("msr SPSR_EL3, %0\n\t" : : "r" (spsr_el3) : "memory");
392 | }
393 |
394 | uint32_t raw_read_spsr_current(void)
395 | {
396 | uint32_t el = get_current_el();
397 | return raw_read_spsr(el);
398 | }
399 |
400 | void raw_write_spsr_current(uint32_t spsr)
401 | {
402 | uint32_t el = get_current_el();
403 | raw_write_spsr(spsr, el);
404 | }
405 |
406 | uint32_t raw_read_spsr(uint32_t el)
407 | {
408 | SWITCH_CASE_READ(raw_read_spsr, spsr, uint32_t, el);
409 | }
410 |
411 | void raw_write_spsr(uint32_t spsr, uint32_t el)
412 | {
413 | SWITCH_CASE_WRITE(raw_write_spsr, spsr, el);
414 | }
415 |
416 | uint32_t raw_read_spsr_fiq(void)
417 | {
418 | uint32_t spsr_fiq;
419 |
420 | __asm__ __volatile__("mrs %0, SPSR_fiq\n\t" : "=r" (spsr_fiq) : : "memory");
421 |
422 | return spsr_fiq;
423 | }
424 |
425 | void raw_write_spsr_fiq(uint32_t spsr_fiq)
426 | {
427 | __asm__ __volatile__("msr SPSR_fiq, %0\n\t" : : "r" (spsr_fiq) : "memory");
428 | }
429 |
430 | uint32_t raw_read_spsr_irq(void)
431 | {
432 | uint32_t spsr_irq;
433 |
434 | __asm__ __volatile__("mrs %0, SPSR_irq\n\t" : "=r" (spsr_irq) : : "memory");
435 |
436 | return spsr_irq;
437 | }
438 |
439 | void raw_write_spsr_irq(uint32_t spsr_irq)
440 | {
441 | __asm__ __volatile__("msr SPSR_irq, %0\n\t" : : "r" (spsr_irq) : "memory");
442 | }
443 |
444 | uint32_t raw_read_spsr_und(void)
445 | {
446 | uint32_t spsr_und;
447 |
448 | __asm__ __volatile__("mrs %0, SPSR_und\n\t" : "=r" (spsr_und) : : "memory");
449 |
450 | return spsr_und;
451 | }
452 |
453 | void raw_write_spsr_und(uint32_t spsr_und)
454 | {
455 | __asm__ __volatile__("msr SPSR_und, %0\n\t" : : "r" (spsr_und) : "memory");
456 | }
457 |
458 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/start.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Branch according to exception level
3 | */
4 | .macro switch_el, xreg, el3_label, el2_label, el1_label
5 | mrs \xreg, CurrentEL
6 | cmp \xreg, 0xc
7 | b.eq \el3_label
8 | cmp \xreg, 0x8
9 | b.eq \el2_label
10 | cmp \xreg, 0x4
11 | b.eq \el1_label
12 | .endm
13 |
14 | .globl _boot
15 | _boot:
16 | /*
17 | * Could be EL3/EL2/EL1, Initial State:
18 | * Little Endian, MMU Disabled, i/dCache Disabled
19 | */
20 | adr x0, _vector_table
21 | switch_el x1, 3f, 2f, 1f
22 | 3: msr vbar_el3, x0
23 | mrs x0, scr_el3
24 | orr x0, x0, #0xf /* SCR_EL3.NS|IRQ|FIQ|EA */
25 | msr scr_el3, x0
26 | msr cptr_el3, xzr /* Enable FP/SIMD */
27 | b 0f
28 | 2: msr vbar_el2, x0
29 | mov x0, #0x33ff
30 | msr cptr_el2, x0 /* Enable FP/SIMD */
31 | b 0f
32 | 1: msr vbar_el1, x0
33 | mov x0, #3 << 20
34 | msr cpacr_el1, x0 /* Enable FP/SIMD */
35 | 0:
36 | /* check CPU ID = 0x0, or jump to hang */
37 | mrs x0, mpidr_el1
38 | and x0, x0, #3
39 | cmp x0, #0
40 | bne hang
41 |
42 | master_cpu:
43 | /* configure stack */
44 | adrp x0, stack_top // Address of 4KB page at a PC-relative offset
45 | magic_label: // Why do we need this label to let GDB step continually?
46 | mov sp, x0 // sp = stack_top (align with 4KB page)
47 | /* clear bss. */
48 | ldr x1, =__bss_start /* A 64-bit general-purpose register named X0 to X30 */
49 | ldr w2, =__bss_size /* A 32-bit general-purpose register named W0 to W30 */
50 | 1: cbz w2, 2f /* Compare and Branch on Zero */
51 | str xzr, [x1], #8
52 | sub w2, w2, #1
53 | cbnz w2, 1b
54 |
55 | 2: bl main
56 |
57 | hang:
58 | wfi
59 | b hang
60 |
61 |
62 |
63 |
64 |
65 |
66 | # =========================================
67 | .align 3
68 |
69 | #if 0 //RyanYao
70 | .globl _TEXT_BASE
71 | _TEXT_BASE:
72 | .quad CONFIG_SYS_TEXT_BASE
73 |
74 | /*
75 | * These are defined in the linker script.
76 | */
77 | .globl _end_ofs
78 | _end_ofs:
79 | .quad _end - _start
80 |
81 | .globl _bss_start_ofs
82 | _bss_start_ofs:
83 | .quad __bss_start - _start
84 |
85 | .globl _bss_end_ofs
86 | _bss_end_ofs:
87 | .quad __bss_end - _start
88 | #endif //RyanYao
89 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/uart.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "FreeRTOSConfig.h"
3 | #include "uart.h"
4 |
5 | volatile unsigned int * const UART0DR = (unsigned int *) UARTDR;
6 | volatile unsigned int * const UART0FR = (unsigned int *) UARTFR;
7 |
8 |
9 | void uart_putc(const char c)
10 | {
11 | // Wait for UART to become ready to transmit.
12 | while ((*UART0FR) & (1 << 5)) { }
13 | *UART0DR = c; /* Transmit char */
14 | }
15 |
16 | void uart_puthex(uint64_t n)
17 | {
18 | const char *hexdigits = "0123456789ABCDEF";
19 |
20 | uart_putc('0');
21 | uart_putc('x');
22 | for (int i = 60; i >= 0; i -= 4){
23 | uart_putc(hexdigits[(n >> i) & 0xf]);
24 | if (i == 32)
25 | uart_putc(' ');
26 | }
27 | }
28 |
29 | void uart_puts(const char *s) {
30 | for (int i = 0; s[i] != '\0'; i ++)
31 | uart_putc((unsigned char)s[i]);
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/FreeRTOS/Demo/CORTEX_A57_64-bit/vectors.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | *
3 | * Copyright (C) 2009 - 2016 Xilinx, Inc. All rights reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * Use of the Software is limited solely to applications:
16 | * (a) running on a Xilinx device, or
17 | * (b) that interact with a Xilinx device through a bus or interconnect.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 | * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | *
27 | * Except as contained in this notice, the name of the Xilinx shall not be used
28 | * in advertising or otherwise to promote the sale, use or other dealings in
29 | * this Software without prior written authorization from Xilinx.
30 | *
31 | ******************************************************************************/
32 | /*****************************************************************************/
33 | /**
34 | * @file vectors.c
35 | *
36 | * This file contains the C level vectors for the ARM Cortex A9 core.
37 | *
38 | *
39 | * MODIFICATION HISTORY:
40 | *
41 | * Ver Who Date Changes
42 | * ----- ---- -------- ---------------------------------------------------
43 | * 1.00a ecm 10/20/09 Initial version, moved over from bsp area
44 | * 6.0 mus 27/07/16 Consolidated vectors for a53,a9 and r5 processor
45 | * and added UndefinedException for a53 32 bit and r5
46 | * processor
47 | *
48 | *
49 | * @note
50 | *
51 | * None.
52 | *
53 | ******************************************************************************/
54 | /***************************** Include Files *********************************/
55 |
56 | #if 0 //RyanYao
57 | #include "xil_exception.h"
58 | #include "vectors.h"
59 |
60 | /************************** Constant Definitions *****************************/
61 |
62 | /**************************** Type Definitions *******************************/
63 |
64 | typedef struct {
65 | Xil_ExceptionHandler Handler;
66 | void *Data;
67 | } XExc_VectorTableEntry;
68 |
69 | /***************** Macros (Inline Functions) Definitions *********************/
70 |
71 | /************************** Variable Definitions *****************************/
72 |
73 | extern XExc_VectorTableEntry XExc_VectorTable[];
74 | #endif //RyanYao
75 |
76 | /************************** Function Prototypes ******************************/
77 |
78 |
79 | /*****************************************************************************/
80 | /**
81 | *
82 | * This is the C level wrapper for the FIQ interrupt called from the vectors.s
83 | * file.
84 | *
85 | * @param None.
86 | *
87 | * @return None.
88 | *
89 | * @note None.
90 | *
91 | ******************************************************************************/
92 | void FIQInterrupt(void)
93 | {
94 | #if 0 //RyanYao
95 | XExc_VectorTable[XIL_EXCEPTION_ID_FIQ_INT].Handler(XExc_VectorTable[
96 | XIL_EXCEPTION_ID_FIQ_INT].Data);
97 | #endif
98 | }
99 |
100 | /*****************************************************************************/
101 | /**
102 | *
103 | * This is the C level wrapper for the IRQ interrupt called from the vectors.s
104 | * file.
105 | *
106 | * @param None.
107 | *
108 | * @return None.
109 | *
110 | * @note None.
111 | *
112 | ******************************************************************************/
113 | void IRQInterrupt(void)
114 | {
115 | #if 0 //RyanYao
116 | XExc_VectorTable[XIL_EXCEPTION_ID_IRQ_INT].Handler(XExc_VectorTable[
117 | XIL_EXCEPTION_ID_IRQ_INT].Data);
118 | #endif
119 | }
120 |
121 | #if !defined (__aarch64__)
122 | /*****************************************************************************/
123 | /**
124 | *
125 | * This is the C level wrapper for the Undefined exception called from the
126 | * vectors.s file.
127 | *
128 | * @param None.
129 | *
130 | * @return None.
131 | *
132 | * @note None.
133 | *
134 | ******************************************************************************/
135 | void UndefinedException(void)
136 | {
137 | XExc_VectorTable[XIL_EXCEPTION_ID_UNDEFINED_INT].Handler(XExc_VectorTable[
138 | XIL_EXCEPTION_ID_UNDEFINED_INT].Data);
139 | }
140 |
141 | /*****************************************************************************/
142 | /**
143 | *
144 | * This is the C level wrapper for the SW Interrupt called from the vectors.s
145 | * file.
146 | *
147 | * @param None.
148 | *
149 | * @return None.
150 | *
151 | * @note None.
152 | *
153 | ******************************************************************************/
154 | void SWInterrupt(void)
155 | {
156 | XExc_VectorTable[XIL_EXCEPTION_ID_SWI_INT].Handler(XExc_VectorTable[
157 | XIL_EXCEPTION_ID_SWI_INT].Data);
158 | }
159 |
160 | /*****************************************************************************/
161 | /**
162 | *
163 | * This is the C level wrapper for the DataAbort Interrupt called from the
164 | * vectors.s file.
165 | *
166 | * @param None.
167 | *
168 | * @return None.
169 | *
170 | * @note None.
171 | *
172 | ******************************************************************************/
173 | void DataAbortInterrupt(void)
174 | {
175 | XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Handler(
176 | XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Data);
177 | }
178 |
179 | /*****************************************************************************/
180 | /**
181 | *
182 | * This is the C level wrapper for the PrefetchAbort Interrupt called from the
183 | * vectors.s file.
184 | *
185 | * @param None.
186 | *
187 | * @return None.
188 | *
189 | * @note None.
190 | *
191 | ******************************************************************************/
192 | void PrefetchAbortInterrupt(void)
193 | {
194 | XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Handler(
195 | XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Data);
196 | }
197 | #else
198 |
199 | /*****************************************************************************/
200 | /**
201 | *
202 | * This is the C level wrapper for the Synchronous Interrupt called from the vectors.s
203 | * file.
204 | *
205 | * @param None.
206 | *
207 | * @return None.
208 | *
209 | * @note None.
210 | *
211 | ******************************************************************************/
212 | void SynchronousInterrupt(void)
213 | {
214 | #if 0 //RyanYao
215 | XExc_VectorTable[XIL_EXCEPTION_ID_SYNC_INT].Handler(XExc_VectorTable[
216 | XIL_EXCEPTION_ID_SYNC_INT].Data);
217 | #endif
218 | }
219 |
220 | /*****************************************************************************/
221 | /**
222 | *
223 | * This is the C level wrapper for the SError Interrupt called from the
224 | * vectors.s file.
225 | *
226 | * @param None.
227 | *
228 | * @return None.
229 | *
230 | * @note None.
231 | *
232 | ******************************************************************************/
233 | void SErrorInterrupt(void)
234 | {
235 | #if 0 //RyanYao
236 | XExc_VectorTable[XIL_EXCEPTION_ID_SERROR_ABORT_INT].Handler(
237 | XExc_VectorTable[XIL_EXCEPTION_ID_SERROR_ABORT_INT].Data);
238 | #endif
239 | }
240 |
241 | #endif
242 |
--------------------------------------------------------------------------------
/FreeRTOS/License/license.txt:
--------------------------------------------------------------------------------
1 | The FreeRTOS kernel is released under the MIT open source license, the text of
2 | which is provided below.
3 |
4 | This license covers the FreeRTOS kernel source files, which are located in the
5 | /FreeRTOS/Source directory of the official FreeRTOS kernel download. It also
6 | covers most of the source files in the demo application projects, which are
7 | located in the /FreeRTOS/Demo directory of the official FreeRTOS download. The
8 | demo projects may also include third party software that is not part of FreeRTOS
9 | and is licensed separately to FreeRTOS. Examples of third party software
10 | includes header files provided by chip or tools vendors, linker scripts,
11 | peripheral drivers, etc. All the software in subdirectories of the /FreeRTOS
12 | directory is either open source or distributed with permission, and is free for
13 | use. For the avoidance of doubt, refer to the comments at the top of each
14 | source file.
15 |
16 |
17 | License text:
18 | -------------
19 |
20 | Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
21 | Permission is hereby granted, free of charge, to any person obtaining a copy of
22 | this software and associated documentation files (the "Software"), to deal in
23 | the Software without restriction, including without limitation the rights to
24 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
25 | the Software, and to permit persons to whom the Software is furnished to do so,
26 | subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in all
29 | copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
33 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
34 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
35 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 |
38 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/StackMacros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef STACK_MACROS_H
29 | #define STACK_MACROS_H
30 |
31 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */
32 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released.
33 | #endif
34 |
35 | /*
36 | * Call the stack overflow hook function if the stack of the task being swapped
37 | * out is currently overflowed, or looks like it might have overflowed in the
38 | * past.
39 | *
40 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check
41 | * the current stack state only - comparing the current top of stack value to
42 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1
43 | * will also cause the last few stack bytes to be checked to ensure the value
44 | * to which the bytes were set when the task was created have not been
45 | * overwritten. Note this second test does not guarantee that an overflowed
46 | * stack will always be recognised.
47 | */
48 |
49 | /*-----------------------------------------------------------*/
50 |
51 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) )
52 |
53 | /* Only the current stack state is to be checked. */
54 | #define taskCHECK_FOR_STACK_OVERFLOW() \
55 | { \
56 | /* Is the currently saved stack pointer within the stack limit? */ \
57 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \
58 | { \
59 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
60 | } \
61 | }
62 |
63 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
64 | /*-----------------------------------------------------------*/
65 |
66 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) )
67 |
68 | /* Only the current stack state is to be checked. */
69 | #define taskCHECK_FOR_STACK_OVERFLOW() \
70 | { \
71 | \
72 | /* Is the currently saved stack pointer within the stack limit? */ \
73 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \
74 | { \
75 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
76 | } \
77 | }
78 |
79 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
80 | /*-----------------------------------------------------------*/
81 |
82 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
83 |
84 | #define taskCHECK_FOR_STACK_OVERFLOW() \
85 | { \
86 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
87 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
88 | \
89 | if( ( pulStack[ 0 ] != ulCheckValue ) || \
90 | ( pulStack[ 1 ] != ulCheckValue ) || \
91 | ( pulStack[ 2 ] != ulCheckValue ) || \
92 | ( pulStack[ 3 ] != ulCheckValue ) ) \
93 | { \
94 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
95 | } \
96 | }
97 |
98 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
99 | /*-----------------------------------------------------------*/
100 |
101 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
102 |
103 | #define taskCHECK_FOR_STACK_OVERFLOW() \
104 | { \
105 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
106 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
107 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
108 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
109 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
110 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
111 | \
112 | \
113 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
114 | \
115 | /* Has the extremity of the task stack ever been written over? */ \
116 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
117 | { \
118 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
119 | } \
120 | }
121 |
122 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
123 | /*-----------------------------------------------------------*/
124 |
125 | /* Remove stack overflow macro if not being used. */
126 | #ifndef taskCHECK_FOR_STACK_OVERFLOW
127 | #define taskCHECK_FOR_STACK_OVERFLOW()
128 | #endif
129 |
130 |
131 |
132 | #endif /* STACK_MACROS_H */
133 |
134 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/deprecated_definitions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef DEPRECATED_DEFINITIONS_H
29 | #define DEPRECATED_DEFINITIONS_H
30 |
31 |
32 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
33 | pre-processor definition was used to ensure the pre-processor found the correct
34 | portmacro.h file for the port being used. That scheme was deprecated in favour
35 | of setting the compiler's include path such that it found the correct
36 | portmacro.h file - removing the need for the constant and allowing the
37 | portmacro.h file to be located anywhere in relation to the port being used. The
38 | definitions below remain in the code for backward compatibility only. New
39 | projects should not use them. */
40 |
41 | #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
42 | #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"
43 | typedef void ( __interrupt __far *pxISR )();
44 | #endif
45 |
46 | #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT
47 | #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"
48 | typedef void ( __interrupt __far *pxISR )();
49 | #endif
50 |
51 | #ifdef GCC_MEGA_AVR
52 | #include "../portable/GCC/ATMega323/portmacro.h"
53 | #endif
54 |
55 | #ifdef IAR_MEGA_AVR
56 | #include "../portable/IAR/ATMega323/portmacro.h"
57 | #endif
58 |
59 | #ifdef MPLAB_PIC24_PORT
60 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
61 | #endif
62 |
63 | #ifdef MPLAB_DSPIC_PORT
64 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
65 | #endif
66 |
67 | #ifdef MPLAB_PIC18F_PORT
68 | #include "../../Source/portable/MPLAB/PIC18F/portmacro.h"
69 | #endif
70 |
71 | #ifdef MPLAB_PIC32MX_PORT
72 | #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h"
73 | #endif
74 |
75 | #ifdef _FEDPICC
76 | #include "libFreeRTOS/Include/portmacro.h"
77 | #endif
78 |
79 | #ifdef SDCC_CYGNAL
80 | #include "../../Source/portable/SDCC/Cygnal/portmacro.h"
81 | #endif
82 |
83 | #ifdef GCC_ARM7
84 | #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h"
85 | #endif
86 |
87 | #ifdef GCC_ARM7_ECLIPSE
88 | #include "portmacro.h"
89 | #endif
90 |
91 | #ifdef ROWLEY_LPC23xx
92 | #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h"
93 | #endif
94 |
95 | #ifdef IAR_MSP430
96 | #include "..\..\Source\portable\IAR\MSP430\portmacro.h"
97 | #endif
98 |
99 | #ifdef GCC_MSP430
100 | #include "../../Source/portable/GCC/MSP430F449/portmacro.h"
101 | #endif
102 |
103 | #ifdef ROWLEY_MSP430
104 | #include "../../Source/portable/Rowley/MSP430F449/portmacro.h"
105 | #endif
106 |
107 | #ifdef ARM7_LPC21xx_KEIL_RVDS
108 | #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h"
109 | #endif
110 |
111 | #ifdef SAM7_GCC
112 | #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h"
113 | #endif
114 |
115 | #ifdef SAM7_IAR
116 | #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h"
117 | #endif
118 |
119 | #ifdef SAM9XE_IAR
120 | #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h"
121 | #endif
122 |
123 | #ifdef LPC2000_IAR
124 | #include "..\..\Source\portable\IAR\LPC2000\portmacro.h"
125 | #endif
126 |
127 | #ifdef STR71X_IAR
128 | #include "..\..\Source\portable\IAR\STR71x\portmacro.h"
129 | #endif
130 |
131 | #ifdef STR75X_IAR
132 | #include "..\..\Source\portable\IAR\STR75x\portmacro.h"
133 | #endif
134 |
135 | #ifdef STR75X_GCC
136 | #include "..\..\Source\portable\GCC\STR75x\portmacro.h"
137 | #endif
138 |
139 | #ifdef STR91X_IAR
140 | #include "..\..\Source\portable\IAR\STR91x\portmacro.h"
141 | #endif
142 |
143 | #ifdef GCC_H8S
144 | #include "../../Source/portable/GCC/H8S2329/portmacro.h"
145 | #endif
146 |
147 | #ifdef GCC_AT91FR40008
148 | #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h"
149 | #endif
150 |
151 | #ifdef RVDS_ARMCM3_LM3S102
152 | #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h"
153 | #endif
154 |
155 | #ifdef GCC_ARMCM3_LM3S102
156 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
157 | #endif
158 |
159 | #ifdef GCC_ARMCM3
160 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
161 | #endif
162 |
163 | #ifdef IAR_ARM_CM3
164 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
165 | #endif
166 |
167 | #ifdef IAR_ARMCM3_LM
168 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
169 | #endif
170 |
171 | #ifdef HCS12_CODE_WARRIOR
172 | #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h"
173 | #endif
174 |
175 | #ifdef MICROBLAZE_GCC
176 | #include "../../Source/portable/GCC/MicroBlaze/portmacro.h"
177 | #endif
178 |
179 | #ifdef TERN_EE
180 | #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h"
181 | #endif
182 |
183 | #ifdef GCC_HCS12
184 | #include "../../Source/portable/GCC/HCS12/portmacro.h"
185 | #endif
186 |
187 | #ifdef GCC_MCF5235
188 | #include "../../Source/portable/GCC/MCF5235/portmacro.h"
189 | #endif
190 |
191 | #ifdef COLDFIRE_V2_GCC
192 | #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h"
193 | #endif
194 |
195 | #ifdef COLDFIRE_V2_CODEWARRIOR
196 | #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h"
197 | #endif
198 |
199 | #ifdef GCC_PPC405
200 | #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h"
201 | #endif
202 |
203 | #ifdef GCC_PPC440
204 | #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h"
205 | #endif
206 |
207 | #ifdef _16FX_SOFTUNE
208 | #include "..\..\Source\portable\Softune\MB96340\portmacro.h"
209 | #endif
210 |
211 | #ifdef BCC_INDUSTRIAL_PC_PORT
212 | /* A short file name has to be used in place of the normal
213 | FreeRTOSConfig.h when using the Borland compiler. */
214 | #include "frconfig.h"
215 | #include "..\portable\BCC\16BitDOS\PC\prtmacro.h"
216 | typedef void ( __interrupt __far *pxISR )();
217 | #endif
218 |
219 | #ifdef BCC_FLASH_LITE_186_PORT
220 | /* A short file name has to be used in place of the normal
221 | FreeRTOSConfig.h when using the Borland compiler. */
222 | #include "frconfig.h"
223 | #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"
224 | typedef void ( __interrupt __far *pxISR )();
225 | #endif
226 |
227 | #ifdef __GNUC__
228 | #ifdef __AVR32_AVR32A__
229 | #include "portmacro.h"
230 | #endif
231 | #endif
232 |
233 | #ifdef __ICCAVR32__
234 | #ifdef __CORE__
235 | #if __CORE__ == __AVR32A__
236 | #include "portmacro.h"
237 | #endif
238 | #endif
239 | #endif
240 |
241 | #ifdef __91467D
242 | #include "portmacro.h"
243 | #endif
244 |
245 | #ifdef __96340
246 | #include "portmacro.h"
247 | #endif
248 |
249 |
250 | #ifdef __IAR_V850ES_Fx3__
251 | #include "../../Source/portable/IAR/V850ES/portmacro.h"
252 | #endif
253 |
254 | #ifdef __IAR_V850ES_Jx3__
255 | #include "../../Source/portable/IAR/V850ES/portmacro.h"
256 | #endif
257 |
258 | #ifdef __IAR_V850ES_Jx3_L__
259 | #include "../../Source/portable/IAR/V850ES/portmacro.h"
260 | #endif
261 |
262 | #ifdef __IAR_V850ES_Jx2__
263 | #include "../../Source/portable/IAR/V850ES/portmacro.h"
264 | #endif
265 |
266 | #ifdef __IAR_V850ES_Hx2__
267 | #include "../../Source/portable/IAR/V850ES/portmacro.h"
268 | #endif
269 |
270 | #ifdef __IAR_78K0R_Kx3__
271 | #include "../../Source/portable/IAR/78K0R/portmacro.h"
272 | #endif
273 |
274 | #ifdef __IAR_78K0R_Kx3L__
275 | #include "../../Source/portable/IAR/78K0R/portmacro.h"
276 | #endif
277 |
278 | #endif /* DEPRECATED_DEFINITIONS_H */
279 |
280 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/mpu_prototypes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | /*
29 | * When the MPU is used the standard (non MPU) API functions are mapped to
30 | * equivalents that start "MPU_", the prototypes for which are defined in this
31 | * header files. This will cause the application code to call the MPU_ version
32 | * which wraps the non-MPU version with privilege promoting then demoting code,
33 | * so the kernel code always runs will full privileges.
34 | */
35 |
36 |
37 | #ifndef MPU_PROTOTYPES_H
38 | #define MPU_PROTOTYPES_H
39 |
40 | /* MPU versions of tasks.h API functions. */
41 | BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask );
42 | TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer );
43 | BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask );
44 | BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask );
45 | void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
46 | void MPU_vTaskDelete( TaskHandle_t xTaskToDelete );
47 | void MPU_vTaskDelay( const TickType_t xTicksToDelay );
48 | void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement );
49 | BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask );
50 | UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t xTask );
51 | eTaskState MPU_eTaskGetState( TaskHandle_t xTask );
52 | void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
53 | void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
54 | void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend );
55 | void MPU_vTaskResume( TaskHandle_t xTaskToResume );
56 | void MPU_vTaskStartScheduler( void );
57 | void MPU_vTaskSuspendAll( void );
58 | BaseType_t MPU_xTaskResumeAll( void );
59 | TickType_t MPU_xTaskGetTickCount( void );
60 | UBaseType_t MPU_uxTaskGetNumberOfTasks( void );
61 | char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery );
62 | TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery );
63 | UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
64 | void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
65 | TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask );
66 | void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue );
67 | void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex );
68 | BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
69 | TaskHandle_t MPU_xTaskGetIdleTaskHandle( void );
70 | UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime );
71 | void MPU_vTaskList( char * pcWriteBuffer );
72 | void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer );
73 | BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue );
74 | BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
75 | uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
76 | BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask );
77 | BaseType_t MPU_xTaskIncrementTick( void );
78 | TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void );
79 | void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
80 | BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
81 | void MPU_vTaskMissedYield( void );
82 | BaseType_t MPU_xTaskGetSchedulerState( void );
83 |
84 | /* MPU versions of queue.h API functions. */
85 | BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition );
86 | BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait );
87 | BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait );
88 | BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait );
89 | UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue );
90 | UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue );
91 | void MPU_vQueueDelete( QueueHandle_t xQueue );
92 | QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType );
93 | QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue );
94 | QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount );
95 | QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue );
96 | void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore );
97 | BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait );
98 | BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex );
99 | void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName );
100 | void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue );
101 | const char * MPU_pcQueueGetName( QueueHandle_t xQueue );
102 | QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType );
103 | QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType );
104 | QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength );
105 | BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet );
106 | BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet );
107 | QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait );
108 | BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue );
109 | void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber );
110 | UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue );
111 | uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue );
112 |
113 | /* MPU versions of timers.h API functions. */
114 | TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction );
115 | TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer );
116 | void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer );
117 | void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
118 | BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer );
119 | TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void );
120 | BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait );
121 | const char * MPU_pcTimerGetName( TimerHandle_t xTimer );
122 | TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer );
123 | TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer );
124 | BaseType_t MPU_xTimerCreateTimerTask( void );
125 | BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait );
126 |
127 | /* MPU versions of event_group.h API functions. */
128 | EventGroupHandle_t MPU_xEventGroupCreate( void );
129 | EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer );
130 | EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait );
131 | EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
132 | EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
133 | EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait );
134 | void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup );
135 | UBaseType_t MPU_uxEventGroupGetNumber( void* xEventGroup );
136 |
137 | /* MPU versions of message/stream_buffer.h API functions. */
138 | size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait );
139 | size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken );
140 | size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait );
141 | size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken );
142 | void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer );
143 | BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );
144 | BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );
145 | BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );
146 | size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer );
147 | size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer );
148 | BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel );
149 | StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer );
150 | StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer );
151 |
152 |
153 |
154 | #endif /* MPU_PROTOTYPES_H */
155 |
156 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/mpu_wrappers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef MPU_WRAPPERS_H
29 | #define MPU_WRAPPERS_H
30 |
31 | /* This file redefines API functions to be called through a wrapper macro, but
32 | only for ports that are using the MPU. */
33 | #ifdef portUSING_MPU_WRAPPERS
34 |
35 | /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
36 | included from queue.c or task.c to prevent it from having an effect within
37 | those files. */
38 | #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
39 |
40 | /*
41 | * Map standard (non MPU) API functions to equivalents that start
42 | * "MPU_". This will cause the application code to call the MPU_
43 | * version, which wraps the non-MPU version with privilege promoting
44 | * then demoting code, so the kernel code always runs will full
45 | * privileges.
46 | */
47 |
48 | /* Map standard tasks.h API functions to the MPU equivalents. */
49 | #define xTaskCreate MPU_xTaskCreate
50 | #define xTaskCreateStatic MPU_xTaskCreateStatic
51 | #define xTaskCreateRestricted MPU_xTaskCreateRestricted
52 | #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
53 | #define vTaskDelete MPU_vTaskDelete
54 | #define vTaskDelay MPU_vTaskDelay
55 | #define vTaskDelayUntil MPU_vTaskDelayUntil
56 | #define xTaskAbortDelay MPU_xTaskAbortDelay
57 | #define uxTaskPriorityGet MPU_uxTaskPriorityGet
58 | #define eTaskGetState MPU_eTaskGetState
59 | #define vTaskGetInfo MPU_vTaskGetInfo
60 | #define vTaskPrioritySet MPU_vTaskPrioritySet
61 | #define vTaskSuspend MPU_vTaskSuspend
62 | #define vTaskResume MPU_vTaskResume
63 | #define vTaskSuspendAll MPU_vTaskSuspendAll
64 | #define xTaskResumeAll MPU_xTaskResumeAll
65 | #define xTaskGetTickCount MPU_xTaskGetTickCount
66 | #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
67 | #define pcTaskGetName MPU_pcTaskGetName
68 | #define xTaskGetHandle MPU_xTaskGetHandle
69 | #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
70 | #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
71 | #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
72 | #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
73 | #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
74 | #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
75 | #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
76 | #define uxTaskGetSystemState MPU_uxTaskGetSystemState
77 | #define vTaskList MPU_vTaskList
78 | #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
79 | #define xTaskGenericNotify MPU_xTaskGenericNotify
80 | #define xTaskNotifyWait MPU_xTaskNotifyWait
81 | #define ulTaskNotifyTake MPU_ulTaskNotifyTake
82 | #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear
83 |
84 | #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
85 | #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
86 | #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
87 | #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
88 |
89 | /* Map standard queue.h API functions to the MPU equivalents. */
90 | #define xQueueGenericSend MPU_xQueueGenericSend
91 | #define xQueueReceive MPU_xQueueReceive
92 | #define xQueuePeek MPU_xQueuePeek
93 | #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
94 | #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
95 | #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
96 | #define vQueueDelete MPU_vQueueDelete
97 | #define xQueueCreateMutex MPU_xQueueCreateMutex
98 | #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
99 | #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
100 | #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
101 | #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
102 | #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
103 | #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
104 | #define xQueueGenericCreate MPU_xQueueGenericCreate
105 | #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
106 | #define xQueueCreateSet MPU_xQueueCreateSet
107 | #define xQueueAddToSet MPU_xQueueAddToSet
108 | #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
109 | #define xQueueSelectFromSet MPU_xQueueSelectFromSet
110 | #define xQueueGenericReset MPU_xQueueGenericReset
111 |
112 | #if( configQUEUE_REGISTRY_SIZE > 0 )
113 | #define vQueueAddToRegistry MPU_vQueueAddToRegistry
114 | #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
115 | #define pcQueueGetName MPU_pcQueueGetName
116 | #endif
117 |
118 | /* Map standard timer.h API functions to the MPU equivalents. */
119 | #define xTimerCreate MPU_xTimerCreate
120 | #define xTimerCreateStatic MPU_xTimerCreateStatic
121 | #define pvTimerGetTimerID MPU_pvTimerGetTimerID
122 | #define vTimerSetTimerID MPU_vTimerSetTimerID
123 | #define xTimerIsTimerActive MPU_xTimerIsTimerActive
124 | #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
125 | #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
126 | #define pcTimerGetName MPU_pcTimerGetName
127 | #define xTimerGetPeriod MPU_xTimerGetPeriod
128 | #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
129 | #define xTimerGenericCommand MPU_xTimerGenericCommand
130 |
131 | /* Map standard event_group.h API functions to the MPU equivalents. */
132 | #define xEventGroupCreate MPU_xEventGroupCreate
133 | #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
134 | #define xEventGroupWaitBits MPU_xEventGroupWaitBits
135 | #define xEventGroupClearBits MPU_xEventGroupClearBits
136 | #define xEventGroupSetBits MPU_xEventGroupSetBits
137 | #define xEventGroupSync MPU_xEventGroupSync
138 | #define vEventGroupDelete MPU_vEventGroupDelete
139 |
140 | /* Map standard message/stream_buffer.h API functions to the MPU
141 | equivalents. */
142 | #define xStreamBufferSend MPU_xStreamBufferSend
143 | #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR
144 | #define xStreamBufferReceive MPU_xStreamBufferReceive
145 | #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR
146 | #define vStreamBufferDelete MPU_vStreamBufferDelete
147 | #define xStreamBufferIsFull MPU_xStreamBufferIsFull
148 | #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
149 | #define xStreamBufferReset MPU_xStreamBufferReset
150 | #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
151 | #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
152 | #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
153 | #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
154 | #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
155 |
156 |
157 | /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
158 | macro so applications can place data in privileged access sections
159 | (useful when using statically allocated objects). */
160 | #define PRIVILEGED_FUNCTION
161 | #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
162 |
163 | #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
164 |
165 | /* Ensure API functions go in the privileged execution section. */
166 | #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
167 | #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
168 |
169 | #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
170 |
171 | #else /* portUSING_MPU_WRAPPERS */
172 |
173 | #define PRIVILEGED_FUNCTION
174 | #define PRIVILEGED_DATA
175 | #define portUSING_MPU_WRAPPERS 0
176 |
177 | #endif /* portUSING_MPU_WRAPPERS */
178 |
179 |
180 | #endif /* MPU_WRAPPERS_H */
181 |
182 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/portable.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | /*-----------------------------------------------------------
29 | * Portable layer API. Each function must be defined for each port.
30 | *----------------------------------------------------------*/
31 |
32 | #ifndef PORTABLE_H
33 | #define PORTABLE_H
34 |
35 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
36 | pre-processor definition was used to ensure the pre-processor found the correct
37 | portmacro.h file for the port being used. That scheme was deprecated in favour
38 | of setting the compiler's include path such that it found the correct
39 | portmacro.h file - removing the need for the constant and allowing the
40 | portmacro.h file to be located anywhere in relation to the port being used.
41 | Purely for reasons of backward compatibility the old method is still valid, but
42 | to make it clear that new projects should not use it, support for the port
43 | specific constants has been moved into the deprecated_definitions.h header
44 | file. */
45 | #include "deprecated_definitions.h"
46 |
47 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
48 | did not result in a portmacro.h header file being included - and it should be
49 | included here. In this case the path to the correct portmacro.h header file
50 | must be set in the compiler's include path. */
51 | #ifndef portENTER_CRITICAL
52 | #include "portmacro.h"
53 | #endif
54 |
55 | #if portBYTE_ALIGNMENT == 32
56 | #define portBYTE_ALIGNMENT_MASK ( 0x001f )
57 | #endif
58 |
59 | #if portBYTE_ALIGNMENT == 16
60 | #define portBYTE_ALIGNMENT_MASK ( 0x000f )
61 | #endif
62 |
63 | #if portBYTE_ALIGNMENT == 8
64 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
65 | #endif
66 |
67 | #if portBYTE_ALIGNMENT == 4
68 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
69 | #endif
70 |
71 | #if portBYTE_ALIGNMENT == 2
72 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
73 | #endif
74 |
75 | #if portBYTE_ALIGNMENT == 1
76 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
77 | #endif
78 |
79 | #ifndef portBYTE_ALIGNMENT_MASK
80 | #error "Invalid portBYTE_ALIGNMENT definition"
81 | #endif
82 |
83 | #ifndef portNUM_CONFIGURABLE_REGIONS
84 | #define portNUM_CONFIGURABLE_REGIONS 1
85 | #endif
86 |
87 | #ifdef __cplusplus
88 | extern "C" {
89 | #endif
90 |
91 | #include "mpu_wrappers.h"
92 |
93 | /*
94 | * Setup the stack of a new task so it is ready to be placed under the
95 | * scheduler control. The registers have to be placed on the stack in
96 | * the order that the port expects to find them.
97 | *
98 | */
99 | #if( portUSING_MPU_WRAPPERS == 1 )
100 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
101 | #else
102 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
103 | #endif
104 |
105 | /* Used by heap_5.c. */
106 | typedef struct HeapRegion
107 | {
108 | uint8_t *pucStartAddress;
109 | size_t xSizeInBytes;
110 | } HeapRegion_t;
111 |
112 | /*
113 | * Used to define multiple heap regions for use by heap_5.c. This function
114 | * must be called before any calls to pvPortMalloc() - not creating a task,
115 | * queue, semaphore, mutex, software timer, event group, etc. will result in
116 | * pvPortMalloc being called.
117 | *
118 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
119 | * defines a region of memory that can be used as the heap. The array is
120 | * terminated by a HeapRegions_t structure that has a size of 0. The region
121 | * with the lowest start address must appear first in the array.
122 | */
123 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
124 |
125 |
126 | /*
127 | * Map to the memory management routines required for the port.
128 | */
129 | void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
130 | void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
131 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
132 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
133 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
134 |
135 | /*
136 | * Setup the hardware ready for the scheduler to take control. This generally
137 | * sets up a tick interrupt and sets timers for the correct tick frequency.
138 | */
139 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
140 |
141 | /*
142 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
143 | * the hardware is left in its original condition after the scheduler stops
144 | * executing.
145 | */
146 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
147 |
148 | /*
149 | * The structures and methods of manipulating the MPU are contained within the
150 | * port layer.
151 | *
152 | * Fills the xMPUSettings structure with the memory region information
153 | * contained in xRegions.
154 | */
155 | #if( portUSING_MPU_WRAPPERS == 1 )
156 | struct xMEMORY_REGION;
157 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
158 | #endif
159 |
160 | #ifdef __cplusplus
161 | }
162 | #endif
163 |
164 | #endif /* PORTABLE_H */
165 |
166 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/projdefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef PROJDEFS_H
29 | #define PROJDEFS_H
30 |
31 | /*
32 | * Defines the prototype to which task functions must conform. Defined in this
33 | * file to ensure the type is known before portable.h is included.
34 | */
35 | typedef void (*TaskFunction_t)( void * );
36 |
37 | /* Converts a time in milliseconds to a time in ticks. This macro can be
38 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
39 | definition here is not suitable for your application. */
40 | #ifndef pdMS_TO_TICKS
41 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
42 | #endif
43 |
44 | #define pdFALSE ( ( BaseType_t ) 0 )
45 | #define pdTRUE ( ( BaseType_t ) 1 )
46 |
47 | #define pdPASS ( pdTRUE )
48 | #define pdFAIL ( pdFALSE )
49 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 )
50 | #define errQUEUE_FULL ( ( BaseType_t ) 0 )
51 |
52 | /* FreeRTOS error definitions. */
53 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
54 | #define errQUEUE_BLOCKED ( -4 )
55 | #define errQUEUE_YIELD ( -5 )
56 |
57 | /* Macros used for basic data corruption checks. */
58 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES
59 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
60 | #endif
61 |
62 | #if( configUSE_16_BIT_TICKS == 1 )
63 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a
64 | #else
65 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL
66 | #endif
67 |
68 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS
69 | itself. */
70 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */
71 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
72 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */
73 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */
74 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */
75 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */
76 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */
77 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */
78 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */
79 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */
80 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */
81 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */
82 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */
83 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */
84 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */
85 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */
86 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */
87 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */
88 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */
89 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */
90 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */
91 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */
92 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */
93 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */
94 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */
95 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */
96 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */
97 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
98 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */
99 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */
100 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */
101 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */
102 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */
103 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */
104 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */
105 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */
106 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */
107 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */
108 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */
109 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
110 |
111 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS
112 | itself. */
113 | #define pdFREERTOS_LITTLE_ENDIAN 0
114 | #define pdFREERTOS_BIG_ENDIAN 1
115 |
116 | /* Re-defining endian values for generic naming. */
117 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN
118 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN
119 |
120 |
121 | #endif /* PROJDEFS_H */
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/stack_macros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef STACK_MACROS_H
29 | #define STACK_MACROS_H
30 |
31 | /*
32 | * Call the stack overflow hook function if the stack of the task being swapped
33 | * out is currently overflowed, or looks like it might have overflowed in the
34 | * past.
35 | *
36 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check
37 | * the current stack state only - comparing the current top of stack value to
38 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1
39 | * will also cause the last few stack bytes to be checked to ensure the value
40 | * to which the bytes were set when the task was created have not been
41 | * overwritten. Note this second test does not guarantee that an overflowed
42 | * stack will always be recognised.
43 | */
44 |
45 | /*-----------------------------------------------------------*/
46 |
47 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) )
48 |
49 | /* Only the current stack state is to be checked. */
50 | #define taskCHECK_FOR_STACK_OVERFLOW() \
51 | { \
52 | /* Is the currently saved stack pointer within the stack limit? */ \
53 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \
54 | { \
55 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
56 | } \
57 | }
58 |
59 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
60 | /*-----------------------------------------------------------*/
61 |
62 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) )
63 |
64 | /* Only the current stack state is to be checked. */
65 | #define taskCHECK_FOR_STACK_OVERFLOW() \
66 | { \
67 | \
68 | /* Is the currently saved stack pointer within the stack limit? */ \
69 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \
70 | { \
71 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
72 | } \
73 | }
74 |
75 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
76 | /*-----------------------------------------------------------*/
77 |
78 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
79 |
80 | #define taskCHECK_FOR_STACK_OVERFLOW() \
81 | { \
82 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
83 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
84 | \
85 | if( ( pulStack[ 0 ] != ulCheckValue ) || \
86 | ( pulStack[ 1 ] != ulCheckValue ) || \
87 | ( pulStack[ 2 ] != ulCheckValue ) || \
88 | ( pulStack[ 3 ] != ulCheckValue ) ) \
89 | { \
90 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
91 | } \
92 | }
93 |
94 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
95 | /*-----------------------------------------------------------*/
96 |
97 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
98 |
99 | #define taskCHECK_FOR_STACK_OVERFLOW() \
100 | { \
101 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
102 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
103 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
104 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
105 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
106 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
107 | \
108 | \
109 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
110 | \
111 | /* Has the extremity of the task stack ever been written over? */ \
112 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
113 | { \
114 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
115 | } \
116 | }
117 |
118 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
119 | /*-----------------------------------------------------------*/
120 |
121 | /* Remove stack overflow macro if not being used. */
122 | #ifndef taskCHECK_FOR_STACK_OVERFLOW
123 | #define taskCHECK_FOR_STACK_OVERFLOW()
124 | #endif
125 |
126 |
127 |
128 | #endif /* STACK_MACROS_H */
129 |
130 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/include/stdint.readme:
--------------------------------------------------------------------------------
1 |
2 | #ifndef FREERTOS_STDINT
3 | #define FREERTOS_STDINT
4 |
5 | /*******************************************************************************
6 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions
7 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be
8 | * built using compilers that do not provide their own stdint.h definition.
9 | *
10 | * To use this file:
11 | *
12 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h
13 | * header file, as that directory will already be in the compilers include
14 | * path.
15 | *
16 | * 2) Rename the copied file stdint.h.
17 | *
18 | */
19 |
20 | typedef signed char int8_t;
21 | typedef unsigned char uint8_t;
22 | typedef short int16_t;
23 | typedef unsigned short uint16_t;
24 | typedef long int32_t;
25 | typedef unsigned long uint32_t;
26 |
27 | #endif /* FREERTOS_STDINT */
28 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/list.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 |
29 | #include
30 | #include "FreeRTOS.h"
31 | #include "list.h"
32 |
33 | /*-----------------------------------------------------------
34 | * PUBLIC LIST API documented in list.h
35 | *----------------------------------------------------------*/
36 |
37 | void vListInitialise( List_t * const pxList )
38 | {
39 | /* The list structure contains a list item which is used to mark the
40 | end of the list. To initialise the list the list end is inserted
41 | as the only list entry. */
42 | pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
43 |
44 | /* The list end value is the highest possible value in the list to
45 | ensure it remains at the end of the list. */
46 | pxList->xListEnd.xItemValue = portMAX_DELAY;
47 |
48 | /* The list end next and previous pointers point to itself so we know
49 | when the list is empty. */
50 | pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
51 | pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
52 |
53 | pxList->uxNumberOfItems = ( UBaseType_t ) 0U;
54 |
55 | /* Write known values into the list if
56 | configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
57 | listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList );
58 | listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList );
59 | }
60 | /*-----------------------------------------------------------*/
61 |
62 | void vListInitialiseItem( ListItem_t * const pxItem )
63 | {
64 | /* Make sure the list item is not recorded as being on a list. */
65 | pxItem->pvContainer = NULL;
66 |
67 | /* Write known values into the list item if
68 | configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
69 | listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );
70 | listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );
71 | }
72 | /*-----------------------------------------------------------*/
73 |
74 | void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )
75 | {
76 | ListItem_t * const pxIndex = pxList->pxIndex;
77 |
78 | /* Only effective when configASSERT() is also defined, these tests may catch
79 | the list data structures being overwritten in memory. They will not catch
80 | data errors caused by incorrect configuration or use of FreeRTOS. */
81 | listTEST_LIST_INTEGRITY( pxList );
82 | listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );
83 |
84 | /* Insert a new list item into pxList, but rather than sort the list,
85 | makes the new list item the last item to be removed by a call to
86 | listGET_OWNER_OF_NEXT_ENTRY(). */
87 | pxNewListItem->pxNext = pxIndex;
88 | pxNewListItem->pxPrevious = pxIndex->pxPrevious;
89 |
90 | /* Only used during decision coverage testing. */
91 | mtCOVERAGE_TEST_DELAY();
92 |
93 | pxIndex->pxPrevious->pxNext = pxNewListItem;
94 | pxIndex->pxPrevious = pxNewListItem;
95 |
96 | /* Remember which list the item is in. */
97 | pxNewListItem->pvContainer = ( void * ) pxList;
98 |
99 | ( pxList->uxNumberOfItems )++;
100 | }
101 | /*-----------------------------------------------------------*/
102 |
103 | void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem )
104 | {
105 | ListItem_t *pxIterator;
106 | const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
107 |
108 | /* Only effective when configASSERT() is also defined, these tests may catch
109 | the list data structures being overwritten in memory. They will not catch
110 | data errors caused by incorrect configuration or use of FreeRTOS. */
111 | listTEST_LIST_INTEGRITY( pxList );
112 | listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );
113 |
114 | /* Insert the new list item into the list, sorted in xItemValue order.
115 |
116 | If the list already contains a list item with the same item value then the
117 | new list item should be placed after it. This ensures that TCB's which are
118 | stored in ready lists (all of which have the same xItemValue value) get a
119 | share of the CPU. However, if the xItemValue is the same as the back marker
120 | the iteration loop below will not end. Therefore the value is checked
121 | first, and the algorithm slightly modified if necessary. */
122 | if( xValueOfInsertion == portMAX_DELAY )
123 | {
124 | pxIterator = pxList->xListEnd.pxPrevious;
125 | }
126 | else
127 | {
128 | /* *** NOTE ***********************************************************
129 | If you find your application is crashing here then likely causes are
130 | listed below. In addition see http://www.freertos.org/FAQHelp.html for
131 | more tips, and ensure configASSERT() is defined!
132 | http://www.freertos.org/a00110.html#configASSERT
133 |
134 | 1) Stack overflow -
135 | see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
136 | 2) Incorrect interrupt priority assignment, especially on Cortex-M
137 | parts where numerically high priority values denote low actual
138 | interrupt priorities, which can seem counter intuitive. See
139 | http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition
140 | of configMAX_SYSCALL_INTERRUPT_PRIORITY on
141 | http://www.freertos.org/a00110.html
142 | 3) Calling an API function from within a critical section or when
143 | the scheduler is suspended, or calling an API function that does
144 | not end in "FromISR" from an interrupt.
145 | 4) Using a queue or semaphore before it has been initialised or
146 | before the scheduler has been started (are interrupts firing
147 | before vTaskStartScheduler() has been called?).
148 | **********************************************************************/
149 |
150 | for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
151 | {
152 | /* There is nothing to do here, just iterating to the wanted
153 | insertion position. */
154 | }
155 | }
156 |
157 | pxNewListItem->pxNext = pxIterator->pxNext;
158 | pxNewListItem->pxNext->pxPrevious = pxNewListItem;
159 | pxNewListItem->pxPrevious = pxIterator;
160 | pxIterator->pxNext = pxNewListItem;
161 |
162 | /* Remember which list the item is in. This allows fast removal of the
163 | item later. */
164 | pxNewListItem->pvContainer = ( void * ) pxList;
165 |
166 | ( pxList->uxNumberOfItems )++;
167 | }
168 | /*-----------------------------------------------------------*/
169 |
170 | UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
171 | {
172 | /* The list item knows which list it is in. Obtain the list from the list
173 | item. */
174 | List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;
175 |
176 | pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
177 | pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
178 |
179 | /* Only used during decision coverage testing. */
180 | mtCOVERAGE_TEST_DELAY();
181 |
182 | /* Make sure the index is left pointing to a valid item. */
183 | if( pxList->pxIndex == pxItemToRemove )
184 | {
185 | pxList->pxIndex = pxItemToRemove->pxPrevious;
186 | }
187 | else
188 | {
189 | mtCOVERAGE_TEST_MARKER();
190 | }
191 |
192 | pxItemToRemove->pvContainer = NULL;
193 | ( pxList->uxNumberOfItems )--;
194 |
195 | return pxList->uxNumberOfItems;
196 | }
197 | /*-----------------------------------------------------------*/
198 |
199 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/GCC/ARM_CA57_64_BIT/portASM.S:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | .text
29 |
30 | /* Variables and functions. */
31 | .extern ullMaxAPIPriorityMask
32 | .extern pxCurrentTCB
33 | .extern vTaskSwitchContext
34 | .extern vApplicationIRQHandler
35 | .extern ullPortInterruptNesting
36 | .extern ullPortTaskHasFPUContext
37 | .extern ullCriticalNesting
38 | .extern ullPortYieldRequired
39 | .extern ullICCEOIR
40 | .extern ullICCIAR
41 | .extern _freertos_vector_table
42 |
43 | .global FreeRTOS_IRQ_Handler
44 | .global FreeRTOS_SWI_Handler
45 | .global vPortRestoreTaskContext
46 |
47 |
48 | .macro portSAVE_CONTEXT
49 |
50 | /* Switch to use the EL0 stack pointer. */
51 | MSR SPSEL, #0
52 |
53 | /* Save the entire context. */
54 | STP X0, X1, [SP, #-0x10]!
55 | STP X2, X3, [SP, #-0x10]!
56 | STP X4, X5, [SP, #-0x10]!
57 | STP X6, X7, [SP, #-0x10]!
58 | STP X8, X9, [SP, #-0x10]!
59 | STP X10, X11, [SP, #-0x10]!
60 | STP X12, X13, [SP, #-0x10]!
61 | STP X14, X15, [SP, #-0x10]!
62 | STP X16, X17, [SP, #-0x10]!
63 | STP X18, X19, [SP, #-0x10]!
64 | STP X20, X21, [SP, #-0x10]!
65 | STP X22, X23, [SP, #-0x10]!
66 | STP X24, X25, [SP, #-0x10]!
67 | STP X26, X27, [SP, #-0x10]!
68 | STP X28, X29, [SP, #-0x10]!
69 | STP X30, XZR, [SP, #-0x10]!
70 |
71 | /* Save the SPSR. */
72 | #if defined( GUEST )
73 | MRS X3, SPSR_EL1
74 | MRS X2, ELR_EL1
75 | #else
76 | MRS X3, SPSR_EL3
77 | /* Save the ELR. */
78 | MRS X2, ELR_EL3
79 | #endif
80 |
81 | STP X2, X3, [SP, #-0x10]!
82 |
83 | /* Save the critical section nesting depth. */
84 | LDR X0, ullCriticalNestingConst
85 | LDR X3, [X0]
86 |
87 | /* Save the FPU context indicator. */
88 | LDR X0, ullPortTaskHasFPUContextConst
89 | LDR X2, [X0]
90 |
91 | /* Save the FPU context, if any (32 128-bit registers). */
92 | CMP X2, #0
93 | B.EQ 1f
94 | STP Q0, Q1, [SP,#-0x20]!
95 | STP Q2, Q3, [SP,#-0x20]!
96 | STP Q4, Q5, [SP,#-0x20]!
97 | STP Q6, Q7, [SP,#-0x20]!
98 | STP Q8, Q9, [SP,#-0x20]!
99 | STP Q10, Q11, [SP,#-0x20]!
100 | STP Q12, Q13, [SP,#-0x20]!
101 | STP Q14, Q15, [SP,#-0x20]!
102 | STP Q16, Q17, [SP,#-0x20]!
103 | STP Q18, Q19, [SP,#-0x20]!
104 | STP Q20, Q21, [SP,#-0x20]!
105 | STP Q22, Q23, [SP,#-0x20]!
106 | STP Q24, Q25, [SP,#-0x20]!
107 | STP Q26, Q27, [SP,#-0x20]!
108 | STP Q28, Q29, [SP,#-0x20]!
109 | STP Q30, Q31, [SP,#-0x20]!
110 |
111 | 1:
112 | /* Store the critical nesting count and FPU context indicator. */
113 | STP X2, X3, [SP, #-0x10]!
114 |
115 | LDR X0, pxCurrentTCBConst
116 | LDR X1, [X0]
117 | MOV X0, SP /* Move SP into X0 for saving. */
118 | STR X0, [X1]
119 |
120 | /* Switch to use the ELx stack pointer. */
121 | MSR SPSEL, #1
122 |
123 | .endm
124 |
125 | ; /**********************************************************************/
126 |
127 | .macro portRESTORE_CONTEXT
128 |
129 | /* Switch to use the EL0 stack pointer. */
130 | MSR SPSEL, #0
131 |
132 | /* Set the SP to point to the stack of the task being restored. */
133 | LDR X0, pxCurrentTCBConst
134 | LDR X1, [X0]
135 | LDR X0, [X1]
136 | MOV SP, X0
137 |
138 | LDP X2, X3, [SP], #0x10 /* Critical nesting and FPU context. */
139 |
140 | /* Set the PMR register to be correct for the current critical nesting
141 | depth. */
142 | LDR X0, ullCriticalNestingConst /* X0 holds the address of ullCriticalNesting. */
143 | MOV X1, #255 /* X1 holds the unmask value. */
144 | LDR X4, ullICCPMRConst /* X4 holds the address of the ICCPMR constant. */
145 | CMP X3, #0
146 | LDR X5, [X4] /* X5 holds the address of the ICCPMR register. */
147 | B.EQ 1f
148 | LDR X6, ullMaxAPIPriorityMaskConst
149 | LDR X1, [X6] /* X1 holds the mask value. */
150 | 1:
151 | STR W1, [X5] /* Write the mask value to ICCPMR. */
152 | DSB SY /* _RB_Barriers probably not required here. */
153 | ISB SY
154 | STR X3, [X0] /* Restore the task's critical nesting count. */
155 |
156 | /* Restore the FPU context indicator. */
157 | LDR X0, ullPortTaskHasFPUContextConst
158 | STR X2, [X0]
159 |
160 | /* Restore the FPU context, if any. */
161 | CMP X2, #0
162 | B.EQ 1f
163 | LDP Q30, Q31, [SP], #0x20
164 | LDP Q28, Q29, [SP], #0x20
165 | LDP Q26, Q27, [SP], #0x20
166 | LDP Q24, Q25, [SP], #0x20
167 | LDP Q22, Q23, [SP], #0x20
168 | LDP Q20, Q21, [SP], #0x20
169 | LDP Q18, Q19, [SP], #0x20
170 | LDP Q16, Q17, [SP], #0x20
171 | LDP Q14, Q15, [SP], #0x20
172 | LDP Q12, Q13, [SP], #0x20
173 | LDP Q10, Q11, [SP], #0x20
174 | LDP Q8, Q9, [SP], #0x20
175 | LDP Q6, Q7, [SP], #0x20
176 | LDP Q4, Q5, [SP], #0x20
177 | LDP Q2, Q3, [SP], #0x20
178 | LDP Q0, Q1, [SP], #0x20
179 | 1:
180 | LDP X2, X3, [SP], #0x10 /* SPSR and ELR. */
181 |
182 | #if defined( GUEST )
183 | /* Restore the SPSR. */
184 | MSR SPSR_EL1, X3
185 | /* Restore the ELR. */
186 | MSR ELR_EL1, X2
187 | #else
188 | /* Restore the SPSR. */
189 | MSR SPSR_EL3, X3 /*_RB_ Assumes started in EL3. */
190 | /* Restore the ELR. */
191 | MSR ELR_EL3, X2
192 | #endif
193 |
194 | LDP X30, XZR, [SP], #0x10
195 | LDP X28, X29, [SP], #0x10
196 | LDP X26, X27, [SP], #0x10
197 | LDP X24, X25, [SP], #0x10
198 | LDP X22, X23, [SP], #0x10
199 | LDP X20, X21, [SP], #0x10
200 | LDP X18, X19, [SP], #0x10
201 | LDP X16, X17, [SP], #0x10
202 | LDP X14, X15, [SP], #0x10
203 | LDP X12, X13, [SP], #0x10
204 | LDP X10, X11, [SP], #0x10
205 | LDP X8, X9, [SP], #0x10
206 | LDP X6, X7, [SP], #0x10
207 | LDP X4, X5, [SP], #0x10
208 | LDP X2, X3, [SP], #0x10
209 | LDP X0, X1, [SP], #0x10
210 |
211 | /* Switch to use the ELx stack pointer. _RB_ Might not be required. */
212 | MSR SPSEL, #1
213 |
214 | ERET
215 |
216 | .endm
217 |
218 |
219 | /******************************************************************************
220 | * FreeRTOS_SWI_Handler handler is used to perform a context switch.
221 | *****************************************************************************/
222 | .align 8
223 | .type FreeRTOS_SWI_Handler, %function
224 | FreeRTOS_SWI_Handler:
225 | /* Save the context of the current task and select a new task to run. */
226 | portSAVE_CONTEXT
227 | #if defined( GUEST )
228 | MRS X0, ESR_EL1
229 | #else
230 | MRS X0, ESR_EL3
231 | #endif
232 |
233 | LSR X1, X0, #26
234 |
235 | #if defined( GUEST )
236 | CMP X1, #0x15 /* 0x15 = SVC instruction. */
237 | #else
238 | CMP X1, #0x17 /* 0x17 = SMC instruction. */
239 | #endif
240 | B.NE FreeRTOS_Abort
241 | BL vTaskSwitchContext
242 |
243 | portRESTORE_CONTEXT
244 |
245 | FreeRTOS_Abort:
246 | /* Full ESR is in X0, exception class code is in X1. */
247 | B .
248 |
249 | /******************************************************************************
250 | * vPortRestoreTaskContext is used to start the scheduler.
251 | *****************************************************************************/
252 | .align 8
253 | .type vPortRestoreTaskContext, %function
254 | vPortRestoreTaskContext:
255 | .set freertos_vector_base, _freertos_vector_table
256 |
257 | /* Install the FreeRTOS interrupt handlers. */
258 | LDR X1, =freertos_vector_base
259 | #if defined( GUEST )
260 | MSR VBAR_EL1, X1
261 | #else
262 | MSR VBAR_EL3, X1
263 | #endif
264 | DSB SY
265 | ISB SY
266 |
267 | /* Start the first task. */
268 | portRESTORE_CONTEXT
269 |
270 |
271 | /******************************************************************************
272 | * FreeRTOS_IRQ_Handler handles IRQ entry and exit.
273 | *****************************************************************************/
274 | .align 8
275 | .type FreeRTOS_IRQ_Handler, %function
276 | FreeRTOS_IRQ_Handler:
277 | /* Save volatile registers. */
278 | STP X0, X1, [SP, #-0x10]!
279 | STP X2, X3, [SP, #-0x10]!
280 | STP X4, X5, [SP, #-0x10]!
281 | STP X6, X7, [SP, #-0x10]!
282 | STP X8, X9, [SP, #-0x10]!
283 | STP X10, X11, [SP, #-0x10]!
284 | STP X12, X13, [SP, #-0x10]!
285 | STP X14, X15, [SP, #-0x10]!
286 | STP X16, X17, [SP, #-0x10]!
287 | STP X18, X19, [SP, #-0x10]!
288 | STP X29, X30, [SP, #-0x10]!
289 |
290 | /* Save the SPSR and ELR. */
291 | #if defined( GUEST )
292 | MRS X3, SPSR_EL1
293 | MRS X2, ELR_EL1
294 | #else
295 | MRS X3, SPSR_EL3
296 | MRS X2, ELR_EL3
297 | #endif
298 | STP X2, X3, [SP, #-0x10]!
299 |
300 | /* Increment the interrupt nesting counter. */
301 | LDR X5, ullPortInterruptNestingConst
302 | LDR X1, [X5] /* Old nesting count in X1. */
303 | ADD X6, X1, #1
304 | STR X6, [X5] /* Address of nesting count variable in X5. */
305 |
306 | /* Maintain the interrupt nesting information across the function call. */
307 | STP X1, X5, [SP, #-0x10]!
308 |
309 | /* Read value from the interrupt acknowledge register, which is stored in W0
310 | for future parameter and interrupt clearing use. */
311 | LDR X2, ullICCIARConst
312 | LDR X3, [X2]
313 | LDR W0, [X3] /* ICCIAR in W0 as parameter. */
314 |
315 | /* Maintain the ICCIAR value across the function call. */
316 | STP X0, X1, [SP, #-0x10]!
317 |
318 | /* Call the C handler. */
319 | BL vApplicationIRQHandler
320 |
321 | /* Disable interrupts. */
322 | MSR DAIFSET, #2
323 | DSB SY
324 | ISB SY
325 |
326 | /* Restore the ICCIAR value. */
327 | LDP X0, X1, [SP], #0x10
328 |
329 | /* End IRQ processing by writing ICCIAR to the EOI register. */
330 | LDR X4, ullICCEOIRConst
331 | LDR X4, [X4]
332 | STR W0, [X4]
333 |
334 | /* Restore the critical nesting count. */
335 | LDP X1, X5, [SP], #0x10
336 | STR X1, [X5]
337 |
338 | /* Has interrupt nesting unwound? */
339 | CMP X1, #0
340 | B.NE Exit_IRQ_No_Context_Switch
341 |
342 | /* Is a context switch required? */
343 | LDR X0, ullPortYieldRequiredConst
344 | LDR X1, [X0]
345 | CMP X1, #0
346 | B.EQ Exit_IRQ_No_Context_Switch
347 |
348 | /* Reset ullPortYieldRequired to 0. */
349 | MOV X2, #0
350 | STR X2, [X0]
351 |
352 | /* Restore volatile registers. */
353 | LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */
354 | #if defined( GUEST )
355 | MSR SPSR_EL1, X5
356 | MSR ELR_EL1, X4
357 | #else
358 | MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */
359 | MSR ELR_EL3, X4
360 | #endif
361 | DSB SY
362 | ISB SY
363 |
364 | LDP X29, X30, [SP], #0x10
365 | LDP X18, X19, [SP], #0x10
366 | LDP X16, X17, [SP], #0x10
367 | LDP X14, X15, [SP], #0x10
368 | LDP X12, X13, [SP], #0x10
369 | LDP X10, X11, [SP], #0x10
370 | LDP X8, X9, [SP], #0x10
371 | LDP X6, X7, [SP], #0x10
372 | LDP X4, X5, [SP], #0x10
373 | LDP X2, X3, [SP], #0x10
374 | LDP X0, X1, [SP], #0x10
375 |
376 | /* Save the context of the current task and select a new task to run. */
377 | portSAVE_CONTEXT
378 | BL vTaskSwitchContext
379 | portRESTORE_CONTEXT
380 |
381 | Exit_IRQ_No_Context_Switch:
382 | /* Restore volatile registers. */
383 | LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */
384 | #if defined( GUEST )
385 | MSR SPSR_EL1, X5
386 | MSR ELR_EL1, X4
387 | #else
388 | MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */
389 | MSR ELR_EL3, X4
390 | #endif
391 | DSB SY
392 | ISB SY
393 |
394 | LDP X29, X30, [SP], #0x10
395 | LDP X18, X19, [SP], #0x10
396 | LDP X16, X17, [SP], #0x10
397 | LDP X14, X15, [SP], #0x10
398 | LDP X12, X13, [SP], #0x10
399 | LDP X10, X11, [SP], #0x10
400 | LDP X8, X9, [SP], #0x10
401 | LDP X6, X7, [SP], #0x10
402 | LDP X4, X5, [SP], #0x10
403 | LDP X2, X3, [SP], #0x10
404 | LDP X0, X1, [SP], #0x10
405 |
406 | ERET
407 |
408 |
409 |
410 |
411 | .align 8
412 | pxCurrentTCBConst: .dword pxCurrentTCB
413 | ullCriticalNestingConst: .dword ullCriticalNesting
414 | ullPortTaskHasFPUContextConst: .dword ullPortTaskHasFPUContext
415 |
416 | ullICCPMRConst: .dword ullICCPMR
417 | ullMaxAPIPriorityMaskConst: .dword ullMaxAPIPriorityMask
418 | vApplicationIRQHandlerConst: .word vApplicationIRQHandler
419 | ullPortInterruptNestingConst: .dword ullPortInterruptNesting
420 | ullPortYieldRequiredConst: .dword ullPortYieldRequired
421 | ullICCIARConst: .dword ullICCIAR
422 | ullICCEOIRConst: .dword ullICCEOIR
423 |
424 |
425 |
426 | .end
427 |
428 |
429 |
430 |
431 |
432 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/GCC/ARM_CA57_64_BIT/portmacro.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | #ifndef PORTMACRO_H
29 | #define PORTMACRO_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | /*-----------------------------------------------------------
36 | * Port specific definitions.
37 | *
38 | * The settings in this file configure FreeRTOS correctly for the given hardware
39 | * and compiler.
40 | *
41 | * These settings should not be altered.
42 | *-----------------------------------------------------------
43 | */
44 |
45 | /* Type definitions. */
46 | #define portCHAR char
47 | #define portFLOAT float
48 | #define portDOUBLE double
49 | #define portLONG long
50 | #define portSHORT short
51 | #define portSTACK_TYPE size_t
52 | #define portBASE_TYPE long
53 |
54 | typedef portSTACK_TYPE StackType_t;
55 | typedef portBASE_TYPE BaseType_t;
56 | typedef uint64_t UBaseType_t;
57 |
58 | typedef uint64_t TickType_t;
59 | #define portMAX_DELAY ( ( TickType_t ) 0xffffffffffffffff )
60 |
61 | /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
62 | not need to be guarded with a critical section. */
63 | #define portTICK_TYPE_IS_ATOMIC 1
64 |
65 | /*-----------------------------------------------------------*/
66 |
67 | /* Hardware specifics. */
68 | #define portSTACK_GROWTH ( -1 )
69 | #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
70 | #define portBYTE_ALIGNMENT 16
71 | #define portPOINTER_SIZE_TYPE uint64_t
72 |
73 | /*-----------------------------------------------------------*/
74 |
75 | /* Task utilities. */
76 |
77 | /* Called at the end of an ISR that can cause a context switch. */
78 | #define portEND_SWITCHING_ISR( xSwitchRequired )\
79 | { \
80 | extern uint64_t ullPortYieldRequired; \
81 | \
82 | if( xSwitchRequired != pdFALSE ) \
83 | { \
84 | ullPortYieldRequired = pdTRUE; \
85 | } \
86 | }
87 |
88 | #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
89 | #if defined( GUEST )
90 | #define portYIELD() __asm volatile ( "SVC 0" ::: "memory" )
91 | #else
92 | #define portYIELD() __asm volatile ( "SMC 0" ::: "memory" )
93 | #endif
94 | /*-----------------------------------------------------------
95 | * Critical section control
96 | *----------------------------------------------------------*/
97 |
98 | extern void vPortEnterCritical( void );
99 | extern void vPortExitCritical( void );
100 | extern UBaseType_t uxPortSetInterruptMask( void );
101 | extern void vPortClearInterruptMask( UBaseType_t uxNewMaskValue );
102 | extern void vPortInstallFreeRTOSVectorTable( void );
103 |
104 | #define portDISABLE_INTERRUPTS() \
105 | __asm volatile ( "MSR DAIFSET, #2" ::: "memory" ); \
106 | __asm volatile ( "DSB SY" ); \
107 | __asm volatile ( "ISB SY" );
108 |
109 | #define portENABLE_INTERRUPTS() \
110 | __asm volatile ( "MSR DAIFCLR, #2" ::: "memory" ); \
111 | __asm volatile ( "DSB SY" ); \
112 | __asm volatile ( "ISB SY" );
113 |
114 |
115 | /* These macros do not globally disable/enable interrupts. They do mask off
116 | interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */
117 | #define portENTER_CRITICAL() vPortEnterCritical();
118 | #define portEXIT_CRITICAL() vPortExitCritical();
119 | #define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMask()
120 | #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
121 |
122 | /*-----------------------------------------------------------*/
123 |
124 | /* Task function macros as described on the FreeRTOS.org WEB site. These are
125 | not required for this port but included in case common demo code that uses these
126 | macros is used. */
127 | #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
128 | #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
129 |
130 | /* Prototype of the FreeRTOS tick handler. This must be installed as the
131 | handler for whichever peripheral is used to generate the RTOS tick. */
132 | void FreeRTOS_Tick_Handler( void );
133 |
134 | /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()
135 | before any floating point instructions are executed. */
136 | void vPortTaskUsesFPU( void );
137 | #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
138 |
139 | #define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )
140 | #define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL )
141 |
142 | /* Architecture specific optimisations. */
143 | #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
144 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
145 | #endif
146 |
147 | #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
148 |
149 | /* Store/clear the ready priorities in a bit map. */
150 | #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
151 | #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
152 |
153 | /*-----------------------------------------------------------*/
154 |
155 | #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __builtin_clz( uxReadyPriorities ) )
156 |
157 | #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
158 |
159 | #ifdef configASSERT
160 | void vPortValidateInterruptPriority( void );
161 | #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
162 | #endif /* configASSERT */
163 |
164 | #define portNOP() __asm volatile( "NOP" )
165 | #define portINLINE __inline
166 |
167 | #ifdef __cplusplus
168 | } /* extern C */
169 | #endif
170 |
171 |
172 | /* The number of bits to shift for an interrupt priority is dependent on the
173 | number of bits implemented by the interrupt controller. */
174 | #if configUNIQUE_INTERRUPT_PRIORITIES == 16
175 | #define portPRIORITY_SHIFT 4
176 | #define portMAX_BINARY_POINT_VALUE 3
177 | #elif configUNIQUE_INTERRUPT_PRIORITIES == 32
178 | #define portPRIORITY_SHIFT 3
179 | #define portMAX_BINARY_POINT_VALUE 2
180 | #elif configUNIQUE_INTERRUPT_PRIORITIES == 64
181 | #define portPRIORITY_SHIFT 2
182 | #define portMAX_BINARY_POINT_VALUE 1
183 | #elif configUNIQUE_INTERRUPT_PRIORITIES == 128
184 | #define portPRIORITY_SHIFT 1
185 | #define portMAX_BINARY_POINT_VALUE 0
186 | #elif configUNIQUE_INTERRUPT_PRIORITIES == 256
187 | #define portPRIORITY_SHIFT 0
188 | #define portMAX_BINARY_POINT_VALUE 0
189 | #else
190 | #error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware
191 | #endif
192 |
193 | /* Interrupt controller access addresses. */
194 | #define portICCPMR_PRIORITY_MASK_OFFSET ( 0x04 )
195 | #define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET ( 0x0C )
196 | #define portICCEOIR_END_OF_INTERRUPT_OFFSET ( 0x10 )
197 | #define portICCBPR_BINARY_POINT_OFFSET ( 0x08 )
198 | #define portICCRPR_RUNNING_PRIORITY_OFFSET ( 0x14 )
199 |
200 | #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS ( GIC_GICC_BASE )
201 | #define portICCPMR_PRIORITY_MASK_REGISTER ( *( ( volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) ) )
202 | #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET )
203 | #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET )
204 | #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET )
205 | #define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) )
206 | #define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) )
207 |
208 | #endif /* PORTMACRO_H */
209 |
210 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/MemMang/ReadMe.url:
--------------------------------------------------------------------------------
1 | [{000214A0-0000-0000-C000-000000000046}]
2 | Prop3=19,2
3 | [InternetShortcut]
4 | URL=http://www.freertos.org/a00111.html
5 | IDList=
6 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/MemMang/heap_1.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 |
29 | /*
30 | * The simplest possible implementation of pvPortMalloc(). Note that this
31 | * implementation does NOT allow allocated memory to be freed again.
32 | *
33 | * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the
34 | * memory management pages of http://www.FreeRTOS.org for more information.
35 | */
36 | #include
37 |
38 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
39 | all the API functions to use the MPU wrappers. That should only be done when
40 | task.h is included from an application file. */
41 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
42 |
43 | #include "FreeRTOS.h"
44 | #include "task.h"
45 |
46 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
47 |
48 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
49 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
50 | #endif
51 |
52 | /* A few bytes might be lost to byte aligning the heap start address. */
53 | #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
54 |
55 | /* Allocate the memory for the heap. */
56 | /* Allocate the memory for the heap. */
57 | #if( configAPPLICATION_ALLOCATED_HEAP == 1 )
58 | /* The application writer has already defined the array used for the RTOS
59 | heap - probably so it can be placed in a special segment or address. */
60 | extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
61 | #else
62 | static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
63 | #endif /* configAPPLICATION_ALLOCATED_HEAP */
64 |
65 | /* Index into the ucHeap array. */
66 | static size_t xNextFreeByte = ( size_t ) 0;
67 |
68 | /*-----------------------------------------------------------*/
69 |
70 | void *pvPortMalloc( size_t xWantedSize )
71 | {
72 | void *pvReturn = NULL;
73 | static uint8_t *pucAlignedHeap = NULL;
74 |
75 | /* Ensure that blocks are always aligned to the required number of bytes. */
76 | #if( portBYTE_ALIGNMENT != 1 )
77 | {
78 | if( xWantedSize & portBYTE_ALIGNMENT_MASK )
79 | {
80 | /* Byte alignment required. */
81 | xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
82 | }
83 | }
84 | #endif
85 |
86 | vTaskSuspendAll();
87 | {
88 | if( pucAlignedHeap == NULL )
89 | {
90 | /* Ensure the heap starts on a correctly aligned boundary. */
91 | pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
92 | }
93 |
94 | /* Check there is enough room left for the allocation. */
95 | if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&
96 | ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */
97 | {
98 | /* Return the next free byte then increment the index past this
99 | block. */
100 | pvReturn = pucAlignedHeap + xNextFreeByte;
101 | xNextFreeByte += xWantedSize;
102 | }
103 |
104 | traceMALLOC( pvReturn, xWantedSize );
105 | }
106 | ( void ) xTaskResumeAll();
107 |
108 | #if( configUSE_MALLOC_FAILED_HOOK == 1 )
109 | {
110 | if( pvReturn == NULL )
111 | {
112 | extern void vApplicationMallocFailedHook( void );
113 | vApplicationMallocFailedHook();
114 | }
115 | }
116 | #endif
117 |
118 | return pvReturn;
119 | }
120 | /*-----------------------------------------------------------*/
121 |
122 | void vPortFree( void *pv )
123 | {
124 | /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and
125 | heap_4.c for alternative implementations, and the memory management pages of
126 | http://www.FreeRTOS.org for more information. */
127 | ( void ) pv;
128 |
129 | /* Force an assert as it is invalid to call this function. */
130 | configASSERT( pv == NULL );
131 | }
132 | /*-----------------------------------------------------------*/
133 |
134 | void vPortInitialiseBlocks( void )
135 | {
136 | /* Only required when static memory is not cleared. */
137 | xNextFreeByte = ( size_t ) 0;
138 | }
139 | /*-----------------------------------------------------------*/
140 |
141 | size_t xPortGetFreeHeapSize( void )
142 | {
143 | return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );
144 | }
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/MemMang/heap_2.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 | /*
29 | * A sample implementation of pvPortMalloc() and vPortFree() that permits
30 | * allocated blocks to be freed, but does not combine adjacent free blocks
31 | * into a single larger block (and so will fragment memory). See heap_4.c for
32 | * an equivalent that does combine adjacent blocks into single larger blocks.
33 | *
34 | * See heap_1.c, heap_3.c and heap_4.c for alternative implementations, and the
35 | * memory management pages of http://www.FreeRTOS.org for more information.
36 | */
37 | #include
38 |
39 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
40 | all the API functions to use the MPU wrappers. That should only be done when
41 | task.h is included from an application file. */
42 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
43 |
44 | #include "FreeRTOS.h"
45 | #include "task.h"
46 |
47 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
48 |
49 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
50 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
51 | #endif
52 |
53 | /* A few bytes might be lost to byte aligning the heap start address. */
54 | #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
55 |
56 | /*
57 | * Initialises the heap structures before their first use.
58 | */
59 | static void prvHeapInit( void );
60 |
61 | /* Allocate the memory for the heap. */
62 | #if( configAPPLICATION_ALLOCATED_HEAP == 1 )
63 | /* The application writer has already defined the array used for the RTOS
64 | heap - probably so it can be placed in a special segment or address. */
65 | extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
66 | #else
67 | static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
68 | #endif /* configAPPLICATION_ALLOCATED_HEAP */
69 |
70 |
71 | /* Define the linked list structure. This is used to link free blocks in order
72 | of their size. */
73 | typedef struct A_BLOCK_LINK
74 | {
75 | struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */
76 | size_t xBlockSize; /*<< The size of the free block. */
77 | } BlockLink_t;
78 |
79 |
80 | static const uint16_t heapSTRUCT_SIZE = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );
81 | #define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
82 |
83 | /* Create a couple of list links to mark the start and end of the list. */
84 | static BlockLink_t xStart, xEnd;
85 |
86 | /* Keeps track of the number of free bytes remaining, but says nothing about
87 | fragmentation. */
88 | static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
89 |
90 | /* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */
91 |
92 | /*
93 | * Insert a block into the list of free blocks - which is ordered by size of
94 | * the block. Small blocks at the start of the list and large blocks at the end
95 | * of the list.
96 | */
97 | #define prvInsertBlockIntoFreeList( pxBlockToInsert ) \
98 | { \
99 | BlockLink_t *pxIterator; \
100 | size_t xBlockSize; \
101 | \
102 | xBlockSize = pxBlockToInsert->xBlockSize; \
103 | \
104 | /* Iterate through the list until a block is found that has a larger size */ \
105 | /* than the block we are inserting. */ \
106 | for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \
107 | { \
108 | /* There is nothing to do here - just iterate to the correct position. */ \
109 | } \
110 | \
111 | /* Update the list to include the block being inserted in the correct */ \
112 | /* position. */ \
113 | pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \
114 | pxIterator->pxNextFreeBlock = pxBlockToInsert; \
115 | }
116 | /*-----------------------------------------------------------*/
117 |
118 | void *pvPortMalloc( size_t xWantedSize )
119 | {
120 | BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
121 | static BaseType_t xHeapHasBeenInitialised = pdFALSE;
122 | void *pvReturn = NULL;
123 |
124 | vTaskSuspendAll();
125 | {
126 | /* If this is the first call to malloc then the heap will require
127 | initialisation to setup the list of free blocks. */
128 | if( xHeapHasBeenInitialised == pdFALSE )
129 | {
130 | prvHeapInit();
131 | xHeapHasBeenInitialised = pdTRUE;
132 | }
133 |
134 | /* The wanted size is increased so it can contain a BlockLink_t
135 | structure in addition to the requested amount of bytes. */
136 | if( xWantedSize > 0 )
137 | {
138 | xWantedSize += heapSTRUCT_SIZE;
139 |
140 | /* Ensure that blocks are always aligned to the required number of bytes. */
141 | if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 )
142 | {
143 | /* Byte alignment required. */
144 | xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
145 | }
146 | }
147 |
148 | if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) )
149 | {
150 | /* Blocks are stored in byte order - traverse the list from the start
151 | (smallest) block until one of adequate size is found. */
152 | pxPreviousBlock = &xStart;
153 | pxBlock = xStart.pxNextFreeBlock;
154 | while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )
155 | {
156 | pxPreviousBlock = pxBlock;
157 | pxBlock = pxBlock->pxNextFreeBlock;
158 | }
159 |
160 | /* If we found the end marker then a block of adequate size was not found. */
161 | if( pxBlock != &xEnd )
162 | {
163 | /* Return the memory space - jumping over the BlockLink_t structure
164 | at its start. */
165 | pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );
166 |
167 | /* This block is being returned for use so must be taken out of the
168 | list of free blocks. */
169 | pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;
170 |
171 | /* If the block is larger than required it can be split into two. */
172 | if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
173 | {
174 | /* This block is to be split into two. Create a new block
175 | following the number of bytes requested. The void cast is
176 | used to prevent byte alignment warnings from the compiler. */
177 | pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
178 |
179 | /* Calculate the sizes of two blocks split from the single
180 | block. */
181 | pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;
182 | pxBlock->xBlockSize = xWantedSize;
183 |
184 | /* Insert the new block into the list of free blocks. */
185 | prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
186 | }
187 |
188 | xFreeBytesRemaining -= pxBlock->xBlockSize;
189 | }
190 | }
191 |
192 | traceMALLOC( pvReturn, xWantedSize );
193 | }
194 | ( void ) xTaskResumeAll();
195 |
196 | #if( configUSE_MALLOC_FAILED_HOOK == 1 )
197 | {
198 | if( pvReturn == NULL )
199 | {
200 | extern void vApplicationMallocFailedHook( void );
201 | vApplicationMallocFailedHook();
202 | }
203 | }
204 | #endif
205 |
206 | return pvReturn;
207 | }
208 | /*-----------------------------------------------------------*/
209 |
210 | void vPortFree( void *pv )
211 | {
212 | uint8_t *puc = ( uint8_t * ) pv;
213 | BlockLink_t *pxLink;
214 |
215 | if( pv != NULL )
216 | {
217 | /* The memory being freed will have an BlockLink_t structure immediately
218 | before it. */
219 | puc -= heapSTRUCT_SIZE;
220 |
221 | /* This unexpected casting is to keep some compilers from issuing
222 | byte alignment warnings. */
223 | pxLink = ( void * ) puc;
224 |
225 | vTaskSuspendAll();
226 | {
227 | /* Add this block to the list of free blocks. */
228 | prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
229 | xFreeBytesRemaining += pxLink->xBlockSize;
230 | traceFREE( pv, pxLink->xBlockSize );
231 | }
232 | ( void ) xTaskResumeAll();
233 | }
234 | }
235 | /*-----------------------------------------------------------*/
236 |
237 | size_t xPortGetFreeHeapSize( void )
238 | {
239 | return xFreeBytesRemaining;
240 | }
241 | /*-----------------------------------------------------------*/
242 |
243 | void vPortInitialiseBlocks( void )
244 | {
245 | /* This just exists to keep the linker quiet. */
246 | }
247 | /*-----------------------------------------------------------*/
248 |
249 | static void prvHeapInit( void )
250 | {
251 | BlockLink_t *pxFirstFreeBlock;
252 | uint8_t *pucAlignedHeap;
253 |
254 | /* Ensure the heap starts on a correctly aligned boundary. */
255 | pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
256 |
257 | /* xStart is used to hold a pointer to the first item in the list of free
258 | blocks. The void cast is used to prevent compiler warnings. */
259 | xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap;
260 | xStart.xBlockSize = ( size_t ) 0;
261 |
262 | /* xEnd is used to mark the end of the list of free blocks. */
263 | xEnd.xBlockSize = configADJUSTED_HEAP_SIZE;
264 | xEnd.pxNextFreeBlock = NULL;
265 |
266 | /* To start with there is a single free block that is sized to take up the
267 | entire heap space. */
268 | pxFirstFreeBlock = ( void * ) pucAlignedHeap;
269 | pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE;
270 | pxFirstFreeBlock->pxNextFreeBlock = &xEnd;
271 | }
272 | /*-----------------------------------------------------------*/
273 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/MemMang/heap_3.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeRTOS Kernel V10.0.1
3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | * this software and associated documentation files (the "Software"), to deal in
7 | * the Software without restriction, including without limitation the rights to
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
10 | * subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 | *
22 | * http://www.FreeRTOS.org
23 | * http://aws.amazon.com/freertos
24 | *
25 | * 1 tab == 4 spaces!
26 | */
27 |
28 |
29 | /*
30 | * Implementation of pvPortMalloc() and vPortFree() that relies on the
31 | * compilers own malloc() and free() implementations.
32 | *
33 | * This file can only be used if the linker is configured to to generate
34 | * a heap memory area.
35 | *
36 | * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the
37 | * memory management pages of http://www.FreeRTOS.org for more information.
38 | */
39 |
40 | #include
41 |
42 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
43 | all the API functions to use the MPU wrappers. That should only be done when
44 | task.h is included from an application file. */
45 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
46 |
47 | #include "FreeRTOS.h"
48 | #include "task.h"
49 |
50 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
51 |
52 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
53 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
54 | #endif
55 |
56 | /*-----------------------------------------------------------*/
57 |
58 | void *pvPortMalloc( size_t xWantedSize )
59 | {
60 | void *pvReturn;
61 |
62 | vTaskSuspendAll();
63 | {
64 | pvReturn = malloc( xWantedSize );
65 | traceMALLOC( pvReturn, xWantedSize );
66 | }
67 | ( void ) xTaskResumeAll();
68 |
69 | #if( configUSE_MALLOC_FAILED_HOOK == 1 )
70 | {
71 | if( pvReturn == NULL )
72 | {
73 | extern void vApplicationMallocFailedHook( void );
74 | vApplicationMallocFailedHook();
75 | }
76 | }
77 | #endif
78 |
79 | return pvReturn;
80 | }
81 | /*-----------------------------------------------------------*/
82 |
83 | void vPortFree( void *pv )
84 | {
85 | if( pv )
86 | {
87 | vTaskSuspendAll();
88 | {
89 | free( pv );
90 | traceFREE( pv, 0 );
91 | }
92 | ( void ) xTaskResumeAll();
93 | }
94 | }
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/portable/readme.txt:
--------------------------------------------------------------------------------
1 | Each real time kernel port consists of three files that contain the core kernel
2 | components and are common to every port, and one or more files that are
3 | specific to a particular microcontroller and/or compiler.
4 |
5 |
6 | + The FreeRTOS/Source/Portable/MemMang directory contains the five sample
7 | memory allocators as described on the http://www.FreeRTOS.org WEB site.
8 |
9 | + The other directories each contain files specific to a particular
10 | microcontroller or compiler, where the directory name denotes the compiler
11 | specific files the directory contains.
12 |
13 |
14 |
15 | For example, if you are interested in the [compiler] port for the [architecture]
16 | microcontroller, then the port specific files are contained in
17 | FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If this is the
18 | only port you are interested in then all the other directories can be
19 | ignored.
20 |
21 |
--------------------------------------------------------------------------------
/FreeRTOS/Source/readme.txt:
--------------------------------------------------------------------------------
1 | Each real time kernel port consists of three files that contain the core kernel
2 | components and are common to every port, and one or more files that are
3 | specific to a particular microcontroller and or compiler.
4 |
5 | + The FreeRTOS/Source directory contains the three files that are common to
6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these
7 | three files. croutine.c implements the optional co-routine functionality - which
8 | is normally only used on very memory limited systems.
9 |
10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to
11 | a particular microcontroller and or compiler.
12 |
13 | + The FreeRTOS/Source/include directory contains the real time kernel header
14 | files.
15 |
16 | See the readme file in the FreeRTOS/Source/Portable directory for more
17 | information.
--------------------------------------------------------------------------------
/FreeRTOS/links_to_doc_pages_for_the_demo_projects.url:
--------------------------------------------------------------------------------
1 | [{000214A0-0000-0000-C000-000000000046}]
2 | Prop3=19,2
3 | [InternetShortcut]
4 | URL=http://www.freertos.org/a00090.html
5 | IDList=
6 |
--------------------------------------------------------------------------------
/FreeRTOS/readme.txt:
--------------------------------------------------------------------------------
1 | Directories:
2 |
3 | + The FreeRTOS/Source directory contains the FreeRTOS source code, and contains
4 | its own readme file.
5 |
6 | + The FreeRTOS/Demo directory contains a demo application for every official
7 | FreeRTOS port, and contains its own readme file.
8 |
9 | + See http://www.freertos.org/a00017.html for full details of the directory
10 | structure and information on locating the files you require.
11 |
12 | The easiest way to use FreeRTOS is to start with one of the pre-configured demo
13 | application projects (found in the FreeRTOS/Demo directory). That way you will
14 | have the correct FreeRTOS source files included, and the correct include paths
15 | configured. Once a demo application is building and executing you can remove
16 | the demo application file, and start to add in your own application source
17 | files.
18 |
19 | See also -
20 | http://www.freertos.org/FreeRTOS-quick-start-guide.html
21 | http://www.freertos.org/FAQHelp.html
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Test commands.
2 | # make run
3 | # Ctrl-A X (Exit)
4 |
5 | # GCC flags
6 | CFLAG = -c
7 | OFLAG = -o
8 | INCLUDEFLAG = -I
9 | CROSS = aarch64-linux-gnu
10 | CC = $(CROSS)-gcc
11 | AS = $(CROSS)-as
12 | LD = $(CROSS)-ld
13 | OBJDUMP = $(CROSS)-objdump
14 | CFLAGS = -mcpu=cortex-a57 -ffreestanding -Wall -Wextra -g -DGUEST
15 | # -mcpu=name
16 | # Specify the name of the target processor
17 | # -Wall
18 | # Turns on all optional warnings which are desirable for normal code
19 | # -Wextra
20 | # This enables some extra warning flags that are not enabled by -Wall
21 | # -g
22 | # Produce debugging information in the operating system's native format.
23 | # GDB can work with this debugging information.
24 | # -DGUEST
25 | # #define GUEST /* At the time of writing, we only supports EL1. */
26 | # -ffreestanding
27 | # Assert that compilation targets a freestanding environment. This
28 | # implies -fno-builtin. A freestanding environment is one in which the
29 | # standard library may not exist, and program startup may not necessarily
30 | # be at "main". The most obvious example is an OS kernel. This is
31 | # equivalent to -fno-hosted.
32 | ASM_FLAGS = -mcpu=cortex-a57 -g
33 |
34 | # Compiler/target path in FreeRTOS/Source/portable
35 | PORT_COMP_TARG = GCC/ARM_CA57_64_BIT/
36 |
37 | # Intermediate directory for all *.o and other files:
38 | OBJDIR = obj/
39 |
40 | # FreeRTOS source base directory
41 | FREERTOS_SRC = ./FreeRTOS/Source/
42 |
43 | # Directory with memory management source files
44 | FREERTOS_MEMMANG_SRC = $(FREERTOS_SRC)portable/MemMang/
45 |
46 | # Directory with platform specific source files
47 | FREERTOS_PORT_SRC = $(FREERTOS_SRC)portable/$(PORT_COMP_TARG)
48 |
49 | # Directory with Application source files
50 | APP_SRC = ./FreeRTOS/Demo/CORTEX_A57_64-bit/
51 |
52 | # Due to a large number, the .o files are arranged into logical groups:
53 |
54 | FREERTOS_OBJS = queue.o list.o tasks.o
55 | # The following o. files are only necessary if
56 | # certain options are enabled in FreeRTOSConfig.h
57 | FREERTOS_OBJS += timers.o
58 | #FREERTOS_OBJS += croutine.o
59 | #FREERTOS_OBJS += event_groups.o
60 | #FREERTOS_OBJS += stream_buffer.o
61 |
62 | # Only one memory management .o file must be uncommented!
63 | FREERTOS_MEMMANG_OBJS = heap_1.o
64 | #FREERTOS_MEMMANG_OBJS = heap_2.o
65 | #FREERTOS_MEMMANG_OBJS = heap_3.o
66 | #FREERTOS_MEMMANG_OBJS = heap_4.o
67 | #FREERTOS_MEMMANG_OBJS = heap_5.o
68 |
69 |
70 | # FREERTOS_PORT_OBJS = port.o portISR.o
71 | FREERTOS_PORT_OBJS = port.o portASM.o
72 |
73 | APP_OBJS = main.o start.o FreeRTOS_asm_vectors.o FreeRTOS_tick_config.o
74 | APP_OBJS += vectors.o exception.o sysctrl.o pstate.o gic_v3.o uart.o
75 | APP_OBJS += printf-stdarg.o example.o
76 | # nostdlib.o must be commented out if standard lib is going to be linked!
77 | APP_OBJS += nostdlib.o
78 |
79 |
80 | # All object files specified above are prefixed the intermediate directory
81 | OBJS = $(addprefix $(OBJDIR), $(FREERTOS_OBJS) $(FREERTOS_MEMMANG_OBJS) $(FREERTOS_PORT_OBJS) $(APP_OBJS) )
82 |
83 | ELF_IMAGE = image.elf
84 |
85 | # Include paths to be passed to $(CC) where necessary
86 | INC_FREERTOS = $(FREERTOS_SRC)include/
87 | INC_APP = $(APP_SRC)include/
88 |
89 | # Complete include flags to be passed to $(CC) where necessary
90 | INC_FLAGS = $(INCLUDEFLAG)$(INC_FREERTOS) $(INCLUDEFLAG)$(INC_APP) $(INCLUDEFLAG)$(FREERTOS_PORT_SRC)
91 |
92 |
93 | all: $(OBJDIR) $(ELF_IMAGE)
94 |
95 | $(OBJDIR) :
96 | mkdir -p $@
97 |
98 | $(ELF_IMAGE): $(APP_SRC)linker.ld $(OBJS)
99 | $(LD) -T $(APP_SRC)linker.ld $^ -o $@
100 | $(OBJDUMP) -D $(ELF_IMAGE) > image.list
101 |
102 | # FreeRTOS core
103 |
104 | $(OBJDIR)%.o : $(FREERTOS_SRC)%.c
105 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
106 |
107 | # Rules for all MemMang implementations are provided
108 | # Only one of these object files must be linked to the final target
109 |
110 | $(OBJDIR)%.o : $(FREERTOS_MEMMANG_SRC)%.c
111 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
112 |
113 | # HW specific part, in FreeRTOS/Source/portable/$(PORT_COMP_TARGET)
114 |
115 | $(OBJDIR)%.o : $(FREERTOS_PORT_SRC)%.c
116 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
117 |
118 | $(OBJDIR)%.o : $(FREERTOS_PORT_SRC)%.S
119 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
120 |
121 | # Demo application
122 |
123 | $(OBJDIR)%.o : $(APP_SRC)%.S
124 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
125 |
126 | $(OBJDIR)%.o : $(APP_SRC)%.c
127 | $(CC) $(CFLAG) $(CFLAGS) $(INC_FLAGS) $< $(OFLAG) $@
128 |
129 | run:
130 | $(MAKE) all
131 | # qemu-system-aarch64 -machine virt -cpu cortex-a57 -m 128 -serial stdio -nographic -nodefaults -kernel kernel.elf
132 | qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -kernel $(ELF_IMAGE)
133 |
134 | gen_tags: clean_tags
135 | ./gen_tags.sh
136 |
137 | clean_tags:
138 | rm -rf tags cscope*
139 |
140 | clean:
141 | rm -f *.o *.elf *.list
142 | rm -rf $(OBJDIR)
143 |
144 | .PHONY: run gen_tags clean_tags clean
145 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # port_freertos_to_qemu_a57_virt
2 | * Porting FreeRTOS to QEMU (-M virt -cpu cortex-a57). I am studying now.
3 | * The booting procedure bases from [u-boot](u-boot/u-boot)
4 | * The FreeRTOS project bases from FreeRTOSv10.0.1/FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC
5 | * Currently, the default exception level in booting is EL1.
6 | * Status
7 | * Basic Uart works.
8 | * uart_putc(), uart_puts(), uart_puthex()
9 | * Basic FreeRTOS works.
10 | * configASSERT(), xTaskCreate(), vTaskStartScheduler()
11 | * printf() works.
12 | * Basic examples work.
13 | * Queue, Mutex, Binary Semaphore and software timer.
14 | * Branch: nvdla_test
15 | * Porting vp/tests/nvdla_bdma_mmio Successfully.
16 | * Porting kernel driver. (Halt)
17 | * We need drm.ko and opendla.ko. But drm.ko is prebuilt, there is no source code.
18 |
19 | # Issues
20 | * GDB can't step into main() if missing lable: magic_label in start.S (commit 0ddf0c433d759b763c84106ee4810e5f809a78c3)
21 |
22 | # Reference:
23 | * Project:
24 | * [aarch64-bare-metal-qemu]( https://github.com/freedomtan/aarch64-bare-metal-qemu).
25 | * Directly using UARTDR(UART Data Register) to send out the characters.
26 | * [ARM926 interrupts in QEMU](https://balau82.wordpress.com/2012/04/15/arm926-interrupts-in-qemu/)
27 | * The basic uart interrupt example
28 | * [FreeRTOS-GCC-ARM926ejs](https://github.com/jkovacic/FreeRTOS-GCC-ARM926ejs)
29 | * [ARM9EJ-S Technical Reference Manual - DDI0222](http://infocenter.arm.com/help/topic/com.arm.doc.ddi0222b/DDI0222.pdf)
30 | * [Building Bare-Metal ARM Systems with GNU: Part 2](https://www.embedded.com/design/mcus-processors-and-socs/4026075/Building-Bare-Metal-ARM-Systems-with-GNU-Part-2)
31 | * [raspberrypi](https://github.com/eggman/raspberrypi)
32 | * [sample-tsk-sw](https://github.com/takeharukato/sample-tsk-sw)
33 | * [armv8-bare-metal](https://github.com/NienfengYao/armv8-bare-metal)
34 | * My study, including the basic booting, gic and timer
35 | * FreeRTOSv10.0.1/FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC
36 | * QEMU
37 | * [QEMU version 2.12.50 User Documentation](https://qemu.weilnetz.de/doc/qemu-doc.html)
38 | * [virt.c](https://github.com/qemu/qemu/blob/master/hw/arm/virt.c)
39 | * Makefile
40 | * [Makefile範例教學](http://maxubuntu.blogspot.com/2010/02/makefile.html)
41 | * [GNU 的連結工具 (ld, nm, objdump, ar)](http://sp1.wikidot.com/gnulinker)
42 | * [GCC Command-Line Options](http://tigcc.ticalc.org/doc/comopts.html)
43 | * [LD Index](https://sourceware.org/binutils/docs/ld/LD-Index.html#LD-Index)
44 | * FreeRTOS
45 | * Start
46 | * [Creating a New FreeRTOS Project](https://www.freertos.org/Creating-a-new-FreeRTOS-project.html)
47 | * [FreeRTOS Quick Start Guide](https://www.freertos.org/FreeRTOS-quick-start-guide.html)
48 | * [Getting Started with Simple FreeRTOS Projects](https://www.freertos.org/simple-freertos-demos.html)
49 | * [Hardware independent FreeRTOS example](https://www.freertos.org/Hardware-independent-RTOS-example.html)
50 | * [FreeRTOS Tutorial](http://socialledge.com/sjsu/index.php/FreeRTOS_Tutorial)
51 | * [Coding Standard and Style Guide](https://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html)
52 | * Memory
53 | * [Memory Management](https://www.freertos.org/a00111.html)
54 | * [Static Vs Dynamic Memory Allocation](https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html)
55 | * [Statically Allocated FreeRTOS Reference Project](https://www.freertos.org/freertos-static-allocation-demo.html)
56 | * GIC
57 | * [That incorporate a Generic Interrupt Controller (GIC)](https://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html)
58 | * [淺談優先權,從ARM Cortex-M到FreeRTOS設定](http://opass.logdown.com/posts/248297-talking-about-the-priority-from-the-arm-set-cortex-m-to-freertos)
59 | * [FreeRTOS Tutorial](http://socialledge.com/sjsu/index.php/FreeRTOS_Tutorial)
60 | * [xTimerCreate](https://www.freertos.org/FreeRTOS-timers-xTimerCreate.html)
61 | * U-Boot
62 | * [U-Boot on QEMU's 'virt' machine on ARM & AArch64](https://github.com/u-boot/u-boot/blob/master/doc/README.qemu-arm)
63 | * [What is the difference between ELF files and bin files?](https://stackoverflow.com/questions/2427011/what-is-the-difference-between-elf-files-and-bin-files?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa)
64 | * [U-BOOT-2016.07移植 (第一篇) 初步分析](http://www.itread01.com/articles/1476615343.html)
65 | * GDB
66 | * [GNU GDB Debugger Command Cheat Sheet](http://www.yolinux.com/TUTORIALS/GDB-Commands.html)
67 | * [Debugging with GDB (入門篇)](http://www.study-area.org/goldencat/debug.htm)
68 | * [GDB Debugging ARM U-Boot on QEMU](http://winfred-lu.blogspot.com/2011/12/arm-u-boot-on-qemu.html)
69 | * [Use Qemu GDB to forcely debug Linux early boot process ](https://mudongliang.github.io/2017/09/21/use-qemu-gdb-to-forcely-debug-linux-early-boot-process.html)
70 | * [how can one see content of stack with gdb](https://stackoverflow.com/questions/7848771/how-can-one-see-content-of-stack-with-gdb)
71 | * [10.6 Examining Memory](https://sourceware.org/gdb/onlinedocs/gdb/Memory.html)
72 | * ARM
73 | * [iOS开发同学的arm64汇编入门](https://blog.cnbluebox.com/blog/2017/07/24/arm64-start/)
74 | * [Arm® Compiler armasm User Guide](http://www.keil.com/support/man/docs/armclang_asm/armclang_asm_chunk708094578.htm)
75 | * [Application Note Bare-metal Boot Code for ARMv8-A Processors Version 1.0](http://infocenter.arm.com/help/topic/com.arm.doc.dai0527a/DAI0527A_baremetal_boot_code_for_ARMv8_A_processors.pdf)
76 | * ARM® Architecture Reference Manual ARMv8, for ARMv8-A architecture profile Beta
77 | * ARM® Cortex®-A57 MPCore™ Processor Revision: r1p0 Technical Reference Manual
78 | * ARM® Cortex®-A Series Version: 1.0 Programmer’s Guide for ARMv8-A
79 | * ARM® Generic Interrupt Controller Architecture Specification GIC architecture version 3.0 and version 4.0
80 | * Compile
81 | * [GNU 的連結工具 (ld, nm, objdump, ar)](http://sp1.wikidot.com/gnulinker)
82 | * Makefile
83 | * [Makefile的賦值運算符(=, :=, +=, ?=)](http://dannysun-unknown.blogspot.com/2015/03/makefile.html)
84 | * GCC
85 | * [GCC Command-Line Options](http://tigcc.ticalc.org/doc/comopts.html)
86 | * Weak symbol
87 | * [弱符號 - 維基百科](https://zh.wikipedia.org/wiki/%E5%BC%B1%E7%AC%A6%E5%8F%B7)
88 | * [Weak references and definitions](http://www.keil.com/support/man/docs/armclang_link/armclang_link_pge1362065917715.htm)
89 | * Assembler
90 | * [Writing ARM Assembly Language](http://www.keil.com/support/man/docs/armasm/armasm_dom1359731144635.htm)
91 | * [ARM組語備忘錄](https://myao0730.blogspot.com/2015/09/arm-aapcs-def-procedure-call-standard.html)
92 | * [Using as](https://sourceware.org/binutils/docs/as/index.html#SEC_Contents)
93 | * printf()
94 | * [Write your own printf() function in c](http://www.firmcodes.com/write-printf-function-c/)
95 | * [Wiki: stdarg.h](https://zh.wikipedia.org/wiki/Stdarg.h)
96 | * [printf-stdarg.c](https://github.com/atgreen/FreeRTOS/blob/master/Demo/CORTEX_STM32F103_Primer_GCC/printf-stdarg.c)
97 |
98 |
--------------------------------------------------------------------------------
/gen_tags.sh:
--------------------------------------------------------------------------------
1 | find ./ -name "*.[chsS]" -print >> cscope.files
2 | cscope -bkq -i cscope.files
3 | ctags -R
4 |
--------------------------------------------------------------------------------