4 * Copyright (C) 1991, 1992, 1993 Linus Torvalds
8 * head.S contains the 32-bit startup code.
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]
15 * Page 0 is deliberately kept safe, since System Management Mode code in
16 * laptops may need to access the BIOS data stored there. This is also
17 * useful for future device drivers that either access the BIOS via VM86
22 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
27 #include <linux/linkage.h>
28 #include <asm/segment.h>
37 movl $(__KERNEL_DS),%eax
45 1: incl %eax # check that A20 really IS enabled
46 movl %eax,0x000000 # loop forever if it isn't
51 * Initialize eflags. Some BIOS's leave bits like NT set. This would
52 * confuse the debugger if this code is traced.
53 * XXX - best to initialize before switching to protected mode.
68 * Do the decompression, and jump to the new kernel..
70 subl $16,%esp # place for structure on the stack
72 pushl %esi # real mode pointer as second arg
73 pushl %eax # address of structure as first arg
74 call decompress_kernel
79 ljmp $(__KERNEL_CS), $__PHYSICAL_START
82 * We come here, if we were loaded high.
83 * We need to move the move-in-place routine down to 0x1000
84 * and then start it with the buffer addresses in registers,
85 * which we got from the stack.
89 movl $move_routine_start,%esi
91 movl $move_routine_end,%ecx
99 popl %esi # discard the address
100 addl $4,%esp # real mode pointer
101 popl %esi # low_buffer_start
103 popl %edx # high_buffer_start
105 movl $__PHYSICAL_START,%edi
106 cli # make sure we don't get interrupted
107 ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine
110 * Routine (template) for moving the decompressed kernel in place,
111 * if we were high loaded. This _must_ PIC-code !
123 movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
128 movl %ebx,%esi # Restore setup pointer
130 ljmp $(__KERNEL_CS), $__PHYSICAL_START
134 /* Stack for uncompression */
139 .long user_stack+4096