Browse Source

[vesafb] Handle failures from fbcon_init()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
b20fe32315
1 changed files with 27 additions and 9 deletions
  1. 27
    9
      src/arch/i386/interface/pcbios/vesafb.c

+ 27
- 9
src/arch/i386/interface/pcbios/vesafb.c View File

371
 	return best_mode_number;
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
  * Initialise VESA frame buffer
390
  * Initialise VESA frame buffer
376
  *
391
  *
412
 	vesafb_font();
427
 	vesafb_font();
413
 
428
 
414
 	/* Initialise frame buffer console */
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
  err_set_mode:
440
  err_set_mode:
441
+	vesafb_restore();
419
  err_select_mode:
442
  err_select_mode:
420
 	free ( mode_numbers );
443
 	free ( mode_numbers );
421
  err_mode_list:
444
  err_mode_list:
427
  *
450
  *
428
  */
451
  */
429
 static void vesafb_fini ( void ) {
452
 static void vesafb_fini ( void ) {
430
-	uint32_t discard_a;
431
 
453
 
432
 	/* Finalise frame buffer console */
454
 	/* Finalise frame buffer console */
433
 	fbcon_fini ( &vesafb.fbcon );
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
 /**

Loading…
Cancel
Save