source: rtems/c/src/lib/libbsp/i386/go32/startup/bspstart.c @ bd9c3d1

4.104.114.84.9
Last change on this file since bd9c3d1 was bd9c3d1, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 15, 1998 at 8:50:31 PM

Numerous changes which in total greatly reduced the amount of source
code in each BSP's bspstart.c. These changes were:

+ confdefs.h now knows libio's semaphore requirements
+ shared/main.c now copies Configuration to BSP_Configuration
+ shared/main.c fills in the Cpu_table with default values

This removed the need for rtems_libio_config() and the constant
BSP_LIBIO_MAX_FDS in every BSP. Plus now the maximum number of open
files can now be set on the gcc command line.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  This routine starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before this routine is invoked.
6 *
7 *  COPYRIGHT (c) 1989-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright assigned to U.S. Government, 1994.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <bsp.h>
19#include <rtems/libio.h>
20 
21#include <libcsupport.h>
22#include <zilog/z8036.h>
23 
24#include <string.h>
25 
26/*
27 *  The original table from the application and our copy of it with
28 *  some changes.
29 */
30
31extern rtems_configuration_table  Configuration;
32rtems_configuration_table  BSP_Configuration;
33
34rtems_cpu_table Cpu_table;
35
36char *rtems_progname;
37
38/*
39 *  Use the shared implementations of the following routines
40 */
41 
42void bsp_postdriver_hook(void);
43void bsp_libc_init( void *, unsigned32, int );
44
45/*
46 *  Function:   bsp_pretasking_hook
47 *  Created:    95/03/10
48 *
49 *  Description:
50 *      BSP pretasking hook.  Called just before drivers are initialized.
51 *      Used to setup libc and install any BSP extensions.
52 *
53 *  NOTES:
54 *      Must not use libc (to do io) from here, since drivers are
55 *      not yet initialized.
56 *
57 */
58 
59void bsp_pretasking_hook(void)
60{
61    rtems_unsigned32        heap_start;
62
63#if 0
64    extern int end;
65    heap_start = (rtems_unsigned32) &end;
66#else
67    void * sbrk( int );
68    heap_start = (rtems_unsigned32) sbrk( 64 * 1024 + CPU_ALIGNMENT );
69#endif
70    if (heap_start & (CPU_ALIGNMENT-1))
71        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
72
73    bsp_libc_init((void *) heap_start, 64 * 1024, 0);
74
75 
76#ifdef RTEMS_DEBUG
77    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
78#endif
79}
80 
81/*
82 *  main/bsp_start
83 *
84 *  This routine does the bulk of the system initialization.
85 */
86
87/* This is the original command line passed from DOS */
88char ** Go32_Argv;
89
90int main(
91  int argc,
92  char **argv,
93  char **environp
94)
95{
96  extern void * sbrk( int );
97  extern volatile void _exit( int );
98
99  /* Set up arguments that we can access later */
100  Go32_Argv = argv;
101
102  if ((argc > 0) && argv && argv[0])
103    rtems_progname = argv[0];
104  else
105    rtems_progname = "RTEMS";
106
107  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
108  Cpu_table.postdriver_hook = bsp_postdriver_hook;
109  Cpu_table.interrupt_table_segment = 0;/* get_ds(); */
110  Cpu_table.interrupt_table_offset = (void *)0;
111  Cpu_table.interrupt_stack_size = 4096;
112
113  BSP_Configuration.work_space_start = sbrk( Configuration.work_space_size );
114  if ( BSP_Configuration.work_space_start == 0 )  {
115    /* Big trouble */
116    int write( int, void *, int );
117    char msg[] = "bsp_start() couldn't sbrk() RTEMS work space\n";
118    write( 2, msg, sizeof msg - 1 );
119    _exit( 1 );
120  }
121
122  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
123  /* does not return */
124
125  /* We only return here if the executive has finished.  This happens   */
126  /* when the task has called exit().                                   */
127  /* At this point we call _exit() which resides in djgcc.              */
128   
129  for (;;)
130          _exit( 0 );
131
132  /* no cleanup necessary for GO32 */
133
134  return 0;
135}
Note: See TracBrowser for help on using the repository browser.