These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / i386 / interface / pxe / pxe_entry.S
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         .arch i386
28
29 /****************************************************************************
30  * !PXE structure
31  ****************************************************************************
32  */
33         .section ".text16.data", "aw", @progbits
34         .globl ppxe
35         .align 16
36 ppxe:
37         .ascii "!PXE"                   /* Signature */
38         .byte pxe_length                /* StructLength */
39         .byte 0                         /* StructCksum */
40         .byte 0                         /* StructRev */
41         .byte 0                         /* reserved_1 */
42         .word undiheader, 0             /* UNDIROMID */
43         .word 0, 0                      /* BaseROMID */
44         .word pxe_entry_sp, 0           /* EntryPointSP */
45         .word pxe_entry_esp, 0          /* EntryPointESP */
46         .word -1, -1                    /* StatusCallout */
47         .byte 0                         /* reserved_2 */
48         .byte SegDescCnt                /* SegDescCnt */
49         .word 0                         /* FirstSelector */
50 pxe_segments:
51         .word 0, 0, 0, _data16_memsz    /* Stack */
52         .word 0, 0, 0, _data16_memsz    /* UNDIData */
53         .word 0, 0, 0, _text16_memsz    /* UNDICode */
54         .word 0, 0, 0, _text16_memsz    /* UNDICodeWrite */
55         .word 0, 0, 0, 0                /* BC_Data */
56         .word 0, 0, 0, 0                /* BC_Code */
57         .word 0, 0, 0, 0                /* BC_CodeWrite */
58         .equ    SegDescCnt, ( ( . - pxe_segments ) / 8 )
59         .equ    pxe_length, . - ppxe
60         .size   ppxe, . - ppxe
61
62         /* Define undiheader=0 as a weak symbol for non-ROM builds */
63         .section ".weak", "a", @nobits
64         .weak   undiheader
65 undiheader:
66
67 /****************************************************************************
68  * PXENV+ structure
69  ****************************************************************************
70  */
71         .section ".text16.data", "aw", @progbits
72         .globl pxenv
73         .align 16
74 pxenv:
75         .ascii "PXENV+"                 /* Signature */
76         .word 0x0201                    /* Version */
77         .byte pxenv_length              /* Length */
78         .byte 0                         /* Checksum */
79         .word pxenv_entry, 0            /* RMEntry */
80         .long 0                         /* PMEntry */
81         .word 0                         /* PMSelector */
82         .word 0                         /* StackSeg */
83         .word _data16_memsz             /* StackSize */
84         .word 0                         /* BC_CodeSeg */
85         .word 0                         /* BC_CodeSize */
86         .word 0                         /* BC_DataSeg */
87         .word 0                         /* BC_DataSize */
88         .word 0                         /* UNDIDataSeg */
89         .word _data16_memsz             /* UNDIDataSize */
90         .word 0                         /* UNDICodeSeg */
91         .word _text16_memsz             /* UNDICodeSize */
92         .word ppxe, 0                   /* PXEPtr */
93         .equ    pxenv_length, . - pxenv
94         .size   pxenv, . - pxenv
95  
96 /****************************************************************************
97  * pxenv_entry (16-bit far call)
98  *
99  * PXE API call PXENV+ entry point
100  *
101  * Parameters:
102  *   %es:di : Far pointer to PXE parameter structure
103  *   %bx : PXE API call
104  * Returns:
105  *   %ax : PXE exit status
106  * Corrupts:
107  *   none
108  ****************************************************************************
109  */
110         /* Wyse Streaming Manager server (WLDRM13.BIN) assumes that
111          * the PXENV+ entry point is at UNDI_CS:0000; apparently,
112          * somebody at Wyse has difficulty distinguishing between the
113          * words "may" and "must"...
114          */
115         .section ".text16.null", "ax", @progbits
116         .code16
117 pxenv_null_entry:
118         jmp     pxenv_entry
119
120         .section ".text16", "ax", @progbits
121         .code16
122 pxenv_entry:
123         pushl   $pxe_api_call
124         pushw   %cs
125         call    prot_call
126         addl    $4, %esp
127         lret
128         .size   pxenv_entry, . - pxenv_entry
129
130 /****************************************************************************
131  * pxe_entry
132  *
133  * PXE API call !PXE entry point
134  *
135  * Parameters:
136  *   stack : Far pointer to PXE parameter structure
137  *   stack : PXE API call
138  * Returns:
139  *   %ax : PXE exit status
140  * Corrupts:
141  *   none
142  ****************************************************************************
143  */
144         .section ".text16", "ax", @progbits
145         .code16
146 pxe_entry:
147 pxe_entry_sp:
148         /* Preserve original %esp */
149         pushl   %esp
150         /* Zero high word of %esp to allow use of common code */
151         movzwl  %sp, %esp
152         jmp     pxe_entry_common
153 pxe_entry_esp:
154         /* Preserve %esp to match behaviour of pxe_entry_sp */
155         pushl   %esp
156 pxe_entry_common:
157         /* Save PXENV+ API call registers */
158         pushw   %es
159         pushw   %di
160         pushw   %bx
161         /* Load !PXE parameters from stack into PXENV+ registers */
162         addr32 movw     18(%esp), %bx
163         movw    %bx, %es
164         addr32 movw     16(%esp), %di
165         addr32 movw     14(%esp), %bx
166         /* Make call as for PXENV+ */
167         pushw   %cs
168         call    pxenv_entry
169         /* Restore PXENV+ registers */
170         popw    %bx
171         popw    %di
172         popw    %es
173         /* Restore original %esp and return */
174         popl    %esp
175         lret
176         .size   pxe_entry, . - pxe_entry
177
178 /****************************************************************************
179  * pxe_int_1a
180  *
181  * PXE INT 1A handler
182  *
183  * Parameters:
184  *   %ax : 0x5650
185  * Returns:
186  *   %ax : 0x564e
187  *   %es:bx : Far pointer to the PXENV+ structure
188  *   %edx : Physical address of the PXENV+ structure
189  *   CF cleared
190  * Corrupts:
191  *   none
192  ****************************************************************************
193  */
194         .section ".text16", "ax", @progbits
195         .code16
196         .globl  pxe_int_1a
197 pxe_int_1a:
198         pushfw
199         cmpw    $0x5650, %ax
200         jne     1f
201         /* INT 1A,5650 - PXE installation check */
202         xorl    %edx, %edx
203         movw    %cs, %dx
204         movw    %dx, %es
205         movw    $pxenv, %bx
206         shll    $4, %edx
207         addl    $pxenv, %edx
208         movw    $0x564e, %ax
209         pushw   %bp
210         movw    %sp, %bp
211         andb    $~0x01, 8(%bp)  /* Clear CF on return */
212         popw    %bp
213         popfw
214         iret
215 1:      /* INT 1A,other - pass through */
216         popfw
217         ljmp    *%cs:pxe_int_1a_vector
218
219         .section ".text16.data", "aw", @progbits
220         .globl  pxe_int_1a_vector
221 pxe_int_1a_vector:      .long 0