1 |
30 |
unneback |
/*-------------------------------------------------------------------------+
|
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.OARcorp.com/rtems/license.html.
|
33 |
|
|
| **************************************************************************
|
34 |
|
|
|
|
35 |
|
|
| $Id: start.S,v 1.2 2001-09-27 11:59:48 chris Exp $
|
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 "asm.h"
|
45 |
|
|
|
46 |
|
|
/*----------------------------------------------------------------------------+
|
47 |
|
|
| Size of heap and stack:
|
48 |
|
|
+----------------------------------------------------------------------------*/
|
49 |
|
|
|
50 |
|
|
.set STACK_SIZE, 0x1000
|
51 |
|
|
|
52 |
|
|
/*----------------------------------------------------------------------------+
|
53 |
|
|
| CODE section
|
54 |
|
|
+----------------------------------------------------------------------------*/
|
55 |
|
|
|
56 |
|
|
BEGIN_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 |
|
|
|
75 |
|
|
SYM (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
|
85 |
|
|
speakl: 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)
|
127 |
|
|
SYM (_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 |
|
|
|
139 |
|
|
SYM (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 |
|
|
| Check CPU type. Enable Cache and init coprocessor if needed.
|
152 |
|
|
+---------------------------------------------------------------------*/
|
153 |
|
|
call checkCPUtypeSetCr0
|
154 |
|
|
/*---------------------------------------------------------------------+
|
155 |
|
|
| Transfer control to User's Board Support Package
|
156 |
|
|
+---------------------------------------------------------------------*/
|
157 |
|
|
|
158 |
|
|
pushl $0 # environp
|
159 |
|
|
pushl $0 # argv
|
160 |
|
|
pushl $0 # argc
|
161 |
|
|
call SYM (boot_card)
|
162 |
|
|
addl $12, esp
|
163 |
|
|
|
164 |
|
|
/*---------------------------------------------------------------------+
|
165 |
|
|
| Clean up - we do not know anything about it, so we will
|
166 |
|
|
| jump to BSP specific code to do cleanup
|
167 |
|
|
+---------------------------------------------------------------------*/
|
168 |
|
|
|
169 |
|
|
jmp SYM (_return_to_monitor)
|
170 |
|
|
|
171 |
|
|
END_CODE
|
172 |
|
|
|
173 |
|
|
BEGIN_DATA
|
174 |
|
|
|
175 |
|
|
PUBLIC(_stack_size)
|
176 |
|
|
SYM(_stack_size):
|
177 |
|
|
.long STACK_SIZE
|
178 |
|
|
|
179 |
|
|
#ifdef DEBUG_EARLY_START
|
180 |
|
|
|
181 |
|
|
PUBLIC (welcome_msg)
|
182 |
|
|
SYM (welcome_msg) :
|
183 |
|
|
.string "Ready to debug RTEMS ?\nEnter \n"
|
184 |
|
|
|
185 |
|
|
PUBLIC (hex_msg)
|
186 |
|
|
SYM (hex_msg) :
|
187 |
|
|
.string "0x%x\n"
|
188 |
|
|
|
189 |
|
|
PUBLIC (made_it_msg)
|
190 |
|
|
SYM (made_it_msg) :
|
191 |
|
|
.string "made it to %d\n"
|
192 |
|
|
|
193 |
|
|
#endif
|
194 |
|
|
|
195 |
|
|
END_DATA
|
196 |
|
|
|
197 |
|
|
END
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|