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

4.104.114.84.95
Last change on this file since cc1426bb was cc1426bb, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/02/04 at 11:19:28
  • start/start.S: Include <rtems/asm.h> instead of <asm.h>.
  • timer/timerisr.S: Include <rtems/asm.h> instead of <asm.h>.
  • 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/*
69 * In case this crashes on your machine and this is not due
70 * to video mode set by the loader, you may try to define
71 * the following variable:
72 */
73/* #define DEBUG_EARLY_START */
74
75SYM (start):
76        /*
77         *  When things are really, REALLY!, bad -- turn on the speaker and
78         *  lock up.  This shows whether or not we make it to a certain
79         *  location.
80         */
81#if 0
82        inb     $0x61, al
83        orb     $0x03, al
84        outb    al, $0x61       # enable the speaker
85speakl: jmp     speakl             # and SPIN!!!
86#endif
87
88        nop
89        cli                     # DISABLE INTERRUPTS!!!
90        cld
91#ifdef DEBUG_EARLY_START
92        /*
93         * Must get video attribute to have a working printk.
94         * Note that the following code assume we already have
95         * valid segments and a stack. It should be true for
96         * any loader starting RTEMS in protected mode (or
97         * at least I hope so : -)).
98         */
99        call _IBMPC_initVideo
100        /*
101         * try printk and a getchar in polling mode ASAP
102         */
103        pushl   $welcome_msg
104        call    printk
105        addl    $4, esp
106
107        /* call debugPollingGetChar */
108       
109#endif 
110
111/*----------------------------------------------------------------------------+
112| Load the segment registers (this is done by the board's BSP) and perform any
113| other board specific initialization procedures, this piece of code
114| does not know anything about
115|
116| NOTE: Upon return, gs will contain the segment descriptor for a segment which
117|       maps directly to all of physical memory.
118+----------------------------------------------------------------------------*/
119
120        jmp     SYM (_load_segments)    # load board dependent segments
121
122/*----------------------------------------------------------------------------+
123| Set up the stack
124+----------------------------------------------------------------------------*/
125
126        PUBLIC (_establish_stack)
127SYM (_establish_stack):
128
129        movl    $_end, eax              # eax = end of bss/start of heap
130        addl    $STACK_SIZE, eax        # make room for stack
131        andl    $0xffffffc0, eax        # align it on 16 byte boundary
132        movl    eax, esp                # set stack pointer
133        movl    eax, ebp                # set base pointer
134
135/*----------------------------------------------------------------------------+
136| Zero out the BSS segment
137+----------------------------------------------------------------------------*/
138
139SYM (zero_bss):
140        cld                             # make direction flag count up
141        movl    $ SYM (_end), ecx       # find end of .bss
142        movl    $ SYM (_bss_start), edi # edi = beginning of .bss
143        subl    edi, ecx                # ecx = size of .bss in bytes
144        shrl    ecx                     # size of .bss in longs
145        shrl    ecx
146        xorl    eax, eax                # value to clear out memory
147        repne                           # while ecx != 0
148        stosl                           #   clear a long in the bss
149
150/*-------------------------------------------------------------------+
151| Initialize the video because zero_bss has cleared initVideo parameters
152| if it was called earlier
153| So from now we can use printk
154+-------------------------------------------------------------------*/
155        call _IBMPC_initVideo
156               
157/*---------------------------------------------------------------------+
158| Check CPU type. Enable Cache and init coprocessor if needed.
159+---------------------------------------------------------------------*/
160        call checkCPUtypeSetCr0
161       
162/*---------------------------------------------------------------------+
163| Transfer control to User's Board Support Package
164+---------------------------------------------------------------------*/
165
166        pushl   $0                      # environp
167        pushl   $0                      # argv
168        pushl   $0                      # argc
169        call    SYM (boot_card)
170        addl    $12, esp
171
172/*---------------------------------------------------------------------+
173| Clean up - we do not know anything about it, so we will
174| jump to BSP specific code to do cleanup
175+---------------------------------------------------------------------*/
176
177        jmp     SYM (_return_to_monitor)
178
179END_CODE
180
181BEGIN_DATA
182
183        PUBLIC(_stack_size)
184SYM(_stack_size):
185        .long STACK_SIZE
186
187#ifdef DEBUG_EARLY_START
188
189        PUBLIC (welcome_msg)
190SYM (welcome_msg) :
191        .string "Ready to debug RTEMS ?\nEnter <CR>\n"
192
193        PUBLIC (hex_msg)
194SYM (hex_msg) :
195        .string "0x%x\n"
196
197        PUBLIC (made_it_msg)
198SYM (made_it_msg) :
199        .string "made it to %d\n"
200
201#endif
202
203END_DATA
204
205END
206
207
208
209
Note: See TracBrowser for help on using the repository browser.