Merge trunk
This commit is contained in:
commit
9606c5e760
100 changed files with 2152 additions and 705 deletions
405
ChangeLog
405
ChangeLog
|
@ -1,3 +1,408 @@
|
|||
2009-12-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Workaround for broken ATI VBE.
|
||||
|
||||
* video/i386/pc/vbe.c (last_set_mode): New variable.
|
||||
(grub_vbe_set_video_mode): Set 'last_set_mode'.
|
||||
(grub_vbe_get_video_mode): Use 'last_set_mode' if get_mode fails.
|
||||
(grub_video_vbe_setup): Don't check for reserved flag.
|
||||
|
||||
2009-12-17 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
* gendistlist.sh: Use POSIX compliant `!' instead of `-not' in
|
||||
the `find' command.
|
||||
|
||||
2009-12-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
UUID support for HFS.
|
||||
|
||||
* fs/hfs.c (grub_hfs_uuid): New function.
|
||||
(grub_hfs_fs): New value .uuid.
|
||||
* include/grub/hfs.h (grub_hfs_sblock): New field 'num_serial'.
|
||||
|
||||
2009-12-14 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
Fix a segfault with parsing unknown long options.
|
||||
|
||||
* util/grub-mkrelpath.c (options): Zero terminate it.
|
||||
|
||||
2009-12-13 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* include/grub/misc.h (grub_puts): New declaration.
|
||||
(grub_puts_): Likewise.
|
||||
* kern/mis.c (grub_puts): New definition.
|
||||
(grub_puts_): Likewise.
|
||||
|
||||
2009-12-13 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* util/grub-probe.c (probe): Improve error message.
|
||||
|
||||
2009-12-13 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* loader/i386/multiboot_elfxx.c
|
||||
(CONCAT(grub_multiboot_load_elf, XX)): Fix `grub_multiboot_payload_eip'
|
||||
initialization.
|
||||
|
||||
2009-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Relocator framework
|
||||
|
||||
* loader/i386/xnu_helper.S: Removed. All users updated.
|
||||
* conf/i386.rmk (pkglib_MODULES): Add relocator.mod.
|
||||
(relocator_mod_SOURCES): New variable.
|
||||
(relocator_mod_CFLAGS): Likewise.
|
||||
(relocator_mod_LDFLAGS): Likewise.
|
||||
(relocator_mod_ASFLAGS): Likewise.
|
||||
* conf/x86_64.rmk: Likewise.
|
||||
* include/grub/i386/multiboot.h (grub_multiboot_payload_orig): Removed.
|
||||
(grub_multiboot_payload_entry_offset): Likewise.
|
||||
(grub_multiboot_forward_relocator): Likewise.
|
||||
(grub_multiboot_forward_relocator_end): Likewise.
|
||||
(grub_multiboot_backward_relocator): Likewise.
|
||||
(grub_multiboot_backward_relocator_end): Likewise.
|
||||
(grub_multiboot_payload_eip): New variable.
|
||||
(grub_multiboot_payload_orig): Likewise.
|
||||
* include/grub/i386/pc/memory.h: Include grub/i386/memory.h.
|
||||
(GRUB_MEMORY_MACHINE_CR0_PE_ON): Move from here ...
|
||||
* include/grub/i386/memory.h
|
||||
(GRUB_MEMORY_CPU_CR0_PE_ON): ... to here
|
||||
(GRUB_MEMORY_CPU_CR4_PAE_ON): New definition.
|
||||
(GRUB_MEMORY_CPU_CR0_PAGING_ON): Likewise.
|
||||
(GRUB_MEMORY_CPU_AMD64_MSR): Likewise.
|
||||
(GRUB_MEMORY_CPU_AMD64_MSR_ON): Likewise.
|
||||
* include/grub/i386/relocator.h: New file.
|
||||
* include/grub/x86_64/relocator.h: Likewise.
|
||||
* include/grub/i386/xnu.h: Include grub/cpu/relocator.h.
|
||||
(XNU_RELOCATOR): New macro.
|
||||
(grub_xnu_launcher_start): Remove.
|
||||
(grub_xnu_launcher_end): Likewise.
|
||||
* include/grub/xnu.h (grub_xnu_boot_resume): New prototype.
|
||||
(grub_xnu_heap_real_start): Remove.
|
||||
(grub_xnu_heap_start): Change to void *. All users updated.
|
||||
* kern/i386/realmode.S (real_to_prot): Use GRUB_MEMORY_CPU_CR0_PE_ON.
|
||||
* lib/i386/relocator.c: New file.
|
||||
* lib/i386/relocator_asm.S: Likewise.
|
||||
* lib/i386/relocator_backward.S: Likewise.
|
||||
* lib/mips/relocator.c: Likewise.
|
||||
* lib/mips/relocator_asm.S: Likewise.
|
||||
* lib/relocator.c: Likewise.
|
||||
* loader/i386/multiboot.c: Include grub/i386/relocator.h.
|
||||
(entry): Removed.
|
||||
(playground): Likewise.
|
||||
(grub_multiboot_payload_orig): New variable.
|
||||
(grub_multiboot_payload_dest): Likewise.
|
||||
(grub_multiboot_payload_size): Likewise.
|
||||
(grub_multiboot_payload_eip): Likewise.
|
||||
(grub_multiboot_payload_esp): Likewise.
|
||||
(grub_multiboot_boot): Use grub_relocator32_boot.
|
||||
(grub_multiboot_unload): Free relocators.
|
||||
(grub_multiboot): Setup stack. Use relocators.
|
||||
* loader/i386/multiboot_elfxx.c: Include grub/i386/relocator.h.
|
||||
(grub_multiboot_load_elfXX): Use relocators.
|
||||
* loader/i386/multiboot_helper.S (grub_multiboot_payload_orig): Removed.
|
||||
(grub_multiboot_payload_size): Likewise.
|
||||
(grub_multiboot_payload_dest): Likewise.
|
||||
(grub_multiboot_payload_entry_offset): Likewise.
|
||||
(grub_multiboot_forward_relocator): Likewise.
|
||||
(grub_multiboot_backward_relocator): Likewise.
|
||||
(grub_multiboot_real_boot): Likewise.
|
||||
* loader/i386/xnu.c (grub_xnu_heap_will_be_at): New variable.
|
||||
(grub_xnu_entry_point): Likewise.
|
||||
(grub_xnu_arg1): Likewise.
|
||||
(grub_xnu_stack): Likewise.
|
||||
(grub_xnu_launch): Removed.
|
||||
(grub_xnu_boot_resume): New function.
|
||||
(grub_xnu_boot): Use relocators.
|
||||
* loader/i386/xnu_helper.S: Removed.
|
||||
* loader/xnu.c (grub_xnu_heap_start): New variable.
|
||||
(grub_xnu_heap_size): Likewise.
|
||||
(grub_xnu_heap_malloc): Use relocators.
|
||||
* loader/xnu_resume.c (grub_xnu_resume): Use relocators.
|
||||
|
||||
2009-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/i386/pc/startup.S (multiboot_entry): Setup stack before calling
|
||||
anything.
|
||||
|
||||
2009-12-13 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* script/execute.c (grub_script_execute_cmdline): Set grub_errno to
|
||||
GRUB_ERR_NONE before calling grub_env_set.
|
||||
|
||||
2009-12-12 Robert Millan <rmh@aybabtu.com>
|
||||
|
||||
* gendistlist.sh (EXTRA_DISTFILES): Add `genvideolist.sh'.
|
||||
* genmk.rb (video): New variable.
|
||||
(CLEANFILES, VIDEOFILES): Add #{video}.
|
||||
(#{video}): New target rule.
|
||||
* genvideolist.sh: New file.
|
||||
* Makefile.in (pkglib_DATA): Add video.lst.
|
||||
(video.lst): New target rule.
|
||||
* util/grub-mkconfig.in: Initialize ${GRUB_VIDEO_BACKEND} using
|
||||
`video.lst'.
|
||||
* util/grub.d/30_os-prober.in: Replace `vbe' with
|
||||
${GRUB_VIDEO_BACKEND}.
|
||||
|
||||
2009-12-11 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* THANKS: Add David Miller.
|
||||
|
||||
2009-12-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
libpciaccess support.
|
||||
|
||||
* Makefile.in (LIBPCIACCESS): New variable.
|
||||
(enable_grub_emu_pci): Likewise.
|
||||
* conf/any-emu.rmk (grub_emu_SOURCES) [enable_grub_emu_pci]: Add
|
||||
util/pci.c and commands/lspci.c.
|
||||
(grub_emu_LDFLAGS) [enable_grub_emu_pci]: Add $(LIBPCIACCESS).
|
||||
* configure.ac (grub-emu-pci): New option.
|
||||
* include/grub/i386/pci.h (grub_pci_device_map_range): New function.
|
||||
(grub_pci_device_unmap_range): Likewise.
|
||||
* include/grub/pci.h [GRUB_UTIL]: Include grub/pciutils.h.
|
||||
(grub_pci_device) [!GRUB_UTIL]: New structure. All users updated.
|
||||
(grub_pci_address_t) [!GRUB_UTIL]: New type.
|
||||
(grub_pci_device_t) [!GRUB_UTIL]: Likewise.
|
||||
(grub_pci_get_bus) [!GRUB_UTIL]: New function.
|
||||
(grub_pci_get_device) [!GRUB_UTIL]: Likewise.
|
||||
(grub_pci_get_function) [!GRUB_UTIL]: Likewise.
|
||||
* include/grub/pciutils.h: New file.
|
||||
* util/pci.c: Likewise.
|
||||
|
||||
2009-12-11 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
* util/misc.c: Don't include <errno.h> twice.
|
||||
|
||||
2009-12-10 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
* disk/i386/pc/biosdisk.c (grub_biosdisk_open): Show the disk
|
||||
name in an error message.
|
||||
(grub_biosdisk_rw): Likewise.
|
||||
|
||||
2009-12-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Eliminate NTFS 4Gib barrier.
|
||||
|
||||
* fs/ntfs.c (read_attr): Use grub_disk_addr_t and grub_size_t.
|
||||
(read_run_data): Likewise.
|
||||
(grub_ntfs_read_run_list): Likewise.
|
||||
(grub_ntfs_read_block): Likewise.
|
||||
(grub_ntfs_iterate_dir): Likewise.
|
||||
(read_mft): Likewise.
|
||||
(read_data): Likewise.
|
||||
Use COM_LOG_LEN.
|
||||
* fs/ntfscomp.c (read_block): Cast ctx->target_vcn & 0xF to unsigned
|
||||
to avoid 64-bit division
|
||||
* include/grub/ntfs.h (COM_LOG_LEN): New definition.
|
||||
(grub_ntfs_rlst): Use grub_disk_addr_t.
|
||||
|
||||
2009-12-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Eliminate grub-fstest 4Gib barrier.
|
||||
|
||||
* util/grub-fstest.c (skip, leng): Use grub_disk_addr_t.
|
||||
(read_file): Fix error reporting.
|
||||
|
||||
2009-12-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Eliminate hexdump 4Gib barrier.
|
||||
|
||||
* commands/hexdump.c (grub_cmd_hexdump): Use grub_disk_addr_t.
|
||||
* lib/arg.c (grub_arg_parse): Use grub_strtoull.
|
||||
|
||||
2009-12-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/device.c (grub_device_iterate): Ignore errors during first scan.
|
||||
Fixes amarsh bug.
|
||||
|
||||
2009-12-09 Bruce Dubbs <bruce.dubbs@gmail.com>
|
||||
|
||||
Remove miscellaneous files in distclean target.
|
||||
|
||||
* Makefile.in: Remove docs/{grub.info,version.texi,stamp-vti}
|
||||
|
||||
2009-12-09 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-mkconfig_lib.in: Don't set grub_probe or grub_mkrelpath
|
||||
if they're already set. This resolves the conflict between my
|
||||
grub-install change on 2009-10-06 and Felix' change on 2009-11-11,
|
||||
fixing the --grub-probe option again.
|
||||
* util/sparc64/ieee1275/grub-install.in: Revert the last piece of my
|
||||
change on 2009-10-06, so that we now once again source
|
||||
`${libdir}/grub/grub-mkconfig_lib' after options have been parsed.
|
||||
|
||||
2009-12-08 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* conf/common.rmk [sparc64-ieee1275] (grub_mkdevicemap_SOURCES): Use
|
||||
`util/ieee1275/ofpath.c' and `util/ieee1275/devicemap.c' instead of
|
||||
`util/devicemap.c'.
|
||||
|
||||
2009-12-08 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* include/grub/misc.h (grub_printf_): New declaration.
|
||||
* kern/misc.c (grub_printf_): New definition.
|
||||
* normal/main.c (grub_normal_reader_init): Use `grub_printf_' and `N_'
|
||||
instead of `grub_printf' and `_'.
|
||||
* normal/menu_entry.c (store_completion): Likewise.
|
||||
(run): Likewise.
|
||||
(grub_menu_entry_run): Likewise.
|
||||
* normal/menu_text.c (grub_wait_after_message): Likewise.
|
||||
(notify_booting): Likewise.
|
||||
(notify_fallback): Likewise.
|
||||
(notify_execution_failure): Likewise.
|
||||
|
||||
2009-12-07 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* configure.ac: Check for vasprintf.
|
||||
* util/misc.c (asprintf): Move allocation from here ...
|
||||
(vasprintf): ... to here. New function.
|
||||
(xasprintf): New function.
|
||||
* include/grub/util/misc.h (vasprintf, xasprintf): Add
|
||||
prototypes.
|
||||
* util/getroot.c (grub_util_get_grub_dev): Use xasprintf.
|
||||
* util/grub-mkfont.c (write_font): Likewise.
|
||||
* util/grub-probe.c (probe): Likewise.
|
||||
* util/hostdisk.c (make_device_name): Likewise.
|
||||
|
||||
2009-12-06 David S. Miller <davem@sunset.davemloft.net>
|
||||
|
||||
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Recognize
|
||||
anything even prefixed with 'cdrom' as a cdrom.
|
||||
|
||||
2009-12-06 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
* util/misc.c (make_system_path_relative_to_its_root): Correctly cope with
|
||||
mount points.
|
||||
|
||||
2009-12-05 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* gettext/gettext.c: Include `<grub/list.h>'. Define grub_gettext_msg,
|
||||
grub_gettext_msg_list.
|
||||
(grub_gettext_gettranslation_from_position): Return const char *
|
||||
and not char *.
|
||||
(grub_gettext_translate): Add the translated strings into a list,
|
||||
returns from the list if existing there.
|
||||
(grub_gettext_init_ext): Add \n at the end of grub_dprintf string.
|
||||
(grub_gettext_delete_list): Delete the list.
|
||||
(grub_gettext_env_write_lang): Call grub_gettext_delete_list when
|
||||
lang environment variable is changed.
|
||||
(GRUB_MOD_FINI): Call grub_gettext_delete_list.
|
||||
|
||||
2009-12-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Rename kernel.mod to kernel.img.
|
||||
|
||||
* conf/i386-efi.rmk (pkglib_MODULES): Change kernel.mod to kernel.img.
|
||||
(kernel_mod_EXPORTS): Rename to ...
|
||||
(kernel_img_EXPORTS): ... this.
|
||||
(kernel_mod_SOURCES): Rename to ...
|
||||
(kernel_img_SOURCES): ... this.
|
||||
(kernel_mod_HEADERS): Rename to ...
|
||||
(kernel_img_HEADERS): ... this. All users updated.
|
||||
(kernel_mod_CFLAGS): Rename to ...
|
||||
(kernel_img_CFLAGS): ... this.
|
||||
(kernel_mod_ASFLAGS): Rename to ...
|
||||
(kernel_img_ASFLAGS): ... this.
|
||||
(kernel_mod_LDFLAGS): Rename to ...
|
||||
(kernel_img_LDFLAGS): ... this.
|
||||
* conf/x86_64-efi.rmk: Likewise.
|
||||
* util/i386/efi/grub-mkimage.c (read_kernel_module): Rename to ...
|
||||
(read_kernel_image): ... this. All users updated.
|
||||
(read_kernel_image): Read "kernel.img" instead of "kernel.mod".
|
||||
|
||||
2009-12-05 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* normal/menu_text.c (grub_color_menu_high): Gettexttize string.
|
||||
(print_spaces): New function.
|
||||
(grub_print_ucs4): New function.
|
||||
(getstringwidth): New function.
|
||||
(print_message_indented): New function.
|
||||
(print_message): Gettexttize strings using print_message_indented.
|
||||
(run_menu): Replaces grub_printf by print_spaces and dynamic terminal
|
||||
width.
|
||||
(get_entry_number): Gettextize and uses dynamic terminal width.
|
||||
(notify_booting, notify_fallback, notify_execution_failure):
|
||||
Gettextize.
|
||||
* normal/menu_entry.c (store_completion): Cleanup the gettextized
|
||||
string.
|
||||
(run): Likewise.
|
||||
(grub_menu_entry_run): Likewise.
|
||||
* PO/POTFILES: Add normal/menu_entry.c.
|
||||
|
||||
2009-12-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac (TARGET_ASFLAGS): Add "-D<MACHINE>".
|
||||
|
||||
2009-12-05 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* util/grub-install.in: Install gettext .mo files.
|
||||
* util/grub-mkrescue.in (process_input_dir): Copy gettext .mo files.
|
||||
|
||||
2009-12-05 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* gettext/gettext.c (grub_gettext_init_ext): Replace grub_printf with
|
||||
grub_dprintf.
|
||||
|
||||
2009-12-05 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* kern/ieee1275/openfw.c (grub_reboot): Disable for i386. The
|
||||
non-firmware-dependant one in realmode.S takes precedence.
|
||||
|
||||
2009-12-04 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* commands/halt.c: Replace misc arch-specific headers with
|
||||
`<grub/misc.h>'.
|
||||
* commands/reboot.c: Likewise.
|
||||
* commands/i386/pc/halt.c: Replace `<grub/machine/init.h>' with
|
||||
`<grub/misc.h>'.
|
||||
* conf/i386-coreboot.rmk (kernel_img_HEADERS): Remove `cpu/reboot.h'.
|
||||
(halt_mod_SOURCES): Move `kern/i386/halt.c' from here ...
|
||||
(kernel_img_SOURCES): ... to here.
|
||||
|
||||
* include/grub/efi/efi.h (grub_reboot, grub_halt): Remove prototypes.
|
||||
* include/grub/i386/pc/init.h: Likewise.
|
||||
* include/grub/powerpc/ieee1275/kernel.h: Likewise.
|
||||
* include/grub/sparc64/ieee1275/kernel.h: Likewise.
|
||||
|
||||
* include/grub/misc.h (grub_reboot, grub_halt): New prototypes.
|
||||
|
||||
* include/grub/i386/halt.h: Remove.
|
||||
* include/grub/i386/reboot.h: Likewise.
|
||||
|
||||
* kern/i386/halt.c: Remove `<grub/cpu/halt.h>'.
|
||||
|
||||
2009-12-03 David S. Miller <davem@sunset.davemloft.net>
|
||||
|
||||
* conf/sparc64-ieee1275.rmk (grub_mkimage_SOURCES,
|
||||
grub_setup_SOURCES, grub_ofpathname_SOURCES): Add gnulib/progname.c
|
||||
* util/sparc64/ieee1275/grub-mkimage.c: Include <grub/i18n.h> and
|
||||
"progname.h"
|
||||
* util/sparc64/ieee1275/grub-ofpathname.c: Likewise.
|
||||
* util/sparc64/ieee1275/grub-setup.c: Likewise.
|
||||
(usage): Add missing comma in printf.
|
||||
|
||||
2009-12-02 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
Use the same reboot approach on i386 coreboot and qemu as we do on
|
||||
BIOS.
|
||||
|
||||
* conf/i386-coreboot.rmk (kernel_img_HEADERS): Add `cpu/reboot.h'.
|
||||
(reboot_mod_SOURCES): Remove `kern/i386/reboot.c'.
|
||||
* kern/i386/reboot.c: Remove.
|
||||
* include/grub/i386/reboot.h (grub_reboot): Export function.
|
||||
* kern/i386/pc/startup.S (grub_reboot): Move from here ...
|
||||
* kern/i386/realmode.S (grub_reboot): ... to here. Jump to
|
||||
0xf000:0xfff0 instead of 0xffff:0x0000.
|
||||
[!GRUB_MACHINE_PCBIOS] (prot_to_real): Do not restore interrupts.
|
||||
* kern/i386/qemu/startup.S: Include `"../realmode.S"'.
|
||||
|
||||
2009-11-30 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
Fix $srcdir != $objdir build.
|
||||
|
||||
* Makefile.in (po/%.po): Rewrite as ...
|
||||
($(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po)): ... this.
|
||||
|
||||
2009-11-29 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||
|
||||
Fix GNU/Hurd grub-install crash.
|
||||
|
|
13
Makefile.in
13
Makefile.in
|
@ -109,11 +109,13 @@ endif
|
|||
AWK = @AWK@
|
||||
LIBCURSES = @LIBCURSES@
|
||||
LIBUSB = @LIBUSB@
|
||||
LIBPCIACCESS = @LIBPCIACCESS@
|
||||
YACC = @YACC@
|
||||
FONT_SOURCE = @FONT_SOURCE@
|
||||
|
||||
# Options.
|
||||
enable_grub_emu_usb = @enable_grub_emu_usb@
|
||||
enable_grub_emu_pci = @enable_grub_emu_pci@
|
||||
enable_grub_fstest = @enable_grub_fstest@
|
||||
enable_grub_pe2elf = @enable_grub_pe2elf@
|
||||
enable_grub_mkfont = @enable_grub_mkfont@
|
||||
|
@ -139,7 +141,9 @@ CLEANFILES =
|
|||
MOSTLYCLEANFILES =
|
||||
DISTCLEANFILES = config.status config.cache config.log config.h \
|
||||
Makefile stamp-h include/grub/cpu include/grub/machine \
|
||||
gensymlist.sh genkernsyms.sh build_env.mk
|
||||
gensymlist.sh genkernsyms.sh build_env.mk \
|
||||
docs/grub.info docs/version.texi docs/stamp-vti
|
||||
|
||||
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \
|
||||
$(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS)
|
||||
|
||||
|
@ -165,7 +169,7 @@ endif
|
|||
### General targets.
|
||||
|
||||
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst
|
||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst
|
||||
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
|
||||
cat $(DEFSYMFILES) /dev/null \
|
||||
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|
||||
|
@ -186,6 +190,9 @@ handler.lst: $(HANDLERFILES)
|
|||
parttool.lst: $(PARTTOOLFILES)
|
||||
cat $^ /dev/null | sort | uniq > $@
|
||||
|
||||
video.lst: $(VIDEOFILES)
|
||||
cat $^ /dev/null | sort | uniq > $@
|
||||
|
||||
ifneq (true, $(MAKEINFO))
|
||||
info_INFOS += docs/grub.info
|
||||
endif
|
||||
|
@ -480,7 +487,7 @@ $(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
|
|||
cd $(srcdir) && $(XGETTEXT) --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_
|
||||
cd $(srcdir) && $(XGETTEXT) --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell
|
||||
|
||||
po/%.po: po/$(PACKAGE).pot
|
||||
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
|
||||
$(MSGMERGE) -U $@ $^
|
||||
|
||||
po/%.mo: po/%.po
|
||||
|
|
1
THANKS
1
THANKS
|
@ -8,6 +8,7 @@ generally assist in the GRUB 2 maintainership process:
|
|||
|
||||
Andrey Shuvikov <mr_hyro@yahoo.com>
|
||||
Bibo Mao <bibo.mao@intel.com>
|
||||
David Miller <davem@davemloft.net>
|
||||
Guillem Jover <guillem@hadrons.org>
|
||||
Harley D. Eades III <hde@foobar-qux.org>
|
||||
Hitoshi Ozeki <h-ozeki@ck2.so-net.ne.jp>
|
||||
|
|
23
bus/pci.c
23
bus/pci.c
|
@ -21,41 +21,40 @@
|
|||
#include <grub/pci.h>
|
||||
|
||||
grub_pci_address_t
|
||||
grub_pci_make_address (int bus, int device, int function, int reg)
|
||||
grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||
{
|
||||
return (1 << 31) | (bus << 16) | (device << 11) | (function << 8) | (reg << 2);
|
||||
return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
|
||||
| (dev.function << 8) | (reg << 2);
|
||||
}
|
||||
|
||||
void
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||
{
|
||||
int bus;
|
||||
int dev;
|
||||
int func;
|
||||
grub_pci_device_t dev;
|
||||
grub_pci_address_t addr;
|
||||
grub_pci_id_t id;
|
||||
grub_uint32_t hdr;
|
||||
|
||||
for (bus = 0; bus < 256; bus++)
|
||||
for (dev.bus = 0; dev.bus < 256; dev.bus++)
|
||||
{
|
||||
for (dev = 0; dev < 32; dev++)
|
||||
for (dev.device = 0; dev.device < 32; dev.device++)
|
||||
{
|
||||
for (func = 0; func < 8; func++)
|
||||
for (dev.function = 0; dev.function < 8; dev.function++)
|
||||
{
|
||||
addr = grub_pci_make_address (bus, dev, func, 0);
|
||||
addr = grub_pci_make_address (dev, 0);
|
||||
id = grub_pci_read (addr);
|
||||
|
||||
/* Check if there is a device present. */
|
||||
if (id >> 16 == 0xFFFF)
|
||||
continue;
|
||||
|
||||
if (hook (bus, dev, func, id))
|
||||
if (hook (dev, id))
|
||||
return;
|
||||
|
||||
/* Probe only func = 0 if the device if not multifunction */
|
||||
if (func == 0)
|
||||
if (dev.function == 0)
|
||||
{
|
||||
addr = grub_pci_make_address (bus, dev, func, 3);
|
||||
addr = grub_pci_make_address (dev, 3);
|
||||
hdr = grub_pci_read (addr);
|
||||
if (!(hdr & 0x800000))
|
||||
break;
|
||||
|
|
|
@ -113,7 +113,7 @@ grub_ohci_writereg32 (struct grub_ohci *o,
|
|||
/* Iterate over all PCI devices. Determine if a device is an OHCI
|
||||
controller. If this is the case, initialize it. */
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_ohci_pci_iter (int bus, int device, int func,
|
||||
grub_ohci_pci_iter (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid __attribute__((unused)))
|
||||
{
|
||||
grub_uint32_t class_code;
|
||||
|
@ -126,7 +126,7 @@ grub_ohci_pci_iter (int bus, int device, int func,
|
|||
grub_uint32_t revision;
|
||||
grub_uint32_t frame_interval;
|
||||
|
||||
addr = grub_pci_make_address (bus, device, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
class_code = grub_pci_read (addr) >> 8;
|
||||
|
||||
interf = class_code & 0xFF;
|
||||
|
@ -138,7 +138,7 @@ grub_ohci_pci_iter (int bus, int device, int func,
|
|||
return 0;
|
||||
|
||||
/* Determine IO base address. */
|
||||
addr = grub_pci_make_address (bus, device, func, 4);
|
||||
addr = grub_pci_make_address (dev, 4);
|
||||
base = grub_pci_read (addr);
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -138,7 +138,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
|||
/* Iterate over all PCI devices. Determine if a device is an UHCI
|
||||
controller. If this is the case, initialize it. */
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_uhci_pci_iter (int bus, int device, int func,
|
||||
grub_uhci_pci_iter (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid __attribute__((unused)))
|
||||
{
|
||||
grub_uint32_t class_code;
|
||||
|
@ -151,7 +151,7 @@ grub_uhci_pci_iter (int bus, int device, int func,
|
|||
struct grub_uhci *u;
|
||||
int i;
|
||||
|
||||
addr = grub_pci_make_address (bus, device, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
class_code = grub_pci_read (addr) >> 8;
|
||||
|
||||
interf = class_code & 0xFF;
|
||||
|
@ -163,7 +163,7 @@ grub_uhci_pci_iter (int bus, int device, int func,
|
|||
return 0;
|
||||
|
||||
/* Determine IO base address. */
|
||||
addr = grub_pci_make_address (bus, device, func, 8);
|
||||
addr = grub_pci_make_address (dev, 8);
|
||||
base = grub_pci_read (addr);
|
||||
/* Stop if there is no IO space base address defined. */
|
||||
if (! (base & 1))
|
||||
|
|
|
@ -38,11 +38,11 @@ static struct grub_video_patch
|
|||
};
|
||||
|
||||
static int NESTED_FUNC_ATTR
|
||||
scan_card (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
|
||||
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
if (grub_pci_read_byte (addr + 3) == 0x3)
|
||||
{
|
||||
struct grub_video_patch *p = video_patches;
|
||||
|
|
|
@ -41,6 +41,7 @@ enable_rom_area (void)
|
|||
{
|
||||
grub_pci_address_t addr;
|
||||
grub_uint32_t *rom_ptr;
|
||||
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
|
||||
|
||||
rom_ptr = (grub_uint32_t *) VBIOS_ADDR;
|
||||
if (*rom_ptr != BLANK_MEM)
|
||||
|
@ -49,7 +50,7 @@ enable_rom_area (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
addr = grub_pci_make_address (0, 0, 0, 36);
|
||||
addr = grub_pci_make_address (dev, 36);
|
||||
grub_pci_write_byte (addr++, 0x30);
|
||||
grub_pci_write_byte (addr++, 0x33);
|
||||
grub_pci_write_byte (addr++, 0x33);
|
||||
|
@ -73,8 +74,9 @@ static void
|
|||
lock_rom_area (void)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
|
||||
|
||||
addr = grub_pci_make_address (0, 0, 0, 36);
|
||||
addr = grub_pci_make_address (dev, 36);
|
||||
grub_pci_write_byte (addr++, 0x10);
|
||||
grub_pci_write_byte (addr++, 0x11);
|
||||
grub_pci_write_byte (addr++, 0x11);
|
||||
|
|
|
@ -19,15 +19,7 @@
|
|||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#if defined(GRUB_MACHINE_IEEE1275)
|
||||
#include <grub/machine/kernel.h>
|
||||
#elif defined(GRUB_MACHINE_EFI)
|
||||
#include <grub/efi/efi.h>
|
||||
#else
|
||||
/* Platforms shipping standalone halt, such as coreboot. */
|
||||
#include <grub/cpu/halt.h>
|
||||
#endif
|
||||
#include <grub/misc.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
|
|
@ -38,18 +38,18 @@ grub_cmd_hexdump (grub_extcmd_t cmd, int argc, char **args)
|
|||
struct grub_arg_list *state = cmd->state;
|
||||
char buf[GRUB_DISK_SECTOR_SIZE * 4];
|
||||
grub_ssize_t size, length;
|
||||
grub_addr_t skip;
|
||||
grub_disk_addr_t skip;
|
||||
int namelen;
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
namelen = grub_strlen (args[0]);
|
||||
skip = (state[0].set) ? grub_strtoul (state[0].arg, 0, 0) : 0;
|
||||
skip = (state[0].set) ? grub_strtoull (state[0].arg, 0, 0) : 0;
|
||||
length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 256;
|
||||
|
||||
if (!grub_strcmp (args[0], "(mem)"))
|
||||
hexdump (skip, (char *) skip, length);
|
||||
hexdump (skip, (char *) (grub_addr_t) skip, length);
|
||||
else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
|
||||
{
|
||||
grub_disk_t disk;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
|
|
|
@ -115,15 +115,16 @@ grub_pci_get_class (int class, int subclass)
|
|||
}
|
||||
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
||||
{
|
||||
grub_uint32_t class;
|
||||
const char *sclass;
|
||||
grub_pci_address_t addr;
|
||||
|
||||
grub_printf ("%02x:%02x.%x %04x:%04x", bus, dev, func, pciid & 0xFFFF,
|
||||
pciid >> 16);
|
||||
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||
grub_printf ("%02x:%02x.%x %04x:%04x", grub_pci_get_bus (dev),
|
||||
grub_pci_get_device (dev), grub_pci_get_function (dev),
|
||||
pciid & 0xFFFF, pciid >> 16);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
/* Lookup the class name, if there isn't a specific one,
|
||||
|
@ -156,13 +157,13 @@ grub_cmd_lspci (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(pci)
|
||||
GRUB_MOD_INIT(lspci)
|
||||
{
|
||||
cmd = grub_register_command ("lspci", grub_cmd_lspci,
|
||||
0, "List PCI devices");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(pci)
|
||||
GRUB_MOD_FINI(lspci)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
|
|
|
@ -19,18 +19,7 @@
|
|||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#if defined(GRUB_MACHINE_IEEE1275)
|
||||
#include <grub/machine/kernel.h>
|
||||
#elif defined(GRUB_MACHINE_EFI)
|
||||
#include <grub/efi/efi.h>
|
||||
#elif defined(GRUB_MACHINE_PCBIOS)
|
||||
#include <grub/machine/init.h>
|
||||
#else
|
||||
/* Platforms shipping standalone reboot, such as coreboot. */
|
||||
#include <grub/cpu/reboot.h>
|
||||
#endif
|
||||
|
||||
#include <grub/misc.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
|
|
@ -59,6 +59,11 @@ grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
|
|||
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
|
||||
endif
|
||||
|
||||
ifeq ($(enable_grub_emu_pci), yes)
|
||||
grub_emu_SOURCES += util/pci.c commands/lspci.c
|
||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||
endif
|
||||
|
||||
grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
|
||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
||||
DISTCLEANFILES += grub_emu_init.lst
|
||||
|
|
|
@ -3,7 +3,13 @@
|
|||
sbin_UTILITIES += grub-mkdevicemap
|
||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||
util/deviceiter.c \
|
||||
util/devicemap.c util/misc.c
|
||||
util/misc.c
|
||||
|
||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
||||
else
|
||||
grub_mkdevicemap_SOURCES += util/devicemap.c
|
||||
endif
|
||||
|
||||
# For grub-mkelfimage.
|
||||
bin_UTILITIES += grub-mkelfimage
|
||||
|
|
|
@ -18,6 +18,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
|||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/multiboot_mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/reader.c kern/term.c \
|
||||
|
@ -61,6 +62,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
|||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/qemu/mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/reader.c kern/term.c \
|
||||
|
@ -124,12 +126,12 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c kern/i386/reboot.c
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c kern/i386/halt.c
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
|
|
|
@ -30,14 +30,14 @@ sbin_SCRIPTS = grub-install
|
|||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = kernel.mod chain.mod appleldr.mod \
|
||||
pkglib_MODULES = kernel.img chain.mod appleldr.mod \
|
||||
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod
|
||||
|
||||
# For kernel.mod.
|
||||
kernel_mod_EXPORTS = no
|
||||
kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
|
||||
# For kernel.img.
|
||||
kernel_img_EXPORTS = no
|
||||
kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/reader.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
|
@ -48,22 +48,22 @@ kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
|
|||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c
|
||||
kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h i18n.h
|
||||
kernel_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.sh
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# For boot.mod.
|
||||
|
@ -155,7 +155,7 @@ efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\
|
||||
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
|
||||
loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
|
|
@ -184,7 +184,7 @@ linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c\
|
||||
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
|
||||
loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
|
|
@ -15,6 +15,12 @@ vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c
|
|||
vga_text_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += relocator.mod
|
||||
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
|
||||
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += ata.mod
|
||||
ata_mod_SOURCES = disk/ata.c
|
||||
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
|
|
@ -63,7 +63,7 @@ sbin_UTILITIES = grub-setup grub-ofpathname
|
|||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
|
||||
util/resolve.c
|
||||
util/resolve.c gnulib/progname.c
|
||||
|
||||
# For grub-setup.
|
||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||
|
@ -82,12 +82,12 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
|||
partmap/sun.c partmap/acorn.c \
|
||||
\
|
||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||
util/raid.c util/lvm.c \
|
||||
util/raid.c util/lvm.c gnulib/progname.c \
|
||||
grub_setup_init.c
|
||||
|
||||
# For grub-ofpathname.
|
||||
grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \
|
||||
util/ieee1275/ofpath.c util/misc.c
|
||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
|
|
@ -29,14 +29,14 @@ sbin_SCRIPTS = grub-install
|
|||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = kernel.mod chain.mod appleldr.mod \
|
||||
pkglib_MODULES = kernel.img chain.mod appleldr.mod \
|
||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod ata.mod
|
||||
|
||||
# For kernel.mod.
|
||||
kernel_mod_EXPORTS = no
|
||||
kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
|
||||
# For kernel.img.
|
||||
kernel_img_EXPORTS = no
|
||||
kernel_img_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/reader.c kern/term.c \
|
||||
|
@ -47,23 +47,23 @@ kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
|
|||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c \
|
||||
term/efi/console.c disk/efi/efidisk.c
|
||||
kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h \
|
||||
handler.h command.h i18n.h
|
||||
kernel_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.sh
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# For boot.mod.
|
||||
|
@ -161,9 +161,15 @@ efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\
|
||||
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
|
||||
loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += relocator.mod
|
||||
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
|
||||
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
45
configure.ac
45
configure.ac
|
@ -122,6 +122,7 @@ case "$platform" in
|
|||
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
|
||||
esac
|
||||
CFLAGS="$CFLAGS $machine_CFLAGS"
|
||||
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
|
||||
|
||||
AC_SUBST(host_cpu)
|
||||
|
@ -193,7 +194,7 @@ else
|
|||
fi
|
||||
|
||||
# Check for functions.
|
||||
AC_CHECK_FUNCS(posix_memalign memalign asprintf)
|
||||
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
|
||||
|
||||
# For grub-mkisofs
|
||||
AC_HEADER_MAJOR
|
||||
|
@ -525,6 +526,10 @@ AC_ARG_ENABLE([grub-emu-usb],
|
|||
[AS_HELP_STRING([--enable-grub-emu-usb],
|
||||
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-pci],
|
||||
[AS_HELP_STRING([--enable-grub-emu-pci],
|
||||
[build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
|
||||
|
||||
if test "$platform" = emu; then
|
||||
missing_ncurses=
|
||||
[# Check for curses libraries.]
|
||||
|
@ -546,6 +551,11 @@ fi
|
|||
if test x"$enable_grub_emu_usb" = xno ; then
|
||||
grub_emu_usb_excuse="explicitly disabled"
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_pci" = xyes ; then
|
||||
grub_emu_usb_excuse="conflicts with PCI support"
|
||||
fi
|
||||
|
||||
[if [ x"$grub_emu_usb_excuse" = x ]; then
|
||||
# Check for libusb libraries.]
|
||||
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
|
||||
|
@ -565,7 +575,35 @@ enable_grub_emu_usb=yes
|
|||
else
|
||||
enable_grub_emu_usb=no
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_pci" != xyes ; then
|
||||
grub_emu_pci_excuse="not enabled"
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_usb" = xyes ; then
|
||||
grub_emu_pci_excuse="conflicts with USB support"
|
||||
fi
|
||||
|
||||
[if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
# Check for libpci libraries.]
|
||||
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
|
||||
[grub_emu_pci_excuse=["need libpciaccess library"]])
|
||||
AC_SUBST([LIBPCIACCESS])
|
||||
[fi]
|
||||
[if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
# Check for headers.]
|
||||
AC_CHECK_HEADERS([pci/pci.h], [],
|
||||
[grub_emu_pci_excuse=["need libpciaccess headers"]])
|
||||
[fi]
|
||||
|
||||
if test x"$grub_emu_pci_excuse" = x ; then
|
||||
enable_grub_emu_pci=yes
|
||||
else
|
||||
enable_grub_emu_pci=no
|
||||
fi
|
||||
|
||||
AC_SUBST([enable_grub_emu_usb])
|
||||
AC_SUBST([enable_grub_emu_pci])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([grub-fstest],
|
||||
|
@ -640,6 +678,11 @@ echo USB support for grub-emu: Yes
|
|||
else
|
||||
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
|
||||
fi
|
||||
if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
echo PCI support for grub-emu: Yes
|
||||
else
|
||||
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
|
||||
fi
|
||||
fi
|
||||
if [ x"$enable_mm_debug" = xyes ]; then
|
||||
echo With memory debugging: Yes
|
||||
|
|
11
disk/ata.c
11
disk/ata.c
|
@ -388,7 +388,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
|
|||
}
|
||||
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_ata_pciinit (int bus, int device, int func,
|
||||
grub_ata_pciinit (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid __attribute__((unused)))
|
||||
{
|
||||
static int compat_use[2] = { 0 };
|
||||
|
@ -402,7 +402,7 @@ grub_ata_pciinit (int bus, int device, int func,
|
|||
static int controller = 0;
|
||||
|
||||
/* Read class. */
|
||||
addr = grub_pci_make_address (bus, device, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
/* Check if this class ID matches that of a PCI IDE Controller. */
|
||||
|
@ -429,9 +429,9 @@ grub_ata_pciinit (int bus, int device, int func,
|
|||
{
|
||||
/* Read the BARs, which either contain a mmapped IO address
|
||||
or the IO port address. */
|
||||
addr = grub_pci_make_address (bus, device, func, 4 + 2 * i);
|
||||
addr = grub_pci_make_address (dev, 4 + 2 * i);
|
||||
bar1 = grub_pci_read (addr);
|
||||
addr = grub_pci_make_address (bus, device, func, 5 + 2 * i);
|
||||
addr = grub_pci_make_address (dev, 5 + 2 * i);
|
||||
bar2 = grub_pci_read (addr);
|
||||
|
||||
/* Check if the BARs describe an IO region. */
|
||||
|
@ -444,7 +444,8 @@ grub_ata_pciinit (int bus, int device, int func,
|
|||
|
||||
grub_dprintf ("ata",
|
||||
"PCI dev (%d,%d,%d) compat=%d rega=0x%x regb=0x%x\n",
|
||||
bus, device, func, compat, rega, regb);
|
||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
||||
grub_pci_get_function (dev), compat, rega, regb);
|
||||
|
||||
if (rega && regb)
|
||||
{
|
||||
|
|
|
@ -169,7 +169,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
else
|
||||
{
|
||||
grub_free (data);
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "%s cannot get C/H/S values", disk->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
1024 /* cylinders */ *
|
||||
256 /* heads */ *
|
||||
63 /* spt */)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
|
||||
|
||||
soff = ((grub_uint32_t) sector) % data->sectors + 1;
|
||||
head = ((grub_uint32_t) sector) / data->sectors;
|
||||
|
@ -260,7 +260,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
coff = head / data->heads;
|
||||
|
||||
if (coff >= data->cylinders)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
|
||||
|
||||
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
|
||||
coff, hoff, soff, size, segment))
|
||||
|
@ -268,9 +268,9 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
switch (cmd)
|
||||
{
|
||||
case GRUB_BIOSDISK_READ:
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "biosdisk read error");
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "%s read error", disk->name);
|
||||
case GRUB_BIOSDISK_WRITE:
|
||||
return grub_error (GRUB_ERR_WRITE_ERROR, "biosdisk write error");
|
||||
return grub_error (GRUB_ERR_WRITE_ERROR, "%s write error", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ grub_ofdisk_iterate (int (*hook) (const char *name))
|
|||
}
|
||||
|
||||
if (! grub_strcmp (alias->type, "block") &&
|
||||
grub_strcmp (alias->name, "cdrom"))
|
||||
grub_strncmp (alias->name, "cdrom", 5))
|
||||
ret = hook (alias->name);
|
||||
return ret;
|
||||
}
|
||||
|
|
26
fs/hfs.c
26
fs/hfs.c
|
@ -1072,6 +1072,31 @@ grub_hfs_label (grub_device_t device, char **label)
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_hfs_uuid (grub_device_t device, char **uuid)
|
||||
{
|
||||
struct grub_hfs_data *data;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
data = grub_hfs_mount (device->disk);
|
||||
if (data && data->sblock.num_serial != 0)
|
||||
{
|
||||
*uuid = grub_malloc (16 + sizeof ('\0'));
|
||||
grub_sprintf (*uuid, "%016llx",
|
||||
(unsigned long long)
|
||||
grub_be_to_cpu64 (data->sblock.num_serial));
|
||||
}
|
||||
else
|
||||
*uuid = NULL;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
grub_free (data);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct grub_fs grub_hfs_fs =
|
||||
|
@ -1082,6 +1107,7 @@ static struct grub_fs grub_hfs_fs =
|
|||
.read = grub_hfs_read,
|
||||
.close = grub_hfs_close,
|
||||
.label = grub_hfs_label,
|
||||
.uuid = grub_hfs_uuid,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
|
|
51
fs/ntfs.c
51
fs/ntfs.c
|
@ -63,7 +63,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic)
|
|||
static grub_err_t read_mft (struct grub_ntfs_data *data, char *buf,
|
||||
grub_uint32_t mftno);
|
||||
static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
|
||||
grub_uint32_t ofs, grub_uint32_t len,
|
||||
grub_disk_addr_t ofs, grub_size_t len,
|
||||
int cached,
|
||||
void
|
||||
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
|
||||
|
@ -72,7 +72,7 @@ static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
|
|||
unsigned length));
|
||||
|
||||
static grub_err_t read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
|
||||
grub_uint32_t ofs, grub_uint32_t len,
|
||||
grub_disk_addr_t ofs, grub_size_t len,
|
||||
int cached,
|
||||
void
|
||||
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
|
||||
|
@ -260,9 +260,9 @@ locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
|
|||
}
|
||||
|
||||
static char *
|
||||
read_run_data (char *run, int nn, grub_uint32_t * val, int sig)
|
||||
read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
|
||||
{
|
||||
grub_uint32_t r, v;
|
||||
grub_disk_addr_t r, v;
|
||||
|
||||
r = 0;
|
||||
v = 1;
|
||||
|
@ -284,7 +284,7 @@ grub_err_t
|
|||
grub_ntfs_read_run_list (struct grub_ntfs_rlst * ctx)
|
||||
{
|
||||
int c1, c2;
|
||||
grub_uint32_t val;
|
||||
grub_disk_addr_t val;
|
||||
char *run;
|
||||
|
||||
run = ctx->cur_run;
|
||||
|
@ -335,25 +335,25 @@ grub_ntfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t block)
|
|||
struct grub_ntfs_rlst *ctx;
|
||||
|
||||
ctx = (struct grub_ntfs_rlst *) node;
|
||||
if ((grub_uint32_t) block >= ctx->next_vcn)
|
||||
if (block >= ctx->next_vcn)
|
||||
{
|
||||
if (grub_ntfs_read_run_list (ctx))
|
||||
return -1;
|
||||
return ctx->curr_lcn;
|
||||
}
|
||||
else
|
||||
return (ctx->flags & RF_BLNK) ? 0 : ((grub_uint32_t) block -
|
||||
return (ctx->flags & RF_BLNK) ? 0 : (block -
|
||||
ctx->curr_vcn + ctx->curr_lcn);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
|
||||
grub_uint32_t len, int cached,
|
||||
read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
|
||||
grub_disk_addr_t ofs, grub_size_t len, int cached,
|
||||
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
|
||||
unsigned offset,
|
||||
unsigned length))
|
||||
{
|
||||
grub_uint32_t vcn;
|
||||
grub_disk_addr_t vcn;
|
||||
struct grub_ntfs_rlst cc, *ctx;
|
||||
|
||||
if (len == 0)
|
||||
|
@ -388,7 +388,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
|
|||
{
|
||||
if ((ofs & (~(COM_LEN - 1))) == at->save_pos)
|
||||
{
|
||||
grub_uint32_t n;
|
||||
grub_disk_addr_t n;
|
||||
|
||||
n = COM_LEN - (ofs - at->save_pos);
|
||||
if (n > len)
|
||||
|
@ -411,11 +411,11 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
|
|||
at->save_pos = 1;
|
||||
}
|
||||
|
||||
vcn = ctx->target_vcn = (ofs / COM_LEN) * (COM_SEC / ctx->comp.spc);
|
||||
vcn = ctx->target_vcn = (ofs >> COM_LOG_LEN) * (COM_SEC / ctx->comp.spc);
|
||||
ctx->target_vcn &= ~0xF;
|
||||
}
|
||||
else
|
||||
vcn = ctx->target_vcn = (ofs >> BLK_SHR) / ctx->comp.spc;
|
||||
vcn = ctx->target_vcn = grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, 0);
|
||||
|
||||
ctx->next_vcn = u32at (pa, 0x10);
|
||||
ctx->curr_lcn = 0;
|
||||
|
@ -427,11 +427,13 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
|
|||
|
||||
if (at->flags & AF_GPOS)
|
||||
{
|
||||
grub_uint32_t st0, st1;
|
||||
grub_disk_addr_t st0, st1;
|
||||
grub_uint32_t m;
|
||||
|
||||
grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, &m);
|
||||
|
||||
st0 =
|
||||
(ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc +
|
||||
((ofs >> BLK_SHR) % ctx->comp.spc);
|
||||
(ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc + m;
|
||||
st1 = st0 + 1;
|
||||
if (st1 ==
|
||||
(ctx->next_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc)
|
||||
|
@ -462,8 +464,8 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
read_attr (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
|
||||
grub_uint32_t len, int cached,
|
||||
read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
|
||||
grub_size_t len, int cached,
|
||||
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
|
||||
unsigned offset,
|
||||
unsigned length))
|
||||
|
@ -479,9 +481,9 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
|
|||
if (at->flags & AF_ALST)
|
||||
{
|
||||
char *pa;
|
||||
grub_uint32_t vcn;
|
||||
grub_disk_addr_t vcn;
|
||||
|
||||
vcn = ofs / (at->mft->data->spc << BLK_SHR);
|
||||
vcn = grub_divmod64 (ofs, at->mft->data->spc << BLK_SHR, 0);
|
||||
pa = at->attr_nxt + u16at (at->attr_nxt, 4);
|
||||
while (pa < at->attr_end)
|
||||
{
|
||||
|
@ -508,7 +510,7 @@ static grub_err_t
|
|||
read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno)
|
||||
{
|
||||
if (read_attr
|
||||
(&data->mmft.attr, buf, mftno * (data->mft_size << BLK_SHR),
|
||||
(&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << BLK_SHR),
|
||||
data->mft_size << BLK_SHR, 0, 0))
|
||||
return grub_error (GRUB_ERR_BAD_FS, "Read MFT 0x%X fails", mftno);
|
||||
return fixup (data, buf, data->mft_size, "FILE");
|
||||
|
@ -640,7 +642,8 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
|
|||
unsigned char *bitmap;
|
||||
struct grub_ntfs_attr attr, *at;
|
||||
char *cur_pos, *indx, *bmp;
|
||||
int bitmap_len, ret = 0;
|
||||
int ret = 0;
|
||||
grub_size_t bitmap_len;
|
||||
struct grub_ntfs_file *mft;
|
||||
|
||||
mft = (struct grub_ntfs_file *) dir;
|
||||
|
@ -744,14 +747,14 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
|
|||
|
||||
if (bitmap)
|
||||
{
|
||||
grub_uint32_t v, i;
|
||||
grub_disk_addr_t v, i;
|
||||
|
||||
indx = grub_malloc (mft->data->idx_size << BLK_SHR);
|
||||
if (indx == NULL)
|
||||
goto done;
|
||||
|
||||
v = 1;
|
||||
for (i = 0; i < (grub_uint32_t) bitmap_len * 8; i++)
|
||||
for (i = 0; i < (grub_disk_addr_t)bitmap_len * 8; i++)
|
||||
{
|
||||
if (*bitmap & v)
|
||||
{
|
||||
|
|
|
@ -209,7 +209,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
|
|||
}
|
||||
}
|
||||
|
||||
nn = (16 - (ctx->target_vcn & 0xF)) / cpb;
|
||||
nn = (16 - (unsigned) (ctx->target_vcn & 0xF)) / cpb;
|
||||
if (nn > num)
|
||||
nn = num;
|
||||
num -= nn;
|
||||
|
|
|
@ -19,6 +19,7 @@ EXTRA_DISTFILES="AUTHORS COPYING ChangeLog DISTLIST INSTALL NEWS README \
|
|||
gendistlist.sh genfslist.sh genhandlerlist.sh geninit.sh \
|
||||
geninitheader.sh genkernsyms.sh.in genmk.rb genmoddep.awk \
|
||||
genmodsrc.sh genpartmaplist.sh genparttoollist.sh \
|
||||
genvideolist.sh \
|
||||
gensymlist.sh.in install-sh mkinstalldirs stamp-h.in"
|
||||
|
||||
DISTDIRS="boot bus commands conf disk docs efiemu font fs hello hook include io \
|
||||
|
@ -35,7 +36,7 @@ dir=`dirname $0`
|
|||
cd $dir
|
||||
|
||||
for dir in $DISTDIRS; do
|
||||
for d in `find $dir -type d -not -name .svn -not -name .bzr | sort`; do
|
||||
for d in `find $dir -type d ! -name .svn ! -name .bzr | sort`; do
|
||||
find $d -maxdepth 1 -name '*.[chSy]' -o -name '*.mk' -o -name '*.rmk' \
|
||||
-o -name '*.rb' -o -name '*.in' -o -name '*.tex' -o -name '*.texi' \
|
||||
-o -name '*.info' -o -name 'grub.cfg' -o -name 'README' \
|
||||
|
|
9
genmk.rb
9
genmk.rb
|
@ -193,6 +193,7 @@ endif
|
|||
partmap = 'partmap-' + obj.suffix('lst')
|
||||
handler = 'handler-' + obj.suffix('lst')
|
||||
parttool = 'parttool-' + obj.suffix('lst')
|
||||
video = 'video-' + obj.suffix('lst')
|
||||
dep = deps[i]
|
||||
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
|
||||
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
|
||||
|
@ -203,7 +204,7 @@ endif
|
|||
-include #{dep}
|
||||
|
||||
clean-module-#{extra_target}.#{@rule_count}:
|
||||
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool}
|
||||
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video}
|
||||
|
||||
CLEAN_MODULE_TARGETS += clean-module-#{extra_target}.#{@rule_count}
|
||||
|
||||
|
@ -212,6 +213,7 @@ FSFILES += #{fs}
|
|||
PARTTOOLFILES += #{parttool}
|
||||
PARTMAPFILES += #{partmap}
|
||||
HANDLERFILES += #{handler}
|
||||
VIDEOFILES += #{video}
|
||||
|
||||
#{command}: #{src} $(#{src}_DEPENDENCIES) gencmdlist.sh
|
||||
set -e; \
|
||||
|
@ -238,6 +240,11 @@ HANDLERFILES += #{handler}
|
|||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
||||
| sh $(srcdir)/genhandlerlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
||||
|
||||
#{video}: #{src} $(#{src}_DEPENDENCIES) genvideolist.sh
|
||||
set -e; \
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
||||
| sh $(srcdir)/genvideolist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
||||
|
||||
"
|
||||
end.join('')
|
||||
end
|
||||
|
|
26
genvideolist.sh
Normal file
26
genvideolist.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Copyright (C) 2005,2008,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This script is free software; the author
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
# Read source code from stdin and detect partmap names.
|
||||
|
||||
module=$1
|
||||
|
||||
# Ignore video.mod.
|
||||
if test $module = video; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# For now, this emits only a module name, if the module registers a partition map.
|
||||
if grep -v "^#" | grep '^ *grub_video_register' >/dev/null 2>&1; then
|
||||
echo $module
|
||||
fi
|
|
@ -17,6 +17,7 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/list.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
@ -41,6 +42,16 @@ static int grub_gettext_max;
|
|||
|
||||
static const char *(*grub_gettext_original) (const char *s);
|
||||
|
||||
struct grub_gettext_msg
|
||||
{
|
||||
struct grub_gettext_msg *next;
|
||||
const char *name;
|
||||
|
||||
const char *translated;
|
||||
};
|
||||
|
||||
struct grub_gettext_msg *grub_gettext_msg_list = NULL;
|
||||
|
||||
#define GETTEXT_MAGIC_NUMBER 0
|
||||
#define GETTEXT_FILE_FORMAT 4
|
||||
#define GETTEXT_NUMBER_OF_STRINGS 8
|
||||
|
@ -79,7 +90,7 @@ grub_gettext_getstring_from_offset (grub_uint32_t offset,
|
|||
translation[length] = '\0';
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
grub_gettext_gettranslation_from_position (int position)
|
||||
{
|
||||
int offsettranslation;
|
||||
|
@ -130,9 +141,18 @@ static const char *
|
|||
grub_gettext_translate (const char *orig)
|
||||
{
|
||||
char *current_string;
|
||||
char *ret;
|
||||
const char *ret;
|
||||
|
||||
int min, max, current;
|
||||
int found = 0;
|
||||
|
||||
struct grub_gettext_msg *cur;
|
||||
|
||||
cur = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_gettext_msg_list),
|
||||
orig);
|
||||
|
||||
if (cur)
|
||||
return cur->translated;
|
||||
|
||||
if (fd_mo == 0)
|
||||
return orig;
|
||||
|
@ -142,7 +162,7 @@ grub_gettext_translate (const char *orig)
|
|||
|
||||
current = (max + min) / 2;
|
||||
|
||||
while (current != min && current != max)
|
||||
while (current != min && current != max && found == 0)
|
||||
{
|
||||
current_string = grub_gettext_getstring_from_position (current);
|
||||
|
||||
|
@ -160,13 +180,31 @@ grub_gettext_translate (const char *orig)
|
|||
else if (grub_strcmp (current_string, orig) == 0)
|
||||
{
|
||||
grub_free (current_string);
|
||||
return grub_gettext_gettranslation_from_position (current);
|
||||
found = 1;
|
||||
}
|
||||
current = (max + min) / 2;
|
||||
}
|
||||
|
||||
ret = grub_malloc (grub_strlen (orig) + 1);
|
||||
grub_strcpy (ret, orig);
|
||||
ret = found ? grub_gettext_gettranslation_from_position (current) : orig;
|
||||
|
||||
if (found)
|
||||
{
|
||||
cur = grub_zalloc (sizeof (*cur));
|
||||
|
||||
if (cur)
|
||||
{
|
||||
cur->name = grub_strdup (orig);
|
||||
if (cur->name)
|
||||
{
|
||||
cur->translated = ret;
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_gettext_msg_list),
|
||||
GRUB_AS_LIST (cur));
|
||||
}
|
||||
}
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -222,7 +260,7 @@ grub_gettext_init_ext (const char *lang)
|
|||
locale_dir = grub_env_get ("locale_dir");
|
||||
if (locale_dir == NULL)
|
||||
{
|
||||
grub_printf ("locale_dir variable is not set up.");
|
||||
grub_dprintf ("gettext", "locale_dir variable is not set up.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -259,12 +297,29 @@ grub_gettext_init_ext (const char *lang)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grub_gettext_delete_list ()
|
||||
{
|
||||
struct grub_gettext_msg *item;
|
||||
|
||||
while ((item =
|
||||
grub_list_pop (GRUB_AS_LIST_P (&grub_gettext_msg_list))) != 0)
|
||||
{
|
||||
char *original = (char *) ((struct grub_gettext_msg *) item)->name;
|
||||
grub_free (original);
|
||||
|
||||
// Don't delete the translated message because could be in use.
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
grub_gettext_env_write_lang (struct grub_env_var *var
|
||||
__attribute__ ((unused)), const char *val)
|
||||
{
|
||||
grub_gettext_init_ext (val);
|
||||
|
||||
grub_gettext_delete_list ();
|
||||
|
||||
return grub_strdup (val);
|
||||
}
|
||||
|
||||
|
@ -307,5 +362,7 @@ GRUB_MOD_FINI (gettext)
|
|||
if (fd_mo != 0)
|
||||
grub_file_close (fd_mo);
|
||||
|
||||
grub_gettext_delete_list ();
|
||||
|
||||
grub_gettext = grub_gettext_original;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,6 @@ char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
|
|||
grub_efi_device_path_t *
|
||||
EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
|
||||
int EXPORT_FUNC(grub_efi_exit_boot_services) (grub_efi_uintn_t map_key);
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
void EXPORT_FUNC (grub_halt) (void);
|
||||
int EXPORT_FUNC (grub_efi_finish_boot_services) (void);
|
||||
|
||||
void grub_efi_mm_init (void);
|
||||
|
|
|
@ -48,7 +48,8 @@ struct grub_hfs_sblock
|
|||
/* A pascal style string that holds the volumename. */
|
||||
grub_uint8_t volname[28];
|
||||
|
||||
grub_uint8_t unused5[60];
|
||||
grub_uint8_t unused5[52];
|
||||
grub_uint64_t num_serial;
|
||||
grub_uint16_t embed_sig;
|
||||
struct grub_hfs_extent embed_extent;
|
||||
grub_uint8_t unused6[4];
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* memory.h - describe the memory map */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,17 +17,14 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/cpu/at_keyboard.h>
|
||||
#include <grub/cpu/reboot.h>
|
||||
#include <grub/misc.h>
|
||||
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||
#define GRUB_MEMORY_CPU_HEADER 1
|
||||
|
||||
void
|
||||
grub_reboot (void)
|
||||
{
|
||||
/* Use the keyboard controller to reboot. That's what keyboards were
|
||||
designed for, isn't it? */
|
||||
grub_outb (KEYBOARD_COMMAND_REBOOT, KEYBOARD_REG_STATUS);
|
||||
/* The flag for protected mode. */
|
||||
#define GRUB_MEMORY_CPU_CR0_PE_ON 0x1
|
||||
#define GRUB_MEMORY_CPU_CR4_PAE_ON 0x00000040
|
||||
#define GRUB_MEMORY_CPU_CR0_PAGING_ON 0x80000000
|
||||
#define GRUB_MEMORY_CPU_AMD64_MSR 0xc0000080
|
||||
#define GRUB_MEMORY_CPU_AMD64_MSR_ON 0x00000100
|
||||
|
||||
grub_printf ("GRUB doesn't know how to reboot this machine yet!\n");
|
||||
}
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
|
@ -27,16 +27,9 @@ void grub_multiboot2_real_boot (grub_addr_t entry,
|
|||
struct multiboot_info *mbi)
|
||||
__attribute__ ((noreturn));
|
||||
|
||||
extern grub_addr_t grub_multiboot_payload_orig;
|
||||
extern grub_uint32_t grub_multiboot_payload_eip;
|
||||
extern char *grub_multiboot_payload_orig;
|
||||
extern grub_addr_t grub_multiboot_payload_dest;
|
||||
extern grub_size_t grub_multiboot_payload_size;
|
||||
extern grub_uint32_t grub_multiboot_payload_entry_offset;
|
||||
|
||||
extern grub_uint8_t grub_multiboot_forward_relocator;
|
||||
extern grub_uint8_t grub_multiboot_forward_relocator_end;
|
||||
extern grub_uint8_t grub_multiboot_backward_relocator;
|
||||
extern grub_uint8_t grub_multiboot_backward_relocator_end;
|
||||
|
||||
#define RELOCATOR_SIZEOF(x) (&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
|
||||
|
||||
#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
|
||||
|
|
|
@ -39,13 +39,6 @@ grub_uint32_t EXPORT_FUNC(grub_get_mmap_entry) (struct grub_machine_mmap_entry *
|
|||
/* Turn on/off Gate A20. */
|
||||
void grub_gate_a20 (int on);
|
||||
|
||||
/* Reboot the machine. */
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
|
||||
/* Halt the system, using APM if possible. If NO_APM is true, don't
|
||||
* use APM even if it is available. */
|
||||
void EXPORT_FUNC (grub_halt) (int no_apm);
|
||||
|
||||
void EXPORT_FUNC(grub_stop_floppy) (void);
|
||||
|
||||
#endif /* ! GRUB_INIT_MACHINE_HEADER */
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <grub/memory.h>
|
||||
#endif
|
||||
|
||||
#include <grub/i386/memory.h>
|
||||
|
||||
/* The scratch buffer used in real mode code. */
|
||||
#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000
|
||||
#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4)
|
||||
|
@ -62,9 +64,6 @@
|
|||
/* The address where another boot loader is loaded. */
|
||||
#define GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00
|
||||
|
||||
/* The flag for protected mode. */
|
||||
#define GRUB_MEMORY_MACHINE_CR0_PE_ON 0x1
|
||||
|
||||
/* The code segment of the protected mode. */
|
||||
#define GRUB_MEMORY_MACHINE_PROT_MODE_CSEG 0x8
|
||||
|
||||
|
|
|
@ -67,4 +67,20 @@ grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
|
|||
grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
|
||||
grub_addr_t base,
|
||||
grub_size_t size __attribute__ ((unused)))
|
||||
{
|
||||
return (void *) base;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
|
||||
void *mem __attribute__ ((unused)),
|
||||
grub_size_t size __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endif /* GRUB_CPU_PCI_H */
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern void grub_reboot (void);
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,4 +16,26 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern void grub_halt (void);
|
||||
#ifndef GRUB_RELOCATOR_CPU_HEADER
|
||||
#define GRUB_RELOCATOR_CPU_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
struct grub_relocator32_state
|
||||
{
|
||||
grub_uint32_t esp;
|
||||
grub_uint32_t eax;
|
||||
grub_uint32_t ebx;
|
||||
grub_uint32_t ecx;
|
||||
grub_uint32_t edx;
|
||||
grub_uint32_t eip;
|
||||
};
|
||||
|
||||
void *grub_relocator32_alloc (grub_size_t size);
|
||||
grub_err_t grub_relocator32_boot (void *relocator, grub_uint32_t dest,
|
||||
struct grub_relocator32_state state);
|
||||
void *grub_relocator32_realloc (void *relocator, grub_size_t size);
|
||||
void grub_relocator32_free (void *relocator);
|
||||
|
||||
#endif /* ! GRUB_RELOCATOR_CPU_HEADER */
|
|
@ -20,6 +20,9 @@
|
|||
#define GRUB_CPU_XNU_H 1
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/cpu/relocator.h>
|
||||
|
||||
#define XNU_RELOCATOR(x) (grub_relocator32_ ## x)
|
||||
|
||||
#define GRUB_XNU_PAGESIZE 4096
|
||||
typedef grub_uint32_t grub_xnu_ptr_t;
|
||||
|
@ -75,6 +78,4 @@ grub_err_t grub_xnu_boot (void);
|
|||
grub_err_t grub_cpu_xnu_fill_devicetree (void);
|
||||
grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *bootparams_relloc);
|
||||
extern grub_uint32_t grub_xnu_heap_will_be_at;
|
||||
extern grub_uint8_t grub_xnu_launcher_start[];
|
||||
extern grub_uint8_t grub_xnu_launcher_end[];
|
||||
#endif
|
||||
|
|
|
@ -171,6 +171,9 @@ char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n);
|
|||
void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_puts) (const char *s);
|
||||
int EXPORT_FUNC(grub_puts_) (const char *s);
|
||||
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||
const int line,
|
||||
const char *condition,
|
||||
|
@ -222,4 +225,15 @@ grub_div_roundup (unsigned int x, unsigned int y)
|
|||
return (x + y - 1) / y;
|
||||
}
|
||||
|
||||
/* Reboot the machine. */
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
/* Halt the system, using APM if possible. If NO_APM is true, don't
|
||||
* use APM even if it is available. */
|
||||
void EXPORT_FUNC (grub_halt) (int no_apm);
|
||||
#else
|
||||
void EXPORT_FUNC (grub_halt) (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_MISC_HEADER */
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#define MAX_IDX (16384 >> BLK_SHR)
|
||||
|
||||
#define COM_LEN 4096
|
||||
#define COM_LOG_LEN 12
|
||||
#define COM_SEC (COM_LEN >> BLK_SHR)
|
||||
|
||||
#define AF_ALST 1
|
||||
|
@ -164,7 +165,7 @@ struct grub_ntfs_comp
|
|||
struct grub_ntfs_rlst
|
||||
{
|
||||
int flags;
|
||||
grub_uint32_t target_vcn, curr_vcn, next_vcn, curr_lcn;
|
||||
grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn;
|
||||
char *cur_run;
|
||||
struct grub_ntfs_attr *attr;
|
||||
struct grub_ntfs_comp comp;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -36,15 +36,44 @@
|
|||
#define GRUB_PCI_ADDR_IO_MASK ~0x03
|
||||
|
||||
typedef grub_uint32_t grub_pci_id_t;
|
||||
typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
|
||||
(int bus, int device, int func, grub_pci_id_t pciid);
|
||||
typedef grub_uint32_t grub_pci_address_t;
|
||||
|
||||
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (int bus, int device,
|
||||
int function, int reg);
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/pciutils.h>
|
||||
#else
|
||||
typedef grub_uint32_t grub_pci_address_t;
|
||||
struct grub_pci_device
|
||||
{
|
||||
int bus;
|
||||
int device;
|
||||
int function;
|
||||
};
|
||||
typedef struct grub_pci_device grub_pci_device_t;
|
||||
static inline int
|
||||
grub_pci_get_bus (grub_pci_device_t dev)
|
||||
{
|
||||
return dev.bus;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_pci_get_device (grub_pci_device_t dev)
|
||||
{
|
||||
return dev.device;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_pci_get_function (grub_pci_device_t dev)
|
||||
{
|
||||
return dev.function;
|
||||
}
|
||||
#include <grub/cpu/pci.h>
|
||||
#endif
|
||||
|
||||
typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
|
||||
(grub_pci_device_t dev, grub_pci_id_t pciid);
|
||||
|
||||
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
|
||||
int reg);
|
||||
|
||||
void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
|
||||
|
||||
#include <grub/cpu/pci.h>
|
||||
|
||||
#endif /* GRUB_PCI_H */
|
||||
|
|
103
include/grub/pciutils.h
Normal file
103
include/grub/pciutils.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_PCIUTILS_H
|
||||
#define GRUB_PCIUTILS_H 1
|
||||
|
||||
#include <pciaccess.h>
|
||||
|
||||
typedef struct pci_device *grub_pci_device_t;
|
||||
|
||||
static inline int
|
||||
grub_pci_get_bus (grub_pci_device_t dev)
|
||||
{
|
||||
return dev->bus;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_pci_get_device (grub_pci_device_t dev)
|
||||
{
|
||||
return dev->dev;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_pci_get_function (grub_pci_device_t dev)
|
||||
{
|
||||
return dev->func;
|
||||
}
|
||||
|
||||
struct grub_pci_address
|
||||
{
|
||||
grub_pci_device_t dev;
|
||||
int pos;
|
||||
};
|
||||
|
||||
typedef struct grub_pci_address grub_pci_address_t;
|
||||
|
||||
static inline grub_uint32_t
|
||||
grub_pci_read (grub_pci_address_t addr)
|
||||
{
|
||||
grub_uint32_t ret;
|
||||
pci_device_cfg_read_u32 (addr.dev, &ret, addr.pos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline grub_uint16_t
|
||||
grub_pci_read_word (grub_pci_address_t addr)
|
||||
{
|
||||
grub_uint16_t ret;
|
||||
pci_device_cfg_read_u16 (addr.dev, &ret, addr.pos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_pci_read_byte (grub_pci_address_t addr)
|
||||
{
|
||||
grub_uint8_t ret;
|
||||
pci_device_cfg_read_u8 (addr.dev, &ret, addr.pos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
|
||||
{
|
||||
pci_device_cfg_write_u32 (addr.dev, data, addr.pos);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
|
||||
{
|
||||
pci_device_cfg_write_u16 (addr.dev, data, addr.pos);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
|
||||
{
|
||||
pci_device_cfg_write_u8 (addr.dev, data, addr.pos);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
|
||||
grub_size_t size);
|
||||
|
||||
void
|
||||
grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
|
||||
grub_size_t size);
|
||||
|
||||
|
||||
#endif /* GRUB_PCIUTILS_H */
|
|
@ -23,9 +23,6 @@
|
|||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
void EXPORT_FUNC (grub_halt) (void);
|
||||
|
||||
/* The prefix which points to the directory where GRUB modules and its
|
||||
configuration file are located. */
|
||||
extern char grub_prefix[];
|
||||
|
|
|
@ -54,9 +54,6 @@ extern grub_int32_t grub_total_module_size;
|
|||
configuration file are located. */
|
||||
extern char grub_prefix[];
|
||||
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
void EXPORT_FUNC (grub_halt) (void);
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <setjmp.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -57,12 +58,20 @@ void grub_util_write_image (const char *img, size_t size, FILE *out);
|
|||
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
||||
FILE *out);
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
|
||||
int vasprintf (char **buf, const char *fmt, va_list ap);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
|
||||
int asprintf (char **buf, const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
char *xasprintf (const char *fmt, ...);
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#define fseeko fseeko64
|
||||
|
|
1
include/grub/x86_64/relocator.h
Normal file
1
include/grub/x86_64/relocator.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include <grub/i386/relocator.h>
|
|
@ -92,6 +92,7 @@ struct grub_xnu_devtree_key *grub_xnu_create_value (struct grub_xnu_devtree_key
|
|||
void grub_xnu_lock (void);
|
||||
void grub_xnu_unlock (void);
|
||||
grub_err_t grub_xnu_resume (char *imagename);
|
||||
grub_err_t grub_xnu_boot_resume (void);
|
||||
struct grub_xnu_devtree_key *grub_xnu_find_key (struct grub_xnu_devtree_key *parent,
|
||||
char *name);
|
||||
grub_err_t grub_xnu_align_heap (int align);
|
||||
|
@ -100,8 +101,7 @@ grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname, char *osbundlerequired,
|
|||
grub_err_t grub_xnu_load_kext_from_dir (char *dirname, char *osbundlerequired,
|
||||
int maxrecursion);
|
||||
void *grub_xnu_heap_malloc (int size);
|
||||
extern grub_uint32_t grub_xnu_heap_real_start;
|
||||
extern grub_size_t grub_xnu_heap_size;
|
||||
extern char *grub_xnu_heap_start;
|
||||
extern void *grub_xnu_heap_start;
|
||||
extern struct grub_video_bitmap *grub_xnu_bitmap;
|
||||
#endif
|
||||
|
|
|
@ -109,6 +109,8 @@ grub_device_iterate (int (*hook) (const char *name))
|
|||
(void) grub_partition_iterate (dev->disk, iterate_partition);
|
||||
grub_device_close (dev);
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
p = ents;
|
||||
while (p != NULL)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/cpu/halt.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
|
|
|
@ -146,6 +146,9 @@ multiboot_entry:
|
|||
/* obtain the boot device */
|
||||
movl 12(%ebx), %edx
|
||||
|
||||
movl $GRUB_MEMORY_MACHINE_PROT_STACK, %ebp
|
||||
movl %ebp, %esp
|
||||
|
||||
/* relocate the code */
|
||||
movl $(GRUB_KERNEL_MACHINE_RAW_SIZE + 0x200), %ecx
|
||||
addl EXT_C(grub_compressed_size) - _start + 0x100000 + 0x200, %ecx
|
||||
|
@ -484,21 +487,6 @@ FUNCTION(grub_exit)
|
|||
jmp cold_reboot
|
||||
.code32
|
||||
|
||||
/*
|
||||
* grub_reboot()
|
||||
*
|
||||
* Reboot the system. At the moment, rely on BIOS.
|
||||
*/
|
||||
FUNCTION(grub_reboot)
|
||||
call prot_to_real
|
||||
.code16
|
||||
cold_reboot:
|
||||
/* cold boot */
|
||||
movw $0x0472, %di
|
||||
movw %ax, (%di)
|
||||
ljmp $0xFFFF, $0x0000
|
||||
.code32
|
||||
|
||||
/*
|
||||
* grub_halt(int no_apm)
|
||||
*
|
||||
|
|
|
@ -95,3 +95,5 @@ codestart:
|
|||
|
||||
/* This should never happen. */
|
||||
jmp EXT_C(grub_stop)
|
||||
|
||||
#include "../realmode.S"
|
||||
|
|
|
@ -127,7 +127,7 @@ real_to_prot:
|
|||
|
||||
/* turn on protected mode */
|
||||
movl %cr0, %eax
|
||||
orl $GRUB_MEMORY_MACHINE_CR0_PE_ON, %eax
|
||||
orl $GRUB_MEMORY_CPU_CR0_PE_ON, %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* jump to relocation, flush prefetch queue, and reload %cs */
|
||||
|
@ -196,7 +196,7 @@ tmpcseg:
|
|||
|
||||
/* clear the PE bit of CR0 */
|
||||
movl %cr0, %eax
|
||||
andl $(~GRUB_MEMORY_MACHINE_CR0_PE_ON), %eax
|
||||
andl $(~GRUB_MEMORY_CPU_CR0_PE_ON), %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* flush prefetch queue, reload %cs */
|
||||
|
@ -215,10 +215,27 @@ realcseg:
|
|||
movw %ax, %gs
|
||||
movw %ax, %ss
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
/* restore interrupts */
|
||||
sti
|
||||
#endif
|
||||
|
||||
/* return on new stack! */
|
||||
DATA32 ret
|
||||
|
||||
.code32
|
||||
|
||||
/*
|
||||
* grub_reboot()
|
||||
*
|
||||
* Reboot the system. At the moment, rely on BIOS.
|
||||
*/
|
||||
FUNCTION(grub_reboot)
|
||||
call prot_to_real
|
||||
.code16
|
||||
cold_reboot:
|
||||
/* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
|
||||
movw $0x0472, %di
|
||||
movw %ax, (%di)
|
||||
ljmp $0xf000, $0xfff0
|
||||
.code32
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* openfw.c -- Open firmware support functions. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -399,11 +399,14 @@ grub_ieee1275_encode_devname (const char *path)
|
|||
return encoding;
|
||||
}
|
||||
|
||||
/* On i386, a firmware-independant grub_reboot() is provided by realmode.S. */
|
||||
#ifndef __i386__
|
||||
void
|
||||
grub_reboot (void)
|
||||
{
|
||||
grub_ieee1275_interpret ("reset-all", 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_halt (void)
|
||||
|
|
32
kern/misc.c
32
kern/misc.c
|
@ -126,6 +126,38 @@ grub_printf (const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
grub_printf_ (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start (ap, fmt);
|
||||
ret = grub_vprintf (_(fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
grub_puts (const char *s)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
grub_putchar (*s);
|
||||
s++;
|
||||
}
|
||||
grub_putchar ('\n');
|
||||
|
||||
return 1; /* Cannot fail. */
|
||||
}
|
||||
|
||||
int
|
||||
grub_puts_ (const char *s)
|
||||
{
|
||||
return grub_puts (_(s));
|
||||
}
|
||||
|
||||
#if defined (APPLE_CC) && ! defined (GRUB_UTIL)
|
||||
int
|
||||
grub_err_printf (const char *fmt, ...)
|
||||
|
|
|
@ -355,7 +355,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
|
|||
{
|
||||
char *tail;
|
||||
|
||||
grub_strtoul (option, &tail, 0);
|
||||
grub_strtoull (option, &tail, 0);
|
||||
if (tail == 0 || tail == option || *tail != '\0' || grub_errno)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
|
|
102
lib/i386/relocator.c
Normal file
102
lib/i386/relocator.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
#include <grub/i386/relocator.h>
|
||||
|
||||
extern grub_uint8_t grub_relocator32_forward_start;
|
||||
extern grub_uint8_t grub_relocator32_forward_end;
|
||||
extern grub_uint8_t grub_relocator32_backward_start;
|
||||
extern grub_uint8_t grub_relocator32_backward_end;
|
||||
|
||||
extern grub_uint32_t grub_relocator32_backward_dest;
|
||||
extern grub_uint32_t grub_relocator32_backward_size;
|
||||
extern grub_addr_t grub_relocator32_backward_src;
|
||||
|
||||
extern grub_uint32_t grub_relocator32_forward_dest;
|
||||
extern grub_uint32_t grub_relocator32_forward_size;
|
||||
extern grub_addr_t grub_relocator32_forward_src;
|
||||
|
||||
extern grub_uint32_t grub_relocator32_forward_eax;
|
||||
extern grub_uint32_t grub_relocator32_forward_ebx;
|
||||
extern grub_uint32_t grub_relocator32_forward_ecx;
|
||||
extern grub_uint32_t grub_relocator32_forward_edx;
|
||||
extern grub_uint32_t grub_relocator32_forward_eip;
|
||||
extern grub_uint32_t grub_relocator32_forward_esp;
|
||||
|
||||
extern grub_uint32_t grub_relocator32_backward_eax;
|
||||
extern grub_uint32_t grub_relocator32_backward_ebx;
|
||||
extern grub_uint32_t grub_relocator32_backward_ecx;
|
||||
extern grub_uint32_t grub_relocator32_backward_edx;
|
||||
extern grub_uint32_t grub_relocator32_backward_eip;
|
||||
extern grub_uint32_t grub_relocator32_backward_esp;
|
||||
|
||||
#define RELOCATOR_SIZEOF(x) (&grub_relocator32_##x##_end - &grub_relocator32_##x##_start)
|
||||
#define RELOCATOR_ALIGN 16
|
||||
#define PREFIX(x) grub_relocator32_ ## x
|
||||
|
||||
static void
|
||||
write_call_relocator_bw (void *ptr, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
grub_relocator32_backward_dest = dest;
|
||||
grub_relocator32_backward_src = PTR_TO_UINT64 (src);
|
||||
grub_relocator32_backward_size = size;
|
||||
|
||||
grub_relocator32_backward_eax = state.eax;
|
||||
grub_relocator32_backward_ebx = state.ebx;
|
||||
grub_relocator32_backward_ecx = state.ecx;
|
||||
grub_relocator32_backward_edx = state.edx;
|
||||
grub_relocator32_backward_eip = state.eip;
|
||||
grub_relocator32_backward_esp = state.esp;
|
||||
|
||||
grub_memmove (ptr,
|
||||
&grub_relocator32_backward_start,
|
||||
RELOCATOR_SIZEOF (backward));
|
||||
((void (*) (void)) ptr) ();
|
||||
}
|
||||
|
||||
static void
|
||||
write_call_relocator_fw (void *ptr, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
|
||||
grub_relocator32_forward_dest = dest;
|
||||
grub_relocator32_forward_src = PTR_TO_UINT64 (src);
|
||||
grub_relocator32_forward_size = size;
|
||||
|
||||
grub_relocator32_forward_eax = state.eax;
|
||||
grub_relocator32_forward_ebx = state.ebx;
|
||||
grub_relocator32_forward_ecx = state.ecx;
|
||||
grub_relocator32_forward_edx = state.edx;
|
||||
grub_relocator32_forward_eip = state.eip;
|
||||
grub_relocator32_forward_esp = state.esp;
|
||||
|
||||
grub_memmove (ptr,
|
||||
&grub_relocator32_forward_start,
|
||||
RELOCATOR_SIZEOF (forward));
|
||||
((void (*) (void)) ptr) ();
|
||||
}
|
||||
|
||||
#include "../relocator.c"
|
248
lib/i386/relocator_asm.S
Normal file
248
lib/i386/relocator_asm.S
Normal file
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/memory.h>
|
||||
|
||||
#ifdef BACKWARD
|
||||
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_backward_ ## x)
|
||||
#else
|
||||
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_forward_ ## x)
|
||||
#endif
|
||||
#ifdef __x86_64__
|
||||
#define RAX %rax
|
||||
#define RCX %rcx
|
||||
#define RDI %rdi
|
||||
#define RSI %rdi
|
||||
#else
|
||||
#define RAX %eax
|
||||
#define RCX %ecx
|
||||
#define RDI %edi
|
||||
#define RSI %esi
|
||||
#endif
|
||||
|
||||
/* The code segment of the protected mode. */
|
||||
#define CODE_SEGMENT 0x10
|
||||
|
||||
/* The data segment of the protected mode. */
|
||||
#define DATA_SEGMENT 0x18
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
RELOCATOR_VARIABLE(start)
|
||||
#ifdef BACKWARD
|
||||
LOCAL(base):
|
||||
#endif
|
||||
cli
|
||||
|
||||
#ifndef __x86_64__
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE(dest)
|
||||
.long 0
|
||||
movl %eax, %edi
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE(src)
|
||||
.long 0
|
||||
movl %eax, %esi
|
||||
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
RELOCATOR_VARIABLE(size)
|
||||
.long 0
|
||||
#else
|
||||
xorq %rax, %rax
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE(dest)
|
||||
.long 0
|
||||
movq %rax, %rdi
|
||||
|
||||
/* mov imm64, %rax */
|
||||
.byte 0x48
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE(src)
|
||||
.long 0, 0
|
||||
movq %rax, %rsi
|
||||
|
||||
xorq %rcx, %rcx
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
RELOCATOR_VARIABLE(size)
|
||||
.long 0
|
||||
|
||||
#endif
|
||||
|
||||
mov RDI, RAX
|
||||
|
||||
#ifdef BACKWARD
|
||||
add RCX, RSI
|
||||
add RCX, RDI
|
||||
#endif
|
||||
|
||||
#ifndef BACKWARD
|
||||
add RCX, RAX
|
||||
#endif
|
||||
add $0x3, RCX
|
||||
shr $2, RCX
|
||||
|
||||
|
||||
#ifdef BACKWARD
|
||||
/* Backward movsl is implicitly off-by-four. compensate that. */
|
||||
sub $4, RSI
|
||||
sub $4, RDI
|
||||
|
||||
/* Backward copy. */
|
||||
std
|
||||
|
||||
rep
|
||||
movsl
|
||||
|
||||
#else
|
||||
/* Forward copy. */
|
||||
cld
|
||||
rep
|
||||
movsl
|
||||
#endif
|
||||
|
||||
/* %rax contains now our new 'base'. */
|
||||
mov RAX, RSI
|
||||
add $(LOCAL(cont0) - LOCAL(base)), RAX
|
||||
jmp *RAX
|
||||
LOCAL(cont0):
|
||||
lea (LOCAL(cont1) - LOCAL(base)) (RSI, 1), RAX
|
||||
movl %eax, (LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
|
||||
|
||||
lea (LOCAL(gdt) - LOCAL(base)) (RSI, 1), RAX
|
||||
mov RAX, (LOCAL(gdt_addr) - LOCAL(base)) (RSI, 1)
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lgdt (LOCAL(gdtdesc) - LOCAL(base)) (RSI, 1)
|
||||
|
||||
/* Update %cs. */
|
||||
ljmp *(LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
|
||||
|
||||
LOCAL(cont1):
|
||||
.code32
|
||||
|
||||
/* Update other registers. */
|
||||
movl $DATA_SEGMENT, %eax
|
||||
movl %eax, %ds
|
||||
movl %eax, %es
|
||||
movl %eax, %fs
|
||||
movl %eax, %gs
|
||||
movl %eax, %ss
|
||||
|
||||
/* Disable paging. */
|
||||
movl %cr0, %eax
|
||||
andl $(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* Disable amd64. */
|
||||
movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
|
||||
rdmsr
|
||||
andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
|
||||
wrmsr
|
||||
|
||||
/* Turn off PAE. */
|
||||
movl %cr4, %eax
|
||||
andl $GRUB_MEMORY_CPU_CR4_PAE_ON, %eax
|
||||
movl %eax, %cr4
|
||||
|
||||
jmp LOCAL(cont2)
|
||||
LOCAL(cont2):
|
||||
.code32
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE (esp)
|
||||
.long 0
|
||||
|
||||
movl %eax, %esp
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
RELOCATOR_VARIABLE (eax)
|
||||
.long 0
|
||||
|
||||
/* mov imm32, %ebx */
|
||||
.byte 0xbb
|
||||
RELOCATOR_VARIABLE (ebx)
|
||||
.long 0
|
||||
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
RELOCATOR_VARIABLE (ecx)
|
||||
.long 0
|
||||
|
||||
/* mov imm32, %edx */
|
||||
.byte 0xba
|
||||
RELOCATOR_VARIABLE (edx)
|
||||
.long 0
|
||||
|
||||
/* Cleared direction flag is of no problem with any current
|
||||
payload and makes this implementation easier. */
|
||||
cld
|
||||
|
||||
.byte 0xea
|
||||
RELOCATOR_VARIABLE (eip)
|
||||
.long 0
|
||||
.word CODE_SEGMENT
|
||||
|
||||
/* GDT. Copied from loader/i386/linux.c. */
|
||||
.p2align 4
|
||||
LOCAL(gdt):
|
||||
/* NULL. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
/* Reserved. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
/* Code segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
|
||||
|
||||
/* Data segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
|
||||
|
||||
.p2align 4
|
||||
LOCAL(gdtdesc):
|
||||
.word 0x27
|
||||
LOCAL(gdt_addr):
|
||||
#ifdef __x86_64__
|
||||
/* Filled by the code. */
|
||||
.quad 0
|
||||
#else
|
||||
/* Filled by the code. */
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
.p2align 4
|
||||
LOCAL(jump_vector):
|
||||
/* Jump location. Is filled by the code */
|
||||
.long 0
|
||||
.long CODE_SEGMENT
|
||||
|
||||
#ifndef BACKWARD
|
||||
LOCAL(base):
|
||||
#endif
|
||||
|
||||
RELOCATOR_VARIABLE(end)
|
2
lib/i386/relocator_backward.S
Normal file
2
lib/i386/relocator_backward.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define BACKWARD
|
||||
#include "relocator_asm.S"
|
109
lib/mips/relocator.c
Normal file
109
lib/mips/relocator.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
#include <grub/mips/relocator.h>
|
||||
|
||||
/* Remark: doesn't work with source outside of 4G.
|
||||
Use relocator64 in this case.
|
||||
*/
|
||||
|
||||
extern grub_uint8_t grub_relocator32_forward_start;
|
||||
extern grub_uint8_t grub_relocator32_forward_end;
|
||||
extern grub_uint8_t grub_relocator32_backward_start;
|
||||
extern grub_uint8_t grub_relocator32_backward_end;
|
||||
|
||||
#define REGW_SIZEOF (2 * sizeof (grub_uint32_t))
|
||||
#define JUMP_SIZEOF (sizeof (grub_uint32_t))
|
||||
|
||||
#define RELOCATOR_SRC_SIZEOF(x) (&grub_relocator32_##x##_end \
|
||||
- &grub_relocator32_##x##_start)
|
||||
#define RELOCATOR_SIZEOF(x) (RELOCATOR_SRC_SIZEOF(x) \
|
||||
+ REGW_SIZEOF * (31 + 3) + JUMP_SIZEOF)
|
||||
#define RELOCATOR_ALIGN 16
|
||||
|
||||
#define PREFIX(x) grub_relocator32_ ## x
|
||||
|
||||
static void
|
||||
write_reg (int regn, grub_uint32_t val, void **target)
|
||||
{
|
||||
/* lui $r, (val+0x8000). */
|
||||
*(grub_uint32_t *) *target = ((0x3c00 | regn) << 16) | ((val + 0x8000) >> 16);
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
/* addiu $r, $r, val. */
|
||||
*(grub_uint32_t *) *target = (((0x2400 | regn << 5 | regn) << 16)
|
||||
| (val & 0xffff));
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
write_jump (int regn, void **target)
|
||||
{
|
||||
/* j $r. */
|
||||
*(grub_uint32_t *) *target = (regn<<21) | 0x8;
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
write_call_relocator_bw (void *ptr0, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
void *ptr = ptr0;
|
||||
int i;
|
||||
write_reg (8, (grub_uint32_t) src, &ptr);
|
||||
write_reg (9, dest, &ptr);
|
||||
write_reg (10, size, &ptr);
|
||||
grub_memcpy (ptr, &grub_relocator32_backward_start,
|
||||
RELOCATOR_SRC_SIZEOF (backward));
|
||||
ptr = (grub_uint8_t *) ptr + RELOCATOR_SRC_SIZEOF (backward);
|
||||
for (i = 1; i < 32; i++)
|
||||
write_reg (i, state.gpr[i], &ptr);
|
||||
write_jump (state.jumpreg, &ptr);
|
||||
grub_arch_sync_caches (ptr0, (grub_uint8_t *) ptr - (grub_uint8_t *) ptr0);
|
||||
grub_dprintf ("relocator", "Backward relocator: about to jump to %p\n", ptr0);
|
||||
((void (*) (void)) ptr0) ();
|
||||
}
|
||||
|
||||
static void
|
||||
write_call_relocator_fw (void *ptr0, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
void *ptr = ptr0;
|
||||
int i;
|
||||
write_reg (8, (grub_uint32_t) src, &ptr);
|
||||
write_reg (9, dest, &ptr);
|
||||
write_reg (10, size, &ptr);
|
||||
grub_memcpy (ptr, &grub_relocator32_forward_start,
|
||||
RELOCATOR_SRC_SIZEOF (forward));
|
||||
ptr = (grub_uint8_t *) ptr + RELOCATOR_SRC_SIZEOF (forward);
|
||||
for (i = 1; i < 32; i++)
|
||||
write_reg (i, state.gpr[i], &ptr);
|
||||
write_jump (state.jumpreg, &ptr);
|
||||
grub_arch_sync_caches (ptr0, (grub_uint8_t *) ptr - (grub_uint8_t *) ptr0);
|
||||
grub_dprintf ("relocator", "Forward relocator: about to jump to %p\n", ptr0);
|
||||
((void (*) (void)) ptr0) ();
|
||||
}
|
||||
|
||||
#include "../relocator.c"
|
93
lib/mips/relocator_asm.S
Normal file
93
lib/mips/relocator_asm.S
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
VARIABLE (grub_relocator32_forward_start)
|
||||
move $12, $9
|
||||
move $13, $10
|
||||
|
||||
copycont1:
|
||||
lb $11,0($8)
|
||||
sb $11,0($9)
|
||||
addiu $8, $8, 0x1
|
||||
addiu $9, $9, 0x1
|
||||
addiu $10, $10, 0xffff
|
||||
bne $10, $0, copycont1
|
||||
|
||||
move $9, $12
|
||||
move $10, $13
|
||||
cachecont1a:
|
||||
cache 1,0($12)
|
||||
addiu $12, $12, 0x1
|
||||
addiu $13, $13, 0xffff
|
||||
bne $13, $0, cachecont1a
|
||||
|
||||
sync
|
||||
|
||||
move $12, $9
|
||||
move $13, $10
|
||||
cachecont1b:
|
||||
cache 0,0($12)
|
||||
addiu $12, $12, 0x1
|
||||
addiu $13, $13, 0xffff
|
||||
bne $13, $0, cachecont1b
|
||||
|
||||
sync
|
||||
|
||||
VARIABLE (grub_relocator32_forward_end)
|
||||
|
||||
VARIABLE (grub_relocator32_backward_start)
|
||||
move $12, $9
|
||||
move $13, $10
|
||||
|
||||
addu $9, $9, $10
|
||||
addu $8, $8, $10
|
||||
/* Backward movsl is implicitly off-by-one. compensate that. */
|
||||
addiu $9, $9, 0xffff
|
||||
addiu $8, $8, 0xffff
|
||||
copycont2:
|
||||
lb $11,0($8)
|
||||
sb $11,0($9)
|
||||
addiu $8, $8, 0xffff
|
||||
addiu $9, $9, 0xffff
|
||||
addiu $10, 0xffff
|
||||
bne $10, $0, copycont2
|
||||
|
||||
move $9, $12
|
||||
move $10, $13
|
||||
cachecont2a:
|
||||
cache 1,0($12)
|
||||
addiu $12, $12, 0x1
|
||||
addiu $13, $13, 0xffff
|
||||
bne $13, $0, cachecont2a
|
||||
|
||||
sync
|
||||
|
||||
move $12, $9
|
||||
move $13, $10
|
||||
cachecont2b:
|
||||
cache 0,0($12)
|
||||
addiu $12, $12, 0x1
|
||||
addiu $13, $13, 0xffff
|
||||
bne $13, $0, cachecont2b
|
||||
|
||||
sync
|
||||
VARIABLE (grub_relocator32_backward_end)
|
137
lib/relocator.c
Normal file
137
lib/relocator.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define MAX_OVERHEAD ((RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) \
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) \
|
||||
+ (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) \
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN))
|
||||
#define PRE_REGION_SIZE (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
|
||||
|
||||
void *
|
||||
PREFIX (alloc) (grub_size_t size)
|
||||
{
|
||||
char *playground;
|
||||
|
||||
playground = grub_malloc (size + MAX_OVERHEAD);
|
||||
if (!playground)
|
||||
return 0;
|
||||
|
||||
*(grub_size_t *) playground = size;
|
||||
|
||||
return playground + PRE_REGION_SIZE;
|
||||
}
|
||||
|
||||
void *
|
||||
PREFIX (realloc) (void *relocator, grub_size_t size)
|
||||
{
|
||||
char *playground;
|
||||
|
||||
if (!relocator)
|
||||
return PREFIX (alloc) (size);
|
||||
|
||||
playground = (char *) relocator - PRE_REGION_SIZE;
|
||||
|
||||
playground = grub_realloc (playground, size + MAX_OVERHEAD);
|
||||
if (!playground)
|
||||
return 0;
|
||||
|
||||
*(grub_size_t *) playground = size;
|
||||
|
||||
return playground + PRE_REGION_SIZE;
|
||||
}
|
||||
|
||||
void
|
||||
PREFIX(free) (void *relocator)
|
||||
{
|
||||
if (relocator)
|
||||
grub_free ((char *) relocator - PRE_REGION_SIZE);
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
PREFIX (boot) (void *relocator, grub_uint32_t dest,
|
||||
struct grub_relocator32_state state)
|
||||
{
|
||||
grub_size_t size;
|
||||
char *playground;
|
||||
|
||||
playground = (char *) relocator - PRE_REGION_SIZE;
|
||||
size = *(grub_size_t *) playground;
|
||||
|
||||
grub_dprintf ("relocator",
|
||||
"Relocator: source: %p, destination: 0x%x, size: 0x%lx\n",
|
||||
relocator, (unsigned) dest, (unsigned long) size);
|
||||
|
||||
/* Very unlikely condition: Relocator may risk overwrite itself.
|
||||
Just move it a bit up. */
|
||||
if ((grub_addr_t) dest < (grub_addr_t) relocator
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
|
||||
&& (grub_addr_t) dest + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
|
||||
> (grub_addr_t) relocator)
|
||||
{
|
||||
void *relocator_new = ((grub_uint8_t *) relocator)
|
||||
+ (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN);
|
||||
grub_dprintf ("relocator", "Overwrite condition detected moving "
|
||||
"relocator from %p to %p\n", relocator, relocator_new);
|
||||
grub_memmove (relocator_new, relocator,
|
||||
(RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
|
||||
+ size
|
||||
+ (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN));
|
||||
relocator = relocator_new;
|
||||
}
|
||||
|
||||
if ((grub_addr_t) dest >= (grub_addr_t) relocator)
|
||||
{
|
||||
int overhead;
|
||||
overhead = dest -
|
||||
ALIGN_UP (dest - RELOCATOR_SIZEOF (backward) - RELOCATOR_ALIGN,
|
||||
RELOCATOR_ALIGN);
|
||||
grub_dprintf ("relocator",
|
||||
"Backward relocator: code %p, source: %p, "
|
||||
"destination: 0x%x, size: 0x%lx\n",
|
||||
(char *) relocator - overhead,
|
||||
(char *) relocator - overhead,
|
||||
(unsigned) dest - overhead,
|
||||
(unsigned long) size + overhead);
|
||||
|
||||
write_call_relocator_bw ((char *) relocator - overhead,
|
||||
(char *) relocator - overhead,
|
||||
dest - overhead, size + overhead, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
int overhead;
|
||||
|
||||
overhead = ALIGN_UP (dest + size, RELOCATOR_ALIGN)
|
||||
+ RELOCATOR_SIZEOF (forward) - (dest + size);
|
||||
grub_dprintf ("relocator",
|
||||
"Forward relocator: code %p, source: %p, "
|
||||
"destination: 0x%x, size: 0x%lx\n",
|
||||
(char *) relocator + size + overhead
|
||||
- RELOCATOR_SIZEOF (forward),
|
||||
relocator, (unsigned) dest,
|
||||
(unsigned long) size + overhead);
|
||||
|
||||
write_call_relocator_fw ((char *) relocator + size + overhead
|
||||
- RELOCATOR_SIZEOF (forward),
|
||||
relocator, dest, size + overhead, state);
|
||||
}
|
||||
|
||||
/* Not reached. */
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
|
@ -469,21 +469,22 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|||
{
|
||||
int found = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid);
|
||||
|
||||
int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
|
||||
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
if (grub_pci_read (addr) >> 24 == 0x3)
|
||||
{
|
||||
int i;
|
||||
|
||||
grub_printf ("Display controller: %d:%d.%d\nDevice id: %x\n",
|
||||
bus, dev, func, pciid);
|
||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
||||
grub_pci_get_function (dev), pciid);
|
||||
addr += 8;
|
||||
for (i = 0; i < 6; i++, addr += 4)
|
||||
{
|
||||
|
|
|
@ -71,21 +71,22 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|||
{
|
||||
int found = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid);
|
||||
|
||||
int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
|
||||
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
if (grub_pci_read (addr) >> 24 == 0x3)
|
||||
{
|
||||
int i;
|
||||
|
||||
grub_printf ("Display controller: %d:%d.%d\nDevice id: %x\n",
|
||||
bus, dev, func, pciid);
|
||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
||||
grub_pci_get_function (dev), pciid);
|
||||
addr += 8;
|
||||
for (i = 0; i < 6; i++, addr += 4)
|
||||
{
|
||||
|
|
|
@ -48,18 +48,36 @@
|
|||
#include <grub/device.h>
|
||||
#include <grub/partition.h>
|
||||
#endif
|
||||
#include <grub/i386/relocator.h>
|
||||
|
||||
extern grub_dl_t my_mod;
|
||||
static struct multiboot_info *mbi, *mbi_dest;
|
||||
static grub_addr_t entry;
|
||||
|
||||
static char *playground = 0;
|
||||
static grub_size_t code_size;
|
||||
|
||||
char *grub_multiboot_payload_orig;
|
||||
grub_addr_t grub_multiboot_payload_dest;
|
||||
grub_size_t grub_multiboot_payload_size;
|
||||
grub_uint32_t grub_multiboot_payload_eip;
|
||||
|
||||
static grub_err_t
|
||||
grub_multiboot_boot (void)
|
||||
{
|
||||
grub_multiboot_real_boot (entry, mbi_dest);
|
||||
struct grub_relocator32_state state =
|
||||
{
|
||||
.eax = MULTIBOOT_MAGIC2,
|
||||
.ebx = PTR_TO_UINT32 (mbi_dest),
|
||||
.ecx = 0,
|
||||
.edx = 0,
|
||||
.eip = grub_multiboot_payload_eip,
|
||||
/* Set esp to some random location in low memory to avoid breaking
|
||||
non-compliant kernels. */
|
||||
.esp = 0x7ff00
|
||||
};
|
||||
|
||||
grub_relocator32_boot (grub_multiboot_payload_orig,
|
||||
grub_multiboot_payload_dest,
|
||||
state);
|
||||
|
||||
/* Not reached. */
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -68,7 +86,7 @@ grub_multiboot_boot (void)
|
|||
static grub_err_t
|
||||
grub_multiboot_unload (void)
|
||||
{
|
||||
if (playground)
|
||||
if (mbi)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < mbi->mods_count; i++)
|
||||
|
@ -79,11 +97,11 @@ grub_multiboot_unload (void)
|
|||
((struct multiboot_mod_list *) mbi->mods_addr)[i].cmdline);
|
||||
}
|
||||
grub_free ((void *) mbi->mods_addr);
|
||||
grub_free (playground);
|
||||
}
|
||||
grub_relocator32_free (grub_multiboot_payload_orig);
|
||||
|
||||
mbi = NULL;
|
||||
playground = NULL;
|
||||
grub_multiboot_payload_orig = NULL;
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -250,11 +268,8 @@ grub_multiboot (int argc, char *argv[])
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (playground)
|
||||
{
|
||||
grub_free (playground);
|
||||
playground = NULL;
|
||||
}
|
||||
grub_relocator32_free (grub_multiboot_payload_orig);
|
||||
grub_multiboot_payload_orig = NULL;
|
||||
|
||||
mmap_length = grub_get_multiboot_mmap_len ();
|
||||
|
||||
|
@ -296,11 +311,12 @@ grub_multiboot (int argc, char *argv[])
|
|||
grub_multiboot_payload_dest = header->load_addr;
|
||||
|
||||
grub_multiboot_payload_size += code_size;
|
||||
playground = grub_malloc (RELOCATOR_SIZEOF(forward) + grub_multiboot_payload_size + RELOCATOR_SIZEOF(backward));
|
||||
if (! playground)
|
||||
goto fail;
|
||||
|
||||
grub_multiboot_payload_orig = (long) playground + RELOCATOR_SIZEOF(forward);
|
||||
grub_multiboot_payload_orig
|
||||
= grub_relocator32_alloc (grub_multiboot_payload_size);
|
||||
|
||||
if (! grub_multiboot_payload_orig)
|
||||
goto fail;
|
||||
|
||||
if ((grub_file_seek (file, offset)) == (grub_off_t) -1)
|
||||
goto fail;
|
||||
|
@ -313,7 +329,7 @@ grub_multiboot (int argc, char *argv[])
|
|||
grub_memset ((void *) (grub_multiboot_payload_orig + load_size), 0,
|
||||
header->bss_end_addr - header->load_addr - load_size);
|
||||
|
||||
grub_multiboot_payload_entry_offset = header->entry_addr - header->load_addr;
|
||||
grub_multiboot_payload_eip = header->entry_addr;
|
||||
|
||||
}
|
||||
else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE)
|
||||
|
@ -334,23 +350,6 @@ grub_multiboot (int argc, char *argv[])
|
|||
mbi->mmap_addr = (grub_uint32_t) mmap_addr (grub_multiboot_payload_dest);
|
||||
mbi->flags |= MULTIBOOT_INFO_MEM_MAP;
|
||||
|
||||
if (grub_multiboot_payload_dest >= grub_multiboot_payload_orig)
|
||||
{
|
||||
grub_memmove (playground, &grub_multiboot_forward_relocator, RELOCATOR_SIZEOF(forward));
|
||||
entry = (grub_addr_t) playground;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_memmove ((char *) (grub_multiboot_payload_orig + grub_multiboot_payload_size),
|
||||
&grub_multiboot_backward_relocator, RELOCATOR_SIZEOF(backward));
|
||||
entry = (grub_addr_t) grub_multiboot_payload_orig + grub_multiboot_payload_size;
|
||||
}
|
||||
|
||||
grub_dprintf ("multiboot_loader", "dest=%p, size=0x%x, entry_offset=0x%x\n",
|
||||
(void *) grub_multiboot_payload_dest,
|
||||
grub_multiboot_payload_size,
|
||||
grub_multiboot_payload_entry_offset);
|
||||
|
||||
/* Convert from bytes to kilobytes. */
|
||||
mbi->mem_lower = grub_mmap_get_lower () / 1024;
|
||||
mbi->mem_upper = grub_mmap_get_upper () / 1024;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#error "I'm confused"
|
||||
#endif
|
||||
|
||||
#include <grub/i386/relocator.h>
|
||||
|
||||
#define CONCAT(a,b) CONCAT_(a, b)
|
||||
#define CONCAT_(a,b) a ## b
|
||||
|
||||
|
@ -99,11 +101,12 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
grub_multiboot_payload_dest = phdr(lowest_segment)->p_paddr;
|
||||
|
||||
grub_multiboot_payload_size += code_size;
|
||||
playground = grub_malloc (RELOCATOR_SIZEOF(forward) + grub_multiboot_payload_size + RELOCATOR_SIZEOF(backward));
|
||||
if (! playground)
|
||||
return grub_errno;
|
||||
|
||||
grub_multiboot_payload_orig = (long) playground + RELOCATOR_SIZEOF(forward);
|
||||
grub_multiboot_payload_orig
|
||||
= grub_relocator32_alloc (grub_multiboot_payload_size);
|
||||
|
||||
if (!grub_multiboot_payload_orig)
|
||||
return grub_errno;
|
||||
|
||||
/* Load every loadable segment in memory. */
|
||||
for (i = 0; i < ehdr->e_phnum; i++)
|
||||
|
@ -135,8 +138,8 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
if (phdr(i)->p_vaddr <= ehdr->e_entry
|
||||
&& phdr(i)->p_vaddr + phdr(i)->p_memsz > ehdr->e_entry)
|
||||
{
|
||||
grub_multiboot_payload_entry_offset = (ehdr->e_entry - phdr(i)->p_vaddr)
|
||||
+ (phdr(i)->p_paddr - phdr(lowest_segment)->p_paddr);
|
||||
grub_multiboot_payload_eip = grub_multiboot_payload_dest
|
||||
+ (ehdr->e_entry - phdr(i)->p_vaddr) + (phdr(i)->p_paddr - phdr(lowest_segment)->p_paddr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,81 +22,6 @@
|
|||
|
||||
.p2align 2 /* force 4-byte alignment */
|
||||
|
||||
/*
|
||||
* This starts the multiboot kernel.
|
||||
*/
|
||||
|
||||
VARIABLE(grub_multiboot_payload_size)
|
||||
.long 0
|
||||
VARIABLE(grub_multiboot_payload_orig)
|
||||
.long 0
|
||||
VARIABLE(grub_multiboot_payload_dest)
|
||||
.long 0
|
||||
VARIABLE(grub_multiboot_payload_entry_offset)
|
||||
.long 0
|
||||
|
||||
/*
|
||||
* The relocators below understand the following parameters:
|
||||
* ecx: Size of the block to be copied.
|
||||
* esi: Where to copy from (always lowest address, even if we're relocating
|
||||
* backwards).
|
||||
* edi: Where to copy to (likewise).
|
||||
* edx: Offset of the entry point (relative to the beginning of the block).
|
||||
*/
|
||||
|
||||
VARIABLE(grub_multiboot_forward_relocator)
|
||||
/* Add entry offset. */
|
||||
addl %edi, %edx
|
||||
|
||||
/* Forward copy. */
|
||||
cld
|
||||
rep
|
||||
movsb
|
||||
|
||||
jmp *%edx
|
||||
VARIABLE(grub_multiboot_forward_relocator_end)
|
||||
|
||||
VARIABLE(grub_multiboot_backward_relocator)
|
||||
/* Add entry offset (before %edi is mangled). */
|
||||
addl %edi, %edx
|
||||
|
||||
/* Backward movsb is implicitly off-by-one. compensate that. */
|
||||
decl %esi
|
||||
decl %edi
|
||||
|
||||
/* Backward copy. */
|
||||
std
|
||||
addl %ecx, %esi
|
||||
addl %ecx, %edi
|
||||
rep
|
||||
movsb
|
||||
|
||||
cld
|
||||
jmp *%edx
|
||||
VARIABLE(grub_multiboot_backward_relocator_end)
|
||||
|
||||
FUNCTION(grub_multiboot_real_boot)
|
||||
/* Push the entry address on the stack. */
|
||||
pushl %eax
|
||||
/* Move the address of the multiboot information structure to ebx. */
|
||||
movl %edx,%ebx
|
||||
|
||||
/* Interrupts should be disabled. */
|
||||
cli
|
||||
|
||||
/* Where do we copy what from. */
|
||||
movl EXT_C(grub_multiboot_payload_size), %ecx
|
||||
movl EXT_C(grub_multiboot_payload_orig), %esi
|
||||
movl EXT_C(grub_multiboot_payload_dest), %edi
|
||||
movl EXT_C(grub_multiboot_payload_entry_offset), %edx
|
||||
|
||||
/* Move the magic value into eax. */
|
||||
movl $MULTIBOOT_MAGIC2, %eax
|
||||
|
||||
/* Jump to the relocator. */
|
||||
popl %ebp
|
||||
jmp *%ebp
|
||||
|
||||
/*
|
||||
* This starts the multiboot 2 kernel.
|
||||
*/
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <grub/term.h>
|
||||
|
||||
char grub_xnu_cmdline[1024];
|
||||
grub_uint32_t grub_xnu_heap_will_be_at;
|
||||
grub_uint32_t grub_xnu_entry_point, grub_xnu_arg1, grub_xnu_stack;
|
||||
|
||||
/* Aliases set for some tables. */
|
||||
struct tbl_alias
|
||||
|
@ -44,21 +46,6 @@ struct tbl_alias table_aliases[] =
|
|||
{GRUB_EFI_ACPI_TABLE_GUID, "ACPI"},
|
||||
};
|
||||
|
||||
/* The following function is used to be able to debug xnu loader
|
||||
with grub-emu. */
|
||||
#ifdef GRUB_UTIL
|
||||
static grub_err_t
|
||||
grub_xnu_launch (void)
|
||||
{
|
||||
grub_printf ("Fake launch %x:%p:%p", grub_xnu_entry_point, grub_xnu_arg1,
|
||||
grub_xnu_stack);
|
||||
grub_getkey ();
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static void (*grub_xnu_launch) (void) = 0;
|
||||
#endif
|
||||
|
||||
static int
|
||||
utf16_strlen (grub_uint16_t *in)
|
||||
{
|
||||
|
@ -417,6 +404,19 @@ grub_cpu_xnu_fill_devicetree (void)
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_xnu_boot_resume (void)
|
||||
{
|
||||
struct grub_relocator32_state state;
|
||||
|
||||
state.esp = grub_xnu_stack;
|
||||
state.eip = grub_xnu_entry_point;
|
||||
state.eax = grub_xnu_arg1;
|
||||
|
||||
return grub_relocator32_boot (grub_xnu_heap_start, grub_xnu_heap_will_be_at,
|
||||
state);
|
||||
}
|
||||
|
||||
/* Boot xnu. */
|
||||
grub_err_t
|
||||
grub_xnu_boot (void)
|
||||
|
@ -434,6 +434,7 @@ grub_xnu_boot (void)
|
|||
void *devtree;
|
||||
grub_size_t devtreelen;
|
||||
int i;
|
||||
struct grub_relocator32_state state;
|
||||
|
||||
/* Page-align to avoid following parts to be inadvertently freed. */
|
||||
err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
|
||||
|
@ -501,7 +502,8 @@ grub_xnu_boot (void)
|
|||
grub_memcpy (bootparams_relloc->cmdline, grub_xnu_cmdline,
|
||||
sizeof (bootparams_relloc->cmdline));
|
||||
|
||||
bootparams_relloc->devtree = ((char *) devtree - grub_xnu_heap_start)
|
||||
bootparams_relloc->devtree
|
||||
= ((grub_uint8_t *) devtree - (grub_uint8_t *) grub_xnu_heap_start)
|
||||
+ grub_xnu_heap_will_be_at;
|
||||
bootparams_relloc->devtreelen = devtreelen;
|
||||
|
||||
|
@ -529,12 +531,7 @@ grub_xnu_boot (void)
|
|||
grub_xnu_stack = bootparams_relloc->heap_start
|
||||
+ bootparams_relloc->heap_size + GRUB_XNU_PAGESIZE;
|
||||
grub_xnu_arg1 = bootparams_relloc_off + grub_xnu_heap_will_be_at;
|
||||
#ifndef GRUB_UTIL
|
||||
grub_xnu_launch = (void (*) (void))
|
||||
(grub_xnu_heap_start + grub_xnu_heap_size);
|
||||
#endif
|
||||
grub_dprintf ("xnu", "eip=%x\n", grub_xnu_entry_point);
|
||||
grub_dprintf ("xnu", "launch=%p\n", grub_xnu_launch);
|
||||
|
||||
const char *debug = grub_env_get ("debug");
|
||||
|
||||
|
@ -560,16 +557,12 @@ grub_xnu_boot (void)
|
|||
bootparams_relloc->lfb_base = 0;
|
||||
}
|
||||
|
||||
grub_memcpy (grub_xnu_heap_start + grub_xnu_heap_size,
|
||||
grub_xnu_launcher_start,
|
||||
grub_xnu_launcher_end - grub_xnu_launcher_start);
|
||||
|
||||
|
||||
if (! grub_autoefi_finish_boot_services ())
|
||||
return grub_error (GRUB_ERR_IO, "can't exit boot services");
|
||||
|
||||
grub_xnu_launch ();
|
||||
|
||||
/* Never reaches here. */
|
||||
return 0;
|
||||
state.eip = grub_xnu_entry_point;
|
||||
state.eax = grub_xnu_arg1;
|
||||
state.esp = grub_xnu_stack;
|
||||
return grub_relocator32_boot (grub_xnu_heap_start, grub_xnu_heap_will_be_at,
|
||||
state);
|
||||
}
|
||||
|
|
|
@ -1,211 +0,0 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
VARIABLE(grub_xnu_launcher_start)
|
||||
base:
|
||||
cli
|
||||
|
||||
#ifndef __x86_64__
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_will_be_at)
|
||||
.long 0
|
||||
mov %eax, %edi
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_start)
|
||||
.long 0
|
||||
mov %eax, %esi
|
||||
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
VARIABLE(grub_xnu_heap_size)
|
||||
.long 0
|
||||
mov %edi, %eax
|
||||
add %ecx, %eax
|
||||
/* %rax now contains our starting position after relocation. */
|
||||
/* One more page to copy: ourselves. */
|
||||
add $0x403, %ecx
|
||||
shr $2, %ecx
|
||||
|
||||
/* Forward copy. */
|
||||
cld
|
||||
rep
|
||||
movsl
|
||||
|
||||
mov %eax, %esi
|
||||
add $(cont0-base), %eax
|
||||
jmp *%eax
|
||||
cont0:
|
||||
#else
|
||||
xorq %rax, %rax
|
||||
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_will_be_at)
|
||||
.long 0
|
||||
mov %rax, %rdi
|
||||
|
||||
/* mov imm32, %rax */
|
||||
.byte 0x48
|
||||
.byte 0xb8
|
||||
VARIABLE(grub_xnu_heap_start)
|
||||
.long 0
|
||||
.long 0
|
||||
mov %rax, %rsi
|
||||
|
||||
/* mov imm32, %rcx */
|
||||
.byte 0x48
|
||||
.byte 0xb9
|
||||
VARIABLE(grub_xnu_heap_size)
|
||||
.long 0
|
||||
.long 0
|
||||
mov %rdi, %rax
|
||||
add %rcx, %rax
|
||||
/* %rax now contains our starting position after relocation. */
|
||||
/* One more page to copy: ourselves. */
|
||||
add $0x403, %rcx
|
||||
shr $2, %rcx
|
||||
|
||||
/* Forward copy. */
|
||||
cld
|
||||
rep
|
||||
movsl
|
||||
|
||||
mov %rax, %rsi
|
||||
#ifdef APPLE_CC
|
||||
add $(cont0-base), %eax
|
||||
#else
|
||||
add $(cont0-base), %rax
|
||||
#endif
|
||||
jmp *%rax
|
||||
|
||||
cont0:
|
||||
#ifdef APPLE_CC
|
||||
lea (cont1 - base) (%esi, 1), %eax
|
||||
mov %eax, (jump_vector - base) (%esi, 1)
|
||||
|
||||
lea (gdt - base) (%esi, 1), %eax
|
||||
mov %eax, (gdt_addr - base) (%esi, 1)
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lgdt (gdtdesc - base) (%esi, 1)
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%esi,1)
|
||||
#else
|
||||
lea (cont1 - base) (%rsi, 1), %rax
|
||||
mov %eax, (jump_vector - base) (%rsi, 1)
|
||||
|
||||
lea (gdt - base) (%rsi, 1), %rax
|
||||
mov %rax, (gdt_addr - base) (%rsi, 1)
|
||||
|
||||
/* Switch to compatibility mode. */
|
||||
|
||||
lgdt (gdtdesc - base) (%rsi, 1)
|
||||
|
||||
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
|
||||
ljmp *(jump_vector - base) (%rsi, 1)
|
||||
#endif
|
||||
|
||||
cont1:
|
||||
.code32
|
||||
|
||||
/* Update other registers. */
|
||||
mov $0x18, %eax
|
||||
mov %eax, %ds
|
||||
mov %eax, %es
|
||||
mov %eax, %fs
|
||||
mov %eax, %gs
|
||||
mov %eax, %ss
|
||||
|
||||
/* Disable paging. */
|
||||
mov %cr0, %eax
|
||||
and $0x7fffffff, %eax
|
||||
mov %eax, %cr0
|
||||
|
||||
/* Disable amd64. */
|
||||
mov $0xc0000080, %ecx
|
||||
rdmsr
|
||||
and $0xfffffeff, %eax
|
||||
wrmsr
|
||||
|
||||
/* Turn off PAE. */
|
||||
movl %cr4, %eax
|
||||
and $0xffffffcf, %eax
|
||||
mov %eax, %cr4
|
||||
|
||||
jmp cont2
|
||||
cont2:
|
||||
#endif
|
||||
.code32
|
||||
|
||||
/* Registers on XNU boot: eip, esp and eax. */
|
||||
/* mov imm32, %ecx */
|
||||
.byte 0xb9
|
||||
VARIABLE (grub_xnu_entry_point)
|
||||
.long 0
|
||||
/* mov imm32, %eax */
|
||||
.byte 0xb8
|
||||
VARIABLE (grub_xnu_arg1)
|
||||
.long 0
|
||||
/* mov imm32, %ebx */
|
||||
.byte 0xbb
|
||||
VARIABLE (grub_xnu_stack)
|
||||
.long 0
|
||||
|
||||
movl %ebx, %esp
|
||||
|
||||
jmp *%ecx
|
||||
|
||||
#ifdef __x86_64__
|
||||
/* GDT. Copied from loader/i386/linux.c. */
|
||||
.p2align 4
|
||||
gdt:
|
||||
/* NULL. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
/* Reserved. */
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
/* Code segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
|
||||
|
||||
/* Data segment. */
|
||||
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
|
||||
|
||||
gdtdesc:
|
||||
.word 31
|
||||
gdt_addr:
|
||||
/* Filled by the code. */
|
||||
.quad 0
|
||||
|
||||
.p2align 4
|
||||
jump_vector:
|
||||
/* Jump location. Is filled by the code */
|
||||
.long 0
|
||||
.long 0x10
|
||||
#endif
|
||||
VARIABLE(grub_xnu_launcher_end)
|
39
loader/xnu.c
39
loader/xnu.c
|
@ -36,6 +36,9 @@ struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0;
|
|||
static int driverspackagenum = 0;
|
||||
static int driversnum = 0;
|
||||
|
||||
void *grub_xnu_heap_start = 0;
|
||||
grub_size_t grub_xnu_heap_size = 0;
|
||||
|
||||
/* Allocate heap by 32MB-blocks. */
|
||||
#define GRUB_XNU_HEAP_ALLOC_BLOCK 0x2000000
|
||||
|
||||
|
@ -46,12 +49,6 @@ void *
|
|||
grub_xnu_heap_malloc (int size)
|
||||
{
|
||||
void *val;
|
||||
|
||||
#if 0
|
||||
/* This way booting is faster but less reliable.
|
||||
Once we have advanced mm second way will be as fast as this one. */
|
||||
val = grub_xnu_heap_start = (char *) 0x100000;
|
||||
#else
|
||||
int oldblknum, newblknum;
|
||||
|
||||
/* The page after the heap is used for stack. Ensure it's usable. */
|
||||
|
@ -63,25 +60,21 @@ grub_xnu_heap_malloc (int size)
|
|||
newblknum = (grub_xnu_heap_size + size + GRUB_XNU_PAGESIZE
|
||||
+ GRUB_XNU_HEAP_ALLOC_BLOCK - 1) / GRUB_XNU_HEAP_ALLOC_BLOCK;
|
||||
if (oldblknum != newblknum)
|
||||
{
|
||||
/* FIXME: instruct realloc to allocate at 1MB if possible once
|
||||
advanced mm is ready. */
|
||||
val = grub_realloc (grub_xnu_heap_start,
|
||||
newblknum * GRUB_XNU_HEAP_ALLOC_BLOCK);
|
||||
else
|
||||
val = grub_xnu_heap_start;
|
||||
if (! val)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"not enough space on xnu memory heap");
|
||||
return 0;
|
||||
grub_xnu_heap_start
|
||||
= XNU_RELOCATOR (realloc) (grub_xnu_heap_start,
|
||||
newblknum
|
||||
* GRUB_XNU_HEAP_ALLOC_BLOCK);
|
||||
if (!grub_xnu_heap_start)
|
||||
return NULL;
|
||||
}
|
||||
grub_xnu_heap_start = val;
|
||||
#endif
|
||||
|
||||
val = (char *) grub_xnu_heap_start + grub_xnu_heap_size;
|
||||
val = (grub_uint8_t *) grub_xnu_heap_start + grub_xnu_heap_size;
|
||||
grub_xnu_heap_size += size;
|
||||
grub_dprintf ("xnu", "val=%p\n", val);
|
||||
return (char *) val;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Make sure next block of the heap will be aligned.
|
||||
|
@ -251,7 +244,7 @@ grub_xnu_writetree_toheap (void **start, grub_size_t *size)
|
|||
- *size % GRUB_XNU_PAGESIZE);
|
||||
|
||||
/* Put real data in the dummy. */
|
||||
extdesc->addr = (char *) *start - grub_xnu_heap_start
|
||||
extdesc->addr = (grub_uint8_t *) *start - (grub_uint8_t *) grub_xnu_heap_start
|
||||
+ grub_xnu_heap_will_be_at;
|
||||
extdesc->size = (grub_uint32_t) *size;
|
||||
|
||||
|
@ -503,7 +496,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
grub_file_t infoplist;
|
||||
struct grub_xnu_extheader *exthead;
|
||||
int neededspace = sizeof (*exthead);
|
||||
char *buf;
|
||||
grub_uint8_t *buf;
|
||||
grub_size_t infoplistsize = 0, machosize = 0;
|
||||
|
||||
if (! grub_xnu_heap_size)
|
||||
|
@ -552,7 +545,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
/* Load the binary. */
|
||||
if (macho)
|
||||
{
|
||||
exthead->binaryaddr = (buf - grub_xnu_heap_start)
|
||||
exthead->binaryaddr = (buf - (grub_uint8_t *) grub_xnu_heap_start)
|
||||
+ grub_xnu_heap_will_be_at;
|
||||
exthead->binarysize = machosize;
|
||||
if ((err = grub_macho32_readfile (macho, buf)))
|
||||
|
@ -568,7 +561,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
|
|||
/* Load the plist. */
|
||||
if (infoplist)
|
||||
{
|
||||
exthead->infoplistaddr = (buf - grub_xnu_heap_start)
|
||||
exthead->infoplistaddr = (buf - (grub_uint8_t *) grub_xnu_heap_start)
|
||||
+ grub_xnu_heap_will_be_at;
|
||||
exthead->infoplistsize = infoplistsize + 1;
|
||||
if (grub_file_read (infoplist, buf, infoplistsize)
|
||||
|
|
|
@ -45,7 +45,7 @@ grub_xnu_resume (char *imagename)
|
|||
grub_file_t file;
|
||||
grub_size_t total_header_size;
|
||||
struct grub_xnu_hibernate_header hibhead;
|
||||
char *buf, *codetmp;
|
||||
grub_uint8_t *buf;
|
||||
|
||||
grub_uint32_t codedest;
|
||||
grub_uint32_t codesize;
|
||||
|
@ -94,17 +94,28 @@ grub_xnu_resume (char *imagename)
|
|||
/* Try to allocate necessary space.
|
||||
FIXME: mm isn't good enough yet to handle huge allocations.
|
||||
*/
|
||||
grub_xnu_hibernate_image = buf = grub_malloc (hibhead.image_size);
|
||||
grub_xnu_hibernate_image = buf = XNU_RELOCATOR (alloc) (hibhead.image_size
|
||||
+ codesize
|
||||
+ GRUB_XNU_PAGESIZE);
|
||||
if (! buf)
|
||||
{
|
||||
grub_file_close (file);
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"not enough memory to load image");
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Read code part. */
|
||||
if (grub_file_seek (file, total_header_size) == (grub_off_t) -1
|
||||
|| grub_file_read (file, buf, codesize)
|
||||
!= (grub_ssize_t) codesize)
|
||||
{
|
||||
grub_file_close (file);
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Cannot read resume image.");
|
||||
}
|
||||
|
||||
/* Read image. */
|
||||
if (grub_file_seek (file, 0) == (grub_off_t) -1
|
||||
|| grub_file_read (file, buf, hibhead.image_size)
|
||||
|| grub_file_read (file, buf + codesize + GRUB_XNU_PAGESIZE,
|
||||
hibhead.image_size)
|
||||
!= (grub_ssize_t) hibhead.image_size)
|
||||
{
|
||||
grub_file_close (file);
|
||||
|
@ -112,22 +123,20 @@ grub_xnu_resume (char *imagename)
|
|||
}
|
||||
grub_file_close (file);
|
||||
|
||||
codetmp = grub_memalign (GRUB_XNU_PAGESIZE, codesize + GRUB_XNU_PAGESIZE);
|
||||
/* Setup variables needed by asm helper. */
|
||||
grub_xnu_heap_will_be_at = codedest;
|
||||
grub_xnu_heap_start = codetmp;
|
||||
grub_xnu_heap_size = codesize;
|
||||
grub_xnu_heap_start = buf;
|
||||
grub_xnu_heap_size = codesize + GRUB_XNU_PAGESIZE + hibhead.image_size;
|
||||
grub_xnu_stack = (codedest + hibhead.stack);
|
||||
grub_xnu_entry_point = (codedest + hibhead.entry_point);
|
||||
grub_xnu_arg1 = (long) buf;
|
||||
grub_xnu_arg1 = codedest + codesize + GRUB_XNU_PAGESIZE;
|
||||
|
||||
/* Prepare asm helper. */
|
||||
grub_memcpy (codetmp, ((grub_uint8_t *) buf) + total_header_size, codesize);
|
||||
grub_memcpy (codetmp + codesize, grub_xnu_launcher_start,
|
||||
grub_xnu_launcher_end - grub_xnu_launcher_start);
|
||||
grub_dprintf ("xnu", "entry point 0x%x\n", codedest + hibhead.entry_point);
|
||||
grub_dprintf ("xnu", "image at 0x%x\n",
|
||||
codedest + codesize + GRUB_XNU_PAGESIZE);
|
||||
|
||||
/* We're ready now. */
|
||||
grub_loader_set ((grub_err_t (*) (void)) (codetmp + codesize),
|
||||
grub_loader_set (grub_xnu_boot_resume,
|
||||
grub_xnu_resume_unload, 0);
|
||||
|
||||
/* Prevent module from unloading. */
|
||||
|
|
|
@ -509,7 +509,7 @@ grub_normal_reader_init (void)
|
|||
grub_normal_init_page ();
|
||||
grub_setcursor (1);
|
||||
|
||||
grub_printf (_("\
|
||||
grub_printf_ (N_("\
|
||||
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
|
||||
lists possible command completions. Anywhere else TAB lists possible\n\
|
||||
device/file completions.%s ]\n\n"),
|
||||
|
|
|
@ -836,7 +836,9 @@ store_completion (const char *item, grub_completion_type_t type, int count)
|
|||
}
|
||||
|
||||
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf (" Possible %s are:\n ", what);
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Possible %s are:"), what);
|
||||
grub_printf ("\n ");
|
||||
}
|
||||
|
||||
/* Make sure that the completion buffer has enough room. */
|
||||
|
@ -997,7 +999,9 @@ run (struct screen *screen)
|
|||
}
|
||||
|
||||
grub_cls ();
|
||||
grub_printf (_(" Booting a command list\n\n"));
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Booting a command list"));
|
||||
grub_printf ("\n\n");
|
||||
|
||||
|
||||
/* Execute the script, line for line. */
|
||||
|
@ -1177,6 +1181,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
|
|||
grub_cls ();
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_printf (_("\nPress any key to continue..."));
|
||||
grub_putchar ('\n');
|
||||
grub_printf_ (N_("Press any key to continue..."));
|
||||
(void) grub_getkey ();
|
||||
}
|
||||
|
|
|
@ -39,11 +39,105 @@ static grub_uint8_t grub_color_menu_highlight;
|
|||
void
|
||||
grub_wait_after_message (void)
|
||||
{
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
grub_putchar ('\n');
|
||||
grub_printf_ (N_("Press any key to continue..."));
|
||||
(void) grub_getkey ();
|
||||
grub_putchar ('\n');
|
||||
}
|
||||
|
||||
static void
|
||||
print_spaces (int number_spaces)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < number_spaces; i++)
|
||||
grub_putchar (' ');
|
||||
}
|
||||
|
||||
static void
|
||||
grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position)
|
||||
{
|
||||
while (str < last_position)
|
||||
{
|
||||
grub_putcode (*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position)
|
||||
{
|
||||
grub_ssize_t width = 0;
|
||||
|
||||
while (str < last_position)
|
||||
{
|
||||
width += grub_getcharwidth (*str);
|
||||
str++;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
static void
|
||||
print_message_indented (const char *msg)
|
||||
{
|
||||
const int line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') * 15;
|
||||
|
||||
grub_uint32_t *unicode_msg;
|
||||
|
||||
grub_ssize_t msg_len = grub_strlen (msg);
|
||||
|
||||
unicode_msg = grub_malloc (msg_len * sizeof (*unicode_msg));
|
||||
|
||||
msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len,
|
||||
(grub_uint8_t *) msg, -1, 0);
|
||||
|
||||
if (!unicode_msg)
|
||||
{
|
||||
grub_printf ("print_message_indented ERROR1: %s", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg_len < 0)
|
||||
{
|
||||
grub_printf ("print_message_indented ERROR2: %s", msg);
|
||||
grub_free (unicode_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const grub_uint32_t *last_position = unicode_msg + msg_len;
|
||||
|
||||
grub_uint32_t *current_position = unicode_msg;
|
||||
|
||||
grub_uint32_t *next_new_line = unicode_msg;
|
||||
|
||||
while (current_position < last_position)
|
||||
{
|
||||
next_new_line = (grub_uint32_t *) last_position;
|
||||
|
||||
while (getstringwidth (current_position, next_new_line) > line_len
|
||||
|| (*next_new_line != ' ' && next_new_line > current_position &&
|
||||
next_new_line != last_position))
|
||||
{
|
||||
next_new_line--;
|
||||
}
|
||||
|
||||
if (next_new_line == current_position)
|
||||
{
|
||||
next_new_line = (next_new_line + line_len > last_position) ?
|
||||
(grub_uint32_t *) last_position : next_new_line + line_len;
|
||||
}
|
||||
|
||||
print_spaces (6);
|
||||
grub_print_ucs4 (current_position, next_new_line);
|
||||
grub_putchar ('\n');
|
||||
|
||||
next_new_line++;
|
||||
current_position = next_new_line;
|
||||
}
|
||||
grub_free (unicode_msg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw_border (void)
|
||||
{
|
||||
|
@ -87,22 +181,33 @@ print_message (int nested, int edit)
|
|||
|
||||
if (edit)
|
||||
{
|
||||
grub_printf ("\n\
|
||||
Minimum Emacs-like screen editing is supported. TAB lists\n\
|
||||
completions. Press Ctrl-x to boot, Ctrl-c for a command-line\n\
|
||||
or ESC to return menu.");
|
||||
grub_putchar ('\n');
|
||||
print_message_indented (_("Minimum Emacs-like screen editing is \
|
||||
supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \
|
||||
command-line or ESC to return menu."));
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf (_("\n\
|
||||
Use the %C and %C keys to select which entry is highlighted.\n"),
|
||||
(grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
|
||||
grub_printf ("\
|
||||
Press enter to boot the selected OS, \'e\' to edit the\n\
|
||||
commands before booting or \'c\' for a command-line.");
|
||||
const char *msg = _("Use the %C and %C keys to select which \
|
||||
entry is highlighted.");
|
||||
char *msg_translated =
|
||||
grub_malloc (sizeof (char) * grub_strlen (msg) + 1);
|
||||
|
||||
grub_sprintf (msg_translated, msg, (grub_uint32_t) GRUB_TERM_DISP_UP,
|
||||
(grub_uint32_t) GRUB_TERM_DISP_DOWN);
|
||||
grub_putchar ('\n');
|
||||
print_message_indented (msg_translated);
|
||||
|
||||
grub_free (msg_translated);
|
||||
|
||||
print_message_indented (_("Press enter to boot the selected OS, \
|
||||
\'e\' to edit the commands before booting or \'c\' for a command-line."));
|
||||
|
||||
if (nested)
|
||||
grub_printf ("\n\
|
||||
ESC to return previous menu.");
|
||||
{
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("ESC to return previous menu."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,13 +370,17 @@ get_entry_number (const char *name)
|
|||
static void
|
||||
print_timeout (int timeout, int offset, int second_stage)
|
||||
{
|
||||
/* NOTE: Do not remove the trailing space characters.
|
||||
They are required to clear the line. */
|
||||
char *msg = " The highlighted entry will be booted automatically in %ds. ";
|
||||
const char *msg =
|
||||
_("The highlighted entry will be booted automatically in %ds.");
|
||||
const int msg_localized_len = grub_strlen (msg);
|
||||
const int number_spaces = GRUB_TERM_WIDTH - msg_localized_len - 3;
|
||||
|
||||
char *msg_end = grub_strchr (msg, '%');
|
||||
|
||||
grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_gotoxy (second_stage ? (msg_end - msg + 3) : 3, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf (second_stage ? msg_end : msg, timeout);
|
||||
print_spaces (second_stage ? number_spaces : 0);
|
||||
|
||||
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
||||
grub_refresh ();
|
||||
};
|
||||
|
@ -360,8 +469,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||
if (timeout >= 0)
|
||||
{
|
||||
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf ("\
|
||||
");
|
||||
print_spaces (GRUB_TERM_WIDTH - 1);
|
||||
|
||||
grub_env_unset ("timeout");
|
||||
grub_env_unset ("fallback");
|
||||
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
||||
|
@ -517,7 +626,9 @@ static void
|
|||
notify_booting (grub_menu_entry_t entry,
|
||||
void *userdata __attribute__((unused)))
|
||||
{
|
||||
grub_printf (" Booting \'%s\'\n\n", entry->title);
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Booting \'%s\'"), entry->title);
|
||||
grub_printf ("\n\n");
|
||||
}
|
||||
|
||||
/* Callback invoked when a default menu entry executed because of a timeout
|
||||
|
@ -527,7 +638,9 @@ static void
|
|||
notify_fallback (grub_menu_entry_t entry,
|
||||
void *userdata __attribute__((unused)))
|
||||
{
|
||||
grub_printf ("\n Falling back to \'%s\'\n\n", entry->title);
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("Falling back to \'%s\'"), entry->title);
|
||||
grub_printf ("\n\n");
|
||||
grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS);
|
||||
}
|
||||
|
||||
|
@ -541,7 +654,8 @@ notify_execution_failure (void *userdata __attribute__((unused)))
|
|||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
grub_printf ("\n Failed to boot default entries.\n");
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("Failed to boot default entries.\n"));
|
||||
grub_wait_after_message ();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,4 +11,5 @@ util/mkisofs/rock.c
|
|||
util/mkisofs/tree.c
|
||||
util/mkisofs/write.c
|
||||
|
||||
normal/menu_entry.c
|
||||
normal/menu_text.c
|
||||
|
|
|
@ -113,13 +113,13 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
|||
|
||||
if (eq)
|
||||
{
|
||||
/* This was set because the command was not found. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
/* Create two strings and set the variable. */
|
||||
*eq = '\0';
|
||||
eq++;
|
||||
grub_env_set (assign, eq);
|
||||
|
||||
/* This was set because the command was not found. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
grub_free (assign);
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
if (q)
|
||||
*q = ',';
|
||||
|
||||
asprintf (&grub_dev, "md%s", p);
|
||||
grub_dev = xasprintf ("md%s", p);
|
||||
free (p);
|
||||
}
|
||||
else if (os_dev[7] == '/' && os_dev[8] == 'd')
|
||||
|
@ -561,7 +561,7 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
if (q)
|
||||
*q = ',';
|
||||
|
||||
asprintf (&grub_dev, "md%s", p);
|
||||
grub_dev = xasprintf ("md%s", p);
|
||||
free (p);
|
||||
}
|
||||
else if (os_dev[7] >= '0' && os_dev[7] <= '9')
|
||||
|
@ -574,7 +574,7 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
if (q)
|
||||
*q = ',';
|
||||
|
||||
asprintf (&grub_dev, "md%s", p);
|
||||
grub_dev = xasprintf ("md%s", p);
|
||||
free (p);
|
||||
}
|
||||
else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9')
|
||||
|
@ -587,7 +587,7 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
if (q)
|
||||
*q = ',';
|
||||
|
||||
asprintf (&grub_dev, "md%s", p);
|
||||
grub_dev = xasprintf ("md%s", p);
|
||||
free (p);
|
||||
}
|
||||
else if (os_dev[7] == '/')
|
||||
|
|
|
@ -107,7 +107,7 @@ create_envblk_file (const char *name)
|
|||
if (! buf)
|
||||
grub_util_error ("out of memory");
|
||||
|
||||
asprintf (&namenew, "%s.new", name);
|
||||
namenew = xasprintf ("%s.new", name);
|
||||
fp = fopen (namenew, "wb");
|
||||
if (! fp)
|
||||
grub_util_error ("cannot open the file %s", namenew);
|
||||
|
|
|
@ -85,7 +85,7 @@ execute_command (char *name, int n, char **args)
|
|||
|
||||
#define BUF_SIZE 32256
|
||||
|
||||
static grub_off_t skip, leng;
|
||||
static grub_disk_addr_t skip, leng;
|
||||
|
||||
static void
|
||||
read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
||||
|
@ -140,7 +140,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
|
||||
if (skip > file->size)
|
||||
{
|
||||
grub_util_error ("invalid skip value %d.");
|
||||
grub_util_error ("invalid skip value %lld.", (unsigned long long) skip);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -247,6 +247,14 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Copy gettext files
|
||||
mkdir -p ${grubdir}/locale/
|
||||
for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" ${grubdir}/locale/
|
||||
fi
|
||||
done
|
||||
|
||||
# Write device to a variable so we don't have to traverse /dev every time.
|
||||
grub_device=`$grub_probe --target=device ${grubdir}`
|
||||
|
||||
|
|
|
@ -144,13 +144,9 @@ case x${GRUB_TERMINAL_OUTPUT} in
|
|||
x | xgfxterm)
|
||||
# If this platform supports gfxterm, try to use it.
|
||||
if test -e ${grub_prefix}/gfxterm.mod ; then
|
||||
GRUB_VIDEO_BACKEND=
|
||||
for i in vbe ; do
|
||||
if test -e ${grub_prefix}/$i.mod ; then
|
||||
GRUB_VIDEO_BACKEND=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
# FIXME: this should do something smarter than just loading first
|
||||
# video backend.
|
||||
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
||||
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then
|
||||
GRUB_TERMINAL_OUTPUT=gfxterm
|
||||
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
|
||||
|
|
|
@ -24,8 +24,12 @@ bindir=@bindir@
|
|||
sbindir=@sbindir@
|
||||
pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
|
||||
|
||||
if test "x$grub_probe" = x; then
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
fi
|
||||
if test "x$grub_mkrelpath" = x; then
|
||||
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
|
||||
fi
|
||||
|
||||
grub_warn ()
|
||||
{
|
||||
|
|
|
@ -366,7 +366,7 @@ write_font (struct grub_font_info *font_info, char *output_file)
|
|||
if (! style_name[0])
|
||||
strcpy (style_name, " Regular");
|
||||
|
||||
asprintf (&font_name, "%s %s %d", font_info->name, &style_name[1],
|
||||
font_name = xasprintf ("%s %s %d", font_info->name, &style_name[1],
|
||||
font_info->size);
|
||||
|
||||
write_string_section ("NAME", font_name, &offset, file);
|
||||
|
|
|
@ -27,6 +27,7 @@ static struct option options[] =
|
|||
{
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
|
@ -100,6 +100,13 @@ process_input_dir ()
|
|||
cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p ${iso9660_dir}/boot/grub/locale
|
||||
for file in ${input_dir}/po/*.mo; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" ${iso9660_dir}/boot/grub/locale/
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${override_dir}" = "" ] ; then
|
||||
|
|
|
@ -123,7 +123,7 @@ probe (const char *path, char *device_name)
|
|||
device_name = grub_guess_root_device (path);
|
||||
|
||||
if (! device_name)
|
||||
grub_util_error ("cannot find a device for %s.\n", path);
|
||||
grub_util_error ("cannot find a device for %s (is /dev mounted?).\n", path);
|
||||
|
||||
if (print == PRINT_DEVICE)
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ probe (const char *path, char *device_name)
|
|||
filebuf_via_sys = grub_util_read_image (path);
|
||||
|
||||
rel_path = make_system_path_relative_to_its_root (path);
|
||||
asprintf (&grub_path, "(%s)%s", drive_name, rel_path);
|
||||
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
||||
free (rel_path);
|
||||
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
||||
file = grub_file_open (grub_path);
|
||||
|
|
|
@ -120,7 +120,7 @@ menuentry "${LONGNAME} (on ${DEVICE})" {
|
|||
EOF
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
insmod vbe
|
||||
insmod ${GRUB_VIDEO_BACKEND}
|
||||
do_resume=0
|
||||
if [ /var/vm/sleepimage -nt10 / ]; then
|
||||
if xnu_resume /var/vm/sleepimage; then
|
||||
|
|
|
@ -679,12 +679,12 @@ make_device_name (int drive, int dos_part, int bsd_part)
|
|||
char *bsd_part_str = NULL;
|
||||
|
||||
if (dos_part >= 0)
|
||||
asprintf (&dos_part_str, ",%d", dos_part + 1);
|
||||
dos_part_str = xasprintf (",%d", dos_part + 1);
|
||||
|
||||
if (bsd_part >= 0)
|
||||
asprintf (&bsd_part_str, ",%c", dos_part + 'a');
|
||||
bsd_part_str = xasprintf (",%c", dos_part + 'a');
|
||||
|
||||
asprintf (&ret, "%s%s%s", map[drive].drive,
|
||||
ret = xasprintf ("%s%s%s", map[drive].drive,
|
||||
dos_part_str ? : "",
|
||||
bsd_part_str ? : "");
|
||||
|
||||
|
|
|
@ -55,12 +55,12 @@ align_pe32_section (Elf_Addr addr)
|
|||
/* Read the whole kernel image. Return the pointer to a read image,
|
||||
and store the size in bytes in *SIZE. */
|
||||
static char *
|
||||
read_kernel_module (const char *dir, size_t *size)
|
||||
read_kernel_image (const char *dir, size_t *size)
|
||||
{
|
||||
char *kernel_image;
|
||||
char *kernel_path;
|
||||
|
||||
kernel_path = grub_util_get_path (dir, "kernel.mod");
|
||||
kernel_path = grub_util_get_path (dir, "kernel.img");
|
||||
*size = grub_util_get_image_size (kernel_path);
|
||||
kernel_image = grub_util_read_image (kernel_path);
|
||||
free (kernel_path);
|
||||
|
@ -945,7 +945,7 @@ convert_elf (const char *dir, char *prefix, FILE *out, char *mods[])
|
|||
int i;
|
||||
|
||||
/* Get the kernel image and check the format. */
|
||||
kernel_image = read_kernel_module (dir, &kernel_size);
|
||||
kernel_image = read_kernel_image (dir, &kernel_size);
|
||||
e = (Elf_Ehdr *) kernel_image;
|
||||
if (! check_elf_header (e, kernel_size))
|
||||
grub_util_error ("invalid ELF header");
|
||||
|
|
45
util/misc.c
45
util/misc.c
|
@ -370,6 +370,19 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
|||
{
|
||||
}
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
|
||||
int
|
||||
vasprintf (char **buf, const char *fmt, va_list ap)
|
||||
{
|
||||
/* Should be large enough. */
|
||||
*buf = xmalloc (512);
|
||||
|
||||
return vsprintf (*buf, fmt, ap);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
|
||||
int
|
||||
|
@ -378,11 +391,8 @@ asprintf (char **buf, const char *fmt, ...)
|
|||
int status;
|
||||
va_list ap;
|
||||
|
||||
/* Should be large enough. */
|
||||
*buf = xmalloc (512);
|
||||
|
||||
va_start (ap, fmt);
|
||||
status = vsprintf (*buf, fmt, ap);
|
||||
status = vasprintf (*buf, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
return status;
|
||||
|
@ -390,6 +400,23 @@ asprintf (char **buf, const char *fmt, ...)
|
|||
|
||||
#endif
|
||||
|
||||
char *
|
||||
xasprintf (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *result;
|
||||
|
||||
va_start (ap, fmt);
|
||||
if (vasprintf (&result, fmt, ap) < 0)
|
||||
{
|
||||
if (errno == ENOMEM)
|
||||
grub_util_error ("out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
void sync (void)
|
||||
|
@ -500,7 +527,17 @@ make_system_path_relative_to_its_root (const char *path)
|
|||
|
||||
/* buf is another filesystem; we found it. */
|
||||
if (st.st_dev != num)
|
||||
{
|
||||
/* offset == 0 means path given is the mount point. */
|
||||
if (offset == 0)
|
||||
{
|
||||
free (buf);
|
||||
free (buf2);
|
||||
return strdup ("/");
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
offset = p - buf;
|
||||
/* offset == 1 means root directory. */
|
||||
|
|
76
util/pci.c
Normal file
76
util/pci.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* pci.c - Generic PCI interfaces. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/pci.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/util/misc.h>
|
||||
|
||||
grub_pci_address_t
|
||||
grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||
{
|
||||
grub_pci_address_t ret;
|
||||
ret.dev = dev;
|
||||
ret.pos = reg << 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||
{
|
||||
struct pci_device_iterator *iter;
|
||||
struct pci_slot_match slot;
|
||||
struct pci_device *dev;
|
||||
slot.domain = PCI_MATCH_ANY;
|
||||
slot.bus = PCI_MATCH_ANY;
|
||||
slot.dev = PCI_MATCH_ANY;
|
||||
slot.func = PCI_MATCH_ANY;
|
||||
iter = pci_slot_match_iterator_create (&slot);
|
||||
while ((dev = pci_device_next (iter)))
|
||||
hook (dev, dev->vendor_id | (dev->device_id << 16));
|
||||
pci_iterator_destroy (iter);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
|
||||
grub_size_t size)
|
||||
{
|
||||
void *addr;
|
||||
int err;
|
||||
err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
|
||||
if (err)
|
||||
grub_util_error ("mapping 0x%x failed (error %d)\n", base, err);
|
||||
return addr;
|
||||
}
|
||||
|
||||
void
|
||||
grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
|
||||
grub_size_t size)
|
||||
{
|
||||
pci_device_unmap_range (dev, mem, size);
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT (pci)
|
||||
{
|
||||
pci_system_init ();
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (pci)
|
||||
{
|
||||
pci_system_cleanup ();
|
||||
}
|
|
@ -31,9 +31,6 @@ target_cpu=@target_cpu@
|
|||
platform=@platform@
|
||||
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
|
||||
|
||||
# for make_system_path_relative_to_its_root()
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
|
||||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
|
@ -120,6 +117,9 @@ for option in "$@"; do
|
|||
esac
|
||||
done
|
||||
|
||||
# for make_system_path_relative_to_its_root()
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
if test "x$install_device" = x; then
|
||||
echo "install_device not specified." 1>&2
|
||||
usage
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/resolve.h>
|
||||
|
@ -34,6 +35,8 @@
|
|||
#define _GNU_SOURCE 1
|
||||
#include <getopt.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
static void
|
||||
compress_kernel (char *kernel_img, size_t kernel_size,
|
||||
char **core_img, size_t *core_size)
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include <grub/util/misc.h>
|
||||
#include <grub/util/ofpath.h>
|
||||
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *of_path;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/fs.h>
|
||||
|
@ -49,6 +50,8 @@
|
|||
#define _GNU_SOURCE 1
|
||||
#include <getopt.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
/* This program fills in various fields inside of the 'boot' and 'core'
|
||||
* image files.
|
||||
*
|
||||
|
@ -419,7 +422,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
|
|||
-v, --verbose print verbose messages\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
", program_name
|
||||
", program_name,
|
||||
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
|
||||
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
|
||||
|
||||
|
|
|
@ -84,21 +84,22 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
|||
{
|
||||
int found = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid);
|
||||
|
||||
int NESTED_FUNC_ATTR find_card (int bus, int dev, int func,
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
|
||||
addr = grub_pci_make_address (bus, dev, func, 2);
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
if (grub_pci_read (addr) >> 24 == 0x3)
|
||||
{
|
||||
int i;
|
||||
|
||||
grub_dprintf ("fb", "Display controller: %d:%d.%d\nDevice id: %x\n",
|
||||
bus, dev, func, pciid);
|
||||
grub_pci_get_bus (dev), grub_pci_get_device (dev),
|
||||
grub_pci_get_function (dev), pciid);
|
||||
addr += 8;
|
||||
for (i = 0; i < 6; i++, addr += 4)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,9 @@ static int vbe_detected = -1;
|
|||
static struct grub_vbe_info_block controller_info;
|
||||
static struct grub_vbe_mode_info_block active_vbe_mode_info;
|
||||
|
||||
/* Track last mode to support cards which fail on get_mode. */
|
||||
static grub_uint32_t last_set_mode = 3;
|
||||
|
||||
static struct
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
@ -160,6 +163,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
|||
status = grub_vbe_bios_set_mode (vbe_mode, 0);
|
||||
if (status != GRUB_VBE_STATUS_OK)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", vbe_mode);
|
||||
last_set_mode = vbe_mode;
|
||||
|
||||
/* Save information for later usage. */
|
||||
framebuffer.active_vbe_mode = vbe_mode;
|
||||
|
@ -203,6 +207,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
|||
case 8: framebuffer.bytes_per_pixel = 1; break;
|
||||
default:
|
||||
grub_vbe_bios_set_mode (old_vbe_mode, 0);
|
||||
last_set_mode = old_vbe_mode;
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot set VBE mode %x",
|
||||
vbe_mode);
|
||||
|
@ -256,8 +261,9 @@ grub_vbe_get_video_mode (grub_uint32_t *mode)
|
|||
|
||||
/* Try to query current mode from VESA BIOS. */
|
||||
status = grub_vbe_bios_get_mode (mode);
|
||||
/* XXX: ATI cards don't support get_mode. */
|
||||
if (status != GRUB_VBE_STATUS_OK)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get current VBE mode");
|
||||
*mode = last_set_mode;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -391,10 +397,6 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
/* If not available, skip it. */
|
||||
continue;
|
||||
|
||||
if ((vbe_mode_info.mode_attributes & 0x002) == 0)
|
||||
/* Not enough information. */
|
||||
continue;
|
||||
|
||||
if ((vbe_mode_info.mode_attributes & 0x008) == 0)
|
||||
/* Monochrome is unusable. */
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue