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 )
29
/* Initial temporary stack size */
30
#define EXE_STACK_SIZE 0x400
32
/* Temporary decompression area (avoid DOS high memory area) */
33
#define EXE_DECOMPRESS_ADDRESS 0x110000
35
/* Fields within the Program Segment Prefix */
36
#define PSP_CMDLINE_LEN 0x80
37
#define PSP_CMDLINE_START 0x81
43
.section ".prefix", "awx", @progbits
50
/* Number of bytes in last block that are really used */
54
/* Number of 512-byte blocks */
56
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
64
/* Number of relocation entries stored after the header */
68
/* Number of paragraphs in the header */
69
.word ( ( _exe_start - signature ) / 16 )
72
/* Minimum number of paragraphs of additional (BSS) memory */
73
.word ( EXE_STACK_SIZE / 16 )
76
/* Maximum number of paragraphs of additional (BSS) memory */
77
.word ( EXE_STACK_SIZE / 16 )
80
/* Initial stack segment (relative to start of executable) */
81
.word -( ( _exe_start - signature ) / 16 )
82
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
90
/* Initial stack pointer */
94
/* Checksum (ignored) */
98
/* Initial instruction pointer */
102
/* Initial code segment (relative to start of executable) */
103
.word -( ( _exe_start - signature ) / 16 )
106
/* Relocation table offset */
117
/* Install iPXE. Use a fixed temporary decompression area to
118
* avoid trashing the DOS high memory area.
122
movl $EXE_DECOMPRESS_ADDRESS, %edi
123
orl $0xffffffff, %ebp /* Allow arbitrary relocation */
124
call install_prealloc
126
/* Set up real-mode stack */
130
/* Jump to .text16 segment */
134
.section ".text16", "awx", @progbits
136
/* Terminate command line with a NUL */
137
movzbw PSP_CMDLINE_LEN, %si
138
movb $0, PSP_CMDLINE_START(%si)
140
/* Calculate command line physical address */
144
addl $PSP_CMDLINE_START, %esi
146
/* Set up %ds for access to .data16 */
149
/* Record command line address */
150
movl %esi, cmdline_phys
158
/* Exit back to DOS. This is very unlikely to work */