source: rtems/bsps/arm/tms570/start/tms570-pom.c @ a62c75c1

5
Last change on this file since a62c75c1 was a62c75c1, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/18 at 13:38:55

bsp/tms570: Move more start to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/**
2 * @file tms570-pom.c
3 *
4 * @ingroup tms570
5 *
6 * @brief TMS570 Parameter Overlay Module functions definitions.
7 */
8
9 /*
10 * Copyright (c) 2014 Pavel Pisa <pisa@cmp.felk.cvut.cz>
11 *
12 * Czech Technical University in Prague
13 * Zikova 1903/4
14 * 166 36 Praha 6
15 * Czech Republic
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#include <stdint.h>
23#include <string.h>
24#include <bsp/tms570-pom.h>
25#include <bsp/linker-symbols.h>
26#include <rtems/score/armv4.h>
27#include <bsp.h>
28
29/*
30 * Placement of exceptions target addresses in memory
31 * when insructions with opcode 0xe59ff018
32 *      ldr pc, [pc, #0x18]
33 * are used to fill ARM exception vectors area
34 */
35typedef struct{
36  uint32_t reserved1;
37  uint32_t except_addr_undef;
38  uint32_t except_addr_swi;
39  uint32_t except_addr_prefetch;
40  uint32_t except_addr_abort;
41  uint32_t reserved2;
42  uint32_t except_addr_irq;
43  uint32_t except_addr_fiq;
44}vec_remap_table;
45
46void bsp_block_on_exception(void);
47
48void bsp_block_on_exception(void){
49  while(1);
50}
51
52extern char bsp_int_vec_overlay_start[];
53
54/*
55 * Global overlay target address holds shared MSB bits for all regions
56 * It is set to linker RAM_INT_VEC region - i.e. area reserved
57 * at internal SRAM memory start, address 0x08000000
58 */
59uint32_t pom_global_overlay_target_address_start =
60                                 (uintptr_t)bsp_int_vec_overlay_start;
61
62/**
63 * @brief initialize and clear parameters overlay module (POM)
64 *
65 * clears all remap regions. The actual POM enable is left to the first user.
66 *
67 * @retval Void
68 */
69void tms570_initialize_and_clear(void)
70{
71  int i;
72
73  TMS570_POM.GLBCTRL = 0 | (TMS570_POM_GLBCTRL_OTADDR(~0) &
74                            pom_global_overlay_target_address_start);
75
76  for ( i = 0; i < TMS570_POM_REGIONS; ++i ) {
77    TMS570_POM.REG[i].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_DISABLED);
78  }
79}
80
81/**
82 * @brief remaps vector table
83 *
84 * transfer the rtems start vector table to address 0x0
85 *
86 * @retval Void
87 */
88void tms570_pom_remap(void)
89{
90  uint32_t vec_overlay_start = pom_global_overlay_target_address_start;
91
92  /*
93   * Copy RTEMS the first level exception processing code
94   * to RAM area which can be used for later as POM overlay
95   * of Flash vectors. The code is expected to have for of eight
96   *   ldr pc, [pc,#0x18]
97   * instructions followed by eight words with actual exception
98   * service routines target addresses. This is case of RTEMS default
99   * table found in
100   *   c/src/lib/libbsp/arm/shared/start/start.S
101   */
102  memcpy((void*)vec_overlay_start, bsp_start_vector_table_begin, 64);
103
104  #if 0
105  {
106    /* Fill exception table by catch error infinite loop for debugging */
107    vec_remap_table* vec_table = (vec_remap_table*)(vec_overlay_start+32);
108    vec_table->except_addr_undef = (uint32_t)bsp_block_on_exception;
109    vec_table->except_addr_swi = (uint32_t)bsp_block_on_exception;
110    vec_table->except_addr_prefetch = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_prefetch_abort;
111    vec_table->except_addr_abort = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_data_abort;
112    vec_table->except_addr_irq = (uint32_t)_ARMV4_Exception_interrupt;
113    vec_table->except_addr_fiq = (uint32_t)bsp_block_on_exception;//_ARMV4_Exception_interrupt;
114  }
115  #endif
116
117  /*
118   * The overlay vectors replacement area cannot be used directly
119   * to replace jump instructions on start of Flash because instruction
120   * fetch through POM is not reliable supported (works in most times
121   * but sometimes fails).
122   * Area of 64 bytes starting at address 0x00000040 is replaced.
123   * This way target addresses are placed between 0x00000060
124   * and 0x0000007F. If boot loader startup code contains instructions
125   *   ldr pc,[pc,#0x58]
126   * (opcode 0xe59ff058) then the jump target addresses are replaced
127   * by pointers to actual RTEMS exceptions service functions.
128   */
129  TMS570_POM.REG[0].PROGSTART = TMS570_POM_PROGSTART_STARTADDRESS(64);
130  TMS570_POM.REG[0].OVLSTART = TMS570_POM_OVLSTART_STARTADDRESS(vec_overlay_start);
131  TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_64B);
132  TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ON_OFF(0xa) |
133                       TMS570_POM_GLBCTRL_ETO(0xa) |
134                       (TMS570_POM_GLBCTRL_OTADDR(~0) &
135                        pom_global_overlay_target_address_start);
136}
Note: See TracBrowser for help on using the repository browser.