commit-grub
[Top][All Lists]
Advanced

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

[2253] 2009-06-04 Vladimir Serbinenko <address@hidden>


From: Vladimir Serbinenko
Subject: [2253] 2009-06-04 Vladimir Serbinenko <address@hidden>
Date: Thu, 04 Jun 2009 20:01:19 +0000

Revision: 2253
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2253
Author:   phcoder
Date:     2009-06-04 20:01:19 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
2009-06-04  Vladimir Serbinenko  <address@hidden>

        Absolute addressing through constant with Apple's cc

        * kern/i386/pc/startup.S: Define necessary constants
        and address through it when using ABS with Apple's CC
        * boot/i386/pc/diskboot.S: likewise
        * boot/i386/pc/boot.S: likewise
        * boot/i386/pc/lnxboot.S: likewise
        * boot/i386/pc/cdboot.S: likewise
        * mmap/i386/pc/mmap_helper.S: likewise
        * commands/i386/pc/drivemap_int13h.S: likewise

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/boot/i386/pc/boot.S
    trunk/grub2/boot/i386/pc/cdboot.S
    trunk/grub2/boot/i386/pc/diskboot.S
    trunk/grub2/boot/i386/pc/lnxboot.S
    trunk/grub2/commands/i386/pc/drivemap_int13h.S
    trunk/grub2/kern/i386/pc/startup.S
    trunk/grub2/mmap/i386/pc/mmap_helper.S

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog       2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/ChangeLog       2009-06-04 20:01:19 UTC (rev 2253)
@@ -1,5 +1,18 @@
 2009-06-04  Vladimir Serbinenko  <address@hidden>
 
+       Absolute addressing through constant with Apple's cc
+
+       * kern/i386/pc/startup.S: Define necessary constants
+       and address through it when using ABS with Apple's CC
+       * boot/i386/pc/diskboot.S: likewise
+       * boot/i386/pc/boot.S: likewise
+       * boot/i386/pc/lnxboot.S: likewise
+       * boot/i386/pc/cdboot.S: likewise
+       * mmap/i386/pc/mmap_helper.S: likewise
+       * commands/i386/pc/drivemap_int13h.S: likewise
+
+2009-06-04  Vladimir Serbinenko  <address@hidden>
+
        Check if compiler is apple cc
 
        * Makefile.in (ASFLAGS): new variable

Modified: trunk/grub2/boot/i386/pc/boot.S
===================================================================
--- trunk/grub2/boot/i386/pc/boot.S     2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/boot/i386/pc/boot.S     2009-06-04 20:01:19 UTC (rev 2253)
@@ -30,7 +30,11 @@
 #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
 
        .file   "boot.S"
 
@@ -125,7 +129,12 @@
         * 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
 
 real_start:    
 
@@ -143,7 +152,12 @@
         *  Check if we have a forced disk reference here
         */
         /* assign root_drive at the same time */
-        movw    ABS(boot_drive), %ax
+#ifdef APPLE_CC
+       boot_drive_abs = ABS (boot_drive)
+       movw    boot_drive_abs, %ax
+#else
+       movw    ABS(boot_drive), %ax
+#endif
         movb    %ah, %dh
        cmpb    $0xff, %al
        je      1f
@@ -156,7 +170,12 @@
        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
        
        /* do not probe LBA if the drive is a floppy */
        testb   $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
@@ -197,10 +216,18 @@
        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    %ebx, 8(%si)
        movl    ABS(kernel_sector + 4), %ebx
        movl    %ebx, 12(%si)
+#endif
 
        /* the segment of buffer address */
        movw    $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
@@ -267,12 +294,22 @@
 
 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
+
        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
 
        /* zero %edx */
        xorl    %edx, %edx
@@ -336,7 +373,12 @@
        movw    %es, %bx
        
 copy_buffer:
+#ifdef APPLE_CC
+       kernel_segment_abs = ABS (kernel_segment)
+       movw    (kernel_segment_abs), %es
+#else
        movw    ABS(kernel_segment), %es
+#endif
 
        /*
         * We need to save %cx and %si because the startup code in
@@ -360,7 +402,12 @@
         popw    %dx
 
        /* boot kernel */
+#ifdef APPLE_CC
+       kernel_address_abs = ABS (kernel_address)
+       jmp     *(kernel_address_abs)
+#else
        jmp     *(kernel_address)
+#endif
 
 /* END OF MAIN LOOP */
 
