1 | /* |
---|
2 | * Copyright (c) 2013 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <info@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <libcpu/arm-cp15.h> |
---|
16 | |
---|
17 | #include <bsp/linker-symbols.h> |
---|
18 | |
---|
19 | void arm_cp15_set_exception_handler( |
---|
20 | Arm_symbolic_exception_name exception, |
---|
21 | void (*handler)(void), |
---|
22 | uint32_t section_flags_for_mirror_table_access |
---|
23 | ) |
---|
24 | { |
---|
25 | if ((unsigned) exception < MAX_EXCEPTIONS) { |
---|
26 | uint32_t *cpu_table = (uint32_t *) 0 + MAX_EXCEPTIONS; |
---|
27 | uint32_t *mirror_table = (uint32_t *) bsp_vector_table_begin + MAX_EXCEPTIONS; |
---|
28 | uint32_t current_handler = mirror_table[exception]; |
---|
29 | |
---|
30 | if (current_handler != (uint32_t) handler) { |
---|
31 | size_t table_size = MAX_EXCEPTIONS * sizeof(uint32_t); |
---|
32 | uint32_t cls = arm_cp15_get_min_cache_line_size(); |
---|
33 | uint32_t ctrl; |
---|
34 | rtems_interrupt_level level; |
---|
35 | |
---|
36 | rtems_interrupt_disable(level); |
---|
37 | |
---|
38 | ctrl = arm_cp15_mmu_disable(cls); |
---|
39 | |
---|
40 | mirror_table[exception] = (uint32_t) handler; |
---|
41 | rtems_cache_flush_multiple_data_lines(mirror_table, table_size); |
---|
42 | rtems_cache_invalidate_multiple_instruction_lines(cpu_table, table_size); |
---|
43 | |
---|
44 | arm_cp15_set_control(ctrl); |
---|
45 | |
---|
46 | rtems_interrupt_enable(level); |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|