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

« back to all changes in this revision

Viewing changes to roms/ipxe/src/arch/x86/interface/pxe/pxe_entry.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
/*
 
2
 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; either version 2 of the
 
7
 * License, or any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
 * 02110-1301, USA.
 
18
 *
 
19
 * You can also choose to distribute this program under the terms of
 
20
 * the Unmodified Binary Distribution Licence (as given in the file
 
21
 * COPYING.UBDL), provided that you have satisfied its requirements.
 
22
 *
 
23
 */
 
24
 
 
25
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
 
26
 
 
27
#include <librm.h>
 
28
 
 
29
        .arch i386
 
30
 
 
31
/****************************************************************************
 
32
 * !PXE structure
 
33
 ****************************************************************************
 
34
 */
 
35
        .section ".text16.data", "aw", @progbits
 
36
        .globl ppxe
 
37
        .align 16
 
38
ppxe:
 
39
        .ascii "!PXE"                   /* Signature */
 
40
        .byte pxe_length                /* StructLength */
 
41
        .byte 0                         /* StructCksum */
 
42
        .byte 0                         /* StructRev */
 
43
        .byte 0                         /* reserved_1 */
 
44
        .word undiheader, 0             /* UNDIROMID */
 
45
        .word 0, 0                      /* BaseROMID */
 
46
        .word pxe_entry_sp, 0           /* EntryPointSP */
 
47
        .word pxe_entry_esp, 0          /* EntryPointESP */
 
48
        .word -1, -1                    /* StatusCallout */
 
49
        .byte 0                         /* reserved_2 */
 
50
        .byte SegDescCnt                /* SegDescCnt */
 
51
        .word 0                         /* FirstSelector */
 
52
pxe_segments:
 
53
        .word 0, 0, 0, _data16_memsz    /* Stack */
 
54
        .word 0, 0, 0, _data16_memsz    /* UNDIData */
 
55
        .word 0, 0, 0, _text16_memsz    /* UNDICode */
 
56
        .word 0, 0, 0, _text16_memsz    /* UNDICodeWrite */
 
57
        .word 0, 0, 0, 0                /* BC_Data */
 
58
        .word 0, 0, 0, 0                /* BC_Code */
 
59
        .word 0, 0, 0, 0                /* BC_CodeWrite */
 
60
        .equ    SegDescCnt, ( ( . - pxe_segments ) / 8 )
 
61
        .equ    pxe_length, . - ppxe
 
62
        .size   ppxe, . - ppxe
 
63
 
 
64
        /* Define undiheader=0 as a weak symbol for non-ROM builds */
 
65
        .section ".weak", "a", @nobits
 
66
        .weak   undiheader
 
67
undiheader:
 
68
 
 
69
/****************************************************************************
 
70
 * PXENV+ structure
 
71
 ****************************************************************************
 
72
 */
 
73
        .section ".text16.data", "aw", @progbits
 
74
        .globl pxenv
 
75
        .align 16
 
76
pxenv:
 
77
        .ascii "PXENV+"                 /* Signature */
 
78
        .word 0x0201                    /* Version */
 
79
        .byte pxenv_length              /* Length */
 
80
        .byte 0                         /* Checksum */
 
81
        .word pxenv_entry, 0            /* RMEntry */
 
82
        .long 0                         /* PMEntry */
 
83
        .word 0                         /* PMSelector */
 
84
        .word 0                         /* StackSeg */
 
85
        .word _data16_memsz             /* StackSize */
 
86
        .word 0                         /* BC_CodeSeg */
 
87
        .word 0                         /* BC_CodeSize */
 
88
        .word 0                         /* BC_DataSeg */
 
89
        .word 0                         /* BC_DataSize */
 
90
        .word 0                         /* UNDIDataSeg */
 
91
        .word _data16_memsz             /* UNDIDataSize */
 
92
        .word 0                         /* UNDICodeSeg */
 
93
        .word _text16_memsz             /* UNDICodeSize */
 
94
        .word ppxe, 0                   /* PXEPtr */
 
95
        .equ    pxenv_length, . - pxenv
 
96
        .size   pxenv, . - pxenv
 
97
 
 
98
/****************************************************************************
 
99
 * pxenv_entry (16-bit far call)
 
100
 *
 
101
 * PXE API call PXENV+ entry point
 
102
 *
 
103
 * Parameters:
 
104
 *   %es:di : Far pointer to PXE parameter structure
 
105
 *   %bx : PXE API call
 
106
 * Returns:
 
107
 *   %ax : PXE exit status
 
108
 * Corrupts:
 
109
 *   none
 
110
 ****************************************************************************
 
111
 */
 
