/**
* Relocate iPXE
*
- * @v ix86 x86 register dump from prefix
- * @ret ix86 x86 registers to return to prefix
+ * @v ebp Maximum address to use for relocation
+ * @ret esi Current physical address
+ * @ret edi New physical address
+ * @ret ecx Length to copy
*
* This finds a suitable location for iPXE near the top of 32-bit
* address space, and returns the physical address of the new location
/* Determine maximum usable address */
max = MAX_ADDR;
- if ( ix86->regs.ebp && ( ix86->regs.ebp < max ) ) {
+ if ( ix86->regs.ebp < max ) {
max = ix86->regs.ebp;
DBG ( "Limiting relocation to [0,%lx)\n", max );
}
static struct e820_entry __bss16 ( e820buf );
#define e820buf __use_data16 ( e820buf )
+/** We are running during POST; inhibit INT 15,e820 and INT 15,e801 */
+uint8_t __bss16 ( memmap_post );
+#define memmap_post __use_data16 ( memmap_post )
+
/**
* Get size of extended memory via INT 15,e801
*
unsigned int flags;
unsigned int extmem;
+ /* Inhibit INT 15,e801 during POST */
+ if ( memmap_post ) {
+ DBG ( "INT 15,e801 not available during POST\n" );
+ return 0;
+ }
+
__asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
"int $0x15\n\t"
"pushfw\n\t"
unsigned int flags;
unsigned int discard_D;
+ /* Inhibit INT 15,e820 during POST */
+ if ( memmap_post ) {
+ DBG ( "INT 15,e820 not available during POST\n" );
+ return -ENOTTY;
+ }
+
/* Clear the E820 buffer. Do this once before starting,
* rather than on each call; some BIOSes rely on the contents
* being preserved between calls.
call alloc_basemem
xorl %esi, %esi
movl $EXE_DECOMPRESS_ADDRESS, %edi
- xorl %ebp, %ebp
+ orl $0xffffffff, %ebp /* Allow arbitrary relocation */
call install_prealloc
/* Set up real-mode stack */
/* Image destination = default */
xorl %edi, %edi
/* Allow arbitrary relocation */
- xorl %ebp, %ebp
+ orl $0xffffffff, %ebp
/* Install text and data segments */
call install_prealloc
/* Restore registers and return */
* %bx : .data16 segment address
* %esi : Image source physical address (or zero for %cs:0000)
* %edi : Decompression temporary area physical address (or zero for default)
- * %ebp : Maximum end address for relocation (or zero for no maximum)
+ * %ebp : Maximum end address for relocation
+ * - 0xffffffff for no maximum
+ * - 0x00000000 to inhibit use of INT 15,e820 and INT 15,e801
* Corrupts:
* none
****************************************************************************
movw %ax, (init_librm_vector+2)
lcall *init_librm_vector
+ /* Inhibit INT 15,e820 and INT 15,e801 if applicable */
+ testl %ebp, %ebp
+ jnz 1f
+ incb memmap_post
+ decl %ebp
+1:
+
/* Call relocate() to determine target address for relocation.
* relocate() will return with %esi, %edi and %ecx set up
* ready for the copy to the new location.
* picked up by the initial shell prompt, and we will drop
* into a shell.
*/
- movl $0xa0000, %ebp /* Inhibit relocation during POST */
+ xorl %ebp, %ebp /* Inhibit use of INT 15,e820 and INT 15,e801 */
pushw %cs
call exec
2:
* Called by the PnP BIOS when it wants to boot us.
*/
bev_entry:
- xorl %ebp, %ebp /* Allow relocation */
+ orl $0xffffffff, %ebp /* Allow arbitrary relocation */
pushw %cs
call exec
lret
/* Leave keypress in buffer and start iPXE. The keypress will
* cause the usual initial Ctrl-B prompt to be skipped.
*/
- xorl %ebp, %ebp /* Allow relocation */
+ orl $0xffffffff, %ebp /* Allow arbitrary relocation */
pushw %cs
call exec
1: /* Try to call original INT 19 vector */
movw %es:14(%di), %ax
movl image_source, %esi
movl decompress_to, %edi
- xorl %ebp, %ebp /* Allow relocation */
+ orl $0xffffffff, %ebp /* Allow arbitrary relocation */
call install_prealloc
popw %di
/* Call UNDI loader C code */