1 |
27 |
unneback |
#ifndef CYGONCE_HAL_PLATFORM_INC
|
2 |
|
|
#define CYGONCE_HAL_PLATFORM_INC
|
3 |
|
|
##=============================================================================
|
4 |
|
|
##
|
5 |
|
|
## platform.inc
|
6 |
|
|
##
|
7 |
|
|
## PC platform support
|
8 |
|
|
##
|
9 |
|
|
##=============================================================================
|
10 |
|
|
#####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
## -------------------------------------------
|
12 |
|
|
## This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
##
|
15 |
|
|
## eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
## the terms of the GNU General Public License as published by the Free
|
17 |
|
|
## Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
##
|
19 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
## for more details.
|
23 |
|
|
##
|
24 |
|
|
## You should have received a copy of the GNU General Public License along
|
25 |
|
|
## with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
##
|
28 |
|
|
## As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
## or inline functions from this file, or you compile this file and link it
|
30 |
|
|
## with other works to produce a work based on this file, this file does not
|
31 |
|
|
## by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
## License. However the source code for this file must still be made available
|
33 |
|
|
## in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
##
|
35 |
|
|
## This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
## this file might be covered by the GNU General Public License.
|
37 |
|
|
##
|
38 |
|
|
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
## at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
## -------------------------------------------
|
41 |
|
|
#####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
##=============================================================================
|
43 |
|
|
#######DESCRIPTIONBEGIN####
|
44 |
|
|
##
|
45 |
|
|
## Author(s): jskov
|
46 |
|
|
## Contributors:jskov, pjo, nickg
|
47 |
|
|
## Date: 1999-01-07
|
48 |
|
|
## Purpose: PC platform support
|
49 |
|
|
## Description: This file contains any PC specific assembler macros needed to
|
50 |
|
|
## run eCos on a standard i386 PC.
|
51 |
|
|
##
|
52 |
|
|
##
|
53 |
|
|
######DESCRIPTIONEND####
|
54 |
|
|
##
|
55 |
|
|
##=============================================================================
|
56 |
|
|
|
57 |
|
|
#include
|
58 |
|
|
|
59 |
|
|
#include
|
60 |
|
|
|
61 |
|
|
##=============================================================================
|
62 |
|
|
## CPU initialization
|
63 |
|
|
|
64 |
|
|
#ifndef CYGPKG_HAL_I386_CPU_INIT_DEFINED
|
65 |
|
|
|
66 |
|
|
#define CYGPKG_HAL_I386_CPU_INIT_DEFINED
|
67 |
|
|
|
68 |
|
|
##=============================================================================
|
69 |
|
|
## ROM and GRUB startup
|
70 |
|
|
##
|
71 |
|
|
## Although these two startup types are, on the face of it, very different,
|
72 |
|
|
## the actual work that needs to be done here for them both is much the same.
|
73 |
|
|
## In both cases the system has been initialized in real mode and the transition
|
74 |
|
|
## to 32 bit protected mode has been done. Here all we need to do is set up
|
75 |
|
|
## our own GDT and IDT, reload the segment registers and proceed.
|
76 |
|
|
|
77 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_GRUB)
|
78 |
|
|
|
79 |
|
|
.macro hal_cpu_init
|
80 |
|
|
|
81 |
|
|
hal_cpu_init_start:
|
82 |
|
|
|
83 |
|
|
# Disable interrupt handling.
|
84 |
|
|
cli
|
85 |
|
|
|
86 |
|
|
# Make a GDT pointer in location 0 and load new GDTR
|
87 |
|
|
movw $(gdtEnd - gdtStart),%ax
|
88 |
|
|
movw %ax,0
|
89 |
|
|
leal gdtStart,%eax
|
90 |
|
|
movl %eax,2
|
91 |
|
|
lgdt 0
|
92 |
|
|
|
93 |
|
|
# Make an IDT pointer in location 0 and load new LDTR
|
94 |
|
|
movw $0x77F,%ax
|
95 |
|
|
movw %ax,0
|
96 |
|
|
leal idtStart,%eax
|
97 |
|
|
movl %eax,2
|
98 |
|
|
lidt 0
|
99 |
|
|
|
100 |
|
|
# Jump long to reload CS
|
101 |
|
|
jmpl $8,$3f
|
102 |
|
|
|
103 |
|
|
.align 4, 0xFF
|
104 |
|
|
gdtStart:
|
105 |
|
|
/* Selector 0x00 == invalid. */
|
106 |
|
|
.word 0x0000
|
107 |
|
|
.word 0x0000
|
108 |
|
|
.byte 0x00
|
109 |
|
|
.byte 0x00
|
110 |
|
|
.byte 0x00
|
111 |
|
|
.byte 0x00
|
112 |
|
|
|
113 |
|
|
/* Selector 0x08 == code. */
|
114 |
|
|
.word 0xFFFF
|
115 |
|
|
.word 0x0000
|
116 |
|
|
.byte 0x00
|
117 |
|
|
.byte 0x9B
|
118 |
|
|
.byte 0xCF
|
119 |
|
|
.byte 0x00
|
120 |
|
|
|
121 |
|
|
/* Selector 0x10 == data. */
|
122 |
|
|
.word 0xFFFF
|
123 |
|
|
.word 0x0000
|
124 |
|
|
.byte 0x00
|
125 |
|
|
.byte 0x93
|
126 |
|
|
.byte 0xCF
|
127 |
|
|
.byte 0x00
|
128 |
|
|
|
129 |
|
|
/* Selector 0x18 == shorter code: faults any code
|
130 |
|
|
* access 0xF0000000-0xFFFFFFFF.
|
131 |
|
|
*/
|
132 |
|
|
.word 0xFFFF
|
133 |
|
|
.word 0x0000
|
134 |
|
|
.byte 0x00
|
135 |
|
|
.byte 0x9B
|
136 |
|
|
.byte 0xC7
|
137 |
|
|
.byte 0x00
|
138 |
|
|
|
139 |
|
|
/* Selector 0x20 == data; faults any access 0xF0000000-0xFFFFFFFF. */
|
140 |
|
|
.word 0xFFFF
|
141 |
|
|
.word 0x0000
|
142 |
|
|
.byte 0x00
|
143 |
|
|
.byte 0x93
|
144 |
|
|
.byte 0xC7
|
145 |
|
|
.byte 0x00
|
146 |
|
|
|
147 |
|
|
.align 4, 0xFF
|
148 |
|
|
gdtEnd:
|
149 |
|
|
|
150 |
|
|
#if defined(CYG_HAL_STARTUP_GRUB)
|
151 |
|
|
# Multiboot header -- this must be in the first 8k
|
152 |
|
|
# of the image file.
|
153 |
|
|
|
154 |
|
|
#define GRUB_MAGIC 0x1BADB002 /* Magic number */
|
155 |
|
|
#define GRUB_FLAGS 0x00000000 /* Flags */
|
156 |
|
|
|
157 |
|
|
.align 4, 0xFF
|
158 |
|
|
.long GRUB_MAGIC
|
159 |
|
|
.long GRUB_FLAGS
|
160 |
|
|
.long 0-GRUB_MAGIC-GRUB_FLAGS /* Checksum */
|
161 |
|
|
#endif
|
162 |
|
|
|
163 |
|
|
3:
|
164 |
|
|
# Set up data selectors
|
165 |
|
|
movw $0x10, %ax
|
166 |
|
|
movw %ax, %ds
|
167 |
|
|
movw %ax, %es
|
168 |
|
|
movw %ax, %fs
|
169 |
|
|
movw %ax, %gs
|
170 |
|
|
|
171 |
|
|
movw %ax, %ss
|
172 |
|
|
|
173 |
|
|
# Set up SP
|
174 |
|
|
movl $__interrupt_stack,%esp
|
175 |
|
|
|
176 |
|
|
/* Reset the flags register. */
|
177 |
|
|
push $0
|
178 |
|
|
popf
|
179 |
|
|
|
180 |
|
|
#if defined(CYG_HAL_STARTUP_GRUB)
|
181 |
|
|
# Save the multiboot info passed in %EBX away into a
|
182 |
|
|
# global variable for later use.
|
183 |
|
|
.data
|
184 |
|
|
.global hal_multiboot_info
|
185 |
|
|
hal_multiboot_info:
|
186 |
|
|
.long 0
|
187 |
|
|
.text
|
188 |
|
|
movl %ebx,hal_multiboot_info
|
189 |
|
|
#endif
|
190 |
|
|
|
191 |
|
|
hal_cpu_init_end:
|
192 |
|
|
nop
|
193 |
|
|
|
194 |
|
|
.endm
|
195 |
|
|
#endif
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
##=============================================================================
|
199 |
|
|
## RAM startup
|
200 |
|
|
|
201 |
|
|
#ifdef CYG_HAL_STARTUP_RAM
|
202 |
|
|
|
203 |
|
|
.macro hal_cpu_init
|
204 |
|
|
.endm
|
205 |
|
|
|
206 |
|
|
#endif /* CYG_HAL_STARTUP_RAM */
|
207 |
|
|
|
208 |
|
|
#endif // CYGPKG_HAL_I386_CPU_INIT_DEFINED
|
209 |
|
|
|
210 |
|
|
##=============================================================================
|
211 |
|
|
## IDT support
|
212 |
|
|
|
213 |
|
|
.macro set_IDT_entry idx,addr
|
214 |
|
|
pushl $(idtStart+8*\idx)
|
215 |
|
|
pushl $\addr
|
216 |
|
|
.extern cyg_hal_pc_set_idt_entry
|
217 |
|
|
call cyg_hal_pc_set_idt_entry
|
218 |
|
|
addl $8,%esp
|
219 |
|
|
.endm
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
.macro hal_idt_init
|
224 |
|
|
.text
|
225 |
|
|
hal_idt_init:
|
226 |
|
|
set_IDT_entry 0, hal_pc_exception_0
|
227 |
|
|
set_IDT_entry 1, hal_pc_exception_1
|
228 |
|
|
set_IDT_entry 2, hal_pc_exception_2
|
229 |
|
|
set_IDT_entry 3, hal_pc_exception_3
|
230 |
|
|
set_IDT_entry 4, hal_pc_exception_4
|
231 |
|
|
set_IDT_entry 5, hal_pc_exception_5
|
232 |
|
|
set_IDT_entry 6, hal_pc_exception_6
|
233 |
|
|
set_IDT_entry 7, hal_pc_exception_7
|
234 |
|
|
set_IDT_entry 8, hal_pc_exception_8
|
235 |
|
|
set_IDT_entry 9, hal_pc_exception_9
|
236 |
|
|
set_IDT_entry 10, hal_pc_exception_10
|
237 |
|
|
set_IDT_entry 11, hal_pc_exception_11
|
238 |
|
|
set_IDT_entry 12, hal_pc_exception_12
|
239 |
|
|
set_IDT_entry 13, hal_pc_exception_13
|
240 |
|
|
set_IDT_entry 14, hal_pc_exception_14
|
241 |
|
|
set_IDT_entry 15, hal_pc_exception_15
|
242 |
|
|
set_IDT_entry 16, hal_pc_exception_16
|
243 |
|
|
set_IDT_entry 17, hal_pc_exception_17
|
244 |
|
|
set_IDT_entry 18, hal_pc_exception_18
|
245 |
|
|
set_IDT_entry 19, hal_pc_exception_19
|
246 |
|
|
set_IDT_entry 20, hal_pc_exception_20
|
247 |
|
|
set_IDT_entry 21, hal_pc_exception_21
|
248 |
|
|
set_IDT_entry 22, hal_pc_exception_22
|
249 |
|
|
set_IDT_entry 23, hal_pc_exception_23
|
250 |
|
|
set_IDT_entry 24, hal_pc_exception_24
|
251 |
|
|
set_IDT_entry 25, hal_pc_exception_25
|
252 |
|
|
set_IDT_entry 26, hal_pc_exception_26
|
253 |
|
|
set_IDT_entry 27, hal_pc_exception_27
|
254 |
|
|
set_IDT_entry 28, hal_pc_exception_28
|
255 |
|
|
set_IDT_entry 29, hal_pc_exception_29
|
256 |
|
|
set_IDT_entry 30, hal_pc_exception_30
|
257 |
|
|
set_IDT_entry 31, hal_pc_exception_31
|
258 |
|
|
set_IDT_entry 32, hal_pc_irq_32
|
259 |
|
|
set_IDT_entry 33, hal_pc_irq_33
|
260 |
|
|
set_IDT_entry 34, hal_pc_irq_34
|
261 |
|
|
set_IDT_entry 35, hal_pc_irq_35
|
262 |
|
|
set_IDT_entry 36, hal_pc_irq_36
|
263 |
|
|
set_IDT_entry 37, hal_pc_irq_37
|
264 |
|
|
set_IDT_entry 38, hal_pc_irq_38
|
265 |
|
|
set_IDT_entry 39, hal_pc_irq_39
|
266 |
|
|
set_IDT_entry 40, hal_pc_irq_40
|
267 |
|
|
set_IDT_entry 41, hal_pc_irq_41
|
268 |
|
|
set_IDT_entry 42, hal_pc_irq_42
|
269 |
|
|
set_IDT_entry 43, hal_pc_irq_43
|
270 |
|
|
set_IDT_entry 44, hal_pc_irq_44
|
271 |
|
|
set_IDT_entry 45, hal_pc_irq_45
|
272 |
|
|
set_IDT_entry 46, hal_pc_irq_46
|
273 |
|
|
set_IDT_entry 47, hal_pc_irq_47
|
274 |
|
|
#ifdef CYGPKG_HAL_SMP_SUPPORT
|
275 |
|
|
set_IDT_entry 48, hal_pc_irq_48
|
276 |
|
|
set_IDT_entry 49, hal_pc_irq_49
|
277 |
|
|
set_IDT_entry 50, hal_pc_irq_50
|
278 |
|
|
set_IDT_entry 51, hal_pc_irq_51
|
279 |
|
|
set_IDT_entry 52, hal_pc_irq_52
|
280 |
|
|
set_IDT_entry 53, hal_pc_irq_53
|
281 |
|
|
set_IDT_entry 54, hal_pc_irq_54
|
282 |
|
|
set_IDT_entry 55, hal_pc_irq_55
|
283 |
|
|
set_IDT_entry 56, hal_pc_irq_56
|
284 |
|
|
set_IDT_entry 57, hal_pc_irq_57
|
285 |
|
|
set_IDT_entry 58, hal_pc_irq_58
|
286 |
|
|
set_IDT_entry 59, hal_pc_irq_59
|
287 |
|
|
set_IDT_entry 60, hal_pc_irq_60
|
288 |
|
|
set_IDT_entry 61, hal_pc_irq_61
|
289 |
|
|
set_IDT_entry 62, hal_pc_irq_62
|
290 |
|
|
set_IDT_entry 63, hal_pc_irq_63
|
291 |
|
|
|
292 |
|
|
set_IDT_entry 64, hal_pc_irq_64
|
293 |
|
|
set_IDT_entry 65, hal_pc_irq_65
|
294 |
|
|
set_IDT_entry 66, hal_pc_irq_66
|
295 |
|
|
set_IDT_entry 67, hal_pc_irq_67
|
296 |
|
|
#endif
|
297 |
|
|
.endm
|
298 |
|
|
|
299 |
|
|
##=============================================================================
|
300 |
|
|
#endif // ifndef CYGONCE_HAL_PLATFORM_INC
|
301 |
|
|
## end of platform.inc
|