Ticket #2023: 0014-Fixes-updates-and-improvements-to-virtex5-BSP.patch
File 0014-Fixes-updates-and-improvements-to-virtex5-BSP.patch, 28.2 KB (added by Ric Claus, on 03/02/12 at 01:01:09) |
---|
-
c/src/lib/libbsp/powerpc/virtex5/Makefile.am
From 7b3f41ca66d4c9a12aa25b600621d341574cbb99 Mon Sep 17 00:00:00 2001 From: Ric Claus <claus@SLAC.Stanford.edu> Date: Thu, 1 Mar 2012 17:31:11 -0800 Subject: [PATCH 14/14] Fixes, updates and improvements to virtex5 BSP --- c/src/lib/libbsp/powerpc/virtex5/Makefile.am | 20 +- c/src/lib/libbsp/powerpc/virtex5/configure.ac | 10 +- c/src/lib/libbsp/powerpc/virtex5/include/bsp.h | 9 +- c/src/lib/libbsp/powerpc/virtex5/include/irq.h | 76 ++++- c/src/lib/libbsp/powerpc/virtex5/irq/irq_init.c | 328 ++++++++++++++++++++ c/src/lib/libbsp/powerpc/virtex5/preinstall.am | 8 +- .../lib/libbsp/powerpc/virtex5/startup/bspclean.c | 12 +- .../lib/libbsp/powerpc/virtex5/startup/bspstart.c | 97 ++++-- .../libbsp/powerpc/virtex5/startup/dummy_console.c | 36 ++- c/src/lib/libbsp/powerpc/virtex5/startup/linkcmds | 8 +- 10 files changed, 542 insertions(+), 62 deletions(-) create mode 100644 c/src/lib/libbsp/powerpc/virtex5/irq/irq_init.c diff --git a/c/src/lib/libbsp/powerpc/virtex5/Makefile.am b/c/src/lib/libbsp/powerpc/virtex5/Makefile.am index 0e47953..5952497 100644
a b include_bspdir = $(includedir)/bsp 11 11 dist_project_lib_DATA = bsp_specs 12 12 13 13 # include 14 include_HEADERS = include/bsp.h 15 #include_HEADERS += include/tm27.h 14 include_HEADERS = include/bsp.h 15 include_HEADERS += ../../shared/include/tm27.h 16 17 include_bsp_HEADERS = 16 18 17 19 nodist_include_HEADERS = include/bspopts.h 20 nodist_include_HEADERS += include/coverhd.h 18 21 nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h 19 22 DISTCLEANFILES = include/bspopts.h 20 23 21 nodist_include_HEADERS += include/coverhd.h22 23 24 # start 24 25 noinst_LIBRARIES = libbspstart.a 25 26 libbspstart_a_SOURCES = ../../powerpc/shared/start/rtems_crti.S … … libbsp_a_SOURCES = startup/bspclean.c \ 43 44 # start 44 45 libbsp_a_SOURCES += startup/start.S 45 46 46 # clock 47 libbsp_a_SOURCES += ../shared/clock/clock.c 47 # clock & timer 48 libbsp_a_SOURCES += ../../../libcpu/@RTEMS_CPU@/ppc403/clock/clock.c 49 libbsp_a_SOURCES += ../../../libcpu/@RTEMS_CPU@/ppc403/timer/timer.c 48 50 49 51 # console 50 52 libbsp_a_SOURCES += startup/dummy_console.c \ 51 53 ../../shared/dummy_printk_support.c 52 54 53 55 # irq 54 include_bsp_HEADERS = include/irq.h 56 include_bsp_HEADERS += include/irq.h 57 libbsp_a_SOURCES += irq/irq_init.c 55 58 56 59 #vectors 57 60 include_bsp_HEADERS += ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/vectors.h … … include_bsp_HEADERS += ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/irq_s 59 62 60 63 libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/@exceptions@/rtems-cpu.rel \ 61 64 ../../../libcpu/@RTEMS_CPU@/@exceptions@/exc_bspsupport.rel \ 62 ../../../libcpu/@RTEMS_CPU@/@exceptions@/irq_bspsupport.rel \63 65 ../../../libcpu/@RTEMS_CPU@/shared/cache.rel \ 64 66 ../../../libcpu/@RTEMS_CPU@/shared/cpuIdent.rel 65 67 66 EXTRA_DIST = 68 EXTRA_DIST = times 67 69 68 70 include $(srcdir)/preinstall.am 69 71 include $(top_srcdir)/../../../../automake/local.am -
c/src/lib/libbsp/powerpc/virtex5/configure.ac
diff --git a/c/src/lib/libbsp/powerpc/virtex5/configure.ac b/c/src/lib/libbsp/powerpc/virtex5/configure.ac index 85a4cbc..7abff1b 100644
a b RTEMS_CANONICALIZE_TOOLS 16 16 RTEMS_PROG_CCAS 17 17 18 18 RTEMS_CHECK_NETWORKING 19 20 19 AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes") 21 20 21 RTEMS_BSPOPTS_SET([PPC_USE_DATA_CACHE],[*],[1]) 22 RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE], 23 [If defined, then the PowerPC specific code in RTEMS will use 24 data cache instructions to optimize the context switch code. 25 This code can conflict with debuggers or emulators. It is known 26 to break the Corelis PowerPC emulator with at least some combinations 27 of PowerPC 603e revisions and emulator versions. 28 The BSP actually contains the call that enables this.]) 29 22 30 RTEMS_BSPOPTS_SET([PPC_USE_SPRG],[*],[1]) 23 31 RTEMS_BSPOPTS_HELP([PPC_USE_SPRG], 24 32 [If defined, then the PowerPC specific code in RTEMS will use some -
c/src/lib/libbsp/powerpc/virtex5/include/bsp.h
diff --git a/c/src/lib/libbsp/powerpc/virtex5/include/bsp.h b/c/src/lib/libbsp/powerpc/virtex5/include/bsp.h index 3580b3c..1ae242a 100644
a b extern "C" { 53 53 * confdefs.h overrides for this BSP: 54 54 * - Interrupt stack space is not minimum if defined. 55 55 */ 56 57 56 #define CONFIGURE_INTERRUPT_STACK_MEMORY (16 * 1024) 58 57 59 58 #ifdef ASM … … extern "C" { 66 65 #include <rtems/clockdrv.h> 67 66 #include <rtems/iosupp.h> 68 67 68 /* miscellaneous stuff assumed to exist */ 69 extern bool bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ 70 71 extern rtems_configuration_table BSP_Configuration; /* owned by BSP */ 69 72 #endif /* ASM */ 70 73 74 void BSP_ask_for_reset(void); 75 void BSP_panic(char *s); 76 void _BSP_Fatal_error(unsigned int v); 77 71 78 #ifdef __cplusplus 72 79 } 73 80 #endif -
c/src/lib/libbsp/powerpc/virtex5/include/irq.h
diff --git a/c/src/lib/libbsp/powerpc/virtex5/include/irq.h b/c/src/lib/libbsp/powerpc/virtex5/include/irq.h index 92a7207..2edf6aa 100644
a b 1 #ifndef VIRTEX5_RTEMSBSP_IRQ_H 2 #define VIRTEX5_RTEMSBSP_IRQ_H 1 /*===============================================================*\ 2 | Project: RTEMS virtex BSP | 3 +-----------------------------------------------------------------+ 4 | Copyright (c) 2007 | 5 | Embedded Brains GmbH | 6 | Obere Lagerstr. 30 | 7 | D-82178 Puchheim | 8 | Germany | 9 | rtems@embedded-brains.de | 10 +-----------------------------------------------------------------+ 11 | The license and distribution terms for this file may be | 12 | found in the file LICENSE in this distribution or at | 13 | | 14 | http://www.rtems.com/license/LICENSE. | 15 | | 16 +-----------------------------------------------------------------+ 17 | this file declares constants of the interrupt controller | 18 \*===============================================================*/ 19 #ifndef VIRTEX5_IRQ_IRQ_H 20 #define VIRTEX5_IRQ_IRQ_H 3 21 4 # warning "virtex5 BSP's <bsp/irq.h> is BOGUS; this BSP implements no interrupt handling. This header exists to get everything to compile."22 #include <rtems/irq.h> 5 23 6 #define BSP_SHARED_HANDLER_SUPPORT 1 24 /* 25 * the following definitions specify the indices used 26 * to interface the interrupt handler API 27 */ 7 28 8 #include <rtems/irq.h> 29 /* 30 * Peripheral IRQ handlers related definitions 31 */ 32 /* Not supported at this level */ 33 34 /* 35 * Processor IRQ handlers related definitions 36 */ 37 #define BSP_PROCESSOR_IRQ_NUMBER 3 38 #define BSP_PROCESSOR_IRQ_LOWEST_OFFSET 0 39 #define BSP_PROCESSOR_IRQ_MAX_OFFSET (BSP_PROCESSOR_IRQ_LOWEST_OFFSET\ 40 +BSP_PROCESSOR_IRQ_NUMBER-1) 41 42 #define BSP_IS_PROCESSOR_IRQ(irqnum) \ 43 (((irqnum) >= BSP_PROCESSOR_IRQ_LOWEST_OFFSET) && \ 44 ((irqnum) <= BSP_PROCESSOR_IRQ_MAX_OFFSET)) 9 45 10 46 /* 11 * The following symbols must be defined properly.47 * Summary 12 48 */ 13 #define BSP_DECREMENTER 0 49 #define BSP_IRQ_NUMBER (BSP_PROCESSOR_IRQ_MAX_OFFSET+1) 50 #define BSP_LOWEST_OFFSET BSP_PROCESSOR_IRQ_LOWEST_OFFSET 51 #define BSP_MAX_OFFSET BSP_PROCESSOR_IRQ_MAX_OFFSET 52 53 #define BSP_IS_VALID_IRQ(irqnum) (BSP_IS_PROCESSOR_IRQ(irqnum)) 14 54 55 #ifndef ASM 56 #ifdef __cplusplus 57 extern "C" { 15 58 #endif 59 60 /* 61 * index table for the module specific handlers, a few entries are only placeholders 62 */ 63 typedef enum { 64 BSP_EXT = BSP_PROCESSOR_IRQ_LOWEST_OFFSET + 0, 65 BSP_PIT = BSP_PROCESSOR_IRQ_LOWEST_OFFSET + 1, 66 BSP_CRIT = BSP_PROCESSOR_IRQ_LOWEST_OFFSET + 2 67 } rtems_irq_symbolic_name; 68 69 extern rtems_irq_connect_data *BSP_rtems_irq_tbl; 70 void BSP_rtems_irq_mngt_init(unsigned cpuId); 71 72 #ifdef __cplusplus 73 } 74 #endif 75 #endif /* ASM */ 76 77 #endif /* VIRTEX5_IRQ_IRQ_H */ -
new file c/src/lib/libbsp/powerpc/virtex5/irq/irq_init.c
diff --git a/c/src/lib/libbsp/powerpc/virtex5/irq/irq_init.c b/c/src/lib/libbsp/powerpc/virtex5/irq/irq_init.c new file mode 100644 index 0000000..74aaebb
- + 1 /*===============================================================*\ 2 | Project: RTEMS virtex BSP | 3 +-----------------------------------------------------------------+ 4 | Partially based on the code references which are named below. | 5 | Adaptions, modifications, enhancements and any recent parts of | 6 | the code are: | 7 | Copyright (c) 2007 | 8 | Embedded Brains GmbH | 9 | Obere Lagerstr. 30 | 10 | D-82178 Puchheim | 11 | Germany | 12 | rtems@embedded-brains.de | 13 +-----------------------------------------------------------------+ 14 | The license and distribution terms for this file may be | 15 | found in the file LICENSE in this distribution or at | 16 | | 17 | http://www.rtems.com/license/LICENSE. | 18 | | 19 +-----------------------------------------------------------------+ 20 | this file contains the irq controller handler | 21 \*===============================================================*/ 22 #include <libcpu/spr.h> 23 #include <bsp/irq.h> 24 #include <bsp.h> 25 #include <rtems/bspIo.h> 26 #include <rtems/powerpc/powerpc.h> 27 #include <bsp/vectors.h> 28 29 uint32_t* IRQ_Counter = (uint32_t*)0x1500; 30 31 static rtems_irq_connect_data rtemsIrqTbl[BSP_IRQ_NUMBER]; 32 rtems_irq_connect_data *BSP_rtems_irq_tbl; 33 rtems_irq_global_settings* BSP_rtems_irq_config; 34 35 /*********************************************************** 36 * dummy functions for on/off/isOn calls 37 * these functions just do nothing fulfill the semantic 38 * requirements to enable/disable a certain interrupt or exception 39 */ 40 void BSP_irq_nop_func(const rtems_irq_connect_data *unused) 41 { 42 /* 43 * nothing to do 44 */ 45 } 46 47 void BSP_irq_nop_hdl(void *hdl) 48 { 49 /* 50 * nothing to do 51 */ 52 } 53 54 int BSP_irq_isOn_func(const rtems_irq_connect_data *unused) 55 { 56 /* 57 * nothing to do 58 */ 59 return 0; 60 } 61 62 /*********************************************************** 63 * interrupt handler and its enable/disable functions 64 ***********************************************************/ 65 66 /*********************************************************** 67 * functions to enable/disable/query external/critical interrupts 68 */ 69 void BSP_irqexc_on_fnc(rtems_irq_connect_data *conn_data) 70 { 71 uint32_t msr_value; 72 /* 73 * get current MSR value 74 */ 75 _CPU_MSR_GET(msr_value); 76 77 msr_value |= PPC_MSR_EE; 78 _CPU_MSR_SET(msr_value); 79 } 80 81 void BSP_irqexc_off_fnc(rtems_irq_connect_data *unused) 82 { 83 uint32_t msr_value; 84 /* 85 * get current MSR value 86 */ 87 _CPU_MSR_GET(msr_value); 88 89 msr_value &= ~PPC_MSR_EE; 90 _CPU_MSR_SET(msr_value); 91 } 92 93 /*********************************************************** 94 * High level IRQ handler called from shared_raw_irq_code_entry 95 */ 96 int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum) 97 { 98 /* 99 * Handle interrupt 100 */ 101 switch(excNum) { 102 case ASM_EXT_VECTOR: 103 BSP_rtems_irq_tbl[BSP_EXT].hdl(BSP_rtems_irq_tbl[BSP_EXT].handle); 104 break; 105 case ASM_BOOKE_DEC_VECTOR: 106 BSP_rtems_irq_tbl[BSP_PIT].hdl(BSP_rtems_irq_tbl[BSP_PIT].handle); 107 break; 108 #if 0 /* Critical interrupts not yet supported */ 109 case ASM_BOOKE_CRIT_VECTOR: 110 BSP_rtems_irq_tbl[BSP_CRIT].hdl(BSP_rtems_irq_tbl[BSP_CRIT].handle); 111 break; 112 #endif 113 } 114 115 return 0; 116 } 117 118 /*********************************************************** 119 * functions to set/get/remove interrupt handlers 120 ***********************************************************/ 121 int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq) 122 { 123 rtems_interrupt_level level; 124 125 /* 126 * check for valid irq name 127 * if invalid, print error and return 0 128 */ 129 if (!BSP_IS_VALID_IRQ(irq->name)) { 130 printk("Invalid interrupt vector %d\n",irq->name); 131 return 0; 132 } 133 134 /* 135 * disable interrupts 136 */ 137 rtems_interrupt_disable(level); 138 139 /* 140 * check, that default handler is installed now 141 */ 142 if (rtemsIrqTbl[irq->name].hdl != BSP_rtems_irq_config->defaultEntry.hdl) { 143 rtems_interrupt_enable(level); 144 printk("IRQ vector %d already connected\n",irq->name); 145 return 0; 146 } 147 148 /* 149 * store new handler data 150 */ 151 rtemsIrqTbl[irq->name] = *irq; 152 153 /* 154 * call "on" function to enable interrupt at device 155 */ 156 irq->on(irq); 157 158 /* 159 * reenable interrupts 160 */ 161 rtems_interrupt_enable(level); 162 163 return 1; 164 } 165 166 int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* irq) 167 { 168 rtems_interrupt_level level; 169 170 /* 171 * check for valid IRQ name 172 */ 173 if (!BSP_IS_VALID_IRQ(irq->name)) { 174 return 0; 175 } 176 rtems_interrupt_disable(level); 177 178 /* 179 * return current IRQ entry 180 */ 181 *irq = rtemsIrqTbl[irq->name]; 182 rtems_interrupt_enable(level); 183 return 1; 184 } 185 186 int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq) 187 { 188 rtems_interrupt_level level; 189 190 /* 191 * check for valid IRQ name 192 */ 193 if (!BSP_IS_VALID_IRQ(irq->name)) { 194 return 0; 195 } 196 rtems_interrupt_disable(level); 197 198 /* 199 * check, that specified handler is really connected now 200 */ 201 if (rtemsIrqTbl[irq->name].hdl != irq->hdl) { 202 rtems_interrupt_enable(level); 203 return 0; 204 } 205 206 /* 207 * disable interrupt at source 208 */ 209 irq->off(irq); 210 211 /* 212 * restore default interrupt handler 213 */ 214 rtemsIrqTbl[irq->name] = BSP_rtems_irq_config->defaultEntry; 215 216 /* 217 * reenable interrupts 218 */ 219 rtems_interrupt_enable(level); 220 221 return 1; 222 } 223 224 /*********************************************************** 225 * functions to set/get the basic interrupt management setup 226 ***********************************************************/ 227 /* 228 * (Re) get info on current RTEMS interrupt management. 229 */ 230 int BSP_rtems_irq_mngt_get(rtems_irq_global_settings** ret_ptr) 231 { 232 *ret_ptr = BSP_rtems_irq_config; 233 return 0; 234 } 235 236 237 /* 238 * set management stuff 239 */ 240 int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config) 241 { 242 int i; 243 rtems_interrupt_level level; 244 245 rtems_interrupt_disable(level); 246 247 /* 248 * store given configuration 249 */ 250 BSP_rtems_irq_config = config; 251 BSP_rtems_irq_tbl = BSP_rtems_irq_config->irqHdlTbl; 252 253 /* 254 * store any irq-like processor exceptions 255 */ 256 for (i = BSP_PROCESSOR_IRQ_LOWEST_OFFSET; 257 i < BSP_PROCESSOR_IRQ_MAX_OFFSET; 258 i++) { 259 if (BSP_rtems_irq_tbl[i].hdl != config->defaultEntry.hdl) { 260 if (BSP_rtems_irq_tbl[i].on != NULL) { 261 BSP_rtems_irq_tbl[i].on 262 (&(BSP_rtems_irq_tbl[i])); 263 } 264 } 265 else { 266 if (BSP_rtems_irq_tbl[i].off != NULL) { 267 BSP_rtems_irq_tbl[i].off 268 (&(BSP_rtems_irq_tbl[i])); 269 } 270 } 271 } 272 rtems_interrupt_enable(level); 273 return 1; 274 } 275 276 /* 277 * dummy for an empty IRQ handler entry 278 */ 279 static rtems_irq_connect_data emptyIrq = { 280 0, /* Irq Name */ 281 BSP_irq_nop_hdl, /* handler function */ 282 NULL, /* handle passed to handler */ 283 BSP_irq_nop_func, /* on function */ 284 BSP_irq_nop_func, /* off function */ 285 BSP_irq_isOn_func /* isOn function */ 286 }; 287 288 static rtems_irq_global_settings initialConfig = { 289 BSP_IRQ_NUMBER, /* irqNb */ 290 { 0, /* Irq Name */ 291 BSP_irq_nop_hdl, /* handler function */ 292 NULL, /* handle passed to handler */ 293 BSP_irq_nop_func, /* on function */ 294 BSP_irq_nop_func, /* off function */ 295 BSP_irq_isOn_func /* isOn function */ 296 }, /* emptyIrq */ 297 rtemsIrqTbl, /* irqHdlTbl */ 298 0, /* irqBase */ 299 NULL /* irqPrioTbl */ 300 }; 301 302 void BSP_rtems_irq_mngt_init(unsigned cpuId) 303 { 304 int i; 305 306 /* 307 * connect all exception vectors needed 308 */ 309 ppc_exc_set_handler(ASM_EXT_VECTOR, C_dispatch_irq_handler); 310 ppc_exc_set_handler(ASM_BOOKE_DEC_VECTOR, C_dispatch_irq_handler); 311 312 /* 313 * setup interrupt handlers table 314 */ 315 for (i = 0; 316 i < BSP_IRQ_NUMBER; 317 i++) { 318 rtemsIrqTbl[i] = emptyIrq; 319 rtemsIrqTbl[i].name = i; 320 } 321 322 /* 323 * initialize interrupt management 324 */ 325 if (!BSP_rtems_irq_mngt_set(&initialConfig)) { 326 BSP_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n"); 327 } 328 } -
c/src/lib/libbsp/powerpc/virtex5/preinstall.am
diff --git a/c/src/lib/libbsp/powerpc/virtex5/preinstall.am b/c/src/lib/libbsp/powerpc/virtex5/preinstall.am index e945d2b..7f0e698 100644
a b $(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp) 45 45 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h 46 46 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h 47 47 48 $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)49 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h50 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h51 52 48 $(PROJECT_INCLUDE)/coverhd.h: include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp) 53 49 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h 54 50 PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h 55 51 52 $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp) 53 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h 54 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h 55 56 56 $(PROJECT_LIB)/rtems_crti.$(OBJEXT): rtems_crti.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp) 57 57 $(INSTALL_DATA) $< $(PROJECT_LIB)/rtems_crti.$(OBJEXT) 58 58 TMPINSTALL_FILES += $(PROJECT_LIB)/rtems_crti.$(OBJEXT) -
c/src/lib/libbsp/powerpc/virtex5/startup/bspclean.c
diff --git a/c/src/lib/libbsp/powerpc/virtex5/startup/bspclean.c b/c/src/lib/libbsp/powerpc/virtex5/startup/bspclean.c index c80c1b1..df2d7af 100644
a b 30 30 * The license and distribution terms for this file may be 31 31 * found in the file LICENSE in this distribution or at 32 32 * http://www.rtems.com/license/LICENSE. 33 *34 * $Id: bspclean.c 63 2011-04-26 00:23:51Z claus $35 33 */ 36 34 37 35 #include <rtems.h> 38 36 #include <bsp.h> 39 37 38 static void _noopfun(void) {} 39 40 void app_bsp_cleanup(void) 41 __attribute__(( weak, alias("_noopfun") )); 42 40 43 void bsp_cleanup( void ) 41 44 { 42 /* rtems_fatal_error_occurred(0); */ 45 app_bsp_cleanup(); 46 47 /* All done. Hang out. */ 48 BSP_ask_for_reset(); 43 49 } -
c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c
diff --git a/c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c b/c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c index 02ebfad..0560696 100644
a b 53 53 * 54 54 * Modifications for PPC405GP by Dennis Ehlin 55 55 * Modifications for Virtex5 by Richard Claus <claus@slac.stanford.edu> 56 *57 * $Id: bspstart.c 63 2011-04-26 00:23:51Z claus $58 56 */ 59 57 60 58 #include <string.h> 61 59 #include <fcntl.h> 62 60 63 61 #include <bsp.h> 62 #include <bsp/irq.h> 63 #include <bsp/vectors.h> 64 #include <rtems/bspIo.h> 64 65 #include <rtems/libio.h> 65 66 #include <rtems/libcsupport.h> 66 #include <rtems/bspIo.h> 67 #include <bsp/vectors.h> 68 #include <libcpu/spr.h> 67 #include <rtems/sptables.h> /* for RTEMS_VERSION */ 69 68 #include <libcpu/cpuIdent.h> 69 #include <libcpu/spr.h> 70 70 71 71 #define DO_DOWN_ALIGN(x,a) ((x) & ~((a)-1)) 72 72 … … uint32_t bsp_timer_least_valid; 83 83 uint32_t bsp_timer_average_overhead; 84 84 85 85 86 /* Provide weak aliases so that RTEMS distribution builds; the 87 * generated executables are bogus, however... 86 /* Defined in linkcmds linker script */ 87 LINKER_SYMBOL(RamBase); 88 LINKER_SYMBOL(RamSize); 89 LINKER_SYMBOL(__bsp_ram_start); 90 LINKER_SYMBOL(__bsp_ram_end); 91 LINKER_SYMBOL(__rtems_end); 92 LINKER_SYMBOL(_stack); 93 LINKER_SYMBOL(StackSize); 94 LINKER_SYMBOL(__stack_base); 95 LINKER_SYMBOL(WorkAreaBase); 96 LINKER_SYMBOL(MsgAreaBase); 97 LINKER_SYMBOL(MsgAreaSize); 98 LINKER_SYMBOL(__phy_ram_end); 99 100 101 /* 102 * Provide weak aliases so that RTEMS distribution builds 88 103 */ 89 void __app_noopfun(void) {} 104 static void _noopfun(void) {} 105 static void _bsp_start(void) 106 { 107 rtems_status_code sc = RTEMS_SUCCESSFUL; 108 uintptr_t intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start); 109 uintptr_t intrStackSize = rtems_configuration_get_interrupt_stack_size(); 110 111 /* 112 * Initialize default raw exception handlers. 113 * 114 * This BSP does not assume anything about firmware possibly loaded in the 115 * FPGA, so the external interrupt should not be enabled in order to avoid 116 * spurious interrupts. 117 */ 118 sc = ppc_exc_initialize(PPC_INTERRUPT_DISABLE_MASK_DEFAULT & ~MSR_EE, 119 intrStackStart, 120 intrStackSize); 121 if (sc != RTEMS_SUCCESSFUL) BSP_panic("Cannot initialize exceptions"); 122 123 /* Install our own set of exception vectors */ 124 BSP_rtems_irq_mngt_init(0); 125 } 90 126 91 void app_memory_write(void) /* See dummy_console.c */92 __attribute__(( weak, alias("__app_noopfun") ));93 127 94 128 void app_bsp_start(void) 95 __attribute__(( weak, alias("_ _app_noopfun") ));129 __attribute__(( weak, alias("_bsp_start") )); 96 130 97 131 void app_bsp_pretasking_hook(void) 98 __attribute__(( weak, alias("_ _app_noopfun") ));132 __attribute__(( weak, alias("_noopfun") )); 99 133 100 134 void app_bsp_predriver_hook(void) 101 __attribute__(( weak, alias("_ _app_noopfun") ));135 __attribute__(( weak, alias("_noopfun") )); 102 136 103 137 104 LINKER_SYMBOL(__bsp_ram_start);105 LINKER_SYMBOL(__bsp_ram_end);106 LINKER_SYMBOL(WorkAreaBase);107 LINKER_SYMBOL(MsgAreaBase);108 LINKER_SYMBOL(MsgAreaSize);109 110 138 static char* bspMsgBuffer = (char*)MsgAreaBase; 111 139 112 140 static void __bsp_outchar_to_memory(char c) … … static void __bsp_outchar_to_memory(char c) 120 148 121 149 void BSP_ask_for_reset(void) 122 150 { 123 printk("\nSystem stopped, pressRESET");151 printk("\nSystem stopped, issue RESET"); 124 152 for(;;); 125 /*__asm__ __volatile ("sc");*/126 153 } 127 154 128 155 … … void _BSP_Fatal_error(unsigned int v) 149 176 */ 150 177 void bsp_start(void) 151 178 { 152 rtems_status_code sc = RTEMS_SUCCESSFUL;153 179 uintptr_t intrStackStart; 154 180 uintptr_t intrStackSize; 155 181 ppc_cpu_id_t myCpu; … … void bsp_start(void) 158 184 /* Set the character output function; The application may override this */ 159 185 BSP_output_char = __bsp_outchar_to_memory; 160 186 187 printk("\nWelcome to RTEMS %s\n", _RTEMS_version ); 188 161 189 /* 162 190 * Get CPU identification dynamically. Note that the get_ppc_cpu_type() 163 * function stores the result in global variables 164 * so that it can be used later... 191 * function stores the result in global variables so that it can be used later... 165 192 */ 166 193 myCpu = get_ppc_cpu_type(); 167 194 myCpuRevision = get_ppc_cpu_revision(); … … void bsp_start(void) 183 210 */ 184 211 intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start); 185 212 intrStackSize = rtems_configuration_get_interrupt_stack_size(); 186 187 /* 188 * Initialize default raw exception handlers. 189 */ 190 sc = ppc_exc_initialize(PPC_INTERRUPT_DISABLE_MASK_DEFAULT, 191 intrStackStart, 192 intrStackSize); 193 if (sc != RTEMS_SUCCESSFUL) BSP_panic("Cannot initialize exceptions"); 213 printk("RamBase: 0x%08x Size: 0x%x\n" 214 "RTEMS End: 0x%08x\n" 215 "Interrupt Stack Start: 0x%08x Size: 0x%x\n" 216 "Stack Base: 0x%08x End: 0x%08x Size: 0x%x\n" 217 "Workspace Start: 0x%08x End: 0x%08x\n" 218 "MsgAreaBase: 0x%08x Size: 0x%x\n" 219 "Physical RAM End: 0x%08x\n", 220 (uint32_t)RamBase, (uint32_t)RamSize, 221 (uint32_t)__rtems_end, 222 intrStackStart, intrStackSize, 223 (uint32_t)__stack_base, (uint32_t)StackSize, (uint32_t)_stack, 224 (uint32_t)WorkAreaBase, (uint32_t)__bsp_ram_end, 225 (uint32_t)MsgAreaBase, (uint32_t)MsgAreaSize, 226 (uint32_t)__phy_ram_end); 194 227 195 228 /* Continue with application-specific initialization */ 196 229 app_bsp_start(); -
c/src/lib/libbsp/powerpc/virtex5/startup/dummy_console.c
diff --git a/c/src/lib/libbsp/powerpc/virtex5/startup/dummy_console.c b/c/src/lib/libbsp/powerpc/virtex5/startup/dummy_console.c index 33f6a09..048133d 100644
a b 1 1 #include <rtems.h> 2 2 #include <rtems/libio.h> 3 3 4 extern int app_memory_write(int minor, const char* buf, int len); 4 #include <string.h> 5 6 ssize_t app_memory_write(int minor, const char* buf, size_t len) 7 __attribute__(( weak, alias("__bsp_memory_write") )); 8 9 ssize_t __bsp_memory_write(int minor, const char* buf, size_t len); 10 rtems_device_driver console_initialize(rtems_device_major_number major, 11 rtems_device_minor_number minor, 12 void* arg); 13 rtems_device_driver console_open(rtems_device_major_number major, 14 rtems_device_minor_number minor, 15 void* arg); 16 rtems_device_driver console_close(rtems_device_major_number major, 17 rtems_device_minor_number minor, 18 void* arg); 19 rtems_device_driver console_read(rtems_device_major_number major, 20 rtems_device_minor_number minor, 21 void* arg); 22 rtems_device_driver console_write(rtems_device_major_number major, 23 rtems_device_minor_number minor, 24 void* arg); 25 rtems_device_driver console_control(rtems_device_major_number major, 26 rtems_device_minor_number minor, 27 void* arg); 28 29 30 ssize_t __bsp_memory_write(int minor, const char* buf, size_t len) 31 { 32 const char* const last = buf+len; 33 while (buf < last) 34 { 35 BSP_output_char(*buf++); 36 } 37 return len; 38 } 5 39 6 40 static rtems_termios_callbacks gMemCallbacks = { 7 41 0, /* firstOpen */ -
c/src/lib/libbsp/powerpc/virtex5/startup/linkcmds
diff --git a/c/src/lib/libbsp/powerpc/virtex5/startup/linkcmds b/c/src/lib/libbsp/powerpc/virtex5/startup/linkcmds index 4f66ada..20d4095 100644
a b OUTPUT_ARCH(powerpc) 10 10 11 11 ENTRY(download_entry) 12 12 13 MsgAreaSize = DEFINED(MsgAreaSize) ? MsgAreaSize : 1 K;13 MsgAreaSize = DEFINED(MsgAreaSize) ? MsgAreaSize : 1M; 14 14 RamBase = DEFINED(RamBase) ? RamBase : 0x0; 15 RamSize = DEFINED(RamSize) ? RamSize : 4096M - MsgAreaSize;15 RamSize = DEFINED(RamSize) ? RamSize : 2048M - MsgAreaSize; 16 16 IntrStackSize = DEFINED(IntrStackSize) ? IntrStackSize : 16K; 17 17 StackSize = DEFINED(StackSize) ? StackSize : 64K; 18 18 HeapSize = DEFINED(HeapSize) ? HeapSize : 0; /* 0=Use def */ … … HeapSize = DEFINED(HeapSize) ? HeapSize : 0; /* 0=Use def */ 21 21 MEMORY 22 22 { 23 23 VECTORS : ORIGIN = 0x00000000, LENGTH = 8K 24 RAM : ORIGIN = 0x00002000, LENGTH = 4096M - 8K24 RAM : ORIGIN = 0x00002000, LENGTH = 2048M - 8K 25 25 } 26 26 27 27 … … _SDA_BASE_ = __SDATA_START__ + 0x8000; 244 244 245 245 /* The heap comes after the work space */ 246 246 247 . = RamBase + RamSize - MsgAreaSize;247 . = RamBase + RamSize; 248 248 PROVIDE(__bsp_ram_end = .); 249 249 250 250 /* Message area for capturing early printk output */