1 /* Copyright (C) 2013 Czech Technical University in Prague
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
28 * File : pom_vect_remap.c
30 * Setup of parameter overlay module which remaps SRAM areal
31 * over exception vectors at start of the Flash which enables
32 * to redirect them to application load into SDRAM, SRAM
33 * or placed after bootblock in the Flash
36 * RPP API documentation.
40 #include <sys/ti_drv_pom.h>
42 #define POM_REGIONS 32
43 #define POM_SIZE_DISABLED 0
44 #define POM_REGADDRMASK ((1<<23)-1)
45 #define POM_GLBCTRL_ENABLE 0x000000a0a
46 #define ARM_MAX_EXCEPTIONS 8
48 #pragma DATA_ALIGN(pom_vector_overlay, 64)
49 uint32_t pom_vector_overlay[2*ARM_MAX_EXCEPTIONS];
53 2 b vPortYieldProcessor
61 extern void _dabort(void);
62 extern void vPortYieldProcessor(void);
64 void pom_set_cpu_exception_handler(int cpu_exception, uint32_t target_addr)
67 /* e59ff018 ldr pc, [pc, #24] */
68 pom_vector_overlay[cpu_exception] = 0xe59ff000+(ARM_MAX_EXCEPTIONS*4-8);
69 pom_vector_overlay[cpu_exception+ARM_MAX_EXCEPTIONS] = target_addr;
73 * @brief remaps vector table
75 * transfer the rtems start vector table to address 0x0
79 void pom_vectors_remap(void)
82 uint32_t vec_overlay_start = (uint32_t)pom_vector_overlay;
84 pomREG->POMGLBCTRL_UL = 0;
86 memcpy(pom_vector_overlay, (void *)(volatile void *)0x0, 64);
87 pom_set_cpu_exception_handler(2, (uint32_t)vPortYieldProcessor);
88 pom_set_cpu_exception_handler(4, (uint32_t)_dabort);
89 /* ldr pc,[pc,#-0x1b0] */
90 pom_vector_overlay[6] = 0xe51ff1b0;
91 /* ldr pc,[pc,#-0x1b0] */
92 pom_vector_overlay[7] = 0xe51ff1b0;
95 for ( i = 0; i < POM_REGIONS; ++i ) {
96 pomREG->POMRGNCONF_ST[i].POMREGSIZE_UL = POM_SIZE_DISABLED;
99 pomREG->POMRGNCONF_ST[0].POMPROGSTART_UL = 0x0 & POM_REGADDRMASK;
100 pomREG->POMRGNCONF_ST[0].POMOVLSTART_UL = vec_overlay_start & POM_REGADDRMASK;
101 pomREG->POMRGNCONF_ST[0].POMREGSIZE_UL = SIZE_64BYTES;
103 pomREG->POMGLBCTRL_UL = POM_GLBCTRL_ENABLE |
104 (vec_overlay_start & ~POM_REGADDRMASK);