source: rtems/c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c @ 4130d8e2

4.104.114.95
Last change on this file since 4130d8e2 was 4130d8e2, checked in by Joel Sherrill <joel.sherrill@…>, on 12/11/07 at 15:50:25

2007-12-11 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspstart.c: Eliminate copies of the Configuration Table. Use the RTEMS provided accessor macros to obtain configuration fields.
  • Property mode set to 100644
File size: 6.9 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 <cplb.h>
24#include <rtems/libio.h>
25#include <rtems/libcsupport.h>
26
27
28const unsigned int dcplbs_table[16][2] = { 
29        { 0xFFA00000,   (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) },
30        { 0xFF900000,   (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) }, /* L1 Data B */
31        { 0xFF800000,   (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) }, /* L1 Data A */
32        { 0xFFB00000,   (PAGE_SIZE_1MB | CPLB_DNOCACHE) },
33
34        { 0x20300000,   (PAGE_SIZE_1MB | CPLB_DNOCACHE) },      /* Async Memory Bank 3 */
35        { 0x20200000,   (PAGE_SIZE_1MB | CPLB_DNOCACHE) },      /* Async Memory Bank 2 (Secnd)  */
36        { 0x20100000,   (PAGE_SIZE_1MB | CPLB_DNOCACHE) },      /* Async Memory Bank 1 (Prim B) */
37        { 0x20000000,   (PAGE_SIZE_1MB | CPLB_DNOCACHE) },      /* Async Memory Bank 0 (Prim A) */
38
39        { 0x02400000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
40        { 0x02000000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
41        { 0x00C00000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
42        { 0x00800000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
43        { 0x00400000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
44        { 0x00000000,   (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
45
46        { 0xffffffff, 0xffffffff }                                                      /* end of section - termination */
47
48       }
49;
50
51
52const unsigned int _icplbs_table[16][2] = {
53        { 0xFFA00000,   (PAGE_SIZE_1MB | CPLB_I_PAGE_MGMT | CPLB_I_PAGE_MGMT | 0x4) },  /* L1 Code */
54        { 0xEF000000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },      /* AREA DE BOOT */
55        { 0xFFB00000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },     
56
57        { 0x20300000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },      /* Async Memory Bank 3 */
58        { 0x20200000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },      /* Async Memory Bank 2 (Secnd) */
59        { 0x20100000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },      /* Async Memory Bank 1 (Prim B) */
60        { 0x20000000,   (PAGE_SIZE_1MB | CPLB_INOCACHE) },      /* Async Memory Bank 0 (Prim A) */
61
62        { 0x02400000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
63        { 0x02000000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
64        { 0x00C00000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
65        { 0x00800000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
66        { 0x00400000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
67        { 0x00000000,   (PAGE_SIZE_4MB | CPLB_INOCACHE) },
68
69        { 0xffffffff, 0xffffffff }                                                      /* end of section - termination */
70
71       }
72;
73
74/*
75 *  Use the shared implementations of the following routines
76 */
77
78void bsp_postdriver_hook(void);
79void bsp_libc_init( void *, uint32_t, int );
80void Init_PLL (void);
81void Init_EBIU (void);
82void Init_Flags(void);
83void Init_RTC (void);
84
85void null_isr(void);
86
87/*
88 *  Function:   bsp_pretasking_hook
89 *  Created:    95/03/10
90 *
91 *  Description:
92 *      BSP pretasking hook.  Called just before drivers are initialized.
93 *      Used to setup libc and install any BSP extensions.
94 *
95 *  NOTES:
96 *      Must not use libc (to do io) from here, since drivers are
97 *      not yet initialized.
98 *
99 */
100
101void bsp_pretasking_hook(void)
102{
103    extern int HeapBase;
104    extern int HeapSize;
105    void         *heapStart = &HeapBase;
106    unsigned long heapSize = (unsigned long)&HeapSize;
107
108    bsp_libc_init(heapStart, heapSize, 0);
109
110#ifdef RTEMS_DEBUG
111    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
112#endif
113}
114
115/*
116 *  bsp_start
117 *
118 *  This routine does the bulk of the system initialization.
119 */
120
121void bsp_start( void )
122{
123   
124  extern void          * _WorkspaceBase;
125
126  /* BSP Hardware Initialization*/
127  Init_RTC();   /* Blackfin Real Time Clock initialization */ 
128  Init_PLL();   /* PLL initialization */
129  Init_EBIU();  /* EBIU initialization */
130  Init_Flags(); /* GPIO initialization */
131
132  /*
133   *  Allocate the memory for the RTEMS Work Space.  This can come from
134   *  a variety of places: hard coded address, malloc'ed from outside
135   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
136   *  typically done by stock BSPs) by subtracting the required amount
137   *  of work space from the last physical address on the CPU board.
138   */
139
140  /*
141   *  Need to "allocate" the memory for the RTEMS Workspace and
142   *  tell the RTEMS configuration where it is.  This memory is
143   *  not malloc'ed.  It is just "pulled from the air".
144   */
145
146  Configuration.work_space_start = (void *) &_WorkspaceBase;
147
148  int i=0;
149  for (i=5;i<16;i++) {
150    set_vector((rtems_isr_entry)null_isr, i, 1);
151  }
152 
153}
154
155 /*
156  * Init_PLL
157  *
158  * Routine to initialize the PLL. The Ezkit uses a 27 Mhz XTAL.
159  * See "../eZKit533/include/bsp.h" for more information.
160  */
161
162void Init_PLL (void)
163{
164 
165  unsigned int n;
166 
167  /* Configure PLL registers */
168  *((uint16_t*)PLL_LOCKCNT) = 0x1000;
169  *((uint16_t*)PLL_DIV) = PLL_CSEL|PLL_SSEL;
170  *((uint16_t*)PLL_CTL) = PLL_MSEL|PLL_DF;
171
172  /* Commands to set PLL values */
173  asm("cli r0;");
174  asm("idle;");
175  asm("sti r0;");
176 
177  /* Delay for PLL stabilization */
178  for (n=0; n<200; n++) {}
179 
180}
181
182 /*
183  * Init_EBIU
184  *
185  * Configure extern memory
186  */
187
188void Init_EBIU (void)
189{
190  /* Configure FLASH */
191  *((uint32_t*)EBIU_AMBCTL0)  = 0x7bb07bb0L;
192  *((uint32_t*)EBIU_AMBCTL1)  = 0x7bb07bb0L;
193  *((uint16_t*)EBIU_AMGCTL)   = 0x000f;
194 
195  /* Configure SDRAM
196  *((uint32_t*)EBIU_SDGCTL) = 0x0091998d;
197  *((uint16_t*)EBIU_SDBCTL) = 0x0013;
198  *((uint16_t*)EBIU_SDRRC)  = 0x0817;
199  */
200}
201
202 /*
203  * Init_Flags
204  *
205  * Enable LEDs port
206  */
207void Init_Flags(void)
208{
209  *((uint16_t*)FIO_INEN)    = 0x0100;
210  *((uint16_t*)FIO_DIR)     = 0x0000;
211  *((uint16_t*)FIO_EDGE)    = 0x0100;
212  *((uint16_t*)FIO_MASKA_D) = 0x0100;
213 
214  *((uint8_t*)FlashA_PortB_Dir)  = 0x3f;
215  *((uint8_t*)FlashA_PortB_Data) = 0x00;   
216}
217
218/*
219 * Helper Function to use the EzKits LEDS.
220 * Can be used by the Application.
221 */
222void setLED (uint8_t value)
223{
224  *((uint8_t*)FlashA_PortB_Data) = value;   
225}
226
227/*
228 * Helper Function to use the EzKits LEDS
229 */
230uint8_t getLED (void)
231{
232  return *((uint8_t*)FlashA_PortB_Data);
233}
234
235void initCPLB() {
236
237       int i = 0;
238       unsigned int *addr;
239       unsigned int *data;
240       
241       addr = (unsigned int *)0xffe00100;
242       data = (unsigned int *)0xffe00200;
243
244       while ( dcplbs_table[i][0] != 0xffffffff ) {
245               *addr = dcplbs_table[i][0];
246               *data = dcplbs_table[i][1];
247
248               addr++;
249               data++;
250       }
251}
Note: See TracBrowser for help on using the repository browser.