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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [i386/] [pc/] [current/] [src/] [romboot.S] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
##=============================================================================
2
##
3
##      romboot.S
4
##
5
##      x86 romboot
6
##
7
##=============================================================================
8
## ####ECOSGPLCOPYRIGHTBEGIN####
9
## -------------------------------------------
10
## This file is part of eCos, the Embedded Configurable Operating System.
11
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
##
13
## eCos is free software; you can redistribute it and/or modify it under
14
## the terms of the GNU General Public License as published by the Free
15
## Software Foundation; either version 2 or (at your option) any later
16
## version.
17
##
18
## eCos is distributed in the hope that it will be useful, but WITHOUT
19
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
## for more details.
22
##
23
## You should have received a copy of the GNU General Public License
24
## along with eCos; if not, write to the Free Software Foundation, Inc.,
25
## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
##
27
## As a special exception, if other files instantiate templates or use
28
## macros or inline functions from this file, or you compile this file
29
## and link it with other works to produce a work based on this file,
30
## this file does not by itself cause the resulting work to be covered by
31
## the GNU General Public License. However the source code for this file
32
## must still be made available in accordance with section (3) of the GNU
33
## General Public License v2.
34
##
35
## This exception does not invalidate any other reasons why a work based
36
## on this file might be covered by the GNU General Public License.
37
## -------------------------------------------
38
## ####ECOSGPLCOPYRIGHTEND####
39
##=============================================================================
40
#######DESCRIPTIONBEGIN####
41
##
42
## Author(s):   jskov
43
## Contributors:jskov
44
## Date:        1999-01-07
45
## Purpose:     x86 romboot
46
## Description: When booting from ROM we need to run a short sequence of real
47
##              mode code before jumping into 32 bit protected mode. There are
48
##              problems in GAS with mixing all this code together, and it is
49
##              easier to just move this bit of code out to a separate file.
50
##
51
##
52
######DESCRIPTIONEND####
53
##
54
##=============================================================================
55
 
56
 
57
#include 
58
#include 
59
 
60
#include 
61
 
62
#==============================================================================
63
 
64
//    .file   "romboot.S"
65
 
66
#------------------------------------------------------------------------------
67
 
68
        .code16
69
 
70
romboot_start:
71
        /* Disable interrupt handling. */
72
        cli
73
 
74
        # Set DS == CS
75
        movw    %cs,%ax
76
        movw    %ax,%ds
77
        # set ES == 0
78
        movw    $0,%ax
79
        movw    %ax,%es
80
 
81
        # Call video bios to init display
82
        movw    $0xc000,%bx
83
        movw    %bx,%ds
84
        movw    0x0000,%ax
85
        movw    $0x0000,%bx
86
        movw    %bx,%ds
87
        cmpw    $0xAA55,%ax
88
        jne     1f
89
        .byte   0x9a            # lcall
90
        .word   0x0003          # offset
91
        .word   0xc000          # segment
92
1:
93
 
94
        movw    %cs,%ax
95
        movw    %ax,%ds
96
        # set ES == 0
97
        movw    $0,%ax
98
        movw    %ax,%es
99
 
100
        # build a GDT descriptor in memory at location zero
101
        movw    $(gdtEnd - gdtStart),%ax
102
        movw    %ax,%es:0
103
        lea     gdtStart,%ax
104
        addw    $0xFF00,%ax
105
        movw    %ax,%es:2
106
        movw    $0x000F,%ax
107
        movw    %ax,%es:4
108
 
109
        # load GDTR
110
        lgdt    %es:0
111
 
112
        # Switch to protected mode.
113
        movl    %cr0,%eax
114
        orb     $1, %al
115
        movl    %eax,%cr0
116
 
117
        # and do a jump to flush instruction prefetch
118
        jmp     romboot_pm
119
 
120
        hlt
121
 
122
        .align  4, 0xCC
123
gdtStart:
124
        /* Selector 0x00 == invalid. */
125
        .word   0x0000
126
        .word   0x0000
127
        .byte   0x00
128
        .byte   0x00
129
        .byte   0x00
130
        .byte   0x00
131
 
132
        /* Selector 0x08 == code. */
133
        .word   0xFFFF
134
        .word   0x0000
135
        .byte   0x00
136
        .byte   0x9B
137
        .byte   0xCF
138
        .byte   0x00
139
 
140
        /* Selector 0x10 == data. */
141
        .word   0xFFFF
142
        .word   0x0000
143
        .byte   0x00
144
        .byte   0x93
145
        .byte   0xCF
146
        .byte   0x00
147
 
148
        /* Selector 0x18 == shorter code: faults any code
149
         * access 0xF0000000-0xFFFFFFFF.
150
         */
151
        .word   0xFFFF
152
        .word   0x0000
153
        .byte   0x00
154
        .byte   0x9B
155
        .byte   0xC7
156
        .byte   0x00
157
 
158
        /* Selector 0x20 == data; faults any access 0xF0000000-0xFFFFFFFF. */
159
        .word   0xFFFF
160
        .word   0x0000
161
        .byte   0x00
162
        .byte   0x93
163
        .byte   0xC7
164
        .byte   0x00
165
 
166
        .align  4, 0xCC
167
gdtEnd:
168
 
169
        # We arrive here in protected mode
170
romboot_pm:
171
 
172
        # Load data selectors
173
        movw    $0x10, %ax
174
        movw    %ax, %ds
175
        movw    %ax, %es
176
        movw    %ax, %fs
177
        movw    %ax, %gs
178
 
179
        # jump to start of ROM, where the PM code starts
180
#       ljmp    $8,$0xF0000
181
        .byte   0x66,0xea       # opsize + ljmp opcode
182
        .long   0x000F0000      # destination address
183
        .word   0x0008          # code selector
184
 
185
        .code16
186
 
187
        .org    0xF0
188
romboot_reset:
189
        jmp     romboot_start
190
 
191
        .org    0x100
192
 
193
#------------------------------------------------------------------------------
194
# end of romboot.S

powered by: WebSVN 2.1.0

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