Skip to contentSkip to conversation

linux/gfxterm integration

PATCH In review Robert Millan 6 participants 19 messages Mar 6, 2009 – Apr 1, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/gfxterm integration

This patch integrates the generic Linux loader with gfxterm. The result is that graphical mode becomes usable with this loader. Our loader gets the screen settings from the video subsystem (as per gfxterm setup), and passes them to Linux.

This way GRUB/gfxterm can transition to Linux/fb with no further mode setting. Perhaps this can be exploited to make the transition seamless by using the same background image in both places, but I haven't explored this possibility yet :-)

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?

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."

2009-03-06 Robert Millan <[email protected]>

* include/grub/i386/pc/vbe.h (struct grub_video_render_target): Move from here ...
* include/grub/video.h (struct grub_video_render_target): ... to here.

* loader/i386/linux.c: Inclue `<grub/video.h>'. (grub_linux_setup_video): New function. Loosely based on the EFI one. (grub_rescue_cmd_linux): Attempt to configure video settings with grub_linux_setup_video().
Set noreturn=0 in grub_loader_set, in order to avoid grub_console_fini() which would step out of graphical mode unconditionally.

grub/i386/pc/vbe.h +0 -23
Index: include/grub/i386/pc/vbe.h
===================================================================
@@ -227,29 +227,6 @@ grub_err_t grub_vbe_get_video_mode_info 
 /* VBE module internal prototypes (should not be used from elsewhere).  */
 struct grub_video_i386_vbeblit_info;
 
-struct grub_video_render_target
-{
-  /* Copy of the screen's mode info structure, except that width, height and
-     mode_type has been re-adjusted to requested render target settings.  */
-  struct grub_video_mode_info mode_info;
-
-  struct
-  {
-    unsigned int x;
-    unsigned int y;
-    unsigned int width;
-    unsigned int height;
-  } viewport;
-
-  /* Indicates whether the data has been allocated by us and must be freed
-     when render target is destroyed.  */
-  int is_allocated;
-
-  /* Pointer to data.  Can either be in video card memory or in local host's
-     memory.  */
-  void *data;
-};
-
 grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source,
                                              grub_uint32_t x, grub_uint32_t y);
 
grub/video.h +23 -4
Index: include/grub/video.h
===================================================================
@@ -26,10 +26,6 @@
    specific coding format.  */
 typedef grub_uint32_t grub_video_color_t;
 
-/* This structure is driver specific and should not be accessed directly by
-   outside code.  */
-struct grub_video_render_target;
-
 /* Forward declarations for used data structures.  */
 struct grub_video_bitmap;
 
@@ -152,6 +148,29 @@ struct grub_video_mode_info
   grub_uint8_t fg_alpha;
 };
 
+struct grub_video_render_target
+{
+  /* Copy of the screen's mode info structure, except that width, height and
+     mode_type has been re-adjusted to requested render target settings.  */
+  struct grub_video_mode_info mode_info;
+
+  struct
+  {
+    unsigned int x;
+    unsigned int y;
+    unsigned int width;
+    unsigned int height;
+  } viewport;
+
+  /* Indicates whether the data has been allocated by us and must be freed
+     when render target is destroyed.  */
+  int is_allocated;
+
+  /* Pointer to data.  Can either be in video card memory or in local host's
+     memory.  */
+  void *data;
+};
+
 struct grub_video_palette_data
 {
   grub_uint8_t r; /* Red color value (0-255).  */
i386/linux.c +42 -4

87 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · Robert Millan

This patch integrates the generic Linux loader with gfxterm. The result is that graphical mode becomes usable with this loader. Our loader gets the screen settings from the video subsystem (as per gfxterm setup), and passes them to Linux.

This way GRUB/gfxterm can transition to Linux/fb with no further mode setting. Perhaps this can be exploited to make the transition seamless by using the same background image in both places, but I haven't explored this possibility yet :-)

Quoted 4 lines

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?

New patch. This one calls grub_linux_setup_video() from grub_linux32_boot instead of grub_rescue_cmd_linux. This way it gets the video status we have when "boot" is issued instead of the one we have when linux is loaded.

Any comments on my question about struct grub_video_render_target ?

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."
#2 lore raw

Sorry, forgot to attach it.

Quoted 29 lines · Robert Millan
Quoted 11 lines · Robert Millan

This patch integrates the generic Linux loader with gfxterm. The result is that graphical mode becomes usable with this loader. Our loader gets the screen settings from the video subsystem (as per gfxterm setup), and passes them to Linux.

This way GRUB/gfxterm can transition to Linux/fb with no further mode setting. Perhaps this can be exploited to make the transition seamless by using the same background image in both places, but I haven't explored this possibility yet :-)

Quoted 4 lines

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?

New patch. This one calls grub_linux_setup_video() from grub_linux32_boot instead of grub_rescue_cmd_linux. This way it gets the video status we have when "boot" is issued instead of the one we have when linux is loaded.

Any comments on my question about struct grub_video_render_target ?

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."
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."

2009-03-06 Robert Millan <[email protected]>

* include/grub/i386/pc/vbe.h (struct grub_video_render_target): Move from here ...
* include/grub/video.h (struct grub_video_render_target): ... to here.

* loader/i386/linux.c: Inclue `<grub/video.h>'. (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.

