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
21 FILE_LICENCE ( GPL2_OR_LATER )
23 /* Initial temporary stack size */
24 #define EXE_STACK_SIZE 0x400
26 /* Temporary decompression area (avoid DOS high memory area) */
27 #define EXE_DECOMPRESS_ADDRESS 0x110000
29 /* Fields within the Program Segment Prefix */
30 #define PSP_CMDLINE_LEN 0x80
31 #define PSP_CMDLINE_START 0x81
37 .section ".prefix", "awx", @progbits
44 /* Number of bytes in last block that are really used */
48 /* Number of 512-byte blocks */
50 .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
58 /* Number of relocation entries stored after the header */
62 /* Number of paragraphs in the header */
63 .word ( ( _exe_start - signature ) / 16 )
66 /* Minimum number of paragraphs of additional (BSS) memory */
67 .word ( EXE_STACK_SIZE / 16 )
70 /* Maximum number of paragraphs of additional (BSS) memory */
71 .word ( EXE_STACK_SIZE / 16 )
74 /* Initial stack segment (relative to start of executable) */
75 .word -( ( _exe_start - signature ) / 16 )
76 .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
84 /* Initial stack pointer */
88 /* Checksum (ignored) */
92 /* Initial instruction pointer */
96 /* Initial code segment (relative to start of executable) */
97 .word -( ( _exe_start - signature ) / 16 )
100 /* Relocation table offset */
111 /* Install iPXE. Use a fixed temporary decompression area to
112 * avoid trashing the DOS high memory area.
116 movl $EXE_DECOMPRESS_ADDRESS, %edi
117 orl $0xffffffff, %ebp /* Allow arbitrary relocation */
118 call install_prealloc
120 /* Set up real-mode stack */
124 /* Jump to .text16 segment */
128 .section ".text16", "awx", @progbits
130 /* Terminate command line with a NUL */
131 movzbw PSP_CMDLINE_LEN, %si
132 movb $0, PSP_CMDLINE_START(%si)
134 /* Calculate command line physical address */
138 addl $PSP_CMDLINE_START, %esi
140 /* Set up %ds for access to .data16 */
143 /* Record command line address */
144 movl %esi, cmdline_phys
150 popl %ecx /* discard */
155 /* Exit back to DOS. This is very unlikely to work */