grub/grub-core/loader/multiboot.c

469 lines
11 KiB
C
Raw Normal View History

/* multiboot.c - boot a multiboot OS image. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org> Migrate to GNU General Public License Version 3. * COPYING: Replaced with the plain text version of GPLv3. * config.guess: Updated from gnulib. * config.sub: Likewise. * geninit.sh: Output a GPLv3 copyright notice. * geninitheader.sh: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh.in: Likewise. * boot/i386/pc/boot.S: Upgraded to GPLv3. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/echo.c: Likewise. * commands/help.c: Likewise. * commands/ls.c: Likewise. * commands/search.c: Likewise. * commands/terminal.c: Likewise. * commands/test.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/reboot.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/halt.c: Likewise. * commands/ieee1275/reboot.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * font/manager.c: Likewise. * fs/affs.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * fs/fshelp.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/sfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * hello/hello.c: Likewise. * include/grub/acorn_filecore.h: Likewise. * include/grub/arg.h: Likewise. * include/grub/bitmap.h: Likewise. * include/grub/boot.h: Likewise. * include/grub/cache.h: Likewise. * include/grub/device.h: Likewise. * include/grub/disk.h: Likewise. * include/grub/dl.h: Likewise. * include/grub/elfload.h: Likewise. * include/grub/env.h: Likewise. * include/grub/err.h: Likewise. * include/grub/file.h: Likewise. * include/grub/font.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/fshelp.h: Likewise. * include/grub/gzio.h: Likewise. * include/grub/hfs.h: Likewise. * include/grub/kernel.h: Likewise. * include/grub/loader.h: Likewise. * include/grub/lvm.h: Likewise. * include/grub/misc.h: Likewise. * include/grub/mm.h: Likewise. * include/grub/net.h: Likewise. * include/grub/normal.h: Likewise. * include/grub/parser.h: Likewise. * include/grub/partition.h: Likewise. * include/grub/pc_partition.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/rescue.h: Likewise. * include/grub/script.h: Likewise. * include/grub/setjmp.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/term.h: Likewise. * include/grub/terminfo.h: Likewise. * include/grub/tparm.h: Likewise. * include/grub/types.h: Likewise. * include/grub/video.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/chainloader.h: Likewise. * include/grub/efi/console.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/disk.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/efi/time.h: Likewise. * include/grub/i386/linux.h: Likewise. * include/grub/i386/setjmp.h: Likewise. * include/grub/i386/types.h: Likewise. * include/grub/i386/efi/kernel.h: Likewise. * include/grub/i386/efi/loader.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * include/grub/i386/pc/biosdisk.h: Likewise. * include/grub/i386/pc/boot.h: Likewise. * include/grub/i386/pc/chainloader.h: Likewise. * include/grub/i386/pc/console.h: Likewise. * include/grub/i386/pc/init.h: Likewise. * include/grub/i386/pc/kernel.h: Likewise. * include/grub/i386/pc/loader.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/multiboot.h: Likewise. * include/grub/i386/pc/serial.h: Likewise. * include/grub/i386/pc/time.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pc/vbeblit.h: Likewise. * include/grub/i386/pc/vbefill.h: Likewise. * include/grub/i386/pc/vbeutil.h: Likewise. * include/grub/i386/pc/vga.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ieee1275/ofdisk.h: Likewise. * include/grub/powerpc/libgcc.h: Likewise. * include/grub/powerpc/setjmp.h: Likewise. * include/grub/powerpc/types.h: Likewise. * include/grub/powerpc/ieee1275/biosdisk.h: Likewise. * include/grub/powerpc/ieee1275/console.h: Likewise. * include/grub/powerpc/ieee1275/ieee1275.h: Likewise. * include/grub/powerpc/ieee1275/kernel.h: Likewise. * include/grub/powerpc/ieee1275/loader.h: Likewise. * include/grub/powerpc/ieee1275/multiboot.h: Likewise. * include/grub/powerpc/ieee1275/time.h: Likewise. * include/grub/powerpc/ieee1275/util/biosdisk.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/sparc64/setjmp.h: Likewise. * include/grub/sparc64/types.h: Likewise. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/ieee1275/kernel.h: Likewise. * include/grub/sparc64/ieee1275/time.h: Likewise. * include/grub/util/biosdisk.h: Likewise. * include/grub/util/getroot.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/misc.h: Likewise. * include/grub/util/raid.h: Likewise. * include/grub/util/resolve.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/elf.c: Likewise. * kern/env.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/parser.c: Likewise. * kern/partition.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/init.c: Likewise. * kern/efi/mm.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/powerpc/cache.S: Likewise. * kern/powerpc/dl.c: Likewise. * kern/powerpc/ieee1275/cmain.c: Likewise. * kern/powerpc/ieee1275/crt0.S: Likewise. * kern/powerpc/ieee1275/init.c: Likewise. * kern/powerpc/ieee1275/openfw.c: Likewise. * kern/sparc64/cache.S: Likewise. * kern/sparc64/dl.c: Likewise. * kern/sparc64/ieee1275/init.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/linux_normal.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/linux_normal.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * normal/arg.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/completion.c: Likewise. * normal/execute.c: Likewise. * normal/function.c: Likewise. * normal/lexer.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/menu_entry.c: Likewise. * normal/misc.c: Likewise. * normal/parser.y: Likewise. * normal/script.c: Likewise. * normal/i386/setjmp.S: Likewise. * normal/powerpc/setjmp.S: Likewise. * normal/sparc64/setjmp.S: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * partmap/gpt.c: Likewise. * partmap/pc.c: Likewise. * partmap/sun.c: Likewise. * term/gfxterm.c: Likewise. * term/terminfo.c: Likewise. * term/efi/console.c: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vesafb.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * util/biosdisk.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/getroot.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-probe.c: Likewise. * util/lvm.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. * util/resolve.c: Likewise. * util/update-grub.in: Likewise. * util/update-grub_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/i386/efi/grub-install.in: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkrescue.in: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/misc.c: Likewise. * util/powerpc/ieee1275/grub-install.in: Likewise. * util/powerpc/ieee1275/grub-mkimage.c: Likewise. * util/powerpc/ieee1275/misc.c: Likewise. * video/bitmap.c: Likewise. * video/video.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/i386/pc/vbeblit.c: Likewise. * video/i386/pc/vbefill.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * video/readers/tga.c: Likewise.
2007-07-21 23:32:33 +00:00
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org> Migrate to GNU General Public License Version 3. * COPYING: Replaced with the plain text version of GPLv3. * config.guess: Updated from gnulib. * config.sub: Likewise. * geninit.sh: Output a GPLv3 copyright notice. * geninitheader.sh: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh.in: Likewise. * boot/i386/pc/boot.S: Upgraded to GPLv3. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/echo.c: Likewise. * commands/help.c: Likewise. * commands/ls.c: Likewise. * commands/search.c: Likewise. * commands/terminal.c: Likewise. * commands/test.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/reboot.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/halt.c: Likewise. * commands/ieee1275/reboot.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * font/manager.c: Likewise. * fs/affs.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * fs/fshelp.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/sfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * hello/hello.c: Likewise. * include/grub/acorn_filecore.h: Likewise. * include/grub/arg.h: Likewise. * include/grub/bitmap.h: Likewise. * include/grub/boot.h: Likewise. * include/grub/cache.h: Likewise. * include/grub/device.h: Likewise. * include/grub/disk.h: Likewise. * include/grub/dl.h: Likewise. * include/grub/elfload.h: Likewise. * include/grub/env.h: Likewise. * include/grub/err.h: Likewise. * include/grub/file.h: Likewise. * include/grub/font.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/fshelp.h: Likewise. * include/grub/gzio.h: Likewise. * include/grub/hfs.h: Likewise. * include/grub/kernel.h: Likewise. * include/grub/loader.h: Likewise. * include/grub/lvm.h: Likewise. * include/grub/misc.h: Likewise. * include/grub/mm.h: Likewise. * include/grub/net.h: Likewise. * include/grub/normal.h: Likewise. * include/grub/parser.h: Likewise. * include/grub/partition.h: Likewise. * include/grub/pc_partition.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/rescue.h: Likewise. * include/grub/script.h: Likewise. * include/grub/setjmp.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/term.h: Likewise. * include/grub/terminfo.h: Likewise. * include/grub/tparm.h: Likewise. * include/grub/types.h: Likewise. * include/grub/video.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/chainloader.h: Likewise. * include/grub/efi/console.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/disk.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/efi/time.h: Likewise. * include/grub/i386/linux.h: Likewise. * include/grub/i386/setjmp.h: Likewise. * include/grub/i386/types.h: Likewise. * include/grub/i386/efi/kernel.h: Likewise. * include/grub/i386/efi/loader.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * include/grub/i386/pc/biosdisk.h: Likewise. * include/grub/i386/pc/boot.h: Likewise. * include/grub/i386/pc/chainloader.h: Likewise. * include/grub/i386/pc/console.h: Likewise. * include/grub/i386/pc/init.h: Likewise. * include/grub/i386/pc/kernel.h: Likewise. * include/grub/i386/pc/loader.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/multiboot.h: Likewise. * include/grub/i386/pc/serial.h: Likewise. * include/grub/i386/pc/time.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pc/vbeblit.h: Likewise. * include/grub/i386/pc/vbefill.h: Likewise. * include/grub/i386/pc/vbeutil.h: Likewise. * include/grub/i386/pc/vga.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ieee1275/ofdisk.h: Likewise. * include/grub/powerpc/libgcc.h: Likewise. * include/grub/powerpc/setjmp.h: Likewise. * include/grub/powerpc/types.h: Likewise. * include/grub/powerpc/ieee1275/biosdisk.h: Likewise. * include/grub/powerpc/ieee1275/console.h: Likewise. * include/grub/powerpc/ieee1275/ieee1275.h: Likewise. * include/grub/powerpc/ieee1275/kernel.h: Likewise. * include/grub/powerpc/ieee1275/loader.h: Likewise. * include/grub/powerpc/ieee1275/multiboot.h: Likewise. * include/grub/powerpc/ieee1275/time.h: Likewise. * include/grub/powerpc/ieee1275/util/biosdisk.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/sparc64/setjmp.h: Likewise. * include/grub/sparc64/types.h: Likewise. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/ieee1275/kernel.h: Likewise. * include/grub/sparc64/ieee1275/time.h: Likewise. * include/grub/util/biosdisk.h: Likewise. * include/grub/util/getroot.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/misc.h: Likewise. * include/grub/util/raid.h: Likewise. * include/grub/util/resolve.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/elf.c: Likewise. * kern/env.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/parser.c: Likewise. * kern/partition.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/init.c: Likewise. * kern/efi/mm.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/powerpc/cache.S: Likewise. * kern/powerpc/dl.c: Likewise. * kern/powerpc/ieee1275/cmain.c: Likewise. * kern/powerpc/ieee1275/crt0.S: Likewise. * kern/powerpc/ieee1275/init.c: Likewise. * kern/powerpc/ieee1275/openfw.c: Likewise. * kern/sparc64/cache.S: Likewise. * kern/sparc64/dl.c: Likewise. * kern/sparc64/ieee1275/init.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/linux_normal.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/linux_normal.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * normal/arg.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/completion.c: Likewise. * normal/execute.c: Likewise. * normal/function.c: Likewise. * normal/lexer.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/menu_entry.c: Likewise. * normal/misc.c: Likewise. * normal/parser.y: Likewise. * normal/script.c: Likewise. * normal/i386/setjmp.S: Likewise. * normal/powerpc/setjmp.S: Likewise. * normal/sparc64/setjmp.S: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * partmap/gpt.c: Likewise. * partmap/pc.c: Likewise. * partmap/sun.c: Likewise. * term/gfxterm.c: Likewise. * term/terminfo.c: Likewise. * term/efi/console.c: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vesafb.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * util/biosdisk.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/getroot.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-probe.c: Likewise. * util/lvm.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. * util/resolve.c: Likewise. * util/update-grub.in: Likewise. * util/update-grub_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/i386/efi/grub-install.in: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkrescue.in: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/misc.c: Likewise. * util/powerpc/ieee1275/grub-install.in: Likewise. * util/powerpc/ieee1275/grub-mkimage.c: Likewise. * util/powerpc/ieee1275/misc.c: Likewise. * video/bitmap.c: Likewise. * video/video.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/i386/pc/vbeblit.c: Likewise. * video/i386/pc/vbefill.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * video/readers/tga.c: Likewise.
2007-07-21 23:32:33 +00:00
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org> Migrate to GNU General Public License Version 3. * COPYING: Replaced with the plain text version of GPLv3. * config.guess: Updated from gnulib. * config.sub: Likewise. * geninit.sh: Output a GPLv3 copyright notice. * geninitheader.sh: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh.in: Likewise. * boot/i386/pc/boot.S: Upgraded to GPLv3. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/echo.c: Likewise. * commands/help.c: Likewise. * commands/ls.c: Likewise. * commands/search.c: Likewise. * commands/terminal.c: Likewise. * commands/test.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/reboot.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/halt.c: Likewise. * commands/ieee1275/reboot.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * font/manager.c: Likewise. * fs/affs.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * fs/fshelp.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/sfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * hello/hello.c: Likewise. * include/grub/acorn_filecore.h: Likewise. * include/grub/arg.h: Likewise. * include/grub/bitmap.h: Likewise. * include/grub/boot.h: Likewise. * include/grub/cache.h: Likewise. * include/grub/device.h: Likewise. * include/grub/disk.h: Likewise. * include/grub/dl.h: Likewise. * include/grub/elfload.h: Likewise. * include/grub/env.h: Likewise. * include/grub/err.h: Likewise. * include/grub/file.h: Likewise. * include/grub/font.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/fshelp.h: Likewise. * include/grub/gzio.h: Likewise. * include/grub/hfs.h: Likewise. * include/grub/kernel.h: Likewise. * include/grub/loader.h: Likewise. * include/grub/lvm.h: Likewise. * include/grub/misc.h: Likewise. * include/grub/mm.h: Likewise. * include/grub/net.h: Likewise. * include/grub/normal.h: Likewise. * include/grub/parser.h: Likewise. * include/grub/partition.h: Likewise. * include/grub/pc_partition.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/rescue.h: Likewise. * include/grub/script.h: Likewise. * include/grub/setjmp.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/term.h: Likewise. * include/grub/terminfo.h: Likewise. * include/grub/tparm.h: Likewise. * include/grub/types.h: Likewise. * include/grub/video.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/chainloader.h: Likewise. * include/grub/efi/console.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/disk.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/efi/time.h: Likewise. * include/grub/i386/linux.h: Likewise. * include/grub/i386/setjmp.h: Likewise. * include/grub/i386/types.h: Likewise. * include/grub/i386/efi/kernel.h: Likewise. * include/grub/i386/efi/loader.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * include/grub/i386/pc/biosdisk.h: Likewise. * include/grub/i386/pc/boot.h: Likewise. * include/grub/i386/pc/chainloader.h: Likewise. * include/grub/i386/pc/console.h: Likewise. * include/grub/i386/pc/init.h: Likewise. * include/grub/i386/pc/kernel.h: Likewise. * include/grub/i386/pc/loader.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/multiboot.h: Likewise. * include/grub/i386/pc/serial.h: Likewise. * include/grub/i386/pc/time.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pc/vbeblit.h: Likewise. * include/grub/i386/pc/vbefill.h: Likewise. * include/grub/i386/pc/vbeutil.h: Likewise. * include/grub/i386/pc/vga.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ieee1275/ofdisk.h: Likewise. * include/grub/powerpc/libgcc.h: Likewise. * include/grub/powerpc/setjmp.h: Likewise. * include/grub/powerpc/types.h: Likewise. * include/grub/powerpc/ieee1275/biosdisk.h: Likewise. * include/grub/powerpc/ieee1275/console.h: Likewise. * include/grub/powerpc/ieee1275/ieee1275.h: Likewise. * include/grub/powerpc/ieee1275/kernel.h: Likewise. * include/grub/powerpc/ieee1275/loader.h: Likewise. * include/grub/powerpc/ieee1275/multiboot.h: Likewise. * include/grub/powerpc/ieee1275/time.h: Likewise. * include/grub/powerpc/ieee1275/util/biosdisk.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/sparc64/setjmp.h: Likewise. * include/grub/sparc64/types.h: Likewise. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/ieee1275/kernel.h: Likewise. * include/grub/sparc64/ieee1275/time.h: Likewise. * include/grub/util/biosdisk.h: Likewise. * include/grub/util/getroot.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/misc.h: Likewise. * include/grub/util/raid.h: Likewise. * include/grub/util/resolve.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/elf.c: Likewise. * kern/env.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/parser.c: Likewise. * kern/partition.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/init.c: Likewise. * kern/efi/mm.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/powerpc/cache.S: Likewise. * kern/powerpc/dl.c: Likewise. * kern/powerpc/ieee1275/cmain.c: Likewise. * kern/powerpc/ieee1275/crt0.S: Likewise. * kern/powerpc/ieee1275/init.c: Likewise. * kern/powerpc/ieee1275/openfw.c: Likewise. * kern/sparc64/cache.S: Likewise. * kern/sparc64/dl.c: Likewise. * kern/sparc64/ieee1275/init.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/linux_normal.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/linux_normal.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * normal/arg.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/completion.c: Likewise. * normal/execute.c: Likewise. * normal/function.c: Likewise. * normal/lexer.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/menu_entry.c: Likewise. * normal/misc.c: Likewise. * normal/parser.y: Likewise. * normal/script.c: Likewise. * normal/i386/setjmp.S: Likewise. * normal/powerpc/setjmp.S: Likewise. * normal/sparc64/setjmp.S: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * partmap/gpt.c: Likewise. * partmap/pc.c: Likewise. * partmap/sun.c: Likewise. * term/gfxterm.c: Likewise. * term/terminfo.c: Likewise. * term/efi/console.c: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vesafb.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * util/biosdisk.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/getroot.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-probe.c: Likewise. * util/lvm.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. * util/resolve.c: Likewise. * util/update-grub.in: Likewise. * util/update-grub_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/i386/efi/grub-install.in: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkrescue.in: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/misc.c: Likewise. * util/powerpc/ieee1275/grub-install.in: Likewise. * util/powerpc/ieee1275/grub-mkimage.c: Likewise. * util/powerpc/ieee1275/misc.c: Likewise. * video/bitmap.c: Likewise. * video/video.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/i386/pc/vbeblit.c: Likewise. * video/i386/pc/vbefill.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * video/readers/tga.c: Likewise.
2007-07-21 23:32:33 +00:00
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org> Migrate to GNU General Public License Version 3. * COPYING: Replaced with the plain text version of GPLv3. * config.guess: Updated from gnulib. * config.sub: Likewise. * geninit.sh: Output a GPLv3 copyright notice. * geninitheader.sh: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh.in: Likewise. * boot/i386/pc/boot.S: Upgraded to GPLv3. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/echo.c: Likewise. * commands/help.c: Likewise. * commands/ls.c: Likewise. * commands/search.c: Likewise. * commands/terminal.c: Likewise. * commands/test.c: Likewise. * commands/videotest.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/reboot.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/halt.c: Likewise. * commands/ieee1275/reboot.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * font/manager.c: Likewise. * fs/affs.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * fs/fshelp.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/sfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * hello/hello.c: Likewise. * include/grub/acorn_filecore.h: Likewise. * include/grub/arg.h: Likewise. * include/grub/bitmap.h: Likewise. * include/grub/boot.h: Likewise. * include/grub/cache.h: Likewise. * include/grub/device.h: Likewise. * include/grub/disk.h: Likewise. * include/grub/dl.h: Likewise. * include/grub/elfload.h: Likewise. * include/grub/env.h: Likewise. * include/grub/err.h: Likewise. * include/grub/file.h: Likewise. * include/grub/font.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/fshelp.h: Likewise. * include/grub/gzio.h: Likewise. * include/grub/hfs.h: Likewise. * include/grub/kernel.h: Likewise. * include/grub/loader.h: Likewise. * include/grub/lvm.h: Likewise. * include/grub/misc.h: Likewise. * include/grub/mm.h: Likewise. * include/grub/net.h: Likewise. * include/grub/normal.h: Likewise. * include/grub/parser.h: Likewise. * include/grub/partition.h: Likewise. * include/grub/pc_partition.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/rescue.h: Likewise. * include/grub/script.h: Likewise. * include/grub/setjmp.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/term.h: Likewise. * include/grub/terminfo.h: Likewise. * include/grub/tparm.h: Likewise. * include/grub/types.h: Likewise. * include/grub/video.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/chainloader.h: Likewise. * include/grub/efi/console.h: Likewise. * include/grub/efi/console_control.h: Likewise. * include/grub/efi/disk.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/efi/time.h: Likewise. * include/grub/i386/linux.h: Likewise. * include/grub/i386/setjmp.h: Likewise. * include/grub/i386/types.h: Likewise. * include/grub/i386/efi/kernel.h: Likewise. * include/grub/i386/efi/loader.h: Likewise. * include/grub/i386/efi/time.h: Likewise. * include/grub/i386/pc/biosdisk.h: Likewise. * include/grub/i386/pc/boot.h: Likewise. * include/grub/i386/pc/chainloader.h: Likewise. * include/grub/i386/pc/console.h: Likewise. * include/grub/i386/pc/init.h: Likewise. * include/grub/i386/pc/kernel.h: Likewise. * include/grub/i386/pc/loader.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/multiboot.h: Likewise. * include/grub/i386/pc/serial.h: Likewise. * include/grub/i386/pc/time.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pc/vbeblit.h: Likewise. * include/grub/i386/pc/vbefill.h: Likewise. * include/grub/i386/pc/vbeutil.h: Likewise. * include/grub/i386/pc/vga.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ieee1275/ofdisk.h: Likewise. * include/grub/powerpc/libgcc.h: Likewise. * include/grub/powerpc/setjmp.h: Likewise. * include/grub/powerpc/types.h: Likewise. * include/grub/powerpc/ieee1275/biosdisk.h: Likewise. * include/grub/powerpc/ieee1275/console.h: Likewise. * include/grub/powerpc/ieee1275/ieee1275.h: Likewise. * include/grub/powerpc/ieee1275/kernel.h: Likewise. * include/grub/powerpc/ieee1275/loader.h: Likewise. * include/grub/powerpc/ieee1275/multiboot.h: Likewise. * include/grub/powerpc/ieee1275/time.h: Likewise. * include/grub/powerpc/ieee1275/util/biosdisk.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/sparc64/setjmp.h: Likewise. * include/grub/sparc64/types.h: Likewise. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/ieee1275/kernel.h: Likewise. * include/grub/sparc64/ieee1275/time.h: Likewise. * include/grub/util/biosdisk.h: Likewise. * include/grub/util/getroot.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/misc.h: Likewise. * include/grub/util/raid.h: Likewise. * include/grub/util/resolve.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/elf.c: Likewise. * kern/env.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/parser.c: Likewise. * kern/partition.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/init.c: Likewise. * kern/efi/mm.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/efi/init.c: Likewise. * kern/i386/efi/startup.S: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/powerpc/cache.S: Likewise. * kern/powerpc/dl.c: Likewise. * kern/powerpc/ieee1275/cmain.c: Likewise. * kern/powerpc/ieee1275/crt0.S: Likewise. * kern/powerpc/ieee1275/init.c: Likewise. * kern/powerpc/ieee1275/openfw.c: Likewise. * kern/sparc64/cache.S: Likewise. * kern/sparc64/dl.c: Likewise. * kern/sparc64/ieee1275/init.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/linux_normal.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/chainloader_normal.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/linux_normal.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/pc/multiboot_normal.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/powerpc/ieee1275/linux_normal.c: Likewise. * normal/arg.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/completion.c: Likewise. * normal/execute.c: Likewise. * normal/function.c: Likewise. * normal/lexer.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/menu_entry.c: Likewise. * normal/misc.c: Likewise. * normal/parser.y: Likewise. * normal/script.c: Likewise. * normal/i386/setjmp.S: Likewise. * normal/powerpc/setjmp.S: Likewise. * normal/sparc64/setjmp.S: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * partmap/gpt.c: Likewise. * partmap/pc.c: Likewise. * partmap/sun.c: Likewise. * term/gfxterm.c: Likewise. * term/terminfo.c: Likewise. * term/efi/console.c: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vesafb.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * util/biosdisk.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/getroot.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-probe.c: Likewise. * util/lvm.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. * util/resolve.c: Likewise. * util/update-grub.in: Likewise. * util/update-grub_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/i386/efi/grub-install.in: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkrescue.in: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/misc.c: Likewise. * util/powerpc/ieee1275/grub-install.in: Likewise. * util/powerpc/ieee1275/grub-mkimage.c: Likewise. * util/powerpc/ieee1275/misc.c: Likewise. * video/bitmap.c: Likewise. * video/video.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/i386/pc/vbeblit.c: Likewise. * video/i386/pc/vbefill.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * video/readers/tga.c: Likewise.
2007-07-21 23:32:33 +00:00
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* FIXME: The following features from the Multiboot specification still
* need to be implemented:
* - drives table
* - ROM configuration table
2010-09-21 06:37:50 +00:00
* - SMBIOS tables
* - Networking information
*/
#include <grub/loader.h>
2010-03-08 14:40:57 +00:00
#include <grub/command.h>
#ifdef GRUB_USE_MULTIBOOT2
#include <grub/multiboot2.h>
#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER
#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT
#define GRUB_MULTIBOOT(x) grub_multiboot2_ ## x
#else
#include <grub/multiboot.h>
#define GRUB_MULTIBOOT(x) grub_multiboot_ ## x
#endif
#include <grub/cpu/multiboot.h>
#include <grub/elf.h>
#include <grub/aout.h>
#include <grub/file.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/env.h>
2010-04-03 12:14:48 +00:00
#include <grub/cpu/relocator.h>
#include <grub/video.h>
2010-01-16 15:25:43 +00:00
#include <grub/memory.h>
2010-03-08 14:40:57 +00:00
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
#ifdef GRUB_MACHINE_EFI
#include <grub/efi/efi.h>
#endif
struct grub_relocator *GRUB_MULTIBOOT (relocator) = NULL;
grub_uint32_t GRUB_MULTIBOOT (payload_eip);
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
2010-01-16 15:25:43 +00:00
#define DEFAULT_VIDEO_MODE "text"
#else
#define DEFAULT_VIDEO_MODE "auto"
#endif
static int accepts_video;
2010-03-10 10:40:20 +00:00
static int accepts_ega_text;
static int console_required;
2010-03-08 14:40:57 +00:00
static grub_dl_t my_mod;
2010-01-16 15:25:43 +00:00
Remove nested functions from memory map iterators. * grub-core/efiemu/mm.c (grub_efiemu_mmap_iterate): Add hook_data argument, passed to hook. * grub-core/kern/i386/coreboot/mmap.c (grub_linuxbios_table_iterate): Likewise. (grub_machine_mmap_iterate: iterate_linuxbios_table): Make static instead of nested. (grub_machine_mmap_iterate): Add hook_data argument. * grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_iterate): Add hook_data argument, passed to hook. * grub-core/kern/i386/pc/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/i386/qemu/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/arc/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/loongson/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/qemu_mips/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/mmap/efi/mmap.c (grub_efi_mmap_iterate): Likewise. (grub_machine_mmap_iterate): Likewise. * grub-core/mmap/mmap.c (grub_mmap_iterate): Likewise. * include/grub/efiemu/efiemu.h (grub_efiemu_mmap_iterate): Update prototype. * include/grub/memory.h (grub_memory_hook_t): Add data argument. Remove NESTED_FUNC_ATTR from here and from all users. (grub_mmap_iterate): Update prototype. (grub_efi_mmap_iterate): Update prototype. Update all callers to pass appropriate hook data. (grub_machine_mmap_iterate): Likewise. * grub-core/commands/acpi.c (grub_acpi_create_ebda: find_hook): Make static instead of nested. * grub-core/commands/lsmmap.c (grub_cmd_lsmmap: hook): Likewise. Rename to ... (lsmmap_hook): ... this. * grub-core/efiemu/mm.c (grub_efiemu_mmap_init: bounds_hook): Likewise. (grub_efiemu_mmap_fill: fill_hook): Likewise. * grub-core/kern/i386/coreboot/init.c (grub_machine_init: heap_init): Likewise. * grub-core/kern/i386/pc/init.c (grub_machine_init: hook): Likewise. Rename to ... (mmap_iterate_hook): ... this. * grub-core/kern/ieee1275/init.c (grub_claim_heap: heap_init): Likewise. * grub-core/lib/ieee1275/relocator.c (grub_relocator_firmware_get_max_events: count): Likewise. (grub_relocator_firmware_fill_events: fill): Likewise. Rename to ... (grub_relocator_firmware_fill_events_iter): ... this. * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align: hook): Likewise. Rename to ... (grub_relocator_alloc_chunk_align_iter): ... this. * grub-core/loader/i386/bsd.c (generate_e820_mmap: hook): Likewise. Rename to ... (generate_e820_mmap_iter): ... this. * grub-core/loader/i386/linux.c (find_mmap_size: hook): Likewise. Rename to ... (count_hook): ... this. (grub_linux_boot: hook): Likewise. Rename to ... (grub_linux_boot_mmap_find): ... this. (grub_linux_boot: hook_fill): Likewise. Rename to ... (grub_linux_boot_mmap_fill): ... this. * grub-core/loader/i386/multiboot_mbi.c (grub_fill_multiboot_mmap: hook): Likewise. Rename to ... (grub_fill_multiboot_mmap_iter): ... this. * grub-core/loader/multiboot.c (grub_get_multiboot_mmap_count: hook): Likewise. Rename to ... (count_hook): ... this. * grub-core/loader/multiboot_mbi2.c (grub_fill_multiboot_mmap: hook): Likewise. Rename to ... (grub_fill_multiboot_mmap_iter): ... this. * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_claimmap_iterate: alloc_mem): Likewise. * grub-core/loader/sparc64/ieee1275/linux.c (alloc_phys: choose): Likewise. Rename to ... (alloc_phys_choose): ... this. (determine_phys_base: get_physbase): Likewise. * grub-core/mmap/i386/mmap.c (grub_mmap_malign_and_register: find_hook): Likewise. * grub-core/mmap/i386/pc/mmap.c (preboot: fill_hook): Likewise. (malloc_hook: count_hook): Likewise. * grub-core/mmap/i386/uppermem.c (grub_mmap_get_lower: hook): Likewise. Rename to ... (lower_hook): ... this. (grub_mmap_get_upper: hook): Likewise. Rename to ... (upper_hook): ... this. (grub_mmap_get_post64: hook): Likewise. Rename to ... (post64_hook): ... this. * grub-core/mmap/mips/uppermem.c (grub_mmap_get_lower: hook): Likewise. Rename to ... (lower_hook): ... this. (grub_mmap_get_upper: hook): Likewise. Rename to ... (upper_hook): ... this. * grub-core/mmap/mmap.c (grub_mmap_iterate: count_hook): Likewise. (grub_mmap_iterate: fill_hook): Likewise. (fill_mask): Pass addr and mask within a single struct. (grub_cmd_badram: hook): Make static instead of nested. Rename to ... (badram_iter): ... this. (grub_cmd_cutmem: hook): Likewise. Rename to ... (cutmem_iter): ... this.
2013-01-15 12:02:35 +00:00
/* Helper for grub_get_multiboot_mmap_count. */
static int
count_hook (grub_uint64_t addr __attribute__ ((unused)),
grub_uint64_t size __attribute__ ((unused)),
grub_memory_type_t type __attribute__ ((unused)), void *data)
{
grub_size_t *count = data;
(*count)++;
return 0;
}
2010-01-16 15:25:43 +00:00
/* Return the length of the Multiboot mmap that will be needed to allocate
our platform's map. */
grub_uint32_t
GRUB_MULTIBOOT (get_mmap_count) (void)
2010-01-16 15:25:43 +00:00
{
grub_size_t count = 0;
Remove nested functions from memory map iterators. * grub-core/efiemu/mm.c (grub_efiemu_mmap_iterate): Add hook_data argument, passed to hook. * grub-core/kern/i386/coreboot/mmap.c (grub_linuxbios_table_iterate): Likewise. (grub_machine_mmap_iterate: iterate_linuxbios_table): Make static instead of nested. (grub_machine_mmap_iterate): Add hook_data argument. * grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_iterate): Add hook_data argument, passed to hook. * grub-core/kern/i386/pc/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/i386/qemu/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/arc/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/loongson/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/kern/mips/qemu_mips/init.c (grub_machine_mmap_iterate): Likewise. * grub-core/mmap/efi/mmap.c (grub_efi_mmap_iterate): Likewise. (grub_machine_mmap_iterate): Likewise. * grub-core/mmap/mmap.c (grub_mmap_iterate): Likewise. * include/grub/efiemu/efiemu.h (grub_efiemu_mmap_iterate): Update prototype. * include/grub/memory.h (grub_memory_hook_t): Add data argument. Remove NESTED_FUNC_ATTR from here and from all users. (grub_mmap_iterate): Update prototype. (grub_efi_mmap_iterate): Update prototype. Update all callers to pass appropriate hook data. (grub_machine_mmap_iterate): Likewise. * grub-core/commands/acpi.c (grub_acpi_create_ebda: find_hook): Make static instead of nested. * grub-core/commands/lsmmap.c (grub_cmd_lsmmap: hook): Likewise. Rename to ... (lsmmap_hook): ... this. * grub-core/efiemu/mm.c (grub_efiemu_mmap_init: bounds_hook): Likewise. (grub_efiemu_mmap_fill: fill_hook): Likewise. * grub-core/kern/i386/coreboot/init.c (grub_machine_init: heap_init): Likewise. * grub-core/kern/i386/pc/init.c (grub_machine_init: hook): Likewise. Rename to ... (mmap_iterate_hook): ... this. * grub-core/kern/ieee1275/init.c (grub_claim_heap: heap_init): Likewise. * grub-core/lib/ieee1275/relocator.c (grub_relocator_firmware_get_max_events: count): Likewise. (grub_relocator_firmware_fill_events: fill): Likewise. Rename to ... (grub_relocator_firmware_fill_events_iter): ... this. * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align: hook): Likewise. Rename to ... (grub_relocator_alloc_chunk_align_iter): ... this. * grub-core/loader/i386/bsd.c (generate_e820_mmap: hook): Likewise. Rename to ... (generate_e820_mmap_iter): ... this. * grub-core/loader/i386/linux.c (find_mmap_size: hook): Likewise. Rename to ... (count_hook): ... this. (grub_linux_boot: hook): Likewise. Rename to ... (grub_linux_boot_mmap_find): ... this. (grub_linux_boot: hook_fill): Likewise. Rename to ... (grub_linux_boot_mmap_fill): ... this. * grub-core/loader/i386/multiboot_mbi.c (grub_fill_multiboot_mmap: hook): Likewise. Rename to ... (grub_fill_multiboot_mmap_iter): ... this. * grub-core/loader/multiboot.c (grub_get_multiboot_mmap_count: hook): Likewise. Rename to ... (count_hook): ... this. * grub-core/loader/multiboot_mbi2.c (grub_fill_multiboot_mmap: hook): Likewise. Rename to ... (grub_fill_multiboot_mmap_iter): ... this. * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_claimmap_iterate: alloc_mem): Likewise. * grub-core/loader/sparc64/ieee1275/linux.c (alloc_phys: choose): Likewise. Rename to ... (alloc_phys_choose): ... this. (determine_phys_base: get_physbase): Likewise. * grub-core/mmap/i386/mmap.c (grub_mmap_malign_and_register: find_hook): Likewise. * grub-core/mmap/i386/pc/mmap.c (preboot: fill_hook): Likewise. (malloc_hook: count_hook): Likewise. * grub-core/mmap/i386/uppermem.c (grub_mmap_get_lower: hook): Likewise. Rename to ... (lower_hook): ... this. (grub_mmap_get_upper: hook): Likewise. Rename to ... (upper_hook): ... this. (grub_mmap_get_post64: hook): Likewise. Rename to ... (post64_hook): ... this. * grub-core/mmap/mips/uppermem.c (grub_mmap_get_lower: hook): Likewise. Rename to ... (lower_hook): ... this. (grub_mmap_get_upper: hook): Likewise. Rename to ... (upper_hook): ... this. * grub-core/mmap/mmap.c (grub_mmap_iterate: count_hook): Likewise. (grub_mmap_iterate: fill_hook): Likewise. (fill_mask): Pass addr and mask within a single struct. (grub_cmd_badram: hook): Make static instead of nested. Rename to ... (badram_iter): ... this. (grub_cmd_cutmem: hook): Likewise. Rename to ... (cutmem_iter): ... this.
2013-01-15 12:02:35 +00:00
grub_mmap_iterate (count_hook, &count);
2010-01-16 15:25:43 +00:00
2010-03-07 13:59:15 +00:00
return count;
2010-01-16 15:25:43 +00:00
}
grub_err_t
GRUB_MULTIBOOT (set_video_mode) (void)
2010-01-16 15:25:43 +00:00
{
grub_err_t err;
const char *modevar;
#if GRUB_MACHINE_HAS_VGA_TEXT
if (accepts_video)
#endif
2010-01-16 15:25:43 +00:00
{
modevar = grub_env_get ("gfxpayload");
if (! modevar || *modevar == 0)
2010-03-07 12:01:43 +00:00
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0, 0);
2010-01-16 15:25:43 +00:00
else
{
char *tmp;
2010-03-07 12:01:43 +00:00
tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
2010-01-16 15:25:43 +00:00
if (! tmp)
return grub_errno;
2010-03-07 12:01:43 +00:00
err = grub_video_set_mode (tmp, 0, 0);
2010-01-16 15:25:43 +00:00
grub_free (tmp);
}
}
#if GRUB_MACHINE_HAS_VGA_TEXT
2010-01-16 15:25:43 +00:00
else
2010-03-07 12:01:43 +00:00
err = grub_video_set_mode ("text", 0, 0);
#endif
2010-01-16 15:25:43 +00:00
return err;
}
2009-11-25 22:39:59 +00:00
#ifdef GRUB_MACHINE_EFI
#ifdef __x86_64__
#define grub_relocator_efi_boot grub_relocator64_efi_boot
#define grub_relocator_efi_state grub_relocator64_efi_state
#endif
#endif
#ifdef grub_relocator_efi_boot
static void
efi_boot (struct grub_relocator *rel,
grub_uint32_t target)
{
struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE;
state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip;
state_efi.MULTIBOOT_EFI_MBI_REGISTER = target;
grub_relocator_efi_boot (rel, state_efi);
}
#else
#define grub_efi_is_finished 1
static void
efi_boot (struct grub_relocator *rel __attribute__ ((unused)),
grub_uint32_t target __attribute__ ((unused)))
{
}
#endif
#if defined (__i386__) || defined (__x86_64__)
static void
normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state)
{
grub_relocator32_boot (rel, state, 0);
}
#else
static void
normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state)
{
grub_relocator32_boot (rel, state);
}
#endif
static grub_err_t
grub_multiboot_boot (void)
{
2010-01-10 17:58:18 +00:00
grub_err_t err;
2010-04-03 12:14:48 +00:00
#ifdef GRUB_USE_MULTIBOOT2
struct grub_relocator32_state state = MULTIBOOT2_INITIAL_STATE;
#else
struct grub_relocator32_state state = MULTIBOOT_INITIAL_STATE;
#endif
state.MULTIBOOT_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip);
2009-11-25 22:39:59 +00:00
err = GRUB_MULTIBOOT (make_mbi) (&state.MULTIBOOT_MBI_REGISTER);
2010-01-10 17:58:18 +00:00
if (err)
return err;
if (grub_efi_is_finished)
normal_boot (GRUB_MULTIBOOT (relocator), state);
else
efi_boot (GRUB_MULTIBOOT (relocator), state.MULTIBOOT_MBI_REGISTER);
/* Not reached. */
return GRUB_ERR_NONE;
}
static grub_err_t
grub_multiboot_unload (void)
{
GRUB_MULTIBOOT (free_mbi) ();
2010-01-10 17:58:18 +00:00
grub_relocator_unload (GRUB_MULTIBOOT (relocator));
GRUB_MULTIBOOT (relocator) = NULL;
2009-06-10 21:04:23 +00:00
grub_dl_unref (my_mod);
return GRUB_ERR_NONE;
}
static grub_uint64_t highest_load;
#define MULTIBOOT_LOAD_ELF64
#include "multiboot_elfxx.c"
#undef MULTIBOOT_LOAD_ELF64
#define MULTIBOOT_LOAD_ELF32
#include "multiboot_elfxx.c"
#undef MULTIBOOT_LOAD_ELF32
/* Load ELF32 or ELF64. */
2010-03-08 14:40:57 +00:00
grub_err_t
GRUB_MULTIBOOT (load_elf) (mbi_load_data_t *mld)
{
multiboot2: Add support for relocatable images Currently multiboot2 protocol loads image exactly at address specified in ELF or multiboot2 header. This solution works quite well on legacy BIOS platforms. It is possible because memory regions are placed at predictable addresses (though I was not able to find any spec which says that it is strong requirement, so, it looks that it is just a goodwill of hardware designers). However, EFI platforms are more volatile. Even if required memory regions live at specific addresses then they are sometimes simply not free (e.g. used by boot/runtime services on Dell PowerEdge R820 and OVMF). This means that you are not able to just set up final image destination on build time. You have to provide method to relocate image contents to real load address which is usually different than load address specified in ELF and multiboot2 headers. This patch provides all needed machinery to do self relocation in image code. First of all GRUB2 reads min_addr (min. load addr), max_addr (max. load addr), align (required image alignment), preference (it says which memory regions are preferred by image, e.g. none, low, high) from multiboot_header_tag_relocatable header tag contained in binary (at this stage load addresses from multiboot2 and/or ELF headers are ignored). Later loader tries to fulfill request (not only that one) and if it succeeds then it informs image about real load address via multiboot_tag_load_base_addr tag. At this stage GRUB2 role is finished. Starting from now executable must cope with relocations itself using whole static and dynamic knowledge provided by boot loader. This patch does not provide functionality which could do relocations using ELF relocation data. However, I was asked by Konrad Rzeszutek Wilk and Vladimir 'phcoder' Serbinenko to investigate that thing. It looks that relevant machinery could be added to existing code (including this patch) without huge effort. Additionally, ELF relocation could live in parallel with self relocation provided by this patch. However, during research I realized that first of all we should establish the details how ELF relocatable image should look like and how it should be build. At least to build proper test/example files. So, this patch just provides support for self relocatable images. If ELF file with relocs is loaded then GRUB2 complains loudly and ignores it. Support for such files will be added later. This patch was tested with Xen image which uses that functionality. However, this Xen feature is still under development and new patchset will be released in about 2-3 weeks. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-07-17 19:02:09 +00:00
if (grub_multiboot_is_elf32 (mld->buffer))
return grub_multiboot_load_elf32 (mld);
else if (grub_multiboot_is_elf64 (mld->buffer))
return grub_multiboot_load_elf64 (mld);
return grub_error (GRUB_ERR_UNKNOWN_OS, N_("invalid arch-dependent ELF magic"));
}
2010-03-08 14:40:57 +00:00
grub_err_t
GRUB_MULTIBOOT (set_console) (int console_type, int accepted_consoles,
int width, int height, int depth,
int console_req)
{
2010-03-10 10:40:20 +00:00
console_required = console_req;
if (!(accepted_consoles
& (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER
| (GRUB_MACHINE_HAS_VGA_TEXT ? GRUB_MULTIBOOT_CONSOLE_EGA_TEXT : 0))))
{
2010-03-10 10:40:20 +00:00
if (console_required)
return grub_error (GRUB_ERR_BAD_OS,
"OS requires a console but none is available");
* grub-core/commands/acpihalt.c: Gettextized. * grub-core/commands/cacheinfo.c: Likewise. * grub-core/commands/cmp.c: Likewise. * grub-core/commands/efi/loadbios.c: Likewise. * grub-core/commands/gptsync.c: Likewise. * grub-core/commands/ieee1275/suspend.c: Likewise. * grub-core/commands/legacycfg.c: Likewise. * grub-core/commands/memrw.c: Likewise. * grub-core/commands/minicmd.c: Likewise. * grub-core/commands/parttool.c: Likewise. * grub-core/commands/time.c: Likewise. * grub-core/commands/videoinfo.c: Likewise. * grub-core/disk/geli.c: Likewise. * grub-core/disk/i386/pc/biosdisk.c: Likewise. * grub-core/disk/luks.c: Likewise. * grub-core/disk/lvm.c: Likewise. * grub-core/font/font_cmd.c: Likewise. * grub-core/fs/zfs/zfscrypt.c: Likewise. * grub-core/fs/zfs/zfsinfo.c: Likewise. * grub-core/gfxmenu/view.c: Likewise. * grub-core/kern/emu/hostdisk.c: Likewise. * grub-core/kern/emu/main.c: Likewise. * grub-core/kern/emu/misc.c: Likewise. * grub-core/kern/emu/mm.c: Likewise. * grub-core/kern/mips/arc/init.c: Likewise. * grub-core/kern/mips/loongson/init.c: Likewise. * grub-core/kern/partition.c: Likewise. * grub-core/lib/i386/halt.c: Likewise. * grub-core/lib/mips/arc/reboot.c: Likewise. * grub-core/lib/mips/loongson/reboot.c: Likewise. * grub-core/loader/i386/pc/chainloader.c: Likewise. * grub-core/loader/i386/xnu.c: Likewise. * grub-core/loader/multiboot.c: Likewise. * grub-core/net/bootp.c: Likewise. * grub-core/net/net.c: Likewise. * grub-core/normal/term.c: Likewise. * grub-core/partmap/bsdlabel.c: Likewise. * grub-core/parttool/msdospart.c: Likewise. * grub-core/term/gfxterm.c: Likewise. * grub-core/term/terminfo.c: Likewise. * grub-core/video/i386/pc/vbe.c: Likewise. * util/grub-menulst2cfg.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-mklayout.c: Likewise. * util/grub-mkrelpath.c: Likewise. * util/grub-script-check.c: Likewise. * util/ieee1275/grub-ofpathname.c: Likewise. * util/resolve.c: Likewise.
2011-11-11 20:44:56 +00:00
grub_puts_ (N_("WARNING: no console will be available to OS"));
2010-03-10 10:40:20 +00:00
accepts_video = 0;
accepts_ega_text = 0;
return GRUB_ERR_NONE;
}
2010-03-08 14:40:57 +00:00
if (console_type == GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER)
{
2010-03-08 14:40:57 +00:00
char *buf;
if (depth && width && height)
buf = grub_xasprintf ("%dx%dx%d,%dx%d,auto", width,
height, depth, width, height);
else if (width && height)
buf = grub_xasprintf ("%dx%d,auto", width, height);
else
buf = grub_strdup ("auto");
2010-03-08 14:40:57 +00:00
if (!buf)
return grub_errno;
grub_env_set ("gfxpayload", buf);
grub_free (buf);
}
else
{
#if GRUB_MACHINE_HAS_VGA_TEXT
grub_env_set ("gfxpayload", "text");
#else
/* Always use video if no VGA text is available. */
grub_env_set ("gfxpayload", "auto");
#endif
}
2010-03-08 14:40:57 +00:00
accepts_video = !!(accepted_consoles & GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER);
2010-03-10 10:40:20 +00:00
accepts_ega_text = !!(accepted_consoles & GRUB_MULTIBOOT_CONSOLE_EGA_TEXT);
2010-03-08 14:40:57 +00:00
return GRUB_ERR_NONE;
}
2010-03-08 14:40:57 +00:00
static grub_err_t
grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
2010-03-08 14:40:57 +00:00
grub_err_t err;
grub_loader_unset ();
highest_load = 0;
#ifndef GRUB_USE_MULTIBOOT2
grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE;
int option_found = 0;
do
{
option_found = 0;
if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0)
{
argc--;
argv++;
option_found = 1;
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE;
}
if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0)
{
argc--;
argv++;
option_found = 1;
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
}
} while (option_found);
#endif
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (argv[0]);
if (! file)
return grub_errno;
2010-03-08 14:40:57 +00:00
grub_dl_ref (my_mod);
/* Skip filename. */
GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1);
2008-08-17 Robert Millan <rmh@aybabtu.com> * conf/i386-pc.rmk (kernel_img_SOURCES): Add `kern/i386/pc/mmap.c'. * include/grub/i386/pc/init.h (GRUB_MACHINE_MEMORY_AVAILABLE) (GRUB_MACHINE_MEMORY_RESERVED): New macros. (grub_machine_mmap_iterate): New function declaration. * include/grub/multiboot.h (struct grub_multiboot_mmap_entry): New structure. (GRUB_MMAP_MEMORY_AVAILABLE, GRUB_MMAP_MEMORY_RESERVED): New macros. * kern/i386/pc/init.c (grub_machine_init): Replace hardcoded region type check value with `GRUB_MACHINE_MEMORY_AVAILABLE'. Move e820 parsing from here ... * kern/i386/pc/mmap.c: New file. (grub_machine_mmap_iterate): ... to here. * include/grub/i386/coreboot/memory.h: Remove `<grub/err.h>'. (GRUB_LINUXBIOS_MEMORY_AVAILABLE): Rename (for consistency) to ... (GRUB_MACHINE_MEMORY_AVAILABLE): ... this. Update all users. (grub_available_iterate): Redeclare to return `void', and redeclare its hook to use grub_uint64_t as addr and size parameters, and rename to ... (grub_machine_mmap_iterate): ... this. Update all users. * kern/i386/coreboot/mmap.c (grub_mmap_iterate): Simplify parser loop to make it more readable. Rename to ... (grub_machine_mmap_iterate): ... this. * loader/i386/pc/multiboot.c (mmap_addr, mmap_length): New variables. (grub_get_multiboot_mmap_len, grub_fill_multiboot_mmap): New functions. (grub_multiboot): Allocate an extra region after the payload, and fill it with a Multiboot memory map. Adjust a.out loader to calculate size with the extra space. (grub_multiboot_load_elf32): Adjust elf32 loader to calculate size with the extra space.
2008-08-17 16:32:18 +00:00
grub_relocator_unload (GRUB_MULTIBOOT (relocator));
GRUB_MULTIBOOT (relocator) = grub_relocator_new ();
2010-01-10 14:06:17 +00:00
if (!GRUB_MULTIBOOT (relocator))
2010-01-10 14:06:17 +00:00
goto fail;
err = GRUB_MULTIBOOT (load) (file, argv[0]);
2010-03-08 14:40:57 +00:00
if (err)
goto fail;
GRUB_MULTIBOOT (set_bootdev) ();
2010-01-10 14:06:17 +00:00
grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0);
fail:
if (file)
grub_file_close (file);
if (grub_errno != GRUB_ERR_NONE)
{
grub_relocator_unload (GRUB_MULTIBOOT (relocator));
GRUB_MULTIBOOT (relocator) = NULL;
grub_dl_unref (my_mod);
}
2010-03-08 14:40:57 +00:00
return grub_errno;
}
2010-03-08 14:40:57 +00:00
static grub_err_t
grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
2010-01-10 17:58:18 +00:00
grub_ssize_t size;
2010-01-11 10:29:52 +00:00
void *module = NULL;
grub_addr_t target;
2010-01-10 17:58:18 +00:00
grub_err_t err;
int nounzip = 0;
grub_uint64_t lowest_addr = 0;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
if (grub_strcmp (argv[0], "--nounzip") == 0)
{
argv++;
argc--;
nounzip = 1;
}
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
if (!GRUB_MULTIBOOT (relocator))
2010-03-08 14:40:57 +00:00
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("you need to load the kernel first"));
if (nounzip)
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (! file)
2010-03-08 14:40:57 +00:00
return grub_errno;
#ifndef GRUB_USE_MULTIBOOT2
lowest_addr = 0x100000;
if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL)
lowest_addr = ALIGN_UP (highest_load + 1048576, 4096);
#endif
size = grub_file_size (file);
if (size)
2010-04-21 17:13:45 +00:00
{
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch,
lowest_addr, (0xffffffff - size) + 1,
2010-04-21 17:13:45 +00:00
size, MULTIBOOT_MOD_ALIGN,
GRUB_RELOCATOR_PREFERENCE_NONE, 1);
2010-04-21 17:13:45 +00:00
if (err)
{
grub_file_close (file);
return err;
}
module = get_virtual_current_address (ch);
target = get_physical_target_address (ch);
2010-04-21 17:13:45 +00:00
}
else
{
module = 0;
target = 0;
}
err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
2010-01-10 17:58:18 +00:00
if (err)
2010-03-08 14:40:57 +00:00
{
grub_file_close (file);
return err;
}
if (size && grub_file_read (file, module, size) != size)
{
2010-03-08 14:40:57 +00:00
grub_file_close (file);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
return grub_errno;
}
2010-03-08 14:40:57 +00:00
grub_file_close (file);
return GRUB_ERR_NONE;
}
2010-01-10 17:58:18 +00:00
2010-03-08 14:40:57 +00:00
static grub_command_t cmd_multiboot, cmd_module;
GRUB_MOD_INIT(multiboot)
{
cmd_multiboot =
#ifdef GRUB_USE_MULTIBOOT2
grub_register_command ("multiboot2", grub_cmd_multiboot,
0, N_("Load a multiboot 2 kernel."));
cmd_module =
grub_register_command ("module2", grub_cmd_module,
0, N_("Load a multiboot 2 module."));
2010-03-08 14:40:57 +00:00
#else
grub_register_command ("multiboot", grub_cmd_multiboot,
0, N_("Load a multiboot kernel."));
cmd_module =
grub_register_command ("module", grub_cmd_module,
0, N_("Load a multiboot module."));
#endif
2010-03-08 14:40:57 +00:00
my_mod = mod;
}
2010-01-10 17:58:18 +00:00
2010-03-08 14:40:57 +00:00
GRUB_MOD_FINI(multiboot)
{
grub_unregister_command (cmd_multiboot);
grub_unregister_command (cmd_module);
}