Changeset b7774253 in rtems


Ignore:
Timestamp:
Sep 12, 2008, 8:25:31 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
0729c2d9
Parents:
c3ee4257
Message:

2008-09-12 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac, startup/bspstart.c: Split out bsp_get_work_area() into its own file and user BSP Framework to perform more initialization. Let edb7312 and csb336 shared the implementation.
Location:
c/src/lib/libbsp/arm/csb336
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/csb336/ChangeLog

    rc3ee4257 rb7774253  
     12008-09-12      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * Makefile.am, configure.ac, startup/bspstart.c: Split out
     4        bsp_get_work_area() into its own file and user BSP Framework to
     5        perform more initialization. Let edb7312 and csb336 shared the
     6        implementation.
     7
    182008-08-21      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • c/src/lib/libbsp/arm/csb336/Makefile.am

    rc3ee4257 rb7774253  
    2727
    2828startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
    29     ../../shared/bsppredriverhook.c \
    30     startup/bspstart.c startup/bspclean.c startup/memmap.c \
    31     ../../shared/bootcard.c ../../shared/sbrk.c \
     29    ../shared/bspgetworkarea.c ../../shared/bsppretaskinghook.c \
     30    ../../shared/bsppredriverhook.c startup/bspstart.c startup/bspclean.c \
     31    startup/memmap.c ../../shared/bootcard.c ../../shared/sbrk.c \
    3232    ../../shared/gnatinstallhandler.c
    3333console_SOURCES = console/uart.c
  • c/src/lib/libbsp/arm/csb336/configure.ac

    rc3ee4257 rb7774253  
    1919AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
    2020
     21RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
     22
    2123# Explicitly list all Makefiles here
    2224AC_CONFIG_FILES([Makefile])
  • c/src/lib/libbsp/arm/csb336/startup/bspstart.c

    rc3ee4257 rb7774253  
    44 * Copyright (c) 2004 by Cogent Computer Systems
    55 * Written by Jay Monkman <jtm@lopingdog.com>
    6  *     
     6 *
    77 * The license and distribution terms for this file may be
    88 * found in the file LICENSE in this distribution or at
    9  *
    109 * http://www.rtems.com/license/LICENSE.
    1110 *
    1211 *  $Id$
    1312 */
     13
    1414#include <bsp.h>
    1515#include <rtems/libcsupport.h>
     
    1818#include <mc9328mxl.h>
    1919
    20 /* Global Variables */
    21 extern void            *_flash_size;
    22 extern void            *_flash_base;
    23 extern void            *_sdram_size;
    24 extern void            *_sdram_base;
    25 extern void            *_bss_free_start;
     20extern void rtems_irq_mngt_init(void);
     21extern void mmu_set_cpu_async_mode(void);
    2622
    27 unsigned long           free_mem_start;
    28 unsigned long           free_mem_end;
    29 
    30 extern void rtems_irq_mngt_init(void);
    31 void bsp_libc_init( void *, uint32_t, int );
    32 
    33 /**************************************************************************/
    34 /*                                                                        */
    35 /* NAME: bsp_pretasking_hook - Function to setup system before startup    */
    36 /*                                                                        */
    37 /* DESCRIPTION:                                                           */
    38 /*   This function is called before drivers are initialized and used      */
    39 /*   to setup libc and BSP extensions.                                    */
    40 /*                                                                        */
    41 /* RESTRICTIONS/LIMITATIONS:                                              */
    42 /*   Since this function is setting up libc, it cannot use and libc       */
    43 /*   functions.                                                           */
    44 /*                                                                        */
    45 /**************************************************************************/
    46 void bsp_pretasking_hook(void)
    47 {
    48     uint32_t heap_start;
    49     uint32_t heap_size;
    50 
    51     /*
    52      * Set up the heap.
    53      */
    54     heap_start =  free_mem_start;
    55     heap_size = free_mem_end - free_mem_start;
    56 
    57     /* call rtems lib init - malloc stuff */
    58     bsp_libc_init((void *)heap_start, heap_size, 0);
    59 }
    60  
    61 
    62 /**************************************************************************/
    63 /*                                                                        */
    64 /* NAME: bsp_start_default - BSP initialization function                  */
    65 /*                                                                        */
    66 /* DESCRIPTION:                                                           */
    67 /*   This function is called before RTEMS is initialized and used         */
    68 /*   adjust the kernel's configuration.                                   */
    69 /*                                                                        */
    70 /*   This function also configures the CPU's memory protection unit.      */
    71 /*                                                                        */
    72 /* RESTRICTIONS/LIMITATIONS:                                              */
    73 /*   Since RTEMS is not configured, no RTEMS functions can be called.     */
    74 /*                                                                        */
    75 /**************************************************************************/
    76 void mmu_set_cpu_async_mode(void);
     23/*
     24 * bsp_start_default - BSP initialization function
     25 *
     26 *   This function is called before RTEMS is initialized and used
     27 *   adjust the kernel's configuration.
     28 *
     29 *   This function also configures the CPU's memory protection unit.
     30 *
     31 * RESTRICTIONS/LIMITATIONS:
     32 *   Since RTEMS is not configured, no RTEMS functions can be called.
     33 *
     34 */
    7735void bsp_start_default( void )
    7836{
    79     int i;
     37  int i;
    8038
    81     /* Set the MCU prescaler to divide by 1 */
    82     MC9328MXL_PLL_CSCR &= ~MC9328MXL_PLL_CSCR_PRESC;
     39  /* Set the MCU prescaler to divide by 1 */
     40  MC9328MXL_PLL_CSCR &= ~MC9328MXL_PLL_CSCR_PRESC;
    8341
    84     /* Enable the MCU PLL */
    85     MC9328MXL_PLL_CSCR |= MC9328MXL_PLL_CSCR_MPEN;
     42  /* Enable the MCU PLL */
     43  MC9328MXL_PLL_CSCR |= MC9328MXL_PLL_CSCR_MPEN;
    8644
    87     /* Delay to allow time for PLL to get going */
    88     for (i = 0; i < 100; i++) {
    89         asm volatile ("nop\n");
    90     }
     45  /* Delay to allow time for PLL to get going */
     46  for (i = 0; i < 100; i++) {
     47    asm volatile ("nop\n");
     48  }
    9149
    92     /* Set the CPU to asynchrous clock mode, so it uses its fastest clock */
    93     mmu_set_cpu_async_mode();
     50  /* Set the CPU to asynchrous clock mode, so it uses its fastest clock */
     51  mmu_set_cpu_async_mode();
    9452
    95     /* disable interrupts */
    96     MC9328MXL_AITC_INTENABLEL = 0;
    97     MC9328MXL_AITC_INTENABLEH = 0;
     53  /* disable interrupts */
     54  MC9328MXL_AITC_INTENABLEL = 0;
     55  MC9328MXL_AITC_INTENABLEH = 0;
    9856
    99     /* Set interrupt priority to -1 (allow all priorities) */
    100     MC9328MXL_AITC_NIMASK = 0x1f;
     57  /* Set interrupt priority to -1 (allow all priorities) */
     58  MC9328MXL_AITC_NIMASK = 0x1f;
    10159
    102     /* Place RTEMS workspace at beginning of free memory. */
    103     Configuration.work_space_start = (void *)&_bss_free_start;
    104    
    105     free_mem_start = ((uint32_t)&_bss_free_start +
    106                       rtems_configuration_get_work_space_size());
    107    
    108     free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size);
     60  /*
     61   * Init rtems exceptions management
     62   */
     63  rtems_exception_init_mngt();
    10964
    110     /*
    111      * Init rtems exceptions management
    112      */
    113     rtems_exception_init_mngt();
    114    
    115     /*
    116      * Init rtems interrupt management
    117      */
    118     rtems_irq_mngt_init();
    119    
    120    
    121     /*
    122      *  The following information is very useful when debugging.
    123      */
    124 #if 0
    125     printk( "work_space_size = 0x%x\n",
    126             rtems_configuration_get_work_space_size() );
    127     printk( "microseconds_per_tick = 0x%x\n",
    128             rtems_configuration_get_microseconds_per_tick() );
    129     printk( "ticks_per_timeslice = 0x%x\n",
    130             rtems_configuration_get_ticks_per_timeslice() );
    131     printk( "work_space_start = 0x%x\n",
    132             Configuration.work_space_start );
    133     printk( "work_space_size = 0x%x\n",
    134             rtems_configuration_get_work_space_size() );
    135 #endif
     65  /*
     66   * Init rtems interrupt management
     67   */
     68  rtems_irq_mngt_init();
    13669} /* bsp_start */
    137 
    138 
    13970
    14071/* Calcuate the frequency for perclk1 */
    14172int get_perclk1_freq(void)
    14273{
    143     unsigned int fin;
    144     unsigned int fpll;
    145     unsigned int pd;
    146     unsigned int mfd;
    147     unsigned int mfi;
    148     unsigned int mfn;
    149     uint32_t reg;
    150     int perclk1;
     74  unsigned int fin;
     75  unsigned int fpll;
     76  unsigned int pd;
     77  unsigned int mfd;
     78  unsigned int mfi;
     79  unsigned int mfn;
     80  uint32_t reg;
     81  int perclk1;
    15182
    152     if (MC9328MXL_PLL_CSCR & MC9328MXL_PLL_CSCR_SYSSEL) {
    153         /* Use external oscillator */
    154         fin = BSP_OSC_FREQ;
    155     } else {
    156         /* Use scaled xtal freq */
    157         fin = BSP_XTAL_FREQ * 512;
    158     }
     83  if (MC9328MXL_PLL_CSCR & MC9328MXL_PLL_CSCR_SYSSEL) {
     84    /* Use external oscillator */
     85    fin = BSP_OSC_FREQ;
     86  } else {
     87    /* Use scaled xtal freq */
     88    fin = BSP_XTAL_FREQ * 512;
     89  }
    15990
    160     /* calculate the output of the system PLL */
    161     reg = MC9328MXL_PLL_SPCTL0;
    162     pd = ((reg & MC9328MXL_PLL_SPCTL_PD_MASK) >>
    163           MC9328MXL_PLL_SPCTL_PD_SHIFT);
    164     mfd = ((reg & MC9328MXL_PLL_SPCTL_MFD_MASK) >>
    165            MC9328MXL_PLL_SPCTL_MFD_SHIFT);
    166     mfi = ((reg & MC9328MXL_PLL_SPCTL_MFI_MASK) >>
    167            MC9328MXL_PLL_SPCTL_MFI_SHIFT);
    168     mfn = ((reg & MC9328MXL_PLL_SPCTL_MFN_MASK) >>
    169            MC9328MXL_PLL_SPCTL_MFN_SHIFT);
     91  /* calculate the output of the system PLL */
     92  reg = MC9328MXL_PLL_SPCTL0;
     93  pd = ((reg & MC9328MXL_PLL_SPCTL_PD_MASK) >>
     94        MC9328MXL_PLL_SPCTL_PD_SHIFT);
     95  mfd = ((reg & MC9328MXL_PLL_SPCTL_MFD_MASK) >>
     96         MC9328MXL_PLL_SPCTL_MFD_SHIFT);
     97  mfi = ((reg & MC9328MXL_PLL_SPCTL_MFI_MASK) >>
     98         MC9328MXL_PLL_SPCTL_MFI_SHIFT);
     99  mfn = ((reg & MC9328MXL_PLL_SPCTL_MFN_MASK) >>
     100         MC9328MXL_PLL_SPCTL_MFN_SHIFT);
    170101
    171102#if 0
    172     printk("fin = %d\n", fin);
    173     printk("pd = %d\n", pd);
    174     printk("mfd = %d\n", mfd);
    175     printk("mfi = %d\n", mfi);
    176     printk("mfn = %d\n", mfn);
    177     printk("rounded (fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
    178     printk("rounded (fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
    179            ((long long)fin * mfn) / ((pd + 1) * (mfd + 1)));
     103  printk("fin = %d\n", fin);
     104  printk("pd = %d\n", pd);
     105  printk("mfd = %d\n", mfd);
     106  printk("mfi = %d\n", mfi);
     107  printk("mfn = %d\n", mfn);
     108  printk("rounded (fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
     109  printk("rounded (fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
     110         ((long long)fin * mfn) / ((pd + 1) * (mfd + 1)));
    180111#endif
    181112
    182     fpll = 2 * ( ((fin * mfi  + (pd + 1) / 2) / (pd + 1)) +
    183                  (((long long)fin * mfn + ((pd + 1) * (mfd + 1)) / 2) /
    184                 ((pd + 1) * (mfd + 1))) );
     113  fpll = 2 * ( ((fin * mfi  + (pd + 1) / 2) / (pd + 1)) +
     114               (((long long)fin * mfn + ((pd + 1) * (mfd + 1)) / 2) /
     115              ((pd + 1) * (mfd + 1))) );
    185116
    186     /* calculate the output of the PERCLK1 divider */
    187     reg = MC9328MXL_PLL_PCDR;
    188     perclk1 = fpll / (1 + ((reg & MC9328MXL_PLL_PCDR_PCLK1_MASK) >>
    189                            MC9328MXL_PLL_PCDR_PCLK1_SHIFT));
     117  /* calculate the output of the PERCLK1 divider */
     118  reg = MC9328MXL_PLL_PCDR;
     119  perclk1 = fpll / (1 + ((reg & MC9328MXL_PLL_PCDR_PCLK1_MASK) >>
     120                         MC9328MXL_PLL_PCDR_PCLK1_SHIFT));
    190121
    191     return perclk1;
     122  return perclk1;
    192123}
    193124
     
    196127 *  can override the actual bsp_start routine used.
    197128 */
    198 
    199129void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
    200 
    201130
    202131/**
    203132 *  Reset the system.
    204133 *
    205  *  This functions enables the watchdog and waits for it to
    206  *  fire, thus resetting the system.
    207  */
    208 /**
    209  *  Reset the system.
    210  *
    211  *  This functions enables the watchdog and waits for it to
     134 *  This functions enables the watchdog and waits for it to
    212135 *  fire, thus resetting the system.
    213136 */
    214137void bsp_reset(void)
    215138{
    216     rtems_interrupt_level level;
     139  rtems_interrupt_level level;
    217140
    218     _CPU_ISR_Disable(level);
     141  _CPU_ISR_Disable(level);
    219142
    220     printk("\n\rI should reset here.\n\r");
    221     while(1);
     143  printk("\n\rI should reset here.\n\r");
     144  while(1);
    222145}
Note: See TracChangeset for help on using the changeset viewer.