1FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) 2 3#include <librm.h> 4 5 .text 6 .arch i386 7 .section ".prefix", "awx", @progbits 8 .code16 9 .org 0 10 .globl _hd_start 11_hd_start: 12 13 movw $load_image, %bp 14 jmp find_active_partition 15 16#include "bootpart.S" 17 18load_image: 19 /* Get disk geometry */ 20 pushal 21 pushw %es 22 movb $0x08, %ah 23 int $0x13 24 jc load_failed 25 movb %cl, max_sector 26 movb %dh, max_head 27 popw %es 28 popal 29 301: /* Read to end of current track (or end of image) */ 31 movb %cl, %al 32 negb %al 33 addb max_sector, %al 34 incb %al 35 andb $0x3f, %al 36 movzbl %al, %eax 37 movl load_length, %ebx 38 cmpl %eax, %ebx 39 ja 2f 40 movl %ebx, %eax 412: call *read_sectors 42 jc load_failed 43 44 /* Update %es */ 45 movw %es, %bx 46 shll $5, %eax 47 addw %ax, %bx 48 movw %bx, %es 49 shrl $5, %eax 50 51 /* Update LBA address */ 52 addl %eax, %edi 53 adcl $0, %esi 54 55 /* Update CHS address */ 56 andb $0xc0, %cl 57 orb $0x01, %cl 58 incb %dh 59 cmpb max_head, %dh 60 jbe 3f 61 xorb %dh, %dh 62 incb %ch 63 jnc 3f 64 addb $0xc0, %cl 653: 66 /* Loop until whole image is read */ 67 subl %eax, load_length 68 ja 1b 69 ljmp $BOOT_SEG, $start_image 70 71max_sector: 72 .byte 0 73max_head: 74 .byte 0 75load_length: 76 .long 0 77 78 .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */ 79 .ascii "ADDL" 80 .long load_length 81 .long 512 82 .long 0 83 .previous 84 85 86load_failed: 87 movw $10f, %si 88 jmp boot_error 8910: .asciz "Could not load iPXE\r\n" 90 91 .org 510 92 .byte 0x55, 0xaa 93 94start_image: 95 /* Install iPXE */ 96 call install 97 98 /* Set up real-mode stack */ 99 movw %bx, %ss 100 movw $_estack16, %sp 101 102 /* Jump to .text16 segment */ 103 pushw %ax 104 pushw $1f 105 lret 106 .section ".text16", "awx", @progbits 1071: 108 /* Run iPXE */ 109 virtcall main 110 111 /* Uninstall iPXE */ 112 call uninstall 113 114 /* Boot next device */ 115 int $0x18 116