source: rtems/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @ 67a2288

4.104.114.84.95
Last change on this file since 67a2288 was 67a2288, checked in by Joel Sherrill <joel.sherrill@…>, on 07/23/98 at 22:02:34

Patch from Eric VALETTE <valette@…>:

Here is a enhanced version of my previous patch. This patch enables
to potentially share the new interrupt management code for all Intel targets
(pc386, go32 and force386) bsp.

Note : this patch is complete only for pc386. It still needs to

be completed for go32 and force386. I carrefully checked
that anything needed is in for force386 (only some function
name changes for IDT manipulation and GDT segment
manipulation). But anyway I will not be able to test any
of theses targets...

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/*-------------------------------------------------------------------------+
2| bspstart.c v1.1 - PC386 BSP - 1997/08/07
3+--------------------------------------------------------------------------+
4| This file contains the PC386 BSP startup package. It includes application,
5| board, and monitor specific initialization and configuration. The generic CPU
6| dependent initialization has been performed before this routine is invoked.
7+--------------------------------------------------------------------------+
8| (C) Copyright 1997 -
9| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
10|
11| http://pandora.ist.utl.pt
12|
13| Instituto Superior Tecnico * Lisboa * PORTUGAL
14+--------------------------------------------------------------------------+
15| Disclaimer:
16|
17| This file is provided "AS IS" without warranty of any kind, either
18| expressed or implied.
19+--------------------------------------------------------------------------+
20| This code is based on:
21|   bspstart.c,v 1.8 1996/05/28 13:12:40 joel Exp - go32 BSP
22| With the following copyright notice:
23| **************************************************************************
24| *  COPYRIGHT (c) 1989-1998.
25| *  On-Line Applications Research Corporation (OAR).
26| *  Copyright assigned to U.S. Government, 1994.
27| *
28| *  The license and distribution terms for this file may be
29| *  found in found in the file LICENSE in this distribution or at
30| *  http://www.OARcorp.com/rtems/license.html.
31| **************************************************************************
32|
33|  $Id$
34+--------------------------------------------------------------------------*/
35
36
37#include <bsp.h>
38#include <libcsupport.h>
39#include <rtems/libio.h>
40 
41/*-------------------------------------------------------------------------+
42| Global Variables
43+--------------------------------------------------------------------------*/
44extern rtems_unsigned32 _end;           /* End of BSS. Defined in 'linkcmds'. */
45extern rtems_unsigned32 _heap_size;   /* Size of stack. Defined in 'start.s'. */
46extern rtems_unsigned32 _stack_size;  /* Size of heap. Defined in 'start.s'.  */
47
48rtems_unsigned32 rtemsFreeMemStart;
49                         /* Address of start of free memory - should be updated
50                            after creating new partitions or regions.         */
51
52/* The original BSP configuration table from the application and our copy of it
53   with some changes. */
54
55extern rtems_configuration_table  Configuration;
56       rtems_configuration_table  BSP_Configuration;
57
58rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
59char            *rtems_progname;               /* Program name - from main(). */
60
61
62/*-------------------------------------------------------------------------+
63| External Prototypes
64+--------------------------------------------------------------------------*/
65extern void _exit(int);  /* define in exit.c */
66void bsp_libc_init( void *, unsigned32, int );
67void bsp_postdriver_hook(void);
68extern void rtems_irq_mngt_init();
69
70/*-------------------------------------------------------------------------+
71|         Function: bsp_pretasking_hook
72|      Description: BSP pretasking hook.  Called just before drivers are
73|                   initialized. Used to setup libc and install any BSP
74|                   extensions. NOTE: Must not use libc (to do io) from here,
75|                   since drivers are not yet initialized.
76| Global Variables: None.
77|        Arguments: None.
78|          Returns: Nothing.
79+--------------------------------------------------------------------------*/
80void bsp_pretasking_hook(void)
81{
82  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
83    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
84
85  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
86  rtemsFreeMemStart += _heap_size;           /* HEAP_SIZE  in KBytes */
87
88
89#ifdef RTEMS_DEBUG
90
91  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
92
93#endif /* RTEMS_DEBUG */
94} /* bsp_pretasking_hook */
95 
96
97/*-------------------------------------------------------------------------+
98|         Function: bsp_start
99|      Description: Called before main is invoked.
100| Global Variables: None.
101|        Arguments: None.
102|          Returns: Nothing.
103+--------------------------------------------------------------------------*/
104void bsp_start( void )
105{
106  rtemsFreeMemStart = (rtems_unsigned32)&_end + _heap_size + _stack_size;
107                                    /* set the value of start of free memory. */
108
109  /* If we don't have command line arguments set default program name. */
110
111  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
112  Cpu_table.predriver_hook          = NULL;                /* use system's    */
113  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
114  Cpu_table.idle_task               = NULL;
115                                          /* do not override system IDLE task */
116  Cpu_table.do_zero_of_workspace    = TRUE;
117  Cpu_table.interrupt_table_segment = get_ds();
118  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
119  Cpu_table.interrupt_stack_size    = 4096;
120  Cpu_table.extra_mpci_receive_server_stack = 0;
121
122  /* Place RTEMS workspace at beginning of free memory. */
123
124  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
125    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
126
127  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
128  rtemsFreeMemStart += BSP_Configuration.work_space_size;
129
130  console_reserve_resources(&BSP_Configuration);
131
132  /*
133   * Init trems_interrupt_management
134   */
135  rtems_irq_mngt_init();
136 
137  /*
138   *  The following information is very useful when debugging.
139   */
140
141#if 0
142  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
143  printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
144  printk( "microseconds_per_tick = 0x%x\n",
145     BSP_Configuration.microseconds_per_tick );
146  printk( "ticks_per_timeslice = 0x%x\n",
147     BSP_Configuration.ticks_per_timeslice );
148  printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
149  printk( "number_of_device_drivers = 0x%x\n",
150     BSP_Configuration.number_of_device_drivers );
151  printk( "Device_driver_table = 0x%x\n",
152     BSP_Configuration.Device_driver_table );
153
154  printk( "_heap_size = 0x%x\n", _heap_size );
155  printk( "_stack_size = 0x%x\n", _stack_size );
156  printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
157  printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
158  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
159#endif
160} /* bsp_start */
Note: See TracBrowser for help on using the repository browser.