source: rtems/c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c @ 8d41236

4.104.114.84.95
Last change on this file since 8d41236 was 8d41236, checked in by Joel Sherrill <joel.sherrill@…>, on 10/23/06 at 19:38:12

2006-10-23 Joel Sherrill <joel@…>

  • bfin/ChangeLog, bfin/Makefile.am, bfin/acinclude.m4, bfin/configure.ac, bfin/eZKit533/.cvsignore, bfin/eZKit533/ChangeLog, bfin/eZKit533/Makefile.am, bfin/eZKit533/README, bfin/eZKit533/bsp_specs, bfin/eZKit533/configure, bfin/eZKit533/configure.ac, bfin/eZKit533/preinstall.am, bfin/eZKit533/times, bfin/eZKit533/console/console-io.c, bfin/eZKit533/include/.cvsignore, bfin/eZKit533/include/bsp.h, bfin/eZKit533/include/bspopts.h.in, bfin/eZKit533/include/coverhd.h, bfin/eZKit533/include/tm27.h, bfin/eZKit533/startup/bspstart.c, bfin/eZKit533/startup/linkcmds, bfin/shared/clock/clockdrv.c, bfin/shared/clock/rtc.c, bfin/shared/clock/tod.h, bfin/shared/console/console.c, bfin/shared/start/start.S, bfin/shared/timer/timer.c: New files.
  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*  bspstart.c for eZKit533
