~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/arch/x86/prefix/hdprefix.S

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
FILE_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
 
 
18
load_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
        
 
30
1:      /* Read to end of current track */
 
31
        movb    %cl, %al
 
32
        negb    %al
 
33
        addb    max_sector, %al
 
34
        incb    %al
 
35
        andb    $0x3f, %al
 
36
        movzbl  %al, %eax
 
37
        call    *read_sectors
 
38
        jc      load_failed
 
39
        
 
40
        /* Update %es */
 
41
        movw    %es, %bx
 
42
        shll    $5, %eax
 
43
        addw    %ax, %bx
 
44
        movw    %bx, %es
 
45
        shrl    $5, %eax
 
46
        
 
47
        /* Update LBA address */
 
48
        addl    %eax, %edi
 
49
        adcl    $0, %esi
 
50
        
 
51
        /* Update CHS address */
 
52
        andb    $0xc0, %cl
 
53
        orb     $0x01, %cl
 
54
        incb    %dh
 
55
        cmpb    max_head, %dh
 
56
        jbe     2f
 
57
        xorb    %dh, %dh
 
58
        incb    %ch
 
59
        jnc     2f
 
60
        addb    $0xc0, %cl
 
61
2:
 
62
        /* Loop until whole image is read */
 
63
        subl    %eax, load_length
 
64
        ja      1b
 
65
        ljmp    $BOOT_SEG, $start_image
 
66
 
 
67
max_sector:
 
68
        .byte   0
 
69
max_head:
 
70
        .byte   0
 
71
load_length:
 
72
        .long   0
 
73
        
 
74
        .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
 
75
        .ascii  "ADDL"
 
76
        .long   load_length
 
77
        .long   512
 
78
        .long   0
 
79
        .previous
 
80
 
 
81
 
 
82
load_failed:
 
83
        movw    $10f, %si
 
84
        jmp     boot_error
 
85
10:     .asciz  "Could not load iPXE\r\n"
 
86
 
 
87
        .org 510
 
88
        .byte 0x55, 0xaa
 
89
 
 
90
start_image:
 
91
        /* Install iPXE */
 
92
        call    install
 
93
 
 
94
        /* Set up real-mode stack */
 
95
        movw    %bx, %ss
 
96
        movw    $_estack16, %sp
 
97
 
 
98
        /* Jump to .text16 segment */
 
99
        pushw   %ax
 
100
        pushw   $1f
 
101
        lret
 
102
        .section ".text16", "awx", @progbits
 
103
1:
 
104
        /* Run iPXE */
 
105
        virtcall main
 
106
 
 
107
        /* Uninstall iPXE */
 
108
        call    uninstall
 
109
 
 
110
        /* Boot next device */
 
111
        int $0x18