gfxpayload
PATCH 1/1 gfxpayload
Hello. Here is a long-discussed gfxpayload patch. To start linux in 1024x768 mode do:
insmod vbe
gfxmode=1024x768
linux ...
...
boot
Multiple modes can be separated by either comma or semicolon. First mode can be "keep" which will make the system keep the current mode if accepted by kernel. Another special value is "text" which will put in text mode.
Can someone check that vga= backward compatibility code interprets values correctly?
With linux for a reason I don't know it results in black screen in qemu. But perhaps it's a problem with my kernel
Now it's the same syntax for xnu too. Just remember that current xnu loader support 32-bit modes only
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
commands/videotest.c +1 -2
@@ -30,8 +30,7 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { -if (grub_video_setup (1024 ,768 , -GRUB_VIDEO_MODE_TYPE_INDEX_COLOR ) !=GRUB_ERR_NONE ) +if (grub_video_set_mode ("1024x768;800x600;640x480" ,0 ) !=GRUB_ERR_NONE )return grub_errno;grub_video_color_t color;
include/grub/video.h +5 -3
@@ -34,6 +34,7 @@ struct grub_video_render_target;struct grub_video_bitmap ;/* Defines used to describe video mode or rendering target. */ +#define GRUB_VIDEO_MODE_TYPE_PURE_TEXT 0x00000040#define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000020#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED 0x00000010#define GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP 0x00000004
@@ -236,9 +237,6 @@ void grub_video_register (grub_video_adapter_t adapter);void grub_video_unregister (grub_video_adapter_t adapter);void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter)); -grub_err_t grub_video_setup (unsigned int width,unsigned int height, -unsigned int mode_type); -grub_err_t grub_video_restore (void );grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
@@ -299,4 +297,8 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_targetgrub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target); +grub_err_t grub_video_set_mode (char *modestring, + int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p, +struct grub_video_mode_info *mode_info)); +#endif /* ! GRUB_VIDEO_HEADER */
loader/i386/linux.c +59 -50
167 lines not on this page · raw message
loader/i386/pc/xnu.c +31 -0
@@ -19,6 +19,7 @@#include <grub/env.h> #include <grub/misc.h> #include <grub/xnu.h> +#include <grub/mm.h> #include <grub/cpu/xnu.h> #include <grub/machine/vbe.h> #include <grub/machine/vga.h>
@@ -26,6 +27,17 @@#define min (a,b) (((a) < (b)) ? (a) : (b))#define max (a,b) (((a) > (b)) ? (a) : (b)) +#define DEFAULT_VIDEO_MODE "1024x768x32,800x600x32,640x480x32" + +static int NESTED_FUNC_ATTR video_hook (grub_video_adapter_t p __attribute__ ((unused)), +struct grub_video_mode_info *info) +{ +if (info->mode_type &GRUB_VIDEO_MODE_TYPE_PURE_TEXT ) +return 0 ; + +return 1 ; +} +/* Setup video for xnu. */ grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *params)
@@ -34,8 +46,27 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)struct grub_video_render_target *render_target;int ret;int x,y; +char *tmp, *modevar;grub_err_t err; + modevar =grub_env_get ("gfxpayload" ); +if (! modevar || *modevar ==0 ) + err =grub_video_set_mode (DEFAULT_VIDEO_MODE , video_hook); +else + { + tmp =grub_malloc (grub_strlen (modevar) + +sizeof (DEFAULT_VIDEO_MODE ) +1 ); +if (! tmp) +return grub_error (GRUB_ERR_OUT_OF_MEMORY , +"couldn't allocate temporary storag" ); +grub_sprintf (tmp,"%s;" DEFAULT_VIDEO_MODE , modevar); + err =grub_video_set_mode (tmp, video_hook); +grub_free (tmp); + } + +if (err) +return err; + ret =grub_video_get_info (&mode_info);if (ret)return grub_error (GRUB_ERR_IO ,"couldn't retrieve video parameters" );
term/gfxterm.c +25 -229
282 lines not on this page · raw message
util/grub.d/30_os-prober.in +0 -3
@@ -90,9 +90,6 @@ EOF menuentry "${LONGNAME} (on ${DEVICE})" { set root=${OSXROOT} insmod vbe - insmod gfxterm - gfxmode="1024x768x32;800x600x32" - terminal_output gfxterm do_resume=0 if [ /var/vm/sleepimage -nt10 / ]; then if xnu_resume /var/vm/sleepimage; then
video/video.c +315 -53
386 lines not on this page · raw message
Am Samstag, den 16.05.2009, 20:01 +0200 schrieb Vladimir 'phcoder' Serbinenko:
Quoted 9 lines
Hello. Here is a long-discussed gfxpayload patch. To start linux in 1024x768 mode do:
insmod vbe
gfxmode=1024x768
linux ...
...
boot
Multiple modes can be separated by either comma or semicolon. First mode can be "keep" which will make the system keep the current mode if
Quoted 8 lines
accepted by kernel. Another special value is "text" which will put in text mode.
Can someone check that vga= backward compatibility code interprets values correctly?
With linux for a reason I don't know it results in black screen in qemu. But perhaps it's a problem with my kernel
Now it's the same syntax for xnu too. Just remember that current xnu loader support 32-bit modes only
Just tried it in VMware.
With set gfxmode=1024x768x24 and set gfxpayload=1024x768x24 and no vga= option I just get the normal text mode
with set gfxpayload=keep it works
and also vga=0x317 works too.
Signature · 1 line
Felix Zielcke
Quoted 5 lines
Just tried it in VMware.
With set gfxmode=1024x768x24 and set gfxpayload=1024x768x24 and no vga= option I just get the normal text mode
with set gfxpayload=keep it works
and also vga=0x317 works too.
As we figured out on IRC the problem was that vmware has no 16-bit. New patch with fixed vga=0 and warning for users when using vga=
Quoted 10 lines
--
Felix Zielcke_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
commands/videotest.c +1 -2
@@ -30,8 +30,7 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { -if (grub_video_setup (1024 ,768 , -GRUB_VIDEO_MODE_TYPE_INDEX_COLOR ) !=GRUB_ERR_NONE ) +if (grub_video_set_mode ("1024x768;800x600;640x480" ,0 ) !=GRUB_ERR_NONE )return grub_errno;grub_video_color_t color;
include/grub/video.h +5 -3
@@ -34,6 +34,7 @@ struct grub_video_render_target;struct grub_video_bitmap ;/* Defines used to describe video mode or rendering target. */ +#define GRUB_VIDEO_MODE_TYPE_PURE_TEXT 0x00000040#define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000020#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED 0x00000010#define GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP 0x00000004
@@ -236,9 +237,6 @@ void grub_video_register (grub_video_adapter_t adapter);void grub_video_unregister (grub_video_adapter_t adapter);void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter)); -grub_err_t grub_video_setup (unsigned int width,unsigned int height, -unsigned int mode_type); -grub_err_t grub_video_restore (void );grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
@@ -299,4 +297,8 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_targetgrub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target); +grub_err_t grub_video_set_mode (char *modestring, + int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p, +struct grub_video_mode_info *mode_info)); +#endif /* ! GRUB_VIDEO_HEADER */
loader/i386/linux.c +76 -50
184 lines not on this page · raw message
loader/i386/pc/xnu.c +31 -0
@@ -19,6 +19,7 @@#include <grub/env.h> #include <grub/misc.h> #include <grub/xnu.h> +#include <grub/mm.h> #include <grub/cpu/xnu.h> #include <grub/machine/vbe.h> #include <grub/machine/vga.h>
@@ -26,6 +27,17 @@#define min (a,b) (((a) < (b)) ? (a) : (b))#define max (a,b) (((a) > (b)) ? (a) : (b)) +#define DEFAULT_VIDEO_MODE "1024x768x32,800x600x32,640x480x32" + +static int NESTED_FUNC_ATTR video_hook (grub_video_adapter_t p __attribute__ ((unused)), +struct grub_video_mode_info *info) +{ +if (info->mode_type &GRUB_VIDEO_MODE_TYPE_PURE_TEXT ) +return 0 ; + +return 1 ; +} +/* Setup video for xnu. */ grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *params)
@@ -34,8 +46,27 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)struct grub_video_render_target *render_target;int ret;int x,y; +char *tmp, *modevar;grub_err_t err; + modevar =grub_env_get ("gfxpayload" ); +if (! modevar || *modevar ==0 ) + err =grub_video_set_mode (DEFAULT_VIDEO_MODE , video_hook); +else + { + tmp =grub_malloc (grub_strlen (modevar) + +sizeof (DEFAULT_VIDEO_MODE ) +1 ); +if (! tmp) +return grub_error (GRUB_ERR_OUT_OF_MEMORY , +"couldn't allocate temporary storag" ); +grub_sprintf (tmp,"%s;" DEFAULT_VIDEO_MODE , modevar); + err =grub_video_set_mode (tmp, video_hook); +grub_free (tmp); + } + +if (err) +return err; + ret =grub_video_get_info (&mode_info);if (ret)return grub_error (GRUB_ERR_IO ,"couldn't retrieve video parameters" );
term/gfxterm.c +25 -229
282 lines not on this page · raw message
util/grub.d/30_os-prober.in +0 -3
@@ -90,9 +90,6 @@ EOF menuentry "${LONGNAME} (on ${DEVICE})" { set root=${OSXROOT} insmod vbe - insmod gfxterm - gfxmode="1024x768x32;800x600x32" - terminal_output gfxterm do_resume=0 if [ /var/vm/sleepimage -nt10 / ]; then if xnu_resume /var/vm/sleepimage; then
video/video.c +315 -53
386 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
loader/i386/linux.c line 50
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
#ifndef
GRUB_ASSUME_LINUX_HAS_FB_SUPPORTloader/i386/linux.c +3
-1-#define GRUB_ASSUME_LINUX_HAS_FB_SUPPORT 0 +#define DEFAULT_VIDEO_MODE "text" +#else +#define DEFAULT_VIDEO_MODE "keep"#endif
As discussed on IRC, this "keep" option seems unnecessary; it just means "do nothing" so we may as well #ifdef the code out.
Review
Quoted 2 lines
(quoted diff) +2
-0+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, + "couldn't allocate temporary storag");
Typo.
loader/i386/linux.c grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
Quoted 12 lines
loader/i386/linux.c +2
-2if (grub_strcmp (val,"normal" ) ==0 ) - vid_mode =GRUB_LINUX_VID_MODE_NORMAL ; + vid_mode =0 ;else if (grub_strcmp (val,"ext" ) ==0 ) - vid_mode =GRUB_LINUX_VID_MODE_EXTENDED ; + vid_mode =1 ;switch (vid_mode) {case 0 :case 1 :
Can we avoid encoding this information as numbers? We had nice macros before, and plain numbers are confusing to read for those not familiar with the code.
Review
Quoted 2 lines
(quoted diff) +2
-0+ grub_env_set ("gfxpayload", "text"); + grub_printf ("%s is depreceated. "
Typo ;-)
loader/i386/linux.c grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), · line 763
Quoted 7 lines
loader/i386/linux.c +7
-0+ buf =grub_malloc (20 ); +if (! buf) + { +grub_error (GRUB_ERR_OUT_OF_MEMORY , +"couldn't allocate temporary storage" ); + goto fail; + }
Doesn't grub_malloc set this errno / errmsg already?
term/gfxterm.c line 30
Quoted 11 lines
term/gfxterm.c +1
-4@@ -27,10 +27,7 @@#include <grub/bitmap.h> #include <grub/command.h> -#define DEFAULT_VIDEO_WIDTH 640 -#define DEFAULT_VIDEO_HEIGHT 480 -#define DEFAULT_VIDEO_FLAGS 0 - +#define DEFAULT_VIDEO_MODE "1024x768,800x600,640x480"
Our fonts / texts / menus in general are not prepared to cope well with resolutions higher than 640x480. It works, but looks different/ugly. Please leave that as default untill we solve those problems.
Wrt changes in the video subsystem, as discussed on IRC this was discussed before (me and Vesa, I think) and Vesa said he wanted to think about it. Would be nice if we can reach consensus on this, and someone who's familiarised with that area (not me) could approve those changes.
But Vesa is on vacation... maybe Colin? I don't know. Try CCing them :-)
Thanks!
Signature · 5 lines
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."
Robert Millan wrote on Sunday 17 May 2009:
Quoted 3 lines
Hi,
On Sun, May 17, 2009 at 04:34:16PM +0200, Vladimir 'phcoder' Serbinenko
Quoted 6 lines · wrote:
Quoted 6 lines
term/gfxterm.c +0
-0@@ -27,10 +27,7 @@#include <grub/bitmap.h> #include <grub/command.h>
Quoted 9 lines
term/gfxterm.c line 30
Quoted 5 lines
term/gfxterm.c +1
-4-#define DEFAULT_VIDEO_WIDTH 640 -#define DEFAULT_VIDEO_HEIGHT 480 -#define DEFAULT_VIDEO_FLAGS 0 - +#define DEFAULT_VIDEO_MODE "1024x768,800x600,640x480"Our fonts / texts / menus in general are not prepared to cope well with resolutions higher than 640x480. It works, but looks different/ugly. Please leave that as default untill we solve those problems.
I think the main problems at present are (1) the only provided font is GNU Unifont, which is fairly small (but I think it should work ok at sizes around 1024x768) and (2) my graphical menu themes currently support only absolute pixel positioning, so when the screen size is changed, they don't adapt (I really want to implement some sort of layout management system to handle component layout consistently in the GUI).
Quoted 6 lines
Wrt changes in the video subsystem, as discussed on IRC this was discussed before (me and Vesa, I think) and Vesa said he wanted to think about it. Would be nice if we can reach consensus on this, and someone who's familiarised with that area (not me) could approve those changes.
But Vesa is on vacation... maybe Colin? I don't know. Try CCing them :-)
I think your grub_video_set_mode() is a good change. In fact, I also moved that mode selection code out of gfxterm and into the video API in my graphical menu branch.
It seems to me that there aren't significant changes to the video subsystem except that grub_video_setmode(width, height, mode_type) is removed and replaced with a function that takes only a mode list string. I think this is fine since we should (once we get the above-mentioned issues resolved to support various resolutions properly) never hard-code video mode info (except for the 'videotest' command, perhaps; rather it should always be sourced from the user configuration, which means it will be a mode list string anyway.
I had a minor comment regarding the patch:
--- a/video/video.c
+++ b/video/video.c
...
+grub_err_t
+grub_video_set_mode (char *modestring,
+ int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
+ struct grub_video_mode_info *mode_info))
+{
+ char *tmp; + char *next_mode; + char *current_mode; + char *param; + char *value; + char *modevar; + int width = -1; + int height = -1; + int depth = -1; + int flags = 0;
+
+ /* Take copy of env.var. as we don't want to modify that. */
+ modevar = grub_strdup (modestring);
Since this is called in cases where 'modestring' is not an environment variable, maybe it's more correct to just say, "Copy the mode list argument because it will be modified."
I would declare modestring as 'const char *' to prevent accidental modification, especially since there is code that passes string constants for modestring.
Regards,
Colin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 14 lines · Vladimir 'phcoder' Serbinenko
Quoted 4 lines · Robert Millan
Hi,
On Sun, May 17, 2009 at 04:34:16PM +0200, Vladimir 'phcoder' Serbinenko wrote:
Quoted 9 lines
Quoted 6 lines
#ifndef
GRUB_ASSUME_LINUX_HAS_FB_SUPPORTloader/i386/linux.c +3
-1-#define GRUB_ASSUME_LINUX_HAS_FB_SUPPORT 0 +#define DEFAULT_VIDEO_MODE "text" +#else +#define DEFAULT_VIDEO_MODE "keep"#endif
As discussed on IRC, this "keep" option seems unnecessary; it just means "do nothing" so we may as well #ifdef the code out.
Quoted 4 lines
It may be necessary in future for linux loader to be able to check if current mode is acceptable for linux (e.g. vnc is not). xnu code does this (text mode isn't acceptable). But for now calling with keep can be put in ifdef..endif
Maybe, but there's no point in some part of GRUB telling another routine "please do nothing, leave things as they are" when it could just not call it instead. It just wastes execution time.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
+
grub_error(GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't allocate temporary storage");
+ goto fail;
+ }Doesn't
grub_mallocset this errno / errmsg already?It says "out of memory" but I guess it should be clear enough.
If it's not, it should be fixed in kern/mm.c. There's nothing specific to linux.c in this problem.
Signature · 5 lines
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."