112
        /* Wyse Streaming Manager server (WLDRM13.BIN) assumes that
 
113
         * the PXENV+ entry point is at UNDI_CS:0000; apparently,
 
114
         * somebody at Wyse has difficulty distinguishing between the
 
115
         * words "may" and "must"...
 
116
         */
 
117
        .section ".text16.null", "ax", @progbits
 
118
        .code16
 
119
pxenv_null_entry:
 
120
        jmp     pxenv_entry
 
121
 
 
122
        .section ".text16", "ax", @progbits
 
123
        .code16
 
124
pxenv_entry:
 
125
        virtcall pxe_api_call
 
126
        lret
 
127
        .size   pxenv_entry, . - pxenv_entry
 
128
 
 
129
/****************************************************************************
 
130
 * pxe_entry
 
131
 *
 
132
 * PXE API call !PXE entry point
 
133
 *
 
134
 * Parameters:
 
135
 *   stack : Far pointer to PXE parameter structure
 
136
 *   stack : PXE API call
 
137
 * Returns:
 
138
 *   %ax : PXE exit status
 
139
 * Corrupts:
 
140
 *   none
 
141
 ****************************************************************************
 
142
 */
 
143
        .section ".text16", "ax", @progbits
 
144
        .code16
 
145
pxe_entry:
 
146
pxe_entry_sp:
 
147
        /* Preserve original %esp */
 
148
        pushl   %esp
 
149
        /* Zero high word of %esp to allow use of common code */
 
150
        movzwl  %sp, %esp
 
151
        jmp     pxe_entry_common
 
152
pxe_entry_esp:
 
153
        /* Preserve %esp to match behaviour of pxe_entry_sp */
 
154
        pushl   %esp
 
155
pxe_entry_common:
 
156
        /* Save PXENV+ API call registers */
 
157
        pushw   %es
 
158
        pushw   %di
 
159
        pushw   %bx
 
160
        /* Load !PXE parameters from stack into PXENV+ registers */
 
161
        addr32 movw     18(%esp), %bx
 
162
        movw    %bx, %es
 
163
        addr32 movw     16(%esp), %di
 
164
        addr32 movw     14(%esp), %bx
 
165
        /* Make call as for PXENV+ */
 
166
        pushw   %cs
 
167
        call    pxenv_entry
 
168
        /* Restore PXENV+ registers */
 
169
        popw    %bx
 
170
        popw    %di
 
171
        popw    %es
 
172
        /* Restore original %esp and return */
 
173
        popl    %esp
 
174
        lret
 
175
        .size   pxe_entry, . - pxe_entry
 
176
 
 
177
/****************************************************************************
 
178
 * pxe_int_1a
 
179
 *
 
180
 * PXE INT 1A handler
 
181
 *
 
182
 * Parameters:
 
183
 *   %ax : 0x5650
 
184
 * Returns:
 
185
 *   %ax : 0x564e
 
186
 *   %es:bx : Far pointer to the PXENV+ structure
 
187
 *   %edx : Physical address of the PXENV+ structure
 
188
 *   CF cleared
 
189
 * Corrupts:
 
190
 *   none
 
191
 ****************************************************************************
 
192
 */
 
193
        .section ".text16", "ax", @progbits
 
194
        .code16
 
195
        .globl  pxe_int_1a
 
196
pxe_int_1a:
 
197
        pushfw
 
198
        cmpw    $0x5650, %ax
 
199
        jne     1f
 
200
        /* INT 1A,5650 - PXE installation check */
 
201
        xorl    %edx, %edx
 
202
        movw    %cs, %dx
 
203
        movw    %dx, %es
 
204
        movw    $pxenv, %bx
 
205
        shll    $4, %edx
 
206
        addl    $pxenv, %edx
 
207
        movw    $0x564e, %ax
 
208
        pushw   %bp
 
209
        movw    %sp, %bp
 
210
        andb    $~0x01, 8(%bp)  /* Clear CF on return */
 
211
        popw    %bp
 
212
        popfw
 
213
        iret
 
214
1:      /* INT 1A,other - pass through */
 
215
        popfw
 
216
        ljmp    *%cs:pxe_int_1a_vector
 
217
 
 
218
        .section ".text16.data", "aw", @progbits
 
219
        .globl  pxe_int_1a_vector
 
220
pxe_int_1a_vector:      .long 0