@@ -446,7 +493,12 @@
  *  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
 
 probe_loop:
        /* reset floppy controller INT 13h AH=0 */

Modified: trunk/grub2/boot/i386/pc/cdboot.S
===================================================================
--- trunk/grub2/boot/i386/pc/cdboot.S   2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/boot/i386/pc/cdboot.S   2009-06-04 20:01:19 UTC (rev 2253)
@@ -67,8 +67,15 @@
        movw    %ax, %ds
        movw    %ax, %es
 
+#ifdef APPLE_CC
+       err_noboot_msg_abs = 0x7C00 + err_noboot_msg - start
+       movw    $err_noboot_msg_abs, %si
+       bi_length_dif = bi_length - next
+       movl    %cs:bi_length_dif(%bx), %ecx
+#else
        movw    $(0x7C00 + err_noboot_msg - start), %si
        movl    %cs: bi_length - next(%bx), %ecx
+#endif
        orl     %ecx, %ecx
        jz      fail
 
@@ -152,7 +159,12 @@
        ret
 
 cdrom_fail:
+#ifdef APPLE_CC
+       err_cdfail_msg_abs = 0x7C00 + err_cdfail_msg - start
+       movw    $(err_cdfail_msg_abs), %si
+#else
        movw    $(0x7C00 + err_cdfail_msg - start), %si
+#endif
 
 fail:
        movb    $0x0e, %ah

Modified: trunk/grub2/boot/i386/pc/diskboot.S
===================================================================
--- trunk/grub2/boot/i386/pc/diskboot.S 2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/boot/i386/pc/diskboot.S 2009-06-04 20:01:19 UTC (rev 2253)
@@ -28,7 +28,11 @@
 #define ABS(x) (x-_start+GRUB_BOOT_MACHINE_KERNEL_ADDR)
        
        /* Print message string */
+#ifdef APPLE_CC
+#define MSG(x) x ## _abs = ABS(x); mov $x ## _abs, %esi; call message
+#else
 #define MSG(x) movw $ABS(x), %si; call message
+#endif
 
        .file   "diskboot.S"
 
@@ -61,7 +65,12 @@
        popw    %si
        
        /* this sets up for the first run through "bootloop" */
+#ifdef APPLE_CC
+       firstlist_off_abs = ABS (firstlist - GRUB_BOOT_MACHINE_LIST_SIZE)
+       movl    $firstlist_off_abs, %edi
+#else
        movw    $ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE), %di
+#endif
 
        /* save the sector number of the second sector in %ebp */
        movl    (%di), %ebp

Modified: trunk/grub2/boot/i386/pc/lnxboot.S
===================================================================
--- trunk/grub2/boot/i386/pc/lnxboot.S  2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/boot/i386/pc/lnxboot.S  2009-06-04 20:01:19 UTC (rev 2253)
@@ -123,8 +123,15 @@
 
 linux_init:
 
+#ifdef APPLE_CC
+       reg_edx_rel = reg_edx - start 
+       code32_start_rel = code32_start - start 
+       movw    %cs:(reg_edx_rel), %dx
+       movl    %cs:(code32_start_rel), %ebp
+#else
        movw    %cs:(reg_edx - start), %dx
        movl    %cs:(code32_start - start), %ebp
+#endif
 
 linux_next:
 
@@ -132,12 +139,22 @@
 
 normalize:
        popw    %bx
+#ifdef APPLE_CC
+       normalize_rel = normalize - start
+       subw    $(normalize_rel), %bx
+#else
        subw    $(normalize - start), %bx
+#endif
        shrw    $4, %bx
        movw    %cs, %ax
        addw    %bx, %ax
        pushw   %ax
+#ifdef APPLE_CC
+       real_code_rel = real_code - start
+       pushw   $(real_code_rel)
+#else
        pushw   $(real_code - start)
+#endif
        lret                            /* Jump to real_code.  */
 
 real_code:
@@ -164,7 +181,12 @@
        rep
        movsl
 
+#ifdef APPLE_CC
+       real_code_2_rel = real_code_2 - start
+       ljmp    $(CODE_ADDR >> 4), $(real_code_2_rel)
+#else
        ljmp    $(CODE_ADDR >> 4), $(real_code_2  - start)
+#endif
 
 real_code_2:
 
@@ -189,8 +211,15 @@
        cmpl    $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END)
        jz      1f
 
