[ipxe-devel] [PATCH] [undi] Add stack segment logging

Ladi Prosek lprosek at redhat.com
Thu Jun 9 10:46:14 UTC 2016


The UNDI ROM ID structure declares the minimum required stack segment
size but the value is not used by iPXE.

This commit adds stack-related logging to undirom_parse_pxeromid and
undi_load to help with UNDI debugging.

Signed-off-by: Ladi Prosek <lprosek at redhat.com>
---
Ideally undi_load would fail if we don't have enough real mode stack to
satisfy the ROM requirements. It is possible that the declared minimums
are exaggerated or flatout wrong, though, so I'm only adding logging for
now. The logging could be unconditional or it could be regular console
output instead of DBG. Please advise, I am open to suggestions.
Thanks!

 src/arch/x86/drivers/net/undiload.c | 8 ++++++--
 src/arch/x86/drivers/net/undirom.c  | 5 +++--
 src/arch/x86/include/undirom.h      | 2 ++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/arch/x86/drivers/net/undiload.c b/src/arch/x86/drivers/net/undiload.c
index 7160ee3..74a1129 100644
--- a/src/arch/x86/drivers/net/undiload.c
+++ b/src/arch/x86/drivers/net/undiload.c
@@ -92,8 +92,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
 	undi_loader.UNDI_DS = fbms_seg;
 
 	/* Debug info */
-	DBGC ( undi, "UNDI %p loading UNDI ROM %p to CS %04x DS %04x for ",
-	       undi, undirom, undi_loader.UNDI_CS, undi_loader.UNDI_DS );
+	DBGC ( undi, "UNDI %p loading UNDI ROM %p to CS %04x DS %04x SS %04x for ",
+	       undi, undirom, undi_loader.UNDI_CS, undi_loader.UNDI_DS, rm_ss );
 	if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
 		unsigned int bus = ( undi->pci_busdevfn >> 8 );
 		unsigned int devfn = ( undi->pci_busdevfn & 0xff );
@@ -104,6 +104,10 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
 		DBGC ( undi, "ISAPnP(%04x) CSN %04x\n",
 		       undi->isapnp_read_port, undi->isapnp_csn );
 	}
+	if ( rm_sp < undirom->stack_size ) {
+		DBGC ( undi, "UNDI %p stack required %04x, stack available %04x\n",
+		       undi, undirom->stack_size, rm_sp );
+	}
 
 	/* Call loader */
 	undi_loader_entry = undirom->loader_entry;
diff --git a/src/arch/x86/drivers/net/undirom.c b/src/arch/x86/drivers/net/undirom.c
index b54c617..8df5688 100644
--- a/src/arch/x86/drivers/net/undirom.c
+++ b/src/arch/x86/drivers/net/undirom.c
@@ -71,11 +71,12 @@ static int undirom_parse_pxeromid ( struct undi_rom *undirom,
 	undirom->loader_entry.offset = undiloader;
 	undirom->code_size = undi_rom_id.CodeSize;
 	undirom->data_size = undi_rom_id.DataSize;
+	undirom->stack_size = undi_rom_id.StackSize;
 
 	DBGC ( undirom, "UNDIROM %p has UNDI loader at %04x:%04x "
-	       "(code %04zx data %04zx)\n", undirom,
+	       "(code %04zx data %04zx stack %04zx)\n", undirom,
 	       undirom->loader_entry.segment, undirom->loader_entry.offset,
-	       undirom->code_size, undirom->data_size );
+	       undirom->code_size, undirom->data_size, undirom->stack_size );
 	return 0;
 }
 
diff --git a/src/arch/x86/include/undirom.h b/src/arch/x86/include/undirom.h
index 1c53011..aa95279 100644
--- a/src/arch/x86/include/undirom.h
+++ b/src/arch/x86/include/undirom.h
@@ -37,6 +37,8 @@ struct undi_rom {
 	size_t code_size;
 	/** Data segment size */
 	size_t data_size;
+	/** Stack segment size */
+	size_t stack_size;
 	/** Bus type
 	 *
 	 * Values are as used by @c PXENV_UNDI_GET_NIC_TYPE
-- 
2.5.5




More information about the ipxe-devel mailing list