Compare commits

..

637 Commits

Author SHA1 Message Date
Vladimir Serbinenko
d5edef1a77 Half boot time on pi when using standalone by using greffs 2013-12-22 21:17:54 +01:00
Vladimir Serbinenko
313fb3cef8 Add module loading and parsing boot time checkpoints. 2013-12-22 18:14:42 +01:00
Vladimir Serbinenko
37f617c025 * grub-core/loader/arm/linux.c: Pass arguments through on ATAG
platforms.
2013-12-22 18:14:00 +01:00
Lars Wendler
3deedfc033 * util/grub-mkconfig.in: Skip non-executable files. 2013-12-22 16:38:28 +01:00
Vladimir Serbinenko
5ad9f728eb Workaround buggy timer in raspberry pie by using our own timer
implementation.
2013-12-22 02:48:42 +01:00
Vladimir Serbinenko
eeb8499721 * include/grub/arm/uboot/kernel.h (GRUB_KERNEL_MACHINE_HEAP_SIZE):
Increase to 16 MiB to allow loading the whole memdisk.
2013-12-22 00:32:55 +01:00
Vladimir Serbinenko
0d8b81f89a Fix ARM Linux Loader on non-FDT platforms. 2013-12-22 00:30:19 +01:00
Vladimir Serbinenko
bf082198e2 * configure.ac: Choose link format based on host_os on emu. 2013-12-21 20:19:34 +01:00
Vladimir Serbinenko
0b602bf9ad * grub-core/osdep/unix/getroot.c: Non-unix build fix. 2013-12-21 18:10:05 +01:00
Vladimir Serbinenko
96650a82ec * grub-core/kern/emu/main.c: Build fix for emu. 2013-12-21 18:09:19 +01:00
Vladimir Serbinenko
ca3e20886e Build fixes for argp.h with older gcc. 2013-12-21 18:08:25 +01:00
Vladimir Serbinenko
27db1a9b64 * util/grub-glue-efi.c: Use "universal binary" rather "fat binary"
in strings.

	Suggested by: David Prévot.
2013-12-21 16:12:24 +01:00
Vladimir Serbinenko
8a913e664e * include/grub/crypto.h (grub_crypto_xor): Fix cast-align warning. 2013-12-21 15:35:15 +01:00
Vladimir Serbinenko
ae558c2ccf Enable -Wformat=2 if it's supported. 2013-12-21 15:28:28 +01:00
Vladimir Serbinenko
bbac6789aa * configure.ac: Add -Wmissing-include-dirs -Wmissing-prototypes
-Wmissing-declarations if supported.
2013-12-21 14:47:55 +01:00
Vladimir Serbinenko
ab216512d7 * grub-core/commands/macbless.c (grub_mac_bless_inode): Pass inode as u32
as both HFS and HFS+ have 32-bit inodes.
2013-12-21 14:40:53 +01:00
Vladimir Serbinenko
0d4aa91d0d * include/grub/misc.h (grub_strtol): Fix overflow. 2013-12-21 14:35:46 +01:00
Vladimir Serbinenko
a997af68e3 * include/grub/term.h (grub_unicode_estimate_width): Use grub_size_t
as return type in both conditionals.
2013-12-21 14:33:36 +01:00
Vladimir Serbinenko
36bcaf2903 * include/grub/video.h (grub_video_rgba_color_rgb): Fix prototype
to use uint8_t for color.
2013-12-21 14:31:47 +01:00
Vladimir Serbinenko
74763e9615 * util/misc.c (grub_util_get_image_size): Check for overflow. 2013-12-21 14:28:14 +01:00
Vladimir Serbinenko
80b29fc9b4 * grub-core/disk/raid6_recover.c (grub_raid_block_mulx): Use grub_size_t
for size.
2013-12-21 14:16:49 +01:00
Vladimir Serbinenko
6e327fcd4c * grub-core/disk/lvm.c: Use grub_size_t for sizes and grub_ssize_t
for pointer difference.
2013-12-21 14:15:04 +01:00
Vladimir Serbinenko
62ce03cf40 * util/import_gcry.py: Skip sample keys. 2013-12-21 14:07:42 +01:00
Vladimir Serbinenko
f4d70fd02b * util/misc.c (grub_qsort_strcmp): Don't discard const attribute. 2013-12-21 14:04:50 +01:00
Vladimir Serbinenko
93bf55e616 * configure.ac: Remove duplicate warning arguments. 2013-12-21 13:53:42 +01:00
Vladimir Serbinenko
579ee114b1 Add missing static qualifiers. 2013-12-21 13:50:13 +01:00
Vladimir Serbinenko
ee5283d66b Add missing includes. 2013-12-21 13:47:27 +01:00
Vladimir Serbinenko
5dbde526a8 Inline printf templates when possible to enable format checking. 2013-12-21 13:40:18 +01:00
Vladimir Serbinenko
d88ae4f0a4 * include/grub/crypto.h: Don't discard const attribute. 2013-12-21 13:36:42 +01:00
Vladimir Serbinenko
17b4355943 * grub-core/net/bootp.c (grub_cmd_dhcpopt): Use snprintf where it
was intended.
2013-12-21 13:35:28 +01:00
Vladimir Serbinenko
76a2a43011 * grub-core/lib/crypto.c: Don't discard const attribute. 2013-12-21 13:34:03 +01:00
Vladimir Serbinenko
0d26164edd * grub-core/lib/disk.c: Fix potential overflow. 2013-12-21 13:32:39 +01:00
Vladimir Serbinenko
2622b1e8a8 * grub-core/lib/arg.c: Don't discard const attribute. 2013-12-21 13:28:52 +01:00
Vladimir Serbinenko
05126706b0 * grub-core/kern/dl.c: Don't discard const attribute. 2013-12-21 13:26:27 +01:00
Vladimir Serbinenko
2f9c48041a * grub-core/kern/disk.c: Fix potential overflow. 2013-12-21 13:23:37 +01:00
Vladimir Serbinenko
0438ebf1c3 * conf/Makefile.common: Don't include non-existing directory
grub-core/lib/libgcrypt-grub/include.
2013-12-21 13:21:42 +01:00
Vladimir Serbinenko
065adc346c Clarify several translatable messages. 2013-12-21 03:21:45 +01:00
David Prévot
496a6b3024 Correct some translatable strings. 2013-12-21 03:03:31 +01:00
Colin Watson
971038be55 * util/grub-mkrescue.c: Rephrase mkrescue description. 2013-12-21 02:37:14 +01:00
Vladimir Serbinenko
bfdfeb2508 Clarify several translatable messages. 2013-12-21 01:41:16 +01:00
Vladimir Serbinenko
c00c34efe1 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-12-20 17:13:24 +01:00
Colin Watson
d642d76197 Be more verbose about some configure failures. 2013-12-20 16:09:43 +00:00
Vladimir Serbinenko
871aa709af * util/grub-install.c: Inform user about install platform. 2013-12-20 16:57:48 +01:00
Colin Watson
3bc1b2daab Fix various build problems on GNU/Hurd.
* grub-core/osdep/unix/getroot.c (strip_extra_slashes): Move inside
!defined (__GNU__).
(xgetcwd): Likewise.
* include/grub/emu/hostdisk.h (grub_util_hurd_get_disk_info)
[__GNU__]: Add prototype.
* util/getroot.c (grub_util_biosdisk_get_grub_dev) [__GNU__]: Format
long int using %ld rather than %d.
2013-12-20 14:02:27 +00:00
Vladimir Serbinenko
2fa5a58ca3 * configure.ac: Set version to 2.02~beta1. 2013-12-19 01:54:43 +01:00
Allen Pais
ee281fd0c6 * grub-core/boot/sparc64/ieee1275/boot.S: Fix order of fields.
Also-By: Bob Picco <bob.picco@oracle.com>
2013-12-19 01:53:56 +01:00
Vladimir Serbinenko
2e238b3708 Make grub_zlib_decompress handle incomplete chunks.
Fixes squash4.
2013-12-18 23:39:49 +01:00
Vladimir Serbinenko
2984035e1a * grub-core/Makefile.am: Don't attempt to export grub_bios_interrupt on i386-multiboot. 2013-12-18 21:19:11 +01:00
Aleš Nesrsta
b9f03772b5 * grub-core/disk/usbms.c: Retry on unknown errors.
Reuse the same tag on retries.
2013-12-18 19:00:45 +01:00
Aleš Nesrsta
e3ef0d30cf * grub-core/bus/usb/ehci.c: Fix handling of newborn transfers.
Avoid confusing them with already completed transfers.
2013-12-18 18:59:49 +01:00
Vladimir Serbinenko
72c9a50773 Remove xen VFB.
Due to XEN bug it prevents Linux boot. Remove it at least, until
	workaround is found.
2013-12-18 18:43:09 +01:00
Vladimir Serbinenko
8445567046 * po/exclude.pot: Add 2 missing excludes. 2013-12-18 17:12:13 +01:00
Vladimir Serbinenko
64dd5fdc00 Add missing license section in macbless.mod and macho.mod. 2013-12-18 17:11:11 +01:00
Vladimir Serbinenko
a29f317af1 Allow compilation without thumb-interwork as long as no thumb is
involved or only thumb2 is used.
2013-12-18 13:33:39 +01:00
Vladimir Serbinenko
063f2a04d1 Use -Wl,--no-relax rather than -mno-relax for uniformity. 2013-12-18 13:13:23 +01:00
Vladimir Serbinenko
113f786989 * INSTALL: Update comment as to why sparc64 clang isn't usable. 2013-12-18 13:11:29 +01:00
Vladimir Serbinenko
eba2afeda1 Add __attribute__ ((sysv_abi)) only if it's really needed.
Some compilers don't support it.
2013-12-18 13:09:39 +01:00
Vladimir Serbinenko
1962ed95cc * grub-core/lib/syslinux_parse.c: Declare timeout unsigned. 2013-12-18 12:29:30 +01:00
Vladimir Serbinenko
c2be6f7ef8 Remove -Wold-style-definition.
Not very useful and interaction of it with regexp depends on GCC
	version.
2013-12-18 07:48:09 +01:00
Vladimir Serbinenko
7a7f52388b Make grub_util_get_windows_path_real static. 2013-12-18 07:45:15 +01:00
Vladimir Serbinenko
9246d5c8a4 * grub-core/commands/fileXX.c: Silence cast-align.
* grub-core/loader/i386/xen_fileXX.c: Likewise.
2013-12-18 07:40:43 +01:00
Vladimir Serbinenko
b3aea1bc26 * include/grub/efi/api.h (GRUB_EFI_ERROR_CODE): Use explicit cast
rather than LL suffix.
2013-12-18 07:39:15 +01:00
Vladimir Serbinenko
e8c360ca4a * include/grub/efi/api.h (PRIxGRUB_EFI_UINTN_T): Remove leftover. 2013-12-18 07:35:51 +01:00
Vladimir Serbinenko
bc8dd11952 * grub-core/loader/arm/linux.c: Use common initrd functions. 2013-12-18 07:34:28 +01:00
Vladimir Serbinenko
57a691b7e7 Decrease number of strings to translate. 2013-12-18 07:26:13 +01:00
Vladimir Serbinenko
74fa9417e5 * grub-core/kern/arm/dl.c: Remove unnecessarry execution mode check. 2013-12-18 07:06:23 +01:00
Vladimir Serbinenko
636977b089 Mark strings for translation and add remaining ones to exclude list. 2013-12-18 06:50:24 +01:00
Vladimir Serbinenko
ee4450eb6f * util/grub-file.c (main): Fix sizeof usage. 2013-12-18 06:20:20 +01:00
Vladimir Serbinenko
a43b3e5d8e Silence spurious warning. 2013-12-18 06:19:16 +01:00
Vladimir Serbinenko
81294aff98 Remove check_nt_hiberfil as it's been superseeded by file command. 2013-12-18 06:03:23 +01:00
Vladimir Serbinenko
a99c0a328f * docs/osdetect.cfg: Add isolinux config to detected OSes. 2013-12-18 05:34:17 +01:00
Vladimir Serbinenko
8f5add13ff Implement syslinux parser. 2013-12-18 05:28:05 +01:00
Vladimir Serbinenko
8ff35d0a1b * grub-core/commands/legacycfg.c: Use 32-bit Linux protocol on non-BIOS. 2013-12-18 05:21:06 +01:00
Vladimir Serbinenko
ba14476051 Support cpuid --pae. 2013-12-17 23:40:49 +01:00
Vladimir Serbinenko
daaa89dbe5 Use AT keyboard on Yeeloong 3A. 2013-12-17 22:54:30 +01:00
Vladimir Serbinenko
25a7863d77 Add Yeeloong 3A reboot and halt. 2013-12-17 22:53:18 +01:00
Vladimir Serbinenko
184c61ddce Add Radeon Yeeloong 3A support. 2013-12-17 22:52:04 +01:00
Vladimir Serbinenko
fd4650a556 Add bonito 3A support. 2013-12-17 22:49:27 +01:00
Vladimir Serbinenko
3e88fbfa6e * grub-core/loader/machoXX.c: Fix compilation on non-i386. 2013-12-17 22:44:46 +01:00
Vladimir Serbinenko
1123bed944 * grub-core/loader/i386/xen_fileXX.c: Silence cast-align. 2013-12-17 20:47:31 +01:00
Vladimir Serbinenko
ebda165f3a * grub-core/loader/macho.c: Fix compilation on non-i386. 2013-12-17 20:46:33 +01:00
Vladimir Serbinenko
fe7c20bf9e Add missing format_arg attribute to check that printf with translated
messages has proper arguments.
2013-12-17 16:42:01 +01:00
Vladimir Serbinenko
f4dab3d1ac Use grub_xasprintf to format translated error messages containing
64-bit quantity.
2013-12-17 16:41:09 +01:00
Jon McCune
24d5934daa Fix double-free introduced by commit 33d02a42d6
To reproduce the problem, make sure you have a GPG public key available, build and install GRUB:
grub-install --debug --debug-image="all" --pubkey=/boot/pubkey.gpg --modules="serial terminfo gzio search search_label search_fs_uuid search_fs_file linux vbe video_fb video mmap relocator verify gcry_rsa gcry_dsa gcry_sha256 hashsum gcry_sha1 mpi echo loadenv boottime" /dev/sda
Sign all the files in /boot/grub/* and reboot.

'make check' results identical before and after this change.

TESTED: In a QEMU VM using an i386 target.
2013-12-17 07:32:07 -08:00
Vladimir Serbinenko
d6c2782a90 Unify message for unsupported relocation. 2013-12-17 16:17:46 +01:00
Vladimir Serbinenko
50d2e9596f Mark miscompile error for translation. 2013-12-17 16:05:39 +01:00
Vladimir Serbinenko
18e76955be Use %I64 and not %ll when using OS printf if compiling for windows. 2013-12-17 16:04:47 +01:00
Vladimir Serbinenko
d218ec9738 Update Mac code to match new register_efi prototype. 2013-12-17 16:02:36 +01:00
Vladimir Serbinenko
b8765fa082 Implement better integration with Mac firmware. 2013-12-17 15:21:02 +01:00
Vladimir Serbinenko
1f032575bb * grub-core/loader/multiboot_mbi2.c: Implement special value for load_addr. 2013-12-17 15:14:50 +01:00
Vladimir Serbinenko
1482975549 Include serial module in default_payload.elf. 2013-12-17 14:52:36 +01:00
Vladimir Serbinenko
d45067a290 Add explicit thumb interwork bx in asm files.
Shouldn't matter for armv >= 5 but let's be safe.
2013-12-17 14:50:44 +01:00
Vladimir Serbinenko
3086175489 Implement Truecrypt ISO loader. 2013-12-17 14:45:46 +01:00
Vladimir Serbinenko
e14d409b6f * grub-core/lib/arg.c: Ensure at least a single space between commands. 2013-12-17 14:42:02 +01:00
Vladimir Serbinenko
ec824e0f2a Implement grub_file tool and use it to implement generating of config
in separate root.
2013-12-17 14:39:48 +01:00
Vladimir Serbinenko
296f76068d Change to v1 xen grants. 2013-12-17 13:55:47 +01:00
Vladimir Serbinenko
2c384f1e6e * grub-core/lib/i386/xen/relocator.S: Fix hypercall ABI violation.
GRUB relied on %ebx being preserved across hypercall which isn't true.
2013-12-17 13:40:52 +01:00
Vladimir Serbinenko
d16ff5897f * grub-core/lib/x86_64/xen/relocator.S: Fix hypercall ABI violation.
GRUB relied on %rdi being preserved across hypercall which isn't true.
2013-12-17 13:19:58 +01:00
Vladimir Serbinenko
71669c3b76 Implement XEN VFB support. 2013-12-17 13:07:26 +01:00
Vladimir Serbinenko
60d1dd3d72 Remove grub_bios_interrupt on coreboot.
It's not used currently and cannot be used safely currently.
2013-12-17 12:54:11 +01:00
Vladimir Serbinenko
a82010503e Update exclude.pot and mark few strings for translation. 2013-12-17 01:18:09 +01:00
Vladimir Serbinenko
6cc8959712 * util/grub-mkrescue.c: Fix incorrect file usage in fallback code.
Reported by: Jon McCune
2013-12-17 00:33:55 +01:00
Vladimir Serbinenko
dd05b91f6b Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-12-16 20:33:19 +01:00
Vladimir Serbinenko
2a123f4c58 * grub-core/tests/sleep_test.c: Silence spurious warning. 2013-12-16 20:32:43 +01:00
Andrey Borzenkov
840a2c0592 add verbose information to linux platform check
As suggested by Vladimir Serbienko, add additional verbose output to inform
why we selected this specific platform.
2013-12-16 23:17:40 +04:00
Andrey Borzenkov
35248820ea ChangeLog for previous two commits. 2013-12-16 22:56:48 +04:00
Andrey Borzenkov
d770e63557 use grub_util_exec_redirect_all to silence "moprobe efivars"
modprobe -q still prints error on non-EFI. Redirect stderr instead.

Reported by Javier Vasquez.
2013-12-16 22:41:16 +04:00
Andrey Borzenkov
396311f0f6 consolidate grub_util_exec code
We need to hide "modprobe efivars" error output to avoid confusion. So
consolidate grub_util_exec_* into single function that can optionally redirect
all three standard descriptors and make all other functions compatibility
wrappers.

Also remove include/grub/osdep/exec_unix.h which does not appear to be used
anywhere.
2013-12-16 22:41:15 +04:00
Vladimir Serbinenko
316c8d9a18 Make grub_xen_hypercall on i386 cdecl rather than stdcall to avoid
linker trying to "fixup" the code.
2013-12-16 18:10:50 +01:00
Vladimir Serbinenko
8fcce8d50f * grub-core/kern/x86_64/xen/startup.S: Align stack. 2013-12-16 17:44:10 +01:00
Vladimir Serbinenko
6f1f6a0c82 Add support for converting PE+ to Elf64. 2013-12-16 15:30:50 +01:00
Vladimir Serbinenko
66a07ce2f8 * grub-core/commands/minicmd.c (grub_mini_cmd_dump): Handle LLP case. 2013-12-16 15:28:07 +01:00
Vladimir Serbinenko
cc6fb517de Remove practice of assigning random const pointers to device id.
This is not required as cache code already checks driver id as well.
2013-12-16 14:49:11 +01:00
Vladimir Serbinenko
f009f07c95 * include/grub/x86_64/types.h: Define sizeof (long) as 4 when compiling
with mingw.
2013-12-16 14:41:12 +01:00
Vladimir Serbinenko
9fdec226ff * include/grub/efi/api.h: Don't use call wrappers when compiled with
mingw or cygwin as API already matches.
2013-12-16 14:39:06 +01:00
Vladimir Serbinenko
d87cb3ae3c * grub-core/lib/posix_wrap/errno.h: Undefine errno before redefining. 2013-12-16 14:36:48 +01:00
Vladimir Serbinenko
3e38c31a4b * include/grub/efi/api.h: Define (u)intn_t based on pointer size and
not on long.
2013-12-16 14:34:23 +01:00
Vladimir Serbinenko
f4171ebd34 Handle X86_64_PC64 relocation.
Those are generated by some cygwin compilers.
2013-12-16 14:24:19 +01:00
Vladimir Serbinenko
252a289cb3 Determine the need for mingw-related stubs at compile time rather than
using not very significant $target_os.
2013-12-16 14:18:15 +01:00
Vladimir Serbinenko
fadddc260a Merge branch 'master' of git.sv.gnu.org:/srv/git/grub
Conflicts:
	ChangeLog
2013-12-16 14:15:37 +01:00
Vladimir Serbinenko
23d2abc33c * grub-core/genmod.sh.in: Strip before converting to ELF as strip
may not work with ELF.
2013-12-16 13:18:48 +01:00
Vladimir Serbinenko
4f979ccbf1 Use unix functions for temporary files and special files on cygwin. 2013-12-16 13:16:37 +01:00
Vladimir Serbinenko
37378f748a Define functions explicitly rather than using --defsym in tests
whenever possible. Respect locality in remaining cases.
2013-12-16 13:07:28 +01:00
Vladimir Serbinenko
6a09d83e12 * grub-core/genmoddep.awk: Remove explicit getline < /dev/stdin. 2013-12-16 13:02:19 +01:00
Andrey Borzenkov
e477187bf4 small fixes for Windows EFI install code
Fix potential crash caused by signed vs. unsigned comparison. Negative
length compares as very large unsigned number causing subsequent NULL access.

Make exhaustive search for all BootNNNN variables to find one matching
requested efi_distributor.
2013-12-15 22:00:15 +04:00
Ian Campbell
80b865bdc8 * grub-core/kern/uboot/init.c: Fix units of uboot timer. 2013-12-15 17:59:40 +01:00
Vladimir Serbinenko
04b0285701 New functional test for sleep function.
This test allows to check sleep without qemu. Keep qemu version as
	well as functional test won't notice if all clocks are going too fast
	or too slow.
2013-12-15 17:57:58 +01:00
Vladimir Serbinenko
39711101fd Add explicit sysv_abi on amd64 asm routines. 2013-12-15 14:48:42 +01:00
Vladimir Serbinenko
d99af4f0e8 * grub-core/commands/efi/lsefisystab.c: Use %lld to show num_table_entries. 2013-12-15 14:42:19 +01:00
Vladimir Serbinenko
7104368446 * include/grub/test.h: Use gnu_printf rather than printf on GRUB
functions.
2013-12-15 14:39:21 +01:00
Vladimir Serbinenko
111bf5db8b * grub-core/loader/i386/linux.c: Use grub_addr_t rather than long when
appropriate.
2013-12-15 14:37:12 +01:00
Vladimir Serbinenko
24ca71c93b * grub-core/loader/i386/linux.c: Use %p rather than %lx for pointers. 2013-12-15 14:35:18 +01:00
Vladimir Serbinenko
48ba5c0c86 * grub-core/kern/elfXX.c: Use grub_addr_t rather than long when
appropriate.
2013-12-15 14:33:22 +01:00
Vladimir Serbinenko
8ae6704517 * grub-core/disk/loopback.c: Use sequential IDs rather than pointer.
In case of quick removal of loopback and adding another one it may
	get same ID, confusing the cache system.
2013-12-15 14:31:21 +01:00
Vladimir Serbinenko
ed55931073 * grub-core/commands/acpi.c: Use grub_addr_t rather than long when
appropriate.
2013-12-15 14:27:04 +01:00
Vladimir Serbinenko
8fa2627942 * grub-core/kern/i386/coreboot/cbtable.c: Use char * arithmetic rather
than converting to long.
2013-12-15 14:24:34 +01:00
Vladimir Serbinenko
6f5f3337d8 * grub-core/disk/cryptodisk.c: Rename "n" to "last_cryptodisk_id". 2013-12-15 14:21:14 +01:00
Vladimir Serbinenko
e7c418c58f * util/grub-mkimagexx.c (relocate_addresses): Display offset rather
than almost useless pointer.
2013-12-15 14:18:30 +01:00
Vladimir Serbinenko
7e47e27bd8 Add gcc_struct to all packed structures when compiling with mingw.
Just "packed" doesn't always pack the way we expect.
2013-12-15 14:14:30 +01:00
Vladimir Serbinenko
ae8159b9ca * include/grub/i386/coreboot/lbio.h: Add missing attribute (packed). 2013-12-15 00:56:11 +01:00
Vladimir Serbinenko
74e7ad6604 * util/grub-pe2elf.c: Fix handling of .bss. 2013-12-15 00:55:17 +01:00
Vladimir Serbinenko
814442ba69 Implement windows flavour of EFI install routines. 2013-12-14 23:35:58 +01:00
Vladimir Serbinenko
5f5bb10748 * conf/Makefile.extra-dist: Adjust path to conf/i386-cygwin-img-ld.sc. 2013-12-14 23:33:05 +01:00
Vladimir Serbinenko
a24725cc6e Change grub_install_register_efi interface to pass GRUB device.
This allows grub_install_register_efi to request partition info
	directly.
2013-12-14 23:31:56 +01:00
Vladimir Serbinenko
38933cee85 Workaround cygwin bug when using \\?\Volume{GUID} syntax. 2013-12-14 23:28:34 +01:00
Vladimir Serbinenko
6d3cfe5063 Do not use TCHAR string functions as they are not available on cygwin. 2013-12-14 23:25:30 +01:00
Vladimir Serbinenko
4bad23a15f Workaround windows bug when querying EFI system partition parameters. 2013-12-14 23:23:11 +01:00
Vladimir Serbinenko
6a5fe1328b * grub-core/kern/i386/qemu/init.c (resource): Decrease struct size
by using bitfields.
2013-12-14 23:15:47 +01:00
Vladimir Serbinenko
bc8fcf4bd3 * grub-core/boot/i386/qemu/boot.S: Add missing EXT_C. 2013-12-14 23:13:42 +01:00
Vladimir Serbinenko
60b967be7e Make i386-* other than i386-pc compileable under cygwin. 2013-12-14 23:12:53 +01:00
Vladimir Serbinenko
6dc3337774 Fix definition of grub_efi_hard_drive_device_path. Take care that
existing code would work even if by some reason bogus definition is
	used by EFI implementations.
2013-12-14 22:04:02 +01:00
Vladimir Serbinenko
f2c6ff15e5 * grub-core/osdep/windows/hostdisk.c: Fix cygwin compilation. 2013-12-14 21:55:44 +01:00
Vladimir Serbinenko
6b8a162516 * grub-core/osdep/windows/blocklist.c: Add missing cast in printf
invocation.
2013-12-14 21:54:37 +01:00
Vladimir Serbinenko
954c723acc * util/config.c: Remove trailing newline from distributor in simple
parsing.
2013-12-14 21:50:36 +01:00
Vladimir Serbinenko
607a39f9f0 * include/grub/efi/api.h: Rename protocol and interface to avoid
conflict.
2013-12-14 21:48:46 +01:00
Vladimir Serbinenko
df6fedcab1 * .gitignore: Add .exe variants. Add missing files. Remove few outdated
entries.
2013-12-14 21:45:17 +01:00
Vladimir Serbinenko
f684d7e1a9 * grub-core/osdep/exec.c: Use unix version on cygwin. 2013-12-14 21:39:03 +01:00
Vladimir Serbinenko
0df77d793c Implement multiboot2 EFI BS specification. 2013-12-13 12:56:14 +01:00
Vladimir Serbinenko
dafff9ce44 * grub-core/normal/charset.c: Fix premature line wrap and crash.
Crash happened only in some cases like a string starting at the
	half of the screen of same length.
2013-12-11 17:06:00 +01:00
Vladimir Serbinenko
6644d9733d * include/grub/efiemu/efiemu.h: Sync configuration table declaration
with EFI counterpart.
2013-12-11 16:16:21 +01:00
Vladimir Serbinenko
44bbfa33b8 Propagate the EFI commits to x86-efi specific parts. 2013-12-11 16:11:17 +01:00
Vladimir Serbinenko
3e3dff249f * grub-core/commands/efi/lssal.c: Fix terminating condition. 2013-12-11 15:59:12 +01:00
Vladimir Serbinenko
316dda716c Introduce grub_efi_packed_guid and use it where alignment is not
guaranteed.
2013-12-11 15:57:08 +01:00
Vladimir Serbinenko
219401b8b9 * include/grub/efi/api.h (grub_efi_device_path): Define length as
unaligned u16 rather than u8[2].
2013-12-11 15:54:01 +01:00
Vladimir Serbinenko
30d0053799 * grub-core/kern/ia64/dl.c (grub_arch_dl_relocate_symbols): Add checks
for relocation range.
2013-12-11 11:29:35 +01:00
Vladimir Serbinenko
979742bc7e * grub-core/kern/ia64/dl.c (grub_arch_dl_relocate_symbols): Handle
non-function pcrel21b relocation. It happens with .text.unlikely
	section.
2013-12-11 11:28:48 +01:00
Leif Lindholm
16c8f78513 efi: mm: make MAX_USABLE_ADDRESS platform-specific 2013-12-10 18:05:29 +00:00
Leif Lindholm
3f1423e789 * grub-core/lib/fdt.c: change memcpy => grub_memcpy 2013-12-10 16:51:10 +00:00
Vladimir Serbinenko
0341da6019 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-12-10 09:24:37 +01:00
Andrey Borzenkov
9f2f979bcf always define config_directory and config_file as full pathname
If configfile is relative pathname, extend it with current ($root) so its
interpretation does not change if $root is changed later.

Suggested by Vladimir Serbienko.
2013-12-10 09:55:27 +04:00
Jon McCune
dd73313cba Add --no-rs-codes flag to optionally disable reed-solomon codes in grub-install and grub-bios-setup for x86 BIOS targets. 2013-12-09 16:52:12 -08:00
Vladimir Serbinenko
eaf01c25fe Add missing compile and link options for sparc64-emu. 2013-12-10 00:05:28 +01:00
Vladimir Serbinenko
7a148da6dd Implement sparc64 trampolines (needed for sparc64-emu). 2013-12-10 00:01:27 +01:00
Vladimir Serbinenko
21eee750b7 * grub-core/kern/sparc64/dl.c (grub_arch_dl_relocate_symbols): Check
range of R_SPARC_HI22.
	Implement R_SPARC_LM22.
2013-12-09 15:51:12 +01:00
Vladimir Serbinenko
7b54b62682 * grub-core/kern/powerpc/dl_helper.c (grub_arch_dl_get_tramp_got_size):
Do not explicitly check for symbol table as it's already checked in
	platform-independent layer.
2013-12-09 15:43:27 +01:00
Vladimir Serbinenko
9a945e2a24 * grub-core/kern/emu/cache.c [__ia64__]: Use our cache cleaning routine
on ia64 as __clear_cache is a dummy on ia64.
2013-12-09 14:24:56 +01:00
Vladimir Serbinenko
4f4ea1b449 * grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
Do not explicitly check for symbol table as it's already checked in
	platform-independent layer.
2013-12-09 14:22:31 +01:00
Colin Watson
fe4ae21331 * util/grub-mkconfig.in: Add missing newline to output. 2013-12-09 00:14:59 +00:00
Vladimir Serbinenko
78b2b0a1a0 * grub-core/kern/ia64/efi/init.c (grub_arch_sync_caches): Move to ...
* grub-core/kern/ia64/cache.c (grub_arch_sync_caches): ... here.
2013-12-08 18:27:40 +01:00
Vladimir Serbinenko
d14772c455 * grub-core/kern/emu/main.c: Silence missing prototypes to allow emu
compilation with GCC <= 4.2.
	* grub-core/kern/emu/argp_common.c: Likewise.
2013-12-08 18:21:10 +01:00
Vladimir Serbinenko
388f3cd0d1 * include/grub/kernel.h [__sparc__]: Restrict sparc64-ieee1275 to
right platform rather than leaking to sparc64-emu.
2013-12-08 18:19:42 +01:00
Vladimir Serbinenko
11e4167a35 * grub-core/osdep/windows/emuconsole.c: Remove unsigned comparison >= 0.
But ensure that the variables in question are indeed unsigned.
2013-12-08 18:16:32 +01:00
Vladimir Serbinenko
fa7eb63dec * grub-core/kern/emu/lite.c: Add missing include of ../ia64/dl_helper.c. 2013-12-08 18:14:32 +01:00
Vladimir Serbinenko
50b3a68db9 Remove grub_memalign on emu. 2013-12-08 18:12:20 +01:00
Vladimir Serbinenko
fbbfb6ab11 * grub-core/kern/ia64/efi/init.c: Fix alignment code so it doesn't
truncate incomplete lines but instead flushes them.
2013-12-08 18:10:05 +01:00
Vladimir Serbinenko
a19293cb75 Move OS-dependent mprotect for module loading to grub-core/osdep/*/dl.c
and implement windows variant.
2013-12-08 18:08:23 +01:00
Vladimir Serbinenko
d5c14e1e26 Fix mips-emu compilation. 2013-12-08 17:49:02 +01:00
Vladimir Serbinenko
b75db69ac1 * configure.ac: Check for freetype library usability. 2013-12-08 10:50:59 +01:00
Vladimir Serbinenko
c311ced5d7 Make arm-emu work. 2013-12-08 02:59:21 +01:00
Vladimir Serbinenko
c8fd2ddf6d * util/grub-mkfont.c: Replace stpcpy with grub_stpcpy. 2013-12-07 23:28:20 +01:00
Andrey Borzenkov
c50e5f4543 Update color_normal and color_highlight defaults (light-gray instead of white) 2013-12-08 00:00:26 +04:00
Andrey Borzenkov
bb05e313eb use light-gray as default color in normal.mod for consistency
Defalut font color on PC console seems to be light-gray; this is
what user also gets in rescue prompt and what is defined as
GRUB_TERM_DEFAULT_NORMAL_COLOR. But normal.mod defaults to white.
This makes unpleasant visual effect as colors are changed after kernel
is booted.

Use the same color eveywhere for consistency and default to light-gray
as this is also what at least Linux kernel is using by default.
2013-12-07 20:00:48 +04:00
Vladimir Serbinenko
f23bc65103 Transform -C option to grub-mkstandalone to --core-compress available
in all grub-install flavours.
2013-12-07 16:18:22 +01:00
Vladimir Serbinenko
4c4ea9c7b5 Merge GRUBFS and GRUB_FS variables. 2013-12-07 16:09:39 +01:00
Andrey Borzenkov
92e9352ded second attempt to fix using grub device name as install device
grub-install already resolved passed install device to grub device. So do the
same as grub-setup and strip parenthesis if we get legacy (hdX).

I accidentally commited revert of 69ca97c820 and
this patch as part of f585c90505. So this commit
just adds ChangeLog entry and cosmetic whitespace fix.
2013-12-07 18:58:19 +04:00
Andrey Borzenkov
f585c90505 fix partition module names when /boot is on diskfilter
/usr/local/grub2/sbin/grub-install: info: grub-mkimage --directory '/usr/local/grub2/lib/grub/i386-pc' --prefix '(mduuid/e6d1dcf06cea72140bafae74a8677f36)/grub' --output '/boot/grub/i386-pc/core.img' --format 'i386-pc' --compression 'auto'  'ext2' 'msdos' 'msdos' 'diskfilter' 'mdraid1x' 'biosdisk'
.
/usr/local/grub2/sbin/grub-install: error: cannot open `/usr/local/grub2/lib/grub/i386-pc/msdos.mod': No such file or directory.

Introduce common helper for both diskfilter and non-diskfilter case that
converts partition map names into module names.
2013-12-07 15:00:37 +04:00
Vladimir Serbinenko
5ff249072d * configure.ac: Make unifont mandatory on coreboot. 2013-12-07 11:47:19 +01:00
Vladimir Serbinenko
0277eab701 * configure.ac: Skip unifont 6.3 pcf and bdf. 2013-12-07 11:46:46 +01:00
Vladimir Serbinenko
4861b6c851 * Makefile.am: Remove partial font files if generation failed. 2013-12-07 11:39:35 +01:00
Andrey Borzenkov
3100cdc7f9 add grub_qsort_strcmp to use when sorting array of strings
Compare function used in qsort gets arguments by reference, so strcmp
cannot be used directly - it expects pointer to char, but gets pointer
to pointer to char.

Introduce new helper grub_qsort_strcmp and use it in grub-install.
This helper is going to be used in a couple more places as well so
add it to global file, not in grub-install.c.
2013-12-07 14:29:00 +04:00
Andrey Borzenkov
ad73cc3312 fix use of grub-probe instead of ${grub_probe} 2013-12-07 14:24:25 +04:00
Vladimir Serbinenko
4182262560 Don't add -mlong-calls when compiling with clang. 2013-12-06 11:58:17 +01:00
Vladimir Serbinenko
896f483d49 * configure.ac: Fix a typo. 2013-12-06 10:02:24 +01:00
Vladimir Serbinenko
8c534b85f1 Revamp relocation handling.
Move more code to common dl.c. Add missing veneers for arm and arm64.
	Decreases kernel size by 70 bytes on i386-pc (40-50 compressed)
2013-12-06 09:18:55 +01:00
Vladimir Serbinenko
a846dd4b3a * util/grub-mkimagexx.c: Fix reloc section generation for ia64. 2013-12-05 23:07:10 +01:00
Mike Gilbert
aa437b5890 gentpl.py: Use python3-style print function 2013-12-05 16:07:15 +00:00
Vladimir Serbinenko
b0f311f412 * util/grub-install.c: Mention Boot* variable. 2013-12-05 17:05:21 +01:00
Colin Watson
59b38922a1 Pacify compiler warning
* grub-core/osdep/linux/hostdisk.c
(grub_util_find_partition_start_os): Initialise start to avoid
spurious compiler warning.
2013-12-05 15:48:27 +00:00
Colin Watson
0480665b9d On Linux, read partition start offsets from sysfs if possible
This lets us cope with block device drivers that don't implement
HDIO_GETGEO.  Fixes Ubuntu bug #1237519.

* grub-core/osdep/linux/hostdisk.c (sysfs_partition_path): New
function.
(sysfs_partition_start): Likewise.
(grub_util_find_partition_start_os): Try sysfs_partition_start
before HDIO_GETGEO.
2013-12-05 13:51:52 +00:00
Leif Lindholm
bbeee1c4a3 grub-core/lib/fdt.c: correctly update size_dt_struct in add_subnode() 2013-12-05 11:44:41 +00:00
Vladimir Serbinenko
e5ed2f6947 Handle unaligned .bss on sparc64.
Current code improperly assumes that both __bss_start and _end are
	aligned to 8-bytes. Eliminating this assumption and explicitly align
	modules.
2013-12-05 06:35:19 +01:00
Vladimir Serbinenko
4a73746a04 * grub-core/boot/sparc64/ieee1275/boot.S [CDBOOT]: Move scratchpad
so it doesn't land in the middle of loaded image.
2013-12-04 19:54:37 +01:00
Vladimir Serbinenko
382b500ebe * configure.ac: Move all warning options that may be absent in
gcc >= 3.1 to optional.

	Note: while this allows to compile with older GCC, official requirements
	remain the same and no support for older GCC.
2013-12-04 14:53:25 +01:00
Colin Watson
3a82f8bb48 Fix grub-shell to avoid breaking "make distcheck"
Copying the themes directory in grub-shell isn't
parallel-test-friendly and breaks on the second test when the source
directory is read-only (as in "make distcheck").  Instead, add a
hidden --themes-directory option to grub-mkrescue et al, and use it
in grub-shell.
2013-12-04 13:36:34 +00:00
Vladimir Serbinenko
e3046431da * conf/Makefile.common (CFLAGS_GNULIB): Remove -Wno-old-style-definition
as it's no longer necessarry.
2013-12-04 14:32:04 +01:00
Vladimir Serbinenko
bdb6090d83 * configure.ac: Allow compilation with older GCC for ARM. 2013-12-04 12:42:09 +01:00
Vladimir Serbinenko
b73b70ebca * configure.ac: Add -no-integrated-as if {addme|ame} isn't supported.
* INSTALL: Note that GRUBwas successfully compiled with clang 3.2 for
	ppc.
2013-12-04 12:20:56 +01:00
Vladimir Serbinenko
8a3f0a24b5 * grub-core/kern/emu/main.c: Ignore missing prototype for main. 2013-12-04 10:28:23 +01:00
Vladimir Serbinenko
6f07c4e407 Pass font config to config.h and not by TARGET_CFLAGS as adding
arguments doesn't work if TARGET_CFLAGS is specified on command
	line.
2013-12-04 10:25:53 +01:00
Vladimir Serbinenko
60d5e9cbd9 * configure.ac: Add -Wvla if compiler supports it. 2013-12-04 10:08:57 +01:00
Vladimir Serbinenko
cd15c394cc * grub-core/osdep/windows/emuconsole.c (grub_console_putchar):
Remove variable length arrays.
	* grub-core/term/efi/console.c (grub_console_putchar): Likewise.
2013-12-04 10:05:33 +01:00
Vladimir Serbinenko
bb6e299ccb * grub-core/kern/i386/qemu/init.c: Remove variable length arrays. 2013-12-04 09:48:36 +01:00
Vladimir Serbinenko
85eb579ad9 * include/grub/types.h: Declare all byteswaps as inline functions
except compile-time ones.

	Solves variable shadowing in constructions like
	cpu_to_le (le_to_cpu(x) + 1).
2013-12-04 08:42:35 +01:00
Vladimir Serbinenko
47f88cc94e * grub-core/kern/efi/efi.c: Remove variable length arrays. 2013-12-04 08:39:22 +01:00
Vladimir Serbinenko
40b5739ff9 * grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71
minutes.
2013-12-04 08:26:39 +01:00
Vladimir Serbinenko
234d93464a * grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays.
* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
2013-12-04 08:10:01 +01:00
Colin Watson
0c0eab527f * grub-core/Makefile.core.def (setjmp): Distribute
lib/arm64/setjmp.S.
2013-12-03 18:11:18 +00:00
Colin Watson
44d4884779 Merge branch 'cjwatson/timeout-style' 2013-12-03 16:15:45 +00:00
Colin Watson
10955cda06 Credit and bug reference. 2013-12-03 16:14:01 +00:00
Colin Watson
f315b508ae Reduce nesting level. 2013-12-03 16:11:00 +00:00
Vladimir Serbinenko
9e4e6ddfbf * util/config.c: Add missing pointer adjustment.
Reported by: qwertial
2013-12-02 06:51:13 +01:00
Andrey Borzenkov
5037aa9a7b fix libgrub.pp build post arm64 merge
grub-core/kern/arm64/dl_helper.c:26:28: fatal error: grub/cpu/reloc.h: No such file or directory
2013-11-30 22:36:10 +04:00
Vladimir Serbinenko
8a952d20d1 Missing ChangeLog entry 2013-11-30 16:51:35 +01:00
Leif Lindholm
b29b77fee2 New port arm64-efi 2013-11-30 16:50:31 +01:00
Andrey Borzenkov
be0d45555e document sleep command exit codes 2013-11-30 14:57:11 +04:00
Vladimir Serbinenko
d74b9a1d1a Ensure that -mno-unaligned-access or some equivalent option is used. 2013-11-30 11:31:14 +01:00
Vladimir Serbinenko
35de6d4bac * grub-core/lib/libgcrypt/mpi/longlong.h: Fix compilation error with
-march=armv3.
2013-11-30 11:19:06 +01:00
Vladimir Serbinenko
ce55ed0389 Remove leftover GRUB_IA64_DL_TRAMP_SIZE. 2013-11-30 11:14:30 +01:00
Colin Watson
f70ab525f9 Remove a few references to GRUB_HIDDEN_TIMEOUT*
Reported by Andrey Borzenkov.
2013-11-29 17:19:37 +00:00
Colin Watson
9b70860ecc Consolidate timeout generation code a bit. 2013-11-29 16:11:53 +00:00
Colin Watson
095588ef34 Consistently ignore GRUB_TIMEOUT if GRUB_HIDDEN_TIMEOUT is set
Pointed out by Vladimir Serbinenko.
2013-11-29 15:30:44 +00:00
Colin Watson
2dbda2215c Fix documentation of behaviour after pressing ESC
Pointed out by Andrey Borzenkov.
2013-11-29 15:25:43 +00:00
Colin Watson
53cc63bf85 Add GRUB_TIMEOUT_STYLE_BUTTON support
Suggested by Vladimir Serbinenko.
2013-11-29 15:18:05 +00:00
Colin Watson
471b2683e7 Move deprecated grub-mkconfig options to a separate table
Suggested by Andrey Borzenkov.
2013-11-29 14:59:25 +00:00
Colin Watson
8ddf84bfb8 Fix "make -C docs dvi"
* docs/grub-dev.texi (Font Metrics): Exclude @image command from DVI
builds, since we don't have an EPS version of font_char_metrics.png.
Add leading dot to image extension per the Texinfo documentation.
2013-11-29 13:48:23 +00:00
Colin Watson
fd0df6d098 Fix build with FreeType 2.5.1
* util/grub-gen-asciih.c: Include FT_SYNTHESIS_H rather than
<freetype/ftsynth.h>, fixing build with FreeType 2.5.1.
* util/grub-gen-widthspec.c: Likewise.
* util/grub-mkfont.c: Likewise.
2013-11-29 12:19:36 +00:00
Andrey Borzenkov
69ca97c820 fix using grub device name as install device
Shell version of grub-install called grub-setup which resolved
install device name and called main setup routine. C version of
grub-install calls main setup routine directly, which leads
to the error:

grub2-install: info: grub-bios-setup  --verbose  --force  --skip-fs-probe --directory='/boot/grub2/i386-pc' --device-map='/boot/grub2/device.map' '(hd2)'.
grub2-install: info: reading /boot/grub2/i386-pc/boot.img.
grub2-install: info: reading /boot/grub2/i386-pc/core.img.
grub2-install: info: root is `(null)', dest is `(hd2)'.
grub2-install: info: Opening dest.
grub2-install: info: drive = -1.
grub2-install: error: disk `(hd2)' not found.

Move resolving of destination device name into main setup routine
so it is done consistently in both cases.
2013-11-29 11:32:34 +04:00
Vladimir Serbinenko
eec893ae49 * grub-core/kern/emu/hostfs.c (is_dir): Remove variable length arrays. 2013-11-29 05:52:20 +01:00
Vladimir Serbinenko
621e167fd6 * util/grub-fstest.c: Remove variable length arrays. 2013-11-29 05:50:32 +01:00
Vladimir Serbinenko
d54f647a4a * grub-core/osdep/linux/ofpath.c: Check return value of read. 2013-11-29 05:46:19 +01:00
Vladimir Serbinenko
c8a0f1b229 * util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
computing crc32 rather than handling with md fundtions directly.
2013-11-29 04:14:26 +01:00
Vladimir Serbinenko
726409a513 * util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
checking fwstart.img rather than md fundtions directly.
2013-11-29 04:05:44 +01:00
Vladimir Serbinenko
422e6e886c * util/grub-mkrescue.c (main): Check that fread succeeded. 2013-11-29 03:54:21 +01:00
Vladimir Serbinenko
af1faca3f8 * conf/Makefile.common: Remove -mexplicit-relocs and -DUSE_ASCII_FALLBACK on yeeloong.
-DUSE_ASCII_FALLBACK is already added by font snippets.
	-mexplicit-relocs isn't needed is compiler/assemblera are
	configured properly.
	If they're not we shouldn't attempt to fix it by ourselves.
	Binary compare between before and after shows no difference.
2013-11-29 03:45:50 +01:00
Vladimir Serbinenko
469021b4b3 Remove libgnulib.a and use its sources in dependencies directly.
This was the only instance of "library" in core config. A bug was
	reported that -fno-stack-protector wasn't passed to it. Instead of
	figuring out why it failed just remove this construction used
	needlessly.
2013-11-29 03:36:50 +01:00
Vladimir Serbinenko
83c256ba42 * grub-core/osdep/unix/password.c (grub_password_get): Check that
fgets succeeded.
2013-11-29 03:32:57 +01:00
Francesco Lavra
b67422d33d Fix command description in case of a device name passed as argument. 2013-11-28 17:25:52 +04:00
Colin Watson
827d87e9d6 Fix documentation of timeout expiry. 2013-11-28 11:01:53 +00:00
Colin Watson
8f236c1419 Revamp hidden timeout handling
Add a new timeout_style environment variable and a corresponding
GRUB_TIMEOUT_STYLE configuration key for grub-mkconfig.  This
controls hidden-timeout handling more simply than the previous
arrangements, and pressing any hotkeys associated with menu entries
during the hidden timeout will now boot the corresponding menu entry
immediately.

GRUB_HIDDEN_TIMEOUT=<non-empty> + GRUB_TIMEOUT=<non-zero> now
generates a warning, and if it shows the menu it will do so as if
the second timeout were not present.  Other combinations are
translated into reasonable equivalents.
2013-11-28 02:29:15 +00:00
Vladimir Serbinenko
2d76b4d81e Eliminate variable length arrays in grub_vsnprintf_real.
A bit tricky because this function has to continue to work without
	heap for short strings. Fixing prealloc to 32 arguments is reasonable
	but make all stack references use 32-bit offset rather than 8-bit one.
	So split va_args preparsing to separate function and put the prealloc
	into the caller.
2013-11-27 15:16:09 +01:00
Vladimir Serbinenko
4f9541226c Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
2013-11-27 14:13:50 +01:00
Vladimir Serbinenko
b1f742c103 * gentpl.py: Don't generate platform-dependent conditionals for
platform-independent targets.
2013-11-27 14:10:04 +01:00
Colin Watson
16ef26fd3a * grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove
references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
2013-11-27 11:22:31 +00:00
Colin Watson
cf8c80ff77 Merge branch 'new-autogen' 2013-11-27 10:57:27 +00:00
Colin Watson
5c7206e45e Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into
no-ops, and use it in programs that copy files but do not need to take
special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).

On my laptop, this reduces partmap_test's runtime from 1236 seconds to
204 seconds.
2013-11-27 10:10:22 +00:00
Colin Watson
fc3f2b72cd * tests/util/grub-fs-tester.in: Execute xorriso from $PATH rather
than hardcoding /usr/local/bin/xorriso.
2013-11-26 23:51:48 +00:00
Colin Watson
34b2003def Handle #if/#endif and C-style comments in AutoGen definitions files. 2013-11-26 17:48:20 +00:00
Colin Watson
7e90f5ad25 Show file name in error messages from AutogenParser. 2013-11-26 17:42:56 +00:00
Colin Watson
ab4f15013a Generate Makefile.*.am directly from gentpl.py, eliminating the use of Autogen. The Autogen definitions files remain intact as they offer a useful abstraction. 2013-11-26 17:13:01 +00:00
Vladimir Serbinenko
1e4b358720 Add PCI command activation to all PCI drivers as required for coreboot
and maybe some other firmwares.
2013-11-26 14:21:11 +01:00
Vladimir Serbinenko
9208367d3f * grub-core/Makefile.am: Reduce gratuituous differences between Apple
and non-Apple variants of efiemu compile.
2013-11-26 11:38:12 +01:00
Andrey Borzenkov
67b9b7afd7 Add ChangeLog entry for previous commit 2013-11-25 23:14:04 +04:00
Andrey Borzenkov
c2b70d0981 Explicitly check for linking format to use for efiemu64 module
Similar to check for target linking format, also check for efiemu64
instead of hardcoding -melf_x86_64. This fixes compilation on *BSD
variants. We cannot easily reuse main target check because platforms
are different (main target is 32 bit and efiemu64 - 64 bit).

This commit adds EFIEMU64_LINK_FORMAT that contains detected
link option and is used in efiemu64.o linking instead of hardcoded
value.

Reported-By: Beeblebrox <zaphod@berentweb.com>
2013-11-25 22:32:55 +04:00
Vladimir Serbinenko
bee1b5ce3f * util/grub-mknetdir.c: Look for platform directories under pkglibdir
and not pkgdatadir.
2013-11-25 19:16:05 +01:00
Colin Watson
07e3b04742 Add a --locale-directory option to grub-install and related tools.
* include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add
--locale-directory option.
(enum grub_install_options): Add
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
* util/grub-install-common.c (grub_install_help_filter): Handle
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
(grub_install_parse): Likewise.
(get_localedir): New function to check for a user-provided option
before trying grub_util_get_localedir.
(copy_locales): Use get_localedir rather than
grub_util_get_localedir.  Handle differing locale directory layouts.
(grub_install_copy_files): Likewise.
2013-11-25 18:04:50 +00:00
Vladimir Serbinenko
ebd289335a Mention clang for arm64 2013-11-25 13:27:39 +01:00
Vladimir Serbinenko
d2f7902af0 Make arm64 compileable with clang 2013-11-25 13:06:56 +01:00
Vladimir Serbinenko
1005bed722 Use b.ge form for instructions 2013-11-25 13:04:44 +01:00
Vladimir Serbinenko
d6c92cdc34 Merge branch 'master' into leiflindholm/arm64
Conflicts:
	include/grub/util/install.h
2013-11-25 13:02:27 +01:00
Vladimir Serbinenko
61e1b9a49d * grub-core/osdep/unix/platform.c (get_ofpathname): Trim ending newline.
Don't rely on PATH_MAX.
2013-11-25 07:34:49 +01:00
Vladimir Serbinenko
c98dd165b0 * grub-core/genmoddep.awk: Use more portable && rather than and. 2013-11-25 07:32:51 +01:00
Vladimir Serbinenko
ff1c277ef8 * grub-core/kern/i386/pc/startup.S [__APPLE__]: Create _edata by placing
an object after data. While it doesn't seem right solution, it
	works well enough and OSX isn't main compilation platform.
2013-11-25 05:55:33 +01:00
Vladimir Serbinenko
c8f7614b98 * gentpl.py: Add -ed2016 in order to make objconv accept our binary.
While it doesn't seem right solution, it works well enough and
	OSX isn't main compilation platform.
2013-11-25 05:53:20 +01:00
Vladimir Serbinenko
246a434f61 * configure.ac: Add -static to LDFLAGS when using apple linker to
prevent it from pulling in dynamic linker.
2013-11-25 05:47:20 +01:00
Vladimir Serbinenko
5c066a81c2 Apple assembly doesn't handle symbol arithmetic well. So define an
offset symbol in boot.S and use it.
2013-11-24 07:12:12 +01:00
Vladimir Serbinenko
78f961efe9 Apple assembly doesn't handle symbol arithmetic well. So instead
of getting addres of kernel_sector + 4 define kernel_sector_high.
	It also makes code more readable.
2013-11-24 07:11:00 +01:00
Vladimir Serbinenko
09bc0a577d With Apple assembly in .macro environvemnt you have to use $$ instead
of $. So introduce new preprocessor macro MACRO_DOLLAR(x) which expands
	to $$x on Apple and to $x on everything else.
2013-11-24 07:08:18 +01:00
Vladimir Serbinenko
b700a427d2 * grub-core/Makefile.am: Use correct TARGET_OBJCONV rather than
OBJCONV.
2013-11-24 05:27:20 +01:00
Vladimir Serbinenko
4480b95dcd * grub-core/gdb/i386/machdep.S: Use xorl %eax, %eax on both Apple
and non-Apple. This instruction is shorter and faster,
	so no reason not to use it on both.
2013-11-24 05:17:24 +01:00
Vladimir Serbinenko
e77c81f6f8 * grub-core/lib/reed_solomon.c: Use section _text, _text rather than
.text when compiling for Apple.
2013-11-24 05:14:11 +01:00
Vladimir Serbinenko
971dbee521 * grub-core/term/arc/console.c: Add missing cast to silence warning. 2013-11-24 05:05:34 +01:00
Vladimir Serbinenko
6f2e82be3a * grub-core/boot/i386/pc/boot.S: Fix floppy probe. Due to missing
%dx restore the probe worked on non-existant drive. Reorganize the
	code a little bit to free 2 bytes necessary for push/pop.
2013-11-24 05:05:33 +01:00
Vladimir Serbinenko
9eec9699b9 * grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation):
Add missing cast to silence warning.
2013-11-23 15:35:01 +01:00
Keshav Padram Amburay
5ae5c54c7e * util/grub-install.c (update_nvram): Support --no-nvram flag
for EFI targets.
2013-11-23 13:02:12 +01:00
Vladimir Serbinenko
7b04fe6c9e * INSTALL: Add note about sparc64/ia64 with clang (unsupported). 2013-11-23 12:49:41 +01:00
Vladimir Serbinenko
e67566ce0a * util/garbage-gen.c: Add missing include of sys/time.h. 2013-11-23 12:42:30 +01:00
Vladimir Serbinenko
f93ddcfd1c Don't add -mflush-func if it's not supported by compiler. 2013-11-23 12:40:44 +01:00
Vladimir Serbinenko
1bba40f578 Move common BIOS/coreboot memory map declarations to
include/grub/i386/memory_raw.h and eliminate duplicate declarations.
2013-11-23 12:39:21 +01:00
Andrey Borzenkov
f65e14dc3a add util/garbage-gen.c to EXTRA_DIST 2013-11-23 14:39:35 +04:00
Vladimir Serbinenko
14a94bba6f * INSTALL: Document why older clang versions aren't appropriate. 2013-11-23 01:16:47 +01:00
Vladimir Serbinenko
8109c5d4e2 * INSTALL: Document about clang for mips. 2013-11-23 00:41:32 +01:00
Vladimir Serbinenko
a92b5cb8d8 * grub-core/lib/libgcrypt/mpi/longlong.h: Use C version with mips
clang.
2013-11-23 00:36:13 +01:00
Vladimir Serbinenko
4a23e2fe29 Add *-xen to the list of grub-install-common platforms. 2013-11-22 14:21:16 +01:00
Vladimir Serbinenko
a3ba74104e * configure.ac: Do not enforce -mcmodel=large. It's not necessarry with
3 last commits.
2013-11-22 13:07:51 +01:00
Vladimir Serbinenko
e1c22419ac * grub-core/kern/xen/init.c: Do not map more pages than we can address. 2013-11-22 13:04:29 +01:00
Vladimir Serbinenko
189090cee9 * grub-core/kern/efi/mm.c: Limit allocations to 2GiB when not compiling
with -mcmodel=large.
2013-11-22 13:03:19 +01:00
Vladimir Serbinenko
1a5b7b404f * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Add
range-checking for 32-bit quantities.
2013-11-22 13:01:14 +01:00
Vladimir Serbinenko
9cf12b20af * configure.ac: Compile with -fPIC when compiling with clang on
mips.
2013-11-22 12:50:41 +01:00
Vladimir Serbinenko
63a45330cb * configure.ac: Add -no-integrated-as on mips(el) to TARGET_CCASFLAGS
when compiling with clang.
2013-11-22 12:48:32 +01:00
Vladimir Serbinenko
4a0aaad022 clang emits calls to abort () under some unknown conditions.
Export abort () when compiling with clang.
2013-11-22 12:42:58 +01:00
Vladimir Serbinenko
095bb1bfa5 * docs/grub-dev.texi: Document stack and heap sizes. 2013-11-22 12:03:44 +01:00
Vladimir Serbinenko
3937bd962b * include/grub/i386/pc/memory.h: Decrease
GRUB_MEMORY_MACHINE_SCRATCH_SIZE and increase
	GRUB_MEMORY_MACHINE_PROT_STACK_SIZE.
	The binary doesn't change (checked). It's more to better reflect actual
	usage.
2013-11-22 12:02:00 +01:00
Vladimir Serbinenko
ddb3efc906 * grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_open): Ensure
at compile time that enough of scratch size is available.
2013-11-22 12:00:10 +01:00
Vladimir Serbinenko
4e42521d8c * grub-core/kern/x86_64/efi/callwrap.S: Fix stack alignment.
Previously we misaligned stack by 8 in startup.S and compensated
	for it in callwrap.S. According to ABI docs (EFI and sysv amd64)
	right behaviour is to align stack in startup.S and keep it aligned
	in callwrap.S. startup.S part was committed few commits before. This
	takes care of callwrap.S.
	Reported by: Gary Lin.
2013-11-22 05:40:32 +01:00
Vladimir Serbinenko
054efe541f * grub-core/boot/mips/startup_raw.S: Handle the case of gap between
.data and .bss. May happen if compiler and assembly use different
	alignment.
2013-11-22 05:07:32 +01:00
Vladimir Serbinenko
a0e1befb57 On MIPS handle got16 relocations to local symbols in an ABI-compliant
way.
2013-11-22 05:03:17 +01:00
Vladimir Serbinenko
c36c73f681 Add support for a new magic symbol _gp_disp on mips to handle PIC
binaries.
2013-11-22 04:56:10 +01:00
Vladimir Serbinenko
6f4a19f59f Use $t9 for indirect calls from asm to C as PIC ABI requires. 2013-11-22 04:45:05 +01:00
Vladimir Serbinenko
0d8f04cd83 Remove -march=mips3 from TARGET_CCASFLAGS as it creates linking problem
when rest of GRUB is compiled for hisher stepping. Instead use
	.set mips3/.set mips1 around cache and sync opcodes.
2013-11-22 04:36:53 +01:00
Vladimir Serbinenko
4906052019 Unify GOT/trampoline handling between PPC, MIPS and IA64 as they
do essentially the same thing, do it in similar way.
2013-11-21 21:54:33 +01:00
Colin Watson
c6a823e267 * util/grub-mkrescue.c (main): If a source directory is not
specified, read platform-specific files from subdirectories of
pkglibdir, not pkgdatadir.
2013-11-21 17:36:45 +00:00
Colin Watson
b7f9aedfac * grub-core/normal/progress.c: Remove unused file. 2013-11-21 15:37:57 +00:00
Vladimir Serbinenko
7dd0a30361 * grub-core/lib/crypto.c (grub_crypto_hash): Remove variable length
array.
2013-11-20 20:09:18 +01:00
Vladimir Serbinenko
ca120e31f2 * util/grub-mkconfig.in: Say explicit "grub configuration" rather
than grub.cfg.
2013-11-20 10:18:19 +01:00
Vladimir Serbinenko
48eb35cd78 * coreboot.cfg: Add missing file. 2013-11-20 00:52:23 +01:00
Vladimir Serbinenko
7f20dbbcd2 * Makefile.am: Allow STRIP to be empty when creating windowszip. 2013-11-19 23:48:46 +01:00
Axel Kellermann
55e706c918 * util/grub.d/30_os-prober.in: Add GRUB_OS_PROBER_SKIP_LIST to
selectively skipping systems.
2013-11-19 23:39:51 +01:00
Colin Watson
4e7d433dfb * Makefile.util.def (grub-mkimage): Add
grub-core/osdep/aros/config.c to extra_dist.
* conf/Makefile.extra-dist (EXTRA_DIST): Add docs/autoiso.cfg,
docs/osdetect.cfg, grub-core/gnulib-fix-null-deref.diff,
grub-core/gnulib-fix-width.diff, grub-core/gnulib-no-abort.diff, and
grub-core/gnulib-no-gets.diff.
2013-11-19 20:39:16 +00:00
Vladimir Serbinenko
7d44ff7de6 Add automated filesystem checking based on scripts I've used now for
quite some time locally. Most of the test require root so they are
	skipped when run without necessarry privelegies.
2013-11-19 21:05:59 +01:00
Colin Watson
a8c3e5e3c7 * util/grub-install.c (main): Adjust info messages to match
installed paths of grub-bios-setup and grub-sparc64-setup.
2013-11-19 18:43:05 +00:00
Colin Watson
4402db3ecc * util/grub-install-common.c (copy_locales): Consistently use
grub_util_get_localedir () rather than LOCALEDIR.
(grub_install_copy_files): Likewise.
2013-11-19 15:35:44 +00:00
Josh Triplett
7960d3e182 * grub-core/kern/x86_64/efi/startup.S (_start): Align the stack to a
16-byte boundary, as required by the x86-64 ABI, before calling
	grub_main.  In some cases, GCC emits code that assumes this
	alignment, which crashes if not aligned.  The EFI firmware is also
	entitled to assume that stack alignment without checking.
2013-11-19 14:31:40 +01:00
Leif Lindholm
8a07b55a04 arm64: cache maintenance code rework + bugfix 2013-11-19 10:05:23 +00:00
Josh Triplett
d53f4900d7 * grub-core/mmap/efi/mmap.c (grub_mmap_register): Round up/down to
4k page boundaries as expected by firmware rather than 1k
	boundaries.
	(grub_mmap_malign_and_register): Likewise.
2013-11-18 18:00:52 +01:00
Vladimir Serbinenko
d3def58c52 Add missing arm64 declaration 2013-11-18 17:52:57 +01:00
Vladimir Serbinenko
96fa2d9d02 Merge branch 'master' into leiflindholm/arm64 2013-11-18 17:51:28 +01:00
Vladimir Serbinenko
2d6a38fbf7 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-18 17:46:15 +01:00
Vladimir Serbinenko
bb2b275b7d * tests/grub_func_test.in: Decrease RAM size to 512M. With less
fragmentation 512M is enough.
2013-11-18 17:42:54 +01:00
Vladimir Serbinenko
45bf8b3a75 * grub-core/kern/mm.c (grub_real_malloc): Decrease cut-off of moving the
pointer to 32K. This is the size of cache element which is the most
	common allocation >1K. This way the pointer is always around blocks
	of 32K and so we keep performance while decreasing fragmentation.
2013-11-18 17:41:37 +01:00
Colin Watson
60870be86c * tests/gzcompress_test.in: Skip if gzip is not installed (unlikely,
but for symmetry).
* tests/lzocompress_test.in: Skip if lzop is not installed.
* tests/xzcompress_test.in: Skip if xz is not installed.
2013-11-18 16:16:33 +00:00
Vladimir Serbinenko
39ff43c579 * grub-core/kern/mm.c (grub_real_malloc): Don't update the pointer to
current memory when allocating large chunks. This significantly
	decreases memory fragmentation.
2013-11-18 16:58:55 +01:00
Vladimir Serbinenko
1bbb796799 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-18 16:47:54 +01:00
Vladimir Serbinenko
74e632fea8 * grub-core/kern/mips/qemu_mips/init.c (grub_machine_init): Update
clock frequency to 200 MHz,
2013-11-18 16:39:45 +01:00
Vladimir Serbinenko
efb8de492a * tests/util/grub-shell.in: Increase console size to 1024x1024. 2013-11-18 16:32:22 +01:00
Colin Watson
a1f00cc557 * util/grub-mkrescue.c (main): Fix typo. 2013-11-18 15:30:47 +00:00
Vladimir Serbinenko
421db3da06 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-18 16:12:50 +01:00
Vladimir Serbinenko
b7526e7806 * Makefile.am (default_payload.elf): Add pata to loaded modules.
Load config file from (cbfsdisk)/etc/grub.cfg.
2013-11-18 16:05:47 +01:00
Vladimir Serbinenko
b40ce65180 * util/grub-install-common.c (grub_install_copy_files): Fix module
destination directory.
2013-11-18 15:59:55 +01:00
Colin Watson
1e8e2e78a5 * tests/util/grub-shell.in: Don't fail on emu platform if po/*.gmo
files have not been built.
2013-11-18 14:02:11 +00:00
Vladimir Serbinenko
4d5b72cdb4 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-18 14:54:01 +01:00
Vladimir Serbinenko
35c2851cc1 * tests/util/grub-shell.in: Use -cdrom and don't force cdrom
on primary master on pseries.
2013-11-18 14:40:41 +01:00
Vladimir Serbinenko
ea7c1a7d90 * grub-core/tests/videotest_checksum.c: Don't reload unifont if it's
already loaded. This saves memory needed for tests,
2013-11-18 14:38:31 +01:00
Vladimir Serbinenko
96adefdb12 * util/grub-mkrescue.c (main): Fix a typo to make yeeloong part
work again.
2013-11-18 14:36:31 +01:00
Vladimir Serbinenko
5e3cb8a747 * grub-core/term/terminfo.c (grub_cmd_terminfo): Fix a typo to make -g
work again.
2013-11-18 14:35:18 +01:00
Colin Watson
3bf4088b8b * grub-core/osdep/unix/hostdisk.c (grub_util_make_temporary_file):
Handle errors from mkstemp.
(grub_util_make_temporary_dir): Handle errors from mkdtemp.
2013-11-18 12:27:44 +00:00
Vladimir Serbinenko
256ee7ac6a * tests/util/grub-shell.in: For powerpc tests put the CD-ROM as primary
master since with some combinations of qemu and firmware only primary
	IDE channel is available.
2013-11-18 11:51:46 +01:00
Vladimir Serbinenko
f8b4c3b6b3 * grub-core/tests/gfxterm_menu.c: Skip high-resolution tests on
low-memory platforms where we don't have enough memory for them.
	* grub-core/tests/videotest_checksum.c: Likewise.
2013-11-18 11:48:07 +01:00
Vladimir Serbinenko
4bf703206d * grub-core/tests/cmdline_cat_test.c: Don't reload unifont if it's
already loaded. This saves memory needed for tests,
2013-11-18 11:45:55 +01:00
Vladimir Serbinenko
a284320e1e Fix handling of install lists. 2013-11-18 11:38:00 +01:00
Vladimir Serbinenko
2df8f43d3e * grub-core/lib/sparc64/setjmp.S: Force spilling of current window. 2013-11-18 10:01:36 +01:00
Vladimir Serbinenko
6f1bc8bc0f On i386-ieee1275 we run in paged mode. So we need to explicitly map
the devices before accessing them.
2013-11-18 04:32:33 +01:00
Vladimir Serbinenko
04f39f6df8 * grub-core/lib/relocator.c (grub_mm_check_real): Accept const char *
as file argument.
2013-11-18 02:45:25 +01:00
Vladimir Serbinenko
35d4761ce2 * grub-core/normal/cmdline.c (grub_cmdline_get): Plug memory leak. 2013-11-18 02:43:29 +01:00
Vladimir Serbinenko
33d02a42d6 * grub-core/kern/file.c (grub_file_open): Free file->name on failure.
(grub_file_close): Free file->name.
2013-11-18 02:41:42 +01:00
Vladimir Serbinenko
7bbb60cfbd * grub-core/commands/verify.c (free_pk): Plug memory leak.
(grub_load_public_key): Likewise.
	(grub_verify_signature_real): Likewise.
	(grub_cmd_verify_signature): Likewise.
2013-11-18 02:40:17 +01:00
Vladimir Serbinenko
da93d6753b * grub-core/commands/legacycfg.c (grub_legacy_check_md5_password): Plug
memory leak.
2013-11-18 02:37:46 +01:00
Vladimir Serbinenko
59c943ecf6 * grub-core/lib/powerpc/setjmp.S (grub_setjmp): Save r31.
(grub_longjmp): Restore r31.
	* include/grub/powerpc/setjmp.h (grub_jmp_buf): Reserve space for r31.
2013-11-18 02:35:32 +01:00
Vladimir Serbinenko
4336b5d85e * util/grub-mkrescue.c (make_image_fwdisk_abs): Insert all partmap
modules to be in line with make_image_abs.
2013-11-18 02:03:36 +01:00
Vladimir Serbinenko
44ce3a93b6 * include/grub/mips/setjmp.h (grub_jmp_buf): Fix buffer size.
setjmp.S uses 12 entries but buffer is declared with only 11 entries.
2013-11-18 01:49:14 +01:00
Ian Campbell
7d400406a7 * grub-core/disk/uboot/ubootdisk.c: Include SCSI disks. 2013-11-17 15:38:09 +01:00
Vladimir Serbinenko
77dae919b6 * tests/grub_func_test.in: Increase memory reservation as on EFI we need
to leave some memory to firmware.
2013-11-17 02:16:21 +01:00
Vladimir Serbinenko
0ab8e025c1 * grub-core/tests/cmdline_cat_test.c (cmdline_cat_test): Ignore errors
of loading gfxterm as gfxterm is embed in kernel on some platforms.
	* grub-core/tests/gfxterm_menu.c (gfxterm_menu): Likewise.
	Load gfxmenu.
2013-11-17 02:13:33 +01:00
Vladimir Serbinenko
b80c2d6d4b * tests/core_compress_test.in: Use full arguments as grub-mkimage-extra
now needs full arguments.
2013-11-17 02:09:15 +01:00
Vladimir Serbinenko
6aa6077bcc * util/grub-mkrescue.c (main): Add trailing \n in
.disk_label.contentDetails to be in line with previous shell script.
2013-11-17 02:05:45 +01:00
Vladimir Serbinenko
66c00cb159 * util/grub-mkrescue.c (main): Use right source file for bootinfo.txt. 2013-11-17 02:03:03 +01:00
Vladimir Serbinenko
3a129dba59 * util/grub-install-common.c (grub_install_parse): Recognize
--compress=none like shell script did.
2013-11-17 02:01:21 +01:00
Vladimir Serbinenko
8df6eff6da * include/grub/misc.h: Replace check for __sparc64__ with one for
__sparc__ as __sparc64__ isn't actually defined.
2013-11-17 01:01:47 +01:00
Vladimir Serbinenko
889ebe922b * tests/util/grub-shell.in: Use escc-ch-b on powerpc. This is missing
counterpart of fixing the naming of escc ports.
2013-11-17 00:57:54 +01:00
Vladimir Serbinenko
d4d55b29e0 * util/grub-install-common.c (platforms): Fix the order of entries and
remove useless field val.
2013-11-17 00:54:40 +01:00
Vladimir Serbinenko
55e2c84fe3 * util/grub-install.c: Add new option --no-bootsector to skip
installing of bootsector. Accept --grub-setup=/bin/true as
	backwards-compatible synonym.
2013-11-16 21:11:01 +01:00
Leif Lindholm
15a463d742 ARM 64 port by Leif Lindholm 2013-11-16 20:52:55 +01:00
Vladimir Serbinenko
cd46aa6cef Rewrite grub-install, grub-mkrescue, grub-mkstandalone and grub-mknetdir
the function of these files exceeds what can be sanely handled in shell
	in posix-comaptible way. Also writing it in C extends the functionality
	to non-UNIX-like OS and minimal environments.
2013-11-16 20:21:16 +01:00
Vladimir Serbinenko
9ef81064a3 * grub-core/kern/arm/cache.S: Don't switch back to ARM mode when
compiling to thumb2.
	* grub-core/kern/arm/cache_armv7.S: Likewise.
	* grub-core/lib/arm/setjmp.S: Likewise.
2013-11-16 17:37:06 +01:00
Leif Lindholm
11a7793221 arm: delete superflouous save of r8 in grub_uboot_syscall 2013-11-16 15:56:09 +00:00
Vladimir Serbinenko
080603f0b0 Decrease stack usage in lexer.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/script/yylex.l (yyalloc), (yyfree), (yyrealloc): Declare
	as macros so that compiler would remove useless structure on stack.
	Better solution would be to fix flex not to put this structure on
	the stack but flex is external program.
2013-11-16 16:37:59 +01:00
Vladimir Serbinenko
4f84ae0ec8 Decrease stack usage in signature verification.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/commands/verify.c (grub_load_public_key): Allocate on heap
	rather than stack.
	(grub_verify_signature_real): Likewise.
2013-11-16 16:34:51 +01:00
Vladimir Serbinenko
ab4366fd49 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub
Conflicts:
	ChangeLog
2013-11-16 16:17:46 +01:00
Vladimir Serbinenko
e6a6182d95 Decrease stack usage in mdraid 0.9x.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Allocate on heap
	rather than stack.
2013-11-16 16:16:48 +01:00
Vladimir Serbinenko
1a454efe89 Decrease stack usage in BtrFS.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Allocate on heap
	rather than stack.
2013-11-16 16:15:26 +01:00
Vladimir Serbinenko
deaa7052c5 Decrease stack usage in BtrFS.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Allocate on heap
	rather than stack.
2013-11-16 16:03:28 +01:00
Vladimir Serbinenko
7b5d51d837 Decrease stack usage in JFS.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/fs/jfs.c (getblk): Allocate on heap rather than on
	stack. Note: this function is recursive.
	(grub_jfs_read_inode): Read only part we care about.
2013-11-16 16:00:42 +01:00
Leif Lindholm
593865b907 arm: fix u-boot port syscall interface va_arg handling
Commit c9cd02c broke the u-boot syscall API for va_args that spill over
to the stack, causing the disk support to stop working. This patch
resolves the problem, while keeping the new, cleaner transition_space
handling.
2013-11-16 14:12:12 +00:00
Andrey Borzenkov
31c0cd4362 restore -nostdlib for libgcc symbols tests
Commit 24f4e57c46 plugged leakage
of CFLAGS between individual tests, which broke test for libgcc
symbols. It needs -nostdlib which was set in previous test and
inherited before. Set it explicitly.
2013-11-16 17:03:20 +04:00
Andrey Borzenkov
c2fdb33116 document cmdpath environment variable 2013-11-16 17:00:59 +04:00
Andrey Borzenkov
9e18dfe277 MIPS grub_machine_get_bootlocation arguments are used 2013-11-16 16:59:07 +04:00
Colin Watson
59ba9d147f * .gitignore: Only ignore grub-mk* at the top level. 2013-11-15 16:25:05 +00:00
Colin Watson
23012db921 * util/grub-reboot.in (usage): Fix a typo. 2013-11-15 14:32:03 +00:00
Vladimir Serbinenko
6fcec43954 Replace libgcc version of ctz with our own.
On upcoming arm64 port libgcc ctz* are not usable in standalone
	environment. Since we need ctz* for this case and implementation is
	in C we may as well use it on all concerned platforms.
2013-11-15 03:28:34 +01:00
Vladimir Serbinenko
a9f25a0819 * configure.ac: Probe for linking format rather than guessing it based
on target_os.
2013-11-14 23:17:18 +01:00
Vladimir Serbinenko
c7995256e4 * grub-core/disk/xen/xendisk.c (grub_xendisk_fini): Set state to
"1" prior to handoff.

	Reported by: M A Young.
2013-11-14 22:42:54 +01:00
Vladimir Serbinenko
e1aa5b6620 * grub-core/kern/xen/init.c (grub_xenstore_write_file): Don't add
\0 to all files.

	Reported by: M A Young.
2013-11-14 22:40:50 +01:00
Vladimir Serbinenko
da5ed5cf6b * grub-core/osdep/bsd/hostdisk.c (grub_util_get_fd_size_os): Fix
compilation on NetBSD.
2013-11-14 22:38:36 +01:00
Vladimir Serbinenko
5757a93e01 * acinclude.m4: Don't add -P on initial nm test.
Note: even though this patch postdates Andrey's it bears 14 Nov as
	date due to timezone difference.
2013-11-14 22:37:20 +01:00
Vladimir Serbinenko
deca601915 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-14 22:28:03 +01:00
Andrey Borzenkov
a5986276ec add grub-core/tests/signatures.h to distfiles 2013-11-15 00:51:30 +04:00
Vladimir Serbinenko
da45f43ce3 * Makefile.am (default_payload.elf): Add uhci, ohci and usb_keyboard. 2013-11-14 18:41:41 +01:00
Colin Watson
0de172a0c0 * util/grub-install_header: Set localedir here, since this file is
where it's used.
* util/grub-install.in: Remove setting of localedir.
* util/grub-mkrescue.in: Likewise.
2013-11-14 16:45:27 +00:00
Vladimir Serbinenko
20aea9492f * configure.ac: Move nm checks to the end.
Call grub_PROG_NM_WORKS.
	* acinclude.m4: New check grub_PROG_NM_WORKS.
	Use $TARGET_CFLAGS -c when compiling test binary.
2013-11-14 17:39:01 +01:00
Colin Watson
1326b9ae2a * util/getroot.c (grub_util_biosdisk_get_grub_dev) [__GNU__]: Remove
unused variables.
2013-11-14 15:08:37 +00:00
Matthew Garrett
1fe26ab4a0 * grub-core/kern/main.c (grub_set_prefix_and_root): Set variable
cmdpath to firmware directory.
2013-11-14 15:53:32 +01:00
Vladimir Serbinenko
83e9c273e5 * grub-core/kern/efi/efi.c (grub_efi_get_filename): Reset the pointer
at the start of second iteration.
2013-11-14 15:50:43 +01:00
Vladimir Serbinenko
ec525c18e1 * grub-core/Makefile.am (efiemu64.o): Explicitly set link format. 2013-11-14 12:05:48 +01:00
Vladimir Serbinenko
93fcc7ad73 * Makefile.am (default_payload.elf): New target for easier coreboot
build.
2013-11-14 11:28:38 +01:00
Vladimir Serbinenko
1d912bd3c9 Merge branch 'master' of git.sv.gnu.org:/srv/git/grub
Conflicts:
	ChangeLog
2013-11-14 10:05:54 +01:00
Vladimir Serbinenko
57ffe93485 * grub-core/kern/arm/cache_armv6.S: Remove special handling for
clang (not necessarry with -no-integrated-as).
	* include/grub/symbol.h [__arm__]: Likewise.
2013-11-14 10:05:19 +01:00
Colin Watson
5da5517288 * grub-core/fs/ext2.c (grub_ext2_read_block): Factor out common code for indirect block handling.
Saves 185 bytes on compressed image.
2013-11-14 08:13:06 +00:00
Vladimir Serbinenko
2312f06c30 * configure.ac: Use -no-integrated-as on arm with clang.
* INSTALL: Mention ARM compilation with clang.
2013-11-14 08:36:35 +01:00
Vladimir Serbinenko
2416415c53 * conf/Makefile.common (CCASFLAGS_PLATFORM) [COND_arm]: Add
-mthumb-interwork.
2013-11-14 08:34:54 +01:00
Vladimir Serbinenko
e6050a683c Merge branch 'master' of git.sv.gnu.org:/srv/git/grub 2013-11-14 08:33:14 +01:00
Paulo Flabiano Smorigo
da7703286a fix make clean
* Makefile.am: Remove build-grub-* in make clean.
2013-11-13 23:03:22 -02:00
Paulo Flabiano Smorigo
f02e6b5675 new files to .gitignore
* .gitignore: Add build-grub-gen-asciih, build-grub-gen-widthspec,
build-grub-mkfont, and grub-emu-lite. Remove .bzrignore.
2013-11-13 23:02:31 -02:00
Leif Lindholm
035a26c16a * grub-core/kern/arm/misc.S: Make thumb2-compatible. 2013-11-14 01:33:06 +01:00
Leif Lindholm
bc8a6137b2 * .gitignore: fix rules for .dep* and add *.a post git migration 2013-11-13 20:53:57 +00:00
Colin Watson
6fe506b04b * configure.ac (AM_INIT_AUTOMAKE): Require at least version 1.10.1,
to match INSTALL.
2013-11-13 14:57:12 +00:00
Colin Watson
81a2e438dc * grub-core/kern/misc.c: Don't redirect divisions in the
GRUB_UTIL case.
* include/grub/misc.h: Likewise.
2013-11-13 14:47:23 +00:00
Colin Watson
9b45c0733e * grub-core/osdep/unix/emuconsole.c (put): Pacify the compiler on
systems that require checking the return value of write.
2013-11-13 13:34:57 +00:00
Colin Watson
11b2a9b70b * util/grub-install.in (efi_quiet): Fix inverted logic: make
efibootmgr quiet when --debug is not used, rather than when it is.
2013-11-13 13:05:39 +00:00
Colin Watson
d743d22de6 * gentpl.py (define_macro_for_platform_dependencies): Remove
first (and thus unused) of two definitions for this function.
(platform_dependencies): Likewise.
2013-11-13 12:46:37 +00:00
Colin Watson
11da14b548 * acinclude.m4 (grub_apple_cc): Remove; since the removal of nested
functions, we only need to check this for the target, not the host.
* configure.ac (grub_apple_cc): Likewise.
2013-11-13 12:01:39 +00:00
Vladimir Serbinenko
2bdd07195c * grub-core/kern/arm/cache.c (probe_caches): Move asm part to ...
* grub-core/kern/arm/cache_armv6.S: ... here. This allows this
	asm to stay in arm even if surrounding is thumb.
2013-11-13 09:58:52 +01:00
Vladimir Serbinenko
5e77d9cfc1 * grub-core/kern/arm/misc.S: Add __muldi3 and __aeabi_lmul. Those
helper functions are needed for thumb.
2013-11-13 09:52:33 +01:00
Vladimir Serbinenko
7d5116251d * grub-core/disk/diskfilter.c (grub_diskfilter_make_raid): Make
level / 3 division explicitly unsigned. Saves few bytes.
2013-11-13 09:40:16 +01:00
Vladimir Serbinenko
81023dbdbd * grub-core/fs/zfs/zfs.c (ZAP_LEAF_NUMCHUNKS): Use unsigned arithmetics. 2013-11-13 09:27:36 +01:00
Vladimir Serbinenko
b2e9294fb9 * grub-core/normal/datetime.c (grub_get_weekday): Use if rather than
division.
2013-11-13 09:26:13 +01:00
Vladimir Serbinenko
16a22c3851 * grub-core/kern/uboot/init.c: Move grub_uboot_machine_type and
grub_uboot_boot_data to asm part.
2013-11-13 06:28:15 +01:00
Vladimir Serbinenko
c9cd02c965 * grub-core/kern/arm/uboot/startup.S: Remove = by replacing with
literal load.
	(grub_uboot_syscall): Save/restore r9 and align stack.
2013-11-13 06:27:03 +01:00
Vladimir Serbinenko
8149861554 * grub-core/kern/arm/cache.S: Replace = with explicit litteral load. 2013-11-13 06:23:32 +01:00
Vladimir Serbinenko
ea57de18f8 * include/grub/symbol.h (END) [__arm__]: New macros. Replace all .end
occurencies with END.
2013-11-13 05:19:30 +01:00
Colin Watson
d0d1e3dacb * util/grub-editenv.c (help_filter, argp): Document how to delete
the whole environment block.
Reported by Dan Jacobson.  Fixes Debian bug #726265.
2013-11-13 02:15:57 +00:00
Colin Watson
3809f0163b * docs/grub.texi (Internationalisation, Supported kernels): Fix
sectioning.
2013-11-13 02:08:50 +00:00
Josh Triplett
46d8a2033b * grub-core/normal/term.c (grub_set_more): Use bool logic rather than
increment/decrement.
2013-11-13 02:27:11 +01:00
Vladimir Serbinenko
c773faf05e Revert " * include/grub/symbol.h (ADDR): New macro. Replace all occurences of"
This reverts commit 286551b4eb.
2013-11-13 02:17:20 +01:00
Vladimir Serbinenko
513eeb61dd * grub-core/kern/arm/cache_armv6.S [__clang__]: Don't add .armv6 when
compiling with clang.
2013-11-13 01:08:47 +01:00
Vladimir Serbinenko
bc379c1aa1 * grub-core/kern/arm/uboot/startup.S: Use .org rather than assigning
".".
2013-11-13 01:06:30 +01:00
Vladimir Serbinenko
286551b4eb * include/grub/symbol.h (ADDR): New macro. Replace all occurences of
=x with ADDR(x) in arm assembly.
	(END): New macro. Replace all .end with END.
2013-11-13 01:04:56 +01:00
Vladimir Serbinenko
16057d6bbb Redirect all divisions to grub_divmod64. 2013-11-13 00:53:53 +01:00
Vladimir Serbinenko
f649a6a8fd * grub-core/term/tparm.c (tparam_internal): Use unsigned divisions. 2013-11-13 00:51:06 +01:00
Vladimir Serbinenko
ef28ee8bc1 Add missing includes of loader.h. 2013-11-13 00:43:03 +01:00
Vladimir Serbinenko
300f48c532 * configure.ac: Allow disabling themes. 2013-11-12 22:44:01 +01:00
Lukas Schwaighofer
2d357558fb * util/grub.d/20_linux_xen.in: Don't decompress initrd. 2013-11-12 21:03:27 +01:00
Vladimir Serbinenko
0c62a5b28e * grub-core/term/at_keyboard.c: Don't poll non-functional AT controller
until it becomes operational.
2013-11-12 19:30:46 +01:00
Vladimir Serbinenko
b0720b4988 * grub-core/Makefile.core.def (legacy_password_test): Disable
on platforms where no legacycfg is compiled.
	* grub-core/tests/lib/functional_test.c: Tolerate failure to
	load legacy_password_test.
2013-11-12 18:44:58 +01:00
Vladimir Serbinenko
d5bab2c0e1 * grub-core/loader/i386/bsd.c: Remove variable length arrays. 2013-11-12 16:14:33 +01:00
Vladimir Serbinenko
3ea0ccb319 * grub-core/efiemu/prepare.c: Remove variable length arrays. 2013-11-12 16:12:28 +01:00
Vladimir Serbinenko
08772054e9 * grub-core/osdep/windows/hostdisk.c (grub_util_fd_strerror): Silence
strict-aliasing warning.
	(fsync): Silence cast warning.
2013-11-12 16:09:42 +01:00
Vladimir Serbinenko
1dcb27157d * grub-core/commands/verify.c: Remove variable length arrays.
Load gcry_dsa/gcry_rsa automatically.
2013-11-12 16:07:30 +01:00
Vladimir Serbinenko
61c22fdf36 * grub-core/tests/signature_test.c: New test. 2013-11-12 16:05:57 +01:00
Vladimir Serbinenko
431e57a797 * grub-core/disk/cryptodisk.c (luks_script_get): Adapt to new procfs
API.
2013-11-12 16:01:19 +01:00
Vladimir Serbinenko
b521bb816d * grub-core/tests/legacy_password_test.c (vectors): Make static.
* grub-core/tests/pbkdf2_test.c (vectors): Likewise.
2013-11-12 15:59:58 +01:00
Vladimir Serbinenko
7d06b24eac * grub-core/tests/setjmp_test.c: Reset counter to 0 before starting. 2013-11-12 15:58:50 +01:00
Vladimir Serbinenko
3bbeade41d * grub-core/fs/proc.c: Allow \0 in proc files. 2013-11-12 15:57:09 +01:00
Vladimir Serbinenko
ba82db7a0d * grub-core/tests/xnu_uuid_test.c: Fix assert message. 2013-11-12 14:11:34 +01:00
Vladimir Serbinenko
801564c804 * grub-core/tests/xnu_uuid_test.c: Fix copyright year. 2013-11-12 14:07:34 +01:00
Vladimir Serbinenko
ac8cac1dac * grub-core/fs/ext2.c: Remove variable length arrays. 2013-11-12 03:04:19 +01:00
Vladimir Serbinenko
4b85f1228a * grub-core/lib/crypto.c (grub_crypto_cbc_decrypt): Remove variable
length arrays.
2013-11-12 02:49:17 +01:00
Vladimir Serbinenko
c35fcdc0b7 * grub-core/disk/AFSplitter.c: Remove variable length arrays.
* grub-core/disk/cryptodisk.c: Likewise.
	* grub-core/disk/geli.c: Likewise.
	* grub-core/disk/luks.c: Likewise.
2013-11-12 02:48:02 +01:00
Vladimir Serbinenko
15decd26cc * grub-core/tests/legacy_password_test.c: New test.
* grub-core/commands/legacycfg.c: Remove variable length arrays.
2013-11-12 02:38:33 +01:00
Vladimir Serbinenko
9c6482b8d6 * grub-core/lib/pbkdf2.c: Remove variable length arrays. 2013-11-12 01:52:55 +01:00
Vladimir Serbinenko
41f26e0ebc * grub-core/tests/pbkdf2_test.c: New test. 2013-11-12 01:51:36 +01:00
Vladimir Serbinenko
2def66169e * grub-core/lib/xzembed/xz_dec_stream.c: Remove variable length arrays. 2013-11-12 01:26:56 +01:00
Vladimir Serbinenko
9e34a34e44 * grub-core/io/lzopio.c: Remove variable length arrays. 2013-11-12 01:25:03 +01:00
Vladimir Serbinenko
5ccaf90415 * include/grub/crypto.h: Add maximums on hash size and cipher block
size.
2013-11-12 01:20:45 +01:00
Vladimir Serbinenko
44a387e0ea * grub-core/commands/xnu_uuid.c: Remove variable length arrays. 2013-11-12 01:19:34 +01:00
Vladimir Serbinenko
a388e25576 * grub-core/tests/xnu_uuid_test.c: New test. 2013-11-12 01:18:27 +01:00
Vladimir Serbinenko
a1ef7718c9 * grub-core/commands/hashsum.c: Remove unneeded memset (zalloc already
covers it).
2013-11-12 00:58:46 +01:00
Vladimir Serbinenko
65ddb30016 * grub-core/commands/hashsum.c: Remove variable length arrays. 2013-11-12 00:52:54 +01:00
Vladimir Serbinenko
31747dd521 * grub-core/tests/gfxterm_menu.c (gfxterm_menu): Handle out-of-memory
condition.
	* tests/grub_func_test.in: Increase memory allocation.
2013-11-12 00:44:00 +01:00
Vladimir Serbinenko
6a74c4dfff * grub-core/osdep/unix/getroot.c [HAVE_STRUCT_STATFS_F_FSTYPENAME
&& HAVE_STRUCT_STATFS_F_MNTFROMNAME]: Include sys/param.h and
	sys/mount.h.
2013-11-11 23:10:30 +01:00
Vladimir Serbinenko
394c3e0ac2 * grub-core/osdep/apple/hostdisk.c (grub_util_get_fd_size): Rename to ..
(grub_util_get_fd_size_os): ...this.
	(grub_hostdisk_flush_initial_buffer): New empty function.
2013-11-11 23:08:51 +01:00
Vladimir Serbinenko
60d31116c2 * grub-core/gensyminfo.sh.in: Handle the case of portable output
without --defined-only.
2013-11-11 23:05:53 +01:00
Vladimir Serbinenko
8445b0115f * grub-core/lib/i386/relocator_common.S [__APPLE__ && __x86_64__]: Use
rip-relative addressing in prologue.
2013-11-11 23:02:51 +01:00
Vladimir Serbinenko
8506a64149 * include/grub/misc.h [__APPLE__]: Do not add regparm(0) on x86_64.
* grub-core/kern/misc.c (__bzero) [__APPLE__]: New function.
2013-11-11 22:53:30 +01:00
Vladimir Serbinenko
66acd9d64c * util/getroot.c (grub_util_biosdisk_get_grub_dev) [__APPLE__]:
Add missing semicolon.
2013-11-11 22:49:52 +01:00
Vladimir Serbinenko
348d05359c * util/grub-macho2img.c: Use plain fopen rather than grub_util_fopen. 2013-11-11 22:48:43 +01:00
Vladimir Serbinenko
0d2d30bb39 * configure.ac: Check for lzma.h for enabling liblzma and allow
manual disabling.
2013-11-11 22:47:48 +01:00
Vladimir Serbinenko
631187be8c Add missing includes of loader.h. 2013-11-11 02:30:09 +01:00
Fam Zheng
e756ec8284 * util/grub.d/30_os-prober.in: Add minix entry. 2013-11-11 00:24:49 +01:00
Vladimir Serbinenko
87d62d7d29 * grub-core/loader/i386/coreboot/chainloader.c (load_segment): Use
right buffer for temporary load.
2013-11-11 00:06:52 +01:00
Vladimir Serbinenko
5460cfeba8 * grub-core/loader/i386/coreboot/chainloader.c: Support tianocore. 2013-11-10 23:26:25 +01:00
Vladimir Serbinenko
8997730612 * grub-core/loader/i386/coreboot/chainloader.c: Support lzma-compressed
payload.
2013-11-10 20:53:27 +01:00
Vladimir Serbinenko
3617c59bab * include/grub/lib/LzmaDec.h: Fix to include LzmaTypes.h and
not Types.h.
	* grub-core/lib/LzmaDec.c: Fix prologue to make it compileable in GRUB
	environment.
	(LzmaDec_InitDicAndState): Make static.
2013-11-10 20:37:01 +01:00
Vladimir Serbinenko
881c6a1049 * util/grub-mkimagexx.c (generate_elf): Fix module address on coreboot. 2013-11-10 19:34:19 +01:00
Vladimir Serbinenko
2024ade285 * grub-core/term/ieee1275/escc.c (GRUB_MOD_INIT): Fix order of channels.
Reported by: Aaro Koskinen <aaro.koskinen@iki.fi>
2013-11-10 17:53:11 +01:00
Vladimir Serbinenko
674ad4f6bc * docs/grub-dev.texi: Replace bzr references with git ones. 2013-11-10 17:48:42 +01:00
Andrey Borzenkov
5b99970eb7 grub-reboot no more sets saved_default
Remove reference to grub-default from description of saved default entry.

Also mention that GRUB_DEFAULT=saved depends on availability of environment
block.
2013-11-10 18:24:27 +04:00
Andrey Borzenkov
80cfd940cc ChangeLog entry for 5645cc7995 2013-11-10 18:20:23 +04:00
Vladimir Serbinenko
3c2304d55f * configure.ac: Make efiemu test cflags match the cflags efiemu is
compiled with.
2013-11-10 14:46:13 +01:00
Andrey Borzenkov
5645cc7995 document GRUB_DISABLE_SUBMENU
Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>
2013-11-10 17:40:47 +04:00
Vladimir Serbinenko
33690255c5 Fix grub_machine_fini bitrot.
Reported by: Glenn Washburn.
2013-11-10 13:33:26 +01:00
Vladimir Serbinenko
c61471fc8b * configure.ac: Remove leftover -fnested-funcions -Wl,-allow_execute. 2013-11-10 13:24:06 +01:00
Vladimir Serbinenko
54da019fdb * grub-core/Makefile.am (efiemu): Remove leftover -DAPPLE_CC and
-DELF.
	* grub-core/efiemu/runtime/config.h: Use __i386__ and __x86_64__
	instead of ELF*.
2013-11-10 13:13:41 +01:00
Vladimir Serbinenko
28668d808e * configure.ac: Restore CFLAGS to TARGET_CFLAGS before external tests.
Add -march=core2 when testing compile of efiemu64.

	Thanks Andrey Borzenkov for spotting this.
2013-11-10 13:10:45 +01:00
Vladimir Serbinenko
9612ebc00e Add new ports: i386-xen and x86_64-xen. This allows running GRUB in
XEN PV environment and load kernels.
2013-11-09 21:29:11 +01:00
Vladimir Serbinenko
1a46a3a4b3 * grub-core/loader/i386/multiboot_mbi.c: Handle space in command line.
* grub-core/loader/multiboot_mbi2.c: Likewise.
2013-11-09 17:32:37 +01:00
Vladimir Serbinenko
2df1255117 * grub-core/lib/cmdline.c (grub_loader_cmdline_size): Fix empty cmdline
handling.
2013-11-09 17:31:21 +01:00
Vladimir Serbinenko
3c98038174 * grub-core/commands/i386/cmostest.c: Add new command "cmosset".
Tested by: Denis 'GNUtoo' Carikli.
2013-11-09 17:27:49 +01:00
Vladimir Serbinenko
800f63d38f * grub-core/normal/datetime.c (grub_get_weekday): Use unsigned types. 2013-11-08 19:14:03 +01:00
Vladimir Serbinenko
5620eb5332 * grub-core/gfxmenu/gui_circular_progress.c (parse_angle):
Use to get rounded angle rather than truncated.
2013-11-08 19:13:15 +01:00
Vladimir Serbinenko
9f8acdaa5d * grub-core/term/serial.c: Add option for enabling/disabling
RTS/CTS flow control.
2013-11-08 18:20:20 +01:00
Vladimir Serbinenko
2dc1eb6cbf * grub-core/lib/libgcrypt/cipher/idea.c (mul_inv): Remove signed
divisions.
2013-11-08 18:10:07 +01:00
Vladimir Serbinenko
b9563c9451 * grub-core/lib/libgcrypt/mpi/mpih-div.c (_gcry_mpih_divrem):
Use grub_fatal rather than divide by zero.
	* grub-core/lib/libgcrypt/mpi/mpi-pow.c (gcry_mpi_powm): Likewise.
2013-11-08 16:33:48 +01:00
Vladimir Serbinenko
d6d8e9a93e * include/grub/gui.h (grub_fixed_sfs_divide): Round rather than
truncate.
	(grub_fixed_fsf_divide): Likewise.
2013-11-08 16:17:29 +01:00
Vladimir Serbinenko
d06de6c871 * grub-core/gfxmenu/gui_list.c (draw_scrollbar): Avoid
division by-zero and senseless negative divisions.
2013-11-08 15:44:39 +01:00
Vladimir Serbinenko
6af7d49b92 * grub-core/gfxmenu/gui_circular_progress.c (circprog_paint): Avoid
division by-zero and senseless negative divisions.
	(circprog_set_property): Don't accept negative num_ticks.
2013-11-08 15:43:07 +01:00
Vladimir Serbinenko
bcfa6d72e3 * grub-core/gfxmenu/gui_progress_bar.c (draw_pixmap_bar): Avoid
division by-zero and senseless negative divisions.
2013-11-08 15:38:58 +01:00
Vladimir Serbinenko
dd7f792c85 * configure.ac: Use elf_*_fbsd on kfreebsd. 2013-11-08 15:10:13 +01:00
Vladimir Serbinenko
d061fda7e9 * grub-core/tests/div_test.c: New test. 2013-11-08 15:01:59 +01:00
Vladimir Testov
4db2250000 * grub-core/gfxmenu/gui_box.c: Updated to work with area status.
* grub-core/gfxmenu/gui_canvas.c: Likewise.
        * grub-core/gfxmenu/view.c: Likewise.
        * grub-core/video/fb/video_fb.c: Introduce new functions:
        grub_video_set_area_status, grub_video_get_area_status,
        grub_video_set_region, grub_video_get_region.
        * grub-core/video/bochs.c: Likewise.
        * grub-core/video/capture.c: Likewise.
        * grub-core/video/video.c: Likewise.
        * grub-core/video/cirrus.c: Likewise.
        * grub-core/video/efi_gop.c: Likewise.
        * grub-core/video/efi_uga.c: Likewise.
        * grub-core/video/emu/sdl.c: Likewise.
        * grub-core/video/radeon_fuloong2e.c: Likewise.
        * grub-core/video/sis315pro.c: Likewise.
        * grub-core/video/sm712.c: Likewise.
        * grub-core/video/i386/pc/vbe.c: Likewise.
        * grub-core/video/i386/pc/vga.c: Likewise.
        * grub-core/video/ieee1275.c: Likewise.
        * grub-core/video/i386/coreboot/cbfb.c: Likewise.
        * include/grub/video.h: Likewise.
        * include/grub/video_fb.h: Likewise.
        * include/grub/fbfill.h: Updated render_target structure.
        grub_video_rect_t viewport, region, area
        int area_offset_x, area_offset_y, area_enabled
        * include/grub/gui.h: New helper function
        grub_video_bounds_inside_region.
        * docs/grub-dev.texi: Added information about new functions.
2013-11-08 15:42:38 +04:00
Vladimir Serbinenko
c6b755df45 * grub-core/kern/mm.c (grub_real_malloc): Use AND rather than MOD
for alignment.
2013-11-08 09:43:26 +01:00
Vladimir Serbinenko
e2a6810069 * grub-core/lib/reed_solomon.c (grub_reed_solomon_recover): Add
missing attribute.
	* grub-core/gdb/cstub.c (grub_gdb_trap): Likewise.
2013-11-08 09:27:56 +01:00
Vladimir Serbinenko
c4f11a2a99 * grub-core/kern/misc.c (grub_divmod64): Don't fallback to
simple division on arm and ia64.
2013-11-08 09:07:33 +01:00
Vladimir Serbinenko
e0a7bffa1e * grub-core/kern/arm/misc.S (__aeabi_unwind_cpp_pr0): Add dummy to
link with libgcc.
2013-11-08 07:35:13 +01:00
Vladimir Serbinenko
38b864eaa1 * include/grub/symbol.h (FUNCTION), (VARIABLE): Fix precedence logic. 2013-11-08 07:16:15 +01:00
Vladimir Serbinenko
12359faff0 * include/grub/symbol.h (FUNCTION), (VARIABLE) [__arm__]: Use % as
prefix symbol, not @.
2013-11-08 07:08:27 +01:00
Vladimir Serbinenko
9fdc64a927 * INSTALL: Add note about older gcc and clang. 2013-11-08 06:05:54 +01:00
Vladimir Serbinenko
665c575b2a * tests/util/grub-shell.in: Boot as hdd on ppc by default. 2013-11-08 05:22:36 +01:00
Vladimir Serbinenko
47dcf7b176 * grub-core/loader/multiboot_mbi2.c (grub_multiboot_add_module): Fix
NULL pointer dereference.
2013-11-08 04:59:46 +01:00
Vladimir Serbinenko
d59849b2e7 * grub-core/Makefile.am: Do not include libgcc.h when compiling with
clang.
2013-11-07 19:33:54 +01:00
Vladimir Serbinenko
7a3f4a18d1 * grub-core/kern/powerpc/dl.c: Add missing pragma to silence cast-align
warnings.
2013-11-07 19:33:00 +01:00
Vladimir Serbinenko
7f084087b2 * grub-core/net/net.c (grub_net_route_unregister): Remove unused
function.
	* grub-core/loader/i386/xnu.c (hextoval): Likewise.
	* grub-core/disk/geli.c (ascii2hex): Likewise.
2013-11-07 19:31:22 +01:00
Vladimir Serbinenko
d5524ca87b * configure.ac: Run linker tests without -Werror.
Define TARGET_LDFLAGS_STATIC_LIBGCC and TARGET_LIBGCC.
	Change all occurences of -static-libgcc resp -lgcc to
	TARGET_LDFLAGS_STATIC_LIBGCC resp TARGET_LIBGCC.
2013-11-07 18:21:22 +01:00
Vladimir Serbinenko
390cd7ca90 * configure.ac: Don't add -no-itegrated-as on clang on non-x86. 2013-11-07 18:18:43 +01:00
Vladimir Serbinenko
60375a88fe Allow compiling with clang (not really supported though).
* conf/Makefile.common (CFLAGS_PLATFORM): Don't add -mrtd -mregparm=3
	unconditionally.
	* configure.ac: Add -no-integrated-as when using clangfor asm files.
	Add -mrtd -mregparm=3 on i386 when not using clang.
	* grub-core/kern/misc.c (grub_memset): Add volatile when on clang.
2013-11-07 11:44:40 +01:00
Vladimir Serbinenko
dd07e0c4cf * grub-core/kern/ieee1275/cmain.c: Add explicit attribute on asm
bindings.
	* grub-core/lib/reed_solomon.c: Likewise.
	* include/grub/i386/gdb.h: Likewise.
	* include/grub/i386/pc/int.h: Likewise.
	* include/grub/i386/pc/pxe.h: Likewise.
	* include/grub/ieee1275/ieee1275.h: Likewise.
2013-11-07 10:30:32 +01:00
Vladimir Serbinenko
9d3ae8ecbb missing Changelog entry 2013-11-07 06:37:01 +01:00
Vladimir Serbinenko
d1307d873a Import libgcrypt 1.5.3. 2013-11-07 06:35:50 +01:00
Vladimir Serbinenko
c12936c5d1 * configure.ac: Don't add -Wcast-align on x86. 2013-11-07 03:35:25 +01:00
Vladimir Serbinenko
cdc17f60dc * configure.ac: Add -freg-struct-return on all platforms that
support it.
2013-11-07 03:33:20 +01:00
Vladimir Serbinenko
b35ec29927 * acinclude.m4: Use -Werror on parameter tests.
* configure.ac: Likewise.
2013-11-07 03:31:24 +01:00
Vladimir Serbinenko
05f3a0d754 * acinclude.m4: Add missing TARGET_CCASFLAGS on asm tests. 2013-11-07 03:29:07 +01:00
Vladimir Serbinenko
c966a489cf * configure.ac: Check that -malign-loops works rather than assuming that
either -falign-loops or -malign-loops work.
2013-11-07 03:25:30 +01:00
Vladimir Serbinenko
bb0c57ecd2 * configure.ac: Remove -fnested-functions. We don't need it anymore. 2013-11-07 03:19:55 +01:00
Vladimir Serbinenko
24f4e57c46 * configure.ac: Prevent cflags leaking to subsequent tests by always
resetting cflags to target_cflags in target tests.
2013-11-07 03:17:37 +01:00
Vladimir Serbinenko
ac319fbc90 * grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
function.
2013-11-07 02:53:43 +01:00
Vladimir Serbinenko
4bfe934cd1 * grub-core/kern/misc.c (grub_vsnprintf_real): Remove nested functions. 2013-11-07 02:49:50 +01:00
Vladimir Serbinenko
40a5bfde36 * grub-core/lib/arg.c (grub_arg_parse): Remove nested function. 2013-11-07 02:46:23 +01:00
Vladimir Serbinenko
a67c755ef1 * grub-core/normal/cmdline.c (grub_cmdline_get):
Remove nested functions.
2013-11-07 02:42:38 +01:00
Vladimir Serbinenko
87a04a2df6 * tests/test_sha512sum.in: Make it work on emu. 2013-11-07 02:41:09 +01:00
Vladimir Serbinenko
c03995d297 * grub-core/normal/charset.c (bidi_line_wrap): Eliminate nested
functions.
	(grub_bidi_line_logical_to_visual): Likewise.
2013-11-07 02:31:31 +01:00
Vladimir Serbinenko
ec0ebb3fc2 Remove vestiges of -Wunsafe-loop-optimisations.
* conf/Makefile.common (CFLAGS_GNULIB): Remove
	-Wno-unsafe-loop-optimisations.
	* grub-core/commands/legacycfg.c: Remove -Wunsafe-loop-optimisations
	pragma.
	* grub-core/io/gzio.c: Likewise.
	* grub-core/script/parser.y: Likewise.
	* grub-core/script/yylex.l: Likewise.
	* util/grub-mkfont.c: Likewise.
2013-11-07 02:25:31 +01:00
Vladimir Serbinenko
6ab537e324 * util/grub-mkfont.c (process_cursive): Remove nested function. 2013-11-07 02:13:30 +01:00
Vladimir Serbinenko
e6c368d468 * include/grub/misc.h (grub_dprintf): Use unnamed vararg.
(grub_boot_time): Likewise.
2013-11-07 01:23:06 +01:00
Vladimir Serbinenko
4f1cfd22d3 * include/grub/symbol.h (FUNCTION): Use @function rather than
"function".
	(VARIABLE): Likewise.
2013-11-07 01:18:21 +01:00
Vladimir Serbinenko
6d5a4ceefe * grub-core/net/bootp.c (OFFSET_OF): Explicitly cast to grub_size_t. 2013-11-07 01:11:36 +01:00
Vladimir Serbinenko
f06c2172c0 * grub-core/net/bootp.c (set_env_limn_ro): Make pointer const.
(parse_dhcp_vendor): Likewise.
2013-11-07 01:09:19 +01:00
Vladimir Serbinenko
7cb24eb5ff * util/grub-mkimagexx.c (relocate_symbols): Remove unneeded brackets. 2013-11-07 01:04:06 +01:00
Vladimir Serbinenko
f30c692c1f * grub-core/gettext/gettext.c (main_context), (secondary_context):
Define after defining type and not before.
2013-11-07 01:01:47 +01:00
Vladimir Serbinenko
8b66bb5d8d * grub-core/fs/zfs/zfscrypt.c (grub_ccm_decrypt): Return right error
type.
	(grub_gcm_decrypt): Likewise.
	(algo_decrypt): Likewise.
	(grub_zfs_decrypt_real): Transform error type.
2013-11-07 00:59:44 +01:00
Vladimir Serbinenko
5d17fd0fec * grub-core/disk/geli.c (geli_rekey): Fix error return type. 2013-11-07 00:57:21 +01:00
Vladimir Serbinenko
ac35a0f792 * grub-core/disk/usbms.c (grub_usbms_cbi_cmd): Fix error type.
(grub_usbms_cbi_reset): Likewise.
	(grub_usbms_bo_reset): Likewise.
	(grub_usbms_reset): Likewise.
	(grub_usbms_attach): Likewise.
	(grub_usbms_transfer_cbi): Likewise.
2013-11-07 00:55:17 +01:00
Vladimir Serbinenko
3ee0869734 * grub-core/io/lzopio.c (test_header): Simplify code and remove useless
"checksum = checksum;".
2013-11-07 00:51:28 +01:00
Vladimir Serbinenko
70bb6c855e * grub-core/fs/reiserfs.c (grub_reiserfs_iterate_dir): Fix type of
entry_type.
2013-11-07 00:48:04 +01:00
Vladimir Serbinenko
c7f34744c6 * grub-core/commands/legacycfg.c (grub_cmd_legacy_kernel): Fix
BIOS disk check.
2013-11-07 00:46:44 +01:00
Vladimir Serbinenko
3f63b4d89f * grub-core/bus/usb/ehci.c (grub_ehci_restore_hw): Return right enum
type.
	(grub_ehci_fini_hw): Likewise.
	* grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Likewise.
2013-11-07 00:45:15 +01:00
Vladimir Serbinenko
dac6ce73be * include/grub/usb.h (grub_usb_controller_dev): Make portstatus
return grub_usb_err_t for cosistency. All users updated.
2013-11-07 00:35:56 +01:00
Vladimir Serbinenko
5701750c2c * util/mkimage.c (SzAlloc): Use attribute unused rather than dubious
assigning to itself.
2013-11-07 00:30:41 +01:00
Gustavo Luiz Duarte
9e236169e9 issue separate DNS queries for ipv4 and ipv6
Adding multiple questions on a single DNS query is not supportted by
most DNS servers. This patch issues two separate DNS queries
sequentially for ipv4 and then for ipv6.

Fixes: https://savannah.gnu.org/bugs/?39710

 * grub-core/net/bootp.c (parse_dhcp_vendor): Add DNS option.
 * grub-core/net/dns.c (grub_dns_qtype_id): New enum.
 * (grub_net_dns_lookup): Now using separated dns packages.
 * (grub_cmd_nslookup): Add error condition.
 * (grub_cmd_list_dns): Print DNS option.
 * (grub_cmd_add_dns): Add four parameters: --only-ipv4,
 * --only-ipv6, --prefer-ipv4, and --prefer-ipv6.
 * include/grub/net.h (grub_dns_option_t): New enum.
 * (grub_net_network_level_address): option added.

Also-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
2013-11-05 17:41:16 -02:00
Vladimir Testov
339eacce1b * grub-core/video/fb/video_fb.c: Merge two blit functions
into one.
2013-11-05 21:46:16 +04:00
Vladimir Serbinenko
810f991b9e * grub-core/term/terminfo.c: Add sequences for home and end. 2013-11-05 02:44:31 +01:00
Vladimir Serbinenko
386571a24b * grub-core/lib/legacy_parse.c: Fix handling of hercules and add
graphics console.
2013-11-05 02:43:27 +01:00
Vladimir Serbinenko
3fe63754d2 * grub-core/video/i386/pc/vga.c: Fix double bufferring and
add mode 0x12.
2013-11-05 02:41:50 +01:00
Vladimir Serbinenko
76681e714e * docs/grub.texi (Vendor power-on keys): Add XPS M1330M based on old
e-mail by Per Öberg.
2013-11-04 22:04:22 +01:00
Vladimir Serbinenko
46522fb7bd * grub-core/commands/i386/nthibr.c (GRUB_MOD_INIT): Fix typo in command
name.
2013-11-04 14:27:09 +01:00
Andrey Borzenkov
e7d09ac4f7 enable emuusb and emupci on emu platform only
Also explicitly disable them in configure unless built for emu platform.

Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>
2013-11-04 16:53:39 +04:00
Vladimir Serbinenko
67508925d0 * docs/grub.texi: Document usage of menuentry id. 2013-11-04 05:15:15 +01:00
Vladimir Serbinenko
0c62124eb5 * docs/grub.texi: Add few mentions about EFI, debug and videoinfo. 2013-11-04 02:18:02 +01:00
Peter Lustig
9b5d4eed31 * grub-core/commands/i386/nthibr.c: New command. 2013-11-04 01:47:37 +01:00
Vladimir Serbinenko
79054c1d1e * grub-core/tests/video_checksum.c: Add 2560x1440 mode to testing. 2013-11-04 00:40:14 +01:00
Vladimir Serbinenko
44d47bbe6f * include/grub/term.h (grub_term_coordinate): Extend to 16-bit per
coordinate.
2013-11-04 00:39:13 +01:00
Vladimir Serbinenko
323de05ba2 Support GRUB_DISABLE_SUBMENU config.
Inspired by patch from Prarit Bhargava.
2013-11-04 00:15:31 +01:00
Vladimir Serbinenko
5a01722ebc * docs/grub.texi: Mention RSA support. 2013-11-03 19:04:02 +01:00
Vladimir Serbinenko
1106c3f072 * grub-core/commands/verify.c: Add RSA support. 2013-11-03 18:50:01 +01:00
Vladimir Serbinenko
bed78ef4e6 Revert "Attempts at ZFS options"
It was accidently committed to wrong branch

This reverts commit 0ee5cdfe9f.
2013-11-03 16:52:33 +01:00
Vladimir Serbinenko
0ee5cdfe9f Attempts at ZFS options 2013-11-03 16:40:32 +01:00
Vladimir Serbinenko
a1dcc2cb98 * grub-core/disk/ahci.c (grub_ahci_pciinit): Detect ATAPI devices.
* grub-core/disk/ata.c (grub_ata_identify): Use atapi_identify if
	device is known to be ATAPI.
2013-11-03 13:52:36 +01:00
Mike Frysinger
ee7fb780c8 * configure.ac: Don't add target-prefix. 2013-11-03 12:48:13 +01:00
Vladimir Serbinenko
5ade4a4248 * grub-core/commands/loadenv.c (grub_cmd_save_env): Remove unset
variables.
2013-11-03 06:17:31 +01:00
Vladimir Serbinenko
6cd660435e * grub-core/gettext/gettext.c (grub_gettext_init_ext): Ignore errors
if language is English.
2013-11-03 05:42:02 +01:00
Vladimir Serbinenko
090d7c81cf * grub-core/osdep/linux/getroot.c: Fix cast-align problems. 2013-11-03 00:43:49 +01:00
Vladimir Serbinenko
48145ea358 Fix last commit 2013-11-03 00:25:04 +01:00
Vladimir Serbinenko
dd614590c9 * configure.ac: Don't add -m32/-m64 on emu. 2013-11-02 22:46:01 +01:00
neil
a86865891a * grub-core/osdep/linux/blocklist.c: Include linux/types.h for some
broken linux headers.
2013-11-02 22:19:34 +01:00
Vladimir Serbinenko
fb9f12a02d * util/grub.d/30_os-prober.in: Add unhiding of partition if on msdos. 2013-11-02 22:00:59 +01:00
Vladimir Serbinenko
e25f8e1f37 * grub-core/lib/reed_solomon.c (grub_reed_solomon_recover): Don't do
Reed-Solomon recovery if more than half of redundancy info is 0.
2013-11-02 21:28:03 +01:00
Vladimir Serbinenko
4685200fa9 * util/grub-mount.c: Handle symlinks to directories. 2013-11-02 20:30:39 +01:00
Vladimir Serbinenko
1397f0b520 * grub-core/fs/fshelp.c (find_file): Save ctx->next when calling
find_file recursively for symlink.
2013-11-02 20:29:02 +01:00
Vladimir Serbinenko
8b3e6eb6b6 * tests/util/grub-shell.in: Copy themes. 2013-11-02 19:17:25 +01:00
Vladimir Serbinenko
a0c9d5c6d9 * util/grub-mkimagexx.c (locate_sections): Reject mislinked images. 2013-11-02 19:16:36 +01:00
Vladimir Serbinenko
5cf9459c08 * configure.ac: Use 0x8000 for address instead of 8000. 2013-11-02 19:13:41 +01:00
Vladimir Serbinenko
e7b66a28de * grub-core/loader/sparc64/ieee1275/linux.c (get_physbase): Fix
signature.
2013-11-02 18:57:35 +01:00
Vladimir Serbinenko
203f53fbbe * grub-core/disk/efi/efidisk.c (grub_efidisk_readwrite): Remove unused
variable.
2013-11-02 18:50:39 +01:00
Vladimir Serbinenko
02663ee9d9 * configure.ac (TARGET_CFLAGS): Add -march=i386 on i386. 2013-11-02 16:40:25 +01:00
Vladimir Serbinenko
f169f65e75 * grub-core/fs/hfspluscomp.c (hfsplus_read_compressed_real): Call
file_progress_read_hook.
	* grub-core/fs/ntfscomp.c (hfsplus_read_compressed_real): Likewise.
2013-11-02 16:30:53 +01:00
Vladimir Serbinenko
2855a0fcce * conf/Makefile.common (CFLAGS_PLATFORM): Remove poisoning of float
and double.
2013-11-02 16:25:13 +01:00
Vladimir Serbinenko
bf0f3a8c3e * grub-core/fs/tar.c (grub_cpio_read): Add read_hook. 2013-11-01 23:33:59 +01:00
Vladimir Serbinenko
cb72aa1809 Rewrite blocklist functions in order to get progress when
reading large extents and decrease amount of blocklist hook calls.
2013-11-01 23:28:03 +01:00
Vladimir Serbinenko
896f913571 * grub-core/term/serial.c (options), (grub_cmd_serial): Fix handling
of SI suffixes.
2013-11-01 19:46:30 +01:00
Vladimir Serbinenko
89295a0628 Support --base-clock for serial command to handle weird cards with
non-standard base clock.
2013-11-01 19:33:22 +01:00
Vladimir Serbinenko
eb03ede014 * grub-core/fs/ext2.c (grub_ext2_read_symlink): Use memcpy rather
strncpy.
	* grub-core/fs/jfs.c (grub_jfs_lookup_symlink): Likewise.
	* grub-core/kern/misc.c (grub_strncpy): Move from here ...
	* include/grub/misc.h (grub_strncpy): ... to here. Make inline.
	* grub-core/net/net.c (grub_net_addr_to_str): Use COMPILE_TIME_ASSERT
	+ strcpy rather than strncpy.
2013-11-01 18:44:46 +01:00
Vladimir Serbinenko
8fbe5c7df7 * grub-core/fs/zfs/zfs.c (nvpair_name): Use correct type for size.
(check_pool_label): Likewise. Fixes overflow.
	(nvlist_find_value): Fix comparison.
2013-11-01 18:41:52 +01:00
Vladimir Serbinenko
e54b8f536b * include/grub/misc.h (grub_strcat): Removed. All users changed to
more appropriate functions.
2013-11-01 16:27:37 +01:00
Vladimir Serbinenko
fa9b3dcae2 * grub-core/kern/efi/efi.c (grub_efi_get_filename): Avoid inefficient
realloc.
2013-11-01 16:06:51 +01:00
Vladimir Serbinenko
9a021c5580 * util/grub-mkrescue.in: Do not use UUID search on EFI. 2013-11-01 16:05:15 +01:00
Vladimir Serbinenko
80e8b13ac4 * grub-core/kern/dl.c: Unify section-finding algorithm. Saves 30 bytes
on core size.
2013-11-01 15:20:14 +01:00
Vladimir Serbinenko
b61599aca4 * grub-core/kern/mm.c (grub_realloc): Don't copy more data than we have. 2013-11-01 14:39:33 +01:00
Vladimir Serbinenko
a602dc5425 * grub-core/io/gzio.c (huft_build): Use zalloc for safety.
(initialize_tables): reset tl and td to NULL after freeing.
2013-10-30 11:58:00 +01:00
Vladimir Serbinenko
93c120754a * grub-core/loader/multiboot_mbi2.c: Implement network tag. 2013-10-28 15:53:39 +01:00
Vladimir Serbinenko
1ca4b75ec2 * grub-core/loader/multiboot_mbi2.c: Add EFI memory map to the list
of supported tags.
2013-10-28 15:40:34 +01:00
Vladimir Serbinenko
329550c4a9 * grub-core/loader/multiboot_mbi2.c: Implement EFI memory map. 2013-10-28 15:37:00 +01:00
Vladimir Serbinenko
00bfa988fc * grub-core/loader/multiboot.c: Add support for multiboot kernels
quirks.
2013-10-28 15:23:46 +01:00
Vladimir Serbinenko
81afc5cce6 * grub-core/loader/i386/linux.c (allocate_pages): Allocate at least
a page in protected space.
2013-10-28 14:30:29 +01:00
Vladimir Serbinenko
cb3c4a4722 * grub-core/loader/multiboot.c (grub_cmd_module): Don't attempt to
allocate space for zero-sized modules.
2013-10-28 14:27:19 +01:00
Vladimir Serbinenko
954f7bf5ec * grub-core/loader/xnu_resume.c (grub_xnu_resume): Reject empty images. 2013-10-28 14:25:22 +01:00
Francesco Lavra
526d3d25e2 * grub-core/lib/fdt.c: Fix miscellaneous bugs. 2013-10-28 13:52:32 +01:00
Vladimir Serbinenko
74124c344c * grub-core/lib/progress.c (grub_file_progress_hook_real): Add missing
safeguards. Fixes a crash with i386/pc/console.c.
2013-10-28 13:37:40 +01:00
Vladimir Serbinenko
5177391ebe * include/grub/emu/hostdisk.h: Add proper declaration for grub_host_init
and grub_hostfs_init.
2013-10-28 13:33:12 +01:00
Vladimir Serbinenko
64db14b0cb * grub-core/kern/emu/hostdisk.c (grub_util_check_file_presence): Use
windows method on other platforms without good stat as well.
2013-10-28 02:17:56 +01:00
Vladimir Serbinenko
effe203677 * grub-core/osdep/linux/getroot.c: Add new btrfs defines. 2013-10-28 01:45:06 +01:00
Vladimir Serbinenko
82591fa6e7 Make / in btrfs refer to real root, not the default volume.
Modify mkrelpath to work even if device is mounted with subvolid option.
2013-10-28 01:37:19 +01:00
Andrey Borzenkov
11d81fc6d1 Merge branch 'fu/disk_common' 2013-10-27 23:45:43 +04:00
Vladimir Serbinenko
30fd7198fe * util/grub-mkfont.c (main): Show error message when FT_Set_Pixel_Sizes
fails.
2013-10-27 20:38:32 +01:00
BVK Chaitanya
8d179dae4e * docs/autoiso.cfg: New file. 2013-10-27 20:34:24 +01:00
Andrey Borzenkov
e11cb7268e Add grub-core/kern/disk_common.c to extra_dist 2013-10-27 22:55:11 +04:00
Vladimir Serbinenko
3bc9c8cfc8 * configure.ac: Remove leftover COND_BUILD_GRUB_MKFONT and
COND_GRUB_PE2ELF conditions.
2013-10-27 19:44:19 +01:00
Vladimir Serbinenko
c430e00b80 * grub-core/net/tftp.c: Retransmit ack when rereceiving old packet.
Try to handle more than 0xFFFF packets.
	Reported by: Bernhard Übelacker <bernhardu>.
	He also spotted few overflows in first version of this patch.
2013-10-27 19:15:57 +01:00
Vladimir Serbinenko
cf8d6bbd9e * grub-core/net/tftp.c: Retransmit ack when rereceiving old packet.
Try to handle more than 0xFFFF packets.
2013-10-27 19:15:37 +01:00
Vladimir Serbinenko
8b46b0ea36 * grub-core/loader/i386/bsd.c (grub_cmd_openbsd): Accept "sd", "cd",
"vnd", "rd" and "fd" disks.
2013-10-27 18:59:27 +01:00
666 changed files with 47061 additions and 11763 deletions

60
.gitignore vendored
View File

@@ -11,8 +11,9 @@ ahci_test
ascii.bitmaps
ascii.h
autom4te.cache
build_env.mk
.bzrignore
build-grub-gen-asciih
build-grub-gen-widthspec
build-grub-mkfont
cdboot_test
cmp_test
config.cache
@@ -30,47 +31,59 @@ docs/*.info
docs/stamp-vti
docs/version.texi
ehci_test
*.elf
example_grub_script_test
example_scripted_test
example_unit_test
*.exec
*.exec.exe
fddboot_test
genkernsyms.sh
gensymlist.sh
gentrigtables
gentrigtables.exe
gettext_strings_test
grub-bin2h
grub-bios-setup
/grub-bios-setup
/grub-bios-setup.exe
grub_cmd_date
grub_cmd_echo
grub_cmd_regexp
grub_cmd_set_date
grub_cmd_sleep
grub-editenv
/grub-editenv
/grub-editenv.exe
grub-emu
grub-emu-lite
grub-emu.exe
grub-emu-lite.exe
grub_emu_init.c
grub_emu_init.h
grub-fstest
grub-fstest.exe
grub_fstest_init.c
grub_fstest_init.h
grub_func_test
grub-install
grub-install.exe
grub-kbdcomp
grub-macho2img
grub-menulst2cfg
grub-mk*
/grub-menulst2cfg
/grub-menulst2cfg.exe
/grub-mk*
grub-mount
grub-ofpathname
grub-pe2elf
grub-probe
/grub-ofpathname
/grub-ofpathname.exe
grub-core/build-grub-pe2elf.exe
/grub-probe
/grub-probe.exe
grub_probe_init.c
grub_probe_init.h
grub-reboot
/grub-reboot
grub_script_blanklines
grub_script_blockarg
grub_script_break
grub-script-check
grub-script-check.exe
grub_script_check_init.c
grub_script_check_init.h
grub_script_comments
@@ -101,17 +114,18 @@ grub_script.tab.h
grub_script.yy.c
grub_script.yy.h
grub-set-default
grub-setup
grub_setup_init.c
grub_setup_init.h
grub-shell
grub-shell-tester
grub-sparc64-setup
grub-sparc64-setup.exe
gzcompress_test
hddboot_test
help_test
*.img
*.image
*.image.exe
include/grub/cpu
include/grub/machine
install-sh
@@ -127,6 +141,7 @@ mod-*.c
missing
netboot_test
*.o
*.a
ohci_test
partmap_test
pata_test
@@ -155,16 +170,15 @@ GPATH
GRTAGS
GSYMS
GTAGS
Makefile.tpl
compile
depcomp
mdate-sh
texinfo.tex
grub-core/lib/libgcrypt-grub
**/.deps
**/.deps-util
**/.deps-core
**/.dirstamp
.deps
.deps-util
.deps-core
.dirstamp
Makefile.util.am
contrib
grub-core/bootinfo.txt
@@ -178,6 +192,7 @@ grub-core/gmodule.pl
grub-core/grub.chrp
grub-core/modinfo.sh
grub-core/*.module
grub-core/*.module.exe
grub-core/*.pp
util/bash-completion.d/grub
grub-core/gnulib/alloca.h
@@ -199,7 +214,7 @@ grub-core/gnulib/unistd.h
grub-core/gnulib/warn-on-use.h
grub-core/gnulib/wchar.h
grub-core/gnulib/wctype.h
grub-core/rs_decoder.S
grub-core/rs_decoder.h
widthspec.bin
widthspec.h
docs/stamp-1
@@ -213,9 +228,14 @@ include/grub/gcrypt/gcrypt.h
include/grub/gcrypt/g10lib.h
po/POTFILES.in
po/POTFILES-shell.in
grub-glue-efi
grub-render-label
/grub-glue-efi
/grub-render-label
/grub-glue-efi.exe
/grub-render-label.exe
grub-core/gnulib/locale.h
grub-core/gnulib/unitypes.h
grub-core/gnulib/uniwidth.h
build-aux/test-driver
/garbage-gen
/garbage-gen.exe
/grub-fs-tester

3058
ChangeLog

File diff suppressed because it is too large Load Diff

20
INSTALL
View File

@@ -12,6 +12,23 @@ you don't have any of them, please obtain and install them before
configuring the GRUB.
* GCC 4.1.3 or later
Note: older versions may work but support is limited
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
much bigger binaries.
earlier versions not tested
Note: clang 3.2 or later works for arm
None of tested clang versions generated usable thumb code
earlier versions not tested
Note: clang 3.3 or later works for arm64
earlier versions have no arm64 support
Note: clang 3.3 or later works for mips(el)
earlier versions fail to generate .reginfo and hence gprel relocations
fail.
Note: clang 3.2 or later works for powerpc
earlier versions not tested
Note: clang doesn't support -mno-app-regs and so can't be used for sparc64
Note: clang has no support for ia64 and hence you can't compile GRUB
for ia64 with clang
* GNU Make
* GNU Bison 2.3 or later
* GNU gettext 0.17 or later
@@ -37,10 +54,9 @@ To build GRUB's graphical terminal (gfxterm), you need:
If you use a development snapshot or want to hack on GRUB you may
need the following.
* Python 2.5.2 or later
* Python 2.6 or later
* Autoconf 2.60 or later
* Automake 1.10.1 or later
* Autogen 5.10 or later
Prerequisites for make-check:

View File

@@ -68,12 +68,20 @@ starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/s
build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
CLEANFILES += build-grub-mkfont
garbage-gen: util/garbage-gen.c
$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^
CLEANFILES += garbage-gen
EXTRA_DIST += util/garbage-gen.c
build-grub-gen-asciih: util/grub-gen-asciih.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-asciih
build-grub-gen-widthspec: util/grub-gen-widthspec.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-widthspec
if COND_STARFIELD
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
@@ -88,14 +96,14 @@ dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE)
else
starfield_DATA =
starfield_DATA =
endif
EXTRA_DIST += $(starfield_theme_files)
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE)
./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
CLEANFILES += unicode.pf2
# Arrows and lines are needed to draw the menu, so always include them
@@ -103,19 +111,19 @@ UNICODE_ARROWS=0x2190-0x2193
UNICODE_LINES=0x2501-0x251B
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += ascii.pf2
euro.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += euro.pf2
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
./build-grub-gen-asciih $(FONT_SOURCE) $@
./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += ascii.h
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
./build-grub-gen-widthspec $(FONT_SOURCE) $@
./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += widthspec.h
# Install config.h into platformdir
@@ -389,4 +397,33 @@ BOOTCHECK_TIMEOUT=180
bootcheck: $(BOOTCHECKS)
if COND_i386_coreboot
default_payload.elf: grub-mkstandalone grub-mkimage
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
endif
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
test -d $(windowsdir) && rm -rf $(windowsdir) || true
test -d $(windowsdir) || mkdir $(windowsdir)
$(MAKE) -C po $(AM_MAKEFLAGS) windowsdir
$(MAKE) -C grub-core $(AM_MAKEFLAGS) windowsdir
test -d $(windowsdir)/themes || mkdir $(windowsdir)/themes
test -d $(windowsdir)/themes/starfield || mkdir $(windowsdir)/themes/starfield
for x in $(PROGRAMS); do \
if [ x$(STRIP) != x ]; then $(STRIP) $$x -o $(windowsdir)/$$x; \
else cp -fp $$x $(windowsdir)/$$x; fi; \
done
for x in $(pkgdata_DATA); do \
cp -fp $$x $(windowsdir)/$$x; \
done
for x in $(starfield_DATA); do \
cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \
done
windowszip=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows.zip
windowszip: windowsdir
test -f $(windowszip) && rm $(windowszip) || true
zip -r $(windowszip) $(windowsdir)
EXTRA_DIST += linguas.sh

View File

@@ -15,6 +15,7 @@ library = {
common = grub-core/osdep/getroot.c;
common = grub-core/osdep/devmapper/getroot.c;
common = grub-core/osdep/relpath.c;
extra_dist = grub-core/kern/disk_common.c;
extra_dist = grub-core/osdep/unix/relpath.c;
extra_dist = grub-core/osdep/aros/relpath.c;
extra_dist = grub-core/osdep/windows/relpath.c;
@@ -61,6 +62,7 @@ library = {
common_nodist = grub_script.tab.h;
common = grub-core/commands/blocklist.c;
common = grub-core/commands/macbless.c;
common = grub-core/commands/xnu_uuid.c;
common = grub-core/commands/testload.c;
common = grub-core/commands/ls.c;
@@ -117,6 +119,7 @@ library = {
common = grub-core/fs/sfs.c;
common = grub-core/fs/squash4.c;
common = grub-core/fs/tar.c;
common = grub-core/fs/greffs.c;
common = grub-core/fs/udf.c;
common = grub-core/fs/ufs2.c;
common = grub-core/fs/ufs.c;
@@ -153,8 +156,11 @@ library = {
common = grub-core/script/script.c;
common = grub-core/script/argv.c;
common = grub-core/io/gzio.c;
common = grub-core/io/xzio.c;
common = grub-core/io/lzopio.c;
common = grub-core/kern/ia64/dl_helper.c;
common = grub-core/kern/arm/dl_helper.c;
common = grub-core/kern/arm64/dl_helper.c;
common = grub-core/lib/minilzo/minilzo.c;
common = grub-core/lib/xzembed/xz_dec_bcj.c;
common = grub-core/lib/xzembed/xz_dec_lzma2.c;
@@ -170,8 +176,11 @@ program = {
common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
common = grub-core/kern/arm/dl_helper.c;
common = grub-core/osdep/config.c;
extra_dist = grub-core/osdep/aros/config.c;
extra_dist = grub-core/osdep/windows/config.c;
extra_dist = grub-core/osdep/unix/config.c;
common = util/config.c;
extra_dist = util/grub-mkimagexx.c;
@@ -249,7 +258,7 @@ program = {
name = grub-macho2img;
mansection = 1;
common = util/grub-macho2img.c;
condition = COND_APPLE_CC;
condition = COND_APPLE_LINKER;
};
program = {
@@ -309,6 +318,7 @@ program = {
installdir = sbin;
mansection = 8;
common = util/grub-probe.c;
common = util/probe.c;
common = grub-core/osdep/ofpath.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
@@ -393,6 +403,21 @@ program = {
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
program = {
name = grub-macbless;
installdir = sbin;
mansection = 1;
common = util/grub-macbless.c;
common = grub-core/osdep/init.c;
common = grub-core/kern/emu/argp_common.c;
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
data = {
common = util/grub.d/README;
installdir = grubconf;
@@ -415,49 +440,42 @@ script = {
name = '10_hurd';
common = util/grub.d/10_hurd.in;
installdir = grubconf;
condition = COND_HOST_HURD;
};
script = {
name = '10_kfreebsd';
common = util/grub.d/10_kfreebsd.in;
installdir = grubconf;
condition = COND_HOST_KFREEBSD;
};
script = {
name = '10_illumos';
common = util/grub.d/10_illumos.in;
installdir = grubconf;
condition = COND_HOST_ILLUMOS;
};
script = {
name = '10_netbsd';
common = util/grub.d/10_netbsd.in;
installdir = grubconf;
condition = COND_HOST_NETBSD;
};
script = {
name = '10_linux';
common = util/grub.d/10_linux.in;
installdir = grubconf;
condition = COND_HOST_LINUX;
};
script = {
name = '10_xnu';
common = util/grub.d/10_xnu.in;
installdir = grubconf;
condition = COND_HOST_XNU;
};
script = {
name = '20_linux_xen';
common = util/grub.d/20_linux_xen.in;
installdir = grubconf;
condition = COND_HOST_LINUX;
};
script = {
@@ -478,38 +496,161 @@ script = {
installdir = grubconf;
};
script = {
program = {
mansection = 1;
name = grub-mkrescue;
common = util/grub-install_header;
common = util/grub-mkrescue.in;
enable = noemu;
common = util/grub-mkrescue.c;
common = util/render-label.c;
common = util/glue-efi.c;
common = util/mkimage.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
common = grub-core/lib/reed_solomon.c;
common = grub-core/osdep/random.c;
common = grub-core/osdep/ofpath.c;
common = grub-core/osdep/platform.c;
common = grub-core/osdep/platform_unix.c;
common = grub-core/osdep/compress.c;
extra_dist = grub-core/osdep/unix/compress.c;
extra_dist = grub-core/osdep/basic/compress.c;
common = util/editenv.c;
common = grub-core/osdep/blocklist.c;
common = grub-core/osdep/config.c;
common = util/config.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
ldadd = '$(LIBLZMA)';
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
condition = COND_HAVE_EXEC;
};
script = {
program = {
mansection = 1;
name = grub-mkstandalone;
common = util/grub-install_header;
common = util/grub-mkstandalone.in;
common = util/grub-mkstandalone.c;
common = util/render-label.c;
common = util/glue-efi.c;
common = util/mkimage.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
common = grub-core/lib/reed_solomon.c;
common = grub-core/osdep/random.c;
common = grub-core/osdep/ofpath.c;
common = grub-core/osdep/platform.c;
common = grub-core/osdep/platform_unix.c;
extra_dist = grub-core/osdep/linux/platform.c;
extra_dist = grub-core/osdep/windows/platform.c;
extra_dist = grub-core/osdep/basic/platform.c;
extra_dist = grub-core/osdep/basic/no_platform.c;
extra_dist = grub-core/osdep/unix/platform.c;
common = grub-core/osdep/compress.c;
common = util/editenv.c;
common = grub-core/osdep/blocklist.c;
common = grub-core/osdep/config.c;
common = util/config.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
ldadd = '$(LIBLZMA)';
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
script = {
program = {
mansection = 8;
installdir = sbin;
name = grub-install;
common = util/grub-install_header;
common = util/grub-install.in;
common = util/grub-install.c;
common = util/probe.c;
common = util/mkimage.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
common = grub-core/lib/reed_solomon.c;
common = grub-core/osdep/random.c;
common = grub-core/osdep/ofpath.c;
common = grub-core/osdep/platform.c;
common = grub-core/osdep/platform_unix.c;
common = grub-core/osdep/compress.c;
common = util/editenv.c;
common = grub-core/osdep/blocklist.c;
common = grub-core/osdep/config.c;
common = util/config.c;
common = util/render-label.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
common = util/resolve.c;
enable = noemu;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
ldadd = '$(LIBLZMA)';
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
script = {
program = {
mansection = 1;
installdir = bin;
name = grub-mknetdir;
common = util/grub-install_header;
common = util/grub-mknetdir.in;
common = util/grub-mknetdir.c;
common = util/mkimage.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
common = grub-core/lib/reed_solomon.c;
common = grub-core/osdep/random.c;
common = grub-core/osdep/ofpath.c;
common = grub-core/osdep/platform.c;
common = grub-core/osdep/platform_unix.c;
common = grub-core/osdep/compress.c;
common = util/editenv.c;
common = grub-core/osdep/blocklist.c;
common = grub-core/osdep/config.c;
common = util/config.c;
common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
ldadd = '$(LIBLZMA)';
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
script = {
@@ -557,6 +698,127 @@ script = {
installdir = noinst;
};
script = {
name = grub-fs-tester;
common = tests/util/grub-fs-tester.in;
installdir = noinst;
dependencies = garbage-gen;
};
script = {
testcase;
name = ext234_test;
common = tests/ext234_test.in;
};
script = {
testcase;
name = squashfs_test;
common = tests/squashfs_test.in;
};
script = {
testcase;
name = iso9660_test;
common = tests/iso9660_test.in;
};
script = {
testcase;
name = hfsplus_test;
common = tests/hfsplus_test.in;
};
script = {
testcase;
name = ntfs_test;
common = tests/ntfs_test.in;
};
script = {
testcase;
name = reiserfs_test;
common = tests/reiserfs_test.in;
};
script = {
testcase;
name = fat_test;
common = tests/fat_test.in;
};
script = {
testcase;
name = minixfs_test;
common = tests/minixfs_test.in;
};
script = {
testcase;
name = xfs_test;
common = tests/xfs_test.in;
};
script = {
testcase;
name = nilfs2_test;
common = tests/nilfs2_test.in;
};
script = {
testcase;
name = romfs_test;
common = tests/romfs_test.in;
};
script = {
testcase;
name = exfat_test;
common = tests/exfat_test.in;
};
script = {
testcase;
name = tar_test;
common = tests/tar_test.in;
};
script = {
testcase;
name = udf_test;
common = tests/udf_test.in;
};
script = {
testcase;
name = hfs_test;
common = tests/hfs_test.in;
};
script = {
testcase;
name = jfs_test;
common = tests/jfs_test.in;
};
script = {
testcase;
name = btrfs_test;
common = tests/btrfs_test.in;
};
script = {
testcase;
name = zfs_test;
common = tests/zfs_test.in;
};
script = {
testcase;
name = cpio_test;
common = tests/cpio_test.in;
};
script = {
testcase;
name = example_scripted_test;
@@ -974,6 +1236,24 @@ program = {
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
program = {
name = grub-syslinux2cfg;
mansection = 1;
common = util/grub-syslinux2cfg.c;
common = grub-core/lib/syslinux_parse.c;
common = grub-core/lib/getline.c;
common = grub-core/osdep/init.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
common = grub-core/kern/emu/argp_common.c;
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
program = {
name = grub-glue-efi;
mansection = 1;
@@ -1007,3 +1287,32 @@ program = {
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
program = {
name = grub-file;
mansection = 1;
common = util/grub-file.c;
common = util/render-label.c;
common = grub-core/commands/file.c;
common = grub-core/commands/file32.c;
common = grub-core/commands/file64.c;
common = grub-core/loader/i386/xen_file.c;
common = grub-core/loader/i386/xen_file32.c;
common = grub-core/loader/i386/xen_file64.c;
common = grub-core/io/offset.c;
common = grub-core/kern/elf.c;
common = grub-core/loader/lzss.c;
common = grub-core/loader/macho.c;
common = grub-core/loader/macho32.c;
common = grub-core/loader/macho64.c;
common = grub-core/kern/emu/hostfs.c;
common = grub-core/disk/host.c;
common = grub-core/osdep/init.c;
ldadd = libgrubmods.a;
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};

View File

@@ -19,6 +19,8 @@ AC_DEFUN([grub_PROG_TARGET_CC],
AC_CACHE_VAL(grub_cv_prog_target_cc,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_prog_target_cc=yes],
@@ -134,6 +136,29 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then
fi
])
dnl Check nm
AC_DEFUN([grub_PROG_NM_WORKS],
[AC_MSG_CHECKING([whether nm works])
AC_CACHE_VAL(grub_cv_prog_nm_works,
[
nm_works_tmp_dir="$(mktemp -d "./confXXXXXX")"
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_works_tmp_dir/ef"
if $TARGET_NM "$nm_works_tmp_dir/ef" > /dev/null; then
grub_cv_prog_nm_works=yes
else
grub_cv_prog_nm_minus_p=no
fi
rm "$nm_works_tmp_dir/ef"
rmdir "$nm_works_tmp_dir"
])
AC_MSG_RESULT([$grub_cv_prog_nm_works])
if test "x$grub_cv_prog_nm_works" != xyes; then
AC_MSG_ERROR([nm does not work])
fi
])
dnl Supply -P to nm
AC_DEFUN([grub_PROG_NM_MINUS_P],
[AC_MSG_CHECKING([whether nm accepts -P])
@@ -141,13 +166,14 @@ AC_CACHE_VAL(grub_cv_prog_nm_minus_p,
[
nm_minus_p_tmp_dir="$(mktemp -d "./confXXXXXX")"
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
$TARGET_CC conftest.c -o "$nm_minus_p_tmp_dir/ef"
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_minus_p_tmp_dir/ef"
if $TARGET_NM -P "$nm_minus_p_tmp_dir/ef" 2>&1 > /dev/null; then
grub_cv_prog_nm_minus_p=yes
else
grub_cv_prog_nm_minus_p=no
fi
rm "$nm_minus_p_tmp_dir/ef"
rmdir "$nm_minus_p_tmp_dir"
])
AC_MSG_RESULT([$grub_cv_prog_nm_minus_p])
@@ -165,13 +191,14 @@ AC_CACHE_VAL(grub_cv_prog_nm_defined_only,
[
nm_defined_only_tmp_dir="$(mktemp -d "./confXXXXXX")"
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
$TARGET_CC conftest.c -o "$nm_defined_only_tmp_dir/ef"
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_defined_only_tmp_dir/ef"
if $TARGET_NM --defined-only "$nm_defined_only_tmp_dir/ef" 2>&1 > /dev/null; then
grub_cv_prog_nm_defined_only=yes
else
grub_cv_prog_nm_defined_only=no
fi
rm "$nm_defined_only_tmp_dir/ef"
rmdir "$nm_defined_only_tmp_dir"
])
AC_MSG_RESULT([$grub_cv_prog_nm_defined_only])
@@ -212,7 +239,7 @@ else
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
fi
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
grub_cv_i386_asm_addr32=yes
else
grub_cv_i386_asm_addr32=no
@@ -222,37 +249,6 @@ rm -f conftest*])
AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
dnl check if our compiler is apple cc
dnl because it requires numerous workarounds
AC_DEFUN([grub_apple_cc],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether our compiler is apple cc])
AC_CACHE_VAL(grub_cv_apple_cc,
[if $CC -v 2>&1 | grep "Apple Inc." > /dev/null; then
grub_cv_apple_cc=yes
else
grub_cv_apple_cc=no
fi
])
AC_MSG_RESULT([$grub_cv_apple_cc])])
dnl check if our target compiler is apple cc
dnl because it requires numerous workarounds
AC_DEFUN([grub_apple_target_cc],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether our target compiler is apple cc])
AC_CACHE_VAL(grub_cv_apple_target_cc,
[if $CC -v 2>&1 | grep "Apple Inc." > /dev/null; then
grub_cv_apple_target_cc=yes
else
grub_cv_apple_target_cc=no
fi
])
AC_MSG_RESULT([$grub_cv_apple_target_cc])])
dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines.
@@ -266,7 +262,7 @@ AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement,
l1: addr32 movb %al, l1
EOF
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
grub_cv_i386_asm_prefix_requirement=yes
else
grub_cv_i386_asm_prefix_requirement=no
@@ -294,7 +290,12 @@ AC_DEFUN([grub_CHECK_BSS_START_SYMBOL],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if __bss_start is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);
]],
[[asm ("incl __bss_start")]])],
[grub_cv_check_uscore_uscore_bss_start_symbol=yes],
[grub_cv_check_uscore_uscore_bss_start_symbol=no])])
@@ -303,7 +304,11 @@ AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol])
AC_MSG_CHECKING([if edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_edata_symbol,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);]],
[[asm ("incl edata")]])],
[grub_cv_check_edata_symbol=yes],
[grub_cv_check_edata_symbol=no])])
@@ -312,7 +317,11 @@ AC_MSG_RESULT([$grub_cv_check_edata_symbol])
AC_MSG_CHECKING([if _edata is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);]],
[[asm ("incl _edata")]])],
[grub_cv_check_uscore_edata_symbol=yes],
[grub_cv_check_uscore_edata_symbol=no])])
@@ -336,7 +345,11 @@ AC_DEFUN([grub_CHECK_END_SYMBOL],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if end is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_end_symbol,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);]],
[[asm ("incl end")]])],
[grub_cv_check_end_symbol=yes],
[grub_cv_check_end_symbol=no])])
@@ -345,7 +358,11 @@ AC_MSG_RESULT([$grub_cv_check_end_symbol])
AC_MSG_CHECKING([if _end is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_end_symbol,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);]],
[[asm ("incl _end")]])],
[grub_cv_check_uscore_end_symbol=yes],
[grub_cv_check_uscore_end_symbol=no])])
@@ -391,7 +408,7 @@ AC_MSG_CHECKING([whether `$CC' accepts `-mstack-arg-probe'])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[
void foo (void) { volatile char a[8]; a[3]; }
]])])
[if eval "$ac_compile -S -mstack-arg-probe -o conftest.s" 2> /dev/null; then]
[if eval "$ac_compile -S -mstack-arg-probe -Werror -o conftest.s" 2> /dev/null; then]
AC_MSG_RESULT([yes])
[# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
rm -f conftest.s
@@ -480,23 +497,3 @@ dnl program.
AC_DEFUN([grub_TRANSFORM],[dnl
AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl
])
dnl Check if the C compiler supports `-mno-unaligned-access'.
AC_DEFUN([grub_CHECK_NO_UNALIGNED_ACCESS],[
[# foobar
nua_possible=yes]
AC_MSG_CHECKING([whether `$CC' supports `-mno-unaligned-access'])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[
int main() {
return 0;
}
]])])
[if eval "$ac_compile -S -mno-unaligned-access -o conftest.s" 2> /dev/null; then]
AC_MSG_RESULT([yes])
[rm -f conftest.s
else
nua_possible=no]
AC_MSG_RESULT([no])
[fi]
])

View File

@@ -8,8 +8,6 @@ unset LC_ALL
find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' |sort > po/POTFILES.in
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
autogen --version >/dev/null || exit 1
echo "Importing unicode..."
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
@@ -32,10 +30,7 @@ for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul
ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
done
echo "Creating Makefile.tpl..."
python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
echo "Running autogen..."
echo "Generating Automake input..."
# Automake doesn't like including files from a path outside the project.
rm -f contrib grub-core/contrib
@@ -59,8 +54,8 @@ for extra in contrib/*/Makefile.core.def; do
fi
done
cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
python gentpl.py $UTIL_DEFS > Makefile.util.am
python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then

View File

@@ -6,42 +6,28 @@ export LC_COLLATE := C
unexport LC_ALL
# Platform specific options
if COND_i386_pc
CFLAGS_PLATFORM += -mrtd -mregparm=3 -freg-struct-return
endif
if COND_i386_qemu
CFLAGS_PLATFORM += -mrtd -mregparm=3 -freg-struct-return
endif
if COND_i386_coreboot
CFLAGS_PLATFORM += -mrtd -mregparm=3 -freg-struct-return
endif
if COND_i386_ieee1275
CFLAGS_PLATFORM += -mrtd -mregparm=3 -freg-struct-return
endif
if COND_mips_loongson
CFLAGS_PLATFORM += -mexplicit-relocs
CPPFLAGS_PLATFORM = -DUSE_ASCII_FALLBACK
endif
if COND_mips
CFLAGS_PLATFORM += -mflush-func=grub_red_herring
CCASFLAGS_PLATFORM = -march=mips3
endif
if COND_sparc64_ieee1275
CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -Wl,--no-relax
endif
if COND_sparc64_emu
CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,--no-relax
endif
if COND_arm
CFLAGS_PLATFORM += -mthumb-interwork -mlong-calls
if !COND_emu
LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
endif
endif
if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large
endif
#FIXME: discover and check XEN headers
CPPFLAGS_XEN = -I/usr/include
# Other options
if ! COND_emu
CFLAGS_PLATFORM += -Dfloat=__grub_poison
CFLAGS_PLATFORM += -Ddouble=__grub_poison
endif
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
CPPFLAGS_DEFAULT += -I$(builddir)
CPPFLAGS_DEFAULT += -I$(srcdir)
@@ -49,38 +35,17 @@ CPPFLAGS_DEFAULT += -I$(top_builddir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
CPPFLAGS_DEFAULT += -I$(top_builddir)/include
CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/include
CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
LDADD_KERNEL =
if ! COND_i386_pc
if ! COND_i386_efi
if ! COND_i386_qemu
if ! COND_i386_coreboot
if ! COND_i386_multiboot
if ! COND_i386_ieee1275
if ! COND_x86_64_efi
LDADD_KERNEL += -lgcc
endif
endif
endif
endif
endif
endif
endif
LDADD_KERNEL = $(TARGET_LIBGCC)
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -static-libgcc
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
if COND_CYGWIN
STRIPFLAGS_KERNEL = -F elf32-i386 -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version
else
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .note.gnu.gold-version
endif
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
@@ -107,13 +72,13 @@ grubconfdir = $(sysconfdir)/grub.d
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
starfielddir = $(pkgdatadir)/themes/starfield
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition -Wno-unsafe-loop-optimizations
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
CFLAGS_POSIX = -fno-builtin
CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap
CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls $(CFLAGS_POSIX)
CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX)
CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap $(CPPFLAGS_POSIX) -D_GCRYPT_IN_LIBGCRYPT=1 -I$(top_srcdir)/include/grub/gcrypt
CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime
@@ -164,20 +129,15 @@ EXTRA_DIST =
CLEANFILES =
BUILT_SOURCES =
# Rules for autogen definition files
.PRECIOUS: $(top_srcdir)/Makefile.tpl
$(top_srcdir)/Makefile.tpl: $(top_srcdir)/gentpl.py
python $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@
# Rules for Automake input
.PRECIOUS: $(top_srcdir)/Makefile.util.am
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def $(top_srcdir)/Makefile.tpl
cat $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
python $^ > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def
if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
cat $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
python $^ > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@

View File

@@ -2,7 +2,6 @@ EXTRA_DIST += autogen.sh
EXTRA_DIST += geninit.sh
EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.tpl
EXTRA_DIST += Makefile.util.def
EXTRA_DIST += Makefile.utilgcry.def
@@ -12,9 +11,11 @@ EXTRA_DIST += util/import_gcry.py
EXTRA_DIST += util/import_unicode.py
EXTRA_DIST += docs/man
EXTRA_DIST += docs/autoiso.cfg
EXTRA_DIST += docs/grub.cfg
EXTRA_DIST += docs/osdetect.cfg
EXTRA_DIST += conf/i386-pc-cygwin-img-ld.sc
EXTRA_DIST += conf/i386-cygwin-img-ld.sc
EXTRA_DIST += grub-core/Makefile.core.def
EXTRA_DIST += grub-core/Makefile.gcry.def
@@ -26,6 +27,11 @@ EXTRA_DIST += grub-core/gensymlist.sh
EXTRA_DIST += grub-core/genemuinit.sh
EXTRA_DIST += grub-core/genemuinitheader.sh
EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
EXTRA_DIST += grub-core/gnulib-fix-width.diff
EXTRA_DIST += grub-core/gnulib-no-abort.diff
EXTRA_DIST += grub-core/gnulib-no-gets.diff
EXTRA_DIST += grub-core/lib/libgcrypt
EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
@@ -103,3 +109,4 @@ EXTRA_DIST += grub-core/osdep/windows/sleep.c
EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
EXTRA_DIST += coreboot.cfg

View File

@@ -5,6 +5,8 @@ SECTIONS
.text :
{
start = . ;
_start = . ;
__start = . ;
*(.text)
etext = . ;
}
@@ -33,6 +35,8 @@ SECTIONS
{
*(.edata)
end = . ;
_end = . ;
__end = . ;
}
.stab :
{

View File

@@ -6,6 +6,8 @@
#define __powerpc__ 1
#endif
#define GCRYPT_NO_DEPRECATED 1
/* Define to 1 to enable disk cache statistics. */
#define DISK_CACHE_STATS @DISK_CACHE_STATS@
#define BOOT_TIME_STATS @BOOT_TIME_STATS@
@@ -26,6 +28,7 @@
#elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
#include <config-util.h>
#else
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
/* Define if C symbols get an underscore after compilation. */
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */

File diff suppressed because it is too large Load Diff

3
coreboot.cfg Normal file
View File

@@ -0,0 +1,3 @@
if test -f (cbfsdisk)/etc/grub.cfg; then
source (cbfsdisk)/etc/grub.cfg
fi

244
docs/autoiso.cfg Normal file
View File

@@ -0,0 +1,244 @@
# Sample GRUB script to autodetect operating systems
#
# Copyright (C) 2010 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/>.
function pathname { regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; }
function devname { regexp -s "$2" '^(\(.*\)).*$' "$1"; }
function loopback_iso_entry {
realdev="$1"
isopath="$2"
loopdev="$3"
if test -f /boot/grub/loopback.cfg; then
cfgpath=/boot/grub/loopback.cfg
elif test -f /grub/loopback.cfg; then
cfgpath=/grub/loopback.cfg
else
return 1;
fi
echo loopback.cfg $isopath: yes
menuentry "Boot GRUB Loopback Config from ${realdev}${isopath}" "$realdev" "$isopath" "$cfgpath" {
set device="$2"
set iso_path="$3"
set cfg_path="$4"
export iso_path
loopback loopdev_cfg "${device}${iso_path}"
set root=(loopdev_cfg)
configfile $cfg_path
loopback -d loopdev_cfg
}
return 0
}
function grml_iso_entry {
realdev="$1"
isopath="$2"
loopdev="$3"
result=1
for dir in /boot/grml /boot/grmlsmall /boot/grmlmedium; do
if ! test -f ${dir}/linux26 -a -f ${dir}/initrd.gz; then continue; fi
echo grml $isopath: yes
result=0
menuentry "GRML Linux from ${realdev}${isopath}" \
"$realdev" "$isopath" "$dir" {
set device="$2"
set isopath="$3"
set grmldir="$4"
loopback loopdev_grml "${device}${isopath}"
set root=(loopdev_grml)
linux $grmldir/linux26 findiso="$isopath" apm=power-off quiet \
boot=live nomce
initrd $grmldir/initrd.gz
loopback -d loopdev_grml
}
done
return $result
}
function pmagic_iso_entry {
realdev="$1"
isopath="$2"
loopdev="$3"
if ! test -f /pmagic/bzImage -a -f /pmagic/initramfs; then return 1; fi
echo pmagic $isopath: yes
menuentry "Parted Magic from ${realdev}${isopath}" "$realdev" "$isopath" {
set device="$2"
set isopath="$3"
loopback loopdev_pmagic "${device}${isopath}"
set root=(loopdev_pmagic)
linux /pmagic/bzImage iso_filename="$isopath" edd=off noapic \
load_ramdisk=1 prompt_ramdisk=0 rw sleep=10 loglevel=0 \
keymap=$langcode
initrd /pmagic/initramfs
loopback -d loopdev_pmagic
}
return 0
}
function sidux_iso_entry {
realdev="$1"
isopath="$2"
loopdev="$3"
result=1
for kernel in /boot/vmlinuz-*-sidux-*; do
if ! test -f "$kernel"; then continue; fi
regexp -s 1:v1 -s 2:v2 '/boot/vmlinuz-(.*)-sidux-(.*)' "$kernel"
initrd="/boot/initrd.img-$v1-sidux-$v2"
if ! test -f "$initrd"; then continue; fi
result=0
echo sidux $isopath: yes
menuentry "Sidux vmlinux-$v1-sidux-$v2 from ${realdev}${isopath}" "$realdev" "$isopath" "$kernel" "$initrd" {
set device="$2"
set isopath="$3"
set kernel="$4"
set initrd="$5"
loopback loopdev_sidux "${device}${isopath}"
set root=(loopdev_sidux)
linux $kernel fromiso=$isopath boot=fll quiet
initrd $initrd
loopback -d loopdev_sidux
}
done
return $result
}
function slax_iso_entry {
realdev="$1"
isopath="$2"
loopdev="$3"
if ! test -f /boot/vmlinuz -a -f /boot/initrd.gz; then return 1; fi
echo slax $isopath: yes
menuentry "Slax Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
set device="$2"
set isopath="$3"
loopback loopdev_slax "${device}${isopath}"
set root=(loopdev_slax)
linux /boot/vmlinuz from=$isopath ramdisk_size=6666 root=/dev/ram0 rw
initrd /boot/initrd.gz
loopback -d loopdev_slax
}
return 0
}
function tinycore_iso_entry {
realpath="$1"
isopath="$2"
loopdev="$3"
if ! test -f /boot/bzImage -a -f /boot/tinycore.gz; then return 1; fi
echo tinycore $isopath: yes
menuentry "Tinycore Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
set device="$2"
set isopath="$3"
loopback loopdev_tiny "${device}${isopath}"
set root=(loopdev_tiny)
linux /boot/bzImage
initrd /boot/tinycore.gz
loopback -d loopdev_tiny
}
return 0
}
function casper_iso_entry {
realpath="$1"
isopath="$2"
loopdev="$3"
if ! test -f /casper/vmlinuz; then return 1; fi
initrd=
for f in /casper/initrd.*z; do
if ! test -f "$f"; then continue; fi
pathname "$f" initrd
done
if test -z "$initrd"; then return 1; fi
echo casper $isopath: yes
menuentry "Casper based Linux from ${realdev}${isopath}" "$realdev" "$isopath" "$initrd" {
set device="$2"
set isopath="$3"
set initrd="$4"
loopback loopdev_casper "${device}${isopath}"
set root=(loopdev_casper)
linux /casper/vmlinuz boot=casper iso-scan/filename="$isopath" quiet splash noprompt keyb="$langcode" \
debian-installer/language="$langcode" console-setup/layoutcode?="$langcode" --
initrd $initrd
loopback -d loopdev_casper
}
return 0
}
function scan_isos {
isodirs="$1"
for dev in (*); do
for dir in $isodirs; do
for file in ${dev}${dir}/*.iso ${dev}${dir}/*.ISO; do
if ! test -f "$file"; then continue; fi
pathname $file isopath
if test -z "$dev" -o -z "$isopath"; then continue; fi
if ! loopback loopdev_scan "$file"; then continue; fi
saved_root=$root
set root=(loopdev_scan)
if loopback_iso_entry $dev $isopath (loopdev_scan); then true;
elif grml_iso_entry $dev $isopath (loopdev_scan); then true;
elif pmagic_iso_entry $dev $isopath (loopdev_scan); then true;
elif sidux_iso_entry $dev $isopath (loopdev_scan); then true;
elif slax_iso_entry $dev $isopath (loopdev_scan); then true;
elif tinycore_iso_entry $dev $isopath (loopdev_scan); then true;
elif casper_iso_entry $dev $isopath (loopdev_scan); then true;
else true; fi
set root=$saved_root
loopback -d loopdev_scan
done
done
done
return 0
}
# XXX Remove later
insmod serial
serial
terminal_output --append serial
# terminal_input --append serial
langcode="$lang"
insmod regexp
scan_isos /iso /boot/iso

View File

@@ -79,7 +79,7 @@ This edition documents version @value{VERSION}.
* Contributing Changes::
* Porting::
* Error Handling::
* CIA::
* Stack and heap size::
* BIOS port memory map::
* Video Subsystem::
* PFF2 Font File Format::
@@ -92,24 +92,36 @@ This edition documents version @value{VERSION}.
@node Getting the source code
@chapter Getting the source code
GRUB is maintained using the @uref{http://bazaar-vcs.org/, Bazaar revision
control system}. To fetch the primary development branch:
GRUB is maintained using the @uref{GIT revision
control system}. To fetch:
@example
bzr get http://bzr.savannah.gnu.org/r/grub/trunk/grub
git clone git://git.sv.gnu.org/grub.git
@end example
The GRUB developers maintain several other branches with work in progress.
Of these, the most interesting is the experimental branch, which is a
staging area for new code which we expect to eventually merge into trunk but
which is not yet ready:
Web access is available under
@example
bzr get http://bzr.savannah.gnu.org/r/grub/branches/experimental
http://git.savannah.gnu.org/cgit/grub.git/
@end example
Once you have used @kbd{bzr get} to fetch an initial copy of a branch, you
can use @kbd{bzr pull} to keep it up to date. If you have modified your
The branches available are:
@table @samp
@item master
Main developpement branch.
@item grub-legacy
GRUB 0.97 codebase. Kept for reference and legal reasons
@item multiboot
Multiboot specfication
@item multiboot2
Multiboot2 specfication
@item developper branches
Prefixed with developper name. Every developper of a team manages his own branches.
Developper branches do not need changelog entries.
@end table
Once you have used @kbd{git clone} to fetch an initial copy of a branch, you
can use @kbd{git pull} to keep it up to date. If you have modified your
local version, you may need to resolve conflicts when pulling.
@node Coding style
@@ -334,10 +346,10 @@ anymore.
@itemize
@item Always use latest GRUB 2 source code. So get that first.
For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a Bazaar (bzr) repository.
For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a GIT repository.
Please check Savannah's GRUB project page for details how to get newest bzr:
@uref{http://savannah.gnu.org/bzr/?group=grub, GRUB 2 bzr Repository}
Please check Savannah's GRUB project page for details how to get newest git:
@uref{https://savannah.gnu.org/git/?group=grub, GRUB 2 git Repository}
@item Compile it and try it out.
@@ -895,33 +907,68 @@ if (grub_errno != GRUB_ERR_NONE)
grub_error_pop ();
@end example
@node CIA
@chapter CIA
@c By Robert Millan and Carles Pina
If you have commit access, please setup CIA in your Bazaar
config so those in IRC receive notification of your commits.
@node Stack and heap size
@chapter Stack and heap size
In @file{~/.bazaar/bazaar.conf}, add "cia_send_revno = true".
Optionally, you can also add "cia_user = myusername" if you'd
like CIA service to use a specific account (for statistical purpose).
On emu stack and heap are just normal host OS stack and heap. Stack is typically
8 MiB although it's OS-dependent.
In the @file{.bzr/branch/branch.conf} of your checkout branch,
"set nickname = /path_to_this_branch" and "cia_project = GNU GRUB".
On i386-pc, i386-coreboot, i386-qemu and i386-multiboot the stack is 60KiB.
All available space between 1MiB and 4GiB marks is part of heap.
Additionally, please set cia_send_revno in the [DEFAULT] section
of your @file{~/.bazaar/bazaar.conf}. E.g.:
On *-xen stack is 4MiB. If compiled for x86-64 with GCC 4.4 or later adressable
space is unlimited. When compiled for x86-64 with older GCC version adressable
space is limited to 2GiB. When compiling for i386 adressable space is limited
to 4GiB. All adressable pages except the ones for stack, GRUB binary, special
pages and page table are in the heap.
@example
[DEFAULT]
cia_send_revno = true
@end example
On *-efi GRUB uses same stack as EFI. If compiled for x86-64 with GCC 4.4 or
later adressable space is unlimited. When compiled for x86-64 with older GCC
version adressable space is limited to 2GiB. For all other platforms adressable
space is limited to 4GiB. GRUB allocates pages from EFI for its heap, at most
1.6 GiB.
Remember to install cia-clients (Debian/Ubuntu package) to be able to use CIA.
On i386-ieee1275 and powerpc-ieee1275 GRUB uses same stack as IEEE1275.
It allocates at most 32MiB for its heap.
On sparc64-ieee1275 stack is 256KiB and heap is 2MiB.
On mips(el)-qemu_mips and mipsel-loongson stack is 2MiB (everything below
GRUB image) and everything above GRUB image (from 2MiB + kernel size)
until 256MiB is part of heap.
On mips-arc stack is 2MiB (everything below GRUB image) and everything above
GRUB image(from 2MiB + kernel size) until 128MiB is part of heap.
On mipsel-arc stack is 2MiB (everything below GRUB image which is not part
of ARC) and everything above GRUB image (from 7MiB + kernel size)
until 256MiB is part of heap.
On arm-uboot stack is 256KiB and heap is 2MiB.
In short:
@multitable @columnfractions .15 .25 .5
@headitem Platform @tab Stack @tab Heap
@item emu @tab 8 MiB @tab ?
@item i386-pc @tab 60 KiB @tab < 4 GiB
@item i386-coreboot @tab 60 KiB @tab < 4 GiB
@item i386-multiboot @tab 60 KiB @tab < 4 GiB
@item i386-qemu @tab 60 KiB @tab < 4 GiB
@item *-efi @tab ? @tab < 1.6 GiB
@item i386-ieee1275 @tab ? @tab < 32 MiB
@item powerpc-ieee1275 @tab ? @tab < 32 MiB
@item sparc64-ieee1275 @tab 256KiB @tab 2 MiB
@item arm-uboot @tab 256KiB @tab 2 MiB
@item mips(el)-qemu_mips @tab 2MiB @tab 253 MiB
@item mipsel-loongson @tab 2MiB @tab 253 MiB
@item mips-arc @tab 2MiB @tab 125 MiB
@item mipsel-arc @tab 2MiB @tab 248 MiB
@item x86_64-xen (GCC >= 4.4) @tab 4MiB @tab unlimited
@item x86_64-xen (GCC < 4.4) @tab 4MiB @tab < 2GiB
@item i386-xen @tab 4MiB @tab < 4GiB
@end multitable
Keep in mind Bazaar sends notifications for all commits to branches that have
this setting, regardless of whether they're bound branches (checkouts) or not.
So if you make local commits in a non-bound branch and it bothers you that
others can read them, do not use this setting.
@node BIOS port memory map
@chapter BIOS port memory map
@@ -934,9 +981,8 @@ others can read them, do not use this setting.
@item ? @tab 0x2000 - 1 @tab Real mode stack
@item 0x7C00 @tab 0x7D00 - 1 @tab Boot sector
@item 0x8000 @tab ? @tab GRUB kernel
@item 0x68000 @tab 0x78000 - 1 @tab Disk buffer
@item 0x68000 @tab 0x71000 - 1 @tab Disk buffer
@item ? @tab 0x80000 - 1 @tab Protected mode stack
@item 0x80000 @tab ? @tab Heap
@item ? @tab 0xA0000 - 1 @tab Extended BIOS Data Area
@item 0xA0000 @tab 0xC0000 - 1 @tab Video RAM
@item 0xC0000 @tab 0x100000 - 1 @tab BIOS
@@ -1113,6 +1159,47 @@ struct grub_video_palette_data
Used to query indexed color palettes. If mode is RGB mode, colors will be copied from emulated palette data. In Indexed Color modes, palettes will be read from hardware. Color values will be converted to suit structure format. @code{start} will tell what hardware color index (or emulated color index) will be used as a source for first indice of @code{palette_data}, after that both hardware color index and @code{palette_data} index will be incremented until @code{count} number of colors have been read.
@end itemize
@subsection grub_video_set_area_status
@itemize
@item Prototype:
@example
grub_err_t
grub_video_set_area_status (grub_video_area_status_t area_status);
@end example
@example
enum grub_video_area_status_t
@{
GRUB_VIDEO_AREA_DISABLED,
GRUB_VIDEO_AREA_ENABLED
@};
@end example
@item Description:
Used to set area drawing mode for redrawing the specified region. Draw commands
are performed in the intersection of the viewport and the region called area.
Coordinates remain related to the viewport. If draw commands try to draw over
the area, they are clipped.
Set status to DISABLED if you need to draw everything.
Set status to ENABLED and region to the desired rectangle to redraw everything
inside the region leaving everything else intact.
Should be used for redrawing of active elements.
@end itemize
@subsection grub_video_get_area_status
@itemize
@item Prototype:
@example
grub_err_r
grub_video_get_area_status (grub_video_area_status_t *area_status);
@end example
@item Description:
Used to query the area status.
@end itemize
@subsection grub_video_set_viewport
@itemize
@item Prototype:
@@ -1139,6 +1226,37 @@ grub_video_get_viewport (unsigned int *x, unsigned int *y, unsigned int *width,
Used to query current viewport dimensions. Software developer can use this to choose best way to render contents of the viewport.
@end itemize
@subsection grub_video_set_region
@itemize
@item Prototype:
@example
grub_err_t
grub_video_set_region (unsigned int x, unsigned int y, unsigned int width, unsigned int height);
@end example
@item Description:
Used to specify the region of the screen which should be redrawn. Use absolute
values. When the region is set and area status is ENABLE all draw commands will
be performed inside the interseption of region and viewport named area.
If draw commands try to draw over viewport, they are clipped. If developer
requests larger than possible region, width and height will be clamped to fit
screen. Should be used for redrawing of active elements.
@end itemize
@subsection grub_video_get_region
@itemize
@item Prototype:
@example
grub_err_t
grub_video_get_region (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height);
@end example
@item Description:
Used to query current region dimensions.
@end itemize
@subsection grub_video_map_color
@itemize
@item Prototype:
@@ -1694,7 +1812,9 @@ right edges of two adjacent glyphs. The @strong{device width} field determines
the effective leading value that is used to render the font.
@end itemize
@image{font_char_metrics,,,,png}
@ifnottex
@image{font_char_metrics,,,,.png}
@end ifnottex
An illustration of how the various font metrics apply to characters.

View File

@@ -701,6 +701,26 @@ you may run those commands directly to install GRUB, without using
with the internals of GRUB. Installing a boot loader on a running OS may be
extremely dangerous.
On EFI systems for fixed disk install you have to mount EFI System Partition.
If you mount it at @file{/boot/efi} then you don't need any special arguments:
@example
# @kbd{grub-install}
@end example
Otherwise you need to specify where your EFI System partition is mounted:
@example
# @kbd{grub-install --efi-directory=/mnt/efi}
@end example
For removable installs you have to use @option{--removable} and specify both
@option{--boot-directory} and @option{--efi-directory}:
@example
# @kbd{grub-install --efi-directory=/mnt/usb --boot-directory=/mnt/usb/boot --removable}
@end example
@node Making a GRUB bootable CD-ROM
@section Making a GRUB bootable CD-ROM
@@ -1234,14 +1254,14 @@ Valid keys in @file{/etc/default/grub} are as follows:
@item GRUB_DEFAULT
The default menu entry. This may be a number, in which case it identifies
the Nth entry in the generated menu counted from zero, or the title of a
menu entry, or the special string @samp{saved}. Using the title may be
menu entry, or the special string @samp{saved}. Using the id may be
useful if you want to set a menu entry as the default even though there may
be a variable number of entries before it.
For example, if you have:
@verbatim
menuentry 'Example GNU/Linux distribution' --class gnu-linux {
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
@end verbatim
@@ -1249,12 +1269,17 @@ menuentry 'Example GNU/Linux distribution' --class gnu-linux {
then you can make this the default using:
@example
GRUB_DEFAULT='Example GNU/Linux distribution'
GRUB_DEFAULT=example-gnu-linux
@end example
Previously it was documented the way to use entry title. While this still
works it's not recommended since titles often contain unstable device names
and may be translated
If you set this to @samp{saved}, then the default menu entry will be that
saved by @samp{GRUB_SAVEDEFAULT}, @command{grub-set-default}, or
@command{grub-reboot}.
saved by @samp{GRUB_SAVEDEFAULT} or @command{grub-set-default}. This relies on
the environment block, which may not be available in all situations
(@pxref{Environment block}).
The default is @samp{0}.
@@ -1263,7 +1288,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save
it as a new default entry for use by future runs of GRUB. This is only
useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
@samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
@command{grub-set-default} or @command{grub-reboot}. Unset by default.
@command{grub-set-default}. Unset by default.
This option relies on the environment block, which may not be available in
all situations (@pxref{Environment block}).
@@ -1273,23 +1298,26 @@ a key is pressed. The default is @samp{5}. Set to @samp{0} to boot
immediately without displaying the menu, or to @samp{-1} to wait
indefinitely.
@item GRUB_HIDDEN_TIMEOUT
Wait this many seconds for @key{ESC} to be pressed before displaying the menu.
If no @key{ESC} is pressed during that time, display the menu for the number of
seconds specified in GRUB_TIMEOUT before booting the default entry. We expect
that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set
to @samp{0} so that the menu is not displayed at all unless @key{ESC} is
pressed.
Unset by default.
If @samp{GRUB_TIMEOUT_STYLE} is set to @samp{countdown} or @samp{hidden},
the timeout is instead counted before the menu is displayed.
@item GRUB_HIDDEN_TIMEOUT_QUIET
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
suppress the verbose countdown while waiting for a key to be pressed before
displaying the menu. Unset by default.
@item GRUB_TIMEOUT_STYLE
If this option is unset or set to @samp{menu}, then GRUB will display the
menu and then wait for the timeout set by @samp{GRUB_TIMEOUT} to expire
before booting the default entry. Pressing a key interrupts the timeout.
If this option is set to @samp{countdown} or @samp{hidden}, then, before
displaying the menu, GRUB will wait for the timeout set by
@samp{GRUB_TIMEOUT} to expire. If @key{ESC} is pressed during that time, it
will display the menu and wait for input. If a hotkey associated with a
menu entry is pressed, it will boot the associated menu entry immediately.
If the timeout expires before either of these happens, it will boot the
default entry. In the @samp{countdown} case, it will show a one-line
indication of the remaining time.
@item GRUB_DEFAULT_BUTTON
@itemx GRUB_TIMEOUT_BUTTON
@itemx GRUB_HIDDEN_TIMEOUT_BUTTON
@itemx GRUB_TIMEOUT_STYLE_BUTTON
@itemx GRUB_BUTTON_CMOS_ADDRESS
Variants of the corresponding variables without the @samp{_BUTTON} suffix,
used to support vendor-specific power buttons. @xref{Vendor power-on keys}.
@@ -1426,6 +1454,22 @@ Normally, @command{grub-mkconfig} will try to use the external
systems installed on the same system and generate appropriate menu entries
for them. Set this option to @samp{true} to disable this.
@item GRUB_OS_PROBER_SKIP_LIST
List of space-separated FS UUIDs of filesystems to be ignored from os-prober
output. For efi chainloaders it's <UUID>@@<EFI FILE>
@item GRUB_DISABLE_SUBMENU
Normally, @command{grub-mkconfig} will generate top level menu entry for
the kernel with highest version number and put all other found kernels
or alternative menu entries for recovery mode in submenu. For entries returned
by @command{os-prober} first entry will be put on top level and all others
in submenu. If this option is set to @samp{y}, flat menu with all entries
on top level will be generated instead. Changing this option will require
changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback})
and @samp{default} (@pxref{default}) environment variables as well as saved
default entry using @command{grub-set-default} and value used with
@command{grub-reboot}.
@item GRUB_ENABLE_CRYPTODISK
If set to @samp{y}, @command{grub-mkconfig} and @command{grub-install} will
check for encrypted disks and generate additional commands needed to access
@@ -1448,6 +1492,44 @@ Each module will be loaded as early as possible, at the start of
@end table
The following options are still accepted for compatibility with existing
configurations, but have better replacements:
@table @samp
@item GRUB_HIDDEN_TIMEOUT
Wait this many seconds before displaying the menu. If @key{ESC} is pressed
during that time, display the menu and wait for input according to
@samp{GRUB_TIMEOUT}. If a hotkey associated with a menu entry is pressed,
boot the associated menu entry immediately. If the timeout expires before
either of these happens, display the menu for the number of seconds
specified in @samp{GRUB_TIMEOUT} before booting the default entry.
If you set @samp{GRUB_HIDDEN_TIMEOUT}, you should also set
@samp{GRUB_TIMEOUT=0} so that the menu is not displayed at all unless
@key{ESC} is pressed.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@samp{GRUB_TIMEOUT_STYLE=hidden}.
@item GRUB_HIDDEN_TIMEOUT_QUIET
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
suppress the verbose countdown while waiting for a key to be pressed before
displaying the menu.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown}.
@item GRUB_HIDDEN_TIMEOUT_BUTTON
Variant of @samp{GRUB_HIDDEN_TIMEOUT}, used to support vendor-specific power
buttons. @xref{Vendor power-on keys}.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@samp{GRUB_TIMEOUT_STYLE=hidden}.
@end table
For more detailed customisation of @command{grub-mkconfig}'s output, you may
edit the scripts in @file{/etc/grub.d} directly.
@file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
@@ -2436,17 +2518,20 @@ menu requires several fancy features of your terminal.
@node Vendor power-on keys
@chapter Using GRUB with vendor power-on keys
Some laptop vendors provide an additional power-on button which boots another
OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
@samp{GRUB_DEFAULT_BUTTON}, @samp{GRUB_HIDDEN_TIMEOUT_BUTTON} and
Some laptop vendors provide an additional power-on button which boots
another OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
@samp{GRUB_TIMEOUT_STYLE_BUTTON}, @samp{GRUB_DEFAULT_BUTTON}, and
@samp{GRUB_BUTTON_CMOS_ADDRESS} variables in default/grub (@pxref{Simple
configuration}). @samp{GRUB_TIMEOUT_BUTTON}, @samp{GRUB_DEFAULT_BUTTON} and
@samp{GRUB_HIDDEN_TIMEOUT_BUTTON} are used instead of the corresponding
variables without the @samp{_BUTTON} suffix when powered on using the special
button. @samp{GRUB_BUTTON_CMOS_ADDRESS} is vendor-specific and partially
model-specific. Values known to the GRUB team are:
configuration}). @samp{GRUB_TIMEOUT_BUTTON},
@samp{GRUB_TIMEOUT_STYLE_BUTTON}, and @samp{GRUB_DEFAULT_BUTTON} are used
instead of the corresponding variables without the @samp{_BUTTON} suffix
when powered on using the special button. @samp{GRUB_BUTTON_CMOS_ADDRESS}
is vendor-specific and partially model-specific. Values known to the GRUB
team are:
@table @key
@item Dell XPS M1330M
121:3
@item Dell XPS M1530
85:3
@item Dell Latitude E4300
@@ -2626,6 +2711,7 @@ Heavily limited platforms:
Lightly limited platforms:
@itemize
@item *-xen: limited only by adress space and RAM size.
@item i386-qemu: kernel.img (.text + .data + .bss) is limited by 392704 bytes.
(core.img would be limited by ROM size but it's unlimited on qemu
@item All EFI platforms: limited by contiguous RAM size and possibly firmware bugs
@@ -2681,9 +2767,9 @@ by a digit, like @samp{fd0}, or @samp{cd}.
AHCI, PATA (ata), crypto, USB use the name of driver followed by a number.
Memdisk and host are limited to one disk and so it's refered just by driver
name.
RAID (md), ofdisk (ieee1275 and nand), LVM (lvm), LDM and arcdisk (arc) use
intrinsic name of disk prefixed by driver name. Additionally just ``nand''
refers to the disk aliased as ``nand''.
RAID (md), ofdisk (ieee1275 and nand), LVM (lvm), LDM, virtio (vdsk)
and arcdisk (arc) use intrinsic name of disk prefixed by driver name.
Additionally just ``nand'' refers to the disk aliased as ``nand''.
Conflicts are solved by suffixing a number if necessarry.
Commas need to be escaped.
Loopback uses whatever name specified to @command{loopback} command.
@@ -2949,6 +3035,7 @@ These variables have special meaning to GRUB.
* biosnum::
* check_signatures::
* chosen::
* cmdpath::
* color_highlight::
* color_normal::
* debug::
@@ -2985,6 +3072,7 @@ These variables have special meaning to GRUB.
* superusers::
* theme::
* timeout::
* timeout_style::
@end menu
@@ -3018,6 +3106,16 @@ the titles of each of the submenus starting from the top level followed by
the title of the menu entry itself, separated by @samp{>}.
@node cmdpath
@subsection cmdpath
The location from which @file{core.img} was loaded as an absolute
directory name (@pxref{File name syntax}). This is set by GRUB at
startup based on information returned by platform firmware. Not every
platform provides this information and some may return only device
without path name.
@node color_highlight
@subsection color_highlight
@@ -3025,7 +3123,7 @@ This variable contains the ``highlight'' foreground and background terminal
colors, separated by a slash (@samp{/}). Setting this variable changes
those colors. For the available color names, @pxref{color_normal}.
The default is @samp{black/white}.
The default is @samp{black/light-gray}.
@node color_normal
@@ -3054,7 +3152,7 @@ those colors. Each color must be a name from the following list:
@item white
@end itemize
The default is @samp{white/black}.
The default is @samp{light-gray/black}.
The color support support varies from terminal to terminal.
@@ -3088,7 +3186,8 @@ to go beyond the current 16 colors.
This variable may be set to enable debugging output from various components
of GRUB. The value is a list of debug facility names separated by
whitespace or @samp{,}, or @samp{all} to enable all available debugging
output.
output. The facility names are the first argument to grub_dprintf. Consult
source for more details.
@node default
@@ -3096,7 +3195,21 @@ output.
If this variable is set, it identifies a menu entry that should be selected
by default, possibly after a timeout (@pxref{timeout}). The entry may be
identified by number or by title.
identified by number or by id.
For example, if you have:
@verbatim
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
@end verbatim
then you can make this the default using:
@example
default=example-gnu-linux
@end example
If the entry is in a submenu, then it must be identified using the titles of
each of the submenus starting from the top level followed by the number or
@@ -3136,7 +3249,8 @@ If this variable is set, it sets the resolution used on the @samp{gfxterm}
graphical terminal. Note that you can only use modes which your graphics
card supports via VESA BIOS Extensions (VBE), so for example native LCD
panel resolutions may not be available. The default is @samp{auto}, which
selects a platform-specific default that should look reasonable.
selects a platform-specific default that should look reasonable. Supported
modes can be listed by @samp{videoinfo} command in GRUB.
The resolution may be specified as a sequence of one or more modes,
separated by commas (@samp{,}) or semicolons (@samp{;}); each will be tried
@@ -3391,8 +3505,21 @@ keyboard input before booting the default menu entry. A timeout of @samp{0}
means to boot the default entry immediately without displaying the menu; a
timeout of @samp{-1} (or unset) means to wait indefinitely.
This variable is often set by @samp{GRUB_TIMEOUT} or
@samp{GRUB_HIDDEN_TIMEOUT} (@pxref{Simple configuration}).
If @samp{timeout_style} (@pxref{timeout_style}) is set to @samp{countdown}
or @samp{hidden}, the timeout is instead counted before the menu is
displayed.
This variable is often set by @samp{GRUB_TIMEOUT} (@pxref{Simple
configuration}).
@node timeout_style
@subsection timeout_style
This variable may be set to @samp{menu}, @samp{countdown}, or @samp{hidden}
to control the way in which the timeout (@pxref{timeout}) interacts with
displaying the menu. See the documentation of @samp{GRUB_TIMEOUT_STYLE}
(@pxref{Simple configuration}) for details.
@node Environment block
@@ -3680,6 +3807,8 @@ you forget a command, you can run the command @command{help}
* lsfonts:: List loaded fonts
* lsmod:: Show loaded modules
* md5sum:: Compute or check MD5 hash
* module:: Load module for multiboot kernel
* multiboot:: Load multiboot compliant kernel
* nativedisk:: Switch to native disk drivers
* normal:: Enter normal mode
* normal_exit:: Exit from normal mode
@@ -4347,7 +4476,7 @@ List devices or files.
With no arguments, print all devices known to GRUB.
If the argument is a device name enclosed in parentheses (@pxref{Device
syntax}), then list all files at the root directory of that device.
syntax}), then print the name of the filesystem of that device.
If the argument is a directory given as an absolute file name (@pxref{File
name syntax}), then list the contents of that directory.
@@ -4369,7 +4498,6 @@ List loaded fonts.
Show list of loaded modules.
@end deffn
@node md5sum
@subsection md5sum
@@ -4378,6 +4506,34 @@ Alias for @code{hashsum --hash md5 arg @dots{}}. See command @command{hashsum}
(@pxref{hashsum}) for full description.
@end deffn
@node module
@subsection module
@deffn Command module [--nounzip] file [arguments]
Load a module for multiboot kernel image. The rest of the
line is passed verbatim as the module command line.
@end deffn
@node multiboot
@subsection multiboot
@deffn Command multiboot [--quirk-bad-kludge] [--quirk-modules-after-kernel] file @dots{}
Load a multiboot kernel image from @var{file}. The rest of the
line is passed verbatim as the @dfn{kernel command-line}. Any module must
be reloaded after using this command (@pxref{module}).
Some kernels have known problems. You need to specify --quirk-* for those.
--quirk-bad-kludge is a problem seen in several products that they include
loading kludge information with invalid data in ELF file. GRUB prior to 0.97
and some custom builds prefered ELF information while 0.97 and GRUB 2
use kludge. Use this option to ignore kludge.
Known affected systems: old Solaris, SkyOS.
--quirk-modules-after-kernel is needed for kernels which load at relatively
high address e.g. 16MiB mark and can't cope with modules stuffed between
1MiB mark and beginning of the kernel.
Known afftected systems: VMWare.
@end deffn
@node nativedisk
@subsection nativedisk
@@ -4783,7 +4939,8 @@ Alias for @code{hashsum --hash sha512 arg @dots{}}. See command @command{hashsum
@deffn Command sleep [@option{--verbose}] [@option{--interruptible}] count
Sleep for @var{count} seconds. If option @option{--interruptible} is given,
allow @key{ESC} to interrupt sleep. With @option{--verbose} show countdown
of remaining seconds.
of remaining seconds. Exit code is set to 0 if timeout expired and to 1
if timeout was interrupted by @key{ESC}.
@end deffn
@@ -5120,12 +5277,14 @@ is given, use default list of servers.
@node Internationalisation
@chapter Charset
@chapter Internationalisation
@section Charset
GRUB uses UTF-8 internally other than in rendering where some GRUB-specific
appropriate representation is used. All text files (including config) are
assumed to be encoded in UTF-8.
@chapter Filesystems
@section Filesystems
NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of
ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read
as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix,
@@ -5159,7 +5318,7 @@ treated as distinct from u+combining diaresis. This however means that in
order to access file on HFS+ its name must be specified in normalisation form D.
On normalized ZFS subvolumes filenames out of normalisation are inaccessible.
@chapter Output terminal
@section Output terminal
Firmware output console ``console'' on ARC and IEEE1275 are limited to ASCII.
BIOS firmware console and VGA text are limited to ASCII and some pseudographics.
@@ -5193,7 +5352,7 @@ called ``annotation characters'' If you can complete either of
two lists or, better, propose a patch to improve rendering, please contact
developer team.
@chapter Input terminal
@section Input terminal
Firmware console on BIOS, IEEE1275 and ARC doesn't allow you to enter non-ASCII
characters. EFI specification allows for such but author is unaware of any
actual implementations. Serial input is currently limited for latin1 (unlikely
@@ -5203,15 +5362,15 @@ So no dead keys or advanced input method. Also there is no keymap change hotkey.
In practice it makes difficult to enter any text using non-Latin alphabet.
Moreover all current input consumers are limited to ASCII.
@chapter Gettext
@section Gettext
GRUB supports being translated. For this you need to have language *.mo files in $prefix/locale, load gettext module and set ``lang'' variable.
@chapter Regexp
@section Regexp
Regexps work on unicode characters, however no attempt at checking cannonical
equivalence has been made. Moreover the classes like [:alpha:] match only
ASCII subset.
@chapter Other
@section Other
Currently GRUB always uses YEAR-MONTH-DAY HOUR:MINUTE:SECOND [WEEKDAY] 24-hour
datetime format but weekdays are translated.
GRUB always uses the decimal number format with [0-9] as digits and . as
@@ -5340,9 +5499,8 @@ may halt or otherwise impact the boot process.
GRUB uses GPG-style detached signatures (meaning that a file
@file{foo.sig} will be produced when file @file{foo} is signed), and
currently supports the DSA signing algorithm. Both 2048-bit and
3072-bit keys are supported. A signing key can be generated as
follows:
currently supports the DSA and RSA signing algorithms. A signing key
can be generated as follows:
@example
gpg --gen-key
@@ -5682,7 +5840,7 @@ X86 support is summarised in the following table. ``Yes'' means that the kernel
PowerPC, IA64 and Sparc64 ports support only Linux. MIPS port supports Linux
and multiboot2.
@chapter Boot tests
@section Boot tests
As you have seen in previous chapter the support matrix is pretty big and some of the configurations are only rarely used. To ensure the quality bootchecks are available for all x86 targets except EFI chainloader, Appleloader and XNU. All x86 platforms have bootcheck facility except ieee1275. Multiboot, multiboot2, BIOS chainloader, ntldr and freebsd-bootloader boot targets are tested only with a fake kernel images. Only Linux is tested among the payloads using Linux protocols.
@@ -5836,8 +5994,20 @@ mounted on
Recheck the device map, even if @file{/boot/grub/device.map} already
exists. You should use this option whenever you add/remove a disk
into/from your computer.
@end table
@item --no-rs-codes
By default on x86 BIOS systems, @command{grub-install} will use some
extra space in the bootloader embedding area for Reed-Solomon
error-correcting codes. This enables GRUB to still boot successfully
if some blocks are corrupted. The exact amount of protection offered
is dependent on available space in the embedding area. R sectors of
redundancy can tolerate up to R/2 corrupted sectors. This
redundancy may be cumbersome if attempting to cryptographically
validate the contents of the bootloader embedding area, or in more
modern systems with GPT-style partition tables (@pxref{BIOS
installation}) where GRUB does not reside in any unpartitioned space
outside of the MBR. Disable the Reed-Solomon codes with this option.
@end table
@node Invoking grub-mkconfig
@chapter Invoking grub-mkconfig

2
docs/man/grub-file.h2m Normal file
View File

@@ -0,0 +1,2 @@
[NAME]
grub-file \- check file type

View File

@@ -0,0 +1,4 @@
[NAME]
grub-macbless \- bless a mac file/directory
[SEE ALSO]
.BR grub-install (1)

View File

@@ -0,0 +1,4 @@
[NAME]
grub-syslinux2cfg \- transform syslinux config into grub.cfg
[SEE ALSO]
.BR grub-menulst2cfg (8)

View File

@@ -178,6 +178,12 @@ for dev in (*); do
# uuid: filesystem UUID
probe -s uuid -u $dev
if test -f ($device)/isolinux/isolinux.cfg ; then
menuentry "ISOLINUX config (on $device)" $device {
set root=$2
syslinux_configfile -i /isolinux/isolinux.cfg
}
fi
if test -f ($device)/bootmgr -a -f ($device)/boot/bcd; then
menuentry "Windows Vista bootmgr (on $device)" $device {
set root=$2

1043
gentpl.py

File diff suppressed because it is too large Load Diff

View File

@@ -10,10 +10,6 @@ CCAS=$(TARGET_CC)
RANLIB=$(TARGET_RANLIB)
STRIP=$(TARGET_STRIP)
if COND_HAVE_FONT_SOURCE
TARGET_CFLAGS += -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1
endif
MACHO2IMG=$(top_builddir)/grub-macho2img
AM_CFLAGS = $(TARGET_CFLAGS)
@@ -30,8 +26,11 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
# gentrigtables
gentrigtables: gentrigtables.c
@@ -82,7 +81,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
if !COND_clang
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
if COND_i386_pc
@@ -102,7 +103,6 @@ endif
if COND_i386_coreboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
@@ -112,7 +112,6 @@ endif
if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
endif
if COND_i386_qemu
@@ -128,6 +127,24 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
endif
if COND_i386_xen
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
endif
if COND_x86_64_xen
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/x86_64/xen/hypercall.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
endif
if COND_x86_64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
@@ -153,7 +170,6 @@ endif
if COND_mips_qemu_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
@@ -165,7 +181,6 @@ if COND_mips_loongson
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
@@ -214,6 +229,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
endif
if COND_arm64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
endif
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
@@ -368,43 +388,44 @@ CLEANFILES += $(MOD_FILES)
if COND_ENABLE_EFIEMU
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
-rm -f $@; \
if test "x$(TARGET_APPLE_CC)" = x1; then \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -DAPPLE_CC -m32 -Wall -Werror -nostdlib -O2 -c -o $@.bin $< || exit 1; \
$(OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin; \
-rm -f $@
-rm -f $@.bin
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
if test "x$(TARGET_APPLE_LINKER)" = x1; then \
$(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin ; \
elif test ! -z "$(TARGET_OBJ2ELF)"; then \
$(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
mv $@.bin $@ ; \
else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -m32 -Wall -Werror -nostdlib -O2 -c -o $@ $< || exit 1; \
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
mv $@.bin $@ ; \
fi
# Link format -arch,x86_64 means Apple linker
efiemu64_c.o: efiemu/runtime/efiemu.c
if test "x$(TARGET_APPLE_CC)" = x1; then \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \
else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
fi
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
efiemu64_s.o: efiemu/runtime/efiemu.S
-rm -f $@
if test "x$(TARGET_APPLE_CC)" = x1; then \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \
else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
fi
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
-rm -f $@; \
if test "x$(TARGET_APPLE_CC)" = x1; then \
rm -f $@.bin; \
$(TARGET_CC) -m64 -Wl,-r -nostdlib -o $@.bin $^ || exit 1; \
$(OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
-rm -f $@
-rm -f $@.bin
$(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
$(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin; \
else \
$(TARGET_CC) -m64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
mv $@.bin $@ ; \
fi
platform_DATA += efiemu32.o efiemu64.o
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
endif
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
for x in $(platform_DATA); do \
cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \
done

View File

@@ -59,20 +59,32 @@ kernel = {
ia64_efi_ldflags = '-Wl,-r,-d';
ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
x86_64_xen_cppflags = '$(CPPFLAGS_XEN)';
i386_xen_cppflags = '$(CPPFLAGS_XEN)';
arm_efi_ldflags = '-Wl,-r,-d';
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
arm64_efi_ldflags = '-Wl,-r,-d';
arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200';
i386_coreboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200';
i386_multiboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200';
i386_ieee1275_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_ieee1275_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x10000';
i386_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
ldadd = '$(LDADD_KERNEL)';
i386_coreboot_ldflags = '-Wl,-Ttext=0x8200';
i386_multiboot_ldflags = '-Wl,-Ttext=0x8200';
i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000';
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
@@ -80,7 +92,6 @@ kernel = {
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)';
emu_cppflags = '$(CPPFLAGS_GNULIB)';
@@ -90,6 +101,8 @@ kernel = {
i386_pc_startup = kern/i386/pc/startup.S;
i386_efi_startup = kern/i386/efi/startup.S;
x86_64_efi_startup = kern/x86_64/efi/startup.S;
i386_xen_startup = kern/i386/xen/startup.S;
x86_64_xen_startup = kern/x86_64/xen/startup.S;
i386_qemu_startup = kern/i386/qemu/startup.S;
i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
i386_coreboot_startup = kern/i386/coreboot/startup.S;
@@ -99,6 +112,7 @@ kernel = {
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
arm_uboot_startup = kern/arm/uboot/startup.S;
arm_efi_startup = kern/arm/efi/startup.S;
arm64_efi_startup = kern/arm64/efi/startup.S;
common = kern/command.c;
common = kern/corecmd.c;
@@ -146,6 +160,7 @@ kernel = {
terminfoinkernel = lib/arg.c;
i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c;
i386_coreboot = kern/i386/coreboot/init.c;
i386_multiboot = kern/i386/coreboot/init.c;
@@ -164,19 +179,31 @@ kernel = {
i386_efi = kern/i386/efi/init.c;
i386_efi = bus/pci.c;
x86_64_efi = kern/x86_64/dl.c;
x86_64 = kern/x86_64/dl.c;
x86_64_xen = kern/x86_64/dl.c;
x86_64_efi = kern/x86_64/efi/callwrap.S;
x86_64_efi = kern/i386/efi/init.c;
x86_64_efi = bus/pci.c;
xen = kern/i386/tsc.c;
x86_64_xen = kern/x86_64/xen/hypercall.S;
i386_xen = kern/i386/xen/hypercall.S;
xen = kern/xen/init.c;
xen = term/xen/console.c;
xen = disk/xen/xendisk.c;
xen = commands/boot.c;
ia64_efi = kern/ia64/efi/startup.S;
ia64_efi = kern/ia64/efi/init.c;
ia64_efi = kern/ia64/dl.c;
ia64_efi = kern/ia64/dl_helper.c;
ia64_efi = kern/ia64/cache.c;
arm_efi = kern/arm/efi/init.c;
arm_efi = kern/arm/efi/misc.c;
arm64_efi = kern/arm/efi/init.c;
i386_pc = kern/i386/pc/init.c;
i386_pc = kern/i386/pc/mmap.c;
i386_pc = term/i386/pc/console.c;
@@ -218,6 +245,7 @@ kernel = {
mips_loongson = video/sm712.c;
mips_loongson = video/sis315pro.c;
mips_loongson = video/radeon_fuloong2e.c;
mips_loongson = video/radeon_yeeloong3a.c;
extra_dist = video/sm712_init.c;
extra_dist = video/sis315_init.c;
mips_loongson = commands/keylayouts.c;
@@ -237,6 +265,11 @@ kernel = {
arm = kern/arm/cache.c;
arm = kern/arm/misc.S;
arm64 = kern/arm64/cache.c;
arm64 = kern/arm64/cache_flush.S;
arm64 = kern/arm64/dl.c;
arm64 = kern/arm64/dl_helper.c;
emu = disk/host.c;
emu = kern/emu/cache_s.S;
emu = kern/emu/hostdisk.c;
@@ -255,6 +288,9 @@ kernel = {
emu = osdep/emuconsole.c;
extra_dist = osdep/unix/emuconsole.c;
extra_dist = osdep/windows/emuconsole.c;
emu = osdep/dl.c;
extra_dist = osdep/unix/dl.c;
extra_dist = osdep/windows/dl.c;
emu = osdep/sleep.c;
emu = osdep/init.c;
emu = osdep/emunet.c;
@@ -409,9 +445,9 @@ image = {
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '-lgcc';
cflags = '-Wno-unreachable-code -static-libgcc';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)';
cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips;
};
@@ -423,9 +459,9 @@ image = {
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '-lgcc';
cflags = '-static-libgcc';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)';
cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips;
};
@@ -443,7 +479,7 @@ image = {
name = fwstart;
mips_loongson = boot/mips/loongson/fwstart.S;
objcopyflags = '-O binary';
ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
@@ -451,13 +487,14 @@ image = {
name = fwstart_fuloong2f;
mips_loongson = boot/mips/loongson/fuloong2f.S;
objcopyflags = '-O binary';
ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
module = {
name = disk;
common = lib/disk.c;
extra_dist = kern/disk_common.c;
};
module = {
@@ -496,6 +533,7 @@ module = {
module = {
name = emuusb;
common = bus/usb/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
@@ -544,6 +582,7 @@ module = {
module = {
name = pci;
common = bus/pci.c;
i386_ieee1275 = bus/i386/ieee1275/pci.c;
enable = i386_pc;
enable = i386_ieee1275;
@@ -565,6 +604,7 @@ module = {
common = bus/emu/pci.c;
common = commands/lspci.c;
enable = emu;
condition = COND_GRUB_EMU_PCI;
};
@@ -575,11 +615,12 @@ module = {
enable = mips_arc;
};
library = {
name = libgnulib.a;
common = gnulib/regex.c;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
module = {
name = lsxen;
common = commands/xen/lsxen.c;
cppflags = '$(CPPFLAGS_XEN)';
enable = xen;
};
module = {
@@ -633,8 +674,7 @@ module = {
name = regexp;
common = commands/regexp.c;
common = commands/wildcard.c;
ldadd = libgnulib.a;
dependencies = libgnulib.a;
common = gnulib/regex.c;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
};
@@ -717,6 +757,7 @@ module = {
enable = mips_arc;
enable = ia64_efi;
enable = arm_efi;
enable = arm64_efi;
enable = arm_uboot;
};
@@ -737,8 +778,10 @@ module = {
module = {
name = cpuid;
x86 = commands/i386/cpuid.c;
common = commands/i386/cpuid.c;
enable = x86;
enable = i386_xen;
enable = x86_64_xen;
};
module = {
@@ -795,6 +838,8 @@ module = {
i386_multiboot = lib/i386/halt.c;
i386_coreboot = lib/i386/halt.c;
i386_qemu = lib/i386/halt.c;
xen = lib/xen/halt.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
efi = lib/efi/halt.c;
ieee1275 = lib/ieee1275/halt.c;
emu = lib/emu/halt.c;
@@ -808,11 +853,14 @@ module = {
ia64_efi = lib/efi/reboot.c;
x86_64_efi = lib/efi/reboot.c;
arm_efi = lib/efi/reboot.c;
arm64_efi = lib/efi/reboot.c;
powerpc_ieee1275 = lib/ieee1275/reboot.c;
sparc64_ieee1275 = lib/ieee1275/reboot.c;
mips_arc = lib/mips/arc/reboot.c;
mips_loongson = lib/mips/loongson/reboot.c;
mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
xen = lib/xen/reboot.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
uboot = lib/uboot/reboot.c;
common = commands/reboot.c;
};
@@ -1351,6 +1399,11 @@ module = {
common = fs/tar.c;
};
module = {
name = greffs;
common = fs/greffs.c;
};
module = {
name = udf;
common = fs/udf.c;
@@ -1395,6 +1448,11 @@ module = {
common = fs/zfs/zfsinfo.c;
};
module = {
name = macbless;
common = commands/macbless.c;
};
module = {
name = pxe;
i386_pc = net/drivers/i386/pc/pxe.c;
@@ -1436,6 +1494,11 @@ module = {
common = io/gzio.c;
};
module = {
name = offsetio;
common = io/offset.c;
};
module = {
name = bufio;
common = io/bufio.c;
@@ -1469,13 +1532,21 @@ module = {
x86 = lib/i386/relocator64.S;
i386 = lib/i386/relocator_asm.S;
x86_64 = lib/x86_64/relocator_asm.S;
i386_xen = lib/i386/relocator_asm.S;
x86_64_xen = lib/x86_64/relocator_asm.S;
x86 = lib/i386/relocator.c;
x86 = lib/i386/relocator_common_c.c;
ieee1275 = lib/ieee1275/relocator.c;
efi = lib/efi/relocator.c;
mips = lib/mips/relocator_asm.S;
mips = lib/mips/relocator.c;
powerpc = lib/powerpc/relocator_asm.S;
powerpc = lib/powerpc/relocator.c;
xen = lib/xen/relocator.c;
i386_xen = lib/i386/xen/relocator.S;
x86_64_xen = lib/x86_64/xen/relocator.S;
xen = lib/i386/relocator_common_c.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
extra_dist = lib/i386/relocator_common.S;
extra_dist = kern/powerpc/cache_flush.S;
@@ -1483,6 +1554,7 @@ module = {
enable = mips;
enable = powerpc;
enable = x86;
enable = xen;
};
module = {
@@ -1494,6 +1566,8 @@ module = {
powerpc_ieee1275 = lib/ieee1275/datetime.c;
sparc64_ieee1275 = lib/ieee1275/cmos.c;
powerpc_ieee1275 = lib/ieee1275/cmos.c;
xen = lib/xen/datetime.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
mips_arc = lib/arc/datetime.c;
enable = noemu;
@@ -1510,6 +1584,7 @@ module = {
extra_dist = lib/ia64/setjmp.S;
extra_dist = lib/ia64/longjmp.S;
extra_dist = lib/arm/setjmp.S;
extra_dist = lib/arm64/setjmp.S;
};
module = {
@@ -1551,6 +1626,14 @@ module = {
enable = i386_pc;
};
module = {
name = truecrypt;
i386_pc = loader/i386/pc/truecrypt.c;
enable = i386_pc;
};
module = {
name = freedos;
i386_pc = loader/i386/pc/freedos.c;
@@ -1568,6 +1651,7 @@ module = {
cppflags = "-DGRUB_USE_MULTIBOOT2";
common = loader/multiboot.c;
common = lib/cmdline.c;
common = loader/multiboot_mbi2.c;
enable = x86;
enable = mips;
@@ -1576,6 +1660,7 @@ module = {
module = {
name = multiboot;
common = loader/multiboot.c;
common = lib/cmdline.c;
x86 = loader/i386/multiboot_mbi.c;
extra_dist = loader/multiboot_elfxx.c;
enable = x86;
@@ -1584,6 +1669,8 @@ module = {
module = {
name = linux;
x86 = loader/i386/linux.c;
xen = loader/i386/xen.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
i386_pc = lib/i386/pc/vesa_modes_table.c;
mips = loader/mips/linux.c;
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
@@ -1600,16 +1687,21 @@ module = {
name = xnu;
x86 = loader/xnu_resume.c;
x86 = loader/i386/xnu.c;
x86 = loader/macho32.c;
x86 = loader/macho64.c;
x86 = loader/macho.c;
x86 = loader/xnu.c;
x86 = loader/lzss.c;
extra_dist = loader/machoXX.c;
enable = x86;
};
module = {
name = macho;
common = loader/macho.c;
common = loader/macho32.c;
common = loader/macho64.c;
common = loader/lzss.c;
extra_dist = loader/machoXX.c;
};
module = {
name = appleldr;
common = loader/efi/appleloader.c;
@@ -1622,6 +1714,7 @@ module = {
efi = loader/efi/chainloader.c;
i386_pc = loader/i386/pc/chainloader.c;
i386_coreboot = loader/i386/coreboot/chainloader.c;
i386_coreboot = lib/LzmaDec.c;
enable = i386_pc;
enable = i386_coreboot;
enable = efi;
@@ -1643,6 +1736,7 @@ module = {
enable = x86;
enable = ia64_efi;
enable = arm_efi;
enable = arm64_efi;
enable = mips;
};
@@ -1664,6 +1758,7 @@ module = {
common = normal/term.c;
common = normal/context.c;
common = normal/charset.c;
common = lib/getline.c;
common = script/main.c;
common = script/script.c;
@@ -1847,6 +1942,42 @@ module = {
common = tests/setjmp_test.c;
};
module = {
name = signature_test;
common = tests/signature_test.c;
common = tests/signatures.h;
};
module = {
name = sleep_test;
common = tests/sleep_test.c;
};
module = {
name = xnu_uuid_test;
common = tests/xnu_uuid_test.c;
};
module = {
name = pbkdf2_test;
common = tests/pbkdf2_test.c;
};
module = {
name = legacy_password_test;
common = tests/legacy_password_test.c;
enable = i386_pc;
enable = i386_efi;
enable = x86_64_efi;
enable = emu;
enable = xen;
};
module = {
name = div_test;
common = tests/div_test.c;
};
module = {
name = videotest_checksum;
common = tests/videotest_checksum.c;
@@ -2000,11 +2131,19 @@ module = {
emu = lib/i386/pc/vesa_modes_table.c;
i386_efi = lib/i386/pc/vesa_modes_table.c;
x86_64_efi = lib/i386/pc/vesa_modes_table.c;
xen = lib/i386/pc/vesa_modes_table.c;
enable = i386_pc;
enable = i386_efi;
enable = x86_64_efi;
enable = emu;
enable = xen;
};
module = {
name = syslinuxcfg;
common = lib/syslinux_parse.c;
common = commands/syslinuxcfg.c;
};
module = {
@@ -2038,8 +2177,12 @@ module = {
module = {
name = backtrace;
x86 = lib/i386/backtrace.c;
i386_xen = lib/i386/backtrace.c;
x86_64_xen = lib/i386/backtrace.c;
common = lib/backtrace.c;
enable = x86;
enable = i386_xen;
enable = x86_64_xen;
};
module = {
@@ -2145,3 +2288,15 @@ module = {
name = progress;
common = lib/progress.c;
};
module = {
name = file;
common = commands/file.c;
common = commands/file32.c;
common = commands/file64.c;
extra_dist = commands/fileXX.c;
common = loader/i386/xen_file.c;
common = loader/i386/xen_file32.c;
common = loader/i386/xen_file64.c;
extra_dist = loader/i386/xen_fileXX.c;
};

View File

@@ -31,27 +31,32 @@
.macro floppy
part_start:
probe_values:
LOCAL(probe_values):
.byte 36, 18, 15, 9, 0
LOCAL(floppy_probe):
pushw %dx
/*
* Perform floppy probe.
*/
movw $probe_values - 1, %si
#ifdef __APPLE__
LOCAL(probe_values_minus_one) = LOCAL(probe_values) - 1
movw MACRO_DOLLAR(LOCAL(probe_values_minus_one)), %si
#else
movw MACRO_DOLLAR(LOCAL(probe_values)) - 1, %si
#endif
LOCAL(probe_loop):
/* reset floppy controller INT 13h AH=0 */
xorw %ax, %ax
int $0x13
int MACRO_DOLLAR(0x13)
incw %si
movb (%si), %cl
/* if number of sectors is 0, display error and die */
cmpb $0, %cl
jne 1f
testb %cl, %cl
jnz 1f
/*
* Floppy disk probe failure.
@@ -64,20 +69,20 @@ fd_probe_error_string: .asciz "Floppy"
1:
/* perform read */
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw MACRO_DOLLAR(GRUB_BOOT_MACHINE_BUFFER_SEG), %bx
movw %bx, %es
xorw %bx, %bx
movw $0x201, %ax
movb $0, %ch
movb $0, %dh
int $0x13
movw MACRO_DOLLAR(0x201), %ax
movb MACRO_DOLLAR(0), %ch
movb MACRO_DOLLAR(0), %dh
int MACRO_DOLLAR(0x13)
/* if error, jump to "LOCAL(probe_loop)" */
jc LOCAL(probe_loop)
/* %cl is already the correct value! */
movb $1, %dh
movb $79, %ch
movb MACRO_DOLLAR(1), %dh
movb MACRO_DOLLAR(79), %ch
jmp LOCAL(final_init)
.endm
@@ -180,7 +185,9 @@ kernel_address:
#ifndef HYBRID_BOOT
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
kernel_sector:
.long 1, 0
.long 1
kernel_sector_high:
.long 0
#endif
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
@@ -285,7 +292,7 @@ lba_mode:
/* the absolute address */
movl kernel_sector, %ebx
movl %ebx, 8(%si)
movl kernel_sector + 4, %ebx
movl kernel_sector_high, %ebx
movl %ebx, 12(%si)
/* the segment of buffer address */
@@ -318,11 +325,12 @@ LOCAL(chs_mode):
int $0x13
jnc LOCAL(final_init)
popw %dx
/*
* The call failed, so maybe use the floppy probe instead.
*/
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
jz LOCAL(floppy_probe)
testb %dl, %dl
jnb LOCAL(floppy_probe)
/* Nope, we definitely have a hard disk, and we're screwed. */
ERR(hd_probe_error_string)
@@ -353,7 +361,7 @@ LOCAL(final_init):
setup_sectors:
/* load logical sector start (top half) */
movl kernel_sector + 4, %eax
movl kernel_sector_high, %eax
orl %eax, %eax
jnz LOCAL(geometry_error)
@@ -505,7 +513,9 @@ LOCAL(message):
#ifdef HYBRID_BOOT
. = _start + 0x1b0
kernel_sector:
.long 1, 0
.long 1
kernel_sector_high:
.long 0
#endif
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:

View File

@@ -18,7 +18,6 @@
#include <config.h>
#include <grub/symbol.h>
#include <grub/i386/pc/memory.h>
#include <grub/machine/memory.h>
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
@@ -59,7 +58,7 @@ VARIABLE(grub_core_entry_addr)
orb $0x02, %al
outb $0x92
1:
movl grub_core_entry_addr, %edx
movl EXT_C(grub_core_entry_addr), %edx
jmp *%edx
#include "../../../kern/i386/realmode.S"

View File

@@ -63,18 +63,18 @@ __start:
This way we don't need to sacrifice a register for it. */
retry_cs5536:
/* We have only one bus (0). Function is 0. */
lui $t0, %hi(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
lui $t1, %hi(GRUB_MACHINE_PCI_CONFSPACE)
lui $t0, %hi(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F)
lui $t1, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
lui $t3, %hi(GRUB_CS5536_PCIID)
addiu $t3, $t3, %lo(GRUB_CS5536_PCIID)
ori $t4, $zero, 1
1:
andi $t4, $t4, ((1 << GRUB_PCI_NUM_DEVICES) - 1)
andi $t4, $t4, ((1 << GRUB_PCI_NUM_DEVICES_2F) - 1)
/* In case of failure try again. CS5536 may be slow to come up. */
beql $t4, $zero, retry_cs5536
nop
sw $t4, %lo(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR) ($t0)
lw $t2, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_PCI_REG_PCI_ID) ($t1)
sw $t4, %lo(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F) ($t0)
lw $t2, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_PCI_REG_PCI_ID) ($t1)
bnel $t2, $t3, 1b
sll $t4, $t4, 1
@@ -86,9 +86,9 @@ retry_cs5536:
move $a0, $t4
#endif
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE)
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
li $t1, GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED
sw $t1, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_CONFIG) ($t0)
sw $t1, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_CONFIG) ($t0)
/* Set GPIO LBAR. */
lui $a0, %hi(GRUB_CS5536_MSR_GPIO_BAR)
@@ -121,21 +121,21 @@ retry_cs5536:
bal message
addiu $a0, $a0, %lo(smbus_enabled)
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS)
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS)
/* Disable SMB. */
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
/* Disable interrupts. */
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1) ($t0)
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1) ($t0)
/* Set as master. */
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_ADDR) ($t0)
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_ADDR) ($t0)
/* Launch SMBus controller at slowest speed possible. */
ori $t1, $zero, 0xff
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL3) ($t0)
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL3) ($t0)
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
/* Yeeloong and Fuloong2f have only one memory slot. */
/* Output first byte on serial for debugging. */
@@ -237,8 +237,8 @@ other_exception:
addiu $a0, $a0, %lo(unhandled_exception)
gpio_init:
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
addiu $t0, $t0, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_GPIO)
addiu $t0, $t0, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_GPIO)
lui $t1, %hi (gpio_dump)
addiu $t1, $t1, %lo (gpio_dump)
@@ -368,18 +368,18 @@ self:
Clobbered: $t0
*/
wrmsr:
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE)
sw $a0, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_ADDR) ($t0)
sw $a1, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_DATA0) ($t0)
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
sw $a0, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_ADDR) ($t0)
sw $a1, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_DATA0) ($t0)
jr $ra
sw $a2, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_DATA1) ($t0)
sw $a2, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_DATA1) ($t0)
/* Wait for SMBus data or empty transmitter. */
/* In: $a0 = exception handler. Out: none. Clobbered: $t0, $t1 */
smbus_wait:
1:
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE)
lb $t0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $t0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
andi $t1, $t0, GRUB_CS5536_SMB_REG_STATUS_SDAST
bne $t1, $zero, return
nop
@@ -401,52 +401,52 @@ read_spd:
addiu $a0, $a0, %hi(read_spd_fail)
/* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
bal smbus_wait
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send device address. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
sll $t1, $a1, 1
bal smbus_wait
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send ACK. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_ACK
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send byte address. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
bal smbus_wait
sb $t2, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t2, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
bal smbus_wait
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send device address. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
sll $t1, $a1, 1
ori $t1, $t1, 1
bal smbus_wait
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send STOP. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_STOP
bal smbus_wait
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
lb $v0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
lb $v0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
jr $t3
andi $v0, $v0, 0xff
read_spd_fail:

View File

@@ -27,6 +27,7 @@
.extern __bss_start
.extern _end
.extern _edata
.globl __start, _start, start
.set noreorder
@@ -248,8 +249,9 @@ cmdlinedone:
#include "../../kern/mips/cache_flush.S"
/* Decompress the payload. */
lui $a0, %hi(__bss_start)
addiu $a0, $a0, %lo(__bss_start)
lui $a0, %hi(_edata)
addiu $a0, $a0, %lo(_edata)
lui $t0, %hi(base)
addiu $t0, $t0, %lo(base)
subu $a0, $a0, $t0
@@ -265,16 +267,16 @@ cmdlinedone:
*/
move $s6, $a3
lui $t0, %hi(EXT_C(grub_decompress_core))
addiu $t0, $t0, %lo(EXT_C(grub_decompress_core))
lui $t9, %hi(EXT_C(grub_decompress_core))
addiu $t9, $t9, %lo(EXT_C(grub_decompress_core))
#ifdef GRUB_MACHINE_ARC
lui $sp, %hi(_start - 512)
jalr $t0
jalr $t9
addiu $sp, $sp, %lo(_start - 512)
#else
lui $sp, %hi(_start - 256)
jalr $t0
jalr $t9
addiu $sp, $sp, %lo(_start - 256)
#endif
move $a0, $s1
@@ -287,3 +289,11 @@ cmdlinedone:
jr $t1
nop
/* Ensure that .data section is created. In code we suppose that _edata
is first location not in decompressor image. Strictly speaking it's
_edata only when .data is present and _etext otherwise. But checking
for .data presence would cost more in code than it is to ensure that
.data is created.
*/
.data
.long 0

View File

@@ -44,11 +44,11 @@ pic_base:
. = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH
boot_path:
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
kernel_byte: .xword (2 << 9)
boot_path_end:
kernel_byte: .xword (2 << 9)
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#else
#define boot_path (_start + 512)
#define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
#define boot_path_end (_start + 1024)
#include <grub/offsets.h>
@@ -140,7 +140,11 @@ prom_call:
boot_continue:
mov %o7, PIC_REG /* PIC base */
#ifndef CDBOOT
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
#else
GET_ABS(_start + 512, %l1) /* OF argument slots */
#endif
/* Find the /chosen node so we can fetch the stdout handle,
* and thus perform console output.

View File

@@ -30,8 +30,66 @@ static grub_addr_t addr_win[GRUB_MACHINE_PCI_NUM_WIN] =
{GRUB_MACHINE_PCI_WIN1_ADDR, GRUB_MACHINE_PCI_WIN2_ADDR,
GRUB_MACHINE_PCI_WIN3_ADDR};
grub_bonito_type_t grub_bonito_type;
static volatile void *
config_addr (grub_pci_address_t addr)
{
if (grub_bonito_type == GRUB_BONITO_2F)
{
GRUB_MACHINE_PCI_CONF_CTRL_REG_2F = 1 << ((addr >> 11) & 0xf);
return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_2F
| (addr & 0x07ff));
}
else
{
if (addr >> 16)
return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_3A_EXT | addr);
else
return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_3A | addr);
}
}
grub_uint32_t
grub_pci_read (grub_pci_address_t addr)
{
return *(volatile grub_uint32_t *) config_addr (addr);
}
grub_uint16_t
grub_pci_read_word (grub_pci_address_t addr)
{
return *(volatile grub_uint16_t *) config_addr (addr);
}
grub_uint8_t
grub_pci_read_byte (grub_pci_address_t addr)
{
return *(volatile grub_uint8_t *) config_addr (addr);
}
void
grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
{
*(volatile grub_uint32_t *) config_addr (addr) = data;
}
void
grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
{
*(volatile grub_uint16_t *) config_addr (addr) = data;
}
void
grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
{
*(volatile grub_uint8_t *) config_addr (addr) = data;
}
static inline void
write_bases (void)
write_bases_2f (void)
{
int i;
grub_uint32_t reg = 0;
@@ -39,38 +97,54 @@ write_bases (void)
reg |= (((base_win[i] >> GRUB_MACHINE_PCI_WIN_SHIFT)
& GRUB_MACHINE_PCI_WIN_MASK)
<< (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE));
GRUB_MACHINE_PCI_IO_CTRL_REG = reg;
GRUB_MACHINE_PCI_IO_CTRL_REG_2F = reg;
}
volatile void *
grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
grub_addr_t base, grub_size_t size)
{
int i;
grub_addr_t newbase;
if (grub_bonito_type == GRUB_BONITO_2F)
{
int i;
grub_addr_t newbase;
/* First try already used registers. */
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && base_win[i] <= base
&& base_win[i] + sizes_win[i] > base + size)
{
usage_win[i]++;
return (void *)
(addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
}
/* Map new register. */
newbase = base & ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK;
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (!usage_win[i] && newbase <= base
&& newbase + sizes_win[i] > base + size)
{
usage_win[i]++;
base_win[i] = newbase;
write_bases ();
return (void *)
(addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
}
grub_fatal ("Out of PCI windows.");
/* First try already used registers. */
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && base_win[i] <= base
&& base_win[i] + sizes_win[i] > base + size)
{
usage_win[i]++;
return (void *)
(addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
}
/* Map new register. */
newbase = base & ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK;
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (!usage_win[i] && newbase <= base
&& newbase + sizes_win[i] > base + size)
{
usage_win[i]++;
base_win[i] = newbase;
write_bases_2f ();
return (void *)
(addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
}
grub_fatal ("Out of PCI windows.");
}
else
{
int region = 0;
if (base >= 0x10000000
&& base + size <= 0x18000000)
region = 1;
if (base >= 0x1c000000
&& base + size <= 0x1f000000)
region = 2;
if (region == 0)
grub_fatal ("Attempt to map out of regions");
return (void *) (0xa0000000 | base);
}
}
void *
@@ -86,14 +160,17 @@ grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
volatile void *mem,
grub_size_t size __attribute__ ((unused)))
{
int i;
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && addr_win[i]
== (((grub_addr_t) mem | 0x20000000)
& ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK))
{
usage_win[i]--;
return;
}
grub_fatal ("Tried to unmap not mapped region");
if (grub_bonito_type == GRUB_BONITO_2F)
{
int i;
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && addr_win[i]
== (((grub_addr_t) mem | 0x20000000)
& ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK))
{
usage_win[i]--;
return;
}
grub_fatal ("Tried to unmap not mapped region");
}
}

View File

@@ -0,0 +1,42 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/dl.h>
#include <grub/pci.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/ieee1275/ieee1275.h>
volatile void *
grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
grub_addr_t base,
grub_size_t size)
{
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE))
return (volatile void *) base;
if (grub_ieee1275_map (base, base, size, 7))
grub_fatal ("couldn't map 0x%lx", base);
return (volatile void *) base;
}
void
grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
volatile void *mem __attribute__ ((unused)),
grub_size_t size __attribute__ ((unused)))
{
}

View File

@@ -534,11 +534,20 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
"EHCI grub_ehci_pci_iter: registers above 4G are not supported\n");
return 0;
}
base &= GRUB_PCI_ADDR_MEM_MASK;
if (!base)
{
grub_dprintf ("ehci",
"EHCI: EHCI is not mapped\n");
return 0;
}
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word(addr));
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n");
}
@@ -1504,7 +1513,7 @@ grub_ehci_check_transfer (grub_usb_controller_t dev,
struct grub_ehci *e = dev->data;
struct grub_ehci_transfer_controller_data *cdata =
transfer->controller_data;
grub_uint32_t token;
grub_uint32_t token, token_ftd;
grub_dprintf ("ehci",
"check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n",
@@ -1532,13 +1541,18 @@ grub_ehci_check_transfer (grub_usb_controller_t dev,
return grub_ehci_parse_notrun (dev, transfer, actual);
token = grub_le_to_cpu32 (cdata->qh_virt->td_overlay.token);
/* If the transfer consist from only one TD, we should check */
/* if the TD was really executed and deactivated - to prevent */
/* false detection of transfer finish. */
token_ftd = grub_le_to_cpu32 (cdata->td_first_virt->token);
/* Detect QH halted */
if ((token & GRUB_EHCI_STATUS_HALTED) != 0)
return grub_ehci_parse_halt (dev, transfer, actual);
/* Detect QH not active - QH is not active and no next TD */
if ((token & GRUB_EHCI_STATUS_ACTIVE) == 0)
if (token && ((token & GRUB_EHCI_STATUS_ACTIVE) == 0)
&& ((token_ftd & GRUB_EHCI_STATUS_ACTIVE) == 0))
{
/* It could be finish at all or short packet condition */
if ((grub_le_to_cpu32 (cdata->qh_virt->td_overlay.next_td)
@@ -1677,7 +1691,7 @@ grub_ehci_hubports (grub_usb_controller_t dev)
return portinfo;
}
static grub_err_t
static grub_usb_err_t
grub_ehci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
{
@@ -1699,14 +1713,14 @@ grub_ehci_portstatus (grub_usb_controller_t dev,
endtime = grub_get_time_ms () + 1000;
while (grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_ENABLED)
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "portstatus: EHCI Timed out - disable");
return GRUB_USB_ERR_TIMEOUT;
if (!enable) /* We don't need reset port */
{
grub_dprintf ("ehci", "portstatus: Disabled.\n");
grub_dprintf ("ehci", "portstatus: end, status=0x%02x\n",
grub_ehci_port_read (e, port));
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
grub_dprintf ("ehci", "portstatus: enable\n");
@@ -1724,8 +1738,7 @@ grub_ehci_portstatus (grub_usb_controller_t dev,
endtime = grub_get_time_ms () + 1000;
while (grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_RESET)
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO,
"portstatus: EHCI Timed out - reset port");
return GRUB_USB_ERR_TIMEOUT;
grub_boot_time ("Port %d reset", port);
/* Remember "we did the reset" - needed by detect_dev */
e->reset |= (1 << port);
@@ -1753,7 +1766,7 @@ grub_ehci_portstatus (grub_usb_controller_t dev,
grub_dprintf ("ehci", "portstatus: end, status=0x%02x\n",
grub_ehci_port_read (e, port));
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
static grub_usb_speed_t
@@ -1888,7 +1901,7 @@ grub_ehci_restore_hw (void)
}
}
return GRUB_USB_ERR_NONE;
return GRUB_ERR_NONE;
}
static grub_err_t
@@ -1911,7 +1924,7 @@ grub_ehci_fini_hw (int noreturn __attribute__ ((unused)))
grub_ehci_reset (e);
}
return GRUB_USB_ERR_NONE;
return GRUB_ERR_NONE;
}
static struct grub_usb_controller_dev usb_controller = {

View File

@@ -47,7 +47,7 @@ struct grub_ohci_hcca
grub_uint32_t donehead;
grub_uint8_t reserved[116];
} __attribute__((packed));
} GRUB_PACKED;
/* OHCI General Transfer Descriptor */
struct grub_ohci_td
@@ -64,7 +64,7 @@ struct grub_ohci_td
* physical address in CPU endian */
grub_uint32_t tr_index; /* index of TD in transfer */
grub_uint8_t pad[8 - sizeof (volatile struct grub_ohci_td *)]; /* padding to 32 bytes */
} __attribute__((packed));
} GRUB_PACKED;
/* OHCI Endpoint Descriptor. */
struct grub_ohci_ed
@@ -73,7 +73,7 @@ struct grub_ohci_ed
grub_uint32_t td_tail;
grub_uint32_t td_head;
grub_uint32_t next_ed;
} __attribute__((packed));
} GRUB_PACKED;
typedef volatile struct grub_ohci_td *grub_ohci_td_t;
typedef volatile struct grub_ohci_ed *grub_ohci_ed_t;
@@ -265,16 +265,20 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
base = grub_pci_read (addr);
#if 0
/* Stop if there is no IO space base address defined. */
if (! (base & 1))
return 0;
#endif
base &= GRUB_PCI_ADDR_MEM_MASK;
if (!base)
{
grub_dprintf ("ehci",
"EHCI: EHCI is not mapper\n");
return 0;
}
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word(addr));
grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x\n",
class, subclass, interf);
@@ -1216,7 +1220,7 @@ grub_ohci_cancel_transfer (grub_usb_controller_t dev,
return GRUB_USB_ERR_NONE;
}
static grub_err_t
static grub_usb_err_t
grub_ohci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
{
@@ -1236,11 +1240,11 @@ grub_ohci_portstatus (grub_usb_controller_t dev,
while ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
& (1 << 1)))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "OHCI Timed out - disable");
return GRUB_USB_ERR_TIMEOUT;
grub_dprintf ("ohci", "end of portstatus=0x%02x\n",
grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
/* OHCI does one reset signal 10ms long but USB spec.
@@ -1257,7 +1261,7 @@ grub_ohci_portstatus (grub_usb_controller_t dev,
while (! (grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
& GRUB_OHCI_SET_PORT_RESET_STATUS_CHANGE))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "OHCI Timed out - reset");
return GRUB_USB_ERR_TIMEOUT;
/* End the reset signaling - reset the reset status change */
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
@@ -1275,7 +1279,7 @@ grub_ohci_portstatus (grub_usb_controller_t dev,
while (! (grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
& (1 << 1)))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "OHCI Timed out - enable");
return GRUB_USB_ERR_TIMEOUT;
/* Reset bit Connect Status Change */
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
@@ -1287,7 +1291,7 @@ grub_ohci_portstatus (grub_usb_controller_t dev,
grub_dprintf ("ohci", "end of portstatus=0x%02x\n",
grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
static grub_usb_speed_t

View File

@@ -91,11 +91,13 @@ real_config (struct grub_serial_port *port)
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
GRUB_FTDI_MODEM_CTRL,
GRUB_FTDI_MODEM_CTRL_DTRRTS, 0, 0, 0);
port->config.rtscts ? GRUB_FTDI_MODEM_CTRL_DTRRTS : 0,
0, 0, 0);
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
GRUB_FTDI_FLOW_CTRL,
GRUB_FTDI_FLOW_CTRL_DTRRTS, 0, 0, 0);
port->config.rtscts ? GRUB_FTDI_FLOW_CTRL_DTRRTS : 0,
0, 0, 0);
divisor = get_divisor (port->config.speed);
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,

View File

@@ -55,7 +55,7 @@ struct grub_pl2303_config
grub_uint8_t stop_bits;
grub_uint8_t parity;
grub_uint8_t word_len;
} __attribute__ ((packed));
} GRUB_PACKED;
static void
real_config (struct grub_serial_port *port)
@@ -125,7 +125,7 @@ real_config (struct grub_serial_port *port)
0x22, 3, 0, 0, 0);
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
1, 0, 0x61, 0, 0);
1, 0, port->config.rtscts ? 0x61 : 0, 0, 0);
port->configured = 1;
}

View File

@@ -105,7 +105,7 @@ struct grub_uhci_qh
/* Queue heads are aligned on 16 bytes, pad so a queue head is 16
bytes so we can store many in a 4K page. */
grub_uint8_t pad[8];
} __attribute__ ((packed));
} GRUB_PACKED;
/* UHCI Transfer Descriptor. */
struct grub_uhci_td
@@ -129,7 +129,7 @@ struct grub_uhci_td
/* 3 additional 32 bits words reserved for the Host Controller Driver. */
grub_uint32_t data[3];
} __attribute__ ((packed));
} GRUB_PACKED;
typedef volatile struct grub_uhci_td *grub_uhci_td_t;
typedef volatile struct grub_uhci_qh *grub_uhci_qh_t;
@@ -189,11 +189,6 @@ grub_uhci_writereg32 (struct grub_uhci *u,
grub_outl (val, u->iobase + reg);
}
static grub_err_t
grub_uhci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable);
/* Iterate over all PCI devices. Determine if a device is an UHCI
controller. If this is the case, initialize it. */
static int
@@ -222,12 +217,6 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
if (class != 0x0c || subclass != 0x03 || interf != 0x00)
return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word (addr));
/* Determine IO base address. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
base = grub_pci_read (addr);
@@ -238,6 +227,13 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
if ((base & GRUB_UHCI_IOMASK) == 0)
return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| GRUB_PCI_COMMAND_MEM_ENABLED
| grub_pci_read_word (addr));
grub_dprintf ("uhci", "base = %x\n", base);
/* Allocate memory for the controller and register it. */
@@ -715,7 +711,7 @@ grub_uhci_iterate (grub_usb_controller_iterate_hook_t hook, void *hook_data)
return 0;
}
static grub_err_t
static grub_usb_err_t
grub_uhci_portstatus (grub_usb_controller_t dev,
unsigned int port, unsigned int enable)
{
@@ -733,8 +729,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
else if (port == 1)
reg = GRUB_UHCI_REG_PORTSC2;
else
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"UHCI Root Hub port does not exist");
return GRUB_USB_ERR_INTERNAL;
status = grub_uhci_readreg16 (u, reg);
grub_dprintf ("uhci", "detect=0x%02x\n", status);
@@ -747,11 +742,11 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
endtime = grub_get_time_ms () + 1000;
while ((grub_uhci_readreg16 (u, reg) & (1 << 2)))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "UHCI Timed out - disable");
return GRUB_USB_ERR_TIMEOUT;
status = grub_uhci_readreg16 (u, reg);
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
/* Reset the port. */
@@ -782,7 +777,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
endtime = grub_get_time_ms () + 1000;
while (! ((status = grub_uhci_readreg16 (u, reg)) & (1 << 2)))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "UHCI Timed out - enable");
return GRUB_USB_ERR_TIMEOUT;
/* Reset recovery time */
grub_millisleep (10);
@@ -792,7 +787,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
static grub_usb_speed_t

View File

@@ -195,7 +195,7 @@ grub_usb_add_hub (grub_usb_device_t dev)
rescan = 1;
return GRUB_ERR_NONE;
return GRUB_USB_ERR_NONE;
}
static void
@@ -203,7 +203,7 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
grub_usb_speed_t speed)
{
grub_usb_device_t dev;
grub_err_t err;
grub_usb_err_t err;
grub_boot_time ("After detect_dev");

View File

@@ -227,7 +227,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
v2inebda = target;
target += v2->length;
target = (grub_uint8_t *) ((((long) target - 1) | 0xf) + 1);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v2 = 0;
break;
}
@@ -246,7 +246,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ((((long) target - 1) | 0xf) + 1);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v1 = 0;
break;
}
@@ -265,7 +265,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v2, v2->length);
v2inebda = target;
target += v2->length;
target = (grub_uint8_t *) ((((long) target - 1) | 0xf) + 1);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v2 = 0;
break;
}
@@ -282,7 +282,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ((((long) target - 1) | 0xf) + 1);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v1 = 0;
break;
}
@@ -306,7 +306,7 @@ grub_acpi_create_ebda (void)
*target = 0;
grub_dprintf ("acpi", "Switching EBDA\n");
(*((grub_uint16_t *) 0x40e)) = ((long)targetebda) >> 4;
(*((grub_uint16_t *) 0x40e)) = ((grub_addr_t) targetebda) >> 4;
grub_dprintf ("acpi", "EBDA switched\n");
return GRUB_ERR_NONE;

View File

@@ -62,23 +62,47 @@ read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
if (ctx->num_sectors > 0)
{
if (ctx->start_sector + ctx->num_sectors == sector
&& offset == 0 && length == GRUB_DISK_SECTOR_SIZE)
&& offset == 0 && length >= GRUB_DISK_SECTOR_SIZE)
{
ctx->num_sectors++;
return;
ctx->num_sectors += length >> GRUB_DISK_SECTOR_BITS;
sector += length >> GRUB_DISK_SECTOR_BITS;
length &= (GRUB_DISK_SECTOR_SIZE - 1);
}
if (!length)
return;
print_blocklist (ctx->start_sector, ctx->num_sectors, 0, 0, ctx);
ctx->num_sectors = 0;
}
if (offset == 0 && length == GRUB_DISK_SECTOR_SIZE)
if (offset)
{
ctx->start_sector = sector;
ctx->num_sectors++;
unsigned l = length + offset;
l &= (GRUB_DISK_SECTOR_SIZE - 1);
l -= offset;
print_blocklist (sector, 0, offset, l, ctx);
length -= l;
sector++;
offset = 0;
}
if (!length)
return;
if (length & (GRUB_DISK_SECTOR_SIZE - 1))
{
if (length >> GRUB_DISK_SECTOR_BITS)
{
print_blocklist (sector, length >> GRUB_DISK_SECTOR_BITS, 0, 0, ctx);
sector += length >> GRUB_DISK_SECTOR_BITS;
}
print_blocklist (sector, 0, 0, length & (GRUB_DISK_SECTOR_SIZE - 1), ctx);
}
else
print_blocklist (sector, 0, offset, length, ctx);
{
ctx->start_sector = sector;
ctx->num_sectors = length >> GRUB_DISK_SECTOR_BITS;
}
}
static grub_err_t

View File

@@ -146,8 +146,7 @@ grub_loader_boot (void)
return grub_error (GRUB_ERR_NO_KERNEL,
N_("you need to load the kernel first"));
if (grub_loader_flags & GRUB_LOADER_FLAG_NORETURN)
grub_machine_fini ();
grub_machine_fini (grub_loader_flags);
for (cur = preboots_head; cur; cur = cur->next)
{

View File

@@ -56,7 +56,7 @@ GRUB_MOD_INIT(boottime)
{
cmd_boottime =
grub_register_command ("boottime", grub_cmd_boottime,
0, N_("Get boot time statistics."));
0, N_("Show boot time statistics."));
}
GRUB_MOD_FINI(boottime)

View File

@@ -26,14 +26,14 @@ struct grub_acpi_rsdp_v10 *
grub_machine_acpi_get_rsdpv1 (void)
{
unsigned i;
static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
grub_efi_guid_t *guid =
grub_efi_packed_guid_t *guid =
&grub_efi_system_table->configuration_table[i].vendor_guid;
if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
return (struct grub_acpi_rsdp_v10 *)
grub_efi_system_table->configuration_table[i].vendor_table;
}
@@ -44,14 +44,14 @@ struct grub_acpi_rsdp_v20 *
grub_machine_acpi_get_rsdpv2 (void)
{
unsigned i;
static grub_efi_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
grub_efi_guid_t *guid =
grub_efi_packed_guid_t *guid =
&grub_efi_system_table->configuration_table[i].vendor_guid;
if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_guid_t)))
if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
return (struct grub_acpi_rsdp_v20 *)
grub_efi_system_table->configuration_table[i].vendor_table;
}

View File

@@ -105,7 +105,7 @@ fake_bios_data (int use_rom)
smbios = 0;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
{
grub_efi_guid_t *guid =
grub_efi_packed_guid_t *guid =
&grub_efi_system_table->configuration_table[i].vendor_guid;
if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))

View File

@@ -95,7 +95,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
grub_efi_handle_t handle = handles[i];
grub_efi_status_t status;
grub_efi_uintn_t num_protocols;
grub_efi_guid_t **protocols;
grub_efi_packed_guid_t **protocols;
grub_efi_device_path_t *dp;
grub_printf ("Handle %p\n", handle);

View File

@@ -71,7 +71,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
grub_printf (", Version=%x\n", st->firmware_revision);
grub_printf ("%ld tables:\n", st->num_table_entries);
grub_printf ("%lld tables:\n", (long long) st->num_table_entries);
t = st->configuration_table;
for (i = 0; i < st->num_table_entries; i++)
{

View File

@@ -32,7 +32,7 @@ disp_sal (void *table)
{
struct grub_efi_sal_system_table *t = table;
void *desc;
grub_uint32_t len, l;
grub_uint32_t len, l, i;
grub_printf ("SAL rev: %02x, signature: %x, len:%x\n",
t->sal_rev, t->signature, t->total_table_len);
@@ -44,7 +44,9 @@ disp_sal (void *table)
desc = t->entries;
len = t->total_table_len - sizeof (struct grub_efi_sal_system_table);
while (len > 0)
if (t->total_table_len <= sizeof (struct grub_efi_sal_system_table))
return;
for (i = 0; i < t->entry_count; i++)
{
switch (*(grub_uint8_t *) desc)
{
@@ -123,6 +125,8 @@ disp_sal (void *table)
return;
}
desc = (grub_uint8_t *)desc + l;
if (len <= l)
return;
len -= l;
}
}
@@ -135,12 +139,12 @@ grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
const grub_efi_system_table_t *st = grub_efi_system_table;
grub_efi_configuration_table_t *t = st->configuration_table;
unsigned int i;
grub_efi_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
grub_efi_packed_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
for (i = 0; i < st->num_table_entries; i++)
{
if (grub_memcmp (&guid, &t->vendor_guid,
sizeof (grub_efi_guid_t)) == 0)
sizeof (grub_efi_packed_guid_t)) == 0)
{
disp_sal (t->vendor_table);
return GRUB_ERR_NONE;

641
grub-core/commands/file.c Normal file
View File

@@ -0,0 +1,641 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/env.h>
#include <grub/command.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/file.h>
#include <grub/elf.h>
#include <grub/xen_file.h>
#include <grub/efi/pe32.h>
#include <grub/i386/linux.h>
#include <grub/xnu.h>
#include <grub/machoload.h>
#include <grub/fileid.h>
GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = {
{"is-i386-xen-pae-domu", 0, 0,
N_("Check if FILE can be booted as i386 PAE Xen unprivileged guest kernel"),
0, 0},
{"is-x86_64-xen-domu", 0, 0,
N_("Check if FILE can be booted as x86_64 Xen unprivileged guest kernel"), 0, 0},
{"is-x86-xen-dom0", 0, 0,
N_("Check if FILE can be used as Xen x86 privileged guest kernel"), 0, 0},
{"is-x86-multiboot", 0, 0,
N_("Check if FILE can be used as x86 multiboot kernel"), 0, 0},
{"is-x86-multiboot2", 0, 0,
N_("Check if FILE can be used as x86 multiboot2 kernel"), 0, 0},
{"is-arm-linux", 0, 0,
N_("Check if FILE is ARM Linux"), 0, 0},
{"is-ia64-linux", 0, 0,
N_("Check if FILE is IA64 Linux"), 0, 0},
{"is-mips-linux", 0, 0,
N_("Check if FILE is MIPS Linux"), 0, 0},
{"is-mipsel-linux", 0, 0,
N_("Check if FILE is MIPSEL Linux"), 0, 0},
{"is-sparc64-linux", 0, 0,
N_("Check if FILE is SPARC64 Linux"), 0, 0},
{"is-powerpc-linux", 0, 0,
N_("Check if FILE is POWERPC Linux"), 0, 0},
{"is-x86-linux", 0, 0,
N_("Check if FILE is x86 Linux"), 0, 0},
{"is-x86-linux32", 0, 0,
N_("Check if FILE is x86 Linux supporting 32-bit protocol"), 0, 0},
{"is-x86-kfreebsd", 0, 0,
N_("Check if FILE is x86 kFreeBSD"), 0, 0},
{"is-i386-kfreebsd", 0, 0,
N_("Check if FILE is i386 kFreeBSD"), 0, 0},
{"is-x86_64-kfreebsd", 0, 0,
N_("Check if FILE is x86_64 kFreeBSD"), 0, 0},
{"is-x86-knetbsd", 0, 0,
N_("Check if FILE is x86 kNetBSD"), 0, 0},
{"is-i386-knetbsd", 0, 0,
N_("Check if FILE is i386 kNetBSD"), 0, 0},
{"is-x86_64-knetbsd", 0, 0,
N_("Check if FILE is x86_64 kNetBSD"), 0, 0},
{"is-i386-efi", 0, 0,
N_("Check if FILE is i386 EFI file"), 0, 0},
{"is-x86_64-efi", 0, 0,
N_("Check if FILE is x86_64 EFI file"), 0, 0},
{"is-ia64-efi", 0, 0,
N_("Check if FILE is IA64 EFI file"), 0, 0},
{"is-arm-efi", 0, 0,
N_("Check if FILE is ARM EFI file"), 0, 0},
{"is-hibernated-hiberfil", 0, 0,
N_("Check if FILE is hiberfil.sys in hibernated state"), 0, 0},
{"is-x86_64-xnu", 0, 0,
N_("Check if FILE is x86_64 XNU (Mac OS X kernel)"), 0, 0},
{"is-i386-xnu", 0, 0,
N_("Check if FILE is i386 XNU (Mac OS X kernel)"), 0, 0},
{"is-xnu-hibr", 0, 0,
N_("Check if FILE is XNU (Mac OS X kernel) hibernated image"), 0, 0},
{"is-x86-bios-bootsector", 0, 0,
N_("Check if FILE is BIOS bootsector"), 0, 0},
{0, 0, 0, 0, 0, 0}
};
enum
{
IS_PAE_DOMU,
IS_64_DOMU,
IS_DOM0,
IS_MULTIBOOT,
IS_MULTIBOOT2,
IS_ARM_LINUX,
IS_IA64_LINUX,
IS_MIPS_LINUX,
IS_MIPSEL_LINUX,
IS_SPARC64_LINUX,
IS_POWERPC_LINUX,
IS_X86_LINUX,
IS_X86_LINUX32,
IS_X86_KFREEBSD,
IS_X86_KFREEBSD32,
IS_X86_KFREEBSD64,
IS_X86_KNETBSD,
IS_X86_KNETBSD32,
IS_X86_KNETBSD64,
IS_32_EFI,
IS_64_EFI,
IS_IA_EFI,
IS_ARM_EFI,
IS_HIBERNATED,
IS_XNU64,
IS_XNU32,
IS_XNU_HIBR,
IS_BIOS_BOOTSECTOR,
OPT_TYPE_MIN = IS_PAE_DOMU,
OPT_TYPE_MAX = IS_BIOS_BOOTSECTOR
};
static grub_err_t
grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file = 0;
grub_elf_t elf = 0;
grub_err_t err;
int type = -1, i;
int ret = 0;
grub_macho_t macho = 0;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
for (i = OPT_TYPE_MIN; i <= OPT_TYPE_MAX; i++)
if (ctxt->state[i].set)
{
if (type == -1)
{
type = i;
continue;
}
return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple types specified");
}
if (type == -1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no type specified");
file = grub_file_open (args[0]);
if (!file)
return grub_errno;
switch (type)
{
case IS_BIOS_BOOTSECTOR:
{
grub_uint16_t sig;
if (grub_file_size (file) != 512)
break;
if (grub_file_seek (file, 510) == (grub_size_t) -1)
break;
if (grub_file_read (file, &sig, 2) != 2)
break;
if (sig != grub_cpu_to_le16_compile_time (0xaa55))
break;
ret = 1;
break;
}
case IS_IA64_LINUX:
{
Elf64_Ehdr ehdr;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_ident[EI_CLASS] != ELFCLASS64
|| ehdr.e_ident[EI_DATA] != ELFDATA2LSB
|| ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_IA_64))
break;
ret = 1;
break;
}
case IS_SPARC64_LINUX:
{
Elf64_Ehdr ehdr;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_ident[EI_CLASS] != ELFCLASS64
|| ehdr.e_ident[EI_DATA] != ELFDATA2MSB)
break;
if (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_SPARCV9)
|| ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC))
break;
ret = 1;
break;
}
case IS_POWERPC_LINUX:
{
Elf32_Ehdr ehdr;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB
|| (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_PPC)
&& ehdr.e_machine !=
grub_cpu_to_le16_compile_time (EM_PPC64)))
break;
if (ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC)
&& ehdr.e_type != grub_cpu_to_be16_compile_time (ET_DYN))
break;
ret = 1;
break;
}
case IS_MIPS_LINUX:
{
Elf32_Ehdr ehdr;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB
|| ehdr.e_machine != grub_cpu_to_be16_compile_time (EM_MIPS)
|| ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC))
break;
ret = 1;
break;
}
case IS_X86_KNETBSD:
case IS_X86_KNETBSD32:
case IS_X86_KNETBSD64:
{
int is32, is64;
elf = grub_elf_file (file, file->name);
if (elf->ehdr.ehdr32.e_type != grub_cpu_to_le16_compile_time (ET_EXEC)
|| elf->ehdr.ehdr32.e_ident[EI_DATA] != ELFDATA2LSB)
break;
is32 = grub_elf_is_elf32 (elf);
is64 = grub_elf_is_elf64 (elf);
if (!is32 && !is64)
break;
if (!is32 && type == IS_X86_KNETBSD32)
break;
if (!is64 && type == IS_X86_KNETBSD64)
break;
if (is64)
ret = grub_file_check_netbsd64 (elf);
if (is32)
ret = grub_file_check_netbsd32 (elf);
break;
}
case IS_X86_KFREEBSD:
case IS_X86_KFREEBSD32:
case IS_X86_KFREEBSD64:
{
Elf32_Ehdr ehdr;
int is32, is64;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_type != grub_cpu_to_le16_compile_time (ET_EXEC)
|| ehdr.e_ident[EI_DATA] != ELFDATA2LSB)
break;
if (ehdr.e_ident[EI_OSABI] != ELFOSABI_FREEBSD)
break;
is32 = (ehdr.e_machine == grub_cpu_to_le16_compile_time (EM_386)
&& ehdr.e_ident[EI_CLASS] == ELFCLASS32);
is64 = (ehdr.e_machine == grub_cpu_to_le16_compile_time (EM_X86_64)
&& ehdr.e_ident[EI_CLASS] == ELFCLASS64);
if (!is32 && !is64)
break;
if (!is32 && (type == IS_X86_KFREEBSD32 || type == IS_X86_KNETBSD32))
break;
if (!is64 && (type == IS_X86_KFREEBSD64 || type == IS_X86_KNETBSD64))
break;
ret = 1;
break;
}
case IS_MIPSEL_LINUX:
{
Elf32_Ehdr ehdr;
if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
break;
if (ehdr.e_ident[EI_MAG0] != ELFMAG0
|| ehdr.e_ident[EI_MAG1] != ELFMAG1
|| ehdr.e_ident[EI_MAG2] != ELFMAG2
|| ehdr.e_ident[EI_MAG3] != ELFMAG3
|| ehdr.e_ident[EI_VERSION] != EV_CURRENT
|| ehdr.e_version != EV_CURRENT)
break;
if (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_MIPS)
|| ehdr.e_type != grub_cpu_to_le16_compile_time (ET_EXEC))
break;
ret = 1;
break;
}
case IS_ARM_LINUX:
{
grub_uint32_t sig;
if (grub_file_seek (file, 0x24) == (grub_size_t) -1)
break;
if (grub_file_read (file, &sig, 4) != 4)
break;
if (sig != grub_cpu_to_le32_compile_time (0x016f2818))
break;
ret = 1;
break;
}
case IS_PAE_DOMU ... IS_DOM0:
{
struct grub_xen_file_info xen_inf;
elf = grub_xen_file (file);
if (!elf)
break;
err = grub_xen_get_info (elf, &xen_inf);
if (err)
break;
/* Unfortuntely no way to check if kernel supports dom0. */
if (type == IS_DOM0)
ret = 1;
if (type == IS_PAE_DOMU)
ret = (xen_inf.arch == GRUB_XEN_FILE_I386_PAE
|| xen_inf.arch == GRUB_XEN_FILE_I386_PAE_BIMODE);
if (type == IS_64_DOMU)
ret = (xen_inf.arch == GRUB_XEN_FILE_X86_64);
break;
}
case IS_MULTIBOOT:
case IS_MULTIBOOT2:
{
grub_uint32_t *buffer;
grub_ssize_t len;
grub_size_t search_size;
grub_uint32_t *header;
grub_uint32_t magic;
grub_size_t step;
if (type == IS_MULTIBOOT2)
{
search_size = 32768;
magic = grub_cpu_to_le32_compile_time (0xe85250d6);
step = 2;
}
else
{
search_size = 8192;
magic = grub_cpu_to_le32_compile_time (0x1BADB002);
step = 1;
}
buffer = grub_malloc (search_size);
if (!buffer)
break;
len = grub_file_read (file, buffer, search_size);
if (len < 32)
{
grub_free (buffer);
break;
}
/* Look for the multiboot header in the buffer. The header should
be at least 12 bytes and aligned on a 4-byte boundary. */
for (header = buffer;
((char *) header <=
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
|| (header = 0); header += step)
{
if (header[0] == magic
&& !(grub_le_to_cpu32 (header[0])
+ grub_le_to_cpu32 (header[1])
+ grub_le_to_cpu32 (header[2])
+ (type == IS_MULTIBOOT2
? grub_le_to_cpu32 (header[3]) : 0)))
break;
}
if (header != 0)
ret = 1;
grub_free (buffer);
break;
}
case IS_X86_LINUX32:
case IS_X86_LINUX:
{
struct linux_kernel_header lh;
if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
break;
if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
break;
if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS)
break;
/* FIXME: some really old kernels (< 1.3.73) will fail this. */
if (lh.header !=
grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0200)
break;
if (type == IS_X86_LINUX)
{
ret = 1;
break;
}
/* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
still not support 32-bit boot. */
if (lh.header !=
grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0203)
break;
if (!(lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL))
break;
ret = 1;
break;
}
case IS_HIBERNATED:
{
grub_uint8_t hibr_file_magic[4];
if (grub_file_read (file, &hibr_file_magic, sizeof (hibr_file_magic))
!= sizeof (hibr_file_magic))
break;
if (grub_memcmp ("hibr", hibr_file_magic, sizeof (hibr_file_magic)) ==
0
|| grub_memcmp ("HIBR", hibr_file_magic,
sizeof (hibr_file_magic)) == 0)
ret = 1;
break;
}
case IS_XNU64:
case IS_XNU32:
{
macho = grub_macho_open (args[0], (type == IS_XNU64));
if (!macho)
break;
/* FIXME: more checks? */
ret = 1;
break;
}
case IS_XNU_HIBR:
{
struct grub_xnu_hibernate_header hibhead;
if (grub_file_read (file, &hibhead, sizeof (hibhead))
!= sizeof (hibhead))
break;
if (hibhead.magic !=
grub_cpu_to_le32_compile_time (GRUB_XNU_HIBERNATE_MAGIC))
break;
ret = 1;
break;
}
case IS_32_EFI:
case IS_64_EFI:
case IS_IA_EFI:
case IS_ARM_EFI:
{
char signature[4];
grub_uint32_t pe_offset;
struct grub_pe32_coff_header coff_head;
if (grub_file_read (file, signature, 2) != 2)
break;
if (signature[0] != 'M' || signature[1] != 'Z')
break;
if ((grub_ssize_t) grub_file_seek (file, 0x3c) == -1)
break;
if (grub_file_read (file, &pe_offset, 4) != 4)
break;
if ((grub_ssize_t) grub_file_seek (file, grub_le_to_cpu32 (pe_offset))
== -1)
break;
if (grub_file_read (file, signature, 4) != 4)
break;
if (signature[0] != 'P' || signature[1] != 'E'
|| signature[2] != '\0' || signature[3] != '\0')
break;
if (grub_file_read (file, &coff_head, sizeof (coff_head))
!= sizeof (coff_head))
break;
if (type == IS_32_EFI
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_I386))
break;
if (type == IS_64_EFI
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_X86_64))
break;
if (type == IS_IA_EFI
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_IA64))
break;
if (type == IS_ARM_EFI
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARMTHUMB_MIXED))
break;
if (type == IS_64_EFI || type == IS_64_EFI)
{
struct grub_pe64_optional_header o64;
if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64))
break;
if (o64.magic !=
grub_cpu_to_le16_compile_time (GRUB_PE32_PE64_MAGIC))
break;
if (o64.subsystem !=
grub_cpu_to_le16_compile_time
(GRUB_PE32_SUBSYSTEM_EFI_APPLICATION))
break;
ret = 1;
break;
}
if (type == IS_32_EFI || type == IS_ARM_EFI)
{
struct grub_pe32_optional_header o32;
if (grub_file_read (file, &o32, sizeof (o32)) != sizeof (o32))
break;
if (o32.magic !=
grub_cpu_to_le16_compile_time (GRUB_PE32_PE32_MAGIC))
break;
if (o32.subsystem !=
grub_cpu_to_le16_compile_time
(GRUB_PE32_SUBSYSTEM_EFI_APPLICATION))
break;
ret = 1;
break;
}
break;
}
}
if (elf)
grub_elf_close (elf);
else if (macho)
grub_macho_close (macho);
else if (file)
grub_file_close (file);
if (!ret && (grub_errno == GRUB_ERR_BAD_OS || grub_errno == GRUB_ERR_NONE))
/* TRANSLATORS: it's a standalone boolean value,
opposite of "true". */
grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
return grub_errno;
}
static grub_extcmd_t cmd;
GRUB_MOD_INIT(file)
{
cmd = grub_register_extcmd ("file", grub_cmd_file, 0,
N_("OPTIONS FILE"),
N_("Check if FILE is of specified type."),
options);
}
GRUB_MOD_FINI(file)
{
grub_unregister_extcmd (cmd);
}

View File

@@ -0,0 +1,5 @@
#define GRUB_TARGET_WORDSIZE 32
#define XX 32
#define ehdrXX ehdr32
#define grub_file_check_netbsdXX grub_file_check_netbsd32
#include "fileXX.c"

View File

@@ -0,0 +1,5 @@
#define GRUB_TARGET_WORDSIZE 64
#define XX 64
#define ehdrXX ehdr64
#define grub_file_check_netbsdXX grub_file_check_netbsd64
#include "fileXX.c"

View File

@@ -0,0 +1,70 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/fileid.h>
#include <grub/elfload.h>
#pragma GCC diagnostic ignored "-Wcast-align"
int
grub_file_check_netbsdXX (grub_elf_t elf)
{
Elf_Shdr *s, *s0;
grub_size_t shnum = elf->ehdr.ehdrXX.e_shnum;
grub_size_t shentsize = elf->ehdr.ehdrXX.e_shentsize;
grub_size_t shsize = shnum * shentsize;
grub_off_t stroff;
if (!shnum || !shentsize)
return 0;
s0 = grub_malloc (shsize);
if (!s0)
return 0;
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
return 0;
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
return 0;
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
stroff = s->sh_offset;
for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
s = (Elf_Shdr *) ((char *) s + shentsize))
{
char name[sizeof(".note.netbsd.ident")];
grub_memset (name, 0, sizeof (name));
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
return grub_errno;
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
{
if (grub_errno)
return grub_errno;
continue;
}
if (grub_memcmp (name, ".note.netbsd.ident",
sizeof(".note.netbsd.ident")) != 0)
continue;
return 1;
}
return 0;
}

View File

@@ -63,17 +63,23 @@ hextoval (char c)
static grub_err_t
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
{
GRUB_PROPERLY_ALIGNED_ARRAY (context, hash->contextsize);
grub_uint8_t readbuf[4096];
void *context;
grub_uint8_t *readbuf;
#define BUF_SIZE 4096
readbuf = grub_malloc (BUF_SIZE);
if (!readbuf)
return grub_errno;
context = grub_zalloc (hash->contextsize);
if (!readbuf || !context)
goto fail;
grub_memset (context, 0, sizeof (context));
hash->init (context);
while (1)
{
grub_ssize_t r;
r = grub_file_read (file, readbuf, sizeof (readbuf));
r = grub_file_read (file, readbuf, BUF_SIZE);
if (r < 0)
return grub_errno;
goto fail;
if (r == 0)
break;
hash->write (context, readbuf, r);
@@ -81,7 +87,15 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
hash->final (context);
grub_memcpy (result, hash->read (context), hash->mdlen);
grub_free (readbuf);
grub_free (context);
return GRUB_ERR_NONE;
fail:
grub_free (readbuf);
grub_free (context);
return grub_errno;
}
static grub_err_t
@@ -90,12 +104,15 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
{
grub_file_t hashlist, file;
char *buf = NULL;
grub_uint8_t expected[hash->mdlen];
grub_uint8_t actual[hash->mdlen];
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
grub_err_t err;
unsigned i;
unsigned unread = 0, mismatch = 0;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
hashlist = grub_file_open (hashfilename);
if (!hashlist)
return grub_errno;
@@ -205,6 +222,9 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
if (!hash)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
if (state[2].set)
prefix = state[2].arg;
@@ -218,7 +238,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
for (i = 0; i < (unsigned) argc; i++)
{
GRUB_PROPERLY_ALIGNED_ARRAY (result, hash->mdlen);
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
grub_file_t file;
grub_err_t err;
unsigned j;

View File

@@ -55,7 +55,7 @@ GRUB_MOD_INIT(cmosdump)
{
cmd = grub_register_command ("cmosdump", grub_cmd_cmosdump,
0,
N_("Dump CMOS contents."));
N_("Show raw dump of the CMOS contents."));
}
GRUB_MOD_FINI(cmosdump)

View File

@@ -81,7 +81,25 @@ grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
return grub_cmos_write (byte, value & (~(1 << bit)));
}
static grub_command_t cmd, cmd_clean;
static grub_err_t
grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int byte, bit;
grub_err_t err;
grub_uint8_t value;
err = parse_args (argc, argv, &byte, &bit);
if (err)
return err;
err = grub_cmos_read (byte, &value);
if (err)
return err;
return grub_cmos_write (byte, value | (1 << bit));
}
static grub_command_t cmd, cmd_clean, cmd_set;
GRUB_MOD_INIT(cmostest)
@@ -91,11 +109,16 @@ GRUB_MOD_INIT(cmostest)
N_("Test bit at BYTE:BIT in CMOS."));
cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
N_("BYTE:BIT"),
N_("Clean bit at BYTE:BIT in CMOS."));
N_("Clear bit at BYTE:BIT in CMOS."));
cmd_set = grub_register_command ("cmosset", grub_cmd_cmosset,
N_("BYTE:BIT"),
/* TRANSLATORS: A bit may be either set (1) or clear (0). */
N_("Set bit at BYTE:BIT in CMOS."));
}
GRUB_MOD_FINI(cmostest)
{
grub_unregister_command (cmd);
grub_unregister_command (cmd_clean);
grub_unregister_command (cmd_set);
}

View File

@@ -109,7 +109,7 @@ GRUB_MOD_INIT(cbtime)
{
cmd_boottime =
grub_register_command ("coreboot_boottime", grub_cmd_coreboot_boottime,
0, N_("Get coreboot boot time statistics."));
0, N_("Show coreboot boot time statistics."));
}
GRUB_MOD_FINI(cbtime)

View File

@@ -34,19 +34,38 @@ static const struct grub_arg_option options[] =
/* TRANSLATORS: "(default)" at the end means that this option is used if
no argument is specified. */
{"long-mode", 'l', 0, N_("Check if CPU supports 64-bit (long) mode (default)."), 0, 0},
{"pae", 'p', 0, N_("Check if CPU supports Physical Address Extension."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
#define bit_LM (1 << 29)
enum
{
MODE_LM = 0,
MODE_PAE = 1
};
unsigned char grub_cpuid_has_longmode = 0;
enum
{
bit_PAE = (1 << 6),
};
enum
{
bit_LM = (1 << 29)
};
unsigned char grub_cpuid_has_longmode = 0, grub_cpuid_has_pae = 0;
static grub_err_t
grub_cmd_cpuid (grub_extcmd_context_t ctxt __attribute__ ((unused)),
grub_cmd_cpuid (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
return grub_cpuid_has_longmode ? GRUB_ERR_NONE
int val = 0;
if (ctxt->state[MODE_PAE].set)
val = grub_cpuid_has_pae;
else
val = grub_cpuid_has_longmode;
return val ? GRUB_ERR_NONE
/* TRANSLATORS: it's a standalone boolean value,
opposite of "true". */
: grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
@@ -59,6 +78,7 @@ GRUB_MOD_INIT(cpuid)
#ifdef __x86_64__
/* grub-emu */
grub_cpuid_has_longmode = 1;
grub_cpuid_has_pae = 1;
#else
unsigned int eax, ebx, ecx, edx;
unsigned int max_level;
@@ -79,6 +99,12 @@ GRUB_MOD_INIT(cpuid)
if (max_level == 0)
goto done;
if (max_level >= 1)
{
grub_cpuid (1, eax, ebx, ecx, edx);
grub_cpuid_has_pae = !!(edx & bit_PAE);
}
grub_cpuid (0x80000000, eax, ebx, ecx, edx);
ext_level = eax;
if (ext_level < 0x80000000)

View File

@@ -74,7 +74,7 @@ typedef struct drivemap_node
grub_uint8_t redirto;
} drivemap_node_t;
typedef struct __attribute__ ((packed)) int13map_node
typedef struct GRUB_PACKED int13map_node
{
grub_uint8_t disknum;
grub_uint8_t mapto;

View File

@@ -314,7 +314,11 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
/* First try Linux. */
if (kernel_type == GUESS_IT || kernel_type == LINUX)
{
#ifdef GRUB_MACHINE_PCBIOS
cmd = grub_command_find ("linux16");
#else
cmd = grub_command_find ("linux");
#endif
if (cmd)
{
if (!(cmd->func) (cmd, cutargc, cutargs))
@@ -358,7 +362,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
dev = grub_device_open (0);
if (dev && dev->disk
&& dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID
&& dev->disk->dev->id >= 0x80 && dev->disk->dev->id <= 0x90)
&& dev->disk->id >= 0x80 && dev->disk->id <= 0x90)
{
struct grub_partition *part = dev->disk->partition;
bsd_device = dev->disk->id - 0x80 - hdbias;
@@ -469,10 +473,19 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)),
if (kernel_type == LINUX)
{
#ifdef GRUB_MACHINE_PCBIOS
cmd = grub_command_find ("initrd16");
#else
cmd = grub_command_find ("initrd");
#endif
if (!cmd)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
"initrd16");
#ifdef GRUB_MACHINE_PCBIOS
"initrd16"
#else
"initrd"
#endif
);
return cmd->func (cmd, argc, args);
}
@@ -546,8 +559,6 @@ struct legacy_md5_password
grub_uint8_t hash[MD5_HASHLEN];
};
#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
static int
check_password_md5_real (const char *entered,
struct legacy_md5_password *pw)
@@ -555,8 +566,13 @@ check_password_md5_real (const char *entered,
grub_size_t enteredlen = grub_strlen (entered);
unsigned char alt_result[MD5_HASHLEN];
unsigned char *digest;
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
grub_uint8_t *ctx;
grub_size_t i;
int ret;
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
if (!ctx)
return 0;
GRUB_MD_MD5->init (ctx);
GRUB_MD_MD5->write (ctx, entered, enteredlen);
@@ -602,7 +618,9 @@ check_password_md5_real (const char *entered,
GRUB_MD_MD5->final (ctx);
}
return (grub_crypto_memcmp (digest, pw->hash, MD5_HASHLEN) == 0);
ret = (grub_crypto_memcmp (digest, pw->hash, MD5_HASHLEN) == 0);
grub_free (ctx);
return ret;
}
static grub_err_t
@@ -725,18 +743,12 @@ grub_cmd_legacy_password (struct grub_command *mycmd __attribute__ ((unused)),
NULL);
}
static grub_err_t
grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unused)),
int argc, char **args)
int
grub_legacy_check_md5_password (int argc, char **args,
char *entered)
{
struct legacy_md5_password *pw = NULL;
char entered[GRUB_AUTH_MAX_PASSLEN];
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
grub_puts_ (N_("Enter password: "));
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
return GRUB_ACCESS_DENIED;
int ret;
if (args[0][0] != '-' || args[0][1] != '-')
{
@@ -745,17 +757,33 @@ grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unuse
grub_memset (correct, 0, sizeof (correct));
grub_strncpy (correct, args[0], sizeof (correct));
if (grub_crypto_memcmp (entered, correct, GRUB_AUTH_MAX_PASSLEN) != 0)
return GRUB_ACCESS_DENIED;
return GRUB_ERR_NONE;
return grub_crypto_memcmp (entered, correct, GRUB_AUTH_MAX_PASSLEN) == 0;
}
pw = parse_legacy_md5 (argc, args);
if (!pw)
return 0;
ret = check_password_md5_real (entered, pw);
grub_free (pw);
return ret;
}
static grub_err_t
grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unused)),
int argc, char **args)
{
char entered[GRUB_AUTH_MAX_PASSLEN];
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
grub_puts_ (N_("Enter password: "));
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
return GRUB_ACCESS_DENIED;
if (!check_password_md5_real (entered, pw))
if (!grub_legacy_check_md5_password (argc, args,
entered))
return GRUB_ACCESS_DENIED;
return GRUB_ERR_NONE;

View File

@@ -259,10 +259,28 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
for (p = blocklists; p; p = p->next)
{
struct blocklist *q;
/* Check if any pair of blocks overlap. */
for (q = p->next; q; q = q->next)
{
/* Check if any pair of blocks overlap. */
if (p->sector == q->sector)
grub_disk_addr_t s1, s2;
grub_disk_addr_t e1, e2, t;
s1 = p->sector;
e1 = s1 + ((p->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
s2 = q->sector;
e2 = s2 + ((q->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
if (s2 > s1)
{
t = s2;
s2 = s1;
s1 = t;
t = e2;
e2 = e1;
e1 = t;
}
if (e1 > s2)
{
/* This might be actually valid, but it is unbelievable that
any filesystem makes such a silly allocation. */
@@ -286,9 +304,18 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
part_start = grub_partition_get_start (disk->partition);
buf = grub_envblk_buffer (envblk);
char *blockbuf = NULL;
grub_size_t blockbuf_len = 0;
for (p = blocklists, index = 0; p; index += p->length, p = p->next)
{
char blockbuf[GRUB_DISK_SECTOR_SIZE];
if (p->length > blockbuf_len)
{
grub_free (blockbuf);
blockbuf_len = 2 * p->length;
blockbuf = grub_malloc (blockbuf_len);
if (!blockbuf)
return grub_errno;
}
if (grub_disk_read (disk, p->sector - part_start,
p->offset, p->length, blockbuf))
@@ -340,10 +367,6 @@ save_env_read_hook (grub_disk_addr_t sector, unsigned offset, unsigned length,
struct grub_cmd_save_env_ctx *ctx = data;
struct blocklist *block;
if (offset + length > GRUB_DISK_SECTOR_SIZE)
/* Seemingly a bug. */
return;
block = grub_malloc (sizeof (*block));
if (! block)
return;
@@ -409,6 +432,8 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
goto fail;
}
}
else
grub_envblk_delete (envblk, args[0]);
argc--;
args++;
@@ -430,7 +455,7 @@ GRUB_MOD_INIT(loadenv)
{
cmd_load =
grub_register_extcmd ("load_env", grub_cmd_load_env, 0,
N_("[-f FILE] [-s|--skip-sig] [whitelisted_variable_name] [...]"),
N_("[-f FILE] [-s|--skip-sig] [variable_name_to_whitelist] [...]"),
N_("Load variables from environment block file."),
options);
cmd_list =

View File

@@ -116,11 +116,35 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info,
if (! info->dir)
{
if (! ctx->human)
grub_printf ("%-12llu", (unsigned long long) info->size);
grub_file_t file;
char *pathname;
if (ctx->dirname[grub_strlen (ctx->dirname) - 1] == '/')
pathname = grub_xasprintf ("%s%s", ctx->dirname, filename);
else
grub_printf ("%-12s", grub_get_human_size (info->size,
GRUB_HUMAN_SIZE_SHORT));
pathname = grub_xasprintf ("%s/%s", ctx->dirname, filename);
if (!pathname)
return 1;
/* XXX: For ext2fs symlinks are detected as files while they
should be reported as directories. */
grub_file_filter_disable_compression ();
file = grub_file_open (pathname);
if (! file)
{
grub_errno = 0;
grub_free (pathname);
return 0;
}
if (! ctx->human)
grub_printf ("%-12llu", (unsigned long long) file->size);
else
grub_printf ("%-12s", grub_get_human_size (file->size,
GRUB_HUMAN_SIZE_SHORT));
grub_file_close (file);
grub_free (pathname);
}
else
grub_printf ("%-12s", _("DIR"));

View File

@@ -0,0 +1,236 @@
/* hfspbless.c - set the hfs+ boot directory. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2007,2008,2009,2012,2013 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/command.h>
#include <grub/fs.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/device.h>
#include <grub/disk.h>
#include <grub/hfsplus.h>
#include <grub/hfs.h>
#include <grub/partition.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/err.h>
GRUB_MOD_LICENSE ("GPLv3+");
struct find_node_context
{
grub_uint64_t inode_found;
char *dirname;
enum
{ NONE, FILE, DIR } found;
};
static int
find_inode (const char *filename,
const struct grub_dirhook_info *info, void *data)
{
struct find_node_context *ctx = data;
if (!info->inodeset)
return 0;
if ((grub_strcmp (ctx->dirname, filename) == 0
|| (info->case_insensitive
&& grub_strcasecmp (ctx->dirname, filename) == 0)))
{
ctx->inode_found = info->inode;
ctx->found = info->dir ? DIR : FILE;
}
return 0;
}
grub_err_t
grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
int intel)
{
grub_err_t err;
union
{
struct grub_hfs_sblock hfs;
struct grub_hfsplus_volheader hfsplus;
} volheader;
grub_disk_addr_t embedded_offset;
if (intel && is_dir)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"can't bless a directory for mactel");
if (!intel && !is_dir)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"can't bless a file for mac PPC");
/* Read the bootblock. */
err = grub_disk_read (dev->disk, GRUB_HFSPLUS_SBLOCK, 0, sizeof (volheader),
(char *) &volheader);
if (err)
return err;
embedded_offset = 0;
if (grub_be_to_cpu16 (volheader.hfs.magic) == GRUB_HFS_MAGIC)
{
int extent_start;
int ablk_size;
int ablk_start;
/* See if there's an embedded HFS+ filesystem. */
if (grub_be_to_cpu16 (volheader.hfs.embed_sig) != GRUB_HFSPLUS_MAGIC)
{
if (intel)
volheader.hfs.intel_bootfile = grub_be_to_cpu32 (inode);
else
volheader.hfs.ppc_bootdir = grub_be_to_cpu32 (inode);
return GRUB_ERR_NONE;
}
/* Calculate the offset needed to translate HFS+ sector numbers. */
extent_start =
grub_be_to_cpu16 (volheader.hfs.embed_extent.first_block);
ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
embedded_offset = (ablk_start
+ extent_start
* (ablk_size >> GRUB_DISK_SECTOR_BITS));
err =
grub_disk_read (dev->disk, embedded_offset + GRUB_HFSPLUS_SBLOCK, 0,
sizeof (volheader), (char *) &volheader);
if (err)
return err;
}
if ((grub_be_to_cpu16 (volheader.hfsplus.magic) != GRUB_HFSPLUS_MAGIC)
&& (grub_be_to_cpu16 (volheader.hfsplus.magic) != GRUB_HFSPLUSX_MAGIC))
return grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
if (intel)
volheader.hfsplus.intel_bootfile = grub_be_to_cpu32 (inode);
else
volheader.hfsplus.ppc_bootdir = grub_be_to_cpu32 (inode);
return grub_disk_write (dev->disk, embedded_offset + GRUB_HFSPLUS_SBLOCK, 0,
sizeof (volheader), (char *) &volheader);
}
grub_err_t
grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel)
{
grub_fs_t fs;
char *path, *tail;
struct find_node_context ctx;
fs = grub_fs_probe (dev);
if (!fs || (grub_strcmp (fs->name, "hfsplus") != 0
&& grub_strcmp (fs->name, "hfs") != 0))
return grub_error (GRUB_ERR_BAD_FS, "no suitable FS found");
path = grub_strdup (path_in);
if (!path)
return grub_errno;
tail = path + grub_strlen (path) - 1;
/* Remove trailing '/'. */
while (tail != path && *tail == '/')
*(tail--) = 0;
tail = grub_strrchr (path, '/');
ctx.found = 0;
if (tail)
{
*tail = 0;
ctx.dirname = tail + 1;
(fs->dir) (dev, *path == 0 ? "/" : path, find_inode, &ctx);
}
else
{
ctx.dirname = path + 1;
(fs->dir) (dev, "/", find_inode, &ctx);
}
if (!ctx.found)
{
grub_free (path);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
path_in);
}
grub_free (path);
return grub_mac_bless_inode (dev, (grub_uint32_t) ctx.inode_found,
(ctx.found == DIR), intel);
}
static grub_err_t
grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
{
char *device_name;
char *path = 0;
grub_device_t dev;
grub_err_t err;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
device_name = grub_file_get_device_name (args[0]);
dev = grub_device_open (device_name);
path = grub_strchr (args[0], ')');
if (!path)
path = args[0];
else
path = path + 1;
if (!path || *path == 0 || !device_name)
{
if (dev)
grub_device_close (dev);
grub_free (device_name);
grub_free (path);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
}
err = grub_mac_bless_file (dev, path, cmd->name[3] == 't');
grub_device_close (dev);
grub_free (device_name);
return err;
}
static grub_command_t cmd, cmd_ppc;
GRUB_MOD_INIT(macbless)
{
cmd = grub_register_command ("mactelbless", grub_cmd_macbless,
N_("FILE"),
N_
("Bless FILE of HFS or HFS+ partition for intel macs."));
cmd_ppc =
grub_register_command ("macppcbless", grub_cmd_macbless, N_("DIR"),
N_
("Bless DIR of HFS or HFS+ partition for PPC macs."));
}
GRUB_MOD_FINI(macbless)
{
grub_unregister_command (cmd);
grub_unregister_command (cmd_ppc);
}

View File

@@ -101,12 +101,18 @@ grub_mini_cmd_dump (struct grub_command *cmd __attribute__ ((unused)),
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no address specified");
addr = (grub_uint8_t *) grub_strtoul (argv[0], 0, 0);
#if GRUB_CPU_SIZEOF_VOID_P == GRUB_CPU_SIZEOF_LONG
#define grub_strtoaddr grub_strtoul
#else
#define grub_strtoaddr grub_strtoull
#endif
addr = (grub_uint8_t *) grub_strtoaddr (argv[0], 0, 0);
if (grub_errno)
return grub_errno;
if (argc > 1)
size = (grub_size_t) grub_strtoul (argv[1], 0, 0);
size = (grub_size_t) grub_strtoaddr (argv[1], 0, 0);
while (size--)
{

View File

@@ -75,6 +75,7 @@ get_uuid (const char *name, char **uuid, int getnative)
/* Native disks. */
case GRUB_DISK_DEVICE_ATA_ID:
case GRUB_DISK_DEVICE_SCSI_ID:
case GRUB_DISK_DEVICE_XEN:
if (getnative)
break;

View File

@@ -166,7 +166,7 @@ GRUB_MOD_INIT(pcidump)
{
cmd = grub_register_extcmd ("pcidump", grub_cmd_pcidump, 0,
N_("[-s POSITION] [-d DEVICE]"),
N_("Dump PCI configuration space."), options);
N_("Show raw dump of the PCI configuration space."), options);
}
GRUB_MOD_FINI(pcidump)

View File

@@ -0,0 +1,214 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/types.h>
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/file.h>
#include <grub/normal.h>
#include <grub/script_sh.h>
#include <grub/i18n.h>
#include <grub/term.h>
#include <grub/syslinux_parse.h>
#include <grub/crypto.h>
#include <grub/auth.h>
#include <grub/disk.h>
#include <grub/partition.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* Helper for syslinux_file. */
static grub_err_t
syslinux_file_getline (char **line, int cont __attribute__ ((unused)),
void *data __attribute__ ((unused)))
{
*line = 0;
return GRUB_ERR_NONE;
}
static const struct grub_arg_option options[] =
{
{"root", 'r', 0,
N_("root directory of the syslinux disk [default=/]."),
N_("DIR"), ARG_TYPE_STRING},
{"cwd", 'c', 0,
N_("current directory of the syslinux [default is parent directory of input file]."),
N_("DIR"), ARG_TYPE_STRING},
{"isolinux", 'i', 0, N_("assume input is an isolinux configuration file."), 0, 0},
{"pxelinux", 'p', 0, N_("assume input is a pxelinux configuration file."), 0, 0},
{"syslinux", 's', 0, N_("assume input is a syslinux configuration file."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
enum
{
OPTION_ROOT,
OPTION_CWD,
OPTION_ISOLINUX,
OPTION_PXELINUX,
OPTION_SYSLINUX
};
static grub_err_t
syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
{
char *result;
const char *root = ctxt->state[OPTION_ROOT].set ? ctxt->state[OPTION_ROOT].arg : "/";
const char *cwd = ctxt->state[OPTION_CWD].set ? ctxt->state[OPTION_CWD].arg : NULL;
grub_syslinux_flavour_t flav = GRUB_SYSLINUX_UNKNOWN;
char *cwdf = NULL;
grub_menu_t menu;
if (ctxt->state[OPTION_ISOLINUX].set)
flav = GRUB_SYSLINUX_ISOLINUX;
if (ctxt->state[OPTION_PXELINUX].set)
flav = GRUB_SYSLINUX_PXELINUX;
if (ctxt->state[OPTION_SYSLINUX].set)
flav = GRUB_SYSLINUX_SYSLINUX;
if (!cwd)
{
char *p;
cwdf = grub_strdup (filename);
if (!cwdf)
return grub_errno;
p = grub_strrchr (cwdf, '/');
if (!p)
{
grub_free (cwdf);
cwd = "/";
cwdf = NULL;
}
else
{
*p = '\0';
cwd = cwdf;
}
}
grub_dprintf ("syslinux",
"transforming syslinux config %s, root = %s, cwd = %s\n",
filename, root, cwd);
result = grub_syslinux_config_file (root, root, cwd, cwd, filename, flav);
if (!result)
return grub_errno;
grub_dprintf ("syslinux", "syslinux config transformed\n");
menu = grub_env_get_menu ();
if (! menu)
{
menu = grub_zalloc (sizeof (*menu));
if (! menu)
return grub_errno;
grub_env_set_menu (menu);
}
grub_normal_parse_line (result, syslinux_file_getline, NULL);
grub_print_error ();
grub_free (result);
grub_free (cwdf);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_syslinux_source (grub_extcmd_context_t ctxt,
int argc, char **args)
{
int new_env, extractor;
grub_err_t ret;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
extractor = (ctxt->extcmd->cmd->name[0] == 'e');
new_env = (ctxt->extcmd->cmd->name[extractor ? (sizeof ("extract_syslinux_entries_") - 1)
: (sizeof ("syslinux_") - 1)] == 'c');
if (new_env)
grub_cls ();
if (new_env && !extractor)
grub_env_context_open ();
if (extractor)
grub_env_extractor_open (!new_env);
ret = syslinux_file (ctxt, args[0]);
if (new_env)
{
grub_menu_t menu;
menu = grub_env_get_menu ();
if (menu && menu->size)
grub_show_menu (menu, 1, 0);
if (!extractor)
grub_env_context_close ();
}
if (extractor)
grub_env_extractor_close (!new_env);
return ret;
}
static grub_extcmd_t cmd_source, cmd_configfile;
static grub_extcmd_t cmd_source_extract, cmd_configfile_extract;
GRUB_MOD_INIT(syslinuxcfg)
{
cmd_source
= grub_register_extcmd ("syslinux_source",
grub_cmd_syslinux_source, 0,
N_("FILE"),
/* TRANSLATORS: "syslinux config" means
"config as used by syslinux". */
N_("Execute syslinux config in same context"),
options);
cmd_configfile
= grub_register_extcmd ("syslinux_configfile",
grub_cmd_syslinux_source, 0,
N_("FILE"),
N_("Execute syslinux config in new context"),
options);
cmd_source_extract
= grub_register_extcmd ("extract_syslinux_entries_source",
grub_cmd_syslinux_source, 0,
N_("FILE"),
N_("Execute syslinux config in same context taking only menu entries"),
options);
cmd_configfile_extract
= grub_register_extcmd ("extract_syslinux_entries_configfile",
grub_cmd_syslinux_source, 0,
N_("FILE"),
N_("Execute syslinux config in new context taking only menu entries"),
options);
}
GRUB_MOD_FINI(syslinuxcfg)
{
grub_unregister_extcmd (cmd_source);
grub_unregister_extcmd (cmd_configfile);
grub_unregister_extcmd (cmd_source_extract);
grub_unregister_extcmd (cmd_configfile_extract);
}

View File

@@ -35,10 +35,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
static void
read_progress (grub_disk_addr_t sector __attribute__ ((unused)),
unsigned offset __attribute__ ((unused)),
unsigned len __attribute__ ((unused)),
unsigned len,
void *data __attribute__ ((unused)))
{
grub_xputs (".");
for (; len >= GRUB_DISK_SECTOR_SIZE; len -= GRUB_DISK_SECTOR_SIZE)
grub_xputs (".");
if (len)
grub_xputs (".");
grub_refresh ();
}

View File

@@ -29,7 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] =
{
{ "set", 's', 0, N_("Variable name to update."), N_("VARNAME"), ARG_TYPE_STRING },
{ "set", 's', 0, N_("Set a variable to return value."), N_("VARNAME"), ARG_TYPE_STRING },
{ "upcase", 'U', 0, N_("Translate to upper case."), 0, 0 },
{ "downcase", 'D', 0, N_("Translate to lower case."), 0, 0 },
{ 0, 0, 0, 0, 0, 0 }

View File

@@ -41,7 +41,7 @@ enum
static const struct grub_arg_option options[] =
{
{"skip-sig", 's', 0,
N_("Skip signature-checking of the signature file."), 0, ARG_TYPE_NONE},
N_("Skip signature-checking of the public key file."), 0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
@@ -133,7 +133,7 @@ struct signature_v4_header
grub_uint8_t pkeyalgo;
grub_uint8_t hash;
grub_uint16_t hashed_sub;
} __attribute__ ((packed));
} GRUB_PACKED;
const char *hashes[] = {
[0x01] = "md5",
@@ -145,16 +145,31 @@ const char *hashes[] = {
[0x0b] = "sha224"
};
struct gcry_pk_spec *grub_crypto_pk_dsa;
struct gcry_pk_spec *grub_crypto_pk_ecdsa;
struct gcry_pk_spec *grub_crypto_pk_rsa;
static int
dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
static int
rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
struct
{
const char *name;
grub_size_t nmpisig;
grub_size_t nmpipub;
struct gcry_pk_spec **algo;
int (*pad) (gcry_mpi_t *hmpi, grub_uint8_t *hval,
const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
const char *module;
} pkalgos[] =
{
[1] = { "rsa", 1, 2 },
[3] = { "rsa", 1, 2 },
[17] = { "dsa", 2, 4 },
[1] = { "rsa", 1, 2, &grub_crypto_pk_rsa, rsa_pad, "gcry_rsa" },
[3] = { "rsa", 1, 2, &grub_crypto_pk_rsa, rsa_pad, "gcry_rsa" },
[17] = { "dsa", 2, 4, &grub_crypto_pk_dsa, dsa_pad, "gcry_dsa" },
};
struct grub_public_key
@@ -177,22 +192,39 @@ free_pk (struct grub_public_key *pk)
struct grub_public_subkey *nsk, *sk;
for (sk = pk->subkeys; sk; sk = nsk)
{
grub_size_t i;
for (i = 0; i < ARRAY_SIZE (sk->mpis); i++)
if (sk->mpis[i])
gcry_mpi_release (sk->mpis[i]);
nsk = sk->next;
grub_free (sk);
}
grub_free (pk);
}
#define READBUF_SIZE 4096
struct grub_public_key *
grub_load_public_key (grub_file_t f)
{
grub_err_t err;
struct grub_public_key *ret;
struct grub_public_subkey **last = 0;
void *fingerprint_context = NULL;
grub_uint8_t *buffer = NULL;
ret = grub_zalloc (sizeof (*ret));
if (!ret)
return NULL;
{
grub_free (fingerprint_context);
return NULL;
}
buffer = grub_zalloc (READBUF_SIZE);
fingerprint_context = grub_zalloc (GRUB_MD_SHA1->contextsize);
if (!buffer || !fingerprint_context)
goto fail;
last = &ret->subkeys;
@@ -206,7 +238,6 @@ grub_load_public_key (grub_file_t f)
struct grub_public_subkey *sk;
grub_size_t i;
grub_uint16_t len_be;
GRUB_PROPERLY_ALIGNED_ARRAY (fingerprint_context, GRUB_MD_SHA1->contextsize);
err = read_packet_header (f, &type, &len);
@@ -215,7 +246,11 @@ grub_load_public_key (grub_file_t f)
if (type == 0xfe)
continue;
if (type == 0xff)
return ret;
{
grub_free (fingerprint_context);
grub_free (buffer);
return ret;
}
grub_dprintf ("crypt", "len = %x\n", (int) len);
@@ -279,7 +314,6 @@ grub_load_public_key (grub_file_t f)
{
grub_uint16_t l;
grub_size_t lb;
grub_uint8_t buffer[4096];
if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
@@ -287,7 +321,7 @@ grub_load_public_key (grub_file_t f)
}
lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
@@ -322,6 +356,8 @@ grub_load_public_key (grub_file_t f)
}
fail:
free_pk (ret);
grub_free (fingerprint_context);
grub_free (buffer);
return NULL;
}
@@ -351,6 +387,51 @@ grub_crypto_pk_locate_subkey_in_trustdb (grub_uint64_t keyid)
return 0;
}
static int
dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
const gcry_md_spec_t *hash, struct grub_public_subkey *sk)
{
unsigned nbits = gcry_mpi_get_nbits (sk->mpis[1]);
grub_dprintf ("crypt", "must be %u bits got %d bits\n", nbits,
(int)(8 * hash->mdlen));
return gcry_mpi_scan (hmpi, GCRYMPI_FMT_USG, hval,
nbits / 8 < (unsigned) hash->mdlen ? nbits / 8
: (unsigned) hash->mdlen, 0);
}
static int
rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
const gcry_md_spec_t *hash, struct grub_public_subkey *sk)
{
grub_size_t tlen, emlen, fflen;
grub_uint8_t *em, *emptr;
unsigned nbits = gcry_mpi_get_nbits (sk->mpis[0]);
int ret;
tlen = hash->mdlen + hash->asnlen;
emlen = (nbits + 7) / 8;
if (emlen < tlen + 11)
return 1;
em = grub_malloc (emlen);
if (!em)
return 1;
em[0] = 0x00;
em[1] = 0x01;
fflen = emlen - tlen - 3;
for (emptr = em + 2; emptr < em + 2 + fflen; emptr++)
*emptr = 0xff;
*emptr++ = 0x00;
grub_memcpy (emptr, hash->asnoid, hash->asnlen);
emptr += hash->asnlen;
grub_memcpy (emptr, hval, hash->mdlen);
ret = gcry_mpi_scan (hmpi, GCRYMPI_FMT_USG, em, emlen, 0);
grub_free (em);
return ret;
}
static grub_err_t
grub_verify_signature_real (char *buf, grub_size_t size,
grub_file_t f, grub_file_t sig,
@@ -404,7 +485,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
grub_dprintf ("crypt", "alive\n");
{
GRUB_PROPERLY_ALIGNED_ARRAY (context, hash->contextsize);
void *context = NULL;
unsigned char *hval;
grub_ssize_t rem = grub_be_to_cpu16 (v4.hashed_sub);
grub_uint32_t headlen = grub_cpu_to_be32 (rem + 6);
@@ -415,18 +496,22 @@ grub_verify_signature_real (char *buf, grub_size_t size,
gcry_mpi_t hmpi;
grub_uint64_t keyid = 0;
struct grub_public_subkey *sk;
grub_uint8_t *readbuf = NULL;
context = grub_zalloc (hash->contextsize);
readbuf = grub_zalloc (READBUF_SIZE);
if (!context || !readbuf)
goto fail;
grub_memset (context, 0, sizeof (context));
hash->init (context);
if (buf)
hash->write (context, buf, size);
else
while (1)
{
grub_uint8_t readbuf[4096];
r = grub_file_read (f, readbuf, sizeof (readbuf));
r = grub_file_read (f, readbuf, READBUF_SIZE);
if (r < 0)
return grub_errno;
goto fail;
if (r == 0)
break;
hash->write (context, readbuf, r);
@@ -436,10 +521,10 @@ grub_verify_signature_real (char *buf, grub_size_t size,
hash->write (context, &v4, sizeof (v4));
while (rem)
{
grub_uint8_t readbuf[4096];
r = grub_file_read (sig, readbuf, rem < (grub_ssize_t) sizeof (readbuf) ? rem : (grub_ssize_t) sizeof (readbuf));
r = grub_file_read (sig, readbuf,
rem < READBUF_SIZE ? rem : READBUF_SIZE);
if (r < 0)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
if (r == 0)
break;
hash->write (context, readbuf, r);
@@ -451,17 +536,16 @@ grub_verify_signature_real (char *buf, grub_size_t size,
hash->write (context, &headlen, sizeof (headlen));
r = grub_file_read (sig, &unhashed_sub, sizeof (unhashed_sub));
if (r != sizeof (unhashed_sub))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
{
grub_uint8_t readbuf[4096];
grub_uint8_t *ptr;
grub_uint32_t l;
rem = grub_be_to_cpu16 (unhashed_sub);
if (rem > (int) sizeof (readbuf))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
if (rem > READBUF_SIZE)
goto fail;
r = grub_file_read (sig, readbuf, rem);
if (r != rem)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
for (ptr = readbuf; ptr < readbuf + rem; ptr += l)
{
if (*ptr < 192)
@@ -492,9 +576,9 @@ grub_verify_signature_real (char *buf, grub_size_t size,
hval = hash->read (context);
if (grub_file_read (sig, hash_start, sizeof (hash_start)) != sizeof (hash_start))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (sig));
@@ -502,25 +586,24 @@ grub_verify_signature_real (char *buf, grub_size_t size,
{
grub_uint16_t l;
grub_size_t lb;
grub_uint8_t buffer[4096];
grub_dprintf ("crypt", "alive\n");
if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail;
grub_dprintf ("crypt", "alive\n");
lb = (grub_be_to_cpu16 (l) + 7) / 8;
grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l));
if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
goto fail;
grub_dprintf ("crypt", "alive\n");
if (grub_file_read (sig, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
if (grub_file_read (sig, readbuf + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
goto fail;
grub_dprintf ("crypt", "alive\n");
grub_memcpy (buffer, &l, sizeof (l));
grub_memcpy (readbuf, &l, sizeof (l));
grub_dprintf ("crypt", "alive\n");
if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP,
buffer, lb + sizeof (grub_uint16_t), 0))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
readbuf, lb + sizeof (grub_uint16_t), 0))
goto fail;
grub_dprintf ("crypt", "alive\n");
}
@@ -529,24 +612,42 @@ grub_verify_signature_real (char *buf, grub_size_t size,
else
sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid);
if (!sk)
/* TRANSLATORS: %08x is 32-bit key id. */
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
{
/* TRANSLATORS: %08x is 32-bit key id. */
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"),
keyid);
goto fail;
}
unsigned nbits = gcry_mpi_get_nbits (sk->mpis[1]);
grub_dprintf ("crypt", "must be %u bits got %d bits\n", nbits,
(int)(8 * hash->mdlen));
if (pkalgos[pk].pad (&hmpi, hval, hash, sk))
goto fail;
if (!*pkalgos[pk].algo)
{
grub_dl_load (pkalgos[pk].module);
grub_errno = GRUB_ERR_NONE;
}
if (gcry_mpi_scan (&hmpi, GCRYMPI_FMT_USG, hval,
nbits / 8 < (unsigned) hash->mdlen ? nbits / 8
: (unsigned) hash->mdlen, 0))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
if (!grub_crypto_pk_dsa)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), "gcry_dsa");
if (grub_crypto_pk_dsa->verify (0, hmpi, mpis, sk->mpis, 0, 0))
if (!*pkalgos[pk].algo)
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"),
pkalgos[pk].module);
goto fail;
}
if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0))
goto fail;
grub_free (context);
grub_free (readbuf);
return GRUB_ERR_NONE;
fail:
grub_free (context);
grub_free (readbuf);
if (!grub_errno)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
return grub_errno;
}
return GRUB_ERR_NONE;
}
grub_err_t
@@ -643,8 +744,8 @@ static grub_err_t
grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
int argc, char **args)
{
grub_file_t f, sig;
grub_err_t err;
grub_file_t f = NULL, sig = NULL;
grub_err_t err = GRUB_ERR_NONE;
struct grub_public_key *pk = NULL;
grub_dprintf ("crypt", "alive\n");
@@ -675,19 +776,27 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
grub_file_filter_disable_all ();
f = grub_file_open (args[0]);
if (!f)
return grub_errno;
{
err = grub_errno;
goto fail;
}
grub_file_filter_disable_all ();
sig = grub_file_open (args[1]);
if (!sig)
{
grub_file_close (f);
return grub_errno;
err = grub_errno;
goto fail;
}
err = grub_verify_signature (f, sig, pk);
grub_file_close (f);
grub_file_close (sig);
fail:
if (sig)
grub_file_close (sig);
if (f)
grub_file_close (f);
if (pk)
free_pk (pk);
return err;
}
@@ -776,6 +885,7 @@ grub_pubkey_open (grub_file_t io, const char *filename)
if (err)
return NULL;
io->device = 0;
io->name = 0;
grub_file_close (io);
return ret;
}
@@ -803,9 +913,6 @@ struct grub_fs pseudo_fs =
.read = pseudo_read
};
struct gcry_pk_spec *grub_crypto_pk_dsa;
struct gcry_pk_spec *grub_crypto_pk_ecdsa;
struct gcry_pk_spec *grub_crypto_pk_rsa;
static grub_extcmd_t cmd, cmd_trust;
static grub_command_t cmd_distrust, cmd_list;
@@ -859,14 +966,14 @@ GRUB_MOD_INIT(verify)
options);
cmd_trust = grub_register_extcmd ("trust", grub_cmd_trust, 0,
N_("[-s|--skip-sig] PUBKEY_FILE"),
N_("Add PKFILE to trusted keys."),
N_("Add PUBKEY_FILE to trusted keys."),
options);
cmd_list = grub_register_command ("list_trusted", grub_cmd_list,
0,
N_("List trusted keys."));
N_("Show the list of trusted keys."));
cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust,
N_("PUBKEY_ID"),
N_("Remove KEYID from trusted keys."));
N_("Remove PUBKEY_ID from trusted keys."));
}
GRUB_MOD_FINI(verify)

View File

@@ -0,0 +1,90 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/dl.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/xen.h>
#include <grub/term.h>
GRUB_MOD_LICENSE ("GPLv3+");
static int
hook (const char *dir, void *hook_data __attribute__ ((unused)))
{
grub_printf ("%s\n", dir);
return 0;
}
static grub_err_t
grub_cmd_lsxen (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
char *dir;
grub_err_t err;
char *buf;
if (argc >= 1)
return grub_xenstore_dir (args[0], hook, NULL);
buf = grub_xenstore_get_file ("domid", NULL);
if (!buf)
return grub_errno;
dir = grub_xasprintf ("/local/domain/%s", buf);
grub_free (buf);
err = grub_xenstore_dir (dir, hook, NULL);
grub_free (dir);
return err;
}
static grub_err_t
grub_cmd_catxen (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
const char *dir = "domid";
char *buf;
if (argc >= 1)
dir = args[0];
buf = grub_xenstore_get_file (dir, NULL);
if (!buf)
return grub_errno;
grub_xputs (buf);
grub_xputs ("\n");
grub_free (buf);
return GRUB_ERR_NONE;
}
static grub_command_t cmd_ls, cmd_cat;
GRUB_MOD_INIT (lsxen)
{
cmd_ls = grub_register_command ("xen_ls", grub_cmd_lsxen, N_("[DIR]"),
N_("List Xen storage."));
cmd_cat = grub_register_command ("xen_cat", grub_cmd_catxen, N_("[DIR]"),
N_("List Xen storage."));
}
GRUB_MOD_FINI (lsxen)
{
grub_unregister_command (cmd_ls);
grub_unregister_command (cmd_cat);
}

View File

@@ -50,7 +50,7 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
grub_uint8_t *xnu_uuid;
char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
char *ptr;
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
void *ctx;
int low = 0;
if (argc < 1)
@@ -65,11 +65,14 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16));
GRUB_MD_MD5->init (&ctx);
GRUB_MD_MD5->write (&ctx, hash_prefix, sizeof (hash_prefix));
GRUB_MD_MD5->write (&ctx, &serial, sizeof (serial));
GRUB_MD_MD5->final (&ctx);
xnu_uuid = GRUB_MD_MD5->read (&ctx);
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
if (!ctx)
return grub_errno;
GRUB_MD_MD5->init (ctx);
GRUB_MD_MD5->write (ctx, hash_prefix, sizeof (hash_prefix));
GRUB_MD_MD5->write (ctx, &serial, sizeof (serial));
GRUB_MD_MD5->final (ctx);
xnu_uuid = GRUB_MD_MD5->read (ctx);
grub_snprintf (uuid_string, sizeof (uuid_string),
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
@@ -91,6 +94,8 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
if (argc > 1)
grub_env_set (args[1], uuid_string);
grub_free (ctx);
return GRUB_ERR_NONE;
}

View File

@@ -37,8 +37,8 @@ diffuse (const gcry_md_spec_t * hash, grub_uint8_t * src,
grub_size_t fullblocks = size / hash->mdlen;
int padding = size % hash->mdlen;
grub_uint8_t final[hash->mdlen];
grub_uint8_t temp[sizeof (IV) + hash->mdlen];
grub_uint8_t final[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t temp[sizeof (IV) + GRUB_CRYPTO_MAX_MDLEN];
/* hash block the whole data set with different IVs to produce
* more than just a single data block
@@ -76,6 +76,9 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return GPG_ERR_INV_ARG;
grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++)
{

View File

@@ -133,6 +133,7 @@ struct grub_ahci_device
volatile struct grub_ahci_cmd_table *command_table;
struct grub_pci_dma_chunk *rfis;
int present;
int atapi;
};
static grub_err_t
@@ -616,6 +617,10 @@ grub_ahci_pciinit (grub_pci_device_t dev,
grub_dma_free (failed_adevs[i]->rfis);
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].sig >> 16) == 0xeb14)
adevs[i]->atapi = 1;
for (i = 0; i < nports; i++)
if (adevs[i])
{
@@ -1075,6 +1080,7 @@ grub_ahci_open (int id, int devnum, struct grub_ata *ata)
ata->data = dev;
ata->dma = 1;
ata->atapi = dev->atapi;
ata->maxbuffer = GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH;
ata->present = &dev->present;

View File

@@ -108,6 +108,9 @@ grub_ata_identify (struct grub_ata *dev)
grub_uint16_t *info16;
grub_err_t err;
if (dev->atapi)
return grub_atapi_identify (dev);
info64 = grub_malloc (GRUB_DISK_SECTOR_SIZE);
info32 = (grub_uint32_t *) info64;
info16 = (grub_uint16_t *) info64;
@@ -129,7 +132,7 @@ grub_ata_identify (struct grub_ata *dev)
grub_free (info16);
grub_errno = GRUB_ERR_NONE;
if ((sts & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ
| GRUB_ATA_STATUS_ERR)) == GRUB_ATA_STATUS_ERR
| GRUB_ATA_STATUS_ERR)) == GRUB_ATA_STATUS_ERR
&& (parms.taskfile.error & 0x04 /* ABRT */))
/* Device without ATA IDENTIFY, try ATAPI. */
return grub_atapi_identify (dev);
@@ -285,7 +288,6 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
if (addressing == GRUB_ATA_LBA48 && ((sector + size) >> 28) != 0)
{
batch = 65536;
if (ata->dma)
{
cmd = GRUB_ATA_CMD_READ_SECTORS_DMA_EXT;
@@ -301,10 +303,6 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
{
if (addressing == GRUB_ATA_LBA48)
addressing = GRUB_ATA_LBA;
if (addressing != GRUB_ATA_CHS)
batch = 256;
else
batch = 1;
if (ata->dma)
{
cmd = GRUB_ATA_CMD_READ_SECTORS_DMA;
@@ -317,8 +315,10 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
}
}
if (batch > (ata->maxbuffer >> ata->log_sector_size))
batch = (ata->maxbuffer >> ata->log_sector_size);
if (addressing != GRUB_ATA_CHS)
batch = 256;
else
batch = 1;
while (nsectors < size)
{
@@ -366,7 +366,7 @@ grub_ata_real_open (int id, int bus)
struct grub_ata *ata;
grub_ata_dev_t p;
ata = grub_malloc (sizeof (*ata));
ata = grub_zalloc (sizeof (*ata));
if (!ata)
return NULL;
for (p = grub_ata_dev_list; p; p = p->next)
@@ -464,6 +464,10 @@ grub_ata_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk");
disk->total_sectors = ata->size;
disk->max_agglomerate = (ata->maxbuffer >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS));
if (disk->max_agglomerate > (256U >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS - ata->log_sector_size)))
disk->max_agglomerate = (256U >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS - ata->log_sector_size));
disk->log_sector_size = ata->log_sector_size;
disk->id = grub_make_scsi_id (id, bus, 0);

View File

@@ -51,7 +51,7 @@ static inline int GF_PER_SECTOR (const struct grub_cryptodisk *dev)
}
static grub_cryptodisk_t cryptodisk_list = NULL;
static grub_uint8_t n = 0;
static grub_uint8_t last_cryptodisk_id = 0;
static void
gf_mul_x (grub_uint8_t *g)
@@ -109,7 +109,9 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
void *iv)
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[cipher->cipher->blocksize];
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
if (size % cipher->cipher->blocksize != 0)
@@ -132,7 +134,9 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
void *iv)
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[cipher->cipher->blocksize];
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
if (size % cipher->cipher->blocksize != 0)
@@ -218,6 +222,9 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
grub_size_t i;
gcry_err_code_t err;
if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
/* The only mode without IV. */
if (dev->mode == GRUB_CRYPTODISK_MODE_ECB && !dev->rekey)
return (do_encrypt ? grub_crypto_ecb_encrypt (dev->cipher, data, data, len)
@@ -228,7 +235,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
grub_size_t sz = ((dev->cipher->cipher->blocksize
+ sizeof (grub_uint32_t) - 1)
/ sizeof (grub_uint32_t));
grub_uint32_t iv[sz];
grub_uint32_t iv[(GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE + 3) / 4];
if (dev->rekey)
{
@@ -242,7 +249,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
}
}
grub_memset (iv, 0, sz * sizeof (iv[0]));
grub_memset (iv, 0, sizeof (iv));
switch (dev->mode_iv)
{
case GRUB_CRYPTODISK_MODE_IV_NULL:
@@ -250,9 +257,11 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH:
{
grub_uint64_t tmp;
GRUB_PROPERLY_ALIGNED_ARRAY (ctx, dev->iv_hash->contextsize);
void *ctx;
grub_memset (ctx, 0, sizeof (ctx));
ctx = grub_zalloc (dev->iv_hash->contextsize);
if (!ctx)
return GPG_ERR_OUT_OF_MEMORY;
tmp = grub_cpu_to_le64 (sector << dev->log_sector_size);
dev->iv_hash->init (ctx);
@@ -261,6 +270,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
dev->iv_hash->final (ctx);
grub_memcpy (iv, dev->iv_hash->read (ctx), sizeof (iv));
grub_free (ctx);
}
break;
case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
@@ -407,7 +417,9 @@ grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t ke
if (dev->mode_iv == GRUB_CRYPTODISK_MODE_IV_ESSIV)
{
grub_size_t essiv_keysize = dev->essiv_hash->mdlen;
grub_uint8_t hashed_key[essiv_keysize];
grub_uint8_t hashed_key[GRUB_CRYPTO_MAX_MDLEN];
if (essiv_keysize > GRUB_CRYPTO_MAX_MDLEN)
return GPG_ERR_INV_ARG;
grub_crypto_hash (dev->essiv_hash, hashed_key, key, keysize);
err = grub_crypto_cipher_set_key (dev->essiv_cipher,
@@ -517,6 +529,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk)
disk->data = dev;
disk->total_sectors = dev->total_length;
disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
disk->id = dev->id;
dev->ref++;
return GRUB_ERR_NONE;
@@ -694,7 +707,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
return grub_errno;
}
newdev->id = n++;
newdev->id = last_cryptodisk_id++;
newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id;
newdev->next = cryptodisk_list;
@@ -740,7 +753,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
newdev->cheat_fd = GRUB_UTIL_FD_INVALID;
newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id;
newdev->id = n++;
newdev->id = last_cryptodisk_id++;
newdev->next = cryptodisk_list;
cryptodisk_list = newdev;
@@ -998,12 +1011,14 @@ hex (grub_uint8_t val)
/* Open a file named NAME and initialize FILE. */
static char *
luks_script_get (void)
luks_script_get (grub_size_t *sz)
{
grub_cryptodisk_t i;
grub_size_t size = 0;
char *ptr, *ret;
*sz = 0;
for (i = cryptodisk_list; i != NULL; i = i->next)
if (grub_strcmp (i->modname, "luks") == 0)
{
@@ -1085,6 +1100,7 @@ luks_script_get (void)
*ptr++ = '\n';
}
*ptr = '\0';
*sz = ptr - ret;
return ret;
}

View File

@@ -445,6 +445,7 @@ grub_diskfilter_open (const char *name, grub_disk_t disk)
disk->data = lv;
disk->total_sectors = lv->size;
disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
return 0;
}
@@ -933,7 +934,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
case 4:
case 5:
case 6:
totsize = (nmemb - level / 3) * disk_size;
totsize = (nmemb - ((unsigned) level / 3U)) * disk_size;
break;
default:
@@ -1056,7 +1057,8 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
(unsigned long long) grub_disk_get_size (disk),
array->name, diskfilter->name);
#ifdef GRUB_UTIL
grub_util_info ("Inserting %s (+%lld,%lld) into %s (%s)\n", disk->name,
grub_util_info ("Inserting %s (+%" GRUB_HOST_PRIuLONG_LONG ",%"
GRUB_HOST_PRIuLONG_LONG ") into %s (%s)\n", disk->name,
(unsigned long long) grub_partition_get_start (disk->partition),
(unsigned long long) grub_disk_get_size (disk),
array->name, diskfilter->name);

View File

@@ -88,7 +88,7 @@ struct grub_nv_super
char prodrev[NV_PRODREV_LEN]; /* 0x2C - 0x2F Array product revision */
grub_uint32_t unit_flags; /* 0x30 - 0x33 Flags for this disk */
struct grub_nv_array array; /* Array information */
} __attribute__ ((packed));
} GRUB_PACKED;
static struct grub_diskfilter_vg *
grub_dmraid_nv_detect (grub_disk_t disk,

View File

@@ -157,8 +157,7 @@ find_parent_device (struct grub_efidisk_data *devices,
ldp = find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length[0] = sizeof (*ldp);
ldp->length[1] = 0;
ldp->length = sizeof (*ldp);
for (parent = devices; parent; parent = parent->next)
{
@@ -188,8 +187,7 @@ is_child (struct grub_efidisk_data *child,
ldp = find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length[0] = sizeof (*ldp);
ldp->length[1] = 0;
ldp->length = sizeof (*ldp);
ret = (grub_efi_compare_device_paths (dp, parent->device_path) == 0);
grub_free (dp);
@@ -518,6 +516,8 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n",
m, (unsigned long long) m->last_block, m->block_size);
disk->total_sectors = m->last_block + 1;
/* Don't increase this value due to bug in some EFI. */
disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
if (m->block_size & (m->block_size - 1) || !m->block_size)
return grub_error (GRUB_ERR_IO, "invalid sector size %d",
m->block_size);
@@ -542,32 +542,17 @@ static grub_efi_status_t
grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf, int wr)
{
/* For now, use the disk io interface rather than the block io's. */
struct grub_efidisk_data *d;
grub_efi_block_io_t *bio;
grub_efi_status_t status;
d = disk->data;
bio = d->block_io;
while (size > 0)
{
grub_size_t len;
len = 0x500;
if (len > size)
len = size;
status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) len << disk->log_sector_size,
buf);
size -= len;
buf += len << disk->log_sector_size;
sector += len;
if (status != GRUB_EFI_SUCCESS)
return status;
}
return GRUB_EFI_SUCCESS;
return efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
buf);
}
static grub_err_t
@@ -681,20 +666,20 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
devices = make_devices ();
FOR_CHILDREN (c, devices)
{
grub_efi_hard_drive_device_path_t hd;
grub_efi_hard_drive_device_path_t *hd;
grub_memcpy (&hd, c->last_device_path, sizeof (hd));
hd = (grub_efi_hard_drive_device_path_t *) c->last_device_path;
if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
== GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
&& (grub_partition_get_start (disk->partition)
== (hd.partition_start << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)))
== (hd->partition_start << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)))
&& (grub_partition_get_len (disk->partition)
== (hd.partition_size << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS))))
== (hd->partition_size << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS))))
{
handle = c->handle;
break;
@@ -760,7 +745,7 @@ get_diskname_from_path (const grub_efi_device_path_t *path,
struct grub_efidisk_get_device_name_ctx
{
char *partition_name;
grub_efi_hard_drive_device_path_t hd;
grub_efi_hard_drive_device_path_t *hd;
};
/* Helper for grub_efidisk_get_device_name.
@@ -772,11 +757,11 @@ grub_efidisk_get_device_name_iter (grub_disk_t disk,
struct grub_efidisk_get_device_name_ctx *ctx = data;
if (grub_partition_get_start (part)
== (ctx->hd.partition_start << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS))
== (ctx->hd->partition_start << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS))
&& grub_partition_get_len (part)
== (ctx->hd.partition_size << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)))
== (ctx->hd->partition_size << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)))
{
ctx->partition_name = grub_partition_get_name (part);
return 1;
@@ -829,8 +814,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
dup_ldp->length[0] = sizeof (*dup_ldp);
dup_ldp->length[1] = 0;
dup_ldp->length = sizeof (*dup_ldp);
}
if (!get_diskname_from_path (dup_dp, device_name))
@@ -847,10 +831,10 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* Find a partition which matches the hard drive device path. */
ctx.partition_name = NULL;
grub_memcpy (&ctx.hd, ldp, sizeof (ctx.hd));
if (ctx.hd.partition_start == 0
&& (ctx.hd.partition_size << (parent->log_sector_size
- GRUB_DISK_SECTOR_BITS))
ctx.hd = (grub_efi_hard_drive_device_path_t *) ldp;
if (ctx.hd->partition_start == 0
&& (ctx.hd->partition_size << (parent->log_sector_size
- GRUB_DISK_SECTOR_BITS))
== grub_disk_get_size (parent))
{
dev_name = grub_strdup (parent->name);

View File

@@ -95,7 +95,7 @@ struct grub_geli_key
grub_uint8_t iv_key[64];
grub_uint8_t cipher_key[64];
grub_uint8_t hmac[64];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_geli_phdr
{
@@ -111,7 +111,7 @@ struct grub_geli_phdr
grub_uint32_t niter;
grub_uint8_t salt[64];
struct grub_geli_key keys[2];
} __attribute__ ((packed));
} GRUB_PACKED;
enum
{
@@ -144,42 +144,35 @@ geli_rekey (struct grub_cryptodisk *dev, grub_uint64_t zoneno)
const struct {
char magic[4];
grub_uint64_t zone;
} __attribute__ ((packed)) tohash
} GRUB_PACKED tohash
= { {'e', 'k', 'e', 'y'}, grub_cpu_to_le64 (zoneno) };
GRUB_PROPERLY_ALIGNED_ARRAY (key, dev->hash->mdlen);
GRUB_PROPERLY_ALIGNED_ARRAY (key, GRUB_CRYPTO_MAX_MDLEN);
if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return GPG_ERR_INV_ARG;
grub_dprintf ("geli", "rekeying %" PRIuGRUB_UINT64_T " keysize=%d\n",
zoneno, dev->rekey_derived_size);
gcry_err = grub_crypto_hmac_buffer (dev->hash, dev->rekey_key, 64,
&tohash, sizeof (tohash), key);
if (gcry_err)
return grub_crypto_gcry_error (gcry_err);
return gcry_err;
return grub_cryptodisk_setkey (dev, (grub_uint8_t *) key,
dev->rekey_derived_size);
}
static inline int
ascii2hex (char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return 0;
}
static inline gcry_err_code_t
make_uuid (const struct grub_geli_phdr *header,
char *uuid)
{
grub_uint8_t uuidbin[GRUB_MD_SHA256->mdlen];
grub_uint8_t uuidbin[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
gcry_err_code_t err;
grub_uint8_t *iptr;
char *optr;
if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
return GPG_ERR_TOO_LARGE;
err = grub_crypto_hmac_buffer (GRUB_MD_SHA256,
header->salt, sizeof (header->salt),
"uuid", sizeof ("uuid") - 1, uuidbin);
@@ -187,7 +180,7 @@ make_uuid (const struct grub_geli_phdr *header,
return err;
optr = uuid;
for (iptr = uuidbin; iptr < &uuidbin[ARRAY_SIZE (uuidbin)]; iptr++)
for (iptr = uuidbin; iptr < &uuidbin[GRUB_MD_SHA256->mdlen]; iptr++)
{
grub_snprintf (optr, 3, "%02x", *iptr);
optr += 2;
@@ -254,10 +247,13 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
const struct gcry_cipher_spec *ciph;
const char *ciphername = NULL;
gcry_err_code_t gcry_err;
char uuid[GRUB_MD_SHA256->mdlen * 2 + 1];
char uuid[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
grub_disk_addr_t sector;
grub_err_t err;
if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
return NULL;
sector = grub_disk_get_size (disk);
if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
return NULL;
@@ -391,10 +387,10 @@ static grub_err_t
recover_key (grub_disk_t source, grub_cryptodisk_t dev)
{
grub_size_t keysize;
grub_uint8_t digest[dev->hash->mdlen];
grub_uint8_t geomkey[dev->hash->mdlen];
grub_uint8_t verify_key[dev->hash->mdlen];
grub_uint8_t zero[dev->cipher->cipher->blocksize];
grub_uint8_t digest[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
char passphrase[MAX_PASSPHRASE] = "";
unsigned i;
gcry_err_code_t gcry_err;
@@ -403,6 +399,12 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
grub_disk_addr_t sector;
grub_err_t err;
if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return grub_error (GRUB_ERR_BUG, "cipher block is too long");
if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
sector = grub_disk_get_size (source);
if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
return grub_error (GRUB_ERR_BUG, "not a geli");
@@ -464,12 +466,12 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
}
gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
sizeof (geomkey), "\1", 1, digest);
dev->hash->mdlen, "\1", 1, digest);
if (gcry_err)
return grub_crypto_gcry_error (gcry_err);
gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
sizeof (geomkey), "\0", 1, verify_key);
dev->hash->mdlen, "\0", 1, verify_key);
if (gcry_err)
return grub_crypto_gcry_error (gcry_err);
@@ -479,7 +481,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
for (i = 0; i < ARRAY_SIZE (header.keys); i++)
{
struct grub_geli_key candidate_key;
grub_uint8_t key_hmac[dev->hash->mdlen];
grub_uint8_t key_hmac[GRUB_CRYPTO_MAX_MDLEN];
/* Check if keyslot is enabled. */
if (! (header.keys_used & (1 << i)))
@@ -500,7 +502,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
return grub_crypto_gcry_error (gcry_err);
gcry_err = grub_crypto_hmac_buffer (dev->hash, verify_key,
sizeof (verify_key),
dev->hash->mdlen,
&candidate_key,
(sizeof (candidate_key)
- sizeof (candidate_key.hmac)),

View File

@@ -20,9 +20,13 @@
/* When using the disk, make a reference to this module. Otherwise
the user will end up with a useless module :-). */
#include <config.h>
#include <config-util.h>
#include <grub/dl.h>
#include <grub/disk.h>
#include <grub/misc.h>
#include <grub/emu/hostdisk.h>
int grub_disk_host_i_want_a_reference;
@@ -45,7 +49,7 @@ grub_host_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk");
disk->total_sectors = 0;
disk->id = (unsigned long) "host";
disk->id = 0;
disk->data = 0;

View File

@@ -424,6 +424,13 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
}
disk->total_sectors = total_sectors;
/* Limit the max to 0x7f because of Phoenix EDD. */
disk->max_agglomerate = 0x7f >> GRUB_DISK_CACHE_BITS;
COMPILE_TIME_ASSERT ((0x7f >> GRUB_DISK_CACHE_BITS
<< (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
+ sizeof (struct grub_biosdisk_dap)
< GRUB_MEMORY_MACHINE_SCRATCH_SIZE);
disk->data = data;
return GRUB_ERR_NONE;
@@ -548,10 +555,6 @@ get_safe_sectors (grub_disk_t disk, grub_disk_addr_t sector)
size = sectors - offset;
/* Limit the max to 0x7f because of Phoenix EDD. */
if (size > ((0x7fU << GRUB_DISK_SECTOR_BITS) >> disk->log_sector_size))
size = ((0x7fU << GRUB_DISK_SECTOR_BITS) >> disk->log_sector_size);
return size;
}

View File

@@ -31,11 +31,14 @@ static grub_ieee1275_ihandle_t last_ihandle;
struct ofdisk_hash_ent
{
char *devpath;
char *open_path;
char *grub_devpath;
int is_boot;
int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
const char *grub_shortest;
struct ofdisk_hash_ent *next;
};
@@ -70,12 +73,50 @@ ofdisk_hash_add_real (char *devpath)
{
struct ofdisk_hash_ent *p;
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
const char *iptr;
char *optr;
p = grub_zalloc (sizeof (*p));
if (!p)
return NULL;
p->devpath = devpath;
p->grub_devpath = grub_malloc (sizeof ("ieee1275/")
+ 2 * grub_strlen (p->devpath));
if (!p->grub_devpath)
{
grub_free (p);
return NULL;
}
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
{
p->open_path = grub_malloc (grub_strlen (p->devpath) + 3);
if (!p->open_path)
{
grub_free (p->grub_devpath);
grub_free (p);
return NULL;
}
optr = grub_stpcpy (p->open_path, p->devpath);
*optr++ = ':';
*optr++ = '0';
*optr = '\0';
}
else
p->open_path = p->devpath;
optr = grub_stpcpy (p->grub_devpath, "ieee1275/");
for (iptr = p->devpath; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
p->next = *head;
*head = p;
return p;
@@ -104,7 +145,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
if (!curcan)
{
p->shortest = devpath;
p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath;
if (check_string_cdrom (devpath))
p->is_cdrom = 1;
return p;
@@ -125,7 +167,10 @@ ofdisk_hash_add (char *devpath, char *curcan)
{
if (!pcan->shortest
|| grub_strlen (pcan->shortest) > grub_strlen (devpath))
pcan->shortest = devpath;
{
pcan->shortest = p->devpath;
pcan->grub_shortest = p->grub_devpath;
}
}
return p;
@@ -288,21 +333,8 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
if (!ent->is_boot && ent->is_cdrom)
continue;
{
char buffer[sizeof ("ieee1275/") + 2 * grub_strlen (ent->shortest)];
const char *iptr;
char *optr;
optr = grub_stpcpy (buffer, "ieee1275/");
for (iptr = ent->shortest; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
if (hook (buffer, hook_data))
return 1;
}
if (hook (ent->grub_shortest, hook_data))
return 1;
}
}
return 0;
@@ -396,7 +428,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
if (!op)
return grub_errno;
disk->id = (unsigned long) op;
disk->data = op->devpath;
disk->data = op->open_path;
}
return 0;
@@ -428,20 +460,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
last_ihandle = 0;
last_devpath = NULL;
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
{
char name2[grub_strlen (disk->data) + 3];
char *p;
grub_strcpy (name2, disk->data);
p = name2 + grub_strlen (name2);
*p++ = ':';
*p++ = '0';
*p = 0;
grub_ieee1275_open (name2, &last_ihandle);
}
else
grub_ieee1275_open (disk->data, &last_ihandle);
grub_ieee1275_open (disk->data, &last_ihandle);
if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
last_devpath = disk->data;

View File

@@ -49,7 +49,7 @@ struct grub_ldm_vblk {
grub_uint8_t type;
grub_uint32_t unused2;
grub_uint8_t dynamic[104];
} __attribute__ ((packed));
} GRUB_PACKED;
#define LDM_VBLK_MAGIC "VBLK"
enum
@@ -83,7 +83,7 @@ struct grub_ldm_label
grub_uint64_t pv_size;
grub_uint64_t config_start;
grub_uint64_t config_size;
} __attribute__ ((packed));
} GRUB_PACKED;
#define LDM_MAGIC "PRIVHEAD"

View File

@@ -32,9 +32,11 @@ struct grub_loopback
char *devname;
grub_file_t file;
struct grub_loopback *next;
unsigned long id;
};
static struct grub_loopback *loopback_list;
static unsigned long last_id = 0;
static const struct grub_arg_option options[] =
{
@@ -120,6 +122,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
}
newdev->file = file;
newdev->id = last_id++;
/* Add the new entry to the list. */
newdev->next = loopback_list;
@@ -167,7 +170,11 @@ grub_loopback_open (const char *name, grub_disk_t disk)
/ GRUB_DISK_SECTOR_SIZE);
else
disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
disk->id = (unsigned long) dev;
/* Avoid reading more than 512M. */
disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
- GRUB_DISK_CACHE_BITS);
disk->id = dev->id;
disk->data = dev;

View File

@@ -56,7 +56,7 @@ struct grub_luks_phdr
grub_uint32_t keyMaterialOffset;
grub_uint32_t stripes;
} keyblock[8];
} __attribute__ ((packed));
} GRUB_PACKED;
typedef struct grub_luks_phdr *grub_luks_phdr_t;
@@ -316,6 +316,8 @@ luks_recover_key (grub_disk_t source,
grub_puts_ (N_("Attempting to decrypt master key..."));
keysize = grub_be_to_cpu32 (header.keyBytes);
if (keysize > GRUB_CRYPTODISK_MAX_KEYLEN)
return grub_error (GRUB_ERR_BAD_FS, "key is too long");
for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
if (grub_be_to_cpu32 (header.keyblock[i].active) == LUKS_KEY_ENABLED
@@ -344,8 +346,8 @@ luks_recover_key (grub_disk_t source,
for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
{
gcry_err_code_t gcry_err;
grub_uint8_t candidate_key[keysize];
grub_uint8_t digest[keysize];
grub_uint8_t candidate_key[GRUB_CRYPTODISK_MAX_KEYLEN];
grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN];
/* Check if keyslot is enabled. */
if (grub_be_to_cpu32 (header.keyblock[i].active) != LUKS_KEY_ENABLED)

View File

@@ -65,7 +65,7 @@ grub_lvm_checkvalue (char **p, char *str, char *tmpl)
static int
grub_lvm_check_flag (char *p, const char *str, const char *flag)
{
int len_str = grub_strlen (str), len_flag = grub_strlen (flag);
grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag);
while (1)
{
char *q;
@@ -111,7 +111,8 @@ grub_lvm_detect (grub_disk_t disk,
struct grub_lvm_disk_locn *dlocn;
struct grub_lvm_mda_header *mdah;
struct grub_lvm_raw_locn *rlocn;
unsigned int i, j, vgname_len;
unsigned int i, j;
grub_size_t vgname_len;
struct grub_diskfilter_vg *vg;
struct grub_diskfilter_pv *pv;
@@ -273,7 +274,7 @@ grub_lvm_detect (grub_disk_t disk,
/* Add all the pvs to the volume group. */
while (1)
{
int s;
grub_ssize_t s;
while (grub_isspace (*p))
p++;
@@ -340,7 +341,7 @@ grub_lvm_detect (grub_disk_t disk,
/* And add all the lvs to the volume group. */
while (1)
{
int s;
grub_ssize_t s;
int skip_lv = 0;
struct grub_diskfilter_lv *lv;
struct grub_diskfilter_segment *seg;

View File

@@ -97,7 +97,7 @@ struct grub_raid_super_1x
*/
grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */
};
/* Could be __attribute__ ((packed)), but since all members in this struct
/* Could be GRUB_PACKED, but since all members in this struct
are already appropriately aligned, we can omit this and avoid suboptimal
assembly in some cases. */

View File

@@ -175,7 +175,7 @@ struct grub_raid_super_09
* Active descriptor
*/
struct grub_raid_disk_09 this_disk;
} __attribute__ ((packed));
} GRUB_PACKED;
static struct grub_diskfilter_vg *
grub_mdraid_detect (grub_disk_t disk,
@@ -184,9 +184,10 @@ grub_mdraid_detect (grub_disk_t disk,
{
grub_disk_addr_t sector;
grub_uint64_t size;
struct grub_raid_super_09 sb;
struct grub_raid_super_09 *sb = NULL;
grub_uint32_t *uuid;
grub_uint32_t level;
struct grub_diskfilter_vg *ret;
/* The sector where the mdraid 0.90 superblock is stored, if available. */
size = grub_disk_get_size (disk);
@@ -195,27 +196,31 @@ grub_mdraid_detect (grub_disk_t disk,
return NULL;
sector = NEW_SIZE_SECTORS (size);
if (grub_disk_read (disk, sector, 0, SB_BYTES, &sb))
sb = grub_malloc (sizeof (*sb));
if (!sb)
return NULL;
if (grub_disk_read (disk, sector, 0, SB_BYTES, sb))
goto fail;
/* Look whether there is a mdraid 0.90 superblock. */
if (sb.md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
if (sb->md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
/* not 0.9x raid. */
return NULL;
goto fail;
if (sb.major_version != grub_cpu_to_md32_compile_time (0)
|| sb.minor_version != grub_cpu_to_md32_compile_time (90))
if (sb->major_version != grub_cpu_to_md32_compile_time (0)
|| sb->minor_version != grub_cpu_to_md32_compile_time (90))
/* Unsupported version. */
return NULL;
goto fail;
/* No need for explicit check that sb.size is 0 (unspecified) since
/* No need for explicit check that sb->size is 0 (unspecified) since
0 >= non-0 is false. */
if (((grub_disk_addr_t) grub_md_to_cpu32 (sb.size)) * 2 >= size)
return NULL;
if (((grub_disk_addr_t) grub_md_to_cpu32 (sb->size)) * 2 >= size)
goto fail;
/* FIXME: Check the checksum. */
level = grub_md_to_cpu32 (sb.level);
level = grub_md_to_cpu32 (sb->level);
/* Multipath. */
if ((int) level == -4)
level = 1;
@@ -225,37 +230,43 @@ grub_mdraid_detect (grub_disk_t disk,
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported RAID level: %d", level);
return NULL;
goto fail;
}
if (grub_md_to_cpu32 (sb.this_disk.number) == 0xffff
|| grub_md_to_cpu32 (sb.this_disk.number) == 0xfffe)
if (grub_md_to_cpu32 (sb->this_disk.number) == 0xffff
|| grub_md_to_cpu32 (sb->this_disk.number) == 0xfffe)
/* Spares aren't implemented. */
return NULL;
goto fail;
uuid = grub_malloc (16);
if (!uuid)
return NULL;
goto fail;
uuid[0] = grub_swap_bytes32 (sb.set_uuid0);
uuid[1] = grub_swap_bytes32 (sb.set_uuid1);
uuid[2] = grub_swap_bytes32 (sb.set_uuid2);
uuid[3] = grub_swap_bytes32 (sb.set_uuid3);
uuid[0] = grub_swap_bytes32 (sb->set_uuid0);
uuid[1] = grub_swap_bytes32 (sb->set_uuid1);
uuid[2] = grub_swap_bytes32 (sb->set_uuid2);
uuid[3] = grub_swap_bytes32 (sb->set_uuid3);
*start_sector = 0;
id->uuidlen = 0;
id->id = grub_md_to_cpu32 (sb.this_disk.number);
id->id = grub_md_to_cpu32 (sb->this_disk.number);
char buf[32];
grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb.md_minor));
return grub_diskfilter_make_raid (16, (char *) uuid,
grub_md_to_cpu32 (sb.raid_disks), buf,
(sb.size) ? ((grub_disk_addr_t)
grub_md_to_cpu32 (sb.size)) * 2
: sector,
grub_md_to_cpu32 (sb.chunk_size) >> 9,
grub_md_to_cpu32 (sb.layout),
level);
grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb->md_minor));
ret = grub_diskfilter_make_raid (16, (char *) uuid,
grub_md_to_cpu32 (sb->raid_disks), buf,
(sb->size) ? ((grub_disk_addr_t)
grub_md_to_cpu32 (sb->size)) * 2
: sector,
grub_md_to_cpu32 (sb->chunk_size) >> 9,
grub_md_to_cpu32 (sb->layout),
level);
grub_free (sb);
return ret;
fail:
grub_free (sb);
return NULL;
}
static struct grub_diskfilter grub_mdraid_dev = {

View File

@@ -46,7 +46,8 @@ grub_memdisk_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a memdisk");
disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE;
disk->id = (unsigned long) "mdsk";
disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
disk->id = 0;
return GRUB_ERR_NONE;
}

View File

@@ -402,9 +402,15 @@ grub_pata_pciinit (grub_pci_device_t dev,
bar2 = grub_pci_read (addr);
/* Check if the BARs describe an IO region. */
if ((bar1 & 1) && (bar2 & 1))
if ((bar1 & 1) && (bar2 & 1) && (bar1 & ~3))
{
rega = bar1 & ~3;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr)
| GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER);
}
}

View File

@@ -34,9 +34,9 @@ static unsigned powx_inv[256];
static const grub_uint8_t poly = 0x1d;
static void
grub_raid_block_mulx (unsigned mul, char *buf, int size)
grub_raid_block_mulx (unsigned mul, char *buf, grub_size_t size)
{
int i;
grub_size_t i;
grub_uint8_t *p;
p = (grub_uint8_t *) buf;

View File

@@ -606,6 +606,13 @@ grub_scsi_open (const char *name, grub_disk_t disk)
}
disk->total_sectors = scsi->last_block + 1;
/* PATA doesn't support more than 32K reads.
Not sure about AHCI and USB. If it's confirmed that either of
them can do bigger reads reliably this value can be moved to 'scsi'
structure. */
disk->max_agglomerate = 32768 >> (GRUB_DISK_SECTOR_BITS
+ GRUB_DISK_CACHE_BITS);
if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize)
{
grub_free (scsi);
@@ -647,40 +654,27 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
scsi = disk->data;
while (size)
grub_err_t err;
/* Depending on the type, select a read function. */
switch (scsi->devtype)
{
/* PATA doesn't support more than 32K reads.
Not sure about AHCI and USB. If it's confirmed that either of
them can do bigger reads reliably this value can be moved to 'scsi'
structure. */
grub_size_t len = 32768 >> disk->log_sector_size;
grub_err_t err;
if (len > size)
len = size;
/* Depending on the type, select a read function. */
switch (scsi->devtype)
{
case grub_scsi_devtype_direct:
if (sector >> 32)
err = grub_scsi_read16 (disk, sector, len, buf);
else
err = grub_scsi_read10 (disk, sector, len, buf);
if (err)
return err;
break;
case grub_scsi_devtype_direct:
if (sector >> 32)
err = grub_scsi_read16 (disk, sector, size, buf);
else
err = grub_scsi_read10 (disk, sector, size, buf);
if (err)
return err;
break;
case grub_scsi_devtype_cdrom:
if (sector >> 32)
err = grub_scsi_read16 (disk, sector, len, buf);
else
err = grub_scsi_read12 (disk, sector, len, buf);
if (err)
return err;
break;
}
size -= len;
sector += len;
buf += len << disk->log_sector_size;
case grub_scsi_devtype_cdrom:
if (sector >> 32)
err = grub_scsi_read16 (disk, sector, size, buf);
else
err = grub_scsi_read12 (disk, sector, size, buf);
if (err)
return err;
break;
}
return GRUB_ERR_NONE;
@@ -718,10 +712,10 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
}
static grub_err_t
grub_scsi_write (grub_disk_t disk __attribute((unused)),
grub_disk_addr_t sector __attribute((unused)),
grub_size_t size __attribute((unused)),
const char *buf __attribute((unused)))
grub_scsi_write (grub_disk_t disk,
grub_disk_addr_t sector,
grub_size_t size,
const char *buf)
{
grub_scsi_t scsi;
@@ -730,31 +724,18 @@ grub_scsi_write (grub_disk_t disk __attribute((unused)),
if (scsi->devtype == grub_scsi_devtype_cdrom)
return grub_error (GRUB_ERR_IO, N_("cannot write to CD-ROM"));
while (size)
grub_err_t err;
/* Depending on the type, select a read function. */
switch (scsi->devtype)
{
/* PATA doesn't support more than 32K reads.
Not sure about AHCI and USB. If it's confirmed that either of
them can do bigger reads reliably this value can be moved to 'scsi'
structure. */
grub_size_t len = 32768 >> disk->log_sector_size;
grub_err_t err;
if (len > size)
len = size;
/* Depending on the type, select a read function. */
switch (scsi->devtype)
{
case grub_scsi_devtype_direct:
if (sector >> 32)
err = grub_scsi_write16 (disk, sector, len, buf);
else
err = grub_scsi_write10 (disk, sector, len, buf);
if (err)
return err;
break;
}
size -= len;
sector += len;
buf += len << disk->log_sector_size;
case grub_scsi_devtype_direct:
if (sector >> 32)
err = grub_scsi_write16 (disk, sector, size, buf);
else
err = grub_scsi_write10 (disk, sector, size, buf);
if (err)
return err;
break;
}
return GRUB_ERR_NONE;

View File

@@ -47,6 +47,7 @@ grub_ubootdisk_register (struct device_info *newdev)
{
case DT_STOR_IDE:
case DT_STOR_SATA:
case DT_STOR_SCSI:
case DT_STOR_MMC:
case DT_STOR_USB:
/* hd */

View File

@@ -44,7 +44,7 @@ struct grub_usbms_cbw
grub_uint8_t lun;
grub_uint8_t length;
grub_uint8_t cbwcb[16];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_usbms_csw
{
@@ -52,7 +52,7 @@ struct grub_usbms_csw
grub_uint32_t tag;
grub_uint32_t residue;
grub_uint8_t status;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_usbms_dev
{
@@ -76,7 +76,7 @@ typedef struct grub_usbms_dev *grub_usbms_dev_t;
static grub_usbms_dev_t grub_usbms_devices[MAX_USBMS_DEVICES];
static int first_available_slot = 0;
static grub_err_t
static grub_usb_err_t
grub_usbms_cbi_cmd (grub_usb_device_t dev, int interface,
grub_uint8_t *cbicb)
{
@@ -86,7 +86,7 @@ grub_usbms_cbi_cmd (grub_usb_device_t dev, int interface,
GRUB_USBMS_CBI_CMD_SIZE, (char*)cbicb);
}
static grub_err_t
static grub_usb_err_t
grub_usbms_cbi_reset (grub_usb_device_t dev, int interface)
{
/* Prepare array with Command Block Reset (=CBR) */
@@ -108,17 +108,13 @@ grub_usbms_cbi_reset (grub_usb_device_t dev, int interface)
return grub_usbms_cbi_cmd (dev, interface, (grub_uint8_t *)&cbicb);
}
static grub_err_t
static grub_usb_err_t
grub_usbms_bo_reset (grub_usb_device_t dev, int interface)
{
grub_usb_err_t u;
u = grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0);
if (u)
return grub_error (GRUB_ERR_IO, "USB error %d", u);
return GRUB_ERR_NONE;
return grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0);
}
static grub_err_t
static grub_usb_err_t
grub_usbms_reset (grub_usbms_dev_t dev)
{
if (dev->protocol == GRUB_USBMS_PROTOCOL_BULK)
@@ -149,7 +145,7 @@ grub_usbms_attach (grub_usb_device_t usbdev, int configno, int interfno)
int j;
grub_uint8_t luns = 0;
unsigned curnum;
grub_usb_err_t err = GRUB_ERR_NONE;
grub_usb_err_t err = GRUB_USB_ERR_NONE;
grub_boot_time ("Attaching USB mass storage");
@@ -302,6 +298,8 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
grub_usb_err_t errCSW = GRUB_USB_ERR_NONE;
int retrycnt = 3 + 1;
tag++;
retry:
retrycnt--;
if (retrycnt == 0)
@@ -310,7 +308,7 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
/* Setup the request. */
grub_memset (&cbw, 0, sizeof (cbw));
cbw.signature = grub_cpu_to_le32 (0x43425355);
cbw.tag = tag++;
cbw.tag = tag;
cbw.transfer_length = grub_cpu_to_le32 (size);
cbw.flags = (!read_write) << GRUB_USBMS_DIRECTION_BIT;
cbw.lun = scsi->lun; /* In USB MS CBW are LUN bits on another place than in SCSI CDB, both should be set correctly. */
@@ -339,7 +337,7 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
goto CheckCSW;
}
return grub_error (GRUB_ERR_IO, "USB Mass Storage request failed");
goto retry;
}
/* Read/write the data, (maybe) according to specification. */
@@ -571,8 +569,11 @@ grub_usbms_transfer_cbi (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
}
}
}
if (err)
return grub_error (GRUB_ERR_IO, "USB error %d", err);
return err;
return GRUB_ERR_NONE;
}

View File

@@ -0,0 +1,458 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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/disk.h>
#include <grub/dl.h>
#include <grub/mm.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/term.h>
#include <grub/i18n.h>
#include <grub/xen.h>
#include <grub/time.h>
#include <xen/io/blkif.h>
struct virtdisk
{
int handle;
char *fullname;
char *backend_dir;
char *frontend_dir;
struct blkif_sring *shared_page;
struct blkif_front_ring ring;
grub_xen_grant_t grant;
grub_xen_evtchn_t evtchn;
void *dma_page;
grub_xen_grant_t dma_grant;
};
#define xen_wmb() mb()
#define xen_mb() mb()
static struct virtdisk *virtdisks;
static grub_size_t vdiskcnt;
static int
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
grub_disk_pull_t pull)
{
grub_size_t i;
if (pull != GRUB_DISK_PULL_NONE)
return 0;
for (i = 0; i < vdiskcnt; i++)
if (hook (virtdisks[i].fullname, hook_data))
return 1;
return 0;
}
static grub_err_t
grub_virtdisk_open (const char *name, grub_disk_t disk)
{
grub_size_t i;
grub_uint32_t secsize;
char fdir[200];
char *buf;
for (i = 0; i < vdiskcnt; i++)
if (grub_strcmp (name, virtdisks[i].fullname) == 0)
break;
if (i == vdiskcnt)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
disk->data = &virtdisks[i];
disk->id = i;
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
disk->total_sectors = grub_strtoull (buf, 0, 10);
if (grub_errno)
return grub_errno;
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size",
virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
secsize = grub_strtoull (buf, 0, 10);
if (grub_errno)
return grub_errno;
if ((secsize & (secsize - 1)) || !secsize || secsize < 512
|| secsize > GRUB_XEN_PAGE_SIZE)
return grub_error (GRUB_ERR_IO, "unsupported sector size %d", secsize);
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < secsize; disk->log_sector_size++);
disk->total_sectors >>= disk->log_sector_size - 9;
return GRUB_ERR_NONE;
}
static void
grub_virtdisk_close (grub_disk_t disk __attribute__ ((unused)))
{
}
static grub_err_t
grub_virtdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
struct virtdisk *data = disk->data;
while (size)
{
grub_size_t cur;
struct blkif_request *req;
struct blkif_response *resp;
int sta = 0;
struct evtchn_send send;
cur = size;
if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
while (RING_FULL (&data->ring))
grub_xen_sched_op (SCHEDOP_yield, 0);
req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
req->operation = BLKIF_OP_READ;
req->nr_segments = 1;
req->handle = data->handle;
req->id = 0;
req->sector_number = sector << (disk->log_sector_size - 9);
req->seg[0].gref = data->dma_grant;
req->seg[0].first_sect = 0;
req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
data->ring.req_prod_pvt++;
RING_PUSH_REQUESTS (&data->ring);
mb ();
send.port = data->evtchn;
grub_xen_event_channel_op (EVTCHNOP_send, &send);
while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
{
grub_xen_sched_op (SCHEDOP_yield, 0);
mb ();
}
while (1)
{
int wtd;
RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
if (!wtd)
break;
resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
data->ring.rsp_cons++;
if (resp->status)
sta = resp->status;
}
if (sta)
return grub_error (GRUB_ERR_IO, "read failed");
grub_memcpy (buf, data->dma_page, cur << disk->log_sector_size);
size -= cur;
sector += cur;
buf += cur << disk->log_sector_size;
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_virtdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
struct virtdisk *data = disk->data;
while (size)
{
grub_size_t cur;
struct blkif_request *req;
struct blkif_response *resp;
int sta = 0;
struct evtchn_send send;
cur = size;
if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
grub_memcpy (data->dma_page, buf, cur << disk->log_sector_size);
while (RING_FULL (&data->ring))
grub_xen_sched_op (SCHEDOP_yield, 0);
req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
req->operation = BLKIF_OP_WRITE;
req->nr_segments = 1;
req->handle = data->handle;
req->id = 0;
req->sector_number = sector << (disk->log_sector_size - 9);
req->seg[0].gref = data->dma_grant;
req->seg[0].first_sect = 0;
req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
data->ring.req_prod_pvt++;
RING_PUSH_REQUESTS (&data->ring);
mb ();
send.port = data->evtchn;
grub_xen_event_channel_op (EVTCHNOP_send, &send);
while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
{
grub_xen_sched_op (SCHEDOP_yield, 0);
mb ();
}
while (1)
{
int wtd;
RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
if (!wtd)
break;
resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
data->ring.rsp_cons++;
if (resp->status)
sta = resp->status;
}
if (sta)
return grub_error (GRUB_ERR_IO, "write failed");
size -= cur;
sector += cur;
buf += cur << disk->log_sector_size;
}
return GRUB_ERR_NONE;
}
static struct grub_disk_dev grub_virtdisk_dev = {
.name = "xen",
.id = GRUB_DISK_DEVICE_XEN,
.iterate = grub_virtdisk_iterate,
.open = grub_virtdisk_open,
.close = grub_virtdisk_close,
.read = grub_virtdisk_read,
.write = grub_virtdisk_write,
.next = 0
};
static int
count (const char *dir __attribute__ ((unused)), void *data)
{
grub_size_t *ctr = data;
(*ctr)++;
return 0;
}
static int
fill (const char *dir, void *data)
{
grub_size_t *ctr = data;
domid_t dom;
/* "dir" is just a number, at most 19 characters. */
char fdir[200];
char num[20];
grub_err_t err;
void *buf;
struct evtchn_alloc_unbound alloc_unbound;
/* Shouldn't happen unles some hotplug happened. */
if (vdiskcnt >= *ctr)
return 1;
virtdisks[vdiskcnt].handle = grub_strtoul (dir, 0, 10);
if (grub_errno)
{
grub_errno = 0;
return 0;
}
virtdisks[vdiskcnt].fullname = 0;
virtdisks[vdiskcnt].backend_dir = 0;
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend", dir);
virtdisks[vdiskcnt].backend_dir = grub_xenstore_get_file (fdir, NULL);
if (!virtdisks[vdiskcnt].backend_dir)
goto out_fail_1;
grub_snprintf (fdir, sizeof (fdir), "%s/dev",
virtdisks[vdiskcnt].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
{
grub_errno = 0;
virtdisks[vdiskcnt].fullname = grub_xasprintf ("xenid/%s", dir);
}
else
{
virtdisks[vdiskcnt].fullname = grub_xasprintf ("xen/%s", (char *) buf);
grub_free (buf);
}
if (!virtdisks[vdiskcnt].fullname)
goto out_fail_1;
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend-id", dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
goto out_fail_1;
dom = grub_strtoul (buf, 0, 10);
grub_free (buf);
if (grub_errno)
goto out_fail_1;
virtdisks[vdiskcnt].shared_page =
grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].grant);
if (!virtdisks[vdiskcnt].shared_page)
goto out_fail_1;
virtdisks[vdiskcnt].dma_page =
grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].dma_grant);
if (!virtdisks[vdiskcnt].dma_page)
goto out_fail_2;
alloc_unbound.dom = DOMID_SELF;
alloc_unbound.remote_dom = dom;
grub_xen_event_channel_op (EVTCHNOP_alloc_unbound, &alloc_unbound);
virtdisks[vdiskcnt].evtchn = alloc_unbound.port;
SHARED_RING_INIT (virtdisks[vdiskcnt].shared_page);
FRONT_RING_INIT (&virtdisks[vdiskcnt].ring, virtdisks[vdiskcnt].shared_page,
GRUB_XEN_PAGE_SIZE);
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/ring-ref", dir);
grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].grant);
err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
if (err)
goto out_fail_3;
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/event-channel", dir);
grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].evtchn);
err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
if (err)
goto out_fail_3;
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/protocol", dir);
err = grub_xenstore_write_file (fdir, XEN_IO_PROTO_ABI_NATIVE,
grub_strlen (XEN_IO_PROTO_ABI_NATIVE));
if (err)
goto out_fail_3;
struct gnttab_dump_table dt;
dt.dom = DOMID_SELF;
grub_xen_grant_table_op (GNTTABOP_dump_table, (void *) &dt, 1);
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/state", dir);
err = grub_xenstore_write_file (fdir, "3", 1);
if (err)
goto out_fail_3;
while (1)
{
grub_snprintf (fdir, sizeof (fdir), "%s/state",
virtdisks[vdiskcnt].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
goto out_fail_3;
if (grub_strcmp (buf, "2") != 0)
break;
grub_free (buf);
grub_xen_sched_op (SCHEDOP_yield, 0);
}
grub_dprintf ("xen", "state=%s\n", (char *) buf);
grub_free (buf);
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s", dir);
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
vdiskcnt++;
return 0;
out_fail_3:
grub_xen_free_shared_page (virtdisks[vdiskcnt].dma_page);
out_fail_2:
grub_xen_free_shared_page (virtdisks[vdiskcnt].shared_page);
out_fail_1:
grub_free (virtdisks[vdiskcnt].backend_dir);
grub_free (virtdisks[vdiskcnt].fullname);
grub_errno = 0;
return 0;
}
void
grub_xendisk_init (void)
{
grub_size_t ctr = 0;
if (grub_xenstore_dir ("device/vbd", count, &ctr))
grub_errno = 0;
if (!ctr)
return;
virtdisks = grub_malloc (ctr * sizeof (virtdisks[0]));
if (!virtdisks)
return;
if (grub_xenstore_dir ("device/vbd", fill, &ctr))
grub_errno = 0;
grub_disk_dev_register (&grub_virtdisk_dev);
}
void
grub_xendisk_fini (void)
{
char fdir[200];
unsigned i;
for (i = 0; i < vdiskcnt; i++)
{
char *buf;
struct evtchn_close close_op = {.port = virtdisks[i].evtchn };
grub_snprintf (fdir, sizeof (fdir), "%s/state",
virtdisks[i].frontend_dir);
grub_xenstore_write_file (fdir, "6", 1);
while (1)
{
grub_snprintf (fdir, sizeof (fdir), "%s/state",
virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
grub_dprintf ("xen", "state=%s\n", (char *) buf);
if (!buf || grub_strcmp (buf, "6") == 0)
break;
grub_free (buf);
grub_xen_sched_op (SCHEDOP_yield, 0);
}
grub_free (buf);
grub_snprintf (fdir, sizeof (fdir), "%s/ring-ref",
virtdisks[i].frontend_dir);
grub_xenstore_write_file (fdir, NULL, 0);
grub_snprintf (fdir, sizeof (fdir), "%s/event-channel",
virtdisks[i].frontend_dir);
grub_xenstore_write_file (fdir, NULL, 0);
grub_xen_free_shared_page (virtdisks[i].dma_page);
grub_xen_free_shared_page (virtdisks[i].shared_page);
grub_xen_event_channel_op (EVTCHNOP_close, &close_op);
/* Prepare for handoff. */
grub_snprintf (fdir, sizeof (fdir), "%s/state",
virtdisks[i].frontend_dir);
grub_xenstore_write_file (fdir, "1", 1);
}
}

View File

@@ -122,7 +122,10 @@ SUFFIX (grub_efiemu_crc) (void)
int handle;
grub_off_t off;
struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
grub_uint8_t crc32_context[GRUB_MD_CRC32->contextsize];
grub_uint32_t crc32_val;
if (GRUB_MD_CRC32->mdlen != 4)
return grub_error (GRUB_ERR_BUG, "incorrect mdlen");
/* compute CRC32 of runtime_services */
err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
@@ -134,12 +137,11 @@ SUFFIX (grub_efiemu_crc) (void)
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
runtime_services->hdr.crc32 = 0;
GRUB_MD_CRC32->init(crc32_context);
GRUB_MD_CRC32->write(crc32_context, runtime_services, runtime_services->hdr.header_size);
GRUB_MD_CRC32->final(crc32_context);
grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
runtime_services, runtime_services->hdr.header_size);
runtime_services->hdr.crc32 =
grub_be_to_cpu32(*(grub_uint32_t*)GRUB_MD_CRC32->read(crc32_context));
grub_be_to_cpu32(crc32_val);
err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
if (err)
@@ -147,12 +149,11 @@ SUFFIX (grub_efiemu_crc) (void)
/* compute CRC32 of system table */
SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
GRUB_MD_CRC32->init(crc32_context);
GRUB_MD_CRC32->write(crc32_context, SUFFIX (grub_efiemu_system_table),
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
GRUB_MD_CRC32->final(crc32_context);
grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
SUFFIX (grub_efiemu_system_table),
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
SUFFIX (grub_efiemu_system_table)->hdr.crc32 =
grub_be_to_cpu32(*(grub_uint32_t*)GRUB_MD_CRC32->read(crc32_context));
grub_be_to_cpu32(crc32_val);
grub_dprintf ("efiemu","system_table = %p, runtime_services = %p\n",
SUFFIX (grub_efiemu_system_table), runtime_services);

View File

@@ -19,16 +19,18 @@
#define GRUB_TYPES_CPU_HEADER 1
#ifdef ELF32
#ifdef __i386__
# define SIZEOF_VOID_P 4
# define SIZEOF_LONG 4
# define GRUB_TARGET_SIZEOF_VOID_P 4
# define GRUB_TARGET_SIZEOF_LONG 4
# define EFI_FUNC(x) x
#else
#elif defined (__x86_64__)
# define SIZEOF_VOID_P 8
# define SIZEOF_LONG 8
# define GRUB_TARGET_SIZEOF_VOID_P 8
# define GRUB_TARGET_SIZEOF_LONG 8
# define EFI_FUNC(x) x ## _real
#else
#error "Unknown architecture"
#endif

View File

@@ -33,7 +33,7 @@
GRUB_MOD_LICENSE ("GPLv3+");
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
#include "ascii.h"
#endif
@@ -110,14 +110,14 @@ static struct grub_font null_font;
/* Flag to ensure module is initialized only once. */
static grub_uint8_t font_loader_initialized;
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
static struct grub_font_glyph *ascii_font_glyph[0x80];
#endif
static struct grub_font_glyph *
ascii_glyph_lookup (grub_uint32_t code)
{
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
static int ascii_failback_initialized = 0;
if (code >= 0x80)

View File

@@ -36,7 +36,7 @@ struct grub_affs_bblock
grub_uint8_t flags;
grub_uint32_t checksum;
grub_uint32_t rootblock;
} __attribute__ ((packed));
} GRUB_PACKED;
/* Set if the filesystem is a AFFS filesystem. Otherwise this is an
OFS filesystem. */
@@ -51,14 +51,14 @@ struct grub_affs_rblock
grub_uint32_t unused2;
grub_uint32_t checksum;
grub_uint32_t hashtable[1];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_affs_time
{
grub_int32_t day;
grub_uint32_t min;
grub_uint32_t hz;
} __attribute__ ((packed));
} GRUB_PACKED;
/* The second part of a file header block. */
struct grub_affs_file
@@ -76,7 +76,7 @@ struct grub_affs_file
grub_uint32_t parent;
grub_uint32_t extension;
grub_uint32_t type;
} __attribute__ ((packed));
} GRUB_PACKED;
/* The location of `struct grub_affs_file' relative to the end of a
file header block. */
@@ -565,7 +565,6 @@ grub_affs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
info.mtimeset = 1;
info.mtime = aftime2ctime (&node->di.mtime);
info.size = grub_be_to_cpu32 (node->di.size);
grub_free (node);
return ctx->hook (filename, &info, ctx->hook_data);
}

View File

@@ -67,6 +67,7 @@ handle_symlink (struct grub_archelp_data *data,
grub_size_t prefixlen;
char *rest;
char *linktarget;
grub_size_t linktarget_len;
*restart = 0;
@@ -96,7 +97,8 @@ handle_symlink (struct grub_archelp_data *data,
return grub_errno;
if (linktarget[0] == '\0')
return GRUB_ERR_NONE;
target = grub_malloc (grub_strlen (linktarget) + grub_strlen (*name) + 2);
linktarget_len = grub_strlen (linktarget);
target = grub_malloc (linktarget_len + grub_strlen (*name) + 2);
if (!target)
return grub_errno;
@@ -121,7 +123,7 @@ handle_symlink (struct grub_archelp_data *data,
grub_memcpy (target, *name, prefixlen);
target[prefixlen-1] = '/';
}
grub_strcat (target, rest);
grub_strcpy (target + prefixlen + linktarget_len, rest);
grub_dprintf ("archelp", "symlink redirected %s to %s\n",
*name, target);
grub_free (*name);
@@ -155,10 +157,9 @@ grub_archelp_dir (struct grub_archelp_data *data,
{
grub_int32_t mtime;
grub_uint32_t mode;
grub_uint64_t size;
grub_err_t err;
if (arcops->find_file (data, &name, &mtime, &mode, &size))
if (arcops->find_file (data, &name, &mtime, &mode))
goto fail;
if (mode == GRUB_ARCHELP_ATTR_END)
@@ -190,7 +191,6 @@ grub_archelp_dir (struct grub_archelp_data *data,
info.mtime = mtime;
info.mtimeset = 1;
}
info.size = size;
if (hook (n, &info, hook_data))
{
grub_free (name);
@@ -250,9 +250,8 @@ grub_archelp_open (struct grub_archelp_data *data,
{
grub_uint32_t mode;
int restart;
grub_uint64_t size;
if (arcops->find_file (data, &fn, NULL, &mode, &size))
if (arcops->find_file (data, &fn, NULL, &mode))
goto fail;
if (mode == GRUB_ARCHELP_ATTR_END)

View File

@@ -73,7 +73,7 @@ struct grub_bfs_extent
grub_uint32_t ag;
grub_uint16_t start;
grub_uint16_t len;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_superblock
{
@@ -89,7 +89,7 @@ struct grub_bfs_superblock
grub_uint8_t unused3[32];
grub_uint32_t magic3;
struct grub_bfs_extent root_dir;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_inode
{
@@ -118,11 +118,11 @@ struct grub_bfs_inode
grub_uint64_t max_double_indirect_range;
grub_uint64_t size;
grub_uint32_t pad[4];
} __attribute__ ((packed));
} GRUB_PACKED;
char inplace_link[144];
} __attribute__ ((packed));
} GRUB_PACKED;
grub_uint8_t small_data[0];
} __attribute__ ((packed));
} GRUB_PACKED;
enum
{
@@ -134,7 +134,7 @@ struct grub_bfs_small_data_element_header
grub_uint32_t type;
grub_uint16_t name_len;
grub_uint16_t value_len;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_btree_header
{
@@ -151,7 +151,7 @@ struct grub_bfs_btree_header
grub_uint64_t root;
#endif
grub_uint32_t unused2[2];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_btree_node
{
@@ -165,7 +165,7 @@ struct grub_bfs_btree_node
grub_uint16_t count_keys;
grub_uint16_t total_key_len;
#endif
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_bfs_data
{
@@ -889,7 +889,6 @@ grub_bfs_dir_iter (const char *name, grub_uint64_t value,
info.mtime = grub_bfs_to_cpu64 (ino.mtime) >> 16;
#endif
info.dir = ((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) == ATTR_DIR);
info.size = grub_bfs_to_cpu64 (ino.size);
return ctx->hook (name, &info, ctx->hook_data);
}

View File

@@ -1,7 +1,7 @@
/* btrfs.c - B-tree file system. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
* Copyright (C) 2010,2011,2012,2013 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
@@ -28,6 +28,7 @@
#include <grub/deflate.h>
#include <minilzo.h>
#include <grub/i18n.h>
#include <grub/btrfs.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -52,7 +53,7 @@ struct grub_btrfs_device
grub_uint64_t device_id;
grub_uint64_t size;
grub_uint8_t dummy[0x62 - 0x10];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_superblock
{
@@ -70,7 +71,7 @@ struct grub_btrfs_superblock
char label[0x100];
grub_uint8_t dummy4[0x100];
grub_uint8_t bootstrap_mapping[0x800];
} __attribute__ ((packed));
} GRUB_PACKED;
struct btrfs_header
{
@@ -79,7 +80,7 @@ struct btrfs_header
grub_uint8_t dummy[0x30];
grub_uint32_t nitems;
grub_uint8_t level;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_device_desc
{
@@ -106,24 +107,6 @@ struct grub_btrfs_data
struct grub_btrfs_extent_data *extent;
};
enum
{
GRUB_BTRFS_ITEM_TYPE_INODE_ITEM = 0x01,
GRUB_BTRFS_ITEM_TYPE_INODE_REF = 0x0c,
GRUB_BTRFS_ITEM_TYPE_DIR_ITEM = 0x54,
GRUB_BTRFS_ITEM_TYPE_EXTENT_ITEM = 0x6c,
GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM = 0x84,
GRUB_BTRFS_ITEM_TYPE_DEVICE = 0xd8,
GRUB_BTRFS_ITEM_TYPE_CHUNK = 0xe4
};
struct grub_btrfs_key
{
grub_uint64_t object_id;
grub_uint8_t type;
grub_uint64_t offset;
} __attribute__ ((packed));
struct grub_btrfs_chunk_item
{
grub_uint64_t size;
@@ -139,28 +122,28 @@ struct grub_btrfs_chunk_item
grub_uint8_t dummy2[0xc];
grub_uint16_t nstripes;
grub_uint16_t nsubstripes;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_chunk_stripe
{
grub_uint64_t device_id;
grub_uint64_t offset;
grub_btrfs_uuid_t device_uuid;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_leaf_node
{
struct grub_btrfs_key key;
grub_uint32_t offset;
grub_uint32_t size;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_internal_node
{
struct grub_btrfs_key key;
grub_uint64_t addr;
grub_uint64_t dummy;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_dir_item
{
@@ -173,7 +156,7 @@ struct grub_btrfs_dir_item
#define GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK 7
grub_uint8_t type;
char name[0];
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_leaf_descriptor
{
@@ -188,13 +171,6 @@ struct grub_btrfs_leaf_descriptor
} *data;
};
struct grub_btrfs_root_item
{
grub_uint8_t dummy[0xb0];
grub_uint64_t tree;
grub_uint64_t inode;
};
struct grub_btrfs_time
{
grub_int64_t sec;
@@ -207,7 +183,7 @@ struct grub_btrfs_inode
grub_uint64_t size;
grub_uint8_t dummy2[0x70];
struct grub_btrfs_time mtime;
} __attribute__ ((packed));
} GRUB_PACKED;
struct grub_btrfs_extent_data
{
@@ -228,7 +204,7 @@ struct grub_btrfs_extent_data
grub_uint64_t filled;
};
};
} __attribute__ ((packed));
} GRUB_PACKED;
#define GRUB_BTRFS_EXTENT_INLINE 0
#define GRUB_BTRFS_EXTENT_REGULAR 1
@@ -935,7 +911,6 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
{
grub_uint32_t total_size, cblock_size;
grub_size_t ret = 0;
unsigned char buf[GRUB_BTRFS_LZO_BLOCK_SIZE];
char *ibuf0 = ibuf;
total_size = grub_le_to_cpu32 (grub_get_unaligned32 (ibuf));
@@ -979,13 +954,21 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
if (off > 0 || osize < GRUB_BTRFS_LZO_BLOCK_SIZE)
{
grub_size_t to_copy = GRUB_BTRFS_LZO_BLOCK_SIZE - off;
grub_uint8_t *buf;
if (to_copy > osize)
to_copy = osize;
buf = grub_malloc (GRUB_BTRFS_LZO_BLOCK_SIZE);
if (!buf)
return -1;
if (lzo1x_decompress_safe ((lzo_bytep)ibuf, cblock_size, buf, &usize,
NULL) != LZO_E_OK)
return -1;
{
grub_free (buf);
return -1;
}
if (to_copy > usize)
to_copy = usize;
@@ -996,6 +979,8 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
obuf += to_copy;
ibuf += cblock_size;
off = 0;
grub_free (buf);
continue;
}
@@ -1119,7 +1104,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
- (grub_uint8_t *) data->extent),
extoff, buf, csize)
!= (grub_ssize_t) csize)
return -1;
{
if (!grub_errno)
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"premature end of compressed");
return -1;
}
}
else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_LZO)
{
@@ -1173,7 +1163,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
grub_free (tmp);
if (ret != (grub_ssize_t) csize)
return -1;
{
if (!grub_errno)
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"premature end of compressed");
return -1;
}
break;
}
@@ -1196,6 +1191,40 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
return pos - pos0;
}
static grub_err_t
get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
grub_uint64_t *tree, grub_uint8_t *type)
{
grub_err_t err;
grub_disk_addr_t elemaddr;
grub_size_t elemsize;
struct grub_btrfs_key key_out, key_in;
struct grub_btrfs_root_item ri;
key_in.object_id = GRUB_BTRFS_ROOT_VOL_OBJECTID;
key_in.offset = 0;
key_in.type = GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM;
err = lower_bound (data, &key_in, &key_out,
data->sblock.root_tree,
&elemaddr, &elemsize, NULL, 0);
if (err)
return err;
if (key_in.object_id != key_out.object_id
|| key_in.type != key_out.type
|| key_in.offset != key_out.offset)
return grub_error (GRUB_ERR_BAD_FS, "no root");
err = grub_btrfs_read_logical (data, elemaddr, &ri,
sizeof (ri), 0);
if (err)
return err;
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
key->offset = 0;
key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
*tree = ri.tree;
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
return GRUB_ERR_NONE;
}
static grub_err_t
find_path (struct grub_btrfs_data *data,
const char *path, struct grub_btrfs_key *key,
@@ -1208,42 +1237,31 @@ find_path (struct grub_btrfs_data *data,
grub_size_t allocated = 0;
struct grub_btrfs_dir_item *direl = NULL;
struct grub_btrfs_key key_out;
int skip_default;
const char *ctoken;
grub_size_t ctokenlen;
char *path_alloc = NULL;
char *origpath = NULL;
unsigned symlinks_max = 32;
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
*tree = data->sblock.root_tree;
key->object_id = data->sblock.root_dir_objectid;
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
key->offset = 0;
skip_default = 1;
err = get_root (data, key, tree, type);
if (err)
return err;
origpath = grub_strdup (path);
if (!origpath)
return grub_errno;
while (1)
{
if (!skip_default)
{
while (path[0] == '/')
path++;
if (!path[0])
break;
slash = grub_strchr (path, '/');
if (!slash)
slash = path + grub_strlen (path);
ctoken = path;
ctokenlen = slash - path;
}
else
{
ctoken = "default";
ctokenlen = sizeof ("default") - 1;
}
while (path[0] == '/')
path++;
if (!path[0])
break;
slash = grub_strchr (path, '/');
if (!slash)
slash = path + grub_strlen (path);
ctoken = path;
ctokenlen = slash - path;
if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
{
@@ -1254,10 +1272,8 @@ find_path (struct grub_btrfs_data *data,
if (ctokenlen == 1 && ctoken[0] == '.')
{
if (!skip_default)
path = slash;
skip_default = 0;
continue;
path = slash;
continue;
}
if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.')
{
@@ -1287,9 +1303,7 @@ find_path (struct grub_btrfs_data *data,
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
key->object_id = key_out.offset;
if (!skip_default)
path = slash;
skip_default = 0;
path = slash;
continue;
}
@@ -1359,9 +1373,7 @@ find_path (struct grub_btrfs_data *data,
return err;
}
if (!skip_default)
path = slash;
skip_default = 0;
path = slash;
if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK)
{
struct grub_btrfs_inode inode;
@@ -1411,12 +1423,9 @@ find_path (struct grub_btrfs_data *data,
path = path_alloc = tmp;
if (path[0] == '/')
{
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
*tree = data->sblock.root_tree;
key->object_id = data->sblock.root_dir_objectid;
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
key->offset = 0;
skip_default = 1;
err = get_root (data, key, tree, type);
if (err)
return err;
}
continue;
}
@@ -1580,7 +1589,6 @@ grub_btrfs_dir (grub_device_t device, const char *path,
else
{
info.mtime = grub_le_to_cpu64 (inode.mtime.sec);
info.size = grub_le_to_cpu64 (inode.size);
info.mtimeset = 1;
}
c = cdirel->name[grub_le_to_cpu16 (cdirel->n)];

View File

@@ -44,8 +44,7 @@ struct grub_archelp_data
static grub_err_t
grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
grub_int32_t *mtime,
grub_uint32_t *mode,
grub_uint64_t *size)
grub_uint32_t *mode)
{
grub_size_t offset;
for (;;
@@ -72,7 +71,6 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
return GRUB_ERR_NONE;
}
data->size = grub_be_to_cpu32 (hd.len);
*size = grub_be_to_cpu32 (hd.len);
(void) mtime;
offset = grub_be_to_cpu32 (hd.offset);
@@ -269,7 +267,8 @@ grub_cbfs_close (grub_file_t file)
return grub_errno;
}
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) \
&& !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
static char *cbfsdisk_addr;
static grub_off_t cbfsdisk_size = 0;
@@ -291,7 +290,8 @@ grub_cbfsdisk_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a cbfsdisk");
disk->total_sectors = cbfsdisk_size / GRUB_DISK_SECTOR_SIZE;
disk->id = (unsigned long) "cbfs";
disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
disk->id = 0;
return GRUB_ERR_NONE;
}
@@ -376,7 +376,7 @@ static struct grub_fs grub_cbfs_fs = {
GRUB_MOD_INIT (cbfs)
{
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
init_cbfsdisk ();
#endif
grub_fs_register (&grub_cbfs_fs);
@@ -385,7 +385,7 @@ GRUB_MOD_INIT (cbfs)
GRUB_MOD_FINI (cbfs)
{
grub_fs_unregister (&grub_cbfs_fs);
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
fini_cbfsdisk ();
#endif
}

Some files were not shown because too many files have changed in this diff Show More