Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

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)

Various fixes to the virtex5 BSP

  • 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 
    1111dist_project_lib_DATA = bsp_specs
    1212
    1313# include
    14 include_HEADERS  = include/bsp.h
    15 #include_HEADERS += include/tm27.h
     14include_HEADERS     = include/bsp.h
     15include_HEADERS    += ../../shared/include/tm27.h
     16
     17include_bsp_HEADERS =
    1618
    1719nodist_include_HEADERS     = include/bspopts.h
     20nodist_include_HEADERS    += include/coverhd.h
    1821nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
    1922DISTCLEANFILES             = include/bspopts.h
    2023
    21 nodist_include_HEADERS += include/coverhd.h
    22 
    2324# start
    2425noinst_LIBRARIES      = libbspstart.a
    2526libbspstart_a_SOURCES = ../../powerpc/shared/start/rtems_crti.S
    libbsp_a_SOURCES = startup/bspclean.c \ 
    4344# start
    4445libbsp_a_SOURCES += startup/start.S
    4546
    46 # clock
    47 libbsp_a_SOURCES += ../shared/clock/clock.c
     47# clock & timer
     48libbsp_a_SOURCES += ../../../libcpu/@RTEMS_CPU@/ppc403/clock/clock.c
     49libbsp_a_SOURCES += ../../../libcpu/@RTEMS_CPU@/ppc403/timer/timer.c
    4850
    4951# console
    5052libbsp_a_SOURCES += startup/dummy_console.c \
    5153                    ../../shared/dummy_printk_support.c
    5254
    5355# irq
    54 include_bsp_HEADERS = include/irq.h
     56include_bsp_HEADERS += include/irq.h
     57libbsp_a_SOURCES += irq/irq_init.c
    5558
    5659#vectors
    5760include_bsp_HEADERS += ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/vectors.h
    include_bsp_HEADERS += ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/irq_s 
    5962
    6063libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/@exceptions@/rtems-cpu.rel \
    6164                  ../../../libcpu/@RTEMS_CPU@/@exceptions@/exc_bspsupport.rel \
    62                   ../../../libcpu/@RTEMS_CPU@/@exceptions@/irq_bspsupport.rel \
    6365                  ../../../libcpu/@RTEMS_CPU@/shared/cache.rel \
    6466                  ../../../libcpu/@RTEMS_CPU@/shared/cpuIdent.rel
    6567
    66 EXTRA_DIST =
     68EXTRA_DIST = times
    6769
    6870include $(srcdir)/preinstall.am
    6971include $(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 
    1616RTEMS_PROG_CCAS
    1717
    1818RTEMS_CHECK_NETWORKING
    19 
    2019AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
    2120
     21RTEMS_BSPOPTS_SET([PPC_USE_DATA_CACHE],[*],[1])
     22RTEMS_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
    2230RTEMS_BSPOPTS_SET([PPC_USE_SPRG],[*],[1])
    2331RTEMS_BSPOPTS_HELP([PPC_USE_SPRG],
    2432[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" { 
    5353 *  confdefs.h overrides for this BSP:
    5454 *   - Interrupt stack space is not minimum if defined.
    5555 */
    56 
    5756#define CONFIGURE_INTERRUPT_STACK_MEMORY  (16 * 1024)
    5857
    5958#ifdef ASM
    extern "C" { 
    6665#include <rtems/clockdrv.h>
    6766#include <rtems/iosupp.h>
    6867
     68/* miscellaneous stuff assumed to exist */
     69extern bool bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
     70
     71extern rtems_configuration_table BSP_Configuration;     /* owned by BSP */
    6972#endif /* ASM */
    7073
     74void BSP_ask_for_reset(void);
     75void BSP_panic(char *s);
     76void _BSP_Fatal_error(unsigned int v);
     77
    7178#ifdef __cplusplus
    7279}
    7380#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
    321
    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>
    523
    6 #define BSP_SHARED_HANDLER_SUPPORT 1
     24/*
     25 * the following definitions specify the indices used
     26 * to interface the interrupt handler API
     27 */
    728
    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))
    945
    1046/*
    11  *  The following symbols must be defined properly.
     47 * Summary
    1248 */
    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))
    1454
     55#ifndef ASM
     56#ifdef __cplusplus
     57extern "C" {
    1558#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
     29uint32_t* IRQ_Counter = (uint32_t*)0x1500;
     30
     31static rtems_irq_connect_data rtemsIrqTbl[BSP_IRQ_NUMBER];
     32rtems_irq_connect_data *BSP_rtems_irq_tbl;
     33rtems_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 */
     40void BSP_irq_nop_func(const rtems_irq_connect_data *unused)
     41{
     42  /*
     43   * nothing to do
     44   */
     45}
     46
     47void BSP_irq_nop_hdl(void *hdl)
     48{
     49  /*
     50   * nothing to do
     51   */
     52}
     53
     54int 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 */
     69void 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
     81void 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 */
     96int 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 ***********************************************************/
     121int 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
     166int 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
     186int 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 */
     230int 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 */
     240int 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 */
     279static 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
     288static 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
     302void 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) 
    4545        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
    4646PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
    4747
    48 $(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    49         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
    50 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
    51 
    5248$(PROJECT_INCLUDE)/coverhd.h: include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
    5349        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
    5450PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
    5551
     52$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     53        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
     54PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
     55
    5656$(PROJECT_LIB)/rtems_crti.$(OBJEXT): rtems_crti.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
    5757        $(INSTALL_DATA) $< $(PROJECT_LIB)/rtems_crti.$(OBJEXT)
    5858TMPINSTALL_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  
    3030 *  The license and distribution terms for this file may be
    3131 *  found in the file LICENSE in this distribution or at
    3232 *  http://www.rtems.com/license/LICENSE.
    33  *
    34  *  $Id: bspclean.c 63 2011-04-26 00:23:51Z claus $
    3533 */
    3634
    3735#include <rtems.h>
    3836#include <bsp.h>
    3937
     38static void _noopfun(void) {}
     39
     40void app_bsp_cleanup(void)
     41__attribute__(( weak, alias("_noopfun") ));
     42
    4043void bsp_cleanup( void )
    4144{
    42   /*  rtems_fatal_error_occurred(0); */
     45  app_bsp_cleanup();
     46
     47  /* All done.  Hang out. */
     48  BSP_ask_for_reset();
    4349}
  • 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  
    5353 *
    5454 *  Modifications for PPC405GP by Dennis Ehlin
    5555 *  Modifications for Virtex5 by Richard Claus <claus@slac.stanford.edu>
    56  *
    57  *  $Id: bspstart.c 63 2011-04-26 00:23:51Z claus $
    5856 */
    5957
    6058#include <string.h>
    6159#include <fcntl.h>
    6260
    6361#include <bsp.h>
     62#include <bsp/irq.h>
     63#include <bsp/vectors.h>
     64#include <rtems/bspIo.h>
    6465#include <rtems/libio.h>
    6566#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 */
    6968#include <libcpu/cpuIdent.h>
     69#include <libcpu/spr.h>
    7070
    7171#define DO_DOWN_ALIGN(x,a) ((x) & ~((a)-1))
    7272
    uint32_t bsp_timer_least_valid; 
    8383uint32_t    bsp_timer_average_overhead;
    8484
    8585
    86 /* Provide weak aliases so that RTEMS distribution builds; the
    87  * generated executables are bogus, however...
     86/* Defined in linkcmds linker script */
     87LINKER_SYMBOL(RamBase);
     88LINKER_SYMBOL(RamSize);
     89LINKER_SYMBOL(__bsp_ram_start);
     90LINKER_SYMBOL(__bsp_ram_end);
     91LINKER_SYMBOL(__rtems_end);
     92LINKER_SYMBOL(_stack);
     93LINKER_SYMBOL(StackSize);
     94LINKER_SYMBOL(__stack_base);
     95LINKER_SYMBOL(WorkAreaBase);
     96LINKER_SYMBOL(MsgAreaBase);
     97LINKER_SYMBOL(MsgAreaSize);
     98LINKER_SYMBOL(__phy_ram_end);
     99
     100
     101/*
     102 * Provide weak aliases so that RTEMS distribution builds
    88103 */
    89 void __app_noopfun(void) {}
     104static void _noopfun(void) {}
     105static 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}
    90126
    91 void app_memory_write(void)             /* See dummy_console.c */
    92 __attribute__(( weak, alias("__app_noopfun") ));
    93127
    94128void app_bsp_start(void)
    95 __attribute__(( weak, alias("__app_noopfun") ));
     129__attribute__(( weak, alias("_bsp_start") ));
    96130
    97131void app_bsp_pretasking_hook(void)
    98 __attribute__(( weak, alias("__app_noopfun") ));
     132__attribute__(( weak, alias("_noopfun") ));
    99133
    100134void app_bsp_predriver_hook(void)
    101 __attribute__(( weak, alias("__app_noopfun") ));
     135__attribute__(( weak, alias("_noopfun") ));
    102136
    103137
    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 
    110138static char* bspMsgBuffer = (char*)MsgAreaBase;
    111139
    112140static void __bsp_outchar_to_memory(char c)
    static void __bsp_outchar_to_memory(char c) 
    120148
    121149void BSP_ask_for_reset(void)
    122150{
    123   printk("\nSystem stopped, press RESET");
     151  printk("\nSystem stopped, issue RESET");
    124152  for(;;);
    125   /*__asm__ __volatile ("sc");*/
    126153}
    127154
    128155
    void _BSP_Fatal_error(unsigned int v) 
    149176 */
    150177void bsp_start(void)
    151178{
    152   rtems_status_code  sc = RTEMS_SUCCESSFUL;
    153179  uintptr_t          intrStackStart;
    154180  uintptr_t          intrStackSize;
    155181  ppc_cpu_id_t       myCpu;
    void bsp_start(void) 
    158184  /* Set the character output function;  The application may override this */
    159185  BSP_output_char = __bsp_outchar_to_memory;
    160186
     187  printk("\nWelcome to RTEMS %s\n", _RTEMS_version );
     188
    161189  /*
    162190   * 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...
    165192   */
    166193  myCpu         = get_ppc_cpu_type();
    167194  myCpuRevision = get_ppc_cpu_revision();
    void bsp_start(void) 
    183210   */
    184211  intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start);
    185212  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);
    194227
    195228  /* Continue with application-specific initialization */
    196229  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  
    11#include <rtems.h>
    22#include <rtems/libio.h>
    33
    4 extern int app_memory_write(int minor, const char* buf, int len);
     4#include <string.h>
     5
     6ssize_t app_memory_write(int minor, const char* buf, size_t len)
     7__attribute__(( weak, alias("__bsp_memory_write") ));
     8
     9ssize_t __bsp_memory_write(int minor, const char* buf, size_t len);
     10rtems_device_driver console_initialize(rtems_device_major_number major,
     11                                       rtems_device_minor_number minor,
     12                                       void*                     arg);
     13rtems_device_driver console_open(rtems_device_major_number major,
     14                                 rtems_device_minor_number minor,
     15                                 void*                     arg);
     16rtems_device_driver console_close(rtems_device_major_number major,
     17                                  rtems_device_minor_number minor,
     18                                  void*                     arg);
     19rtems_device_driver console_read(rtems_device_major_number major,
     20                                 rtems_device_minor_number minor,
     21                                 void*                     arg);
     22rtems_device_driver console_write(rtems_device_major_number major,
     23                                  rtems_device_minor_number minor,
     24                                  void*                     arg);
     25rtems_device_driver console_control(rtems_device_major_number major,
     26                                    rtems_device_minor_number minor,
     27                                    void*                     arg);
     28
     29
     30ssize_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}
    539
    640static rtems_termios_callbacks gMemCallbacks = {
    741        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) 
    1010
    1111ENTRY(download_entry)
    1212
    13 MsgAreaSize       = DEFINED(MsgAreaSize)   ? MsgAreaSize   : 1K;
     13MsgAreaSize       = DEFINED(MsgAreaSize)   ? MsgAreaSize   : 1M;
    1414RamBase           = DEFINED(RamBase)       ? RamBase       : 0x0;
    15 RamSize           = DEFINED(RamSize)       ? RamSize       : 4096M - MsgAreaSize;
     15RamSize           = DEFINED(RamSize)       ? RamSize       : 2048M - MsgAreaSize;
    1616IntrStackSize     = DEFINED(IntrStackSize) ? IntrStackSize : 16K;
    1717StackSize         = DEFINED(StackSize)     ? StackSize     : 64K;
    1818HeapSize          = DEFINED(HeapSize)      ? HeapSize      : 0; /* 0=Use def */
    HeapSize = DEFINED(HeapSize) ? HeapSize : 0; /* 0=Use def */ 
    2121MEMORY
    2222{
    2323  VECTORS         : ORIGIN = 0x00000000, LENGTH = 8K
    24   RAM             : ORIGIN = 0x00002000, LENGTH = 4096M - 8K
     24  RAM             : ORIGIN = 0x00002000, LENGTH = 2048M - 8K
    2525}
    2626
    2727
    _SDA_BASE_ = __SDATA_START__ + 0x8000; 
    244244
    245245  /* The heap comes after the work space */
    246246
    247    .              = RamBase + RamSize - MsgAreaSize;
     247   .              = RamBase + RamSize;
    248248  PROVIDE(__bsp_ram_end = .);
    249249
    250250  /* Message area for capturing early printk output */