[LWN Logo]

Date:    Fri, 30 Jul 1999 23:05:05 +0200
To:      linux-kernel@vger.rutgers.edu
From:    Yann Droneaud <lch@multimania.com>
Subject: Boot code rewritten for GAS

Here are the bootloader, setup and video code for GNU as.
It is quite the same than for as86.

Changes:
--------
Some string have been changed
tools/build.c has been updated to support binary file made by objcopy -O
binary
Added svga.h and some define for SVGA detection
compressed/head.S -> changed some %ax to %eax (search for XXX)

Why:
----
I hate as86/ld86 :-)
Seriously the bin86 distribution is quite poor of documentation...
And since GNU as have support for writing 16bits code, we don't need
those old tools...

Tests:
------
It work well on my systems. (IBM PS/VP 486DX/2 66, S3 chip integrated
and Pentium 200,Bios Award,Matrox Millennium)  
zdisk/bzdisk boot correctly.
LILO/Loadlin/GRUB load zImage/bzImage correctly
VESA VGA and S3 video card detection ok
Video mode selection is ok.

It work with binutils-2.9.1.0.11 and binutils-2.9.5.0.3

(NOTE with binutils-2.9.5.0.3 a lot of warning occurs during the
compilation of the kernel
 16bits register use instead of 32bits
 example
  movl %cx,%fs instead of movl %ecx,%fs
)

How to install:
---------------
Untargz the archive in your kernel source tree 
 # cd /usr/src/linux
 # tar xvvzf <boot-gas.tar.gz>
 # cd arch/i386
 # mv boot boot-as86
 # ln -s boot-gas/ boot

If you choose to use it, make a symlink 'boot' to boot-gas/
Others:
-------
Here are patches for arch/i386/kernel/{entry.S,head.S}

========================================================

--- head.S~     Fri Jan 15 07:57:25 1999
+++ head.S      Tue Jul 27 18:49:44 1999
@@ -45,10 +45,10 @@
  */
        cld
        movl $(__KERNEL_DS),%eax
-       movl %ax,%ds
-       movl %ax,%es
-       movl %ax,%fs
-       movl %ax,%gs
+       movl %eax,%ds           /* XXX movl %ax,%ds */
+       movl %eax,%es           /* XXX movl %ax,%es */
+       movl %eax,%fs           /* XXX movl %ax,%fs */
+       movl %eax,%gs           /* XXX movl %ax,%gs */
 #ifdef __SMP__
        orw %bx,%bx
        jz 1f
@@ -229,18 +229,18 @@
        lidt idt_descr
        ljmp $(__KERNEL_CS),$1f
 1:     movl $(__KERNEL_DS),%eax        # reload all the segment
registers
-       movl %ax,%ds            # after changing gdt.
-       movl %ax,%es
-       movl %ax,%fs
-       movl %ax,%gs
+       movl %eax,%ds           # after changing gdt. /* XXX movl
%ax,%ds */
+       movl %eax,%es           /* XXX movl %ax,%es */
+       movl %eax,%fs           /* XXX movl %ax,%fs */
+       movl %eax,%gs           /* XXX movl %ax,%gs */
 #ifdef __SMP__
        movl $(__KERNEL_DS), %eax
-       mov  %ax,%ss            # Reload the stack pointer (segment
only)
+       mov  %ax,%ss            # Reload the stack pointer (segment
only) /* XXX 16bits or 32bits ? */
 #else
        lss stack_start,%esp    # Load processor stack
 #endif
        xorl %eax,%eax
-       lldt %ax
+       lldt %ax                /* XXX %ax or %eax ? */
        cld                     # gcc2 wants the direction flag cleared
at all times
        call SYMBOL_NAME(start_kernel)
 L6:
@@ -312,8 +312,8 @@
        pushl %es
        pushl %ds
        movl $(__KERNEL_DS),%eax
-       movl %ax,%ds
-       movl %ax,%es
+       movl %eax,%ds           /* XXX movl %ax,%ds */
+       movl %eax,%es           /* XXX movl %ax,%es */
        pushl $int_msg
        call SYMBOL_NAME(printk)
        popl %eax
--- entry.S~    Tue Jul 27 18:38:56 1999
+++ entry.S     Tue Jul 27 18:39:29 1999
@@ -92,8 +92,8 @@
        pushl %ecx; \
        pushl %ebx; \
        movl $(__KERNEL_DS),%edx; \
-       movl %dx,%ds; \
-       movl %dx,%es;
+       movl %edx,%ds; \     /* XXX movl %dx,%ds */
+       movl %edx,%es;       /* XXX movl %dx,%es */
 
 #define RESTORE_ALL    \
        popl %ebx;      \