4 * Copyright (C) 1991, 1992, 1993 Linus Torvalds
6 * $Id: head.S,v 1.3 2001/04/20 00:59:28 ak Exp $
10 * head.S contains the 32-bit startup code.
12 * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
13 * the page directory will exist. The startup code will be overwritten by
14 * the page directory. [According to comments etc elsewhere on a compressed
15 * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
17 * Page 0 is deliberately kept safe, since System Management Mode code in
18 * laptops may need to access the BIOS data stored there. This is also
19 * useful for future device drivers that either access the BIOS via VM86
24 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
29 #include <linux/linkage.h>
30 #include <asm/segment.h>
38 movl $(__KERNEL_DS),%eax
46 1: incl %eax # check that A20 really IS enabled
47 movl %eax,0x000000 # loop forever if it isn't
52 * Initialize eflags. Some BIOS's leave bits like NT set. This would
53 * confuse the debugger if this code is traced.
54 * XXX - best to initialize before switching to protected mode.
69 * Do the decompression, and jump to the new kernel..
71 subl $16,%esp # place for structure on the stack
73 pushl %esi # real mode pointer as second arg
74 pushl %eax # address of structure as first arg
75 call decompress_kernel
80 ljmp $(__KERNEL_CS), $0x100000
83 * We come here, if we were loaded high.
84 * We need to move the move-in-place routine down to 0x1000
85 * and then start it with the buffer addresses in registers,
86 * which we got from the stack.
90 movl $move_routine_start,%esi
92 movl $move_routine_end,%ecx
100 popl %esi # discard the address
101 addl $4,%esp # real mode pointer
102 popl %esi # low_buffer_start
104 popl %edx # high_buffer_start
107 cli # make sure we don't get interrupted
108 ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine
111 * Routine (template) for moving the decompressed kernel in place,
112 * if we were high loaded. This _must_ PIC-code !
124 movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
129 movl %ebx,%esi # Restore setup pointer
131 ljmp $(__KERNEL_CS), $0x100000
135 /* Stack for uncompression */
140 .long user_stack+4096