Grub2 and Pegasos
Hell[o]
Some time ago I decide to give a try to GRUB on my Pegasos 2 machine (G4 1GHz, 1G of ram) and generaly it works with some problems.
1) Booting recent CVS snap on OF version dated 2005.12.16 gives me only "Welcome to GRUB" and "Out of memory" message. After OF update to half official 2006.10.23 it works, but as this version is not fully official most of the
pegasos machines still uses old one.
I checked and GRUB 1.94 works fine on older OF (2005.12.16) and 1.95 gives instant reboot.
2) Backspace key seems to not working in GRUB console (I use cursor key and del for now) but works fine in OF console.
Put some debug in ofconsole.c shows that getkey() gives 127 for backspace.
3) After "Welcome to GRUB" message I have a ~1-2s pause and error "ATA device not present or not responding" Currently I have one HD (primary master) and DVD (secondary master) attached.
No error when booting using 1.94.
4) Most of the Pegasos machines uses small affs partition for MorphOS boot images, but it seems affs is broken for ieee1275 as affs uses total_sectors field from grub_disk_t, but looking at ofdisk.c:
/* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it is possible to use seek for this. */
disk->total_sectors = 0xFFFFFFFFUL;
I changed affs to use grub_partition_get_len(). No ideas how correct is it, but it seems to work here.
4) Grub2 can not load morphos boot images then I added ofboot command to allow boot using OF interface (load, init-program, go).
Attached both patches, I am not completly sure how correct are both of them as this was my first look inside grub2 sources. Anyway now I can boot MorphOS and use affs partitions, but three problems are still there.
Can anyone help with this ?
Signature · 1 line
--- Marcin 'Morgoth' Kurek ---
conf/powerpc-ieee1275.mk +115 -5
@@ -235,14 +235,14 @@ normal/menu_entry.c normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ partmap/acorn.c \ - util/console.c util/grub-emu.c util/misc.c \ + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/biosdisk.c util/getroot.c \ util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c -CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o -MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_blocklist.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-fs_ntfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d +CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o +MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_blocklist.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-fs_ntfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_hostfs.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d -grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o - $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS) +grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o + $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS) grub_emu-commands_boot.o: commands/boot.c $(commands/boot.c_DEPENDENCIES) $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
@@ -484,6 +484,10 @@ $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $< -include grub_emu-util_console.d +grub_emu-util_hostfs.o: util/hostfs.c $(util/hostfs.c_DEPENDENCIES) + $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $< +-include grub_emu-util_hostfs.d + grub_emu-util_grub_emu.o: util/grub-emu.c $(util/grub-emu.c_DEPENDENCIES) $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $< -include grub_emu-util_grub_emu.d
@@ -649,6 +653,8 @@ # Modules. pkgdata_MODULES = halt.mod \ + _ofboot.mod \ + ofboot.mod \ _linux.mod \ linux.mod \ normal.mod \
@@ -657,6 +663,110 @@ _multiboot.mod \ multiboot.mod +# For _ofboot.mod. +_ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot.c +CLEANFILES += _ofboot.mod mod-_ofboot.o mod-_ofboot.c pre-_ofboot.o _ofboot_mod-loader_powerpc_ieee1275_ofboot.o und-_ofboot.lst +ifneq ($(_ofboot_mod_EXPORTS),no) +CLEANFILES += def-_ofboot.lst +DEFSYMFILES += def-_ofboot.lst +endif +MOSTLYCLEANFILES += _ofboot_mod-loader_powerpc_ieee1275_ofboot.d +UNDSYMFILES += und-_ofboot.lst + +_ofboot.mod: pre-_ofboot.o mod-_ofboot.o + -rm -f $@ + $(TARGET_CC) $(_ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^ + $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@ + +pre-_ofboot.o: $(_ofboot_mod_DEPENDENCIES) _ofboot_mod-loader_powerpc_ieee1275_ofboot.o + -rm -f $@ + $(TARGET_CC) $(_ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ _ofboot_mod-loader_powerpc_ieee1275_ofboot.o + +mod-_ofboot.o: mod-_ofboot.c + $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -c -o $@ $< + +mod-_ofboot.c: moddep.lst genmodsrc.sh + sh $(srcdir)/genmodsrc.sh '_ofboot' $< > $@ || (rm -f $@; exit 1) + +ifneq ($(_ofboot_mod_EXPORTS),no) +def-_ofboot.lst: pre-_ofboot.o + $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 _ofboot/' > $@ +endif + +und-_ofboot.lst: pre-_ofboot.o + echo '_ofboot' > $@ + $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ + +_ofboot_mod-loader_powerpc_ieee1275_ofboot.o: loader/powerpc/ieee1275/ofboot.c + $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -MD -c -o $@ $< +-include _ofboot_mod-loader_powerpc_ieee1275_ofboot.d + +CLEANFILES += cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst +COMMANDFILES += cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst +FSFILES += fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst + +cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst: loader/powerpc/ieee1275/ofboot.c gencmdlist.sh + set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _ofboot > $@ || (rm -f $@; exit 1) + +fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst: loader/powerpc/ieee1275/ofboot.c genfslist.sh + set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _ofboot > $@ || (rm -f $@; exit 1) + + +_ofboot_mod_CFLAGS = $(COMMON_CFLAGS) +_ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For ofboot.mod. +ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot_normal.c +CLEANFILES += ofboot.mod mod-ofboot.o mod-ofboot.c pre-ofboot.o ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o und-ofboot.lst +ifneq ($(ofboot_mod_EXPORTS),no) +CLEANFILES += def-ofboot.lst +DEFSYMFILES += def-ofboot.lst +endif +MOSTLYCLEANFILES += ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.d +UNDSYMFILES += und-ofboot.lst + +ofboot.mod: pre-ofboot.o mod-ofboot.o + -rm -f $@ + $(TARGET_CC) $(ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^ + $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@ + +pre-ofboot.o: $(ofboot_mod_DEPENDENCIES) ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o + -rm -f $@ + $(TARGET_CC) $(ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o + +mod-ofboot.o: mod-ofboot.c + $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -c -o $@ $< + +mod-ofboot.c: moddep.lst genmodsrc.sh + sh $(srcdir)/genmodsrc.sh 'ofboot' $< > $@ || (rm -f $@; exit 1) + +ifneq ($(ofboot_mod_EXPORTS),no) +def-ofboot.lst: pre-ofboot.o + $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 ofboot/' > $@ +endif + +und-ofboot.lst: pre-ofboot.o + echo 'ofboot' > $@ + $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ + +ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o: loader/powerpc/ieee1275/ofboot_normal.c + $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -MD -c -o $@ $< +-include ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.d + +CLEANFILES += cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst +COMMANDFILES += cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst +FSFILES += fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst + +cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst: loader/powerpc/ieee1275/ofboot_normal.c gencmdlist.sh + set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ofboot > $@ || (rm -f $@; exit 1) + +fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst: loader/powerpc/ieee1275/ofboot_normal.c genfslist.sh + set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh ofboot > $@ || (rm -f $@; exit 1) + + +ofboot_mod_CFLAGS = $(COMMON_CFLAGS) +ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For _linux.mod. _linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c CLEANFILES += _linux.mod mod-_linux.o mod-_linux.c pre-_linux.o _linux_mod-loader_powerpc_ieee1275_linux.o und-_linux.lst
conf/powerpc-ieee1275.rmk +13 -1
@@ -73,7 +73,7 @@ normal/menu_entry.c normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ partmap/acorn.c \ - util/console.c util/grub-emu.c util/misc.c \ + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/biosdisk.c util/getroot.c \ util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c
@@ -101,6 +101,8 @@ # Modules. pkgdata_MODULES = halt.mod \ + _ofboot.mod \ + ofboot.mod \ _linux.mod \ linux.mod \ normal.mod \
@@ -109,6 +111,16 @@ _multiboot.mod \ multiboot.mod +# For _ofboot.mod. +_ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot.c +_ofboot_mod_CFLAGS = $(COMMON_CFLAGS) +_ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For ofboot.mod. +ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot_normal.c +ofboot_mod_CFLAGS = $(COMMON_CFLAGS) +ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For _linux.mod. _linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c _linux_mod_CFLAGS = $(COMMON_CFLAGS)
include/grub/powerpc/ieee1275/loader.h +3 -0
@@ -23,10 +23,13 @@loader. */ void grub_rescue_cmd_linux (int argc,char *argv[]);void grub_rescue_cmd_initrd (int argc,char *argv[]); +void grub_rescue_cmd_ofboot (int argc,char *argv[]);void grub_linux_init (void );void grub_linux_fini (void );void grub_linux_normal_init (void );void grub_linux_normal_fini (void ); +void grub_ofboot_normal_init (void ); +void grub_ofboot_normal_fini (void );#endif /* ! GRUB_LOADER_MACHINE_HEADER */
kern/powerpc/ieee1275/init.c +8 -2
@@ -115,14 +115,16 @@/* Claim some available memory in the first /memory node. */ static void grub_claim_heap (unsigned long heaplimit) { +unsigned long total =0 ; + autoint heap_init (grub_uint64_t addr,grub_uint64_t len);int heap_init (grub_uint64_t addr,grub_uint64_t len) { len -=1 ;/* Required for some firmware. */ /* Don't claim anything above `heaplimit'. */ -if (addr + len > heaplimit) - len = heaplimit - addr; +if (total + len > heaplimit) + len = heaplimit - total;if (len) {
@@ -134,6 +136,10 @@grub_mm_init_region ((void *) (grub_addr_t ) addr, len); } + total += len; +if (total >= heaplimit) +return 1 ; +return 0 ; }
loader/powerpc/ieee1275/ofboot.c +135 -0
135 lines not on this page · raw message
loader/powerpc/ieee1275/ofboot_normal.c +48 -0
48 lines not on this page · raw message
fs/affs.c +14 -9
@@ -25,6 +25,7 @@#include <grub/dl.h> #include <grub/types.h> #include <grub/fshelp.h> +#include <grub/partition.h> /* The affs bootblock. */ struct grub_affs_bblock
@@ -97,6 +98,9 @@struct grub_fshelp_node diropen;grub_disk_t disk; +/* Size in sectors */ +grub_uint64_t len; +/* Blocksize in sectors. */ int blocksize;
@@ -170,10 +174,17 @@int checksumr =0 ;int blocksize =0 ; + data =grub_malloc (sizeof (struct grub_affs_data ));if (!data)return 0 ; +/* total_sectors are not valid on ieee1275 */ +if (disk->partition) + data->len =grub_partition_get_len (disk->partition); +else + data->len = disk->total_sectors; +/* Read the bootblock. */ grub_disk_read (disk,0 ,0 ,sizeof (struct grub_affs_bblock ), (char *) &data->bblock);
@@ -194,12 +205,6 @@ goto fail; } -/* Read the bootblock. */ -grub_disk_read (disk,0 ,0 ,sizeof (struct grub_affs_bblock ), - (char *) &data->bblock); -if (grub_errno) - goto fail; -/* No sane person uses more than 8KB for a block. At least I hope for that person because in that case this won't work. */ rootblock =grub_malloc (GRUB_DISK_SECTOR_SIZE *16 );
@@ -209,7 +214,7 @@ rblock = (struct grub_affs_rblock *) rootblock;/* Read the rootblock. */ -grub_disk_read (disk, (disk->total_sectors >>1 ) + blocksize,0 , +grub_disk_read (disk, (data->len >>1 ) + blocksize,0 ,GRUB_DISK_SECTOR_SIZE *16 , (char *) rootblock);if (grub_errno) goto fail;
@@ -241,7 +246,7 @@ data->disk = disk; data->htsize =grub_be_to_cpu32 (rblock->htsize); data->diropen.data = data; - data->diropen.block = (disk->total_sectors >>1 ); + data->diropen.block = (data->len >>1 );grub_free (rootblock);
@@ -522,7 +527,7 @@ {/* The rootblock maps quite well on a file header block, it's something we can use here. */ -grub_disk_read (data->disk, disk->total_sectors >>1 , +grub_disk_read (data->disk, data->len >>1 , data->blocksize * (GRUB_DISK_SECTOR_SIZE -GRUB_AFFS_FILE_LOCATION ),sizeof (file), (char *) &file);