2009-08-14 Pavel Roskin <proski@gnu.org>
* boot/i386/pc/cdboot.S: Use LOCAL for local labels. Eliminate ABS and APPLE_CC. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/lnxboot.S: Likewise. Hardcode the number of code sectors allow compilation on MacOSX. * conf/i386-pc.rmk: Enable unconditional compilation of lnxboot.img.
This commit is contained in:
parent
9a10df160e
commit
d404ee5646
5 changed files with 63 additions and 164 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/boot.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
@ -25,14 +26,8 @@
|
|||
|
||||
.file "lnxboot.S"
|
||||
|
||||
#ifdef APPLE_CC
|
||||
#error Building lnxboot.img with Apple's as results in an unusable image
|
||||
#endif
|
||||
|
||||
#define CODE_ADDR 0x6000
|
||||
#ifndef APPLE_CC
|
||||
#define CODE_LENG (code_end - start)
|
||||
#endif
|
||||
#define CODE_SECTORS 1
|
||||
#define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
|
||||
|
||||
#define BLCK_LENG 0x4000
|
||||
|
@ -45,17 +40,12 @@
|
|||
|
||||
data_start:
|
||||
xorl %ebp, %ebp
|
||||
jmp linux_next
|
||||
jmp LOCAL(linux_next)
|
||||
|
||||
. = data_start + 0x1F1
|
||||
|
||||
setup_sects:
|
||||
/* Apple's cc can't fill this value. */
|
||||
#ifdef APPLE_CC
|
||||
.byte 0
|
||||
#else
|
||||
.byte (CODE_LENG >> 9)
|
||||
#endif
|
||||
.byte CODE_SECTORS
|
||||
root_flags:
|
||||
.word 0
|
||||
syssize:
|
||||
|
@ -74,7 +64,7 @@ boot_flag:
|
|||
start:
|
||||
_start:
|
||||
|
||||
jmp linux_init
|
||||
jmp LOCAL(linux_init)
|
||||
|
||||
.ascii "HdrS" /* Header signature. */
|
||||
.word 0x0203 /* Header version number. */
|
||||
|
@ -132,40 +122,22 @@ reg_edx:
|
|||
data_leng:
|
||||
.long 0
|
||||
|
||||
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
|
||||
LOCAL(linux_init):
|
||||
movw %cs:(reg_edx - start), %dx
|
||||
movl %cs:(code32_start - start), %ebp
|
||||
#endif
|
||||
|
||||
linux_next:
|
||||
LOCAL(linux_next):
|
||||
|
||||
call normalize
|
||||
call LOCAL(normalize)
|
||||
|
||||
normalize:
|
||||
LOCAL(normalize):
|
||||
popw %bx
|
||||
#ifdef APPLE_CC
|
||||
normalize_rel = normalize - start
|
||||
subw $(normalize_rel), %bx
|
||||
#else
|
||||
subw $(normalize - start), %bx
|
||||
#endif
|
||||
subw $(LOCAL(normalize) - start), %bx
|
||||
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:
|
||||
|
@ -191,13 +163,7 @@ real_code:
|
|||
|
||||
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:
|
||||
|
||||
|
@ -216,21 +182,14 @@ real_code_2:
|
|||
addl %ecx, %esi
|
||||
movl $DATA_ADDR, %edi
|
||||
|
||||
call move_memory
|
||||
call LOCAL(move_memory)
|
||||
|
||||
/* Check for multiboot signature. */
|
||||
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
|
||||
|
||||
|
@ -240,17 +199,11 @@ real_code_2:
|
|||
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx
|
||||
|
||||
2:
|
||||
call move_memory
|
||||
call LOCAL(move_memory)
|
||||
|
||||
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
|
||||
|
@ -264,7 +217,7 @@ real_code_2:
|
|||
* ecx: number of bytes
|
||||
*/
|
||||
|
||||
move_memory:
|
||||
LOCAL(move_memory):
|
||||
incl %ecx
|
||||
andb $0xFE, %cl
|
||||
pushw %dx
|
||||
|
@ -279,28 +232,6 @@ move_memory:
|
|||
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)
|
||||
|
@ -315,7 +246,6 @@ move_memory:
|
|||
movw $(gdt - start), %si
|
||||
movb $0x87, %ah
|
||||
shrw $1, %cx
|
||||
#endif
|
||||
|
||||
int $0x15
|
||||
|
||||
|
@ -325,13 +255,8 @@ move_memory:
|
|||
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
|
||||
jmp LOCAL(fail)
|
||||
|
||||
2:
|
||||
|
||||
|
@ -349,7 +274,7 @@ move_memory:
|
|||
* si: message
|
||||
*/
|
||||
|
||||
fail:
|
||||
LOCAL(fail):
|
||||
movb $0x0e, %ah
|
||||
xorw %bx, %bx
|
||||
1:
|
||||
|
@ -362,11 +287,4 @@ fail:
|
|||
err_int15_msg:
|
||||
.ascii "move memory fails\0"
|
||||
|
||||
/* Unsupported feature in Apple's cc. */
|
||||
#ifndef APPLE_CC
|
||||
. = (. & (~0x1FF)) + 0x1FF
|
||||
#endif
|
||||
|
||||
.byte 0
|
||||
|
||||
code_end:
|
||||
. = _start + CODE_SECTORS * 512
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue