]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[reboot] Generalise warm reboot indicator to a flags bitmask
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 12:42:32 +0000 (13:42 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2025 12:44:53 +0000 (13:44 +0100)
Allow for the possibility of additional reboot types by extending the
reboot() function to use a flags bitmask rather than a single flag.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/interface/sbi/sbi_reboot.c
src/arch/x86/interface/pcbios/bios_reboot.c
src/core/null_reboot.c
src/hci/commands/reboot_cmd.c
src/include/ipxe/reboot.h
src/interface/efi/efi_reboot.c

index 64365b0d3e7ecfcca089bca3820b13859d7d3202..3529c9d38f044836f23fa53e4cac1c364e6cd151 100644 (file)
@@ -37,13 +37,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /**
  * Reboot system
  *
- * @v warm             Perform a warm reboot
+ * @v flags            Reboot flags
  */
-static void sbi_reboot ( int warm ) {
+static void sbi_reboot ( int flags ) {
        struct sbi_return ret;
+       int warm;
        int rc;
 
        /* Reboot system */
+       warm = ( flags & REBOOT_WARM );
        ret = sbi_ecall_2 ( SBI_SRST, SBI_SRST_SYSTEM_RESET,
                            ( warm ? SBI_RESET_WARM : SBI_RESET_COLD ), 0 );
 
index 071173f1956e6b68d43737becf75d78e73ba959c..46347024536c9a2cb9089333300a7ad781d79a48 100644 (file)
@@ -38,14 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /**
  * Reboot system
  *
- * @v warm             Perform a warm reboot
+ * @v flags            Reboot flags
  */
-static void bios_reboot ( int warm ) {
-       uint16_t flag;
+static void bios_reboot ( int flags ) {
+       uint16_t type;
 
        /* Configure BIOS for cold/warm reboot */
-       flag = ( warm ? BDA_REBOOT_WARM : 0 );
-       put_real ( flag, BDA_SEG, BDA_REBOOT );
+       type = ( ( flags & REBOOT_WARM ) ? BDA_REBOOT_WARM : 0 );
+       put_real ( type, BDA_SEG, BDA_REBOOT );
 
        /* Jump to system reset vector */
        __asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : );
index 7be5612a3d31ea9cb29edb4f5263c311c1fc2fc3..63b6e127e1c937bb950a9ff732b543052405a507 100644 (file)
@@ -37,9 +37,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /**
  * Reboot system
  *
- * @v warm             Perform a warm reboot
+ * @v flags            Reboot flags
  */
-static void null_reboot ( int warm __unused ) {
+static void null_reboot ( int flags __unused ) {
 
        printf ( "Cannot reboot; not implemented\n" );
        while ( 1 ) {}
index 45d54cc2c4affdd0b73ff89140fe388ba014d1c3..f344684011666a5335b9d10e51fcf9e20f1d0ffa 100644 (file)
@@ -59,6 +59,7 @@ static struct command_descriptor reboot_cmd =
  */
 static int reboot_exec ( int argc, char **argv ) {
        struct reboot_options opts;
+       int flags = 0;
        int rc;
 
        /* Parse options */
@@ -66,7 +67,9 @@ static int reboot_exec ( int argc, char **argv ) {
                return rc;
 
        /* Reboot system */
-       reboot ( opts.warm );
+       if ( opts.warm )
+               flags |= REBOOT_WARM;
+       reboot ( flags );
 
        return 0;
 }
index 33606d9d5b29a316d402f08fe64dc68a23684aa1..2d8dadecaad4d81cf4bb1fcf532b3877f2c5132f 100644 (file)
@@ -51,9 +51,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /**
  * Reboot system
  *
- * @v warm             Perform a warm reboot
+ * @v flags            Reboot flags
  */
-void reboot ( int warm );
+void reboot ( int flags );
+
+#define REBOOT_WARM    0x00000001 /**< Perform a warm reboot */
 
 /**
  * Power off system
index 35919221e8cd4e1744355faefe33ca4e5a5acdc0..eb389a4b10ea17fa1e87bfd7376a650da1e94436 100644 (file)
@@ -37,13 +37,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 /**
  * Reboot system
  *
- * @v warm             Perform a warm reboot
+ * @v flags            Reboot flags
  */
-static void efi_reboot ( int warm ) {
+static void efi_reboot ( int flags ) {
        EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
+       EFI_RESET_TYPE type;
 
        /* Use runtime services to reset system */
-       rs->ResetSystem ( ( warm ? EfiResetWarm : EfiResetCold ), 0, 0, NULL );
+       type = ( ( flags & REBOOT_WARM ) ? EfiResetWarm : EfiResetCold );
+       rs->ResetSystem ( type, 0, 0, NULL );
 }
 
 /**