+#ifdef APPLE_CC
+       ramdisk_image_rel = ramdisk_image - start
+       ramdisk_size_rel = ramdisk_size - start
+       movl    (ramdisk_image_rel), %esi
+       movl    (ramdisk_size_rel), %ecx
+#else
        movl    (ramdisk_image - start), %esi
        movl    (ramdisk_size - start), %ecx
+#endif
        movl    $(DATA_ADDR - 0x200), %edi
        jmp     2f
 
@@ -205,7 +234,12 @@
        movsbl  %dh, %eax
        movl    %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
 
+#ifdef APPLE_CC
+       reg_edx_rel = reg_edx - start
+       movsbl  (reg_edx_rel + 2), %eax
+#else
        movsbl  (reg_edx + 2 - start), %eax
+#endif
        movl    %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
 
        movb    $0xFF, %dh
@@ -234,6 +268,28 @@
        pushl   %ecx
 
        movl    %esi, %eax
+#ifdef APPLE_CC
+       gdt_src1_rel = gdt_src1 - start
+       gdt_src2_rel = gdt_src2 - start
+       gdt_dst1_rel = gdt_dst1 - start
+       gdt_dst2_rel = gdt_dst2 - start
+       gdt_rel = gdt - start
+
+       movw    %si, (gdt_src1_rel)
+       shrl    $16, %eax
+       movb    %al, (gdt_src1_rel + 2)
+       movb    %ah, (gdt_src2_rel)
+
+       movl    %edi, %eax
+       movw    %di, (gdt_dst1_rel)
+       shrl    $16, %eax
+       movb    %al, (gdt_dst1_rel + 2)
+       movb    %ah, (gdt_dst2_rel)
+
+       movw    $(gdt_rel), %si
+       movb    $0x87, %ah
+       shrw    $1, %cx
+#else
        movw    %si, (gdt_src1 - start)
        shrl    $16, %eax
        movb    %al, (gdt_src1 + 2 - start)
@@ -248,6 +304,7 @@
        movw    $(gdt - start), %si
        movb    $0x87, %ah
        shrw    $1, %cx
+#endif
 
        int     $0x15
 
@@ -257,7 +314,12 @@
        popl    %esi
 
        jnc     2f
+#ifdef APPLE_CC
+       err_int15_msg_rel = err_int15_msg - start
+       movw    $(err_int15_msg_rel), %si
+#else
        movw    $(err_int15_msg - start), %si
+#endif
        jmp     fail
 
 2:

Modified: trunk/grub2/commands/i386/pc/drivemap_int13h.S
===================================================================
--- trunk/grub2/commands/i386/pc/drivemap_int13h.S      2009-06-04 19:53:52 UTC 
(rev 2252)
+++ trunk/grub2/commands/i386/pc/drivemap_int13h.S      2009-06-04 20:01:19 UTC 
(rev 2253)
@@ -30,7 +30,12 @@
        /* Map the drive number (always in DL).  */
        push    %ax
        push    %bx
+#ifdef APPLE_CC
+       grub_drivemap_mapstart_ofs = 
INT13H_OFFSET(EXT_C(grub_drivemap_mapstart))
+       movw    $grub_drivemap_mapstart_ofs, %bx
+#else
        movw    $INT13H_OFFSET(EXT_C(grub_drivemap_mapstart)), %bx
+#endif
 
 more_remaining:
        movw    %cs:(%bx), %ax

Modified: trunk/grub2/kern/i386/pc/startup.S
===================================================================
--- trunk/grub2/kern/i386/pc/startup.S  2009-06-04 19:53:52 UTC (rev 2252)
+++ trunk/grub2/kern/i386/pc/startup.S  2009-06-04 20:01:19 UTC (rev 2253)
@@ -69,7 +69,12 @@
        /*
         *  Guarantee that "main" is loaded at 0x0:0x8200.
         */
+#ifdef APPLE_CC
+       codestart_abs = ABS(codestart) - 0x10000
+       ljmp $0, $(codestart_abs)
+#else
        ljmp $0, $ABS(codestart)
+#endif
 
        /*
         *  Compatibility version number
@@ -249,12 +254,24 @@
        movsb
 #endif
        
+#ifdef APPLE_CC
        /* clean out the bss */
+       bss_start_abs = ABS (bss_start)
+       bss_end_abs = ABS (bss_end)
+
+       movl    bss_start_abs, %edi
+
+       /* compute the bss length */
+       movl    bss_end_abs, %ecx
+       subl    %edi, %ecx
+#else
+       /* clean out the bss */
        movl    $BSS_START_SYMBOL, %edi
 
        /* compute the bss length */
        movl    $END_SYMBOL, %ecx
        subl    %edi, %ecx
