Skip to contentSkip to conversation

Determine the linux loader command at runtime

PATCH In review Lubomir Rintel 2 participants 2 messages Jan 30, 2014 – Jan 31, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Determine the linux loader command at runtime

There are numerous ways to load Linux kernel depending on the platform customs. Pick the correct one at runtime, so that legacy platform interfaces don't break and newer platforms use their native ways of bootstrapping Linux.

Originally from Vladimir Serbinenko <[email protected]>, slightly modified.

---
 ChangeLog               |  5 +++++
 util/grub.d/10_linux.in | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
ChangeLog +5 -0
index 10abfe2..4f1ee02 100644
@@ -1,3 +1,8 @@
+2014-01-20  Lubomir Rintel  <[email protected]>
+
+	* util/grub.d/10_linux.in: Determine the loader command by platform.
+	(linux_entry): Use the command appropriate for given platform.
+
 2014-01-19  Colin Watson  <[email protected]>
 
 	* grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
util/grub.d/10_linux.in +15 -2
index 00d1931..d980d9a 100644
@@ -129,14 +129,14 @@ linux_entry ()
   message="$(gettext_printf "Loading Linux %s ..." ${version})"
   sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+	\$linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
     message="$(gettext_printf "Loading initial ramdisk ...")"
     sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	initrd	${rel_dirname}/${initrd}
+	\$initrd	${rel_dirname}/${initrd}
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
@@ -169,6 +169,19 @@ prepare_root_cache=
 boot_device_id=
 title_correction_code=
 
+# Pick a correct kernel load command. Use real mode entry point on legacy PC
+# platform (so that EDD and APM keep being available) and native entry point
+# on everything else.
+cat <<EOF
+if [ x\$grub_platform = xpc ]; then
+	linux=linux16
+	initrd=initrd16
+else
+	linux=linux
+	initrd=initrd
+fi
+EOF
+
 # Extra indentation to add to menu entries in a submenu. We're not in a submenu
 # yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
 submenu_indentation=""
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 3 lines · Lubomir Rintel

There are numerous ways to load Linux kernel depending on the platform customs. Pick the correct one at runtime, so that legacy platform interfaces don't break and newer platforms use their native ways of bootstrapping Linux.

We (Ubuntu) have been using the 32-bit entry point on i386-pc for quite some time, and I'm fairly sure we rely on it to make gfxpayload work for flicker-free boot. It looks like this will break that; please don't.

Signature · 1 line
Colin Watson                                       [[email protected]]