source: rtems/c/src/lib/libbsp/arm/gba/startup/bspstart.c @ 3f0cfc56

4.104.114.84.95
Last change on this file since 3f0cfc56 was 3f0cfc56, checked in by Joel Sherrill <joel.sherrill@…>, on 03/11/07 at 15:24:18

2007-03-11 Joel Sherrill <joel@…>

  • startup/bspstart.c: Remove assignments of Cpu_table.do_zero_of_workspace to TRUE since TRUE is the default value in boot_card.c
  • Property mode set to 100644
File size: 6.4 KB
Line 
1/**
2 *  @file bspstart.c
3 *
4 *  This file contains the GBA BSP startup package.
5 *  It includes application, board, and monitor specific initialization and
6 *  configuration. The generic CPU dependent initialization has been
7 *  performed before this routine is invoked.
8 */
9/*
10 *  RTEMS GBA BSP
11 *
12 *  Copyright (c) 2004  Markku Puro <markku.puro@kopteri.net>
13 *
14 *  The license and distribution terms for this file may be
15 *  found in found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include <stdio.h>
22#include <bsp.h>
23#include <rtems/bspIo.h>
24#include <rtems/libio.h>
25#include <rtems/libcsupport.h>
26#include <gba.h>
27#include <conio.h>
28
29#define BSP_DEBUG  0
30
31/* Global Variables, Defined in 'linkcmds' */
32extern  void _end;
33extern  void _stack_size;
34extern  void _irq_max_vector;
35extern  void __heap_limit;
36extern  void __ro_start;
37extern  void __ro_end;
38extern  void __data_start;
39extern  void __data_end;
40extern  void __load_start_data;
41extern  void __load_stop_data;
42extern  void __ewram_start;
43extern  void __ewram_end;
44extern  void __load_start_ewram;
45extern  void __load_stop_ewram;
46extern  void __iwram_start;
47extern  void __iwram_end;
48extern  void __load_start_iwram;
49extern  void __load_stop_iwram;
50extern  void __bss_start;
51extern  void __bss_end;
52
53/**  The original BSP configuration table from the application. */
54extern rtems_configuration_table  Configuration;
55/** Our copy of BSP configuration table from the application. */
56rtems_configuration_table  BSP_Configuration;
57
58/* External Prototypes */
59extern void bsp_cleanup( void );
60extern void rtems_irq_mngt_init(void);
61extern void bsp_libc_init( void *, uint32_t, int );
62extern void bsp_postdriver_hook(void);
63
64
65/** Chip registers */
66volatile unsigned int *Regs = (unsigned int *)GBA_IO_REGS_ADDR;
67
68/**
69 *  Size of heap if it is 0 it will be dynamically defined by memory size,
70 *  otherwise the value should be changed by binary patch
71 */
72uint32_t   _heap_size = 0;
73
74/** Address of start of free memory - should be updated after creating new partitions or regions.*/
75uint32_t   rtemsFreeMemStart;
76
77/** CPU configuration table.    */
78rtems_cpu_table    Cpu_table;
79/** Program name - from main(). */
80char              *rtems_progname;
81
82
83/**
84 *  @brief BSP pretasking hook.
85 *
86 *  Called just before drivers are initialized.
87 *  Used to setup libc and install any BSP extensions.
88 *
89 *  NOTE: Must not use libc (to do io) from here, since drivers are not yet initialized.
90 *
91 *  @param  None
92 *  @return None
93 */
94void bsp_pretasking_hook(void)
95{
96
97  if (_heap_size == 0) {
98     _heap_size = (uint32_t)&__heap_limit - rtemsFreeMemStart;
99  }
100
101  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
102
103  rtemsFreeMemStart += _heap_size;
104
105
106#ifdef RTEMS_DEBUG
107  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
108#endif /* RTEMS_DEBUG */
109
110#if BSP_DEBUG
111  /*  The following information is very useful when debugging. */
112  printk("[bsp_pretasking_hook]\n");
113  printk("_heap_size  = 0x%x\n", _heap_size);
114  printk("_stack_size = 0x%x\n", (uint32_t)&_stack_size);
115  printk("_irq_max_vector = 0x%x\n", (uint32_t)&_irq_max_vector);
116  printk("__ro_start      = 0x%x : __ro_end     = 0x%x\n", (uint32_t)&__ro_start, (uint32_t)&__ro_end);
117  printk("__ewram_start   = 0x%x : __ewram_end  = 0x%x\n", (uint32_t)&__ewram_start, (uint32_t)&__ewram_end);
118  printk("__data_start    = 0x%x : __data_end   = 0x%x\n", (uint32_t)&__data_start, (uint32_t)&__data_end);
119  printk("__bss_start     = 0x%x : __bss_end    = 0x%x\n", (uint32_t)&__bss_start,(uint32_t)&__bss_end);
120  printk("__iwram_start   = 0x%x : __iwram_end  = 0x%x\n", (uint32_t)&__iwram_start,(uint32_t)&__iwram_end);
121  printk("__load_start_iwram = 0x%x\n", (uint32_t)&__load_start_iwram);
122  printk("__load_stop_iwram  = 0x%x\n", (uint32_t)&__load_stop_iwram);
123  printk("__load_start_ewram = 0x%x\n", (uint32_t)&__load_start_ewram);
124  printk("__load_stop_ewram  = 0x%x\n", (uint32_t)&__load_stop_ewram);
125  printk("__load_start_data  = 0x%x\n", (uint32_t)&__load_start_data);
126  printk("__load_stop_data   = 0x%x\n", (uint32_t)&__load_stop_data);
127#endif
128}
129
130
131/**
132 *  @brief BSP Start
133 *
134 *  Called before main is invoked.
135 *
136 *  @param  None
137 *  @return None
138 */
139void bsp_start_default( void )
140{
141  /* set the value of start of free memory. */
142  rtemsFreeMemStart = (uint32_t)&_end;
143
144  /* If we don't have command line arguments set default program name. */
145  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
146  Cpu_table.predriver_hook          = NULL;                /* use system's    */
147  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
148  Cpu_table.idle_task               = NULL; /* don't override system IDLE task */
149  Cpu_table.interrupt_stack_size    = 0;
150  Cpu_table.extra_mpci_receive_server_stack = 0;
151
152
153  /* Place RTEMS workspace at beginning of free memory. */
154  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
155  rtemsFreeMemStart += BSP_Configuration.work_space_size;
156
157  /* Init conio  */
158  gba_textmode(CO60);
159
160  /* Init rtems exceptions management  */
161  /*!!!!!GBA - Can't use exception vectors in GBA because they are already in GBA ROM BIOS */
162  /* rtems_exception_init_mngt(); */
163
164  /* Init rtems interrupt management */
165  rtems_irq_mngt_init();
166
167#if BSP_DEBUG
168  /* The following information is very useful when debugging. */
169  printk("[bsp_start]\n");
170  printk("rtemsFreeMemStart= 0x%x\n", rtemsFreeMemStart);
171  printk("__heap_limit     = 0x%x\n", (uint32_t)&__heap_limit);
172  printk("work_space_start = 0x%x size = 0x%x\n", BSP_Configuration.work_space_start,BSP_Configuration.work_space_size);
173  printk("maximum_extensions    = 0x%x\n", BSP_Configuration.maximum_extensions);
174  printk("microseconds_per_tick = 0x%x\n", BSP_Configuration.microseconds_per_tick);
175  printk("ticks_per_timeslice   = 0x%x\n", BSP_Configuration.ticks_per_timeslice);
176  printk("maximum_devices          = 0x%x\n", BSP_Configuration.maximum_devices);
177  printk("number_of_device_drivers = 0x%x\n", BSP_Configuration.number_of_device_drivers);
178  printk("Device_driver_table      = 0x%x\n", BSP_Configuration.Device_driver_table);
179#endif
180
181  /* Do we have enough memory */
182  if ((uint32_t)&__heap_limit < rtemsFreeMemStart) {
183     printk("\nFatal Error: Memory overflow[0x%x]!\n",rtemsFreeMemStart);
184     bsp_cleanup();
185  }
186
187}
188
189
190/**
191 *  @brief weak alias for bsp_start_default
192 *
193 *  By making this a weak alias for bsp_start_default, a brave soul
194 *  can override the actual bsp_start routine used.
195 */
196void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.