![]() |
|
|||
File indexing completed on 2025-05-11 08:23:39
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSBSPsARMTMS570 0007 * 0008 * @brief This source file contains the Parameter Overlay Module (POM) support 0009 * implementation. 0010 */ 0011 0012 /* 0013 * Copyright (C) 2014 Pavel Pisa <pisa@cmp.felk.cvut.cz> 0014 * 0015 * Czech Technical University in Prague 0016 * Zikova 1903/4 0017 * 166 36 Praha 6 0018 * Czech Republic 0019 * 0020 * Redistribution and use in source and binary forms, with or without 0021 * modification, are permitted provided that the following conditions 0022 * are met: 0023 * 1. Redistributions of source code must retain the above copyright 0024 * notice, this list of conditions and the following disclaimer. 0025 * 2. Redistributions in binary form must reproduce the above copyright 0026 * notice, this list of conditions and the following disclaimer in the 0027 * documentation and/or other materials provided with the distribution. 0028 * 0029 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0030 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0031 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0032 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0033 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0034 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0035 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0036 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0037 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0038 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0039 * POSSIBILITY OF SUCH DAMAGE. 0040 */ 0041 0042 #include <stdint.h> 0043 #include <string.h> 0044 #include <bsp/tms570-pom.h> 0045 #include <bsp/linker-symbols.h> 0046 #include <rtems/score/armv4.h> 0047 #include <bsp.h> 0048 0049 /* 0050 * Placement of exceptions target addresses in memory 0051 * when insructions with opcode 0xe59ff018 0052 * ldr pc, [pc, #0x18] 0053 * are used to fill ARM exception vectors area 0054 */ 0055 typedef struct{ 0056 uint32_t reserved1; 0057 uint32_t except_addr_undef; 0058 uint32_t except_addr_swi; 0059 uint32_t except_addr_prefetch; 0060 uint32_t except_addr_abort; 0061 uint32_t reserved2; 0062 uint32_t except_addr_irq; 0063 uint32_t except_addr_fiq; 0064 }vec_remap_table; 0065 0066 void bsp_block_on_exception(void); 0067 0068 void bsp_block_on_exception(void){ 0069 while(1); 0070 } 0071 0072 extern char bsp_int_vec_overlay_start[]; 0073 0074 /* 0075 * Global overlay target address holds shared MSB bits for all regions 0076 * It is set to linker RAM_INT_VEC region - i.e. area reserved 0077 * at internal SRAM memory start, address 0x08000000 0078 */ 0079 uint32_t pom_global_overlay_target_address_start = 0080 (uintptr_t)bsp_int_vec_overlay_start; 0081 0082 /** 0083 * @brief initialize and clear parameters overlay module (POM) 0084 * 0085 * clears all remap regions. The actual POM enable is left to the first user. 0086 * 0087 * @retval Void 0088 */ 0089 void tms570_pom_initialize_and_clear(void) 0090 { 0091 int i; 0092 0093 TMS570_POM.GLBCTRL = 0 | (TMS570_POM_GLBCTRL_OTADDR(~0) & 0094 pom_global_overlay_target_address_start); 0095 0096 for ( i = 0; i < TMS570_POM_REGIONS; ++i ) { 0097 TMS570_POM.REG[i].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_DISABLED); 0098 } 0099 } 0100 0101 /** 0102 * @brief remaps vector table 0103 * 0104 * transfer the rtems start vector table to address 0x0 0105 * 0106 * @retval Void 0107 */ 0108 void tms570_pom_remap(void) 0109 { 0110 void *vec_overlay_start = (void *) pom_global_overlay_target_address_start; 0111 void *addr_tab = (char *) bsp_start_vector_table_begin + 64; 0112 0113 if (vec_overlay_start == addr_tab) { 0114 return; 0115 } 0116 0117 /* 0118 * Copy RTEMS the first level exception processing code 0119 * to RAM area which can be used for later as POM overlay 0120 * of Flash vectors. The code is expected to have for of eight 0121 * ldr pc, [pc,#0x18] 0122 * instructions followed by eight words with actual exception 0123 * service routines target addresses. This is case of RTEMS default 0124 * table found in 0125 * c/src/lib/libbsp/arm/shared/start/start.S 0126 */ 0127 rtems_cache_invalidate_multiple_data_lines(addr_tab, 64); 0128 memcpy(vec_overlay_start, addr_tab, 64); 0129 rtems_cache_flush_multiple_data_lines(vec_overlay_start, 64); 0130 rtems_cache_invalidate_multiple_instruction_lines(vec_overlay_start, 64); 0131 0132 #if 0 0133 { 0134 /* Fill exception table by catch error infinite loop for debugging */ 0135 vec_remap_table* vec_table = (vec_remap_table*)(vec_overlay_start+32); 0136 vec_table->except_addr_undef = (uint32_t)bsp_block_on_exception; 0137 vec_table->except_addr_swi = (uint32_t)bsp_block_on_exception; 0138 vec_table->except_addr_prefetch = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_prefetch_abort; 0139 vec_table->except_addr_abort = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_data_abort; 0140 vec_table->except_addr_irq = (uint32_t)_ARMV4_Exception_interrupt; 0141 vec_table->except_addr_fiq = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_interrupt; 0142 } 0143 #endif 0144 0145 /* 0146 * The overlay vectors replacement area cannot be used directly 0147 * to replace jump instructions on start of Flash because instruction 0148 * fetch through POM is not reliable supported (works in most times 0149 * but sometimes fails). 0150 * Area of 64 bytes starting at address 0x00000040 is replaced. 0151 * This way target addresses are placed between 0x00000060 0152 * and 0x0000007F. If boot loader startup code contains instructions 0153 * ldr pc,[pc,#0x58] 0154 * (opcode 0xe59ff058) then the jump target addresses are replaced 0155 * by pointers to actual RTEMS exceptions service functions. 0156 */ 0157 TMS570_POM.REG[0].PROGSTART = TMS570_POM_PROGSTART_STARTADDRESS(64); 0158 TMS570_POM.REG[0].OVLSTART = TMS570_POM_OVLSTART_STARTADDRESS(vec_overlay_start); 0159 TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_64B); 0160 TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ON_OFF(0xa) | 0161 TMS570_POM_GLBCTRL_ETO(0xa) | 0162 (TMS570_POM_GLBCTRL_OTADDR(~0) & 0163 pom_global_overlay_target_address_start); 0164 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |