2 * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
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.
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.
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
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.
25 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
27 /* Initial temporary stack size */
28 #define EXE_STACK_SIZE 0x400
30 /* Temporary decompression area (avoid DOS high memory area) */
31 #define EXE_DECOMPRESS_ADDRESS 0x110000
33 /* Fields within the Program Segment Prefix */
34 #define PSP_CMDLINE_LEN 0x80
35 #define PSP_CMDLINE_START 0x81
41 .section ".prefix", "awx", @progbits
48 /* Number of bytes in last block that are really used */
52 /* Number of 512-byte blocks */
54 .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
62 /* Number of relocation entries stored after the header */
66 /* Number of paragraphs in the header */
67 .word ( ( _exe_start - signature ) / 16 )
70 /* Minimum number of paragraphs of additional (BSS) memory */
71 .word ( EXE_STACK_SIZE / 16 )
74 /* Maximum number of paragraphs of additional (BSS) memory */
75 .word ( EXE_STACK_SIZE / 16 )
78 /* Initial stack segment (relative to start of executable) */
79 .word -( ( _exe_start - signature ) / 16 )
80 .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
88 /* Initial stack pointer */
92 /* Checksum (ignored) */
96 /* Initial instruction pointer */
100 /* Initial code segment (relative to start of executable) */
101 .word -( ( _exe_start - signature ) / 16 )
104 /* Relocation table offset */
115 /* Install iPXE. Use a fixed temporary decompression area to
116 * avoid trashing the DOS high memory area.
120 movl $EXE_DECOMPRESS_ADDRESS, %edi
121 orl $0xffffffff, %ebp /* Allow arbitrary relocation */
122 call install_prealloc
124 /* Set up real-mode stack */
128 /* Jump to .text16 segment */
132 .section ".text16", "awx", @progbits
134 /* Terminate command line with a NUL */
135 movzbw PSP_CMDLINE_LEN, %si
136 movb $0, PSP_CMDLINE_START(%si)
138 /* Calculate command line physical address */
142 addl $PSP_CMDLINE_START, %esi
144 /* Set up %ds for access to .data16 */
147 /* Record command line address */
148 movl %esi, cmdline_phys
154 popl %ecx /* discard */
159 /* Exit back to DOS. This is very unlikely to work */