Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MUfgG-000278-SS for mharc-grub-devel@gnu.org; Sat, 25 Jul 2009 07:44:48 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUfgE-000273-Ki for grub-devel@gnu.org; Sat, 25 Jul 2009 07:44:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUfg9-00026o-0F for grub-devel@gnu.org; Sat, 25 Jul 2009 07:44:45 -0400 Received: from [199.232.76.173] (port=43663 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUfg8-00026l-Ra for grub-devel@gnu.org; Sat, 25 Jul 2009 07:44:40 -0400 Received: from aybabtu.com ([69.60.117.155]:43951) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MUfg8-0000TN-EV for grub-devel@gnu.org; Sat, 25 Jul 2009 07:44:40 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MUea6-0001H7-1h for grub-devel@gnu.org; Sat, 25 Jul 2009 12:34:22 +0200 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1MUfg5-0003eT-Oo for grub-devel@gnu.org; Sat, 25 Jul 2009 13:44:37 +0200 Date: Sat, 25 Jul 2009 13:44:37 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20090725114437.GA11825@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" Content-Disposition: inline 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: GNU/Linux 2.6 (newer, 1) Subject: [PATCH] DAC palette width retrieval 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: Sat, 25 Jul 2009 11:44:46 -0000 --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When using packed color modes, Linux expects we fill the color sizes with the value obtained from the DAC. If we give it zeroes (like we currently do) it displays a blank screen. This can be reproduced by attempting to boot Linux with a 8-bit color mode (e.g. set gfxpayload=800x600x8). Now I'm not completely sure where does this belong. I think it's somewhat generic and we can reasonably expect other OSes to want this information too, but I'm not completely sure. An alternative would be to do this query in the Linux loader, but this has the disadvantage that we're putting backend-specific code in the loader which aims to be completely backend-independant someday. Also, tell me what you think about the "getset" hack. It looks like a clean way of providing both functions in less space, but then I'm not sure if we really want both functions. For now we only use the "set" one. Then again, once you have "set" getting "get" comes really cheap. -- 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." --wac7ysb48OaltWcw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="008_dac_palette_width.diff" Index: kern/i386/pc/startup.S =================================================================== --- kern/i386/pc/startup.S (revision 2439) +++ kern/i386/pc/startup.S (working copy) @@ -1733,6 +1733,52 @@ ret /* + * grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size) + * + * Register allocations for parameters: + * %eax set + * %edx *dac_mask_size + */ +FUNCTION(grub_vbe_bios_getset_dac_palette_width) + pushl %ebp + pushl %ebx + + xorl %ebx, %ebx + + /* If we only want to fetch the value, set %bl to 1. */ + testl %eax, %eax + jne 1f + incb %bl +1: + + /* Put desired width in %bh. */ + movl (%edx), %eax + movb %al, %bh + + call prot_to_real + .code16 + + movw $0x4f08, %ax + int $0x10 + + movw %ax, %dx /* real_to_prot destroys %eax. */ + + DATA32 call real_to_prot + .code32 + + /* Move result back to *dac_mask_size. */ + movb %bh, %al + movl %eax, (%edx) + + /* Return value in %eax. */ + xorl %eax, %eax + movw %dx, %ax + + popl %ebx + popl %ebp + ret + +/* * grub_vbe_status_t grub_vbe_bios_set_memory_window (grub_uint32_t window, * grub_uint32_t position); * Index: video/i386/pc/vbe.c =================================================================== --- video/i386/pc/vbe.c (revision 2439) +++ video/i386/pc/vbe.c (working copy) @@ -300,6 +300,24 @@ /* Make copy of mode info block. */ grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info)); + + /* Packed mode. Query DAC Palette width for color sizes. */ + if (mode_info->bits_per_pixel <= 8) + { + int width = 8; + status = 0; + + if (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH) + status = grub_vbe_bios_set_dac_palette_width (& width); + + if (status != 0x004F) + /* 6 is default after mode reset. */ + width = 6; + + mode_info->red_mask_size = mode_info->green_mask_size + = mode_info->blue_mask_size = mode_info->rsvd_mask_size + = width; + } } else /* Just clear mode info block if it isn't a VESA mode. */ Index: include/grub/i386/pc/vbe.h =================================================================== --- include/grub/i386/pc/vbe.h (revision 2439) +++ include/grub/i386/pc/vbe.h (working copy) @@ -30,6 +30,8 @@ /* VBE status codes. */ #define GRUB_VBE_STATUS_OK 0x004f +#define GRUB_VBE_CAPABILITY_DACWIDTH (1 << 0) + /* Bits from the GRUB_VBE "mode_attributes" field in the mode info struct. */ #define GRUB_VBE_MODEATTR_SUPPORTED (1 << 0) #define GRUB_VBE_MODEATTR_RESERVED_1 (1 << 1) @@ -181,6 +183,11 @@ grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_mode_info) (grub_uint32_t mode, struct grub_vbe_mode_info_block *mode_info); +grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_getset_dac_palette_width) (int set, int *width); + +#define grub_vbe_bios_get_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(0, (width)) +#define grub_vbe_bios_set_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(1, (width)) + /* Call VESA BIOS 0x4f02 to set video mode, return status. */ grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_mode) (grub_uint32_t mode, struct grub_vbe_crtc_info_block *crtc_info); --wac7ysb48OaltWcw--