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