From 36a4c85f911c85f5ab183331ff74d125f9a9ed32 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 25 Jan 2019 14:53:43 +0000 Subject: [init] Show startup and shutdown function names in debug messages Signed-off-by: Michael Brown --- src/arch/x86/core/cachedhcp.c | 1 + src/arch/x86/core/runtime.c | 1 + src/arch/x86/drivers/net/undionly.c | 1 + src/arch/x86/image/initrd.c | 1 + src/arch/x86/interface/pcbios/bios_console.c | 1 + src/arch/x86/interface/pcbios/hidemem.c | 1 + src/core/device.c | 1 + src/core/init.c | 15 +++++++++++++-- src/core/malloc.c | 1 + src/core/serial.c | 1 + src/crypto/rbg.c | 1 + src/crypto/rootcert.c | 1 + src/drivers/usb/ehci.c | 1 + src/drivers/usb/xhci.c | 1 + src/hci/linux_args.c | 1 + src/include/ipxe/init.h | 1 + src/interface/efi/efi_timer.c | 1 + src/interface/linux/linux_console.c | 1 + src/net/tcp.c | 1 + 19 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/arch/x86/core/cachedhcp.c b/src/arch/x86/core/cachedhcp.c index ff35b925..dffafe3c 100644 --- a/src/arch/x86/core/cachedhcp.c +++ b/src/arch/x86/core/cachedhcp.c @@ -127,6 +127,7 @@ struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = { /** Cached DHCPACK startup function */ struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = { + .name = "cachedhcp", .startup = cachedhcp_startup, }; diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index d160fee0..f96b23af 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -265,5 +265,6 @@ static void runtime_init ( void ) { /** Command line and initrd initialisation function */ struct startup_fn runtime_startup_fn __startup_fn ( STARTUP_NORMAL ) = { + .name = "runtime", .startup = runtime_init, }; diff --git a/src/arch/x86/drivers/net/undionly.c b/src/arch/x86/drivers/net/undionly.c index 9c9ca127..89837221 100644 --- a/src/arch/x86/drivers/net/undionly.c +++ b/src/arch/x86/drivers/net/undionly.c @@ -141,5 +141,6 @@ static void undionly_shutdown ( int booting ) { } struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE ) = { + .name = "undionly", .shutdown = undionly_shutdown, }; diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index 80c19741..8f6366d3 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -300,5 +300,6 @@ static void initrd_startup ( void ) { /** initrd startup function */ struct startup_fn startup_initrd __startup_fn ( STARTUP_LATE ) = { + .name = "initrd", .startup = initrd_startup, }; diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c index 08fa6d03..52a02fba 100644 --- a/src/arch/x86/interface/pcbios/bios_console.c +++ b/src/arch/x86/interface/pcbios/bios_console.c @@ -547,6 +547,7 @@ static void bios_inject_shutdown ( int booting __unused ) { /** Keypress injection startup function */ struct startup_fn bios_inject_startup_fn __startup_fn ( STARTUP_NORMAL ) = { + .name = "bios_inject", .startup = bios_inject_startup, .shutdown = bios_inject_shutdown, }; diff --git a/src/arch/x86/interface/pcbios/hidemem.c b/src/arch/x86/interface/pcbios/hidemem.c index a3728123..1a3022c5 100644 --- a/src/arch/x86/interface/pcbios/hidemem.c +++ b/src/arch/x86/interface/pcbios/hidemem.c @@ -229,6 +229,7 @@ static void unhide_etherboot ( int flags __unused ) { /** Hide Etherboot startup function */ struct startup_fn hide_etherboot_startup_fn __startup_fn ( STARTUP_EARLY ) = { + .name = "hidemem", .startup = hide_etherboot, .shutdown = unhide_etherboot, }; diff --git a/src/core/device.c b/src/core/device.c index 77d7b719..efe4eb68 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -111,6 +111,7 @@ static void remove_devices ( int booting __unused ) { } struct startup_fn startup_devices __startup_fn ( STARTUP_NORMAL ) = { + .name = "devices", .startup = probe_devices, .shutdown = remove_devices, }; diff --git a/src/core/init.c b/src/core/init.c index d91e4466..c13fd166 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -36,6 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** "startup() has been called" flag */ static int started = 0; +/** Colour for debug messages */ +#define colour table_start ( INIT_FNS ) + /** * Initialise iPXE * @@ -69,11 +72,15 @@ void startup ( void ) { /* Call registered startup functions */ for_each_table_entry ( startup_fn, STARTUP_FNS ) { - if ( startup_fn->startup ) + if ( startup_fn->startup ) { + DBGC ( colour, "INIT startup %s...\n", + startup_fn->name ); startup_fn->startup(); + } } started = 1; + DBGC ( colour, "INIT startup complete\n" ); } /** @@ -96,12 +103,16 @@ void shutdown ( int flags ) { /* Call registered shutdown functions (in reverse order) */ for_each_table_entry_reverse ( startup_fn, STARTUP_FNS ) { - if ( startup_fn->shutdown ) + if ( startup_fn->shutdown ) { + DBGC ( colour, "INIT shutdown %s...\n", + startup_fn->name ); startup_fn->shutdown ( flags ); + } } /* Reset console */ console_reset(); started = 0; + DBGC ( colour, "INIT shutdown complete\n" ); } diff --git a/src/core/malloc.c b/src/core/malloc.c index 91c8e4d3..0a7843a1 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -685,6 +685,7 @@ static void shutdown_cache ( int booting __unused ) { /** Memory allocator shutdown function */ struct startup_fn heap_startup_fn __startup_fn ( STARTUP_EARLY ) = { + .name = "heap", .shutdown = shutdown_cache, }; diff --git a/src/core/serial.c b/src/core/serial.c index dd22f673..bef9ccba 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -181,5 +181,6 @@ struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = { /** Serial console startup function */ struct startup_fn serial_startup_fn __startup_fn ( STARTUP_EARLY ) = { + .name = "serial", .shutdown = serial_shutdown, }; diff --git a/src/crypto/rbg.c b/src/crypto/rbg.c index a5a77e3c..4b45b347 100644 --- a/src/crypto/rbg.c +++ b/src/crypto/rbg.c @@ -126,6 +126,7 @@ static void rbg_shutdown_fn ( int booting __unused ) { /** RBG startup table entry */ struct startup_fn startup_rbg __startup_fn ( STARTUP_NORMAL ) = { + .name = "rbg", .startup = rbg_startup_fn, .shutdown = rbg_shutdown_fn, }; diff --git a/src/crypto/rootcert.c b/src/crypto/rootcert.c index f7b9dcfb..867ff50e 100644 --- a/src/crypto/rootcert.c +++ b/src/crypto/rootcert.c @@ -123,5 +123,6 @@ static void rootcert_init ( void ) { /** Root certificate initialiser */ struct startup_fn rootcert_startup_fn __startup_fn ( STARTUP_LATE ) = { + .name = "rootcert", .startup = rootcert_init, }; diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 35cbc8de..cd396707 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -2098,5 +2098,6 @@ static void ehci_shutdown ( int booting ) { /** Startup/shutdown function */ struct startup_fn ehci_startup __startup_fn ( STARTUP_LATE ) = { + .name = "ehci", .shutdown = ehci_shutdown, }; diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index ecf8bf4d..e9a7f4c6 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -3363,5 +3363,6 @@ static void xhci_shutdown ( int booting ) { /** Startup/shutdown function */ struct startup_fn xhci_startup __startup_fn ( STARTUP_LATE ) = { + .name = "xhci", .shutdown = xhci_shutdown, }; diff --git a/src/hci/linux_args.c b/src/hci/linux_args.c index 58eeb063..5f903e3b 100644 --- a/src/hci/linux_args.c +++ b/src/hci/linux_args.c @@ -185,6 +185,7 @@ void linux_args_cleanup(int flags __unused) } struct startup_fn startup_linux_args __startup_fn(STARTUP_EARLY) = { + .name = "linux_args", .startup = linux_args_parse, .shutdown = linux_args_cleanup, }; diff --git a/src/include/ipxe/init.h b/src/include/ipxe/init.h index 025cfaf3..32927e3a 100644 --- a/src/include/ipxe/init.h +++ b/src/include/ipxe/init.h @@ -39,6 +39,7 @@ struct init_fn { * part of the calls to startup() and shutdown(). */ struct startup_fn { + const char *name; void ( * startup ) ( void ); void ( * shutdown ) ( int booting ); }; diff --git a/src/interface/efi/efi_timer.c b/src/interface/efi/efi_timer.c index 8fe307ce..8f40cb81 100644 --- a/src/interface/efi/efi_timer.c +++ b/src/interface/efi/efi_timer.c @@ -212,6 +212,7 @@ static void efi_tick_shutdown ( int booting __unused ) { /** Timer tick startup function */ struct startup_fn efi_tick_startup_fn __startup_fn ( STARTUP_EARLY ) = { + .name = "efi_tick", .startup = efi_tick_startup, .shutdown = efi_tick_shutdown, }; diff --git a/src/interface/linux/linux_console.c b/src/interface/linux/linux_console.c index 5105eaa9..5294fca7 100644 --- a/src/interface/linux/linux_console.c +++ b/src/interface/linux/linux_console.c @@ -150,6 +150,7 @@ static void linux_console_shutdown(int flags __unused) } struct startup_fn linux_console_startup_fn __startup_fn(STARTUP_EARLY) = { + .name = "linux_console", .startup = linux_console_startup, .shutdown = linux_console_shutdown, }; diff --git a/src/net/tcp.c b/src/net/tcp.c index cb3b84ed..c445100a 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -1654,6 +1654,7 @@ static void tcp_shutdown ( int booting __unused ) { /** TCP shutdown function */ struct startup_fn tcp_startup_fn __startup_fn ( STARTUP_LATE ) = { + .name = "tcp", .shutdown = tcp_shutdown, }; -- cgit v1.2.3-55-g7522