From patchwork Thu Sep 18 22:49:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37613 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 98C2E20C9D for ; Thu, 18 Sep 2014 22:52:20 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id p10sf1033967wes.9 for ; Thu, 18 Sep 2014 15:52:19 -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=Asojybiz6yT4g8nq8FnGpv74z8/G/5TlCxckJJzze0g=; b=Xy4LnN62iWLsAKgaXq1mozxpSlIZpgjmqL1PFdxlYvb/TCLiIbRN2KFgcucl/gI+Hp VrFUJzPXJrsrvflDfdAGbx9q/ShmvXUfDJQghreItkVBRx2pF9lg3+KLZWirknmAx8RE c2P6Zkk4tuQH6AQzZ/gH/FE1yIw2mwwMyjJDJfD61JDeVCYyyXYgSYbzq7ZvzHRuzcl6 slDp8aKHsqAYO5Df8JahbtFmZpPoqu/CAIMY07Ei5Nw475OCZx34+keFW8nJ9JEDlZKV dj+EQRgDfiBIfhhzTgt0vPQqN1TdFIqycTZQ6FKRb7K95fSR05nPOXOSRZ2dTk/LvPlz Ltjw== X-Gm-Message-State: ALoCoQkio85qr0m2QJfpivkXJOfuQ4zjfc1ahaXEwPeOhfSP5hCvYuGFDLafIII/JVs0K6o2ywCm X-Received: by 10.152.2.97 with SMTP id 1mr1290979lat.6.1411080739824; Thu, 18 Sep 2014 15:52:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.169 with SMTP id s9ls230216laa.47.gmail; Thu, 18 Sep 2014 15:52:19 -0700 (PDT) X-Received: by 10.112.61.68 with SMTP id n4mr2457618lbr.91.1411080739442; Thu, 18 Sep 2014 15:52:19 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id i8si73241lai.129.2014.09.18.15.52.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id c11so2137123lbj.9 for ; Thu, 18 Sep 2014 15:52:19 -0700 (PDT) X-Received: by 10.152.7.8 with SMTP id f8mr2642246laa.27.1411080739372; Thu, 18 Sep 2014 15:52:19 -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 of9csp843135lbb; Thu, 18 Sep 2014 15:52:18 -0700 (PDT) X-Received: by 10.52.110.202 with SMTP id ic10mr1477254vdb.3.1411080737921; Thu, 18 Sep 2014 15:52:17 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ju2si80946vdb.16.2014.09.18.15.52.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 18 Sep 2014 15:52:17 -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 1XUkX0-0006Lz-0f; Thu, 18 Sep 2014 22:50:30 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUkWy-0006L8-Sa for xen-devel@lists.xen.org; Thu, 18 Sep 2014 22:50:29 +0000 Received: from [85.158.139.211:59835] by server-16.bemta-5.messagelabs.com id 25/F3-01029-4B16B145; Thu, 18 Sep 2014 22:50:28 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1411080625!10080763!1 X-Originating-IP: [209.85.220.46] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5928 invoked from network); 18 Sep 2014 22:50:27 -0000 Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 18 Sep 2014 22:50:27 -0000 Received: by mail-pa0-f46.google.com with SMTP id kq14so2474594pab.5 for ; Thu, 18 Sep 2014 15:50:25 -0700 (PDT) X-Received: by 10.68.65.106 with SMTP id w10mr9598788pbs.100.1411080625224; Thu, 18 Sep 2014 15:50:25 -0700 (PDT) Received: from rfranz-t520.swisscom.com (70-35-38-154.static.wiline.com. [70.35.38.154]) by mx.google.com with ESMTPSA id ig4sm66332pbb.55.2014.09.18.15.50.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Sep 2014 15:50:24 -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: Thu, 18 Sep 2014 15:49:59 -0700 Message-Id: <1411080607-32365-9-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> References: <1411080607-32365-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH V5 08/15] 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.217.178 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/common/efi/boot.c | 69 ++------------------------------------ xen/include/asm-x86/efi-boot.h | 75 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 66 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 2914225..1917052 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; @@ -768,12 +769,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); @@ -1027,7 +1023,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 ) @@ -1036,65 +1031,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(&mmap_size, NULL, &mmap_key, diff --git a/xen/include/asm-x86/efi-boot.h b/xen/include/asm-x86/efi-boot.h index 17b5840..7df04bb 100644 --- a/xen/include/asm-x86/efi-boot.h +++ b/xen/include/asm-x86/efi-boot.h @@ -465,3 +465,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; + } +}