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