From patchwork Wed Sep 24 05:03:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37789 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA3B420792 for ; Wed, 24 Sep 2014 05:05:41 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id p10sf2422772wes.4 for ; Tue, 23 Sep 2014 22:05:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=JIzGNGbNhrTkLa7i6kSdbW1c+EgSvlAUKGX5YHGGTXo=; b=fFqADttKscQZzNgCw1OaGTOaq1ZSPqXN/u+AloqMvbYMxMY7Z6q5u8pu7r60eCFoim S3qBKM5u8zYZceA4L63cOQgzB7hiSN5+ONvoXq9YM4oOTwJrfY+CIMAHwVN93u1/reit eLqfeBNwWX1v3b/ihxlDluiMvJCXjKup7/LIWZRa8nd54O/Er1oqKlyI1t1FjGy630iW 706JoFkHPfM4L/uy8Qief6u4khBuoAcJDfNQIZFFsKrqeCc+XxspaVNiM79buftRn/PY wHv0hXAJAEq68o8zQ1ZCyy0LLIgpEtYUhIej1VJvm+J3j61qFO4C3N5Ci4jg0hLCBbQj rvbA== X-Gm-Message-State: ALoCoQkQaoNDKRV7NXHvdvDRR6CdgyU7iNqEV141v/BMqw3LvjeLi8hAU7d3Ho6lOo463fFJOeFQ X-Received: by 10.152.6.9 with SMTP id w9mr84424law.7.1411535141010; Tue, 23 Sep 2014 22:05:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.194 with SMTP id 2ls115674law.108.gmail; Tue, 23 Sep 2014 22:05:40 -0700 (PDT) X-Received: by 10.112.168.38 with SMTP id zt6mr3680263lbb.60.1411535140743; Tue, 23 Sep 2014 22:05:40 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id b9si21333735laa.24.2014.09.23.22.05.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id ge10so9702714lab.41 for ; Tue, 23 Sep 2014 22:05:40 -0700 (PDT) X-Received: by 10.112.200.134 with SMTP id js6mr3806737lbc.0.1411535140666; Tue, 23 Sep 2014 22:05:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp526262lbb; Tue, 23 Sep 2014 22:05:39 -0700 (PDT) X-Received: by 10.52.231.228 with SMTP id tj4mr3337066vdc.28.1411535138634; Tue, 23 Sep 2014 22:05:38 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w8si5270379vcu.60.2014.09.23.22.05.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 23 Sep 2014 22:05:38 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejt-0006JA-Dh; Wed, 24 Sep 2014 05:03:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWejs-0006IO-BR for xen-devel@lists.xen.org; Wed, 24 Sep 2014 05:03:40 +0000 Received: from [85.158.139.211:64846] by server-10.bemta-5.messagelabs.com id F8/2B-19806-BA052245; Wed, 24 Sep 2014 05:03:39 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1411535017!8239817!1 X-Originating-IP: [209.85.223.180] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20830 invoked from network); 24 Sep 2014 05:03:38 -0000 Received: from mail-ie0-f180.google.com (HELO mail-ie0-f180.google.com) (209.85.223.180) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 24 Sep 2014 05:03:38 -0000 Received: by mail-ie0-f180.google.com with SMTP id ar1so7982584iec.11 for ; Tue, 23 Sep 2014 22:03:36 -0700 (PDT) X-Received: by 10.50.66.229 with SMTP id i5mr6197952igt.27.1411535016836; Tue, 23 Sep 2014 22:03:36 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id ig9sm3477662igb.13.2014.09.23.22.03.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 22:03:36 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Tue, 23 Sep 2014 22:03:06 -0700 Message-Id: <1411534992-27443-9-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> References: <1411534992-27443-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V6 08/14] Create arch functions for console and video init X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Add arch functions for text console and graphics initialization, and move VGA specific code to x86 architecture file. Signed-off-by: Roy Franz Acked-by: Jan Beulich --- xen/arch/x86/efi/efi-boot.h | 75 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 69 ++--------------------------------------- 2 files changed, 78 insertions(+), 66 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index d7e2faf..7f8a603 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -457,3 +457,78 @@ static void __init efi_arch_edd(void) if ( boot_edd_info_nr > EDD_INFO_MAX ) boot_edd_info_nr = EDD_INFO_MAX; } + +static void __init efi_arch_console_init(UINTN cols, UINTN rows) +{ + vga_console_info.video_type = XEN_VGATYPE_TEXT_MODE_3; + vga_console_info.u.text_mode_3.columns = cols; + vga_console_info.u.text_mode_3.rows = rows; + vga_console_info.u.text_mode_3.font_height = 16; +} + +static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, + UINTN info_size, + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info) +{ + int bpp = 0; + + switch ( mode_info->PixelFormat ) + { + case PixelRedGreenBlueReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos = 0; + vga_console_info.u.vesa_lfb.red_size = 8; + vga_console_info.u.vesa_lfb.green_pos = 8; + vga_console_info.u.vesa_lfb.green_size = 8; + vga_console_info.u.vesa_lfb.blue_pos = 16; + vga_console_info.u.vesa_lfb.blue_size = 8; + vga_console_info.u.vesa_lfb.rsvd_pos = 24; + vga_console_info.u.vesa_lfb.rsvd_size = 8; + bpp = 32; + break; + case PixelBlueGreenRedReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos = 16; + vga_console_info.u.vesa_lfb.red_size = 8; + vga_console_info.u.vesa_lfb.green_pos = 8; + vga_console_info.u.vesa_lfb.green_size = 8; + vga_console_info.u.vesa_lfb.blue_pos = 0; + vga_console_info.u.vesa_lfb.blue_size = 8; + vga_console_info.u.vesa_lfb.rsvd_pos = 24; + vga_console_info.u.vesa_lfb.rsvd_size = 8; + bpp = 32; + break; + case PixelBitMask: + bpp = set_color(mode_info->PixelInformation.RedMask, bpp, + &vga_console_info.u.vesa_lfb.red_pos, + &vga_console_info.u.vesa_lfb.red_size); + bpp = set_color(mode_info->PixelInformation.GreenMask, bpp, + &vga_console_info.u.vesa_lfb.green_pos, + &vga_console_info.u.vesa_lfb.green_size); + bpp = set_color(mode_info->PixelInformation.BlueMask, bpp, + &vga_console_info.u.vesa_lfb.blue_pos, + &vga_console_info.u.vesa_lfb.blue_size); + bpp = set_color(mode_info->PixelInformation.ReservedMask, bpp, + &vga_console_info.u.vesa_lfb.rsvd_pos, + &vga_console_info.u.vesa_lfb.rsvd_size); + if ( bpp > 0 ) + break; + /* fall through */ + default: + PrintErr(L"Current graphics mode is unsupported!\r\n"); + bpp = 0; + break; + } + if ( bpp > 0 ) + { + vga_console_info.video_type = XEN_VGATYPE_EFI_LFB; + vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */ + vga_console_info.u.vesa_lfb.width = + mode_info->HorizontalResolution; + vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution; + vga_console_info.u.vesa_lfb.bits_per_pixel = bpp; + vga_console_info.u.vesa_lfb.bytes_per_line = + (mode_info->PixelsPerScanLine * bpp + 7) >> 3; + vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase; + vga_console_info.u.vesa_lfb.lfb_size = + (gop->Mode->FrameBufferSize + 0xffff) >> 16; + } +} diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 4566cf0..3893311 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -61,6 +61,7 @@ static CHAR16 *s2w(union string *str); static char *w2s(const union string *str); static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, struct file *file); +static int set_color(u32 mask, int bpp, u8 *pos, u8 *sz); static EFI_BOOT_SERVICES *__initdata efi_bs; static EFI_HANDLE __initdata efi_ih; @@ -767,12 +768,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( StdOut->QueryMode(StdOut, StdOut->Mode->Mode, &cols, &rows) == EFI_SUCCESS ) - { - vga_console_info.video_type = XEN_VGATYPE_TEXT_MODE_3; - vga_console_info.u.text_mode_3.columns = cols; - vga_console_info.u.text_mode_3.rows = rows; - vga_console_info.u.text_mode_3.font_height = 16; - } + efi_arch_console_init(cols, rows); size = 0; status = efi_bs->LocateHandle(ByProtocol, &gop_guid, NULL, &size, NULL); @@ -1026,7 +1022,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( gop ) { - int bpp = 0; /* Set graphics mode. */ if ( gop_mode < gop->Mode->MaxMode && gop_mode != gop->Mode->Mode ) @@ -1035,65 +1030,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) /* Get graphics and frame buffer info. */ status = gop->QueryMode(gop, gop->Mode->Mode, &info_size, &mode_info); if ( !EFI_ERROR(status) ) - switch ( mode_info->PixelFormat ) - { - case PixelRedGreenBlueReserved8BitPerColor: - vga_console_info.u.vesa_lfb.red_pos = 0; - vga_console_info.u.vesa_lfb.red_size = 8; - vga_console_info.u.vesa_lfb.green_pos = 8; - vga_console_info.u.vesa_lfb.green_size = 8; - vga_console_info.u.vesa_lfb.blue_pos = 16; - vga_console_info.u.vesa_lfb.blue_size = 8; - vga_console_info.u.vesa_lfb.rsvd_pos = 24; - vga_console_info.u.vesa_lfb.rsvd_size = 8; - bpp = 32; - break; - case PixelBlueGreenRedReserved8BitPerColor: - vga_console_info.u.vesa_lfb.red_pos = 16; - vga_console_info.u.vesa_lfb.red_size = 8; - vga_console_info.u.vesa_lfb.green_pos = 8; - vga_console_info.u.vesa_lfb.green_size = 8; - vga_console_info.u.vesa_lfb.blue_pos = 0; - vga_console_info.u.vesa_lfb.blue_size = 8; - vga_console_info.u.vesa_lfb.rsvd_pos = 24; - vga_console_info.u.vesa_lfb.rsvd_size = 8; - bpp = 32; - break; - case PixelBitMask: - bpp = set_color(mode_info->PixelInformation.RedMask, bpp, - &vga_console_info.u.vesa_lfb.red_pos, - &vga_console_info.u.vesa_lfb.red_size); - bpp = set_color(mode_info->PixelInformation.GreenMask, bpp, - &vga_console_info.u.vesa_lfb.green_pos, - &vga_console_info.u.vesa_lfb.green_size); - bpp = set_color(mode_info->PixelInformation.BlueMask, bpp, - &vga_console_info.u.vesa_lfb.blue_pos, - &vga_console_info.u.vesa_lfb.blue_size); - bpp = set_color(mode_info->PixelInformation.ReservedMask, bpp, - &vga_console_info.u.vesa_lfb.rsvd_pos, - &vga_console_info.u.vesa_lfb.rsvd_size); - if ( bpp > 0 ) - break; - /* fall through */ - default: - PrintErr(L"Current graphics mode is unsupported!\r\n"); - status = EFI_UNSUPPORTED; - break; - } - if ( !EFI_ERROR(status) ) - { - vga_console_info.video_type = XEN_VGATYPE_EFI_LFB; - vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */ - vga_console_info.u.vesa_lfb.width = - mode_info->HorizontalResolution; - vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution; - vga_console_info.u.vesa_lfb.bits_per_pixel = bpp; - vga_console_info.u.vesa_lfb.bytes_per_line = - (mode_info->PixelsPerScanLine * bpp + 7) >> 3; - vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase; - vga_console_info.u.vesa_lfb.lfb_size = - (gop->Mode->FrameBufferSize + 0xffff) >> 16; - } + efi_arch_video_init(gop, info_size, mode_info); } efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key,