|  | @@ -575,22 +575,24 @@ static int fbcon_picture_init ( struct fbcon *fbcon,
 | 
		
	
		
			
			| 575 | 575 |   * @v fbcon		Frame buffer console
 | 
		
	
		
			
			| 576 | 576 |   * @v start		Start address
 | 
		
	
		
			
			| 577 | 577 |   * @v pixel		Pixel geometry
 | 
		
	
		
			
			| 578 |  | - * @v margin		Minimum margin
 | 
		
	
		
			
			| 579 | 578 |   * @v map		Colour mapping
 | 
		
	
		
			
			| 580 | 579 |   * @v font		Font definition
 | 
		
	
		
			
			| 581 |  | - * @v pixbuf		Background picture (if any)
 | 
		
	
		
			
			|  | 580 | + * @v config		Console configuration
 | 
		
	
		
			
			| 582 | 581 |   * @ret rc		Return status code
 | 
		
	
		
			
			| 583 | 582 |   */
 | 
		
	
		
			
			| 584 | 583 |  int fbcon_init ( struct fbcon *fbcon, userptr_t start,
 | 
		
	
		
			
			| 585 | 584 |  		 struct fbcon_geometry *pixel,
 | 
		
	
		
			
			| 586 |  | -		 struct fbcon_margin *margin,
 | 
		
	
		
			
			| 587 | 585 |  		 struct fbcon_colour_map *map,
 | 
		
	
		
			
			| 588 | 586 |  		 struct fbcon_font *font,
 | 
		
	
		
			
			| 589 |  | -		 struct pixel_buffer *pixbuf ) {
 | 
		
	
		
			
			|  | 587 | +		 struct console_configuration *config ) {
 | 
		
	
		
			
			| 590 | 588 |  	int width;
 | 
		
	
		
			
			| 591 | 589 |  	int height;
 | 
		
	
		
			
			| 592 | 590 |  	unsigned int xgap;
 | 
		
	
		
			
			| 593 | 591 |  	unsigned int ygap;
 | 
		
	
		
			
			|  | 592 | +	unsigned int left;
 | 
		
	
		
			
			|  | 593 | +	unsigned int right;
 | 
		
	
		
			
			|  | 594 | +	unsigned int top;
 | 
		
	
		
			
			|  | 595 | +	unsigned int bottom;
 | 
		
	
		
			
			| 594 | 596 |  	int rc;
 | 
		
	
		
			
			| 595 | 597 |  
 | 
		
	
		
			
			| 596 | 598 |  	/* Initialise data structure */
 | 
		
	
	
		
			
			|  | @@ -609,24 +611,43 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start,
 | 
		
	
		
			
			| 609 | 611 |  	       user_to_phys ( fbcon->start, 0 ),
 | 
		
	
		
			
			| 610 | 612 |  	       user_to_phys ( fbcon->start, fbcon->len ) );
 | 
		
	
		
			
			| 611 | 613 |  
 | 
		
	
		
			
			|  | 614 | +	/* Calculate margin.  If the actual screen size is larger than
 | 
		
	
		
			
			|  | 615 | +	 * the requested screen size, then update the margins so that
 | 
		
	
		
			
			|  | 616 | +	 * the margin remains relative to the requested screen size.
 | 
		
	
		
			
			|  | 617 | +	 * (As an exception, if a zero margin was specified then treat
 | 
		
	
		
			
			|  | 618 | +	 * this as meaning "expand to edge of actual screen".)
 | 
		
	
		
			
			|  | 619 | +	 */
 | 
		
	
		
			
			|  | 620 | +	xgap = ( pixel->width - config->width );
 | 
		
	
		
			
			|  | 621 | +	ygap = ( pixel->height - config->height );
 | 
		
	
		
			
			|  | 622 | +	left = ( xgap / 2 );
 | 
		
	
		
			
			|  | 623 | +	right = ( xgap - left );
 | 
		
	
		
			
			|  | 624 | +	top = ( ygap / 2 );
 | 
		
	
		
			
			|  | 625 | +	bottom = ( ygap - top );
 | 
		
	
		
			
			|  | 626 | +	fbcon->margin.left = ( config->left + ( config->left ? left : 0 ) );
 | 
		
	
		
			
			|  | 627 | +	fbcon->margin.right = ( config->right + ( config->right ? right : 0 ) );
 | 
		
	
		
			
			|  | 628 | +	fbcon->margin.top = ( config->top + ( config->top ? top : 0 ) );
 | 
		
	
		
			
			|  | 629 | +	fbcon->margin.bottom =
 | 
		
	
		
			
			|  | 630 | +		( config->bottom + ( config->bottom ? bottom : 0 ) );
 | 
		
	
		
			
			|  | 631 | +
 | 
		
	
		
			
			| 612 | 632 |  	/* Expand margin to accommodate whole characters */
 | 
		
	
		
			
			| 613 |  | -	width = ( pixel->width - margin->left - margin->right );
 | 
		
	
		
			
			| 614 |  | -	height = ( pixel->height - margin->top - margin->bottom );
 | 
		
	
		
			
			|  | 633 | +	width = ( pixel->width - fbcon->margin.left - fbcon->margin.right );
 | 
		
	
		
			
			|  | 634 | +	height = ( pixel->height - fbcon->margin.top - fbcon->margin.bottom );
 | 
		
	
		
			
			| 615 | 635 |  	if ( ( width < FBCON_CHAR_WIDTH ) ||
 | 
		
	
		
			
			| 616 | 636 |  	     ( height < ( ( int ) font->height ) ) ) {
 | 
		
	
		
			
			| 617 | 637 |  		DBGC ( fbcon, "FBCON %p has unusable character area "
 | 
		
	
		
			
			| 618 |  | -		       "[%d-%d),[%d-%d)\n", fbcon,
 | 
		
	
		
			
			| 619 |  | -		       margin->left, ( pixel->width - margin->right ),
 | 
		
	
		
			
			| 620 |  | -		       margin->top, ( pixel->height - margin->bottom ) );
 | 
		
	
		
			
			|  | 638 | +		       "[%d-%d),[%d-%d)\n", fbcon, fbcon->margin.left,
 | 
		
	
		
			
			|  | 639 | +		       ( pixel->width - fbcon->margin.right ),
 | 
		
	
		
			
			|  | 640 | +		       fbcon->margin.top,
 | 
		
	
		
			
			|  | 641 | +		       ( pixel->height - fbcon->margin.bottom ) );
 | 
		
	
		
			
			| 621 | 642 |  		rc = -EINVAL;
 | 
		
	
		
			
			| 622 | 643 |  		goto err_margin;
 | 
		
	
		
			
			| 623 | 644 |  	}
 | 
		
	
		
			
			| 624 | 645 |  	xgap = ( width % FBCON_CHAR_WIDTH );
 | 
		
	
		
			
			| 625 | 646 |  	ygap = ( height % font->height );
 | 
		
	
		
			
			| 626 |  | -	fbcon->margin.left = ( margin->left + ( xgap / 2 ) );
 | 
		
	
		
			
			| 627 |  | -	fbcon->margin.top = ( margin->top + ( ygap / 2 ) );
 | 
		
	
		
			
			| 628 |  | -	fbcon->margin.right = ( margin->right + ( xgap - ( xgap / 2 ) ) );
 | 
		
	
		
			
			| 629 |  | -	fbcon->margin.bottom = ( margin->bottom + ( ygap - ( ygap / 2 ) ) );
 | 
		
	
		
			
			|  | 647 | +	fbcon->margin.left += ( xgap / 2 );
 | 
		
	
		
			
			|  | 648 | +	fbcon->margin.top += ( ygap / 2 );
 | 
		
	
		
			
			|  | 649 | +	fbcon->margin.right += ( xgap - ( xgap / 2 ) );
 | 
		
	
		
			
			|  | 650 | +	fbcon->margin.bottom += ( ygap - ( ygap / 2 ) );
 | 
		
	
		
			
			| 630 | 651 |  	fbcon->indent = ( ( fbcon->margin.top * pixel->stride ) +
 | 
		
	
		
			
			| 631 | 652 |  			  ( fbcon->margin.left * pixel->len ) );
 | 
		
	
		
			
			| 632 | 653 |  
 | 
		
	
	
		
			
			|  | @@ -661,7 +682,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start,
 | 
		
	
		
			
			| 661 | 682 |  	memset_user ( fbcon->start, 0, 0, fbcon->len );
 | 
		
	
		
			
			| 662 | 683 |  
 | 
		
	
		
			
			| 663 | 684 |  	/* Generate pixel buffer from background image, if applicable */
 | 
		
	
		
			
			| 664 |  | -	if ( pixbuf && ( ( rc = fbcon_picture_init ( fbcon, pixbuf ) ) != 0 ) )
 | 
		
	
		
			
			|  | 685 | +	if ( config->pixbuf &&
 | 
		
	
		
			
			|  | 686 | +	     ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) )
 | 
		
	
		
			
			| 665 | 687 |  		goto err_picture;
 | 
		
	
		
			
			| 666 | 688 |  
 | 
		
	
		
			
			| 667 | 689 |  	/* Draw background picture (including margins), if applicable */
 |