From patchwork Wed Feb 9 13:09:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tu Dinh Ngoc X-Patchwork-Id: 12740266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0E90C433FE for ; Wed, 9 Feb 2022 13:10:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.269117.463116 (Exim 4.92) (envelope-from ) id 1nHmji-0003oN-Gi; Wed, 09 Feb 2022 13:10:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 269117.463116; Wed, 09 Feb 2022 13:10:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHmji-0003oG-DR; Wed, 09 Feb 2022 13:10:18 +0000 Received: by outflank-mailman (input) for mailman id 269117; Wed, 09 Feb 2022 13:10:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHmjh-0003YU-Ot for xen-devel@lists.xenproject.org; Wed, 09 Feb 2022 13:10:17 +0000 Received: from smtp1.irit.fr (smtp1.irit.fr [141.115.24.2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9fd58bef-89a9-11ec-8f75-fffcc8bd4f1a; Wed, 09 Feb 2022 14:10:16 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9fd58bef-89a9-11ec-8f75-fffcc8bd4f1a From: Tu Dinh Ngoc To: xen-devel@lists.xenproject.org Cc: Tu Dinh Ngoc Subject: [PATCH 1/2] x86: Parse Multiboot2 framebuffer information Date: Wed, 9 Feb 2022 14:09:06 +0100 Message-Id: <20220209130907.252-2-dinhngoc.tu@irit.fr> In-Reply-To: <20220209130907.252-1-dinhngoc.tu@irit.fr> References: <20220209130907.252-1-dinhngoc.tu@irit.fr> Multiboot2 exposes framebuffer data in its boot information tags. Xen requests this information from the bootloader, but does not make use of it. Parse this information for later use. --- xen/arch/x86/boot/reloc.c | 22 ++++++++++++++++++++++ xen/include/xen/multiboot.h | 17 +++++++++++++++++ xen/include/xen/multiboot2.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 4f4039bb7c..01a53d3ae5 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -156,6 +156,8 @@ static multiboot_info_t *mbi2_reloc(u32 mbi_in) multiboot_info_t *mbi_out; u32 ptr; unsigned int i, mod_idx = 0; + u64 fbaddr; + u8 fbtype; ptr = alloc_mem(sizeof(*mbi_out)); mbi_out = _p(ptr); @@ -254,6 +256,26 @@ static multiboot_info_t *mbi2_reloc(u32 mbi_in) ++mod_idx; break; + case MULTIBOOT2_TAG_TYPE_FRAMEBUFFER: + fbaddr = get_mb2_data(tag, framebuffer, framebuffer_addr); + fbtype = get_mb2_data(tag, framebuffer, framebuffer_type); + if (fbaddr == 0 || fbtype != MULTIBOOT2_FRAMEBUFFER_TYPE_RGB) + break; + mbi_out->flags |= MBI_FB; + mbi_out->fb.addr = fbaddr; + mbi_out->fb.pitch = get_mb2_data(tag, framebuffer, framebuffer_pitch); + mbi_out->fb.width = get_mb2_data(tag, framebuffer, framebuffer_width); + mbi_out->fb.height = get_mb2_data(tag, framebuffer, framebuffer_height); + mbi_out->fb.bpp = get_mb2_data(tag, framebuffer, framebuffer_bpp); + mbi_out->fb.type = fbtype; + mbi_out->fb.red_pos = get_mb2_data(tag, framebuffer, framebuffer_red_field_position); + mbi_out->fb.red_size = get_mb2_data(tag, framebuffer, framebuffer_red_mask_size); + mbi_out->fb.green_pos = get_mb2_data(tag, framebuffer, framebuffer_green_field_position); + mbi_out->fb.green_size = get_mb2_data(tag, framebuffer, framebuffer_green_mask_size); + mbi_out->fb.blue_pos = get_mb2_data(tag, framebuffer, framebuffer_blue_field_position); + mbi_out->fb.blue_size = get_mb2_data(tag, framebuffer, framebuffer_blue_mask_size); + break; + case MULTIBOOT2_TAG_TYPE_END: return mbi_out; diff --git a/xen/include/xen/multiboot.h b/xen/include/xen/multiboot.h index d1b43e1183..2d829b5fa7 100644 --- a/xen/include/xen/multiboot.h +++ b/xen/include/xen/multiboot.h @@ -42,6 +42,7 @@ #define MBI_BIOSCONFIG (_AC(1,u) << 8) #define MBI_LOADERNAME (_AC(1,u) << 9) #define MBI_APM (_AC(1,u) << 10) +#define MBI_FB (_AC(1,u) << 11) #ifndef __ASSEMBLY__ @@ -101,6 +102,22 @@ typedef struct { /* Valid if flags sets MBI_APM */ u32 apm_table; + + /* Valid if flags sets MBI_FB */ + struct { + u64 addr; + u32 pitch; + u32 width; + u32 height; + u8 bpp; + u8 type; + u8 red_pos; + u8 red_size; + u8 green_pos; + u8 green_size; + u8 blue_pos; + u8 blue_size; + } fb; } multiboot_info_t; /* The module structure. */ diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h index 5acd225044..a86a080038 100644 --- a/xen/include/xen/multiboot2.h +++ b/xen/include/xen/multiboot2.h @@ -177,6 +177,39 @@ typedef struct { u32 mod_end; char cmdline[]; } multiboot2_tag_module_t; + +typedef struct { + u8 red; + u8 green; + u8 blue; +} multiboot2_framebuffer_color_t; + +typedef struct { + u32 type; + u32 size; + u64 framebuffer_addr; + u32 framebuffer_pitch; + u32 framebuffer_width; + u32 framebuffer_height; + u8 framebuffer_bpp; + u8 framebuffer_type; + u16 reserved; + + union { + struct { + u16 framebuffer_palette_num_colors; + multiboot2_framebuffer_color_t framebuffer_palette[0]; + }; + struct { + u8 framebuffer_red_field_position; + u8 framebuffer_red_mask_size; + u8 framebuffer_green_field_position; + u8 framebuffer_green_mask_size; + u8 framebuffer_blue_field_position; + u8 framebuffer_blue_mask_size; + }; + }; +} multiboot2_tag_framebuffer_t; #endif /* __ASSEMBLY__ */ #endif /* __MULTIBOOT2_H__ */