source: rtems/c/src/lib/libbsp/i386/pc386/start/start.S @ f74578a2

4.104.114.84.95
Last change on this file since f74578a2 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

  • Property mode set to 100644
File size: 6.5 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-1999.
28| *  On-Line Applications Research Corporation (OAR).
29| *
30| *  The license and distribution terms for this file may be
31| *  found in the file LICENSE in this distribution or at
32| *  http://www.rtems.com/license/LICENSE.
33| **************************************************************************
34|
35|  $Id$
36+--------------------------------------------------------------------------*/
37
38/*
39 * The most trivial start.s possible. It does not know anything
40 * about system it is running on, so it will jump to appropriate
41 * place in BSP specific place to do things it knows nothing about
42 */
43
44#include <rtems/asm.h>
45
46/*----------------------------------------------------------------------------+
47| Size of heap and stack:
48+----------------------------------------------------------------------------*/
49
50.set STACK_SIZE, 0x1000
51
52/*----------------------------------------------------------------------------+
53| CODE section
54+----------------------------------------------------------------------------*/
55
56BEGIN_CODE
57
58        PUBLIC (start)          # GNU default entry point
59
60        EXTERN (boot_card)
61        EXTERN (_load_segments)
62        EXTERN (_return_to_monitor)
63        EXTERN (_IBMPC_initVideo)
64        EXTERN (debugPollingGetChar)
65        EXTERN (checkCPUtypeSetCr0)
66
67/*
68 * In case this crashes on your machine and this is not due
69 * to video mode set by the loader, you may try to define
70 * the following variable:
71 */
72/* #define DEBUG_EARLY_START */
73
74SYM (start):
75        /*
76         *  When things are really, REALLY!, bad -- turn on the speaker and
77         *  lock up.  This shows whether or not we make it to a certain
78         *  location.
79         */
80#if 0
81        inb     $0x61, al
82        orb     $0x03, al
83        outb    al, $0x61       # enable the speaker
84speakl: jmp     speakl             # and SPIN!!!
85#endif
86
87        nop
88        cli                     # DISABLE INTERRUPTS!!!
89        cld
90#ifdef DEBUG_EARLY_START
91        /*
92         * Must get video attribute to have a working printk.
93         * Note that the following code assume we already have
94         * valid segments and a stack. It should be true for
95         * any loader starting RTEMS in protected mode (or
96         * at least I hope so : -)).
97         */
98        call _IBMPC_initVideo
99        /*
100         * try printk and a getchar in polling mode ASAP
101         */
102        pushl   $welcome_msg
103        call    printk
104        addl    $4, esp
105
106        /* call debugPollingGetChar */
107
108#endif
109
110/*----------------------------------------------------------------------------+
111| Load the segment registers (this is done by the board's BSP) and perform any
112| other board specific initialization procedures, this piece of code
113| does not know anything about
114|
115| NOTE: Upon return, gs will contain the segment descriptor for a segment which
116|       maps directly to all of physical memory.
117+----------------------------------------------------------------------------*/
118
119        jmp     SYM (_load_segments)    # load board dependent segments
120
121/*----------------------------------------------------------------------------+
122| Set up the stack
123+----------------------------------------------------------------------------*/
124
125        PUBLIC (_establish_stack)
126SYM (_establish_stack):
127
128        movl    $_end, eax              # eax = end of bss/start of heap
129        addl    $STACK_SIZE, eax        # make room for stack
130        andl    $0xffffffc0, eax        # align it on 16 byte boundary
131        movl    eax, esp                # set stack pointer
132        movl    eax, ebp                # set base pointer
133
134/*----------------------------------------------------------------------------+
135| Zero out the BSS segment
136+----------------------------------------------------------------------------*/
137
138SYM (zero_bss):
139        cld                             # make direction flag count up
140        movl    $ SYM (_end), ecx       # find end of .bss
141        movl    $ SYM (_bss_start), edi # edi = beginning of .bss
142        subl    edi, ecx                # ecx = size of .bss in bytes
143        shrl    ecx                     # size of .bss in longs
144        shrl    ecx
145        xorl    eax, eax                # value to clear out memory
146        repne                           # while ecx != 0
147        stosl                           #   clear a long in the bss
148
149/*-------------------------------------------------------------------+
150| Initialize the video because zero_bss has cleared initVideo parameters
151| if it was called earlier
152| So from now we can use printk
153+-------------------------------------------------------------------*/
154        call _IBMPC_initVideo
155
156/*---------------------------------------------------------------------+
157| Check CPU type. Enable Cache and init coprocessor if needed.
158+---------------------------------------------------------------------*/
159        call checkCPUtypeSetCr0
160
161/*---------------------------------------------------------------------+
162| Transfer control to User's Board Support Package
163+---------------------------------------------------------------------*/
164
165        pushl   $0                      # environp
166        pushl   $0                      # argv
167        pushl   $0                      # argc
168        call    SYM (boot_card)
169        addl    $12, esp
170
171/*---------------------------------------------------------------------+
172| Clean up - we do not know anything about it, so we will
173| jump to BSP specific code to do cleanup
174+---------------------------------------------------------------------*/
175
176        jmp     SYM (_return_to_monitor)
177
178END_CODE
179
180BEGIN_DATA
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
Note: See TracBrowser for help on using the repository browser.