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

4.104.114.84.95
Last change on this file since 662c157 was 662c157, checked in by Till Straumann <strauman@…>, on Sep 4, 2006 at 11:29:29 PM
  • startup/bspstart.c, start/start.S: Since the crude memory autodetection code can easily fail (boards with 'reserved' regions - I experienced a hard lockup on a dell precision 490 when writing past the bios-reported memory size) I added code that a) tries to save and use multiboot info, if present b) allows applications to override/set memory size via a weak alias.
  • Property mode set to 100644
File size: 7.0 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
91                /* Save multiboot info */
92                cmp     $0x2badb002,eax
93                jne             1f
94                /* We have multiboot info; let's hope DS and ES are OK... */
95                movl    ebx, SYM(_boot_multiboot_info_p)
96                /* Check for memory size info and save */
97                movl    ebx, esi
98                movl    $SYM(_boot_multiboot_info), edi
99                movsd
100                /* only save flag 1 since that's the only data we save */
101                and             $1,-4(edi)
102                je              1f
103                movl    $2,ecx
104                rep movsd
1051:
106#ifdef DEBUG_EARLY_START
107        /*
108         * Must get video attribute to have a working printk.
109         * Note that the following code assume we already have
110         * valid segments and a stack. It should be true for
111         * any loader starting RTEMS in protected mode (or
112         * at least I hope so : -)).
113         */
114        call _IBMPC_initVideo
115        /*
116         * try printk and a getchar in polling mode ASAP
117         */
118        pushl   $welcome_msg
119        call    printk
120        addl    $4, esp
121
122        /* call debugPollingGetChar */
123
124#endif
125
126/*----------------------------------------------------------------------------+
127| Load the segment registers (this is done by the board's BSP) and perform any
128| other board specific initialization procedures, this piece of code
129| does not know anything about
130|
131| NOTE: Upon return, gs will contain the segment descriptor for a segment which
132|       maps directly to all of physical memory.
133+----------------------------------------------------------------------------*/
134
135        jmp     SYM (_load_segments)    # load board dependent segments
136
137/*----------------------------------------------------------------------------+
138| Set up the stack
139+----------------------------------------------------------------------------*/
140
141        PUBLIC (_establish_stack)
142SYM (_establish_stack):
143
144        movl    $_end, eax              # eax = end of bss/start of heap
145        addl    $STACK_SIZE, eax        # make room for stack
146        andl    $0xffffffc0, eax        # align it on 16 byte boundary
147        movl    eax, esp                # set stack pointer
148        movl    eax, ebp                # set base pointer
149
150/*----------------------------------------------------------------------------+
151| Zero out the BSS segment
152+----------------------------------------------------------------------------*/
153
154SYM (zero_bss):
155        cld                             # make direction flag count up
156        movl    $ SYM (_end), ecx       # find end of .bss
157        movl    $ SYM (_bss_start), edi # edi = beginning of .bss
158        subl    edi, ecx                # ecx = size of .bss in bytes
159        shrl    ecx                     # size of .bss in longs
160        shrl    ecx
161        xorl    eax, eax                # value to clear out memory
162        repne                           # while ecx != 0
163        stosl                           #   clear a long in the bss
164
165/*-------------------------------------------------------------------+
166| Initialize the video because zero_bss has cleared initVideo parameters
167| if it was called earlier
168| So from now we can use printk
169+-------------------------------------------------------------------*/
170        call _IBMPC_initVideo
171
172/*---------------------------------------------------------------------+
173| Check CPU type. Enable Cache and init coprocessor if needed.
174+---------------------------------------------------------------------*/
175        call checkCPUtypeSetCr0
176
177/*---------------------------------------------------------------------+
178| Transfer control to User's Board Support Package
179+---------------------------------------------------------------------*/
180
181        pushl   $0                      # environp
182        pushl   $0                      # argv
183        pushl   $0                      # argc
184        call    SYM (boot_card)
185        addl    $12, esp
186
187/*---------------------------------------------------------------------+
188| Clean up - we do not know anything about it, so we will
189| jump to BSP specific code to do cleanup
190+---------------------------------------------------------------------*/
191
192        jmp     SYM (_return_to_monitor)
193
194END_CODE
195
196BEGIN_DATA
197        PUBLIC(_boot_multiboot_info_p)
198SYM(_boot_multiboot_info_p):
199        .long 0
200
201        PUBLIC(_boot_multiboot_info)
202SYM(_boot_multiboot_info):
203        .long 0 /* flags */
204        .long 0 /* mem_lower */
205        .long 0 /* mem_upper */
206
207        PUBLIC(_stack_size)
208SYM(_stack_size):
209        .long STACK_SIZE
210
211#ifdef DEBUG_EARLY_START
212
213        PUBLIC (welcome_msg)
214SYM (welcome_msg) :
215        .string "Ready to debug RTEMS ?\nEnter <CR>\n"
216
217        PUBLIC (hex_msg)
218SYM (hex_msg) :
219        .string "0x%x\n"
220
221        PUBLIC (made_it_msg)
222SYM (made_it_msg) :
223        .string "made it to %d\n"
224
225#endif
226
227END_DATA
228
229END
Note: See TracBrowser for help on using the repository browser.