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

4.104.114.84.95
Last change on this file since 3c7ed6b was 3c7ed6b, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/05 at 18:46:04

2005-07-06 Markku Puro <markku.puro@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clockdrv.c, console/conio.c, console/console.c, console/defaultfont.c, include/arm_mode_bits.h, include/asm_macros.h, include/bsp.h, include/bspopts.h.in, include/conio.h, include/gba.h, include/gba_registers.h, include/tm27.h, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, start/logo.S, start/start.S, startup/bspstart.c, startup/cpu.c, startup/cpu_asm.S, startup/exit.c, startup/linkcmds, timer/timer.c: New files.
  • Property mode set to 100644
File size: 6.7 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 *, rtems_unsigned32, 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 */
72rtems_unsigned32   _heap_size = 0;
73
74/** Address of start of free memory - should be updated after creating new partitions or regions.*/
75rtems_unsigned32   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 = (rtems_unsigned32)&__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", (rtems_unsigned32)&_stack_size);
115  printk("_irq_max_vector = 0x%x\n", (rtems_unsigned32)&_irq_max_vector);
116  printk("__ro_start      = 0x%x : __ro_end     = 0x%x\n", (rtems_unsigned32)&__ro_start, (rtems_unsigned32)&__ro_end);
117  printk("__ewram_start   = 0x%x : __ewram_end  = 0x%x\n", (rtems_unsigned32)&__ewram_start, (rtems_unsigned32)&__ewram_end);
118  printk("__data_start    = 0x%x : __data_end   = 0x%x\n", (rtems_unsigned32)&__data_start, (rtems_unsigned32)&__data_end);
119  printk("__bss_start     = 0x%x : __bss_end    = 0x%x\n", (rtems_unsigned32)&__bss_start,(rtems_unsigned32)&__bss_end);
120  printk("__iwram_start   = 0x%x : __iwram_end  = 0x%x\n", (rtems_unsigned32)&__iwram_start,(rtems_unsigned32)&__iwram_end);
121  printk("__load_start_iwram = 0x%x\n", (rtems_unsigned32)&__load_start_iwram);
122  printk("__load_stop_iwram  = 0x%x\n", (rtems_unsigned32)&__load_stop_iwram);
123  printk("__load_start_ewram = 0x%x\n", (rtems_unsigned32)&__load_start_ewram);
124  printk("__load_stop_ewram  = 0x%x\n", (rtems_unsigned32)&__load_stop_ewram);
125  printk("__load_start_data  = 0x%x\n", (rtems_unsigned32)&__load_start_data);
126  printk("__load_stop_data   = 0x%x\n", (rtems_unsigned32)&__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 = (rtems_unsigned32)&_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.do_zero_of_workspace    = TRUE;
150  Cpu_table.interrupt_stack_size    = 0;
151  Cpu_table.extra_mpci_receive_server_stack = 0;
152
153
154  /* Place RTEMS workspace at beginning of free memory. */
155  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
156  rtemsFreeMemStart += BSP_Configuration.work_space_size;
157
158  /* Init conio  */
159  gba_textmode(CO60);
160
161  /* Init rtems exceptions management  */
162  /*!!!!!GBA - Can't use exception vectors in GBA because they are already in GBA ROM BIOS */
163  /* rtems_exception_init_mngt(); */
164
165  /* Init rtems interrupt management */
166  rtems_irq_mngt_init();
167
168#if BSP_DEBUG
169  /* The following information is very useful when debugging. */
170  printk("[bsp_start]\n");
171  printk("rtemsFreeMemStart= 0x%x\n", rtemsFreeMemStart);
172  printk("__heap_limit     = 0x%x\n", (rtems_unsigned32)&__heap_limit);
173  printk("work_space_start = 0x%x size = 0x%x\n", BSP_Configuration.work_space_start,BSP_Configuration.work_space_size);
174  printk("maximum_extensions    = 0x%x\n", BSP_Configuration.maximum_extensions);
175  printk("microseconds_per_tick = 0x%x\n", BSP_Configuration.microseconds_per_tick);
176  printk("ticks_per_timeslice   = 0x%x\n", BSP_Configuration.ticks_per_timeslice);
177  printk("maximum_devices          = 0x%x\n", BSP_Configuration.maximum_devices);
178  printk("number_of_device_drivers = 0x%x\n", BSP_Configuration.number_of_device_drivers);
179  printk("Device_driver_table      = 0x%x\n", BSP_Configuration.Device_driver_table);
180#endif
181
182  /* Do we have enough memory */
183  if ((rtems_unsigned32)&__heap_limit < rtemsFreeMemStart) {
184     printk("\nFatal Error: Memory overflow[0x%x]!\n",rtemsFreeMemStart);
185     bsp_cleanup();
186  }
187
188}
189
190
191/**
192 *  @brief weak alias for bsp_start_default
193 *
194 *  By making this a weak alias for bsp_start_default, a brave soul
195 *  can override the actual bsp_start routine used.
196 */
197void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.