Skip to content

Commit

Permalink
[vesafb] Handle failures from fbcon_init()
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jan 22, 2014
1 parent c6c8078 commit b20fe32
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/arch/i386/interface/pcbios/vesafb.c
Expand Up @@ -371,6 +371,21 @@ static int vesafb_select_mode ( const uint16_t *mode_numbers,
return best_mode_number;
}

/**
* Restore video mode
*
*/
static void vesafb_restore ( void ) {
uint32_t discard_a;

/* Restore saved VGA mode */
__asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
: "=a" ( discard_a )
: "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
vesafb.saved_mode );
}

/**
* Initialise VESA frame buffer
*
Expand Down Expand Up @@ -412,10 +427,18 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
vesafb_font();

/* Initialise frame buffer console */
fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
&vesafb.pixel, &vesafb.map, &vesafb.font, pixbuf );
if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
&vesafb.pixel, &vesafb.map, &vesafb.font,
pixbuf ) ) != 0 )
goto err_fbcon_init;

free ( mode_numbers );
return 0;

fbcon_fini ( &vesafb.fbcon );
err_fbcon_init:
err_set_mode:
vesafb_restore();
err_select_mode:
free ( mode_numbers );
err_mode_list:
Expand All @@ -427,17 +450,12 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
*
*/
static void vesafb_fini ( void ) {
uint32_t discard_a;

/* Finalise frame buffer console */
fbcon_fini ( &vesafb.fbcon );

/* Restore VGA mode */
__asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
: "=a" ( discard_a )
: "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
vesafb.saved_mode );
/* Restore saved VGA mode */
vesafb_restore();
}

/**
Expand Down

0 comments on commit b20fe32

Please sign in to comment.