Skip to contentSkip to conversation

efigfx branch ready for merging?

PATCH Colin Watson 1 participant 1 message Jun 17, 2010

lore
Share & tools
lore
#0 lore raw

After discussion with Vladimir on IRC, I've brought his efigfx branch (sftp://bzr.sv.gnu.org/srv/bzr/grub/branches/efigfx/) up to date with trunk and added some more features to it. It now seems pretty good and I think it's ready to be merged. Could others review it and let us know what you think?

Here's a ChangeLog fragment for the parts I was responsible for. Vladimir said that he would write a ChangeLog for the parts he wrote (i.e. most of the branch ...). Following that is a diff of the branch against trunk.

2010-06-17 Colin Watson <[email protected]>

* util/grub-mkconfig.in: Capitalise and export GRUB_PREFIX. Stop setting GRUB_VIDEO_BACKEND. Make it available as a user override instead. Replace the gfxterm backend check with a check that ${GRUB_PREFIX}/video.lst is non-empty.
* util/grub.d/00_header.in: Use GRUB_PREFIX rather than computing it again.
(load_video): New generated function. Call it before loading gfxterm rather than loading ${GRUB_VIDEO_BACKEND}.
* util/grub.d/10_linux.in (linux_entry): Call load_video.
* util/grub.d/30_os-prober.in (osx_entry): Likewise.
* docs/grub.texi (Simple configuration): Document GRUB_VIDEO_BACKEND.

=== modified file 'conf/i386-pc.rmk'

i386-pc.rmk +1 -1
@@ -147,7 +147,7 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 pkglib_MODULES += xnu.mod
-xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \
+xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
 	 loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
 xnu_mod_CFLAGS = $(COMMON_CFLAGS)
 xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)

=== modified file 'conf/x86-efi.rmk'

x86-efi.rmk +1 -1
@@ -102,7 +102,7 @@ efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
 efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 pkglib_MODULES += xnu.mod
-xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
+xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
 	loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
 xnu_mod_CFLAGS = $(COMMON_CFLAGS)
 xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)

=== modified file 'docs/grub.texi'

grub.texi +10 -0
@@ -934,6 +934,16 @@ Disable the generation of recovery mode 
 @item GRUB_DISABLE_NETBSD_RECOVERY
 Disable the generation of recovery mode menu entries for NetBSD.
 
+@item GRUB_VIDEO_BACKEND
+If graphical video support is required, either because the @samp{gfxterm}
+graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
+then @command{grub-mkconfig} will normally load all available GRUB video
+drivers and use the one most appropriate for your hardware.  If you need to
+override this for some reason, then you can set this option.
+
+After @command{grub-install} has been run, the available video drivers are
+listed in @file{/boot/grub/video.lst}.
+
 @item GRUB_GFXMODE
 Set the resolution used on the @samp{gfxterm} graphical terminal.  Note that
 you can only use modes which your graphics card supports via VESA BIOS

=== modified file 'include/grub/i386/xnu.h'

grub/i386/xnu.h +1 -3
@@ -114,8 +114,6 @@ extern grub_uint32_t grub_xnu_stack;
 extern grub_uint32_t grub_xnu_arg1;
 extern char grub_xnu_cmdline[1024];
 grub_err_t grub_xnu_boot (void);
-grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *bootparams_relloc);
-grub_err_t
-grub_cpu_xnu_fill_devicetree (void);
+grub_err_t grub_cpu_xnu_fill_devicetree (void);
 extern grub_uint32_t grub_xnu_heap_will_be_at;
 #endif

=== modified file 'include/grub/video.h'

grub/video.h +18 -3
@@ -183,9 +183,19 @@ typedef enum grub_video_driver_id
     GRUB_VIDEO_DRIVER_EFI_UGA,
     GRUB_VIDEO_DRIVER_EFI_GOP,
     GRUB_VIDEO_DRIVER_SM712,
-    GRUB_VIDEO_DRIVER_VGA
+    GRUB_VIDEO_DRIVER_VGA,
+    GRUB_VIDEO_DRIVER_SDL
   } grub_video_driver_id_t;
 