grub/i386/pc/vbe.h +0 -23
Index: include/grub/i386/pc/vbe.h
===================================================================
@@ -227,29 +227,6 @@ grub_err_t grub_vbe_get_video_mode_info 
 /* VBE module internal prototypes (should not be used from elsewhere).  */
 struct grub_video_i386_vbeblit_info;
 
-struct grub_video_render_target
-{
-  /* Copy of the screen's mode info structure, except that width, height and
-     mode_type has been re-adjusted to requested render target settings.  */
-  struct grub_video_mode_info mode_info;
-
-  struct
-  {
-    unsigned int x;
-    unsigned int y;
-    unsigned int width;
-    unsigned int height;
-  } viewport;
-
-  /* Indicates whether the data has been allocated by us and must be freed
-     when render target is destroyed.  */
-  int is_allocated;
-
-  /* Pointer to data.  Can either be in video card memory or in local host's
-     memory.  */
-  void *data;
-};
-
 grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source,
                                              grub_uint32_t x, grub_uint32_t y);
 
grub/video.h +23 -4
Index: include/grub/video.h
===================================================================
@@ -26,10 +26,6 @@
    specific coding format.  */
 typedef grub_uint32_t grub_video_color_t;
 
-/* This structure is driver specific and should not be accessed directly by
-   outside code.  */
-struct grub_video_render_target;
-
 /* Forward declarations for used data structures.  */
 struct grub_video_bitmap;
 
@@ -152,6 +148,29 @@ struct grub_video_mode_info
   grub_uint8_t fg_alpha;
 };
 
