2009-08-13 Pavel Roskin <proski@gnu.org>
* boot/i386/pc/boot.S: Remove all code dependent on APPLE_CC. Use local labels starting with "L_" so that Apple assembler knows they are local.
This commit is contained in:
parent
81623db677
commit
1f9e557e39
2 changed files with 38 additions and 78 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-08-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* boot/i386/pc/boot.S: Remove all code dependent on APPLE_CC.
|
||||||
|
Use local labels starting with "L_" so that Apple assembler
|
||||||
|
knows they are local.
|
||||||
|
|
||||||
2009-08-10 Robert Millan <rmh.grub@aybabtu.com>
|
2009-08-10 Robert Millan <rmh.grub@aybabtu.com>
|
||||||
|
|
||||||
* include/grub/i386/bsd.h (KERNEL_TYPE_NONE, KERNEL_TYPE_FREEBSD)
|
* include/grub/i386/bsd.h (KERNEL_TYPE_NONE, KERNEL_TYPE_FREEBSD)
|
||||||
|
|
|
@ -30,11 +30,7 @@
|
||||||
#define ABS(x) (x-_start+0x7c00)
|
#define ABS(x) (x-_start+0x7c00)
|
||||||
|
|
||||||
/* Print message string */
|
/* Print message string */
|
||||||
#ifdef APPLE_CC
|
#define MSG(x) movw $ABS(x), %si; call L_message
|
||||||
#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"
|
.file "boot.S"
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ start:
|
||||||
* parameter block.
|
* parameter block.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jmp after_BPB
|
jmp L_after_BPB
|
||||||
nop /* do I care about this ??? */
|
nop /* do I care about this ??? */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -104,7 +100,7 @@ boot_drive:
|
||||||
.byte 0xff /* the disk to load kernel from */
|
.byte 0xff /* the disk to load kernel from */
|
||||||
/* 0xff means use the boot drive */
|
/* 0xff means use the boot drive */
|
||||||
|
|
||||||
after_BPB:
|
L_after_BPB:
|
||||||
|
|
||||||
/* general setup */
|
/* general setup */
|
||||||
cli /* we're not safe here! */
|
cli /* we're not safe here! */
|
||||||
|
@ -129,12 +125,7 @@ boot_drive_check:
|
||||||
* ljmp to the next instruction because some bogus BIOSes
|
* ljmp to the next instruction because some bogus BIOSes
|
||||||
* jump to 07C0:0000 instead of 0000:7C00.
|
* 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)
|
ljmp $0, $ABS(real_start)
|
||||||
#endif
|
|
||||||
|
|
||||||
real_start:
|
real_start:
|
||||||
|
|
||||||
|
@ -151,12 +142,7 @@ real_start:
|
||||||
/*
|
/*
|
||||||
* Check if we have a forced disk reference here
|
* 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
|
movb ABS(boot_drive), %al
|
||||||
#endif
|
|
||||||
cmpb $0xff, %al
|
cmpb $0xff, %al
|
||||||
je 1f
|
je 1f
|
||||||
movb %al, %dl
|
movb %al, %dl
|
||||||
|
@ -168,16 +154,11 @@ real_start:
|
||||||
MSG(notification_string)
|
MSG(notification_string)
|
||||||
|
|
||||||
/* set %si to the disk address packet */
|
/* 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
|
movw $ABS(disk_address_packet), %si
|
||||||
#endif
|
|
||||||
|
|
||||||
/* do not probe LBA if the drive is a floppy */
|
/* do not probe LBA if the drive is a floppy */
|
||||||
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
||||||
jz chs_mode
|
jz L_chs_mode
|
||||||
|
|
||||||
/* check if LBA is supported */
|
/* check if LBA is supported */
|
||||||
movb $0x41, %ah
|
movb $0x41, %ah
|
||||||
|
@ -192,12 +173,12 @@ real_start:
|
||||||
pushw %dx
|
pushw %dx
|
||||||
|
|
||||||
/* use CHS if fails */
|
/* use CHS if fails */
|
||||||
jc chs_mode
|
jc L_chs_mode
|
||||||
cmpw $0xaa55, %bx
|
cmpw $0xaa55, %bx
|
||||||
jne chs_mode
|
jne L_chs_mode
|
||||||
|
|
||||||
andw $1, %cx
|
andw $1, %cx
|
||||||
jz chs_mode
|
jz L_chs_mode
|
||||||
|
|
||||||
lba_mode:
|
lba_mode:
|
||||||
xorw %ax, %ax
|
xorw %ax, %ax
|
||||||
|
@ -214,18 +195,10 @@ lba_mode:
|
||||||
movw $0x0010, (%si)
|
movw $0x0010, (%si)
|
||||||
|
|
||||||
/* the absolute address */
|
/* 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 ABS(kernel_sector), %ebx
|
||||||
movl %ebx, 8(%si)
|
movl %ebx, 8(%si)
|
||||||
movl ABS(kernel_sector + 4), %ebx
|
movl ABS(kernel_sector + 4), %ebx
|
||||||
movl %ebx, 12(%si)
|
movl %ebx, 12(%si)
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the segment of buffer address */
|
/* the segment of buffer address */
|
||||||
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
|
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
|
||||||
|
@ -243,30 +216,30 @@ lba_mode:
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
/* LBA read is not supported, so fallback to CHS. */
|
/* LBA read is not supported, so fallback to CHS. */
|
||||||
jc chs_mode
|
jc L_chs_mode
|
||||||
|
|
||||||
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
||||||
jmp copy_buffer
|
jmp L_copy_buffer
|
||||||
|
|
||||||
chs_mode:
|
L_chs_mode:
|
||||||
/*
|
/*
|
||||||
* Determine the hard disk geometry from the BIOS!
|
* Determine the hard disk geometry from the BIOS!
|
||||||
* We do this first, so that LS-120 IDE floppies work correctly.
|
* We do this first, so that LS-120 IDE floppies work correctly.
|
||||||
*/
|
*/
|
||||||
movb $8, %ah
|
movb $8, %ah
|
||||||
int $0x13
|
int $0x13
|
||||||
jnc final_init
|
jnc L_final_init
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The call failed, so maybe use the floppy probe instead.
|
* The call failed, so maybe use the floppy probe instead.
|
||||||
*/
|
*/
|
||||||
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
||||||
jz floppy_probe
|
jz L_floppy_probe
|
||||||
|
|
||||||
/* Nope, we definitely have a hard disk, and we're screwed. */
|
/* Nope, we definitely have a hard disk, and we're screwed. */
|
||||||
jmp hd_probe_error
|
jmp L_hd_probe_error
|
||||||
|
|
||||||
final_init:
|
L_final_init:
|
||||||
/* set the mode to zero */
|
/* set the mode to zero */
|
||||||
movzbl %dh, %eax
|
movzbl %dh, %eax
|
||||||
movb %ah, -1(%si)
|
movb %ah, -1(%si)
|
||||||
|
@ -292,22 +265,13 @@ final_init:
|
||||||
|
|
||||||
setup_sectors:
|
setup_sectors:
|
||||||
/* load logical sector start (top half) */
|
/* 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
|
movl ABS(kernel_sector + 4), %eax
|
||||||
#endif
|
|
||||||
|
|
||||||
orl %eax, %eax
|
orl %eax, %eax
|
||||||
jnz geometry_error
|
jnz L_geometry_error
|
||||||
|
|
||||||
/* load logical sector start (bottom half) */
|
/* load logical sector start (bottom half) */
|
||||||
#ifdef APPLE_CC
|
|
||||||
movl (kernel_sector_abs), %eax
|
|
||||||
#else
|
|
||||||
movl ABS(kernel_sector), %eax
|
movl ABS(kernel_sector), %eax
|
||||||
#endif
|
|
||||||
|
|
||||||
/* zero %edx */
|
/* zero %edx */
|
||||||
xorl %edx, %edx
|
xorl %edx, %edx
|
||||||
|
@ -323,7 +287,7 @@ setup_sectors:
|
||||||
|
|
||||||
/* do we need too many cylinders? */
|
/* do we need too many cylinders? */
|
||||||
cmpw 8(%si), %ax
|
cmpw 8(%si), %ax
|
||||||
jge geometry_error
|
jge L_geometry_error
|
||||||
|
|
||||||
/* normalize sector start (1-based) */
|
/* normalize sector start (1-based) */
|
||||||
incb %cl
|
incb %cl
|
||||||
|
@ -365,11 +329,11 @@ setup_sectors:
|
||||||
movw $0x0201, %ax /* function 2 */
|
movw $0x0201, %ax /* function 2 */
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
jc read_error
|
jc L_read_error
|
||||||
|
|
||||||
movw %es, %bx
|
movw %es, %bx
|
||||||
|
|
||||||
copy_buffer:
|
L_copy_buffer:
|
||||||
/*
|
/*
|
||||||
* We need to save %cx and %si because the startup code in
|
* We need to save %cx and %si because the startup code in
|
||||||
* kernel uses them without initializing them.
|
* kernel uses them without initializing them.
|
||||||
|
@ -392,42 +356,37 @@ copy_buffer:
|
||||||
popa
|
popa
|
||||||
|
|
||||||
/* boot kernel */
|
/* boot kernel */
|
||||||
#ifdef APPLE_CC
|
|
||||||
kernel_address_abs = ABS (kernel_address)
|
|
||||||
jmp *(kernel_address_abs)
|
|
||||||
#else
|
|
||||||
jmp *(kernel_address)
|
jmp *(kernel_address)
|
||||||
#endif
|
|
||||||
|
|
||||||
/* END OF MAIN LOOP */
|
/* END OF MAIN LOOP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BIOS Geometry translation error (past the end of the disk geometry!).
|
* BIOS Geometry translation error (past the end of the disk geometry!).
|
||||||
*/
|
*/
|
||||||
geometry_error:
|
L_geometry_error:
|
||||||
MSG(geometry_error_string)
|
MSG(geometry_error_string)
|
||||||
jmp general_error
|
jmp L_general_error
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disk probe failure.
|
* Disk probe failure.
|
||||||
*/
|
*/
|
||||||
hd_probe_error:
|
L_hd_probe_error:
|
||||||
MSG(hd_probe_error_string)
|
MSG(hd_probe_error_string)
|
||||||
jmp general_error
|
jmp L_general_error
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read error on the disk.
|
* Read error on the disk.
|
||||||
*/
|
*/
|
||||||
read_error:
|
L_read_error:
|
||||||
MSG(read_error_string)
|
MSG(read_error_string)
|
||||||
|
|
||||||
general_error:
|
L_general_error:
|
||||||
MSG(general_error_string)
|
MSG(general_error_string)
|
||||||
|
|
||||||
/* go here when you need to stop the machine hard after an error condition */
|
/* go here when you need to stop the machine hard after an error condition */
|
||||||
/* tell the BIOS a boot failure, which may result in no effect */
|
/* tell the BIOS a boot failure, which may result in no effect */
|
||||||
int $0x18
|
int $0x18
|
||||||
stop: jmp stop
|
L_stop: jmp L_stop
|
||||||
|
|
||||||
notification_string: .asciz "GRUB "
|
notification_string: .asciz "GRUB "
|
||||||
geometry_error_string: .asciz "Geom"
|
geometry_error_string: .asciz "Geom"
|
||||||
|
@ -450,7 +409,7 @@ general_error_string: .asciz " Error\r\n"
|
||||||
movw $0x0001, %bx
|
movw $0x0001, %bx
|
||||||
movb $0xe, %ah
|
movb $0xe, %ah
|
||||||
int $0x10 /* display a byte */
|
int $0x10 /* display a byte */
|
||||||
message:
|
L_message:
|
||||||
lodsb
|
lodsb
|
||||||
cmpb $0, %al
|
cmpb $0, %al
|
||||||
jne 1b /* if not end of string, jmp to display */
|
jne 1b /* if not end of string, jmp to display */
|
||||||
|
@ -478,19 +437,14 @@ part_start:
|
||||||
probe_values:
|
probe_values:
|
||||||
.byte 36, 18, 15, 9, 0
|
.byte 36, 18, 15, 9, 0
|
||||||
|
|
||||||
floppy_probe:
|
L_floppy_probe:
|
||||||
/*
|
/*
|
||||||
* Perform 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
|
movw $ABS(probe_values-1), %si
|
||||||
#endif
|
|
||||||
|
|
||||||
probe_loop:
|
L_probe_loop:
|
||||||
/* reset floppy controller INT 13h AH=0 */
|
/* reset floppy controller INT 13h AH=0 */
|
||||||
xorw %ax, %ax
|
xorw %ax, %ax
|
||||||
int $0x13
|
int $0x13
|
||||||
|
@ -506,7 +460,7 @@ probe_loop:
|
||||||
* Floppy disk probe failure.
|
* Floppy disk probe failure.
|
||||||
*/
|
*/
|
||||||
MSG(fd_probe_error_string)
|
MSG(fd_probe_error_string)
|
||||||
jmp general_error
|
jmp L_general_error
|
||||||
|
|
||||||
/* "Floppy" */
|
/* "Floppy" */
|
||||||
fd_probe_error_string: .asciz "Floppy"
|
fd_probe_error_string: .asciz "Floppy"
|
||||||
|
@ -519,14 +473,14 @@ fd_probe_error_string: .asciz "Floppy"
|
||||||
movb $0, %dh
|
movb $0, %dh
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
/* if error, jump to "probe_loop" */
|
/* if error, jump to "L_probe_loop" */
|
||||||
jc probe_loop
|
jc L_probe_loop
|
||||||
|
|
||||||
/* %cl is already the correct value! */
|
/* %cl is already the correct value! */
|
||||||
movb $1, %dh
|
movb $1, %dh
|
||||||
movb $79, %ch
|
movb $79, %ch
|
||||||
|
|
||||||
jmp final_init
|
jmp L_final_init
|
||||||
|
|
||||||
. = _start + GRUB_BOOT_MACHINE_PART_END
|
. = _start + GRUB_BOOT_MACHINE_PART_END
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue