hurdhelper: Add helper for loading GNU/Hurd multiboot modules
PATCH v2 1/1 hurdhelper: Add helper for loading GNU/Hurd multiboot modules
This adds a new grub module called hurdhelper.
This module simplifies the loading of hurd multiboot modules by allowing them to be loaded in one line (in order of loading).
A typical use case would be:
grub> insmod hurdhelper
grub> multiboot /boot/gnumach-1.8-486-dbg.gz root=part:2:device:wd0 noide grub> hurdmodules pci-arbiter acpi rumpdisk ext2fs exec
grub> boot
This could, for example, allow hurd to be booted from the grub shell manually without remembering and typing dozens of commands.
--- grub-core/Makefile.core.def | 8 ++ grub-core/loader/hurdhelper.c | 201 ++++++++++++++++++++++++++++++++++ grub-core/loader/multiboot.c | 6 + include/grub/multiboot.h | 1 + include/grub/multiboot2.h | 1 + 5 files changed, 217 insertions(+) create mode 100644 grub-core/loader/hurdhelper.c
grub-core/Makefile.core.def +8 -0
@@ -1788,6 +1788,14 @@ module = { enable = i386_xen_pvh; }; +module = { + name = hurdhelper; + common = loader/hurdhelper.c; + enable = x86; + enable = i386_pc; + enable = i386_multiboot; +}; + module = { name = xen_boot; arm64 = loader/arm64/xen_boot.c;
grub-core/loader/hurdhelper.c new file +201 -0
201 lines not on this page · raw message
grub-core/loader/multiboot.c +6 -0
@@ -440,6 +440,12 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),return GRUB_ERR_NONE ; } +grub_err_t +GRUB_MULTIBOOT (cmd_module ) (int argc,char *argv[]) +{ +return grub_cmd_module (NULL , argc, argv); +} +static grub_command_t cmd_multiboot, cmd_module;GRUB_MOD_INIT (multiboot)
include/grub/multiboot.h +1 -0
@@ -46,6 +46,7 @@ void grub_multiboot_free_mbi (void);grub_err_t grub_multiboot_init_mbi (int argc,char *argv[]);grub_err_t grub_multiboot_add_module (grub_addr_t start,grub_size_t size,int argc,char *argv[]); +grub_err_t grub_multiboot_cmd_module (int argc,char *argv[]);void grub_multiboot_set_bootdev (void ); void grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize,
include/grub/multiboot2.h +1 -0
@@ -38,6 +38,7 @@ void grub_multiboot2_free_mbi (void);grub_err_t grub_multiboot2_init_mbi (int argc,char *argv[]);grub_err_t grub_multiboot2_add_module (grub_addr_t start,grub_size_t size,int argc,char *argv[]); +grub_err_t grub_multiboot2_cmd_module (int argc,char *argv[]);void grub_multiboot2_set_bootdev (void ); void grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize,
Signature · 1 line
2.40.1
Hello,
Damien Zammit, le dim. 16 juil. 2023 10:40:29 +0000, a ecrit:
Quoted 1 line
This adds a new grub module called hurdhelper.
That's both simple to implement and interesting for use, thanks!
Quoted 8 lines
This module simplifies the loading of hurd multiboot modules by allowing them to be loaded in one line (in order of loading).
A typical use case would be:
grub> insmod hurdhelper
grub> multiboot/boot/gnumach-1.8-486-dbg.gzroot=part:2:device:wd0 noide grub> hurdmodules pci-arbiter acpi rumpdisk ext2fs exec
I'd rather see that as separate commands, so as to be able to pass options to them as desired.
grub-core/loader/hurdhelper.c line 38
Quoted 3 lines
grub-core/loader/hurdhelper.c new file +3
-0+#define HURD_FS_PARAMS1 "--multiboot-command-line=${kernel-command-line}" +#define HURD_FS_PARAMS2 "--store-type=typed" +#define HURD_FS_PARAMS3 "${root}"
I'd rather make the user explicitly tell the module that they're loading a FS server.
grub-core/loader/hurdhelper.c line 45
Quoted 3 lines
grub-core/loader/hurdhelper.c new file +3
-0+#define LIB_PREFIX "/lib/" +#define EXEC_TASK "exec" +#define LD_SO_1 "ld.so.1"
We don't want to hardcode that. The user may want to use a static exec, etc.
I.e. I'd rather see something like this:
hurdmodule /hurd/pci-arbiter.static
hurdmodule /hurd/acpi.static
hurdmodule /hurd/rumpdisk.static
hurdrootmodule /hurd/ext2fs.static
hurdexecmodule /lib/ld.so /hurd/exec
Or possibly, by hardcoding only "/hurd/" and ".static" and using lookups to automatically discover what's available:
hurdmodule pci-arbiter
hurdmodule acpi
hurdmodule rumpdisk
hurdrootmodule ext2fs
hurdexecmodule /lib/ld.so /hurd/exec
The user can also just use
hurdexecmodule exec
if they want something simpler to type. That'll just not share libc etc. with the rest of the system, but that's fine for booting something. For grub-generated configurations, we can keep loading ld.so explicitly to load the dynamically-linked version.
grub-core/loader/hurdhelper.c line 55
Quoted 4 lines
grub-core/loader/hurdhelper.c new file +4
-0+static int +is_fs_task (char *arg) +{ +if (!grub_strncmp (arg,FS_TASK ,6 ))
It's not that simple, we can have many different filesystems. Better just make the user explicitly tell which module is the root FS module.
grub-core/loader/hurdhelper.c line 64
Quoted 4 lines
grub-core/loader/hurdhelper.c new file +4
-0+static int +is_exec_task (char *arg) +{ +if (!grub_strncmp (arg,EXEC_TASK ,4 ))
I'd also rather make this explicit. Also because (see my mail on the hurd mailing list) the exec server is special to the root FS.
Samuel