+typedef enum grub_video_adapter_prio
+  {
+    GRUB_VIDEO_ADAPTER_PRIO_FALLBACK = 60,
+    GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY = 70,
+    GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE = 80,
+    GRUB_VIDEO_ADAPTER_PRIO_NATIVE = 100
+  } grub_video_adapter_prio_t;
+
+
 struct grub_video_adapter
 {
   /* The next video adapter.  */
@@ -195,6 +205,8 @@ struct grub_video_adapter
   const char *name;
   grub_video_driver_id_t id;
 
+  grub_video_adapter_prio_t prio;
+
   /* Initialize the video adapter.  */
   grub_err_t (*init) (void);
 
@@ -269,8 +281,11 @@ extern grub_video_adapter_t EXPORT_VAR(g
 static inline void
 grub_video_register (grub_video_adapter_t adapter)
 {
-  grub_list_push (GRUB_AS_LIST_P (&grub_video_adapter_list),
-		  GRUB_AS_LIST (adapter));
+  grub_video_adapter_t *p;
+  for (p = &grub_video_adapter_list; *p && (*p)->prio > adapter->prio; 
+       p = &((*p)->next));
+  adapter->next = *p;
+  *p = adapter;
 }
 #endif
 

=== modified file 'loader/i386/efi/linux.c'

i386/efi/linux.c +97 -173

314 lines not on this page · raw message

=== removed file 'loader/i386/efi/xnu.c'

i386/efi/xnu.c +0 -178

178 lines not on this page · raw message

=== removed file 'loader/i386/pc/xnu.c'

i386/pc/xnu.c +0 -123

123 lines not on this page · raw message

=== modified file 'loader/i386/xnu.c'

i386/xnu.c +98 -0

110 lines not on this page · raw message

=== modified file 'util/grub-mkconfig.in'

grub-mkconfig.in +8 -10
@@ -96,11 +96,11 @@ case "$host_os" in
 netbsd* | openbsd*)
     # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
     # instead of /boot/grub.
-    grub_prefix=`echo /grub | sed ${transform}`
+    GRUB_PREFIX=`echo /grub | sed ${transform}`
     ;;
 *)
     # Use /boot/grub by default.
-    grub_prefix=`echo /boot/grub | sed ${transform}`
+    GRUB_PREFIX=`echo /boot/grub | sed ${transform}`
     ;;
 esac
 
@@ -141,9 +141,9 @@ else
     exit 1
 fi
 
-mkdir -p ${grub_prefix}
+mkdir -p ${GRUB_PREFIX}
 
-if test -e ${grub_prefix}/device.map ; then : ; else
+if test -e ${GRUB_PREFIX}/device.map ; then : ; else
   ${grub_mkdevicemap}
 fi
 
@@ -178,17 +178,14 @@ fi
 for x in ${GRUB_TERMINAL_OUTPUT}; do
     if [ "x${x}" = "xgfxterm" ]; then
         # If this platform supports gfxterm, try to use it.
-	if ! test -e ${grub_prefix}/gfxterm.mod ; then
+	if ! test -e ${GRUB_PREFIX}/gfxterm.mod ; then
 	    if [ "x$termoutdefault" != "x1" ]; then
 		echo "gfxterm isn't available on your platform" >&2 ; exit 1
 	    fi
 	    GRUB_TERMINAL_OUTPUT=
 	    break;
 	fi
-        # FIXME: this should do something smarter than just loading first
-        # video backend.
-	GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
-	if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
+	if [ ! -s "${GRUB_PREFIX}/video.lst" ] ; then
 	    if [ "x$termoutdefault" != "x1" ]; then
 		echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
 	    fi
@@ -246,7 +243,7 @@ export GRUB_DEVICE \
   GRUB_FS \
   GRUB_FONT_PATH \
   GRUB_PRELOAD_MODULES \
-  GRUB_VIDEO_BACKEND
+  GRUB_PREFIX
 
 # These are optional, user-defined variables.
 export GRUB_DEFAULT \
@@ -268,6 +265,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_RECOVERY \
   GRUB_DISABLE_NETBSD_RECOVERY \
+  GRUB_VIDEO_BACKEND \
   GRUB_GFXMODE \
   GRUB_BACKGROUND \
   GRUB_THEME \

=== modified file 'util/grub.d/00_header.in'

grub.d/00_header.in +21 -4
@@ -21,8 +21,7 @@ transform="@program_transform_name@"
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
-grub_prefix=`echo /boot/grub | sed ${transform}`
-locale_dir=`echo /boot/grub/locale | sed ${transform}`
+locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
 grub_lang=`echo $LANG | cut -d _ -f 1`
 
 . ${libdir}/grub/grub-mkconfig_lib
@@ -75,6 +74,24 @@ function savedefault {
     save_env saved_entry
   fi
 }
+
+function load_video {
+EOF
+if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
+    cat <<EOF
+  insmod ${GRUB_VIDEO_BACKEND}
+EOF
+else
+    # Insert all available backends; GRUB will use the most appropriate.
+    for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
+	cat <<EOF
+  insmod ${backend}
+EOF
+    done
+fi
+cat <<EOF
+}
+
 EOF
 
 serial=0;
