david/ipxe
Archived
1
0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/arch/i386/prefix/hdprefix.S

104 lines
1.5 KiB
ArmAsm
Raw Normal View History

2006-03-16 18:59:51 +01:00
.text
2007-07-05 13:58:16 +02:00
.arch i386
.section ".prefix", "awx", @progbits
2006-03-16 18:59:51 +01:00
.code16
2007-07-05 13:58:16 +02:00
.org 0
movw $load_image, %bp
jmp find_active_partition
#include "bootpart.S"
load_image:
2007-07-05 14:30:49 +02:00
/* Get disk geometry */
pushal
pushw %es
movb $0x08, %ah
int $0x13
jc load_failed
movb %cl, max_sector
movb %dh, max_head
popw %es
popal
1: /* Read to end of current track */
movb %cl, %al
negb %al
addb max_sector, %al
incb %al
andb $0x3f, %al
movzbl %al, %eax
2007-07-05 13:58:16 +02:00
call *read_sectors
jc load_failed
2007-07-05 14:30:49 +02:00
2007-07-05 13:58:16 +02:00
/* Update %es */
movw %es, %bx
shll $5, %eax
addw %ax, %bx
movw %bx, %es
shrl $5, %eax
2007-07-05 14:30:49 +02:00
2007-07-05 13:58:16 +02:00
/* Update LBA address */
addl %eax, %edi
adcl $0, %esi
2007-07-05 14:30:49 +02:00
2007-07-05 13:58:16 +02:00
/* Update CHS address */
2007-07-05 14:30:49 +02:00
andb $0xc0, %cl
orb $0x01, %cl
incb %dh
cmpb max_head, %dh
jbe 2f
xorb %dh, %dh
incb %ch
jnc 2f
addb $0xc0, %cl
2:
2007-07-05 13:58:16 +02:00
/* Loop until whole image is read */
2007-07-05 14:30:49 +02:00
subl %eax, load_length
ja 1b
2007-07-05 13:58:16 +02:00
ljmp $BOOT_SEG, $start_image
2007-07-05 14:30:49 +02:00
max_sector:
.byte 0
max_head:
.byte 0
load_length:
.long _load_size_sect
.section ".zinfo.fixup", "a" /* Compressor fixup information */
.ascii "SUBL"
.long load_length
.long 512
.long 0
.previous
2007-07-05 14:30:49 +02:00
2007-07-05 13:58:16 +02:00
load_failed:
movw $10f, %si
jmp boot_error
10: .asciz "Could not load gPXE\r\n"
.org 510
.byte 0x55, 0xaa
start_image:
call install
/* Set up real-mode stack */
movw %bx, %ss
movw $_estack16, %sp
/* Jump to .text16 segment */
pushw %ax
pushw $1f
lret
.section ".text16", "awx", @progbits
1:
pushl $main
pushw %cs
call prot_call
popl %eax /* discard */
/* Boot next device */
int $0x18