source: rtems/c/src/lib/libbsp/bfin/eZKit533/startup/bspstart.c @ 02aaec7

4.104.114.95
Last change on this file since 02aaec7 was dde1fedb, checked in by Joel Sherrill <joel.sherrill@…>, on 05/15/08 at 15:55:28

2008-05-15 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Add capability for bootcard.c BSP Initialization Framework to ask the BSP where it has memory for the RTEMS Workspace and C Program Heap. These collectively are referred to as work area. If the BSP supports this, then it does not have to include code to split the available memory between the two areas. This reduces the amount of code in the BSP specific bspstart.c file. Additionally, the shared framework can initialize the C Library, call rtems_debug_enable(), and dirty the work area memory. Until most/all BSPs support this new capability, if the BSP supports this, it should call RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION from its configure.ac. When the transition is complete, this autoconf macro can be removed.
  • Property mode set to 100644
File size: 6.8 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_libc_init( void *, uint32_t, int );
79void Init_PLL (void);
80void Init_EBIU (void);
81void Init_Flags(void);
82void Init_RTC (void);
83
84void null_isr(void);
85
86/*
87 *  Function:   bsp_pretasking_hook
88 *  Created:    95/03/10
89 *
90 *  Description:
91 *      BSP pretasking hook.  Called just before drivers are initialized.
92 *      Used to setup libc and install any BSP extensions.
93 *
94 *  NOTES:
95 *      Must not use libc (to do io) from here, since drivers are
96 *      not yet initialized.
97 *
98 */
99
100void bsp_pretasking_hook(void)
101{
102    extern int HeapBase;
103    extern int HeapSize;
104    void         *heapStart = &HeapBase;
105    unsigned long heapSize = (unsigned long)&HeapSize;
106
107    bsp_libc_init(heapStart, heapSize, 0);
108}
109
110/*
111 *  bsp_start
112 *
113 *  This routine does the bulk of the system initialization.
114 */
115
116void bsp_start( void )
117{
118   
119  extern void          * _WorkspaceBase;
120
121  /* BSP Hardware Initialization*/
122  Init_RTC();   /* Blackfin Real Time Clock initialization */ 
123  Init_PLL();   /* PLL initialization */
124  Init_EBIU();  /* EBIU initialization */
125  Init_Flags(); /* GPIO initialization */
126
127  /*
128   *  Allocate the memory for the RTEMS Work Space.  This can come from
129   *  a variety of places: hard coded address, malloc'ed from outside
130   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
131   *  typically done by stock BSPs) by subtracting the required amount
132   *  of work space from the last physical address on the CPU board.
133   */
134
135  /*
136   *  Need to "allocate" the memory for the RTEMS Workspace and
137   *  tell the RTEMS configuration where it is.  This memory is
138   *  not malloc'ed.  It is just "pulled from the air".
139   */
140
141  Configuration.work_space_start = (void *) &_WorkspaceBase;
142
143  int i=0;
144  for (i=5;i<16;i++) {
145    set_vector((rtems_isr_entry)null_isr, i, 1);
146  }
147 
148}
149
150 /*
151  * Init_PLL
152  *
153  * Routine to initialize the PLL. The Ezkit uses a 27 Mhz XTAL.
154  * See "../eZKit533/include/bsp.h" for more information.
155  */
156
157void Init_PLL (void)
158{
159 
160  unsigned int n;
161 
162  /* Configure PLL registers */
163  *((uint16_t*)PLL_LOCKCNT) = 0x1000;
164  *((uint16_t*)PLL_DIV) = PLL_CSEL|PLL_SSEL;
165  *((uint16_t*)PLL_CTL) = PLL_MSEL|PLL_DF;
166
167  /* Commands to set PLL values */
168  asm("cli r0;");
169  asm("idle;");
170  asm("sti r0;");
171 
172  /* Delay for PLL stabilization */
173  for (n=0; n<200; n++) {}
174 
175}
176
177 /*
178  * Init_EBIU
179  *
180  * Configure extern memory
181  */
182
183void Init_EBIU (void)
184{
185  /* Configure FLASH */
186  *((uint32_t*)EBIU_AMBCTL0)  = 0x7bb07bb0L;
187  *((uint32_t*)EBIU_AMBCTL1)  = 0x7bb07bb0L;
188  *((uint16_t*)EBIU_AMGCTL)   = 0x000f;
189 
190  /* Configure SDRAM
191  *((uint32_t*)EBIU_SDGCTL) = 0x0091998d;
192  *((uint16_t*)EBIU_SDBCTL) = 0x0013;
193  *((uint16_t*)EBIU_SDRRC)  = 0x0817;
194  */
195}
196
197 /*
198  * Init_Flags
199  *
200  * Enable LEDs port
201  */
202void Init_Flags(void)
203{
204  *((uint16_t*)FIO_INEN)    = 0x0100;
205  *((uint16_t*)FIO_DIR)     = 0x0000;
206  *((uint16_t*)FIO_EDGE)    = 0x0100;
207  *((uint16_t*)FIO_MASKA_D) = 0x0100;
208 
209  *((uint8_t*)FlashA_PortB_Dir)  = 0x3f;
210  *((uint8_t*)FlashA_PortB_Data) = 0x00;   
211}
212
213/*
214 * Helper Function to use the EzKits LEDS.
215 * Can be used by the Application.
216 */
217void setLED (uint8_t value)
218{
219  *((uint8_t*)FlashA_PortB_Data) = value;   
220}
221
222/*
223 * Helper Function to use the EzKits LEDS
224 */
225uint8_t getLED (void)
226{
227  return *((uint8_t*)FlashA_PortB_Data);
228}
229
230void initCPLB() {
231
232       int i = 0;
233       unsigned int *addr;
234       unsigned int *data;
235       
236       addr = (unsigned int *)0xffe00100;
237       data = (unsigned int *)0xffe00200;
238
239       while ( dcplbs_table[i][0] != 0xffffffff ) {
240               *addr = dcplbs_table[i][0];
241               *data = dcplbs_table[i][1];
242
243               addr++;
244               data++;
245       }
246}
Note: See TracBrowser for help on using the repository browser.