debuggers.hg

changeset 21151:a3f7352d83eb

pv-grub: fix boot crash when no fb is available

When no fb is available, init_fbfront will return, so the local
semaphore for synchronization with the kbd thread would get dropped.
Using a global static semaphore instead fixes this.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 06 07:13:01 2010 +0100 (2010-04-06)
parents 4822f82acec6
children b20f897d6010
files stubdom/grub/mini-os.c
line diff
     1.1 --- a/stubdom/grub/mini-os.c	Tue Apr 06 07:12:39 2010 +0100
     1.2 +++ b/stubdom/grub/mini-os.c	Tue Apr 06 07:13:01 2010 +0100
     1.3 @@ -651,12 +651,11 @@ int console_getkey (void)
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +static DECLARE_MUTEX_LOCKED(kbd_sem);
     1.8  static void kbd_thread(void *p)
     1.9  {
    1.10 -    struct semaphore *sem = p;
    1.11 -
    1.12      kbd_dev = init_kbdfront(NULL, 1);
    1.13 -    up(sem);
    1.14 +    up(&kbd_sem);
    1.15  }
    1.16  
    1.17  struct fbfront_dev *fb_open(void *fb, int width, int height, int depth)
    1.18 @@ -665,10 +664,9 @@ struct fbfront_dev *fb_open(void *fb, in
    1.19      int linesize = width * (depth / 8);
    1.20      int memsize = linesize * height;
    1.21      int numpages = (memsize + PAGE_SIZE - 1) / PAGE_SIZE;
    1.22 -    DECLARE_MUTEX_LOCKED(sem);
    1.23      int i;
    1.24  
    1.25 -    create_thread("kbdfront", kbd_thread, &sem);
    1.26 +    create_thread("kbdfront", kbd_thread, &kbd_sem);
    1.27  
    1.28      mfns = malloc(numpages * sizeof(*mfns));
    1.29      for (i = 0; i < numpages; i++) {
    1.30 @@ -681,7 +679,7 @@ struct fbfront_dev *fb_open(void *fb, in
    1.31      if (!fb_dev)
    1.32          return NULL;
    1.33  
    1.34 -    down(&sem);
    1.35 +    down(&kbd_sem);
    1.36      if (!kbd_dev)
    1.37          return NULL;
    1.38