* commands/i386/pc/drivemap_int13h.S: Use LOCAL when possible.
Add 0 byte at the end not to have a symbol with empty target.
* mmap/i386/pc/mmap_helper.S: Likewise.
* genmk.rb: Ignore errors 2030 and 2050.
* kern/i386/pc/startup.S: Use LOCAL when possible.
+2010-03-27 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Simplify Apple CC support.
+
+ * commands/i386/pc/drivemap_int13h.S: Use LOCAL when possible.
+ Add 0 byte at the end not to have a symbol with empty target.
+ * mmap/i386/pc/mmap_helper.S: Likewise.
+ * genmk.rb: Ignore errors 2030 and 2050.
+ * kern/i386/pc/startup.S: Use LOCAL when possible.
+
2010-03-26 BVK Chaitanya <bvk.groups@gmail.com>
Testcase and the fix for final semicolon on cmdline.
#include <grub/symbol.h>
-#define INT13H_OFFSET(x) ((x) - EXT_C(grub_drivemap_handler))
+#define INT13H_OFFSET(x) ((x) - LOCAL (base))
.code16
/* The replacement int13 handler. Preserve all registers. */
FUNCTION(grub_drivemap_handler)
+LOCAL (base):
/* Save %dx for future restore. */
push %dx
/* Push flags. Used to simulate interrupt with original flags. */
/* 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
+ movw $INT13H_OFFSET(LOCAL (mapstart)), %bx
more_remaining:
movw %cs:(%bx), %ax
popf
pushf
-#ifdef APPLE_CC
- grub_drivemap_oldhandler_ofs = INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
- lcall *%cs:grub_drivemap_oldhandler_ofs
-#else
- lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
-#endif
+ lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
push %bp
mov %sp, %bp
popf
pushf
-#ifdef APPLE_CC
- lcall *%cs:grub_drivemap_oldhandler_ofs
-#else
- lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
-#endif
+ lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
push %bp
mov %sp, %bp
/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
IVT entries (thus PI:SC in mem). */
VARIABLE(grub_drivemap_oldhandler)
+LOCAL (oldhandler):
.word 0x0, 0x0
/* This label MUST be at the end of the copied block, since the installer code
reserves additional space for mappings at runtime and copies them over it. */
-.align 2
+ .align 2
+
VARIABLE(grub_drivemap_mapstart)
+LOCAL (mapstart):
+ .byte 0
-rm -f $@
-rm -f $@.bin
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
- $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@
+ $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -ew2030 -ew2050 -nu -nd $@.bin $@
-rm -f $@.bin
endif
endif
#include <multiboot.h>
#include <multiboot2.h>
-#define ABS(x) ((x) - _start + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
+#define ABS(x) ((x) - LOCAL (base) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
.file "startup.S"
.globl start, _start
start:
_start:
+LOCAL (base):
/*
* Guarantee that "main" is loaded at 0x0:0x8200.
*/
-#ifdef APPLE_CC
- codestart_abs = ABS(codestart) - 0x10000
- ljmp $0, $(codestart_abs)
+#ifdef __APPLE__
+ ljmp $0, $(ABS(LOCAL (codestart)) - 0x10000)
#else
- ljmp $0, $ABS(codestart)
+ ljmp $0, $ABS(LOCAL (codestart))
#endif
-
/*
* Compatibility version number
*
.code16
/* the real mode code continues... */
-codestart:
+LOCAL (codestart):
cli /* we're not safe here! */
/* set up %ds, %ss, and %es */
*/
/* this table is used in translate_keycode below */
-translation_table:
+LOCAL (translation_table):
.word GRUB_CONSOLE_KEY_LEFT, GRUB_TERM_LEFT
.word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
.word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
pushw %bx
pushw %si
-#ifdef APPLE_CC
- translation_table_abs = ABS (translation_table) - 0x10000
- movw $(translation_table_abs), %si
+#ifdef __APPLE__
+ movw $(ABS(LOCAL (translation_table)) - 0x10000), %si
#else
- movw $ABS(translation_table), %si
+ movw $ABS(LOCAL (translation_table)), %si
#endif
1: lodsw
#include <grub/symbol.h>
-#define DS(x) ((x) - segstart)
+#define DS(x) ((x) - LOCAL (segstart))
-segstart:
+LOCAL (segstart):
VARIABLE(grub_machine_mmaphook_start)
.code16
VARIABLE(grub_machine_mmaphook_int12)
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
+ movw DS (LOCAL (kblow)), %ax
pop %ds
iret
VARIABLE(grub_machine_mmaphook_int15)
pushf
cmpw $0xe801, %ax
- jz e801
+ jz LOCAL (e801)
cmpw $0xe820, %ax
- jz e820
+ jz LOCAL (e820)
cmpb $0x88, %ah
- jz h88
+ jz LOCAL (h88)
popf
/* ljmp */
.byte 0xea
VARIABLE (grub_machine_mmaphook_int15segment)
.word 0
-e801:
+LOCAL (e801):
popf
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 DS (LOCAL (kbin16mb)), %ax
+ movw DS (LOCAL (m64kbin4gb)), %bx
movw %ax, %cx
movw %bx, %dx
pop %ds
clc
iret
-h88:
+LOCAL (h88):
popf
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
+ movw DS (LOCAL (kbin16mb)), %ax
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
+LOCAL (e820):
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
+ jb LOCAL (errexit)
+ cmpw DS (LOCAL (mmap_num)), %bx
+ jae LOCAL (errexit)
cmp $0x534d4150, %edx
- jne errexit
+ jne LOCAL (errexit)
push %si
push %di
movw $20, %cx
-#ifdef APPLE_CC
- movl $(mmaphook_mmap_rel), %esi
-#else
- movw $(DS(mmaphook_mmap)), %si
-#endif
+ movw $(DS(LOCAL (mmaphook_mmap))), %si
mov %bx, %ax
imul $20, %ax
add %ax, %si
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
+ cmpw DS(LOCAL (mmap_num)), %bx
+ jb LOCAL (noclean)
xor %bx, %bx
-noclean:
+LOCAL (noclean):
mov $0x534d4150, %eax
pop %ds
clc
iret
-errexit:
+LOCAL (errexit):
mov $0x534d4150, %eax
pop %ds
stc
iret
VARIABLE(grub_machine_mmaphook_mmap_num)
+LOCAL (mmap_num):
.word 0
VARIABLE(grub_machine_mmaphook_kblow)
+LOCAL (kblow):
.word 0
VARIABLE (grub_machine_mmaphook_kbin16mb)
+LOCAL (kbin16mb):
.word 0
VARIABLE (grub_machine_mmaphook_64kbin4gb)
+LOCAL (m64kbin4gb):
.word 0
-mmaphook_mmap:
+LOCAL (mmaphook_mmap):
/* Memory map is placed just after the interrupt handlers. */
VARIABLE(grub_machine_mmaphook_end)
+ .byte 0