2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
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
This commit is contained in:
parent
2b167a7218
commit
3e32590112
8 changed files with 214 additions and 1 deletions
|
@ -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 @@ boot_drive_check:
|
|||
* 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 @@ real_start:
|
|||
* 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 @@ real_start:
|
|||
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 @@ lba_mode:
|
|||
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 @@ final_init:
|
|||
|
||||
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 @@ setup_sectors:
|
|||
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 @@ copy_buffer:
|
|||
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 @@ 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
|
||||
#endif
|
||||
|
||||
probe_loop:
|
||||
/* reset floppy controller INT 13h AH=0 */
|
||||
|
|
|
@ -67,8 +67,15 @@ bi_reserved:
|
|||
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 @@ read_cdrom:
|
|||
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
|
||||
|
|
|
@ -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 @@ _start:
|
|||
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
|
||||
|
|
|
@ -123,8 +123,15 @@ data_leng:
|
|||
|
||||
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 @@ linux_next:
|
|||
|
||||
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 @@ 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:
|
||||
|
||||
|
@ -189,8 +211,15 @@ real_code_2:
|
|||
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 @@ real_code_2:
|
|||
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 @@ 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)
|
||||
|
@ -248,6 +304,7 @@ move_memory:
|
|||
movw $(gdt - start), %si
|
||||
movb $0x87, %ah
|
||||
shrw $1, %cx
|
||||
#endif
|
||||
|
||||
int $0x15
|
||||
|
||||
|
@ -257,7 +314,12 @@ 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
|
||||
|
||||
2:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue