--- linux-2.6.13.4/arch/i386/boot/compressed/head.S.orig 2005-12-05 09:23:22.000000000 -0500 +++ linux-2.6.13.4/arch/i386/boot/compressed/head.S 2005-12-05 10:39:56.000000000 -0500 @@ -18,9 +18,21 @@ * mode. */ -/* - * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 - */ +# +# High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 +# +# Dec 5, 2005 rjohnson@analogic.com +# Removed most of the old-style 'C' comment format and replaced with +# GAS comment delimiters. +# +# Dec 5, 2005 rjohnson@analogic.com +# Removed many redundant flag operations. Adjusted offset of +# the move_routine_start to a 16-byte boundary so it is truly +# position-independent. +# +# Dec 5, 2005 rjohnson@analogic.com +# Fixed A20 detection code. +# .text #include @@ -30,41 +42,38 @@ .globl startup_32 startup_32: - cld cli - movl $(__BOOT_DS),%eax - movl %eax,%ds + movl $(__BOOT_DS),%eax # Linear address-space + movl %eax,%ds # Set segments movl %eax,%es movl %eax,%fs movl %eax,%gs - lss stack_start,%esp - xorl %eax,%eax -1: incl %eax # check that A20 really IS enabled - movl %eax,0x000000 # loop forever if it isn't - cmpl %eax,0x100000 - je 1b - -/* - * Initialize eflags. Some BIOS's leave bits like NT set. This would - * confuse the debugger if this code is traced. - * XXX - best to initialize before switching to protected mode. - */ - pushl $0 - popfl -/* - * Clear BSS - */ + lss stack_start,%esp # Set stack + xorl %eax,%eax # Clear + pushl %eax + popfl # Clear all flags +# +# Check for at least 20-bit addressing, (A20 is enabled). +# + movl $__PHYSICAL_START, %ebx + movl (%ebx), %eax # Save whatever is there + movl $0xfeedface, (%ebx) # Set magic +1: cmpl $0xfeedface, (%ebx) # See if 32-bits + jnz 1b # Hang forever if not + movl %eax, (%ebx) # Put the code back +# +# Clear BSS +# xorl %eax,%eax movl $_edata,%edi movl $_end,%ecx subl %edi,%ecx - cld rep stosb -/* - * Do the decompression, and jump to the new kernel.. - */ +# +# Do the decompression, and jump to the new kernel.. +# subl $16,%esp # place for structure on the stack movl %esp,%eax pushl %esi # real mode pointer as second arg @@ -77,20 +86,18 @@ xorl %ebx,%ebx ljmp $(__BOOT_CS), $__PHYSICAL_START -/* - * We come here, if we were loaded high. - * We need to move the move-in-place routine down to 0x1000 - * and then start it with the buffer addresses in registers, - * which we got from the stack. - */ -3: - movl $move_routine_start,%esi +# +# We come here, if we were loaded high. +# We need to move the move-in-place routine down to 0x1000 +# and then start it with the buffer addresses in registers +# which we got from the stack. +# +3: movl $move_routine_start,%esi movl $0x1000,%edi movl $move_routine_end,%ecx subl %esi,%ecx addl $3,%ecx shrl $2,%ecx - cld rep movsl @@ -101,13 +108,13 @@ popl %edx # high_buffer_start popl %eax # hcount movl $__PHYSICAL_START,%edi - cli # make sure we don't get interrupted ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine -/* - * Routine (template) for moving the decompressed kernel in place, - * if we were high loaded. This _must_ PIC-code ! - */ +# +# Routine (template) for moving the decompressed kernel in place, +# when we are high loaded. This _must_ be position-independent code! +# +.align 0x10 move_routine_start: movl %ecx,%ebp shrl $2,%ecx