OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [i386/] [pc/] [current/] [include/] [platform.inc] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.