grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations


From: Pavel Roskin
Subject: [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations
Date: Tue, 14 Jul 2009 21:00:55 -0400
User-agent: StGit/0.15-rc1-4-g4ce8

ChangeLog:

        * boot/i386/pc/boot.S: Declare 0x0-0x7c00 as a discardable .bss
        segment.  Eliminate ABS, rely on the assembler knowing correct
        addresses.  Eliminate .bss segment for the kernel, use direct
        jump to the kernel address.
---
 boot/i386/pc/boot.S |   72 +++++++++------------------------------------------
 1 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index e3f5228..0002773 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -24,20 +24,13 @@
  *  defines for the code go here
  */
 
-       /* Absolute addresses
-          This makes the assembler generate the address without support
-          from the linker. (ELF can't relocate 16-bit addresses!) */
-#define ABS(x) (x-_start+0x7c00)
-
        /* Print message string */
-#ifdef APPLE_CC
-#define MSG(x) x ## _abs = ABS(x); movw $x ## _abs, %si; call message
-#else
-#define MSG(x) movw $ABS(x), %si; call message
-#endif
+#define MSG(x) movw $x, %si; call message
 
        .file   "boot.S"
 
+       .bss
+       . = 0x7c00
        .text
 
        /* Tell GAS to generate 16-bit instructions so that this code works
@@ -126,12 +119,7 @@ boot_drive_check:
         * ljmp to the next instruction because some bogus BIOSes
         * jump to 07C0:0000 instead of 0000:7C00.
         */
-#ifdef APPLE_CC
-       real_start_abs = ABS(real_start)
-       ljmp    $0, $(real_start_abs)
-#else
-       ljmp    $0, $ABS(real_start)
-#endif
+       ljmp    $0, $real_start
 
 real_start:
 
@@ -148,12 +136,7 @@ real_start:
        /*
         *  Check if we have a forced disk reference here
         */
-#ifdef APPLE_CC
-       boot_drive_abs = ABS (boot_drive)
-       movb    boot_drive_abs, %al
-#else
-       movb   ABS(boot_drive), %al
-#endif
+       movb    boot_drive, %al
        cmpb    $0xff, %al
        je      1f
        movb    %al, %dl
@@ -165,12 +148,7 @@ real_start:
        MSG(notification_string)
 
        /* set %si to the disk address packet */
-#ifdef APPLE_CC
-       disk_address_packet_abs = ABS (disk_address_packet)
-       movw    $disk_address_packet_abs, %si
-#else
-       movw    $ABS(disk_address_packet), %si
-#endif
+       movw    $disk_address_packet, %si
 
        /* do not probe LBA if the drive is a floppy */
        testb   $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
@@ -211,18 +189,10 @@ lba_mode:
        movw    $0x0010, (%si)
 
        /* the absolute address */
-#ifdef APPLE_CC
-       kernel_sector_abs = ABS (kernel_sector)
-       movl    (kernel_sector_abs), %ebx
-       movl    %ebx, 8(%si)
-       movl    (kernel_sector_abs + 4), %ebx
-       movl    %ebx, 12(%si)
-#else
-       movl    ABS(kernel_sector), %ebx
+       movl    kernel_sector, %ebx
        movl    %ebx, 8(%si)
-       movl    ABS(kernel_sector + 4), %ebx
+       movl    kernel_sector + 4, %ebx
        movl    %ebx, 12(%si)
-#endif
 
        /* the segment of buffer address */
        movw    $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
@@ -289,22 +259,13 @@ final_init:
 
 setup_sectors:
        /* load logical sector start (top half) */
-#ifdef APPLE_CC
-       kernel_sector_abs = ABS (kernel_sector)
-       movl    (kernel_sector_abs + 4), %eax
-#else
-       movl    ABS(kernel_sector + 4), %eax
-#endif
+       movl    kernel_sector + 4, %eax
 
        orl     %eax, %eax
        jnz     geometry_error
 
        /* load logical sector start (bottom half) */
-#ifdef APPLE_CC
-       movl    (kernel_sector_abs), %eax
-#else
-       movl    ABS(kernel_sector), %eax
-#endif
+       movl    kernel_sector, %eax
 
        /* zero %edx */
        xorl    %edx, %edx
@@ -389,7 +350,7 @@ copy_buffer:
        popa
 
        /* boot kernel */
-       jmp     kernel_entry
+       jmp     GRUB_BOOT_MACHINE_KERNEL_ADDR
 
 /* END OF MAIN LOOP */
 
@@ -475,12 +436,7 @@ floppy_probe:
  *  Perform floppy probe.
  */
 
-#ifdef APPLE_CC
-       probe_values_abs = ABS (probe_values)
-       movw    $(probe_values_abs-1), %si
-#else
-       movw    $ABS(probe_values-1), %si
-#endif
+       movw    $probe_values - 1, %si
 
 probe_loop:
        /* reset floppy controller INT 13h AH=0 */
@@ -524,7 +480,3 @@ fd_probe_error_string:      .asciz "Floppy"
 
 /* the last 2 bytes in the sector 0 contain the signature */
        .word   GRUB_BOOT_MACHINE_SIGNATURE
-
-       .bss
-       . = . + 0x200
-kernel_entry:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]