source: rtems/c/src/lib/libbsp/i386/pc386/start/start.s @ 2d7d605

4.104.114.84.9
Last change on this file since 2d7d605 was 2d7d605, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 19, 1998 at 2:41:23 PM

Patch from Aleksey <qqi@…>:

It fixes netboot build problem, KA9Q configuration
for pc386, some compiler wardning, it also removed some stuff
ifdef'ed with '#if 0'.

  • Property mode set to 100644
File size: 6.3 KB
Line 
1/*-------------------------------------------------------------------------+
2| start.s v1.1 - PC386 BSP - 1997/08/07
3+--------------------------------------------------------------------------+
4| This file contains the entry point for the application.
5| The name of this entry point is compiler dependent.
6| It jumps to the BSP which is responsible for performing all initialization.
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| Modified the 20/05/1998  by valette@crf.canon.fr in order to give a working
16| example of eraly stage debugging via the DEBUG_EARLY_START define.
17+--------------------------------------------------------------------------+
18| Disclaimer:
19|
20| This file is provided "AS IS" without warranty of any kind, either
21| expressed or implied.
22+--------------------------------------------------------------------------+
23| This code is based on an earlier generation RTEMS i386 start.s and the
24| following copyright applies:
25|
26| **************************************************************************
27| *  COPYRIGHT (c) 1989-1998.
28| *  On-Line Applications Research Corporation (OAR). 
29| *  Copyright assigned to U.S. Government, 1994.
30| *
31| *  The license and distribution terms for this file may be
32| *  found in the file LICENSE in this distribution or at
33| *  http://www.OARcorp.com/rtems/license.html.
34| **************************************************************************
35|
36|  $Id$
37+--------------------------------------------------------------------------*/
38
39/*
40 * The most trivial start.s possible. It does not know anything
41 * about system it is running on, so it will jump to appropriate
42 * place in BSP specific place to do things it knows nothing about
43 */
44
45#include "asm.h"
46
47/*----------------------------------------------------------------------------+
48| Size of heap and stack:       
49+----------------------------------------------------------------------------*/
50
51.set HEAP_SIZE,  256
52.set STACK_SIZE, 0x1000
53
54/*----------------------------------------------------------------------------+
55| CODE section
56+----------------------------------------------------------------------------*/
57
58BEGIN_CODE
59
60        PUBLIC (start)          # GNU default entry point
61
62        EXTERN (boot_card)
63        EXTERN (_load_segments)
64        EXTERN (_return_to_monitor)
65        EXTERN (_IBMPC_initVideo)
66        EXTERN (debugPollingGetChar)
67        EXTERN (checkCPUtypeSetCr0)
68       
69
70/*
71 * In case this crashes on your machine and this is not due
72 * to video mode set by the loader, you may try to define
73 * the following variable:
74 */
75/* #define DEBUG_EARLY_START */
76
77SYM (start):
78        /*
79         *  When things are really, REALLY!, bad -- turn on the speaker and
80         *  lock up.  This shows whether or not we make it to a certain
81         *  location.
82         */
83#if 0
84        inb     $0x61, al
85        orb     $0x03, al
86        outb    al, $0x61       # enable the speaker
87speakl: jmp     speakl             # and SPIN!!!
88#endif
89
90        nop
91        cli                     # DISABLE INTERRUPTS!!!
92        cld
93#ifdef DEBUG_EARLY_START
94        /*
95         * Must get video attribute to have a working printk.
96         * Note that the following code assume we already have
97         * valid segments and a stack. It should be true for
98         * any loader starting RTEMS in protected mode (or
99         * at least I hope so : -)).
100         */
101        call _IBMPC_initVideo
102        /*
103         * try printk and a getchar in polling mode ASAP
104         */
105        pushl   $welcome_msg
106        call    printk
107        addl    $4, esp
108
109        /* call debugPollingGetChar */
110       
111#endif 
112
113/*----------------------------------------------------------------------------+
114| Load the segment registers (this is done by the board's BSP) and perform any
115| other board specific initialization procedures, this piece of code
116| does not know anything about
117|
118| NOTE: Upon return, gs will contain the segment descriptor for a segment which
119|       maps directly to all of physical memory.
120+----------------------------------------------------------------------------*/
121
122        jmp     SYM (_load_segments)    # load board dependent segments
123
124/*----------------------------------------------------------------------------+
125| Set up the stack
126+----------------------------------------------------------------------------*/
127
128        PUBLIC (_establish_stack)
129SYM (_establish_stack):
130
131        movl    $_end, eax              # eax = end of bss/start of heap
132        addl    _heap_size, eax         # eax = end of heap
133        addl    $STACK_SIZE, eax        # make room for stack
134        andl    $0xffffffc0, eax        # align it on 16 byte boundary
135        movl    eax, esp                # set stack pointer
136        movl    eax, ebp                # set base pointer
137
138/*----------------------------------------------------------------------------+
139| Zero out the BSS segment
140+----------------------------------------------------------------------------*/
141
142SYM (zero_bss):
143        cld                             # make direction flag count up
144        movl    $ SYM (_end), ecx       # find end of .bss
145        movl    $ SYM (_bss_start), edi # edi = beginning of .bss
146        subl    edi, ecx                # ecx = size of .bss in bytes
147        shrl    ecx                     # size of .bss in longs
148        shrl    ecx
149        xorl    eax, eax                # value to clear out memory
150        repne                           # while ecx != 0
151        stosl                           #   clear a long in the bss
152
153/*---------------------------------------------------------------------+
154| Check CPU type. Enable Cache and init coprocessor if needed.
155+---------------------------------------------------------------------*/
156        call checkCPUtypeSetCr0
157/*---------------------------------------------------------------------+
158| Transfer control to User's Board Support Package
159+---------------------------------------------------------------------*/
160
161        pushl   $0                      # environp
162        pushl   $0                      # argv
163        pushl   $0                      # argc
164        call    SYM (boot_card)
165        addl    $12, esp
166
167/*---------------------------------------------------------------------+
168| Clean up - we do not know anything about it, so we will
169| jump to BSP specific code to do cleanup
170+---------------------------------------------------------------------*/
171
172        jmp     SYM (_return_to_monitor)
173
174END_CODE
175
176BEGIN_DATA
177
178        PUBLIC(_heap_size)
179SYM(_heap_size):
180        .long HEAP_SIZE << 10
181
182        PUBLIC(_stack_size)
183SYM(_stack_size):
184        .long STACK_SIZE
185
186#ifdef DEBUG_EARLY_START
187
188        PUBLIC (welcome_msg)
189SYM (welcome_msg) :
190        .string "Ready to debug RTEMS ?\nEnter <CR>\n"
191
192        PUBLIC (hex_msg)
193SYM (hex_msg) :
194        .string "0x%x\n"
195
196        PUBLIC (made_it_msg)
197SYM (made_it_msg) :
198        .string "made it to %d\n"
199
200#endif
201
202END_DATA
203
204END
205
206
207
208
Note: See TracBrowser for help on using the repository browser.