Changeset b7774253 in rtems
- Timestamp:
- Sep 12, 2008, 8:25:31 PM (11 years ago)
- Branches:
- 4.10, 4.11, master
- Children:
- 0729c2d9
- Parents:
- c3ee4257
- Location:
- c/src/lib/libbsp/arm/csb336
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/arm/csb336/ChangeLog
rc3ee4257 rb7774253 1 2008-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 1 8 2008-08-21 Joel Sherrill <joel.sherrill@oarcorp.com> 2 9 -
c/src/lib/libbsp/arm/csb336/Makefile.am
rc3ee4257 rb7774253 27 27 28 28 startup_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 \ 32 32 ../../shared/gnatinstallhandler.c 33 33 console_SOURCES = console/uart.c -
c/src/lib/libbsp/arm/csb336/configure.ac
rc3ee4257 rb7774253 19 19 AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes") 20 20 21 RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION 22 21 23 # Explicitly list all Makefiles here 22 24 AC_CONFIG_FILES([Makefile]) -
c/src/lib/libbsp/arm/csb336/startup/bspstart.c
rc3ee4257 rb7774253 4 4 * Copyright (c) 2004 by Cogent Computer Systems 5 5 * Written by Jay Monkman <jtm@lopingdog.com> 6 * 6 * 7 7 * The license and distribution terms for this file may be 8 8 * found in the file LICENSE in this distribution or at 9 *10 9 * http://www.rtems.com/license/LICENSE. 11 10 * 12 11 * $Id$ 13 12 */ 13 14 14 #include <bsp.h> 15 15 #include <rtems/libcsupport.h> … … 18 18 #include <mc9328mxl.h> 19 19 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; 20 extern void rtems_irq_mngt_init(void); 21 extern void mmu_set_cpu_async_mode(void); 26 22 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 */ 77 35 void bsp_start_default( void ) 78 36 { 79 37 int i; 80 38 81 82 39 /* Set the MCU prescaler to divide by 1 */ 40 MC9328MXL_PLL_CSCR &= ~MC9328MXL_PLL_CSCR_PRESC; 83 41 84 85 42 /* Enable the MCU PLL */ 43 MC9328MXL_PLL_CSCR |= MC9328MXL_PLL_CSCR_MPEN; 86 44 87 88 89 90 45 /* Delay to allow time for PLL to get going */ 46 for (i = 0; i < 100; i++) { 47 asm volatile ("nop\n"); 48 } 91 49 92 93 50 /* Set the CPU to asynchrous clock mode, so it uses its fastest clock */ 51 mmu_set_cpu_async_mode(); 94 52 95 96 97 53 /* disable interrupts */ 54 MC9328MXL_AITC_INTENABLEL = 0; 55 MC9328MXL_AITC_INTENABLEH = 0; 98 56 99 100 57 /* Set interrupt priority to -1 (allow all priorities) */ 58 MC9328MXL_AITC_NIMASK = 0x1f; 101 59 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(); 109 64 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(); 136 69 } /* bsp_start */ 137 138 139 70 140 71 /* Calcuate the frequency for perclk1 */ 141 72 int get_perclk1_freq(void) 142 73 { 143 144 145 146 147 148 149 150 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; 151 82 152 153 154 155 156 157 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 } 159 90 160 161 162 pd = ((reg & MC9328MXL_PLL_SPCTL_PD_MASK) >>163 164 mfd = ((reg & MC9328MXL_PLL_SPCTL_MFD_MASK) >>165 166 mfi = ((reg & MC9328MXL_PLL_SPCTL_MFI_MASK) >>167 168 mfn = ((reg & MC9328MXL_PLL_SPCTL_MFN_MASK) >>169 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); 170 101 171 102 #if 0 172 173 174 175 176 177 178 179 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))); 180 111 #endif 181 112 182 183 (((long long)fin * mfn + ((pd + 1) * (mfd + 1)) / 2) /184 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))) ); 185 116 186 187 188 189 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)); 190 121 191 122 return perclk1; 192 123 } 193 124 … … 196 127 * can override the actual bsp_start routine used. 197 128 */ 198 199 129 void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); 200 201 130 202 131 /** 203 132 * Reset the system. 204 133 * 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 212 135 * fire, thus resetting the system. 213 136 */ 214 137 void bsp_reset(void) 215 138 { 216 139 rtems_interrupt_level level; 217 140 218 141 _CPU_ISR_Disable(level); 219 142 220 221 143 printk("\n\rI should reset here.\n\r"); 144 while(1); 222 145 }
Note: See TracChangeset
for help on using the changeset viewer.