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

4.115
Last change on this file since 1c0b8d7 was 1c0b8d7, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 18, 2011 at 8:11:08 PM

2011-11-18 Jennifer Averett <Jennifer.Averett@…>

PR 1925

  • Makefile.am, preinstall.am, console/serial_mouse_config.c, include/bsp.h, start/start.S: Converted 1386 console to the libchip style console
  • console/conscfg.c, console/console_control.c, console/printk_support.c, console/vgacons.c, console/vgacons.h: New files.
  • Property mode set to 100644
File size: 9.6 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#include <rtems/score/cpu.h>
46
47/*----------------------------------------------------------------------------+
48| Size of heap and stack:
49+----------------------------------------------------------------------------*/
50
51#ifndef CPU_STACK_ALIGNMENT
52#error  "Missing header ? CPU_STACK_ALIGNMENT NOT DEFINED"
53#endif
54
55.set STACK_SIZE, 0x1000
56
57/*----------------------------------------------------------------------------+
58| CODE section
59+----------------------------------------------------------------------------*/
60
61BEGIN_CODE
62
63        PUBLIC (start)          # GNU default entry point
64
65        EXTERN (boot_card)
66        EXTERN (_load_segments)
67        EXTERN (_return_to_monitor)
68        EXTERN (_IBMPC_initVideo)
69        EXTERN (debugPollingGetChar)
70        EXTERN (checkCPUtypeSetCr0)
71        EXTERN (BSP_console_select)
72        EXTERN (printk)
73#ifdef __SSE__
74        EXTERN (x86_capability)
75#ifdef __SSE3__
76        EXTERN (x86_capability_x)
77#endif
78#endif
79
80/*
81 * In case this crashes on your machine and this is not due
82 * to video mode set by the loader, you may try to define
83 * the following variable:
84 */
85/* #define DEBUG_EARLY_START */
86
87SYM (start):
88        /*
89         *  When things are really, REALLY!, bad -- turn on the speaker and
90         *  lock up.  This shows whether or not we make it to a certain
91         *  location.
92         */
93#if 0
94        inb     $0x61, al
95        orb     $0x03, al
96        outb    al, $0x61       # enable the speaker
97speakl: jmp     speakl             # and SPIN!!!
98#endif
99
100        nop
101        cli                     # DISABLE INTERRUPTS!!!
102        cld
103
104        /* Save multiboot info if we detect a multiboot loader */
105        cmp     $0x2badb002,eax
106        jne     2f
107
108        /* We have multiboot info; let's hope DS and ES are OK... */
109        movl    ebx, SYM(_boot_multiboot_info_p)
110        /* Check for memory size info and save */
111        movl    ebx, esi
112        movl    (esi), eax
113        movl    eax, ebx
114        movl    $SYM(_boot_multiboot_info), edi
115        /* save flags, always present */
116        movsd
117        /* flag 1 is memory */
118        and     $1, eax
119        je      1f
120        movl    $2, ecx
121        rep movsd
122        /* flag 2 is the command line */
1231:      movl    ebx, eax
124        and     $4, eax
125        je      3f
126        movl    (_boot_multiboot_info_p), eax
127        movl    16(eax), esi
128        movl    $255, ecx
1292:      movzbl  (esi), eax
130        test    al, al
131        je      3f
132        movb    al, (edi)
133        inc     edi
134        inc     esi
135        dec     ecx
136        je      3f
137        jmp     2b
1383:      xor     al, al
139        movb    al, (edi)
140#ifdef DEBUG_EARLY_START
141        /*
142         * Must get video attribute to have a working printk.
143         * Note that the following code assume we already have
144         * valid segments and a stack. It should be true for
145         * any loader starting RTEMS in protected mode (or
146         * at least I hope so : -)).
147         */
148        call _IBMPC_initVideo
149        /*
150         * try printk and a getchar in polling mode ASAP
151         */
152        movl    $welcome_msg, 0(esp)
153        call    printk
154        addl    $4, esp
155
156        /* call debugPollingGetChar */
157
158#endif
159
160/*----------------------------------------------------------------------------+
161| Load the segment registers (this is done by the board's BSP) and perform any
162| other board specific initialization procedures, this piece of code
163| does not know anything about
164|
165| NOTE: Upon return, gs will contain the segment descriptor for a segment which
166|       maps directly to all of physical memory.
167+----------------------------------------------------------------------------*/
168
169        jmp     SYM (_load_segments)    # load board dependent segments
170
171/*----------------------------------------------------------------------------+
172| Set up the stack
173+----------------------------------------------------------------------------*/
174
175        PUBLIC (_establish_stack)
176SYM (_establish_stack):
177
178        movl    $_end, eax              # eax = end of bss/start of heap
179        addl    $STACK_SIZE, eax        # make room for stack
180        subl    $4,          eax    # reserve room for arg to 'boot_card'
181        andl    $ - CPU_STACK_ALIGNMENT, eax    # align SP on CPU_STACK_ALIGNMENT boundary
182        movl    eax, esp                # set stack pointer
183        movl    eax, ebp                # set base pointer
184
185/*----------------------------------------------------------------------------+
186| Zero out the BSS segment
187+----------------------------------------------------------------------------*/
188
189SYM (zero_bss):
190        cld                             # make direction flag count up
191        movl    $ SYM (_end), ecx       # find end of .bss
192        movl    $ SYM (__bss_start), edi # edi = beginning of .bss
193        subl    edi, ecx                # ecx = size of .bss in bytes
194        shrl    ecx                     # size of .bss in longs
195        shrl    ecx
196        xorl    eax, eax                # value to clear out memory
197        repne                           # while ecx != 0
198        stosl                           #   clear a long in the bss
199
200/*-------------------------------------------------------------------+
201| Initialize the video because zero_bss has cleared initVideo parameters
202| if it was called earlier
203| So from now we can use printk
204+-------------------------------------------------------------------*/
205        call _IBMPC_initVideo
206
207/*---------------------------------------------------------------------+
208| Check CPU type. Enable Cache and init coprocessor if needed.
209+---------------------------------------------------------------------*/
210        call checkCPUtypeSetCr0
211
212#ifdef __SSE__
213        call SYM(enable_sse)
214#endif
215
216/*---------------------------------------------------------------------+
217| Transfer control to User's Board Support Package
218| Note: at the top we reserved space for the argument
219|       so that
220|          initial_esp = ( TOS - 4 ) & ~(CPU_STACK_ALIGNMENT-1)
221|       this ensures that
222|       1) esp is now aligned
223|       2) there is space for the cmdline pointer which we just
224|          may store at *(esp)
225+---------------------------------------------------------------------*/
226
227        movl    $SYM(_boot_multiboot_cmdline), (esp)
228        call    SYM (boot_card)
229
230        cli     # stops interrupts from being processed after hlt!
231        hlt     # shutdown
232
233#ifdef __SSE__
234/*--------------------------------------------------------------------+
235 | Enable SSE; we really only care about fxsave/fxrstor and leave
236 | The only feature *we* (as an OS) use is fxsave/fxrstor.
237 | But as a courtesy we make sure we don't execute on hardware
238 | that doesn't support features possibly used by the compiler.
239+---------------------------------------------------------------------*/
240        PUBLIC (enable_sse)
241SYM(enable_sse):
242        movl    SYM (x86_capability), eax
243        testl   $0x01000000, eax
244        jne     1f
245        movl    $SYM (no_fxsave_msg), 0(esp)
246        jmp     SYM(_sse_panic)
2471:
248        testl   $0x02000000, eax
249        jne     1f
250        movl    $SYM (no_sse_msg), 0(esp)
251        jmp     SYM(_sse_panic)
2521:
253#ifdef __SSE2__
254        testl   $0x04000000, eax
255        jne     1f
256        movl    $SYM (no_sse2_msg), 0(esp)
257        jmp     SYM(_sse_panic)
2581:
259#endif
260#ifdef __SSE3__
261        movl    SYM (x86_capability_x), eax
262        testl   $1, eax
263        jne     1f
264        movl    $SYM (no_sse3_msg), 0(esp)
265        jmp     SYM(_sse_panic)
2661:
267#endif
268        mov     cr4, eax                # OK to enable now
269        or      $0x600, eax
270        mov     eax, cr4
271        ret
272
273SYM(_sse_panic):
274        call SYM(printk)
2751:      hlt
276        jmp 1b
277#endif
278
279END_CODE
280
281BEGIN_DATA
282        PUBLIC(_boot_multiboot_info_p)
283SYM(_boot_multiboot_info_p):
284        .long 0
285
286        PUBLIC(_boot_multiboot_info)
287        PUBLIC(_boot_multiboot_flags)
288        PUBLIC(_boot_multiboot_memory)
289        PUBLIC(_boot_multiboot_cmdline)
290SYM(_boot_multiboot_info):
291SYM(_boot_multiboot_flags):
292        .long 0 /* flags */
293SYM(_boot_multiboot_memory):
294        .long 0 /* mem_lower */
295        .long 0 /* mem_upper */
296SYM(_boot_multiboot_cmdline):
297        .rept 256 /* cmd line */
298        .byte 0
299        .endr
300
301        PUBLIC(_stack_size)
302SYM(_stack_size):
303        .long STACK_SIZE
304
305#ifdef DEBUG_EARLY_START
306
307        PUBLIC (welcome_msg)
308SYM (welcome_msg) :
309        .string "Ready to debug RTEMS ?\nEnter <CR>\n"
310
311        PUBLIC (hex_msg)
312SYM (hex_msg) :
313        .string "0x%x\n"
314
315        PUBLIC (made_it_msg)
316SYM (made_it_msg) :
317        .string "made it to %d\n"
318
319#endif
320
321#ifdef __SSE__
322SYM (no_fxsave_msg) :
323        .string "PANIC: compiled for SSE but CPU seems to have no FXSAVE/FXRSTOR support (which I need)\n"
324SYM (no_sse_msg) :
325        .string "PANIC: compiled for SSE but your CPU seems to have no SSE support\n"
326#ifdef __SSE2__
327SYM (no_sse2_msg) :
328        .string "PANIC: compiled for SSE2 but your CPU seems to have no SSE2 support\n"
329#endif
330#ifdef __SSE3__
331SYM (no_sse3_msg) :
332        .string "PANIC: compiled for SSE3 but your CPU seems to have no SSE3 support\n"
333#endif
334#endif
335
336END_DATA
337
338END
Note: See TracBrowser for help on using the repository browser.