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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [i386/] [pc/] [v2_0/] [src/] [romboot.S] - Blame information for rev 430

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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