2 *
3 *  This routine starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before this routine is invoked.
7 * 
8 *  Copyright (c) 2006 by Atos Automacao Industrial Ltda.
9 *             written by Alain Schaefer <alain.schaefer@easc.ch>
10 *                    and Antonio Giovanini <antonio@atos.com.br>
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19
20#include <string.h>
21
22#include <bsp.h>
23#include <rtems/libio.h>
24#include <rtems/libcsupport.h>
25
26
27/*
28 *  The original table from the application and our copy of it with
29 *  some changes.
30 */
31
32extern rtems_configuration_table Configuration;
33
34rtems_configuration_table  BSP_Configuration;
35
36rtems_cpu_table Cpu_table;
37
38char *rtems_progname;
39
40/*
41 *  Use the shared implementations of the following routines
42 */
43
44void bsp_postdriver_hook(void);
45void bsp_libc_init( void *, uint32_t, int );
46void Init_PLL (void);
47void Init_EBIU (void);
48void Init_Flags(void);
49void Init_RTC (void);
50
51void null_isr(void);
52
53/*
54 *  Function:   bsp_pretasking_hook
55 *  Created:    95/03/10
56 *
57 *  Description:
58 *      BSP pretasking hook.  Called just before drivers are initialized.
59 *      Used to setup libc and install any BSP extensions.
60 *
61 *  NOTES:
62 *      Must not use libc (to do io) from here, since drivers are
63 *      not yet initialized.
64 *
65 */
66
67void bsp_pretasking_hook(void)
68{
69    extern int HeapBase;
70    extern int HeapSize;
71    void         *heapStart = &HeapBase;
72    unsigned long heapSize = (unsigned long)&HeapSize;
73
74    bsp_libc_init(heapStart, heapSize, 0);
75
76#ifdef RTEMS_DEBUG
77    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
78#endif
79}
80
81/*
82 *  bsp_start
83 *
84 *  This routine does the bulk of the system initialization.
85 */
86
87void bsp_start( void )
88{
89   
90    extern void          * _WorkspaceBase;
91    extern void          *_RamSize;
92
93  /* BSP Hardware Initialization*/
94  Init_RTC();   /* Blackfin Real Time Clock initialization */ 
95  Init_PLL();   /* PLL initialization */
96  Init_EBIU();  /* EBIU initialization */
97  Init_Flags(); /* GPIO initialization */
98
99
100    /*extern unsigned long  _M68k_Ramsize;
101    _M68k_Ramsize = (unsigned long)&_RamSize;*/ /* RAM size set in linker script */
102
103  /*
104   *  Allocate the memory for the RTEMS Work Space.  This can come from
105   *  a variety of places: hard coded address, malloc'ed from outside
106   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
107   *  typically done by stock BSPs) by subtracting the required amount
108   *  of work space from the last physical address on the CPU board.
109   */
110
111  /*
112   *  Need to "allocate" the memory for the RTEMS Workspace and
113   *  tell the RTEMS configuration where it is.  This memory is
114   *  not malloc'ed.  It is just "pulled from the air".
115   */
116
117  BSP_Configuration.work_space_start = (void *) &_WorkspaceBase;
118
119  /*
120   *  initialize the CPU table for this BSP
121   */
122
123  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
124  Cpu_table.postdriver_hook = bsp_postdriver_hook;
125 
126  /*
127   *  SIS does zero out memory BUT only when IT begins execution.  Thus
128   *  if we want to have a clean slate in the workspace each time we
129   *  begin execution of OUR application, then we must zero the workspace.
130   */
131  Cpu_table.do_zero_of_workspace = TRUE;
132
133 
134  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
135
136  int i=0;
137  for (i=5;i<16;i++) {
138    set_vector(null_isr, i, 1);
139  }
140 
141}
142
143 /*
144  * Init_PLL
145  *
146  * Routine to initialize the PLL. The Ezkit uses a 27 Mhz XTAL.
147  * See "../eZKit533/include/bsp.h" for more information.
148  */
149
150void Init_PLL (void)
151{
152 
153  unsigned int n;
154 
155  /* Configure PLL registers */
156  *((uint16_t*)PLL_LOCKCNT) = 0x1000;
157  *((uint16_t*)PLL_DIV) = PLL_CSEL|PLL_SSEL;
158  *((uint16_t*)PLL_CTL) = PLL_MSEL|PLL_DF;
159
160  /* Commands to set PLL values */
161  asm("cli r0;");
162  asm("idle;");
163  asm("sti r0;");
164 
165  /* Delay for PLL stabilization */
166  for (n=0; n<200; n++) {}
167 
168}
169
170 /*
171  * Init_EBIU
172  *
173  * Configure extern memory
174  */
175
176void Init_EBIU (void)
177{
178  /* Configure FLASH */
179  *((uint16_t*)EBIU_AMBCTL0)  = 0x7bb07bb0;
180  *((uint16_t*)EBIU_AMBCTL1)  = 0x7bb07bb0;
181  *((uint16_t*)EBIU_AMGCTL)   = 0x000f;
182 
183  /* Configure SDRAM
184  *((uint16_t*)EBIU_SDGCTL) = 0x0091998d;
185  *((uint16_t*)EBIU_SDBCTL) = 0x0013;
186  *((uint16_t*)EBIU_SDRRC)  = 0x0817;
187  */
188}
189
190 /*
191  * Init_Flags
192  *
193  * Enable LEDs port
194  */
195void Init_Flags(void)
196{
197  *((uint16_t*)FIO_INEN)    = 0x0100;
198  *((uint16_t*)FIO_DIR)     = 0x0000;
199  *((uint16_t*)FIO_EDGE)    = 0x0100;
200  *((uint16_t*)FIO_MASKA_D) = 0x0100;
201 
202  *((uint8_t*)FlashA_PortB_Dir)  = 0x3f;
203  *((uint8_t*)FlashA_PortB_Data) = 0x00;   
204}
205
206/*
207 * Helper Function to use the EzKits LEDS.
208 * Can be used by the Application.
209 */
210void setLED (char value)
211{
212  *((uint8_t*)FlashA_PortB_Data) = value;   
213}
214
215/*
216 * Helper Function to use the EzKits LEDS
217 */
218char getLED (void)
219{
220  return *((uint8_t*)FlashA_PortB_Data);
221}
Note: See TracBrowser for help on using the repository browser.