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>
39 movl $(__KERNEL_DS),%eax
47 1: incl %eax # check that A20 really IS enabled
48 movl %eax,0x000000 # loop forever if it isn't
53 * Initialize eflags. Some BIOS's leave bits like NT set. This would
54 * confuse the debugger if this code is traced.
55 * XXX - best to initialize before switching to protected mode.
70 * Do the decompression, and jump to the new kernel..
72 subl $16,%esp # place for structure on the stack
74 pushl %esi # real mode pointer as second arg
75 pushl %eax # address of structure as first arg
76 call decompress_kernel
81 ljmp $(__KERNEL_CS), $__PHYSICAL_START
84 * We come here, if we were loaded high.
85 * We need to move the move-in-place routine down to 0x1000
86 * and then start it with the buffer addresses in registers,
87 * which we got from the stack.
91 movl $move_routine_start,%esi
93 movl $move_routine_end,%ecx
101 popl %esi # discard the address
102 addl $4,%esp # real mode pointer
103 popl %esi # low_buffer_start
105 popl %edx # high_buffer_start
107 movl $__PHYSICAL_START,%edi
108 cli # make sure we don't get interrupted
109 ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine
112 * Routine (template) for moving the decompressed kernel in place,
113 * if we were high loaded. This _must_ PIC-code !
125 movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
130 movl %ebx,%esi # Restore setup pointer
132 ljmp $(__KERNEL_CS), $__PHYSICAL_START
136 /* Stack for uncompression */
141 .long user_stack+4096