summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/drivers/net/undinet.c
diff options
context:
space:
mode:
authorMichael Brown2008-10-27 02:06:00 +0100
committerMichael Brown2009-02-18 19:12:32 +0100
commitb5577553e59391653f47b9edb12775c080665db0 (patch)
treed824146681cbb12132831358f494b9803bad1d48 /src/arch/i386/drivers/net/undinet.c
parent[i386] Kill off obsolete boot1a.s file (diff)
downloadipxe-b5577553e59391653f47b9edb12775c080665db0.tar.gz
ipxe-b5577553e59391653f47b9edb12775c080665db0.tar.xz
ipxe-b5577553e59391653f47b9edb12775c080665db0.zip
[pxeprefix] Add .kkpxe image type and ability to return via PXE stack
Certain combinations of PXE stack and BIOS result in a broken INT 18 call, which will leave the system displaying a "PRESS ANY KEY TO REBOOT" message instead of proceeding to the next boot device. On these systems, returning via the PXE stack is the only way to continue to the next boot device. Returning via the PXE stack works only if we haven't already blown away the PXE base code in pxeprefix.S. In most circumstances, we do want to blow away the PXE base code. Base memory is a limited resource, and it is desirable to reclaim as much as possible. When we perform an iSCSI boot, we need to place the iBFT above the 512kB mark, because otherwise it may not be detected by the loaded OS; this may not be possible if the PXE base code is still occupying that memory. Introduce a new prefix type .kkpxe which will preserve both the PXE base code and the UNDI driver (as compared to .kpxe, which preserves the UNDI driver but uninstalls the PXE base code). This prefix type can be used on systems that are known to experience the specific problem of INT 18 being broken, or in builds (such as gpxelinux.0) for which it is particularly important to know that returning to the BIOS will work. Written by H. Peter Anvin <hpa@zytor.com> and Stefan Hajnoczi <stefanha@gmail.com>, minor structural alterations by Michael Brown <mcb30@etherboot.org>.
Diffstat (limited to 'src/arch/i386/drivers/net/undinet.c')
-rw-r--r--src/arch/i386/drivers/net/undinet.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/arch/i386/drivers/net/undinet.c b/src/arch/i386/drivers/net/undinet.c
index 7ebfd3c4..d6db6f7c 100644
--- a/src/arch/i386/drivers/net/undinet.c
+++ b/src/arch/i386/drivers/net/undinet.c
@@ -669,15 +669,19 @@ int undinet_probe ( struct undi_device *undi ) {
undi->flags |= UNDI_FL_STARTED;
/* Bring up UNDI stack */
- memset ( &undi_startup, 0, sizeof ( undi_startup ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP, &undi_startup,
- sizeof ( undi_startup ) ) ) != 0 )
- goto err_undi_startup;
- memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
- &undi_initialize,
- sizeof ( undi_initialize ) ) ) != 0 )
- goto err_undi_initialize;
+ if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
+ memset ( &undi_startup, 0, sizeof ( undi_startup ) );
+ if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP,
+ &undi_startup,
+ sizeof ( undi_startup ) ) ) != 0 )
+ goto err_undi_startup;
+ memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
+ if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
+ &undi_initialize,
+ sizeof ( undi_initialize ))) != 0 )
+ goto err_undi_initialize;
+ }
+ undi->flags |= UNDI_FL_INITIALIZED;
/* Get device information */
memset ( &undi_info, 0, sizeof ( undi_info ) );
@@ -731,11 +735,13 @@ int undinet_probe ( struct undi_device *undi ) {
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
sizeof ( undi_cleanup ) );
+ undi->flags &= ~UNDI_FL_INITIALIZED;
err_undi_startup:
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
sizeof ( stop_undi ) );
+ undi->flags &= ~UNDI_FL_STARTED;
err_start_undi:
netdev_nullify ( netdev );
netdev_put ( netdev );
@@ -758,19 +764,26 @@ void undinet_remove ( struct undi_device *undi ) {
/* Unregister net device */
unregister_netdev ( netdev );
- /* Shut down UNDI stack */
- memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
- undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
- sizeof ( undi_shutdown ) );
- memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
- undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
- sizeof ( undi_cleanup ) );
-
- /* Unhook UNDI stack */
- memset ( &stop_undi, 0, sizeof ( stop_undi ) );
- undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
- sizeof ( stop_undi ) );
- undi->flags &= ~UNDI_FL_STARTED;
+ /* If we are preparing for an OS boot, or if we cannot exit
+ * via the PXE stack, then shut down the PXE stack.
+ */
+ if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
+
+ /* Shut down UNDI stack */
+ memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
+ undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
+ sizeof ( undi_shutdown ) );
+ memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
+ undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
+ sizeof ( undi_cleanup ) );
+ undi->flags &= ~UNDI_FL_INITIALIZED;
+
+ /* Unhook UNDI stack */
+ memset ( &stop_undi, 0, sizeof ( stop_undi ) );
+ undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
+ sizeof ( stop_undi ) );
+ undi->flags &= ~UNDI_FL_STARTED;
+ }
/* Clear entry point */
memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );