From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LiDJe-0007pk-B1 for mharc-grub-devel@gnu.org; Fri, 13 Mar 2009 15:45:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LiDJa-0007or-Q6 for grub-devel@gnu.org; Fri, 13 Mar 2009 15:45:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LiDJV-0007oH-C0 for grub-devel@gnu.org; Fri, 13 Mar 2009 15:45:05 -0400 Received: from [199.232.76.173] (port=45326 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LiDJV-0007oE-5n for grub-devel@gnu.org; Fri, 13 Mar 2009 15:45:01 -0400 Received: from aybabtu.com ([69.60.117.155]:49023) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LiDJU-00034a-MX for grub-devel@gnu.org; Fri, 13 Mar 2009 15:45:00 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1LiDAw-0008Og-JY for grub-devel@gnu.org; Fri, 13 Mar 2009 20:36:15 +0100 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1LiDJI-0008R0-04 for grub-devel@gnu.org; Fri, 13 Mar 2009 20:44:48 +0100 Date: Fri, 13 Mar 2009 20:44:47 +0100 From: Robert Millan To: The development of GRUB 2 Message-ID: <20090313194447.GA17416@thorin> References: <20090306195735.GA9992@thorin> <20090308130106.GC28707@thorin> <49B3C9A2.3050101@nic.fi> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <49B3C9A2.3050101@nic.fi> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] linux/gfxterm integration X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2009 19:45:06 -0000 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sun, Mar 08, 2009 at 03:35:30PM +0200, Vesa Jääskeläinen wrote: > Robert Millan wrote: > >> Note: As the comment in grub/video.h says, struct grub_video_render_target > >> didn't really want to be moved. My code only needs to access it to find > >> the framebuffer address. Perhaps it'd be better to move this information > >> elsewhere? Or split it in a separate structure / getter? > > > > Any comments on my question about struct grub_video_render_target ? > > Don't like em... Let me think it a bit. This new patch avoids the problem by accessing struct grub_video_render_target from its current location. When we have more than one video backend, and a clear idea on which parts are generic and which are backend-specific, we could readjust. For now this makes VBE happy. Thoughts? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="linux_gfxterm.diff" 2009-03-13 Robert Millan * loader/i386/linux.c: Include `' and `'.. (grub_linux_setup_video): New function. Loosely based on the EFI one. (grub_linux32_boot): Attempt to configure video settings with grub_linux_setup_video(). (grub_rescue_cmd_linux): Set noreturn=0 in grub_loader_set, in order to avoid grub_console_fini() which would step out of graphical mode unconditionally. Index: loader/i386/linux.c =================================================================== --- loader/i386/linux.c (revision 2030) +++ loader/i386/linux.c (working copy) @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,10 @@ #include #include #include +#include +/* FIXME: the definition of `struct grub_video_render_target' is + VBE-specific. */ +#include #define GRUB_LINUX_CL_OFFSET 0x1000 #define GRUB_LINUX_CL_END_OFFSET 0x2000 @@ -215,6 +219,41 @@ grub_e820_add_region (struct grub_e820_m } } +static int +grub_linux_setup_video (struct linux_kernel_params *params) +{ + struct grub_video_mode_info mode_info; + struct grub_video_render_target *render_target; + int ret; + + ret = grub_video_get_info (&mode_info); + if (ret) + return 1; + + ret = grub_video_get_active_render_target (&render_target); + if (ret) + return 1; + + params->lfb_width = mode_info.width; + params->lfb_height = mode_info.height; + params->lfb_depth = mode_info.bpp; + params->lfb_line_len = mode_info.pitch; + + params->lfb_base = (void *) render_target->data; + params->lfb_size = (params->lfb_line_len * params->lfb_height + 65535) >> 16; + + params->red_mask_size = 8; + params->red_field_pos = 16; + params->green_mask_size = 8; + params->green_field_pos = 8; + params->blue_mask_size = 8; + params->blue_field_pos = 0; + params->reserved_mask_size = 8; + params->reserved_field_pos = 24; + + return 0; +} + #ifdef __x86_64__ struct { @@ -231,6 +270,9 @@ grub_linux32_boot (void) params = real_mode_mem; + if (! grub_linux_setup_video (params)) + params->have_vga = GRUB_VIDEO_TYPE_VLFB; + grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", (unsigned) params->code32_start, (unsigned long) &(idt_desc.limit), @@ -314,7 +356,6 @@ grub_rescue_cmd_linux (int argc, char *a grub_ssize_t len; int i; char *dest; - int video_type; grub_dl_ref (my_mod); @@ -422,7 +463,6 @@ grub_rescue_cmd_linux (int argc, char *a /* Detect explicitly specified memory size, if any. */ linux_mem_size = 0; - video_type = 0; for (i = 1; i < argc; i++) if (grub_memcmp (argv[i], "mem=", 4) == 0) { @@ -481,7 +521,8 @@ grub_rescue_cmd_linux (int argc, char *a if (grub_errno == GRUB_ERR_NONE) { - grub_loader_set (grub_linux32_boot, grub_linux_unload, 1); + grub_loader_set (grub_linux32_boot, grub_linux_unload, + 0 /* set noreturn=0 in order to avoid grub_console_fini() */); loaded = 1; } --3V7upXqbjpZ4EhLz--