@@ -89,7 +106,7 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_T
 done
 
 if [ "x$serial" = x1 ]; then
-    if ! test -e ${grub_prefix}/serial.mod ; then
+    if ! test -e ${GRUB_PREFIX}/serial.mod ; then
 	echo "Serial terminal not available on this platform." >&2 ; exit 1
     fi
 
@@ -107,8 +124,8 @@ if [ "x$gfxterm" = x1 ]; then
     cat << EOF
 if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
   set gfxmode=${GRUB_GFXMODE}
+  load_video
   insmod gfxterm
-  insmod ${GRUB_VIDEO_BACKEND}
 EOF
     if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
 	&& is_path_readable_by_grub "$GRUB_THEME"; then

=== modified file 'util/grub.d/10_linux.in'

grub.d/10_linux.in +3 -0
@@ -66,6 +66,9 @@ linux_entry ()
   # Use ELILO's generic "efifb" when it's known to be available.
   # FIXME: We need an interface to select vesafb in case efifb can't be used.
   if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
+      cat << EOF
+	load_video
+EOF
       if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
 	  && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
 	  cat << EOF

=== modified file 'util/grub.d/30_os-prober.in'

grub.d/30_os-prober.in +1 -1
@@ -44,7 +44,7 @@ EOF
 	save_default_entry | sed -e "s/^/\t/"
 	prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
 	cat << EOF
-        insmod ${GRUB_VIDEO_BACKEND}
+        load_video
         set do_resume=0
         if [ /var/vm/sleepimage -nt10 / ]; then
            if xnu_resume /var/vm/sleepimage; then

=== modified file 'video/efi_gop.c'

efi_gop.c +2 -0
@@ -355,6 +355,8 @@ static struct grub_video_adapter grub_vi
     .name = "EFI GOP driver",
     .id = GRUB_VIDEO_DRIVER_EFI_GOP,
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
     .init = grub_video_gop_init,
     .fini = grub_video_gop_fini,
     .setup = grub_video_gop_setup,

=== modified file 'video/efi_uga.c'

efi_uga.c +2 -0
@@ -302,6 +302,8 @@ static struct grub_video_adapter grub_vi
     .name = "EFI UGA driver",
     .id = GRUB_VIDEO_DRIVER_EFI_UGA,
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY,
+
     .init = grub_video_uga_init,
     .fini = grub_video_uga_fini,
     .setup = grub_video_uga_setup,

=== modified file 'video/emu/sdl.c'

emu/sdl.c +3 -0
@@ -200,6 +200,9 @@ grub_video_sdl_set_active_render_target 
 static struct grub_video_adapter grub_video_sdl_adapter =
   {
     .name = "SDL Video Driver",
+    .id = GRUB_VIDEO_DRIVER_SDL,
+
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
 
     .init = grub_video_sdl_init,
     .fini = grub_video_sdl_fini,

=== modified file 'video/i386/pc/vbe.c'

i386/pc/vbe.c +2 -0
@@ -783,6 +783,8 @@ static struct grub_video_adapter grub_vi
     .name = "VESA BIOS Extension Video Driver",
     .id = GRUB_VIDEO_DRIVER_VBE,
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
     .init = grub_video_vbe_init,
     .fini = grub_video_vbe_fini,
     .setup = grub_video_vbe_setup,

=== modified file 'video/i386/pc/vga.c'

i386/pc/vga.c +2 -0
@@ -375,6 +375,8 @@ static struct grub_video_adapter grub_vi
     .name = "VGA Video Driver",
     .id = GRUB_VIDEO_DRIVER_VGA,
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FALLBACK,
+
     .init = grub_video_vga_init,
     .fini = grub_video_vga_fini,
     .setup = grub_video_vga_setup,

=== modified file 'video/ieee1275.c'

ieee1275.c +2 -0
@@ -254,6 +254,8 @@ static struct grub_video_adapter grub_vi
   {
     .name = "IEEE1275 video driver",
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
     .init = grub_video_ieee1275_init,
     .fini = grub_video_ieee1275_fini,
     .setup = grub_video_ieee1275_setup,

=== modified file 'video/sm712.c'

sm712.c +2 -0
@@ -193,6 +193,8 @@ static struct grub_video_adapter grub_vi
     .name = "SM712 Video Driver",
     .id = GRUB_VIDEO_DRIVER_SM712,
 
+    .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
     .init = grub_video_sm712_video_init,
     .fini = grub_video_sm712_video_fini,
     .setup = grub_video_sm712_setup,
Signature · 1 line
Colin Watson                                       [[email protected]]