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

4.104.114.84.95
Last change on this file since b6394ae was b6394ae, checked in by Joel Sherrill <joel.sherrill@…>, on 04/15/98 at 15:13:01

Transitioned to shared bsp_libc_init() and cleaned up comments.

  • Property mode set to 100644
File size: 3.6 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.predriver_hook = NULL;
109  Cpu_table.postdriver_hook = bsp_postdriver_hook;
110  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
111  Cpu_table.do_zero_of_workspace = TRUE;
112  Cpu_table.interrupt_table_segment = 0;/* get_ds(); */
113  Cpu_table.interrupt_table_offset = (void *)0;
114  Cpu_table.interrupt_stack_size = 4096;
115  Cpu_table.extra_mpci_receive_server_stack = 0;
116
117  /*
118   *  Copy the table
119   */
120  BSP_Configuration = Configuration;
121
122  BSP_Configuration.work_space_start = sbrk( Configuration.work_space_size );
123  if ( BSP_Configuration.work_space_start == 0 )  {
124    /* Big trouble */
125    int write( int, void *, int );
126    char msg[] = "bsp_start() couldn't sbrk() RTEMS work space\n";
127    write( 2, msg, sizeof msg - 1 );
128    _exit( 1 );
129  }
130
131  /*
132   * Tell libio how many fd's we want and allow it to tweak config
133   */
134
135  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
136
137  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
138  /* does not return */
139
140  /* We only return here if the executive has finished.  This happens   */
141  /* when the task has called exit().                                   */
142  /* At this point we call _exit() which resides in djgcc.              */
143   
144  for (;;)
145          _exit( 0 );
146
147  /* no cleanup necessary for GO32 */
148
149  return 0;
150}
Note: See TracBrowser for help on using the repository browser.