Просмотр исходного кода

[vesafb] Handle failures from fbcon_init()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 лет назад
Родитель
Сommit
b20fe32315
1 измененных файлов: 27 добавлений и 9 удалений
  1. 27
    9
      src/arch/i386/interface/pcbios/vesafb.c

+ 27
- 9
src/arch/i386/interface/pcbios/vesafb.c Просмотреть файл

@@ -371,6 +371,21 @@ static int vesafb_select_mode ( const uint16_t *mode_numbers,
371 371
 	return best_mode_number;
372 372
 }
373 373
 
374
+/**
375
+ * Restore video mode
376
+ *
377
+ */
378
+static void vesafb_restore ( void ) {
379
+	uint32_t discard_a;
380
+
381
+	/* Restore saved VGA mode */
382
+	__asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
383
+			       : "=a" ( discard_a )
384
+			       : "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
385
+	DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
386
+	       vesafb.saved_mode );
387
+}
388
+
374 389
 /**
375 390
  * Initialise VESA frame buffer
376 391
  *
@@ -412,10 +427,18 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
412 427
 	vesafb_font();
413 428
 
414 429
 	/* Initialise frame buffer console */
415
-	fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
416
-		     &vesafb.pixel, &vesafb.map, &vesafb.font, pixbuf );
430
+	if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
431
+				 &vesafb.pixel, &vesafb.map, &vesafb.font,
432
+				 pixbuf ) ) != 0 )
433
+		goto err_fbcon_init;
434
+
435
+	free ( mode_numbers );
436
+	return 0;
417 437
 
438
+	fbcon_fini ( &vesafb.fbcon );
439
+ err_fbcon_init:
418 440
  err_set_mode:
441
+	vesafb_restore();
419 442
  err_select_mode:
420 443
 	free ( mode_numbers );
421 444
  err_mode_list:
@@ -427,17 +450,12 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
427 450
  *
428 451
  */
429 452
 static void vesafb_fini ( void ) {
430
-	uint32_t discard_a;
431 453
 
432 454
 	/* Finalise frame buffer console */
433 455
 	fbcon_fini ( &vesafb.fbcon );
434 456
 
435
-	/* Restore VGA mode */
436
-	__asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
437
-			       : "=a" ( discard_a )
438
-			       : "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
439
-	DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
440
-	       vesafb.saved_mode );
457
+	/* Restore saved VGA mode */
458
+	vesafb_restore();
441 459
 }
442 460
 
443 461
 /**

Загрузка…
Отмена
Сохранить