summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2000-04-20 00:06:15 +0000
committerps <ps@FreeBSD.org>2000-04-20 00:06:15 +0000
commit4422f2d83bb4ca051d794f962ed3fdebf99fcddb (patch)
treec0e175580c51dd8f88fefc4346bdb40d530d84f6
parentb86f59222971ce8e1ded778420f9d916dd650e5a (diff)
downloadFreeBSD-src-4422f2d83bb4ca051d794f962ed3fdebf99fcddb.zip
FreeBSD-src-4422f2d83bb4ca051d794f962ed3fdebf99fcddb.tar.gz
Add a cleanup function. This is needed for PXE where you should
shutdown the UNDI and unload the stack.
-rw-r--r--lib/libstand/stand.h1
-rw-r--r--sys/boot/common/boot.c6
-rw-r--r--sys/boot/i386/libi386/pxe.c16
-rw-r--r--sys/boot/i386/loader/main.c5
4 files changed, 21 insertions, 7 deletions
diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h
index ba54885..23626a5 100644
--- a/lib/libstand/stand.h
+++ b/lib/libstand/stand.h
@@ -138,6 +138,7 @@ struct devsw {
int (*dv_close)(struct open_file *f);
int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data);
void (*dv_print)(int verbose); /* print device information */
+ void (*dv_cleanup)();
};
extern int errno;
diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c
index f69d430..4fded2c 100644
--- a/sys/boot/common/boot.c
+++ b/sys/boot/common/boot.c
@@ -53,6 +53,7 @@ command_boot(int argc, char *argv[])
struct loaded_module *km;
char *cp;
int try;
+ int i;
/*
* See if the user has specified an explicit kernel to boot.
@@ -109,6 +110,11 @@ command_boot(int argc, char *argv[])
if (archsw.arch_autoload() != 0)
return(CMD_ERROR);
+ /* Call cleanup routines */
+ for (i = 0; devsw[i] != NULL; ++i)
+ if (devsw[i]->dv_cleanup != NULL)
+ (devsw[i]->dv_cleanup)();
+
/* Call the exec handler from the loader matching the kernel */
module_formats[km->m_loader]->l_exec(km);
return(CMD_ERROR);
diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c
index a2d56ff..9d5ab08 100644
--- a/sys/boot/i386/libi386/pxe.c
+++ b/sys/boot/i386/libi386/pxe.c
@@ -128,7 +128,8 @@ struct devsw pxedisk = {
pxe_open,
pxe_close,
noioctl,
- pxe_print
+ pxe_print,
+ pxe_cleanup
};
/*
@@ -325,14 +326,15 @@ pxe_cleanup(void)
t_PXENV_UNDI_SHUTDOWN *undi_shutdown_p =
(t_PXENV_UNDI_SHUTDOWN *)scratch_buffer;
- pxe_call(PXENV_UNLOAD_STACK);
- if (unload_stack_p->Status != 0)
- panic("pxe_cleanup: UNLOAD_STACK failed");
-
pxe_call(PXENV_UNDI_SHUTDOWN);
if (undi_shutdown_p->Status != 0)
- panic("pxe_cleanup: UNDI_SHUTDOWN failed");
- printf("All cleaned up!\n");
+ panic("pxe_cleanup: UNDI_SHUTDOWN failed %x",
+ undi_shutdown_p->Status);
+
+ pxe_call(PXENV_UNLOAD_STACK);
+ if (unload_stack_p->Status != 0)
+ panic("pxe_cleanup: UNLOAD_STACK failed %x",
+ unload_stack_p->Status);
}
void
diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c
index db35e59..721a664 100644
--- a/sys/boot/i386/loader/main.c
+++ b/sys/boot/i386/loader/main.c
@@ -225,6 +225,11 @@ COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
static int
command_reboot(int argc, char *argv[])
{
+ int i;
+
+ for (i = 0; devsw[i] != NULL; ++i)
+ if (devsw[i]->dv_cleanup != NULL)
+ (devsw[i]->dv_cleanup)();
printf("Rebooting...\n");
delay(1000000);
OpenPOWER on IntegriCloud