source: rtems/c/src/lib/libbsp/powerpc/gen405/startup/bspstart.c @ d34d8692

4.104.114.95
Last change on this file since d34d8692 was d34d8692, checked in by Joel Sherrill <joel.sherrill@…>, on 12/04/07 at 22:22:26

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

  • include/bsp.h, startup/bspstart.c: Move interrupt_stack_size field from CPU Table to Configuration Table. Eliminate CPU Table from all ports. Delete references to CPU Table in all forms.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*  bsp_start()
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 *  INPUT:  NONE
9 *
10 *  OUTPUT: NONE
11 *
12 *  Author:     Thomas Doerfler <td@imd.m.isar.de>
13 *              IMD Ingenieurbuero fuer Microcomputertechnik
14 *
15 *  COPYRIGHT (c) 1998 by IMD
16 *
17 *  Changes from IMD are covered by the original distributions terms.
18 *  This file has been derived from the papyrus BSP:
19 *
20 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
21 *
22 *  COPYRIGHT (c) 1995 by i-cubed ltd.
23 *
24 *  To anyone who acknowledges that this file is provided "AS IS"
25 *  without any express or implied warranty:
26 *      permission to use, copy, modify, and distribute this file
27 *      for any purpose is hereby granted without fee, provided that
28 *      the above copyright notice and this notice appears in all
29 *      copies, and that the name of i-cubed limited not be used in
30 *      advertising or publicity pertaining to distribution of the
31 *      software without specific, written prior permission.
32 *      i-cubed limited makes no representations about the suitability
33 *      of this software for any purpose.
34 *
35 *  Modifications for spooling console driver and control of memory layout
36 *  with linker command file by
37 *              Thomas Doerfler <td@imd.m.isar.de>
38 *  for these modifications:
39 *  COPYRIGHT (c) 1997 by IMD, Puchheim, Germany.
40 *
41 *  To anyone who acknowledges that this file is provided "AS IS"
42 *  without any express or implied warranty:
43 *      permission to use, copy, modify, and distribute this file
44 *      for any purpose is hereby granted without fee, provided that
45 *      the above copyright notice and this notice appears in all
46 *      copies. IMD makes no representations about the suitability
47 *      of this software for any purpose.
48 *
49 *  Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c:
50 *
51 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
52 *  On-Line Applications Research Corporation (OAR).
53 *
54 *  Modifications for PPC405GP by Dennis Ehlin
55 *
56 *  $Id$
57 */
58
59#include <string.h>
60#include <fcntl.h>
61
62#include <bsp.h>
63#include <rtems/libio.h>
64#include <rtems/libcsupport.h>
65#include <ictrl.h>
66
67/*
68 *  The original table from the application and our copy of it with
69 *  some changes.
70 */
71
72extern rtems_configuration_table Configuration;
73rtems_configuration_table  BSP_Configuration;
74char *rtems_progname;
75void *bsp_ram_end = (void *)RAM_END;  /* first addr behind avail. ram area */
76
77/*
78 *  Driver configuration parameters
79 */
80uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
81boolean    bsp_serial_external_clock;
82boolean    bsp_serial_xon_xoff;
83boolean    bsp_serial_cts_rts;
84uint32_t   bsp_serial_rate;
85uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
86uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
87boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
88
89/*      Initialize whatever libc we are using
90 *      called from postdriver hook
91 */
92
93void bsp_postdriver_hook(void);
94void bsp_libc_init( void *, uint32_t, int );
95
96/*
97 *
98 *  bsp_predriver_hook
99 *
100 *  Before drivers are setup.
101 */
102
103void bsp_predriver_hook(void)
104{
105  rtems_status_code status;
106  /* init the PPC405 external interrupt controller handler... */
107  status = ictrl_init();
108}
109
110/*
111 *  Function:   bsp_pretasking_hook
112 *  Created:    95/03/10
113 *
114 *  Description:
115 *      BSP pretasking hook.  Called just before drivers are initialized.
116 *      Used to setup libc and install any BSP extensions.
117 *
118 *  NOTES:
119 *      Must not use libc (to do io) from here, since drivers are
120 *      not yet initialized.
121 *
122 */
123
124void bsp_pretasking_hook(void)
125{
126    extern int _end;
127    extern int _heap_end;
128    uint32_t          heap_start;
129    uint32_t        heap_size;
130    uint32_t        heap_end;
131
132    heap_start = (uint32_t  ) &_end;
133    if (heap_start & (CPU_ALIGNMENT-1))
134        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
135
136    heap_end = (uint32_t  ) &_heap_end;
137    if (heap_end & (CPU_ALIGNMENT-1))
138        heap_end = (heap_end + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
139
140    heap_size = heap_end - heap_start;
141
142    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
143
144#ifdef RTEMS_DEBUG
145    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
146#endif
147
148}
149
150/*
151 *  bsp_start
152 *
153 *  This routine does the bulk of the system initialization.
154 */
155
156void bsp_start( void )
157{
158  /*
159   *  Allocate the memory for the RTEMS Work Space.  This can come from
160   *  a variety of places: hard coded address, malloc'ed from outside
161   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
162   *  typically done by stock BSPs) by subtracting the required amount
163   *  of work space from the last physical address on the CPU board.
164   */
165
166  /*
167   *  Need to "allocate" the memory for the RTEMS Workspace and
168   *  tell the RTEMS configuration where it is.  This memory is
169   *  not malloc'ed.  It is just "pulled from the air".
170   */
171  /* FIME: plan usage of RAM better:
172     - make top of ram dynamic,
173     - take out some part for persistant log
174     - make rest of ram to heap...
175     -remove RAM_END from bsp.h, this cannot be valid...
176      or must be a function call
177   */
178  BSP_Configuration.work_space_start = (void *)
179      ((char *)(bsp_ram_end)) - BSP_Configuration.work_space_size;
180
181  /*
182   *  initialize the device driver parameters
183   */
184  bsp_clicks_per_usec = 300;
185  bsp_serial_per_sec = 14625000;
186  bsp_serial_external_clock = 0;
187  bsp_timer_internal_clock  = 1;
188  bsp_serial_xon_xoff = 0;
189  bsp_serial_cts_rts = 1;
190  bsp_serial_rate = 115200;
191  bsp_timer_average_overhead = 2;
192  bsp_timer_least_valid = 3;
193}
Note: See TracBrowser for help on using the repository browser.