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.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-27 00:04:14 +01:00
parent 8d2977bb7a
commit 969d1c782d
5 changed files with 58 additions and 86 deletions

View file

@ -1,3 +1,13 @@
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> 2010-03-26 BVK Chaitanya <bvk.groups@gmail.com>
Testcase and the fix for final semicolon on cmdline. Testcase and the fix for final semicolon on cmdline.

View file

@ -19,7 +19,7 @@
#include <grub/symbol.h> #include <grub/symbol.h>
#define INT13H_OFFSET(x) ((x) - EXT_C(grub_drivemap_handler)) #define INT13H_OFFSET(x) ((x) - LOCAL (base))
.code16 .code16
@ -27,6 +27,7 @@
/* The replacement int13 handler. Preserve all registers. */ /* The replacement int13 handler. Preserve all registers. */
FUNCTION(grub_drivemap_handler) FUNCTION(grub_drivemap_handler)
LOCAL (base):
/* Save %dx for future restore. */ /* Save %dx for future restore. */
push %dx push %dx
/* Push flags. Used to simulate interrupt with original flags. */ /* Push flags. Used to simulate interrupt with original flags. */
@ -35,12 +36,7 @@ FUNCTION(grub_drivemap_handler)
/* Map the drive number (always in DL). */ /* Map the drive number (always in DL). */
push %ax push %ax
push %bx push %bx
#ifdef APPLE_CC movw $INT13H_OFFSET(LOCAL (mapstart)), %bx
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: more_remaining:
movw %cs:(%bx), %ax movw %cs:(%bx), %ax
@ -66,12 +62,7 @@ not_found:
popf popf
pushf pushf
#ifdef APPLE_CC lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
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
push %bp push %bp
mov %sp, %bp mov %sp, %bp
@ -94,11 +85,7 @@ norestore:
popf popf
pushf pushf
#ifdef APPLE_CC lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
lcall *%cs:grub_drivemap_oldhandler_ofs
#else
lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
#endif
push %bp push %bp
mov %sp, %bp mov %sp, %bp
@ -111,9 +98,13 @@ norestore:
/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode /* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
IVT entries (thus PI:SC in mem). */ IVT entries (thus PI:SC in mem). */
VARIABLE(grub_drivemap_oldhandler) VARIABLE(grub_drivemap_oldhandler)
LOCAL (oldhandler):
.word 0x0, 0x0 .word 0x0, 0x0
/* This label MUST be at the end of the copied block, since the installer code /* 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. */ reserves additional space for mappings at runtime and copies them over it. */
.align 2 .align 2
VARIABLE(grub_drivemap_mapstart) VARIABLE(grub_drivemap_mapstart)
LOCAL (mapstart):
.byte 0

View file

