Patchwork [Seabios] make reboot-timeout to static for using it after POST phase

login
register
mail settings
Submitter Amos Kong
Date March 5, 2013, 2:06 a.m.
Message ID <1362449188-383-1-git-send-email-akong@redhat.com>
Download mbox | patch
Permalink /patch/224912/
State New
Headers show

Comments

Amos Kong - March 5, 2013, 2:06 a.m.
From: Kevin O'Connor <kevin@koconnor.net>

Memory allocated with malloc_tmp() can't be used after the POST
phase. The reboot-timeout inside romfile could not be loaded in
boot_fail(). The patch saved reboot-timeout to a static variable,
it fixed the regression bug introduced by commit 59d6ca52

I already tested this patch, reboot-timeout parameter of qemu
works now.
@ qemu -boot reboot-timeout=1000 ...

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Amos Kong <akong@redhat.com>
---
 src/boot.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
liguang - March 5, 2013, 9:03 a.m.
在 2013-03-05二的 10:06 +0800,Amos Kong写道:
> From: Kevin O'Connor <kevin@koconnor.net>
> 
> Memory allocated with malloc_tmp() can't be used after the POST
> phase. The reboot-timeout inside romfile could not be loaded in
> boot_fail(). The patch saved reboot-timeout to a static variable,
> it fixed the regression bug introduced by commit 59d6ca52
> 
> I already tested this patch, reboot-timeout parameter of qemu
> works now.
> @ qemu -boot reboot-timeout=1000 ...
> 
> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  src/boot.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/src/boot.c b/src/boot.c
> index ec411b7..325fac0 100644
> --- a/src/boot.c
> +++ b/src/boot.c
> @@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
>   * Boot setup
>   ****************************************************************/
>  
> +static int BootRetryTime;
>  static int CheckFloppySig = 1;
>  
>  #define DEFAULT_PRIO           9999
> @@ -271,6 +272,8 @@ boot_init(void)
>          }
>      }
>  
> +    BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000);
> +
>      loadBootOrder();
>  }
>  
> @@ -629,15 +632,15 @@ boot_rom(u32 vector)
>  static void
>  boot_fail(void)
>  {
> -    u32 retrytime = romfile_loadint("etc/boot-fail-wait", 60*1000);
> -    if (retrytime == (u32)-1)
> +    if (BootRetryTime == (u32)-1)
>          printf("No bootable device.\n");
>      else
> -        printf("No bootable device.  Retrying in %d seconds.\n", retrytime/1000);
> +        printf("No bootable device.  Retrying in %d seconds.\n"
> +               , BootRetryTime/1000);
>      // Wait for 'retrytime' milliseconds and then reboot.

s/retrytime/BootRetryTime

> -    u32 end = calc_future_timer(retrytime);
> +    u32 end = calc_future_timer(BootRetryTime);
>      for (;;) {
> -        if (retrytime != (u32)-1 && check_timer(end))
> +        if (BootRetryTime != (u32)-1 && check_timer(end))
>              break;
>          yield_toirq();
>      }

Patch

diff --git a/src/boot.c b/src/boot.c
index ec411b7..325fac0 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -235,6 +235,7 @@  int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
  * Boot setup
  ****************************************************************/
 
+static int BootRetryTime;
 static int CheckFloppySig = 1;
 
 #define DEFAULT_PRIO           9999
@@ -271,6 +272,8 @@  boot_init(void)
         }
     }
 
+    BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000);
+
     loadBootOrder();
 }
 
@@ -629,15 +632,15 @@  boot_rom(u32 vector)
 static void
 boot_fail(void)
 {
-    u32 retrytime = romfile_loadint("etc/boot-fail-wait", 60*1000);
-    if (retrytime == (u32)-1)
+    if (BootRetryTime == (u32)-1)
         printf("No bootable device.\n");
     else
-        printf("No bootable device.  Retrying in %d seconds.\n", retrytime/1000);
+        printf("No bootable device.  Retrying in %d seconds.\n"
+               , BootRetryTime/1000);
     // Wait for 'retrytime' milliseconds and then reboot.
-    u32 end = calc_future_timer(retrytime);
+    u32 end = calc_future_timer(BootRetryTime);
     for (;;) {
-        if (retrytime != (u32)-1 && check_timer(end))
+        if (BootRetryTime != (u32)-1 && check_timer(end))
             break;
         yield_toirq();
     }