+struct grub_video_render_target
+{
+  /* Copy of the screen's mode info structure, except that width, height and
+     mode_type has been re-adjusted to requested render target settings.  */
+  struct grub_video_mode_info mode_info;
+
+  struct
+  {
+    unsigned int x;
+    unsigned int y;
+    unsigned int width;
+    unsigned int height;
+  } viewport;
+
+  /* Indicates whether the data has been allocated by us and must be freed
+     when render target is destroyed.  */
+  int is_allocated;
+
+  /* Pointer to data.  Can either be in video card memory or in local host's
+     memory.  */
+  void *data;
+};
+
 struct grub_video_palette_data
 {
   grub_uint8_t r; /* Red color value (0-255).  */
i386/linux.c +42 -4

87 lines not on this page · raw message

#3 lore raw
In reply to Robert Millan
Quoted 16 lines · Robert Millan
Quoted 10 lines · Robert Millan

This patch integrates the generic Linux loader with gfxterm. The result is that graphical mode becomes usable with this loader. Our loader gets the screen settings from the video subsystem (as per gfxterm setup), and passes them to Linux.

This way GRUB/gfxterm can transition to Linux/fb with no further mode setting. Perhaps this can be exploited to make the transition seamless by using the same background image in both places, but I haven't explored this possibility yet :-)

Quoted 4 lines

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?

Quoted 5 lines

New patch. This one calls grub_linux_setup_video() from grub_linux32_boot instead of grub_rescue_cmd_linux. This way it gets the video status we have when "boot" is issued instead of the one we have when linux is loaded.

Any comments on my question about struct grub_video_render_target ?

Don't like em... Let me think it a bit.

#4 lore raw
Quoted 9 lines · Vesa Jääskeläinen
Quoted 6 lines · Robert Millan
Quoted 4 lines

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?

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."

2009-03-13 Robert Millan <[email protected]>

* loader/i386/linux.c: Include <grub/video.h>' and <grub/i386/pc/vbe.h>'..
(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.

i386/linux.c +45 -4
Index: loader/i386/linux.c
===================================================================
@@ -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 <grub/mm.h>
 #include <grub/term.h>
 #include <grub/cpu/linux.h>
+#include <grub/video.h>
+/* FIXME: the definition of `struct grub_video_render_target' is
+   VBE-specific.  */
+#include <grub/i386/pc/vbe.h>
 
 #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;
     }
 
#5 lore raw

From: Robert Millan <[email protected]>
Date: Fri, 13 Mar 2009 20:44:47 +0100

Quoted 3 lines

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.

I intend to write an ofvideo.c driver, so we'll have that opportunity soon.

#6 lore raw

new Linux loader (Re: [PATCH] linux/gfxterm integration)

In reply to Robert Millan
Quoted 9 lines · Robert Millan

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?

Ok, committed.

Btw, I'm happy to announce that the new Linux loader is fully usable on i386-pc now, with no significant regressions.

I'd like to find a way to make it available to end users. How would you think of a rename?

- loader/i386/pc/linux.c becomes the "legacy_linux" command or so.

- loader/i386/linux.c becomes "linux" command.

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."
#7 lore raw

Re: new Linux loader (Re: [PATCH] linux/gfxterm integration)

IMO linux16 for pc/linux.c would better reflect the difference with normal 'linux' command.

Quoted 22 lines · Robert Millan
Quoted 8 lines · Robert Millan

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?

Ok, committed.

Btw, I'm happy to announce that the new Linux loader is fully usable on i386-pc now, with no significant regressions.

I'd like to find a way to make it available to end users. How would you think of a rename?

- loader/i386/pc/linux.c becomes the "legacy_linux" command or so.

- loader/i386/linux.c becomes "linux" command.

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#8 lore raw

Re: new Linux loader (Re: [PATCH] linux/gfxterm integration)

Quoted 2 lines · phcoder

IMO linux16 for pc/linux.c would better reflect the difference with normal 'linux' command.

I'm fine with that. Does anyone object to the proposed rename?

Note this implies the new Linux loader becomes the default in grub-mkconfig setup (it is already but only with coreboot).

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."
#9 lore raw

PATCH 1/1 build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 8 lines · Robert Millan
Quoted 2 lines · phcoder

IMO linux16 for pc/linux.c would better reflect the difference with normal 'linux' command.

I'm fine with that. Does anyone object to the proposed rename?

Note this implies the new Linux loader becomes the default in grub-mkconfig setup (it is already but only with coreboot).

Here's a patch to rename linux' to linux16' and build the 32-bit loader as simply `linux'.

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."

2009-03-22 Robert Millan <[email protected]>

* conf/i386-pc.rmk (pkglib_MODULES): Add `linux16.mod'. (linux16_mod_SOURCES, linux16_mod_CFLAGS, linux16_mod_LDFLAGS): New variables. Use 16-bit loader.
(linux_mod_SOURCES, linux_mod_CFLAGS, linux_mod_LDFLAGS): Use 32-bit loader.
* kern/i386/loader.S (grub_linux_boot): Rename to ... (grub_linux16_boot): ... this. Update all users.
* loader/i386/linux.c (grub_linux32_boot): Rename to ... (grub_linux_boot): ... this. Update all users.

* loader/i386/pc/linux.c (GRUB_MOD_INIT(linux)): Rename to ... (GRUB_MOD_INIT(linux16)): ... this. Rename linux' and initrd' commands to linux16' and initrd16'. (GRUB_MOD_FINI(linux)): Rename to ... (GRUB_MOD_FINI(linux16)): ... this.

i386-pc.rmk +8 -3
Index: conf/i386-pc.rmk
===================================================================
@@ -167,7 +167,7 @@ grub_install_SOURCES = util/i386/pc/grub
 # For grub-mkrescue.
 grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in
 
-pkglib_MODULES = biosdisk.mod chain.mod linux.mod normal.mod \
+pkglib_MODULES = biosdisk.mod chain.mod normal.mod \
 	multiboot.mod reboot.mod halt.mod	\
 	vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod	\
 	ata.mod vga.mod memdisk.mod pci.mod lspci.mod	\
@@ -185,8 +185,13 @@ chain_mod_SOURCES = loader/i386/pc/chain
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
 chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For _linux.mod.
-linux_mod_SOURCES = loader/i386/pc/linux.c
+pkglib_MODULES += linux16.mod
+linux16_mod_SOURCES = loader/i386/pc/linux.c
+linux16_mod_CFLAGS = $(COMMON_CFLAGS)
+linux16_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+pkglib_MODULES += linux.mod
+linux_mod_SOURCES = loader/i386/linux.c
 linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
i386/loader.S +1 -1
Index: kern/i386/loader.S
===================================================================
@@ -59,7 +59,7 @@ VARIABLE(grub_linux_real_addr)
 VARIABLE(grub_linux_is_bzimage)
 	.long	0
 
-FUNCTION(grub_linux_boot)
+FUNCTION(grub_linux16_boot)
 	/* Must be done before zImage copy.  */
 	call	EXT_C(grub_dl_unload_all)
 
grub/i386/loader.h +1 -1
Index: include/grub/i386/loader.h
===================================================================
@@ -30,7 +30,7 @@ extern grub_int32_t EXPORT_VAR(grub_linu
 extern grub_addr_t EXPORT_VAR(grub_os_area_addr);
 extern grub_size_t EXPORT_VAR(grub_os_area_size);
 
-grub_err_t EXPORT_FUNC(grub_linux_boot) (void);
+grub_err_t EXPORT_FUNC(grub_linux16_boot) (void);
 
 void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
      __attribute__ ((cdecl,noreturn));
i386/linux.c +2 -2
Index: loader/i386/linux.c
===================================================================
@@ -263,7 +263,7 @@ struct
 #endif
 
 static grub_err_t
-grub_linux32_boot (void)
+grub_linux_boot (void)
 {
   struct linux_kernel_params *params;
   int e820_num;
@@ -522,7 +522,7 @@ grub_cmd_linux (grub_command_t cmd __att
 
   if (grub_errno == GRUB_ERR_NONE)
     {
-      grub_loader_set (grub_linux32_boot, grub_linux_unload,
+      grub_loader_set (grub_linux_boot, grub_linux_unload,
 		       0 /* set noreturn=0 in order to avoid grub_console_fini() */);
       loaded = 1;
     }
i386/pc/linux.c +5 -5
Index: loader/i386/pc/linux.c
===================================================================
@@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __att
   if (grub_errno == GRUB_ERR_NONE)
     {
       grub_linux_prot_size = prot_size;
-      grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
+      grub_loader_set (grub_linux16_boot, grub_linux_unload, 1);
       loaded = 1;
     }
 
@@ -378,18 +378,18 @@ grub_cmd_initrd (grub_command_t cmd __at
 
 static grub_command_t cmd_linux, cmd_initrd;
 
-GRUB_MOD_INIT(linux)
+GRUB_MOD_INIT(linux16)
 {
   cmd_linux =
-    grub_register_command ("linux", grub_cmd_linux,
+    grub_register_command ("linux16", grub_cmd_linux,
 			   0, "load linux");
   cmd_initrd =
-    grub_register_command ("initrd", grub_cmd_initrd,
+    grub_register_command ("initrd16", grub_cmd_initrd,
 			   0, "load initrd");
   my_mod = mod;
 }
 
-GRUB_MOD_FINI(linux)
+GRUB_MOD_FINI(linux16)
 {
   grub_unregister_command (cmd_linux);
   grub_unregister_command (cmd_initrd);
#10 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 5 lines · Robert Millan
Quoted 4 lines · Robert Millan
Quoted 2 lines · phcoder

IMO linux16 for pc/linux.c would better reflect the difference with normal 'linux' command.

Quoted 7 lines
Quoted 4 lines

I'm fine with that. Does anyone object to the proposed rename?

Note this implies the new Linux loader becomes the default in grub-mkconfig setup (it is already but only with coreboot).

Here's a patch to rename linux' to linux16' and build the 32-bit loader as simply `linux'.

Committed.

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."
#11 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 4 lines · Robert Millan
Quoted 2 lines

Here's a patch to rename linux' to linux16' and build the 32-bit loader as simply `linux'.

Committed.

Just for your information. With the old loader, booting an x86_64 kernel in qemu emulating i386 would result in a kernel message:

"This kernel requires an x86-64 CPU but only detected an i686 CPU Unable to boot - please use a kernel appropriate for your CPU"

With the new loader, the kernel hands without showing any messages. It can be a kernel bug. Linux 2.6.29, current GRUB.

Signature · 2 lines
Regards,
Pavel Roskin
#12 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 6 lines · Pavel Roskin
Quoted 3 lines · Robert Millan
Quoted 2 lines

Here's a patch to rename linux' to linux16' and build the 32-bit loader as simply `linux'.

Committed.

Quoted 9 lines

Just for your information. With the old loader, booting an x86_64 kernel in qemu emulating i386 would result in a kernel message:

"This kernel requires an x86-64 CPU but only detected an i686 CPU Unable to boot - please use a kernel appropriate for your CPU"

With the new loader, the kernel hands without showing any messages. It can be a kernel bug. Linux 2.6.29, current GRUB.

I confirm. I suppose that this check and message is bypassed with 32-bit loading mode. IMO grub2 should provide an equivlent of this check. We already have cpuid code. Does anyone know how to determine if kernel is i386 or amd64?

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#13 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 13 lines · On Monday 30 March 2009 23:35:52 phcoder wrote:
Quoted 12 lines · Pavel Roskin
Quoted 4 lines · Robert Millan
Quoted 2 lines

Here's a patch to rename linux' to linux16' and build the 32-bit loader as simply `linux'.

Committed.

Just for your information. With the old loader, booting an x86_64 kernel in qemu emulating i386 would result in a kernel message:

"This kernel requires an x86-64 CPU but only detected an i686 CPU Unable to boot - please use a kernel appropriate for your CPU"

Quoted 7 lines
Quoted 2 lines

With the new loader, the kernel hands without showing any messages. It can be a kernel bug. Linux 2.6.29, current GRUB.

I confirm. I suppose that this check and message is bypassed with 32-bit loading mode. IMO grub2 should provide an equivlent of this check. We already have cpuid code. Does anyone know how to determine if kernel is i386 or amd64?

I don't know any reliable way. Some candidates:

- The ramdisk max value. On 32-bit, initrd may not be loaded onto over 2GB. This is hard to change in Linux, so we can expect that this will not change. On 64-bit, currently, the max is 4GB-1. It is likely that this value will not change, but who knows.

- The long mode panic message. This exists only for x86_64. But the message might change some day.

- Otherwise, we could probe some opcodes and see if 64-bit opcodes are used. This would be error-prone.

After all, the best way might be to just ask Linux developers to add a new flag.

Regards,
Okuji

#14 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 10 lines · Yoshinori K. Okuji
Quoted 4 lines · On Monday 30 March 2009 23:35:52 phcoder wrote:

I confirm. I suppose that this check and message is bypassed with 32-bit loading mode. IMO grub2 should provide an equivlent of this check. We already have cpuid code. Does anyone know how to determine if kernel is i386 or amd64?

I don't know any reliable way. Some candidates:

- The ramdisk max value. On 32-bit, initrd may not be loaded onto over 2GB. This is hard to change in Linux, so we can expect that this will not change.

If we are circumventing the standard Linux bootloader, perhaps we should communicate this to the Linux developers.

To check architecture in GRUB, we need one bit of information, but that bit should be reliable.

Also, it looks like Linux on x86_64 does an extra validation of the CPU in arch/x86/boot/compressed/head_64.S, but if the long mode is not supported, it hangs without printing an error message.

Signature · 2 lines
Regards,
Pavel Roskin
#15 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 7 lines · Pavel Roskin
Quoted 6 lines · Yoshinori K. Okuji
Quoted 4 lines · On Monday 30 March 2009 23:35:52 phcoder wrote:

I confirm. I suppose that this check and message is bypassed with 32-bit loading mode. IMO grub2 should provide an equivlent of this check. We already have cpuid code. Does anyone know how to determine if kernel is i386 or amd64?

Quoted 7 lines
Quoted 4 lines

I don't know any reliable way. Some candidates:

- The ramdisk max value. On 32-bit, initrd may not be loaded onto over 2GB. This is hard to change in Linux, so we can expect that this will not change.

If we are circumventing the standard Linux bootloader, perhaps we should communicate this to the Linux developers.

This is not circumvention. We're using a 32-bit interface that's part of their boot protocol specification (i.e. they promised not to break it). The only caveat is that so far it's only used on EFI and on coreboot, it hasn't been so widespread, and therefore not so widely tested yet.

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."
#18 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

In reply to Yoshinori K. Okuji
Quoted 6 lines · Yoshinori K. Okuji

I don't know any reliable way. Some candidates:

- The ramdisk max value. On 32-bit, initrd may not be loaded onto over 2GB. This is hard to change in Linux, so we can expect that this will not change. On 64-bit, currently, the max is 4GB-1. It is likely that this value will not change, but who knows.

This could be possible, but doesn't sound very reliable.

Quoted 2 lines

- The long mode panic message. This exists only for x86_64. But the message might change some day.

Actually, it seems to have changed recently. Doesn't seem too reliable either.

Quoted 2 lines

- Otherwise, we could probe some opcodes and see if 64-bit opcodes are used. This would be error-prone.

Same here :-(

However, this is not as large a problem as it seems. Most users install GRUB to disk through their distribution, which already provides the right Linux builds in /boot. It could be a problem with removable media, but:

- It's easy to solve this when you have a "cpuid" command and know what each of the files you put in the CD is. This also allows for a more user-friendly error message than a Linux panic.

- GRUB is rarely used there anyway (most GNU/Linux distros opt for isolinux)

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."
#16 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

In reply to Robert Millan
Quoted 9 lines · Robert Millan
Quoted 3 lines · Pavel Roskin

If we are circumventing the standard Linux bootloader, perhaps we should communicate this to the Linux developers.

This is not circumvention. We're using a 32-bit interface that's part of their boot protocol specification (i.e. they promised not to break it). The only caveat is that so far it's only used on EFI and on coreboot, it hasn't been so widespread, and therefore not so widely tested yet.

I see. It looks like the x86_64 kernel has code for printing strings in 16-bit mode and in 64-bit mode, but not in 32-bit mode, in which we enter the kernel. So no easy fix, unfortunately.

Signature · 2 lines
Regards,
Pavel Roskin
#17 lore raw

Re: [PATCH] build 32-bit Linux loader as `linux', rename legacy loader to `linux16'

Quoted 6 lines · Pavel Roskin
Quoted 5 lines · Robert Millan
Quoted 3 lines · Pavel Roskin

If we are circumventing the standard Linux bootloader, perhaps we should communicate this to the Linux developers.

Quoted 8 lines
Quoted 4 lines

This is not circumvention. We're using a 32-bit interface that's part of their boot protocol specification (i.e. they promised not to break it). The only caveat is that so far it's only used on EFI and on coreboot, it hasn't been so widespread, and therefore not so widely tested yet.

I see. It looks like the x86_64 kernel has code for printing strings in 16-bit mode and in 64-bit mode, but not in 32-bit mode, in which we enter the kernel. So no easy fix, unfortunately.

It's possible to find a fix for this from Linux side, but IMHO the best long-term fix would be to make whoever installed Linux _and_ GRUB figure out what GRUB should do. Not too much to ask, since we give them the tools (cpuid command) to do it.

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."