+#endif
                        
        /* clean out */
        xorl    %eax, %eax
@@ -293,7 +310,13 @@
        cli
 
        /* load the GDT register */
+#ifdef APPLE_CC
+       mov %cs, %ax
+       mov %ax, %ds
+       DATA32  ADDR32  lgdt    gdtdesc
+#else
        DATA32  ADDR32  lgdt    %cs:gdtdesc
+#endif
 
        /* turn on protected mode */
        movl    %cr0, %eax
@@ -1223,7 +1246,12 @@
        pushw   %bx
        pushw   %si
        
+#ifdef APPLE_CC
+       translation_table_abs = ABS (translation_table) - 0x10000
+       movw    $(translation_table_abs), %si
+#else
        movw    $ABS(translation_table), %si
+#endif
        
 1:     lodsw
        /* check if this is the end */

Modified: trunk/grub2/mmap/i386/pc/mmap_helper.S
===================================================================
--- trunk/grub2/mmap/i386/pc/mmap_helper.S      2009-06-04 19:53:52 UTC (rev 
2252)
+++ trunk/grub2/mmap/i386/pc/mmap_helper.S      2009-06-04 20:01:19 UTC (rev 
2253)
@@ -28,7 +28,12 @@
        push %ds
        push %cs
        pop %ds
+#ifdef APPLE_CC
+       grub_machine_mmaphook_kblow_rel = DS (EXT_C 
(grub_machine_mmaphook_kblow))
+       movw (grub_machine_mmaphook_kblow_rel), %ax
+#else
        movw DS (EXT_C (grub_machine_mmaphook_kblow)), %ax
+#endif
        pop %ds
        iret
 
@@ -53,8 +58,15 @@
        push %ds
        push %cs
        pop %ds
+#ifdef APPLE_CC
+       grub_machine_mmaphook_kbin16mb_rel = DS (EXT_C 
(grub_machine_mmaphook_kbin16mb))
+       grub_machine_mmaphook_64kbin4gb_rel = DS (EXT_C 
(grub_machine_mmaphook_64kbin4gb))
+       movw (grub_machine_mmaphook_kbin16mb_rel), %ax
+       movw (grub_machine_mmaphook_64kbin4gb_rel), %bx
+#else
        movw DS (EXT_C (grub_machine_mmaphook_kbin16mb)), %ax
        movw DS (EXT_C (grub_machine_mmaphook_64kbin4gb)), %bx
+#endif
        movw %ax, %cx
        movw %bx, %dx
        pop %ds
@@ -66,26 +78,42 @@
        push %ds
        push %cs
        pop %ds
+#ifdef APPLE_CC
+       movw (grub_machine_mmaphook_kbin16mb_rel), %ax
+#else
        movw DS (EXT_C (grub_machine_mmaphook_kbin16mb)), %ax
+#endif
        pop %ds
        clc
        iret
 
 e820:
+#ifdef APPLE_CC
+       mmaphook_mmap_rel = DS(mmaphook_mmap)
+       mmaphook_mmap_num_rel = DS(EXT_C(grub_machine_mmaphook_mmap_num))
+#endif
        popf
        push %ds
        push %cs
        pop %ds
        cmpw $20, %cx
        jb errexit
+#ifdef APPLE_CC
+       cmpw (mmaphook_mmap_num_rel), %bx
+#else
        cmpw DS (EXT_C (grub_machine_mmaphook_mmap_num)), %bx
+#endif
        jae errexit
        cmp $0x534d4150, %edx
        jne errexit
        push %si
        push %di
        movw $20, %cx
+#ifdef APPLE_CC
+       movl $(mmaphook_mmap_rel), %esi
+#else
        movw $(DS(mmaphook_mmap)), %si
+#endif
        mov %bx, %ax
        imul $20, %ax
        add %ax, %si
@@ -94,7 +122,11 @@
        pop %si
        movl $20, %ecx
        inc %bx
+#ifdef APPLE_CC
+       cmpw (mmaphook_mmap_num_rel), %bx
+#else
        cmpw DS(EXT_C(grub_machine_mmaphook_mmap_num)), %bx
+#endif
        jb noclean
        xor %bx, %bx    
 noclean:       





reply via email to

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