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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [boot/] [compressed/] [head.S] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
2
 *  linux/boot/head.S
3
 *
4
 *  Copyright (C) 1991, 1992, 1993  Linus Torvalds
5
 */
6
 
7
/*
8
 *  head.S contains the 32-bit startup code.
9
 *
10
 * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
11
 * the page directory will exist. The startup code will be overwritten by
12
 * the page directory. [According to comments etc elsewhere on a compressed
13
 * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
14
 *
15
 * In SMP mode we keep this page safe. Really we ought to shuffle things and
16
 * put the trampoline here. - AC. An SMP trampoline enters with %cx holding
17
 * the stack base.
18
 *
19
 * Page 0 is deliberately kept safe, since System Management Mode code in
20
 * laptops may need to access the BIOS data stored there.  This is also
21
 * useful for future device drivers that either access the BIOS via VM86
22
 * mode.
23
 */
24
 
25
/*
26
 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
27
 */
28
.text
29
 
30
#define __ASSEMBLY__
31
#include 
32
#include 
33
 
34
        .globl startup_32
35
 
36
startup_32:
37
        cld
38
        cli
39
        movl $(KERNEL_DS),%eax
40
        mov %ax,%ds
41
        mov %ax,%es
42
        mov %ax,%fs
43
        mov %ax,%gs
44
#ifdef __SMP__
45
        orw %bx,%bx                     # What state are we in BX=1 for SMP
46
                                        # 0 for boot
47
        jz  2f                          # Initial boot
48
 
49
/*
50
 *      We are trampolining an SMP processor
51
 */
52
        mov %ax,%ss
53
        xorl %eax,%eax                  # Back to 0
54
        mov  %cx,%ax                    # SP low 16 bits
55
        movl %eax,%esp
56
        pushl 0                         # Clear NT
57
        popfl
58
        ljmp $(KERNEL_CS), $0x100000    # Into C and sanity
59
 
60
2:
61
#endif
62
        lss SYMBOL_NAME(stack_start),%esp
63
        xorl %eax,%eax
64
1:      incl %eax               # check that A20 really IS enabled
65
        movl %eax,0x000000      # loop forever if it isn't
66
        cmpl %eax,0x100000
67
        je 1b
68
/*
69
 * Initialize eflags.  Some BIOS's leave bits like NT set.  This would
70
 * confuse the debugger if this code is traced.
71
 * XXX - best to initialize before switching to protected mode.
72
 */
73
        pushl $0
74
        popfl
75
/*
76
 * Clear BSS
77
 */
78
        xorl %eax,%eax
79
        movl $ SYMBOL_NAME(_edata),%edi
80
        movl $ SYMBOL_NAME(_end),%ecx
81
        subl %edi,%ecx
82
        cld
83
        rep
84
        stosb
85
/*
86
 * Do the decompression, and jump to the new kernel..
87
 */
88
        subl $16,%esp   # place for structure on the stack
89
        pushl %esp      # address of structure as first arg
90
        call SYMBOL_NAME(decompress_kernel)
91
        orl  %eax,%eax
92
        jnz  3f
93
        xorl %ebx,%ebx
94
        ljmp $(KERNEL_CS), $0x100000
95
 
96
/*
97
 * We come here, if we were loaded high.
98
 * We need to move the move-in-place routine down to 0x1000
99
 * and then start it with the buffer addresses in registers,
100
 * which we got from the stack.
101
 */
102
3:
103
        movl $move_routine_start,%esi
104
        movl $0x1000,%edi
105
        movl $move_routine_end,%ecx
106
        subl %esi,%ecx
107
        cld
108
        rep
109
        movsb
110
 
111
        popl %esi       # discard the address
112
        popl %esi       # low_buffer_start
113
        popl %ecx       # lcount
114
        popl %edx       # high_buffer_start
115
        popl %eax       # hcount
116
        movl $0x100000,%edi
117
        cli             # make sure we don't get interrupted
118
        ljmp $(KERNEL_CS), $0x1000 # and jump to the move routine
119
 
120
/*
121
 * Routine (template) for moving the decompressed kernel in place,
122
 * if we were high loaded. This _must_ PIC-code !
123
 */
124
move_routine_start:
125
        rep
126
        movsb
127
        movl %edx,%esi
128
        movl %eax,%ecx  # NOTE: rep movsb won't move if %ecx == 0
129
        rep
130
        movsb
131
        xorl %ebx,%ebx
132
/*
133
 * Well, the kernel relies on %esp pointing into low mem,
134
 * with the decompressor loaded high this is no longer true,
135
 * so we set esp here.
136
 */
137
        mov  $0x90000,%esp
138
        ljmp $(KERNEL_CS), $0x100000
139
move_routine_end:

powered by: WebSVN 2.1.0

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