@ -161,7 +161,7 @@ else
-rm -f $@ -rm -f $@
-rm -f $@.bin -rm -f $@.bin
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj} $(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 -rm -f $@.bin
endif endif
endif endif

View file

@ -53,7 +53,7 @@
#include <multiboot.h> #include <multiboot.h>
#include <multiboot2.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" .file "startup.S"
@ -66,16 +66,15 @@
.globl start, _start .globl start, _start
start: start:
_start: _start:
LOCAL (base):
/* /*
* Guarantee that "main" is loaded at 0x0:0x8200. * Guarantee that "main" is loaded at 0x0:0x8200.
*/ */
#ifdef APPLE_CC #ifdef __APPLE__
codestart_abs = ABS(codestart) - 0x10000 ljmp $0, $(ABS(LOCAL (codestart)) - 0x10000)
ljmp $0, $(codestart_abs)
#else #else
ljmp $0, $ABS(codestart) ljmp $0, $ABS(LOCAL (codestart))
#endif #endif
/* /*
* Compatibility version number * Compatibility version number
* *
@ -183,7 +182,7 @@ multiboot_trampoline:
.code16 .code16
/* the real mode code continues... */ /* the real mode code continues... */
codestart: LOCAL (codestart):
cli /* we're not safe here! */ cli /* we're not safe here! */
/* set up %ds, %ss, and %es */ /* set up %ds, %ss, and %es */
@ -1156,7 +1155,7 @@ FUNCTION(grub_console_real_putchar)
*/ */
/* this table is used in translate_keycode below */ /* 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_LEFT, GRUB_TERM_LEFT
.word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT .word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
.word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP .word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
@ -1178,11 +1177,10 @@ translate_keycode:
pushw %bx pushw %bx
pushw %si pushw %si
#ifdef APPLE_CC #ifdef __APPLE__
translation_table_abs = ABS (translation_table) - 0x10000 movw $(ABS(LOCAL (translation_table)) - 0x10000), %si
movw $(translation_table_abs), %si
#else #else
movw $ABS(translation_table), %si movw $ABS(LOCAL (translation_table)), %si
#endif #endif
1: lodsw 1: lodsw

View file

@ -19,32 +19,27 @@
#include <grub/symbol.h> #include <grub/symbol.h>
#define DS(x) ((x) - segstart) #define DS(x) ((x) - LOCAL (segstart))
segstart: LOCAL (segstart):
VARIABLE(grub_machine_mmaphook_start) VARIABLE(grub_machine_mmaphook_start)
.code16 .code16
VARIABLE(grub_machine_mmaphook_int12) VARIABLE(grub_machine_mmaphook_int12)
push %ds push %ds
push %cs push %cs
pop %ds pop %ds
#ifdef APPLE_CC movw DS (LOCAL (kblow)), %ax
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 pop %ds
iret iret
VARIABLE(grub_machine_mmaphook_int15) VARIABLE(grub_machine_mmaphook_int15)
pushf pushf
cmpw $0xe801, %ax cmpw $0xe801, %ax
jz e801 jz LOCAL (e801)
cmpw $0xe820, %ax cmpw $0xe820, %ax
jz e820 jz LOCAL (e820)
cmpb $0x88, %ah cmpb $0x88, %ah
jz h88 jz LOCAL (h88)
popf popf
/* ljmp */ /* ljmp */
.byte 0xea .byte 0xea
@ -53,67 +48,44 @@ VARIABLE (grub_machine_mmaphook_int15offset)
VARIABLE (grub_machine_mmaphook_int15segment) VARIABLE (grub_machine_mmaphook_int15segment)
.word 0 .word 0
e801: LOCAL (e801):
popf popf
push %ds push %ds
push %cs push %cs
pop %ds pop %ds
#ifdef APPLE_CC movw DS (LOCAL (kbin16mb)), %ax
grub_machine_mmaphook_kbin16mb_rel = DS (EXT_C (grub_machine_mmaphook_kbin16mb)) movw DS (LOCAL (m64kbin4gb)), %bx
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 %ax, %cx
movw %bx, %dx movw %bx, %dx
pop %ds pop %ds
clc clc
iret iret
h88: LOCAL (h88):
popf popf
push %ds push %ds
push %cs push %cs
pop %ds pop %ds
#ifdef APPLE_CC movw DS (LOCAL (kbin16mb)), %ax
movw (grub_machine_mmaphook_kbin16mb_rel), %ax
#else
movw DS (EXT_C (grub_machine_mmaphook_kbin16mb)), %ax
#endif
pop %ds pop %ds
clc clc
iret iret
e820: LOCAL (e820):
#ifdef APPLE_CC
mmaphook_mmap_rel = DS(mmaphook_mmap)
mmaphook_mmap_num_rel = DS(EXT_C(grub_machine_mmaphook_mmap_num))
#endif
popf popf
push %ds push %ds
push %cs push %cs
pop %ds pop %ds
cmpw $20, %cx cmpw $20, %cx
jb errexit jb LOCAL (errexit)
#ifdef APPLE_CC cmpw DS (LOCAL (mmap_num)), %bx
cmpw (mmaphook_mmap_num_rel), %bx jae LOCAL (errexit)
#else
cmpw DS (EXT_C (grub_machine_mmaphook_mmap_num)), %bx
#endif
jae errexit
cmp $0x534d4150, %edx cmp $0x534d4150, %edx
jne errexit jne LOCAL (errexit)
push %si push %si
push %di push %di
movw $20, %cx movw $20, %cx
#ifdef APPLE_CC movw $(DS(LOCAL (mmaphook_mmap))), %si
movl $(mmaphook_mmap_rel), %esi
#else
movw $(DS(mmaphook_mmap)), %si
#endif
mov %bx, %ax mov %bx, %ax
imul $20, %ax imul $20, %ax
add %ax, %si add %ax, %si
@ -122,19 +94,15 @@ e820:
pop %si pop %si
movl $20, %ecx movl $20, %ecx
inc %bx inc %bx
#ifdef APPLE_CC cmpw DS(LOCAL (mmap_num)), %bx
cmpw (mmaphook_mmap_num_rel), %bx jb LOCAL (noclean)
#else
cmpw DS(EXT_C(grub_machine_mmaphook_mmap_num)), %bx
#endif
jb noclean
xor %bx, %bx xor %bx, %bx
noclean: LOCAL (noclean):
mov $0x534d4150, %eax mov $0x534d4150, %eax
pop %ds pop %ds
clc clc
iret iret
errexit: LOCAL (errexit):
mov $0x534d4150, %eax mov $0x534d4150, %eax
pop %ds pop %ds
stc stc
@ -142,13 +110,18 @@ errexit:
iret iret
VARIABLE(grub_machine_mmaphook_mmap_num) VARIABLE(grub_machine_mmaphook_mmap_num)
LOCAL (mmap_num):
.word 0 .word 0
VARIABLE(grub_machine_mmaphook_kblow) VARIABLE(grub_machine_mmaphook_kblow)
LOCAL (kblow):
.word 0 .word 0
VARIABLE (grub_machine_mmaphook_kbin16mb) VARIABLE (grub_machine_mmaphook_kbin16mb)
LOCAL (kbin16mb):
.word 0 .word 0
VARIABLE (grub_machine_mmaphook_64kbin4gb) VARIABLE (grub_machine_mmaphook_64kbin4gb)
LOCAL (m64kbin4gb):
.word 0 .word 0
mmaphook_mmap: LOCAL (mmaphook_mmap):
/* Memory map is placed just after the interrupt handlers. */ /* Memory map is placed just after the interrupt handlers. */
VARIABLE(grub_machine_mmaphook_end) VARIABLE(grub_machine_mmaphook_end)
.byte 0