Compare commits

...
Author SHA1 Message Date
Vladimir Serbinenko 7c58da503f merge master to newports/alpha 2013-11-08 18:46:53 +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 5574a209a0 Merge branch 'phcoder/ports/alpha' of git.sv.gnu.org:/srv/git/grub into phcoder/ports/alpha 2013-10-26 02:59:51 +02:00
Vladimir Serbinenko 739b471725 Remove all signed divisions 2013-10-26 02:59:23 +02:00
Vladimir Serbinenko 4c2055ef0b Remove all signed divisions 2013-10-26 02:57:37 +02:00
Vladimir Serbinenko 5d20f9b0e7 Merge remote-tracking branch 'origin/master' into phcoder/ports/alpha 2013-10-26 02:49:12 +02:00
Vladimir Serbinenko 8d5401d29e Merge branch 'master' into phcoder/ports/alpha 2013-10-25 23:58:52 +02:00
Vladimir Serbinenko 3f170e4e73 Merge branch 'master' into phcoder/ports/alpha 2013-10-25 23:27:18 +02:00
Vladimir Serbinenko 7cb450b45e Merge branch 'master' into phcoder/ports/alpha 2013-10-25 21:40:54 +02:00
Vladimir Serbinenko f0a52cf8d2 Merge branch 'master' into phcoder/ports/alpha 2013-10-25 19:49:21 +02:00
Vladimir Serbinenko 3c75c98572 Add missing lines for alpha-srm build 2013-10-25 17:59:29 +02:00
Vladimir Serbinenko e2977a3d68 Remove stale grub_reboot 2013-10-25 17:54:39 +02:00
Vladimir Serbinenko 69fbf6a348 Fix reboot.c and exports 2013-10-25 17:00:01 +02:00
Vladimir Serbinenko cd4ae2e39b Import setjmp from glibc 2013-10-25 16:41:38 +02:00
Vladimir Serbinenko 20fbcb1e9d Merge branch 'master' into phcoder/ports/alpha
Conflicts:
	grub-core/term/terminfo.c
2013-10-25 16:08:50 +02:00
Vladimir Serbinenko 2762216e13 Add alpha to the list of terminfo 2013-10-25 15:09:17 +02:00
Vladimir Serbinenko 6e8c12917b Add stub for bootlocation 2013-10-25 15:07:08 +02:00
Vladimir Serbinenko 0947b55c73 More compile fixes 2013-10-25 15:04:45 +02:00
Vladimir Serbinenko 8a9ece7b4c Fix compilation 2013-10-25 14:46:59 +02:00
Vladimir Serbinenko 85872c8373 Recommit my work on alpha 2013-10-25 13:50:38 +02:00
245 changed files with 16354 additions and 4283 deletions

No files matched your search

+573
View File
@@ -1,3 +1,576 @@
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* b/grub-core/term/serial.c: Add option for enabling/disabling
RTS/CTS flow control.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/libgcrypt/cipher/idea.c (mul_inv): Remove signed
divisions.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/gui.h (grub_fixed_sfs_divide): Round rather than
truncate.
(grub_fixed_fsf_divide): Likewise.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/gfxmenu/gui_list.c (draw_scrollbar): Avoid
division by-zero and senseless negative divisions.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/gfxmenu/gui_progress_bar.c (draw_pixmap_bar): Avoid
division by-zero and senseless negative divisions.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Use elf_*_fbsd on kfreebsd.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/tests/div_test.c: New test.
2013-11-08 Vladimir Testov <vladimir.testov@rosalab.ru>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/mm.c (grub_real_malloc): Use AND rather than MOD
for alignment.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/misc.c (grub_divmod64): Don't fallback to
simple division on arm and ia64.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/arm/misc.S (__aeabi_unwind_cpp_pr0): Add dummy to
link with libgcc.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/symbol.h (FUNCTION), (VARIABLE): Fix precedence logic.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/symbol.h (FUNCTION), (VARIABLE) [__arm__]: Use % as
prefix symbol, not @.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* INSTALL: Add note about older gcc and clang.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* tests/util/grub-shell.in: Boot as hdd on ppc by default.
2013-11-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/multiboot_mbi2.c (grub_multiboot_add_module): Fix
NULL pointer dereference.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.am: Do not include libgcc.h when compiling with
clang.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/powerpc/dl.c: Add missing pragma to silence cast-align
warnings.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Don't add -no-itegrated-as on clang on non-x86.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
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 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
Import libgcrypt 1.5.3.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Don't add -Wcast-align on x86.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add -freg-struct-return on all platforms that
support it.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* acinclude.m4: Use -Werror on parameter tests.
* configure.ac: Likewise.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* acinclude.m4: Add missing TARGET_CCASFLAGS on asm tests.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Check that -malign-loops works rather than assuming that
either -falign-loops or -malign-loops work.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Remove -fnested-functions. We don't need it anymore.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Prevent cflags leaking to subsequent tests by always
resetting cflags to target_cflags in target tests.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
function.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/misc.c (grub_vsnprintf_real): Remove nested functions.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/arg.c (grub_arg_parse): Remove nested function.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/cmdline.c (grub_cmdline_get):
Remove nested functions.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* tests/test_sha512sum.in: Make it work on emu.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/charset.c (bidi_line_wrap): Eliminate nested
functions.
(grub_bidi_line_logical_to_visual): Likewise.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
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 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c (process_cursive): Remove nested function.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/misc.h (grub_dprintf): Use unnamed vararg.
(grub_boot_time): Likewise.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/symbol.h (FUNCTION): Use @function rather than
"function".
(VARIABLE): Likewise.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/bootp.c (OFFSET_OF): Explicitly cast to grub_size_t.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/bootp.c (set_env_limn_ro): Make pointer const.
(parse_dhcp_vendor): Likewise.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimagexx.c (relocate_symbols): Remove unneeded brackets.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/gettext/gettext.c (main_context), (secondary_context):
Define after defining type and not before.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/geli.c (geli_rekey): Fix error return type.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/io/lzopio.c (test_header): Simplify code and remove useless
"checksum = checksum;".
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/reiserfs.c (grub_reiserfs_iterate_dir): Fix type of
entry_type.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/legacycfg.c (grub_cmd_legacy_kernel): Fix
BIOS disk check.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/usb.h (grub_usb_controller_dev): Make portstatus
return grub_usb_err_t for cosistency. All users updated.
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
* util/mkimage.c (SzAlloc): Use attribute unused rather than dubious
assigning to itself.
2013-11-05 Gustavo Luiz Duarte <gustavold@linux.vnet.ibm.com>
2013-11-05 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
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.
2013-11-05 Vladimir Testov <vladimir.testov@rosalab.ru>
* grub-core/video/fb/video_fb.c: Merge two blit functions
into one.
2013-11-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/terminfo.c: Add sequences for home and end.
2013-11-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/legacy_parse.c: Fix handling of hercules and add
graphics console.
2013-11-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/video/i386/pc/vga.c: Fix double bufferring and
add mode 0x12.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi (Vendor power-on keys): Add XPS M1330M based on old
e-mail by Per Öberg.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/i386/nthibr.c (GRUB_MOD_INIT): Fix typo in command
name.
2013-11-04 Andrey Borzenkov <arvidjaar@gmail.com>
* configure.ac: Explicitly disable emusdl, emuusb and emupci on non-
emu platforms.
* grub-core/Makefile.core.def: Enable emupci and emuucb only for emu.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi: Document usage of menuentry id.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi: Add few mentions about EFI, debug and videoinfo.
2013-11-04 Peter Lustig <peter.lustig.7db@gmail.com>
* grub-core/commands/i386/nthibr.c: New command.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/tests/video_checksum.c: Add 2560x1440 mode to testing.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/term.h (grub_term_coordinate): Extend to 16-bit per
coordinate.
2013-11-04 Vladimir Serbinenko <phcoder@gmail.com>
Support GRUB_DISABLE_SUBMENU config.
Inspired by patch from Prarit Bhargava.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi: Mention RSA support.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c: Add RSA support.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Mike Frysinger <vapier>
* configure.ac: Don't add target-prefix.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/loadenv.c (grub_cmd_save_env): Remove unset
variables.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/gettext/gettext.c (grub_gettext_init_ext): Ignore errors
if language is English.
2013-11-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/linux/getroot.c: Fix cast-align problems.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Don't add -m32/-m64 on emu.
2013-11-02 neil
* grub-core/osdep/linux/blocklist.c: Include linux/types.h for some
broken linux headers.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub.d/30_os-prober.in: Add unhiding of partition if on msdos.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mount.c: Handle symlinks to directories.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/fshelp.c (find_file): Save ctx->next when calling
find_file recursively for symlink.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* tests/util/grub-shell.in: Copy themes.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimagexx.c (locate_sections): Reject mislinked images.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Use 0x8000 for address instead of 8000.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/sparc64/ieee1275/linux.c (get_physbase): Fix
signature.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/efi/efidisk.c (grub_efidisk_readwrite): Remove unused
variable.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac (TARGET_CFLAGS): Add -march=i386 on i386.
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* conf/Makefile.common (CFLAGS_PLATFORM): Remove poisoning of float
and double.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/tar.c (grub_cpio_read): Add read_hook.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
Rewrite blocklist functions in order to get progress when
reading large extents and decrease amount of blocklist hook calls.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/serial.c (options), (grub_cmd_serial): Fix handling
of SI suffixes.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
Support --base-clock for serial command to handle weird cards with
non-standard base clock.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* 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 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/misc.h (grub_strcat): Removed. All users changed to
more appropriate functions.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/efi.c (grub_efi_get_filename): Avoid inefficient
realloc.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.in: Do not use UUID search on EFI.
2013-11-01 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/dl.c: Unify section-finding algorithm. Saves 30 bytes
on core size.
2013-10-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/mm.c (grub_realloc): Don't copy more data than we have.
2013-10-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/io/gzio.c (huft_build): Use zalloc for safety.
(initialize_tables): reset tl and td to NULL after freeing.
2013-10-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/multiboot_mbi2.c: Implement network tag.
+4
View File
@@ -12,6 +12,10 @@ 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.
Note: clang 3.4 or later works for powerpc
* GNU Make
* GNU Bison 2.3 or later
* GNU gettext 0.17 or later
+3 -3
View File
@@ -212,7 +212,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
@@ -266,7 +266,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
@@ -391,7 +391,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
+4 -37
View File
@@ -6,18 +6,6 @@ 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
@@ -37,11 +25,6 @@ endif
# 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)
@@ -54,26 +37,10 @@ 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
@@ -107,13 +74,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 -Wno-old-style-definition
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
+2
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@
+152 -94
View File
@@ -41,7 +41,9 @@ AC_CONFIG_AUX_DIR([build-aux])
# Checks for host and target systems.
AC_CANONICAL_HOST
save_program_prefix="${program_prefix}"
AC_CANONICAL_TARGET
program_prefix="${save_program_prefix}"
AM_INIT_AUTOMAKE()
AC_PREREQ(2.60)
@@ -121,6 +123,7 @@ if test "x$with_platform" = x; then
mipsel-*) platform=loongson ;;
mips-*) platform=arc ;;
ia64-*) platform=efi ;;
alpha-*) platform=srm ;;
arm-*) platform=uboot ;;
*) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
esac
@@ -157,16 +160,19 @@ case "$target_cpu"-"$platform" in
mipsel-yeeloong) platform=loongson ;;
mipsel-fuloong) platform=loongson ;;
mipsel-loongson) ;;
alpha-srm ) ;;
arm-uboot) ;;
arm-efi) ;;
*-emu) ;;
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
esac
case "$target_cpu" in
i386 | powerpc) target_m32=1 ;;
x86_64 | sparc64) target_m64=1 ;;
esac
if test x$platform != xemu ; then
case "$target_cpu" in
i386 | powerpc) target_m32=1 ;;
x86_64 | sparc64) target_m64=1 ;;
esac
fi
case "$target_os" in
windows* | mingw32*) target_os=cygwin ;;
@@ -193,6 +199,7 @@ case "$platform" in
uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
srm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ALPHA_SRM=1" ;;
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
@@ -385,7 +392,7 @@ AC_SUBST([LIBUTIL])
AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$HOST_CFLAGS -Wtrampolines"
CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
int va_arg_func (int fixed, va_list args);]], [[]])],
[grub_cv_host_cc_wtrampolines=yes],
@@ -467,27 +474,89 @@ AC_SUBST(TARGET_NMFLAGS_MINUS_P)
AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
# debug flags.
WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
fi
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifdef __clang__
#error "is clang"
#endif
]])],
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
# clang doesn't support .code16
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
fi
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
TARGET_MODULE_FORMAT="elf32"
fi
if test "x$target_m64" = x1; then
# Force 64-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
TARGET_MODULE_FORMAT="elf64"
fi
if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
fi
# Force no alignment to save space on i386.
if test "x$target_cpu" = xi386; then
AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
CFLAGS="$CFLAGS -falign-loops=1"
CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_falign_loop=yes],
[grub_cv_cc_falign_loop=no])
])
AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_malign_loop=yes],
[grub_cv_cc_malign_loop=no])
])
if test "x$grub_cv_cc_falign_loop" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
else
elif test "x$grub_cv_cc_malign_loop" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
fi
fi
AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_freg_struct_return=yes],
[grub_cv_cc_freg_struct_return=no])
])
if test "x$grub_cv_cc_freg_struct_return" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
fi
if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
# Some toolchains enable these features by default, but they need
# registers that aren't set up properly in GRUB.
@@ -499,12 +568,10 @@ fi
# these and they just use up vital space. Restore the old compiler
# behaviour.
AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_fno_dwarf2_cfi_asm=yes],
[grub_cv_cc_fno_dwarf2_cfi_asm=no])
CFLAGS="$SAVE_CFLAGS"
])
if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
@@ -513,7 +580,7 @@ fi
if test x"$target_os" = xcygwin; then
AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
CFLAGS="$CFLAGS -fno-reorder-functions"
CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_no_reorder_functions=yes],
[grub_cv_cc_no_reorder_functions=no])
@@ -529,12 +596,10 @@ fi
# these and they just use up vital space. Restore the old compiler
# behaviour.
AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_fno_asynchronous_unwind_tables=yes],
[grub_cv_cc_fno_asynchronous_unwind_tables=no])
CFLAGS="$SAVE_CFLAGS"
])
if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
@@ -543,9 +608,6 @@ fi
grub_apple_target_cc
if test x$grub_cv_apple_target_cc = xyes ; then
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
CFLAGS="$CFLAGS -fnested-functions"
TARGET_APPLE_CC=1
AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
if test "x$TARGET_OBJCONV" = x ; then
@@ -609,12 +671,10 @@ if test x"$platform" = xefi ; then
fi
if test x"$efiemu_excuse" = x ; then
AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_efiemu=yes],
[grub_cv_cc_efiemu=no])
CFLAGS="$SAVED_CFLAGS"
])
if test x$grub_cv_cc_efiemu = xno; then
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
@@ -630,28 +690,10 @@ enable_efiemu=no
fi
AC_SUBST([enable_efiemu])
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
TARGET_MODULE_FORMAT="elf32"
fi
if test "x$target_m64" = x1; then
# Force 64-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
TARGET_MODULE_FORMAT="elf64"
fi
case "$target_os" in
cygwin)
;;
freebsd)
freebsd | kfreebsd*-gnu)
if test x"$target_cpu" = xi386; then
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_fbsd"
fi
@@ -688,8 +730,7 @@ esac
if test "$target_cpu" = x86_64; then
# Use large model to support 4G memory
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
SAVED_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -m64 -mcmodel=large"
CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mcmodel=yes],
[grub_cv_cc_mcmodel=no])
@@ -704,7 +745,7 @@ fi
if test "$target_cpu"-"$platform" = x86_64-efi; then
# EFI writes to stack below %rsp, we must not use the red zone
AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
CFLAGS="$CFLAGS -m64 -mno-red-zone"
CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_no_red_zone=yes],
[grub_cv_cc_no_red_zone=no])
@@ -758,47 +799,6 @@ if test "$target_cpu" = arm; then
fi
fi
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--disable-werror],
[do not use -Werror when building GRUB])])
if test x"$enable_werror" != xno ; then
TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}"
AC_SUBST(GRUB_TARGET_CPU)
AC_SUBST(GRUB_PLATFORM)
AC_SUBST(TARGET_OBJCONV)
AC_SUBST(TARGET_CPP)
AC_SUBST(TARGET_CCAS)
AC_SUBST(TARGET_OBJ2ELF)
AC_SUBST(TARGET_APPLE_CC)
AC_SUBST(TARGET_MODULE_FORMAT)
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_LDFLAGS)
AC_SUBST(TARGET_CPPFLAGS)
AC_SUBST(TARGET_CCASFLAGS)
AC_SUBST(TARGET_IMG_LDSCRIPT)
AC_SUBST(TARGET_IMG_LDFLAGS)
AC_SUBST(TARGET_IMG_CFLAGS)
AC_SUBST(TARGET_IMG_BASE_LDOPT)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(HOST_LDFLAGS)
AC_SUBST(HOST_CPPFLAGS)
AC_SUBST(HOST_CCASFLAGS)
AC_SUBST(BUILD_LIBM)
# Set them to their new values for the tests below.
CC="$TARGET_CC"
if test "x$TARGET_APPLE_CC" = x1 ; then
@@ -807,17 +807,19 @@ else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
fi
CPPFLAGS="$TARGET_CPPFLAGS"
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
LIBS=
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
TARGET_LIBGCC=
else
LIBS=-lgcc
TARGET_LIBGCC=-lgcc
fi
LIBS="$TARGET_LIBGCC"
grub_ASM_USCORE
if test x$grub_cv_asm_uscore = xyes; then
CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
CFLAGS="$TARGET_CFLAGS -Wl,--defsym,_abort=_main"
else
CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
CFLAGS="$TARGET_CFLAGS -Wl,--defsym,abort=main"
fi
# Check for libgcc symbols
@@ -840,7 +842,7 @@ if test "x$target_cpu" = xi386; then
if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
# Check symbols provided by linker script.
CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
fi
grub_CHECK_BSS_START_SYMBOL
grub_CHECK_END_SYMBOL
@@ -868,13 +870,11 @@ fi
fi
AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$TARGET_CFLAGS -Wtrampolines"
CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
int va_arg_func (int fixed, va_list args);]], [[]])],
[grub_cv_cc_wtrampolines=yes],
[grub_cv_cc_wtrampolines=no])
CFLAGS="$SAVED_CFLAGS"
])
if test x"$grub_cv_cc_wtrampolines" = xyes ; then
@@ -1018,6 +1018,13 @@ fi
AC_SUBST([enable_grub_emu_sdl])
AC_SUBST([enable_grub_emu_usb])
AC_SUBST([enable_grub_emu_pci])
else
# Ignore --enable-emu-* if platform is not emu
enable_grub_emu_sdl=no
enable_grub_emu_usb=no
enable_grub_emu_pci=no
fi
AC_ARG_ENABLE([grub-mkfont],
@@ -1313,11 +1320,61 @@ AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(NEED_REGISTER_FRAME_INFO)
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--disable-werror],
[do not use -Werror when building GRUB])])
if test x"$enable_werror" != xno ; then
TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi
if test "x$grub_cv_cc_target_clang" = xno; then
TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
else
TARGET_LDFLAGS_STATIC_LIBGCC=
fi
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}"
AC_SUBST(GRUB_TARGET_CPU)
AC_SUBST(GRUB_PLATFORM)
AC_SUBST(TARGET_OBJCONV)
AC_SUBST(TARGET_LIBGCC)
AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
AC_SUBST(TARGET_CPP)
AC_SUBST(TARGET_CCAS)
AC_SUBST(TARGET_OBJ2ELF)
AC_SUBST(TARGET_APPLE_CC)
AC_SUBST(TARGET_MODULE_FORMAT)
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_LDFLAGS)
AC_SUBST(TARGET_CPPFLAGS)
AC_SUBST(TARGET_CCASFLAGS)
AC_SUBST(TARGET_IMG_LDSCRIPT)
AC_SUBST(TARGET_IMG_LDFLAGS)
AC_SUBST(TARGET_IMG_CFLAGS)
AC_SUBST(TARGET_IMG_BASE_LDOPT)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(HOST_LDFLAGS)
AC_SUBST(HOST_CPPFLAGS)
AC_SUBST(HOST_CCASFLAGS)
AC_SUBST(BUILD_LIBM)
#
# Automake conditionals
#
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
@@ -1332,6 +1389,7 @@ AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu =
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
AM_CONDITIONAL([COND_alpha_srm], [test x$target_cpu = xalpha -a x$platform = xsrm])
AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
+72
View File
@@ -1113,6 +1113,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 +1180,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:
+50 -9
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,9 +1269,13 @@ 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}.
@@ -2447,6 +2471,8 @@ 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
@@ -3088,7 +3114,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 +3123,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 +3177,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
@@ -5369,9 +5411,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
+2 -2
View File
@@ -23,7 +23,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
"i386_multiboot", "i386_ieee1275", "x86_64_efi",
"mips_loongson", "sparc64_ieee1275",
"powerpc_ieee1275", "mips_arc", "ia64_efi",
"mips_qemu_mips", "arm_uboot", "arm_efi" ]
"mips_qemu_mips", "alpha_srm", "arm_uboot", "arm_efi" ]
GROUPS = {}
@@ -59,7 +59,7 @@ GROUPS["videomodules"] = GRUB_PLATFORMS[:];
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
# Similar for terminfo
GROUPS["terminfoinkernel"] = [ "emu", "mips_loongson", "mips_arc", "mips_qemu_mips" ] + GROUPS["ieee1275"] + GROUPS["uboot"];
GROUPS["terminfoinkernel"] = [ "emu", "mips_loongson", "mips_arc", "mips_qemu_mips", "alpha_srm" ] + GROUPS["ieee1275"] + GROUPS["uboot"];
GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
+8
View File
@@ -82,7 +82,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
@@ -140,6 +142,12 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
endif
if COND_alpha_srm
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/alpha/divide.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
endif
if COND_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
endif
+40 -9
View File
@@ -70,6 +70,8 @@ kernel = {
ldadd = '$(LDADD_KERNEL)';
alpha_srm_cflags = '-mcpu=ev4 -mno-fp-regs -ffixed-8';
i386_coreboot_ldflags = '-Wl,-Ttext=0x8200';
i386_multiboot_ldflags = '-Wl,-Ttext=0x8200';
i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000';
@@ -78,6 +80,7 @@ kernel = {
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
alpha_srm_ldflags = '-Wl,-Ttext,0x20000000';
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
@@ -97,6 +100,7 @@ kernel = {
mips_startup = kern/mips/startup.S;
sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
alpha_srm_startup = kern/alpha/srm/startup.S;
arm_uboot_startup = kern/arm/uboot/startup.S;
arm_efi_startup = kern/arm/efi/startup.S;
@@ -125,6 +129,7 @@ kernel = {
noemu_nodist = symlist.c;
mips = kern/generic/rtc_get_time_ms.c;
alpha_srm = kern/generic/rtc_get_time_ms.c;
ieee1275 = disk/ieee1275/ofdisk.c;
ieee1275 = kern/ieee1275/cmain.c;
@@ -237,6 +242,16 @@ kernel = {
arm = kern/arm/cache.c;
arm = kern/arm/misc.S;
alpha_srm = kern/alpha/srm/dispatch.S;
alpha_srm = kern/alpha/dl.c;
alpha_srm = kern/alpha/cache.S;
alpha_srm = kern/alpha/divide.S;
alpha_srm = kern/alpha/srm/pal_init.c;
alpha_srm = kern/alpha/srm/init.c;
alpha_srm = term/alpha/srm/console.c;
alpha_srm = disk/alpha/srm/srmdisk.c;
alpha_srm = commands/boot.c;
emu = disk/host.c;
emu = kern/emu/cache_s.S;
emu = kern/emu/hostdisk.c;
@@ -409,9 +424,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 +438,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 +458,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,7 +466,7 @@ 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;
};
@@ -497,6 +512,7 @@ module = {
module = {
name = emuusb;
common = bus/usb/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
@@ -566,6 +582,7 @@ module = {
common = bus/emu/pci.c;
common = commands/lspci.c;
enable = emu;
condition = COND_GRUB_EMU_PCI;
};
@@ -576,6 +593,11 @@ module = {
enable = mips_arc;
};
module = {
name = check_nt_hiberfil;
common = commands/i386/nthibr.c;
};
library = {
name = libgnulib.a;
common = gnulib/regex.c;
@@ -798,6 +820,8 @@ module = {
i386_qemu = lib/i386/halt.c;
efi = lib/efi/halt.c;
ieee1275 = lib/ieee1275/halt.c;
alpha_srm = lib/alpha/srm/halt.c;
emu = lib/emu/halt.c;
uboot = lib/uboot/halt.c;
};
@@ -815,6 +839,7 @@ module = {
mips_loongson = lib/mips/loongson/reboot.c;
mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
uboot = lib/uboot/reboot.c;
alpha_srm = lib/alpha/srm/reboot.c;
common = commands/reboot.c;
};
@@ -1497,6 +1522,7 @@ module = {
powerpc_ieee1275 = lib/ieee1275/cmos.c;
mips_arc = lib/arc/datetime.c;
alpha_srm = lib/alpha/srm/datetime.c;
enable = noemu;
};
@@ -1510,7 +1536,7 @@ module = {
extra_dist = lib/powerpc/setjmp.S;
extra_dist = lib/ia64/setjmp.S;
extra_dist = lib/ia64/longjmp.S;
extra_dist = lib/arm/setjmp.S;
extra_dist = lib/alpha/setjmp.S;
};
module = {
@@ -1848,6 +1874,11 @@ module = {
common = tests/setjmp_test.c;
};
module = {
name = div_test;
common = tests/div_test.c;
};
module = {
name = videotest_checksum;
common = tests/videotest_checksum.c;
+7 -8
View File
@@ -1677,7 +1677,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 +1699,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 +1724,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 +1752,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 +1887,7 @@ grub_ehci_restore_hw (void)
}
}
return GRUB_USB_ERR_NONE;
return GRUB_ERR_NONE;
}
static grub_err_t
@@ -1911,7 +1910,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 = {
+6 -6
View File
@@ -1216,7 +1216,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 +1236,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 +1257,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 +1275,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 +1287,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
+4 -2
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,
+1 -1
View File
@@ -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;
}
+6 -12
View File
@@ -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
@@ -715,7 +710,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 +728,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 +741,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 +776,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 +786,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
+2 -2
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");
+31 -7
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
+79
View File
@@ -0,0 +1,79 @@
/* nthibr.c - tests whether an MS Windows system partition is hibernated */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 Peter Lustig
* 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/mm.h>
#include <grub/file.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/err.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t
grub_cmd_nthibr (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
grub_uint8_t hibr_file_magic[4];
grub_file_t hibr_file = 0;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
hibr_file = grub_file_open (args[0]);
if (!hibr_file)
return grub_errno;
/* Try to read magic number of 'hiberfil.sys' */
if (grub_file_read (hibr_file, hibr_file_magic,
sizeof (hibr_file_magic))
!= (grub_ssize_t) sizeof (hibr_file_magic))
{
if (!grub_errno)
grub_error (GRUB_ERR_TEST_FAILURE, "false");
goto exit;
}
if (!(grub_memcmp ("hibr", hibr_file_magic, sizeof (hibr_file_magic)) == 0
|| grub_memcmp ("HIBR", hibr_file_magic, sizeof (hibr_file_magic)) == 0))
grub_error (GRUB_ERR_TEST_FAILURE, "false");
exit:
grub_file_close (hibr_file);
return grub_errno;
}
static grub_command_t cmd;
GRUB_MOD_INIT (check_nt_hiberfil)
{
cmd = grub_register_command ("check_nt_hiberfil", grub_cmd_nthibr,
N_("FILE"),
N_("Test whether a hiberfil.sys is "
"in hibernated state."));
}
GRUB_MOD_FINI (check_nt_hiberfil)
{
grub_unregister_command (cmd);
}
+1 -3
View File
@@ -358,7 +358,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;
@@ -546,8 +546,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)
+32 -7
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++;
+1
View File
@@ -70,6 +70,7 @@ get_uuid (const char *name, char **uuid, int getnative)
case GRUB_DISK_DEVICE_ARCDISK_ID:
case GRUB_DISK_DEVICE_HOSTDISK_ID:
case GRUB_DISK_DEVICE_UBOOTDISK_ID:
case GRUB_DISK_DEVICE_SRMDISK_ID:
break;
/* Native disks. */
+5 -2
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 ();
}
+67 -16
View File
@@ -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
@@ -351,6 +366,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,
@@ -532,17 +592,11 @@ grub_verify_signature_real (char *buf, grub_size_t size,
/* TRANSLATORS: %08x is 32-bit key id. */
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
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 (gcry_mpi_scan (&hmpi, GCRYMPI_FMT_USG, hval,
nbits / 8 < (unsigned) hash->mdlen ? nbits / 8
: (unsigned) hash->mdlen, 0))
if (pkalgos[pk].pad (&hmpi, hval, hash, sk))
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)
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), pkalgos[pk].module);
if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0))
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
}
@@ -803,9 +857,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;
+6
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;
+240
View File
@@ -0,0 +1,240 @@
/* ofdisk.c - Open Firmware disk access. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2006,2007,2008,2009,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/misc.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/alpha/srm/srm.h>
static grub_srm_fileno_t last_handle = 0;
static char *last_path = NULL;
static int lnum = 0;
struct srmdisk_hash_ent
{
char *devpath;
int num;
struct srmdisk_hash_ent *next;
};
#define SRMDISK_HASH_SZ 8
static struct srmdisk_hash_ent *srmdisk_hash[SRMDISK_HASH_SZ];
static int
srmdisk_hash_fn (const char *devpath)
{
int hash = 0;
while (*devpath)
hash ^= *devpath++;
return (hash & (SRMDISK_HASH_SZ - 1));
}
static struct srmdisk_hash_ent *
srmdisk_hash_find (const char *devpath)
{
struct srmdisk_hash_ent *p = srmdisk_hash[srmdisk_hash_fn (devpath)];
while (p)
{
if (!grub_strcmp (p->devpath, devpath))
break;
p = p->next;
}
return p;
}
static struct srmdisk_hash_ent *
srmdisk_hash_add (char *devpath)
{
struct srmdisk_hash_ent *p;
struct srmdisk_hash_ent **head = &srmdisk_hash[srmdisk_hash_fn(devpath)];
p = grub_malloc (sizeof (*p));
if (!p)
return NULL;
p->devpath = devpath;
p->next = *head;
p->num = lnum++;
*head = p;
return p;
}
static int
grub_srmdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
grub_disk_pull_t pull)
{
(void) hook;
(void) pull;
(void) hook_data;
return 0;
}
static grub_err_t
reopen (const char *name)
{
grub_uint64_t r;
if (last_path && grub_strcmp (last_path, name) == 0)
{
grub_dprintf ("srmdisk", "using already opened %s\n", name);
return GRUB_ERR_NONE;
}
if (last_path)
{
grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_CLOSE, last_handle);
grub_free (last_path);
last_path = NULL;
last_handle = 0;
}
grub_dprintf ("srmdisk", "opening %s\n", name);
r = grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_OPEN, name, grub_strlen (name));
grub_printf ("<%lx>", r);
while (1);
if (r & (1ULL << 63))
{
grub_dprintf ("srmdisk", "couldn't open %s\n", name);
return grub_error (GRUB_ERR_IO, "couldn't open %s", name);
}
last_path = grub_strdup (name);
if (!last_path)
return grub_errno;
last_handle = r & 0xffffffff;
grub_dprintf ("srmdisk", "opened %s\n", name);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_srmdisk_open (const char *name, grub_disk_t disk)
{
char *fullname;
grub_err_t err;
struct srmdisk_hash_ent *hash;
if (grub_memcmp (name, "srm/", 4) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not srm device");
fullname = grub_strdup (name + 4);
if (!fullname)
return grub_errno;
disk->data = fullname;
grub_dprintf ("srmdisk", "opening %s\n", fullname);
hash = srmdisk_hash_find (fullname);
if (!hash)
hash = srmdisk_hash_add (fullname);
if (!hash)
return grub_errno;
err = reopen (fullname);
if (err)
return err;
{
grub_uint64_t res = 0;
int i;
/* FIXME: findout the block size. */
for (i = 31; i >= 0; i--)
{
char buf[512];
grub_dprintf ("srmdisk",
"seek to 0x%" PRIxGRUB_UINT64_T "\n",
res | (1UL << i));
if (grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_READ, last_handle, 512,
buf, res | (1ULL << i)) & (1ULL << 63))
continue;
res |= (1ULL << i);
}
grub_dprintf ("srmdisk",
"determined disk size 0x%" PRIxGRUB_UINT64_T "\n", res);
disk->total_sectors = res;
}
disk->id = hash->num;
return GRUB_ERR_NONE;
}
static void
grub_srmdisk_close (grub_disk_t disk)
{
grub_free (disk->data);
}
static grub_err_t
grub_srmdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_err_t err;
err = reopen (disk->data);
if (err)
return err;
/* FIXME: handle incomplete read. */
if (grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_READ, last_handle,
size << 9,
buf, sector) & (1ULL << 63))
return grub_error (GRUB_ERR_READ_ERROR, "read failed");
return GRUB_ERR_NONE;
}
static grub_err_t
grub_srmdisk_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)))
{
return GRUB_ERR_NOT_IMPLEMENTED_YET;
}
static struct grub_disk_dev grub_srmdisk_dev =
{
.name = "srmdisk",
.id = GRUB_DISK_DEVICE_SRMDISK_ID,
.iterate = grub_srmdisk_iterate,
.open = grub_srmdisk_open,
.close = grub_srmdisk_close,
.read = grub_srmdisk_read,
.write = grub_srmdisk_write,
.next = 0
};
void
grub_srmdisk_init (void)
{
grub_disk_dev_register (&grub_srmdisk_dev);
}
void
grub_srmdisk_fini (void)
{
if (last_path)
{
grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_CLOSE, last_handle);
grub_free (last_path);
last_path = NULL;
last_handle = 0;
}
grub_disk_dev_unregister (&grub_srmdisk_dev);
}
+1
View File
@@ -0,0 +1 @@
SCSI 0 1004 0 2 200 0 0
+13 -9
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);
+1
View File
@@ -517,6 +517,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;
+1
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;
}
+7 -20
View File
@@ -518,6 +518,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 +544,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
+1 -13
View File
@@ -153,24 +153,12 @@ geli_rekey (struct grub_cryptodisk *dev, grub_uint64_t zoneno)
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)
+3 -4
View File
@@ -424,6 +424,9 @@ 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;
disk->data = data;
return GRUB_ERR_NONE;
@@ -548,10 +551,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;
}
+4
View File
@@ -167,6 +167,10 @@ grub_loopback_open (const char *name, grub_disk_t disk)
/ GRUB_DISK_SECTOR_SIZE);
else
disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
/* Avoid reading more than 512M. */
disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
- GRUB_DISK_CACHE_BITS);
disk->id = (unsigned long) dev;
disk->data = dev;
+1
View File
@@ -46,6 +46,7 @@ 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->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
disk->id = (unsigned long) "mdsk";
return GRUB_ERR_NONE;
+41 -60
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;
+10 -11
View File
@@ -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");
@@ -571,8 +567,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;
}
+4 -2
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);
+1
View File
@@ -289,6 +289,7 @@ 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->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
disk->id = (unsigned long) "cbfs";
return GRUB_ERR_NONE;
+4 -4
View File
@@ -670,10 +670,10 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
/* If the filesize of the symlink is bigger than
60 the symlink is stored in a separate block,
otherwise it is stored in the inode. */
if (grub_le_to_cpu32 (diro->inode.size) <= 60)
grub_strncpy (symlink,
diro->inode.symlink,
grub_le_to_cpu32 (diro->inode.size));
if (grub_le_to_cpu32 (diro->inode.size) <= sizeof (diro->inode.symlink))
grub_memcpy (symlink,
diro->inode.symlink,
grub_le_to_cpu32 (diro->inode.size));
else
{
grub_ext2_read_file (diro, 0, 0, 0,
+3
View File
@@ -133,6 +133,7 @@ find_file (const char *currpath, grub_fshelp_node_t currroot,
if (ctx->type == GRUB_FSHELP_SYMLINK)
{
char *symlink;
const char *next;
/* Test if the symlink does not loop. */
if (++ctx->symlinknest == 8)
@@ -164,8 +165,10 @@ find_file (const char *currpath, grub_fshelp_node_t currroot,
}
/* Lookup the node the symlink points to. */
next = ctx->next;
find_file (symlink, ctx->oldnode, &ctx->currnode,
iterate_dir, read_symlink, ctx);
ctx->next = next;
ctx->type = ctx->foundtype;
grub_free (symlink);
+2
View File
@@ -888,6 +888,8 @@ grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
struct grub_hfsplus_data *data =
(struct grub_hfsplus_data *) file->data;
data->opened_file.file = file;
if (grub_hfsplus_read_compressed && data->opened_file.compressed)
return grub_hfsplus_read_compressed (&data->opened_file,
file->offset, len, buf);
+5
View File
@@ -23,6 +23,7 @@
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/deflate.h>
#include <grub/file.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -121,6 +122,8 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
if (node->compressed == 1)
{
grub_memcpy (buf, node->cbuf + pos, len);
if (grub_file_progress_hook && node->file)
grub_file_progress_hook (0, 0, len, node->file);
return len;
}
@@ -162,6 +165,8 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
}
grub_memcpy (buf, node->cbuf + (pos % HFSPLUS_COMPRESS_BLOCK_SIZE),
curlen);
if (grub_file_progress_hook && node->file)
grub_file_progress_hook (0, 0, curlen, node->file);
buf += curlen;
pos += curlen;
len -= curlen;
+1 -1
View File
@@ -723,7 +723,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino)
if (!symlink)
return grub_errno;
if (size <= sizeof (data->currinode.symlink.path))
grub_strncpy (symlink, (char *) (data->currinode.symlink.path), size);
grub_memcpy (symlink, (char *) (data->currinode.symlink.path), size);
else if (grub_jfs_read_file (data, 0, 0, 0, size, symlink) < 0)
{
grub_free (symlink);
+3
View File
@@ -378,6 +378,9 @@ read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest,
ctx->comp.log_spc = at->mft->data->log_spc;
ctx->comp.disk = at->mft->data->disk;
if (read_hook == grub_file_progress_hook)
ctx->file = read_hook_data;
if (pa[8] == 0)
{
if (ofs + len > u32at (pa, 0x10))
+29
View File
@@ -226,6 +226,9 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
{
grub_memset (buf, 0, nn * GRUB_NTFS_COM_LEN);
buf += nn * GRUB_NTFS_COM_LEN;
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0, nn * GRUB_NTFS_COM_LEN,
ctx->file);
}
}
else
@@ -236,6 +239,9 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
return grub_errno;
if (buf)
buf += GRUB_NTFS_COM_LEN;
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0, GRUB_NTFS_COM_LEN,
ctx->file);
nn--;
}
}
@@ -262,6 +268,11 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
ctx->target_vcn)) << ctx->comp.log_spc, 0,
tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
return grub_errno;
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0,
tt << (ctx->comp.log_spc
+ GRUB_NTFS_BLK_SHR),
ctx->file);
buf += tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
}
nn -= tt;
@@ -280,6 +291,11 @@ read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
return grub_errno;
buf += nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0,
nn << (ctx->comp.log_spc
+ GRUB_NTFS_BLK_SHR),
ctx->file);
}
ctx->target_vcn += nn;
}
@@ -306,6 +322,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
n = len;
grub_memcpy (dest, ctx->attr->sbuf + ofs - ctx->attr->save_pos, n);
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0, n, ctx->file);
if (n == len)
return 0;
@@ -351,6 +369,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (ofs % GRUB_NTFS_COM_LEN)
{
grub_uint32_t t, n, o;
void *file = ctx->file;
ctx->file = 0;
t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
if (read_block (ctx, ctx->attr->sbuf, 1))
@@ -359,6 +380,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
goto quit;
}
ctx->file = file;
ctx->attr->save_pos = t;
o = ofs % GRUB_NTFS_COM_LEN;
@@ -366,6 +389,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (n > len)
n = len;
grub_memcpy (dest, &ctx->attr->sbuf[o], n);
if (grub_file_progress_hook && ctx->file)
grub_file_progress_hook (0, 0, n, ctx->file);
if (n == len)
goto quit;
dest += n;
@@ -383,7 +408,9 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
if (len)
{
grub_uint32_t t;
void *file = ctx->file;
ctx->file = 0;
t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
if (read_block (ctx, ctx->attr->sbuf, 1))
{
@@ -394,6 +421,8 @@ ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
ctx->attr->save_pos = t;
grub_memcpy (dest, ctx->attr->sbuf, len);
if (grub_file_progress_hook && file)
grub_file_progress_hook (0, 0, len, file);
}
quit:
+1 -1
View File
@@ -781,7 +781,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
= grub_le_to_cpu16 (directory_header->state);
grub_fshelp_node_t entry_item;
struct grub_reiserfs_key entry_key;
enum grub_reiserfs_item_type entry_type;
enum grub_fshelp_filetype entry_type;
char *entry_name;
if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK))
+9 -2
View File
@@ -297,10 +297,17 @@ static grub_ssize_t
grub_cpio_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_archelp_data *data;
grub_ssize_t ret;
data = file->data;
return (grub_disk_read (data->disk, 0, data->dofs + file->offset,
len, buf)) ? -1 : (grub_ssize_t) len;
data->disk->read_hook = file->read_hook;
data->disk->read_hook_data = file->read_hook_data;
ret = (grub_disk_read (data->disk, 0, data->dofs + file->offset,
len, buf)) ? -1 : (grub_ssize_t) len;
data->disk->read_hook = 0;
return ret;
}
static grub_err_t
+15 -16
View File
@@ -877,18 +877,13 @@ nvlist_next_nvpair (const char *nvl, const char *nvpair)
* containing the name of nvpair is saved in buf.
*/
static int
nvpair_name (const char *nvp, char **buf, int *buflen)
nvpair_name (const char *nvp, char **buf, grub_size_t *buflen)
{
int len;
/* skip over encode/decode size */
nvp += 4 * 2;
len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
nvp=nvp+4;
*buf=(char*)nvp;
*buflen=len;
*buf = (char *) (nvp + 4);
*buflen = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
return 0;
}
@@ -1113,15 +1108,15 @@ check_pool_label (struct grub_zfs_data *data,
const char *nvp=NULL;
char name[MAX_SUPPORTED_FEATURE_STRLEN + 1];
char *nameptr;
int namelen;
grub_size_t namelen;
while ((nvp = nvlist_next_nvpair(features, nvp)) != NULL)
{
nvpair_name(nvp, &nameptr,&namelen);
nvpair_name (nvp, &nameptr, &namelen);
if(namelen > MAX_SUPPORTED_FEATURE_STRLEN)
namelen = MAX_SUPPORTED_FEATURE_STRLEN;
grub_strncpy(name,nameptr,namelen);
name[namelen]=0;
grub_dprintf("zfs","namelen=%u str=%s\n",namelen,name);
grub_memcpy (name, nameptr, namelen);
name[namelen] = '\0';
grub_dprintf("zfs","str=%s\n",name);
if (check_feature(name,1, NULL) != 0)
{
grub_dprintf("zfs","feature missing in check_pool_label:%s\n",name);
@@ -3308,7 +3303,8 @@ nvlist_find_value (const char *nvlist_in, const char *name,
int valtype, char **val,
grub_size_t *size_out, grub_size_t *nelm_out)
{
int name_len, type ;
grub_size_t nvp_name_len, name_len = grub_strlen(name);
int type;
const char *nvpair=NULL,*nvlist=nvlist_in;
char *nvp_name;
@@ -3329,9 +3325,12 @@ nvlist_find_value (const char *nvlist_in, const char *name,
*/
while ((nvpair=nvlist_next_nvpair(nvlist,nvpair)))
{
nvpair_name(nvpair,&nvp_name,&name_len);
nvpair_name(nvpair,&nvp_name, &nvp_name_len);
type = nvpair_type(nvpair);
if ((grub_strncmp (nvp_name, name, grub_strlen(name)) == 0) && type == valtype)
if (type == valtype
&& (nvp_name_len == name_len
|| (nvp_name_len > name_len && nvp_name[name_len] == '\0'))
&& grub_memcmp (nvp_name, name, name_len) == 0)
{
return nvpair_value(nvpair,val,size_out,nelm_out);
}
+9 -8
View File
@@ -143,7 +143,7 @@ grub_ccm_decrypt (grub_crypto_cipher_handle_t cipher,
return err;
if (mac_out)
grub_crypto_xor (mac_out, mac, mul, m);
return GRUB_ERR_NONE;
return GPG_ERR_NO_ERROR;
}
static void
@@ -244,7 +244,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher,
if (mac_out)
grub_crypto_xor (mac_out, mac, mac_xor, m);
return GRUB_ERR_NONE;
return GPG_ERR_NO_ERROR;
}
@@ -258,13 +258,14 @@ algo_decrypt (grub_crypto_cipher_handle_t cipher, grub_uint64_t algo,
switch (algo)
{
case 0:
return grub_ccm_decrypt (cipher, out, in, psize, mac_out, nonce, l, m);
return grub_ccm_decrypt (cipher, out, in, psize,
mac_out, nonce, l, m);
case 1:
return grub_gcm_decrypt (cipher, out, in, psize, mac_out, nonce,
return grub_gcm_decrypt (cipher, out, in, psize,
mac_out, nonce,
15 - l, m);
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "algorithm %lld is not supported yet",
(long long) algo);
return GPG_ERR_CIPHER_ALGO;
}
}
@@ -279,7 +280,7 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher,
grub_uint32_t mac[4];
unsigned i;
grub_uint32_t sw[4];
grub_err_t err;
gcry_err_code_t err;
grub_memcpy (sw, nonce, 16);
if (endian != GRUB_ZFS_BIG_ENDIAN)
@@ -295,7 +296,7 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher,
size, mac,
sw + 1, 3, 12);
if (err)
return err;
return grub_crypto_gcry_error (err);
for (i = 0; i < 3; i++)
if (grub_zfs_to_cpu32 (expected_mac[i], endian)
+1 -1
View File
@@ -201,7 +201,7 @@ grub_gdb_hex2int (char **ptr, grub_uint64_t *int_value)
}
/* This function does all command procesing for interfacing to gdb. */
void
void __attribute__ ((regparm(3)))
grub_gdb_trap (int trap_no)
{
unsigned int sig_no;
+6 -2
View File
@@ -34,8 +34,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html .
*/
static struct grub_gettext_context main_context, secondary_context;
static const char *(*grub_gettext_original) (const char *s);
struct grub_gettext_msg
@@ -69,6 +67,8 @@ struct grub_gettext_context
struct grub_gettext_msg *grub_gettext_msg_list;
};
static struct grub_gettext_context main_context, secondary_context;
#define MO_MAGIC_NUMBER 0x950412de
static grub_err_t
@@ -423,6 +423,10 @@ grub_gettext_init_ext (struct grub_gettext_context *ctx,
grub_free (lang);
}
if (locale[0] == 'e' && locale[1] == 'n'
&& (locale[2] == '\0' || locale[2] == '_'))
grub_errno = err = GRUB_ERR_NONE;
return err;
}
+16
View File
@@ -234,14 +234,30 @@ static void
box_paint (void *vself, const grub_video_rect_t *region)
{
grub_gui_box_t self = vself;
struct component_node *cur;
grub_video_rect_t vpsave;
grub_video_area_status_t box_area_status;
grub_video_get_area_status (&box_area_status);
grub_gui_set_viewport (&self->bounds, &vpsave);
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
{
grub_gui_component_t comp = cur->component;
grub_video_rect_t r;
comp->ops->get_bounds(comp, &r);
if (!grub_video_have_common_points (region, &r))
continue;
/* Paint the child. */
if (box_area_status == GRUB_VIDEO_AREA_ENABLED
&& grub_video_bounds_inside_region (&r, region))
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
comp->ops->paint (comp, region);
if (box_area_status == GRUB_VIDEO_AREA_ENABLED)
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
}
grub_gui_restore_viewport (&vpsave);
}
+13 -2
View File
@@ -80,9 +80,13 @@ static void
canvas_paint (void *vself, const grub_video_rect_t *region)
{
grub_gui_canvas_t self = vself;
struct component_node *cur;
grub_video_rect_t vpsave;
grub_video_area_status_t canvas_area_status;
grub_video_get_area_status (&canvas_area_status);
grub_gui_set_viewport (&self->bounds, &vpsave);
for (cur = self->components.next; cur; cur = cur->next)
{
@@ -135,9 +139,16 @@ canvas_paint (void *vself, const grub_video_rect_t *region)
r.height = h;
comp->ops->set_bounds (comp, &r);
if (!grub_video_have_common_points (region, &r))
continue;
/* Paint the child. */
if (grub_video_have_common_points (region, &r))
comp->ops->paint (comp, region);
if (canvas_area_status == GRUB_VIDEO_AREA_ENABLED
&& grub_video_bounds_inside_region (&r, region))
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
comp->ops->paint (comp, region);
if (canvas_area_status == GRUB_VIDEO_AREA_ENABLED)
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
}
grub_gui_restore_viewport (&vpsave);
}
+19 -12
View File
@@ -37,7 +37,7 @@ struct grub_gui_circular_progress
int start;
int end;
int value;
int num_ticks;
unsigned num_ticks;
int start_angle;
int ticks_disappear;
char *theme_dir;
@@ -139,15 +139,16 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
center_width, center_height);
int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
int nticks;
int tick_begin;
int tick_end;
if (self->end == self->start)
unsigned nticks;
unsigned tick_begin;
unsigned tick_end;
if (self->end <= self->start
|| self->value <= self->start)
nticks = 0;
else
nticks = (self->num_ticks
* (self->value - self->start)
/ (self->end - self->start));
nticks = ((unsigned) (self->num_ticks
* (self->value - self->start)))
/ ((unsigned) (self->end - self->start));
/* Do ticks appear or disappear as the value approached the end? */
if (self->ticks_disappear)
{
@@ -160,7 +161,7 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
tick_end = nticks;
}
int i;
unsigned i;
for (i = tick_begin; i < tick_end; i++)
{
int x;
@@ -168,7 +169,8 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
int angle;
/* Calculate the location of the tick. */
angle = self->start_angle + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
angle = self->start_angle
+ i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
@@ -238,7 +240,12 @@ parse_angle (const char *value)
/* Unicode symbol of degrees (a circle, U+b0). Put here in UTF-8 to
avoid potential problem with text file reesncoding */
|| grub_strcmp (ptr, "\xc2\xb0") == 0)
angle = (angle * 64 + 45) / 90;
{
if (angle >= 0)
angle = ((unsigned) angle * 64 + 45) / 90;
else
angle = -((unsigned) -angle * 64 + 45) / 90;
}
return angle;
}
@@ -248,7 +255,7 @@ circprog_set_property (void *vself, const char *name, const char *value)
circular_progress_t self = vself;
if (grub_strcmp (name, "num_ticks") == 0)
{
self->num_ticks = grub_strtol (value, 0, 10);
self->num_ticks = grub_strtoul (value, 0, 10);
}
else if (grub_strcmp (name, "start_angle") == 0)
{
+26 -7
View File
@@ -251,18 +251,24 @@ draw_scrollbar (list_impl_t self,
int value, int extent, int min, int max,
int scrollbar_width, int scrollbar_height)
{
unsigned thumby, thumbheight;
grub_gfxmenu_box_t frame = self->scrollbar_frame;
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
int frame_vertical_pad = (frame->get_top_pad (frame)
+ frame->get_bottom_pad (frame));
int frame_horizontal_pad = (frame->get_left_pad (frame)
+ frame->get_right_pad (frame));
int thumb_vertical_pad = (thumb->get_top_pad (thumb)
+ thumb->get_bottom_pad (thumb));
unsigned thumb_vertical_pad = (thumb->get_top_pad (thumb)
+ thumb->get_bottom_pad (thumb));
int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
+ thumb->get_right_pad (thumb));
int tracktop = frame->get_top_pad (frame);
int tracklen = scrollbar_height - frame_vertical_pad;
unsigned tracklen;
if (scrollbar_height <= frame_vertical_pad)
tracklen = 0;
else
tracklen = scrollbar_height - frame_vertical_pad;
frame->set_content_size (frame,
scrollbar_width - frame_horizontal_pad,
tracklen);
@@ -271,15 +277,28 @@ draw_scrollbar (list_impl_t self,
tracklen += thumb_vertical_pad;
tracktop -= thumb->get_top_pad (thumb);
}
int thumby = tracktop + tracklen * (value - min) / (max - min);
int thumbheight = tracklen * extent / (max - min) + 1;
if (value <= min || max <= min)
thumby = 0;
else
thumby = ((unsigned) tracklen * (value - min))
/ ((unsigned) (max - min));
if (max <= min)
thumbheight = 1;
else
thumbheight = ((unsigned) (tracklen * extent)
/ ((unsigned) (max - min))) + 1;
/* Rare occasion: too many entries or too low height. */
if (thumbheight < thumb_vertical_pad)
{
thumbheight = thumb_vertical_pad;
thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min)
/ (max - extent));
if (value <= min || max <= extent
|| tracklen <= thumb_vertical_pad)
thumby = 0;
else
thumby = ((unsigned) ((tracklen - thumb_vertical_pad) * (value - min))
/ ((unsigned)(max - extent)));
}
thumby += tracktop;
int thumbx = frame->get_left_pad (frame);
int thumbwidth = scrollbar_width - frame_horizontal_pad;
if (!self->scrollbar_thumb_overlay)
+6 -2
View File
@@ -169,8 +169,12 @@ draw_pixmap_bar (grub_gui_progress_bar_t self)
else
hlheight -= hl_v_pad;
barwidth = (tracklen * (self->value - self->start)
/ (self->end - self->start));
if (self->value <= self->start
|| self->end <= self->start)
barwidth = 0;
else
barwidth = ((unsigned) (tracklen * (self->value - self->start))
/ ((unsigned) (self->end - self->start)));
if (barwidth >= hl_h_pad)
{
+7 -11
View File
@@ -137,23 +137,19 @@ static struct grub_video_bitmap *
try_loading_icon (grub_gfxmenu_icon_manager_t mgr,
const char *dir, const char *class_name)
{
char *path;
int l;
char *path, *ptr;
path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name)
+ grub_strlen (icon_extension) + 3);
if (! path)
return 0;
grub_strcpy (path, dir);
l = grub_strlen (path);
if (path[l-1] != '/')
{
path[l] = '/';
path[l+1] = 0;
}
grub_strcat (path, class_name);
grub_strcat (path, icon_extension);
ptr = grub_stpcpy (path, dir);
if (path == ptr || ptr[-1] != '/')
*ptr++ = '/';
ptr = grub_stpcpy (ptr, class_name);
ptr = grub_stpcpy (ptr, icon_extension);
*ptr = '\0';
struct grub_video_bitmap *raw_bitmap;
grub_video_bitmap_load (&raw_bitmap, path);
+18 -1
View File
@@ -213,6 +213,7 @@ redraw_timeouts (struct grub_gfxmenu_view *view)
{
grub_video_rect_t bounds;
cur->self->ops->get_bounds (cur->self, &bounds);
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
grub_gfxmenu_view_redraw (view, &bounds);
}
}
@@ -321,6 +322,11 @@ grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
grub_gfxterm_schedule_repaint ();
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
grub_video_area_status_t area_status;
grub_video_get_area_status (&area_status);
if (area_status == GRUB_VIDEO_AREA_ENABLED)
grub_video_set_region (region->x, region->y,
region->width, region->height);
redraw_background (view, region);
if (view->canvas)
@@ -328,6 +334,9 @@ grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
draw_title (view);
if (grub_video_have_common_points (&view->progress_message_frame, region))
draw_message (view);
if (area_status == GRUB_VIDEO_AREA_ENABLED)
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
}
void
@@ -350,10 +359,15 @@ grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
refresh_menu_components (view);
update_menu_components (view);
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
grub_gfxmenu_view_redraw (view, &view->screen);
grub_video_swap_buffers ();
if (view->double_repaint)
grub_gfxmenu_view_redraw (view, &view->screen);
{
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
grub_gfxmenu_view_redraw (view, &view->screen);
}
}
static void
@@ -367,6 +381,7 @@ redraw_menu_visit (grub_gui_component_t component,
grub_video_rect_t bounds;
component->ops->get_bounds (component, &bounds);
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
grub_gfxmenu_view_redraw (view, &bounds);
}
}
@@ -404,6 +419,8 @@ grub_gfxmenu_draw_terminal_box (void)
if (!term_box)
return;
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
term_box->set_content_size (term_box, term_view->terminal_rect.width,
term_view->terminal_rect.height);
+3 -3
View File
@@ -363,8 +363,6 @@ static ush mask_bits[] =
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
#define NEEDBITS(n) do {while(k<(n)){b|=((ulg)get_byte(gzio))<<k;k+=8;}} while (0)
#define DUMPBITS(n) do {b>>=(n);k-=(n);} while (0)
@@ -544,7 +542,7 @@ huft_build (unsigned *b, /* code lengths in bits (all assumed <= BMAX) */
z = 1 << j; /* table entries for j-bit table */
/* allocate and link in new table */
q = (struct huft *) grub_malloc ((z + 1) * sizeof (struct huft));
q = (struct huft *) grub_zalloc ((z + 1) * sizeof (struct huft));
if (! q)
{
if (h)
@@ -1118,6 +1116,8 @@ initialize_tables (grub_gzio_t gzio)
/* Reset memory allocation stuff. */
huft_free (gzio->tl);
huft_free (gzio->td);
gzio->tl = NULL;
gzio->td = NULL;
}
+2 -6
View File
@@ -380,12 +380,8 @@ test_header (grub_file_t file)
sizeof (checksum))
goto CORRUPTED;
if (hcheck)
{
checksum = checksum;
if (grub_memcmp (&checksum, hcheck->read(context), sizeof(checksum)) != 0)
goto CORRUPTED;
}
if (hcheck && grub_memcmp (&checksum, hcheck->read(context), sizeof(checksum)) != 0)
goto CORRUPTED;
lzopio->start_block_off = grub_file_tell (lzopio->file);
+9
View File
@@ -0,0 +1,9 @@
#include <grub/symbol.h>
.set noreorder
.set nomacro
FUNCTION (grub_arch_sync_all_caches)
call_pal 134
ret $31,($26)
+114
View File
@@ -0,0 +1,114 @@
#include <grub/symbol.h>
.set noat
.macro PREAMBLE
subq $30, 31 * 8, $30
stq $0, (0 * 8)($30)
stq $1, (1 * 8)($30)
stq $2, (2 * 8)($30)
stq $3, (3 * 8)($30)
stq $4, (4 * 8)($30)
stq $5, (5 * 8)($30)
stq $6, (6 * 8)($30)
stq $7, (7 * 8)($30)
stq $8, (8 * 8)($30)
stq $9, (9 * 8)($30)
stq $10, (10 * 8)($30)
stq $11, (11 * 8)($30)
stq $12, (12 * 8)($30)
stq $13, (13 * 8)($30)
stq $14, (14 * 8)($30)
stq $15, (15 * 8)($30)
stq $16, (16 * 8)($30)
stq $17, (17 * 8)($30)
stq $18, (18 * 8)($30)
stq $19, (19 * 8)($30)
stq $20, (20 * 8)($30)
stq $21, (21 * 8)($30)
stq $22, (22 * 8)($30)
stq $23, (23 * 8)($30)
stq $24, (24 * 8)($30)
stq $25, (25 * 8)($30)
stq $26, (26 * 8)($30)
stq $28, (28 * 8)($30)
stq $29, (29 * 8)($30)
addq $30, (30 * 8), $18
/* load GP. */
br $27, 1f
1: ldgp $29, 0($27)
.endm
.macro POSTAMBLE
ldq $0, (0 * 8)($30)
ldq $1, (1 * 8)($30)
ldq $2, (2 * 8)($30)
ldq $3, (3 * 8)($30)
ldq $4, (4 * 8)($30)
ldq $5, (5 * 8)($30)
ldq $6, (6 * 8)($30)
ldq $7, (7 * 8)($30)
ldq $8, (8 * 8)($30)
ldq $9, (9 * 8)($30)
ldq $10, (10 * 8)($30)
ldq $11, (11 * 8)($30)
ldq $12, (12 * 8)($30)
ldq $13, (13 * 8)($30)
ldq $14, (14 * 8)($30)
ldq $15, (15 * 8)($30)
ldq $16, (16 * 8)($30)
ldq $17, (17 * 8)($30)
ldq $18, (18 * 8)($30)
ldq $19, (19 * 8)($30)
ldq $20, (20 * 8)($30)
ldq $21, (21 * 8)($30)
ldq $22, (22 * 8)($30)
ldq $23, (23 * 8)($30)
ldq $24, (24 * 8)($30)
ldq $25, (25 * 8)($30)
ldq $26, (26 * 8)($30)
ldq $28, (28 * 8)($30)
ldq $29, (29 * 8)($30)
addq $30, 31 * 8, $30
ret $31,($23)
.endm
FUNCTION (__divqu)
PREAMBLE
mov $24, $16
mov $25, $17
jsr $26, EXT_C (grub_divmod64)
mov $0, $27
POSTAMBLE
FUNCTION (__remqu)
PREAMBLE
mov $24, $16
mov $25, $17
jsr $26, EXT_C (grub_divmod64)
ldq $27, (30 * 8)($30)
POSTAMBLE
FUNCTION (__divlu)
PREAMBLE
sll $24, 32, $16
sra $16, 32, $16
sll $25, 32, $17
sra $17, 32, $17
mov $24, $16
mov $25, $17
jsr $26, EXT_C (grub_divmod64)
mov $0, $27
POSTAMBLE
FUNCTION (__remlu)
PREAMBLE
sll $24, 32, $16
sra $16, 32, $16
sll $25, 32, $17
sra $17, 32, $17
jsr $26, EXT_C (grub_divmod64)
ldq $27, (30 * 8)($30)
POSTAMBLE
+257
View File
@@ -0,0 +1,257 @@
/*
* 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/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/cpu/types.h>
#include <grub/mm.h>
#pragma GCC diagnostic ignored "-Wcast-align"
void
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
{
const Elf64_Ehdr *e = ehdr;
grub_size_t cntt = 0, cntg = 0;;
const Elf64_Shdr *s;
unsigned i;
/* Find a symbol table. */
for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
i < grub_le_to_cpu16 (e->e_shnum);
i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
if (grub_le_to_cpu32 (s->sh_type) == SHT_SYMTAB)
break;
if (i == grub_le_to_cpu16 (e->e_shnum))
return;
for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
i < grub_le_to_cpu16 (e->e_shnum);
i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
if (grub_le_to_cpu32 (s->sh_type) == SHT_RELA)
{
Elf64_Rela *rel, *max;
for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu32 (s->sh_offset)),
max = rel + grub_le_to_cpu32 (s->sh_size) / grub_le_to_cpu16 (s->sh_entsize);
rel < max; rel++)
switch (ELF64_R_TYPE (grub_le_to_cpu32 (rel->r_info)))
{
case R_ALPHA_LITERAL:
cntg++;
break;
default:;
}
}
*tramp = cntt;
*got = cntg;
}
/* Check if EHDR is a valid ELF header. */
grub_err_t
grub_arch_dl_check_header (void *ehdr)
{
Elf_Ehdr *e = ehdr;
/* Check the magic numbers. */
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_ALPHA)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return GRUB_ERR_NONE;
}
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
grub_uint8_t *gp;
grub_uint64_t *gpptr;
gp = (grub_uint8_t *) mod->got;
gpptr = (grub_uint64_t *) mod->got;
/* Find a symbol table. */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
entsize = s->sh_entsize;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
Elf_Rela *rel, *max;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
max = (Elf_Rela *) ((char *) rel + s->sh_size);
rel < max;
rel++)
{
grub_uint8_t *addr;
Elf_Sym *sym;
grub_uint64_t value;
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (grub_uint8_t *) seg->addr + rel->r_offset;
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
value = sym->st_value + rel->r_addend;
switch (ELF_R_TYPE (rel->r_info))
{
case R_ALPHA_REFQUAD:
*(grub_uint64_t *) addr += value;
break;
case R_ALPHA_REFLONG:
*(grub_uint32_t *) addr += value;
break;
case R_ALPHA_GPREL32:
*(grub_uint32_t *) addr += value - (grub_addr_t) gp;
break;
case R_ALPHA_GPDISP:
{
grub_int64_t off = gp - addr;
if (off < (-2147483647L - 1)
|| off > 2147483647L)
return grub_error (GRUB_ERR_BAD_MODULE,
"gpdisp offset too large");
/* Lower part is
treated as signed. Hence add 0x8000 to compensate.
*/
*(grub_uint16_t *) addr = (off + 0x8000) >> 16;
*(grub_uint16_t *) (addr + rel->r_addend) = off;
break;
}
case R_ALPHA_GPRELHIGH:
{
Elf_Rela *rel2;
/* Handle partner lo16 relocation. Lower part is
treated as signed. Hence add 0x8000 to compensate.
*/
value += (*(grub_uint16_t *) addr << 16);
value -= (grub_addr_t) gp;
for (rel2 = rel + 1; rel2 < max; rel2++)
if (ELF_R_SYM (rel2->r_info)
== ELF_R_SYM (rel->r_info)
&& ELF_R_TYPE (rel2->r_info) == R_ALPHA_GPRELLOW)
{
value += *(grub_int16_t *)
((char *) seg->addr + rel2->r_offset);
break;
}
/* Handle partner lo16 relocation. Lower part is
treated as signed. Hence add 0x8000 to compensate.
*/
if ((grub_int64_t) value < (-2147483647L - 1)
|| (grub_int64_t) value > 2147483647L)
return grub_error (GRUB_ERR_BAD_MODULE,
"gpdisp offset too large");
value += 0x8000;
*(grub_uint16_t *) addr = (value >> 16) & 0xffff;
break;
}
case R_ALPHA_GPRELLOW:
value -= (grub_addr_t) gp;
*(grub_uint16_t *) addr += value & 0xffff;
break;
case R_ALPHA_LITERAL:
*gpptr = value + *(grub_uint16_t *) addr;
*(grub_uint16_t *) addr = ((grub_uint8_t *) gpptr - gp);
gpptr++;
break;
case R_ALPHA_SREL32:
*(grub_uint32_t *) addr += value - (grub_addr_t) seg->addr;
break;
case R_ALPHA_BRSGP:
value += (((*(grub_uint32_t *) addr)
& ((1 << 21) - 1)) << 2);
value -= (grub_addr_t) addr;
if (sym->st_other == STO_ALPHA_STD_GPLOAD)
value += 4;
else
value -= 4;
if (value & 3)
return grub_error (GRUB_ERR_BAD_MODULE,
"unaligned branch");
if ((value & ~((1UL << 22) - 1)) != 0
&& (value & ~((1UL << 22) - 1)) != ~((1UL << 22) - 1))
return grub_error (GRUB_ERR_BAD_MODULE,
"brs offset too large (%lx)",
value);
*(grub_uint32_t *) addr
= ((*(grub_uint32_t *) addr & ~((1 << 21) - 1))
| ((value >> 2) & ((1 << 21) - 1)));
break;
case R_ALPHA_LITUSE:
case R_ALPHA_HINT:
break;
default:
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown relocation type %d\n",
ELF_R_TYPE (rel->r_info));
}
break;
}
}
}
}
return GRUB_ERR_NONE;
}
+215
View File
@@ -0,0 +1,215 @@
/*
* 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/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/cache.h>
#include <grub/kernel.h>
#include <grub/memory.h>
#include <grub/env.h>
#include <grub/machine/srm.h>
#include <grub/machine/console.h>
/* FIXME: determine va_size. */
static void *kseg_addr = (void *) 0xfffffc0000000000;
static grub_uint64_t log_page_size;
extern char _start[];
extern char _end[];
grub_uint32_t grub_arch_pccclock;
/* FIXME: use interrupt to count high. */
grub_uint64_t
grub_get_rtc (void)
{
static grub_uint32_t high = 0;
static grub_uint32_t last = 0;
grub_uint32_t low;
asm volatile ("rpcc %0" : "=r" (low));
if (low < last)
high++;
last = low;
return (((grub_uint64_t) high) << 32) | low;
}
static grub_addr_t
get_pfn (grub_addr_t va, grub_uint64_t ptbr)
{
grub_uint64_t *l1;
grub_uint64_t l1n;
grub_uint64_t *l2;
grub_uint64_t l2n;
grub_uint64_t *l3;
grub_uint64_t l3n;
l3n = va >> log_page_size;
l2n = l3n >> (log_page_size - 3);
l1n = l2n >> (log_page_size - 3);
l3n &= ((1 << (log_page_size - 3)) - 1);
l2n &= ((1 << (log_page_size - 3)) - 1);
l1n &= ((1 << (log_page_size - 3)) - 1);
l1 = ((grub_uint64_t *) kseg_addr + (ptbr << (log_page_size - 3))
+ l1n);
l2 = ((grub_uint64_t *) kseg_addr + ((*l1 >> 32) << (log_page_size - 3))
+ l2n);
l3 = ((grub_uint64_t *) kseg_addr + ((*l2 >> 32) << (log_page_size - 3))
+ l3n);
return (*l3 >> 32);
}
void pal_init(void);
grub_addr_t grub_modbase;
void
grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
char **path __attribute__ ((unused)))
{
}
void
grub_machine_init (void)
{
unsigned i;
struct grub_alpha_srm_memdesc *memdesc;
struct grub_alpha_srm_hwpcb *pcb;
grub_addr_t a;
grub_addr_t start, end;
grub_uint64_t low_pfn = ~0ULL, high_pfn = 0;
grub_arch_pccclock = GRUB_ALPHA_SRM_HWRPB.pcc_freq;
grub_modbase = (grub_addr_t) _end;
grub_console_init_early ();
pal_init ();
grub_install_get_time_ms (grub_rtc_get_time_ms);
for (log_page_size = 0;
!((1 << log_page_size) & GRUB_ALPHA_SRM_HWRPB.page_size);
log_page_size++);
memdesc = (struct grub_alpha_srm_memdesc *)
(GRUB_ALPHA_SRM_HWRPB_ADDR + GRUB_ALPHA_SRM_HWRPB.memory_descriptor_table);
pcb = (void *) (GRUB_ALPHA_SRM_HWRPB_ADDR
+ GRUB_ALPHA_SRM_HWRPB.cpu_slots_offset
+ (GRUB_ALPHA_SRM_HWRPB.primary_cpu_id
* GRUB_ALPHA_SRM_HWRPB.cpu_slot_size));
start = ALIGN_DOWN ((grub_addr_t) (&_start[0]),
GRUB_ALPHA_SRM_HWRPB.page_size);
end = ALIGN_UP (grub_modules_get_end (), GRUB_ALPHA_SRM_HWRPB.page_size);
for (a = start; a < end; a += GRUB_ALPHA_SRM_HWRPB.page_size)
{
grub_uint64_t curpfn = get_pfn (a, pcb->ptbr);
if (curpfn > high_pfn)
high_pfn = curpfn;
if (curpfn < low_pfn)
low_pfn = curpfn;
}
for (i = 0; i < memdesc->num_entries; i++)
{
grub_uint64_t from, to;
if (memdesc->entries[i].type
!= GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_AVAILABLE)
continue;
from = memdesc->entries[i].start_page;
to = memdesc->entries[i].start_page + memdesc->entries[i].num_pages;
if ((to > low_pfn) && (from < high_pfn + 1))
{
if (from < low_pfn)
/* from .. (lowpfn - 1) */
grub_mm_init_region ((char *) kseg_addr + (from << log_page_size),
(low_pfn - from) << log_page_size);
if (high_pfn + 1 < to)
/* (high_pfn + 1) .. (to - 1) */
grub_mm_init_region ((char *) kseg_addr
+ ((high_pfn + 1) << log_page_size),
(to - high_pfn - 1) << log_page_size);
}
else
/* from .. (to - 1) */
grub_mm_init_region ((char *) kseg_addr
+ (from << log_page_size),
(to - from) << log_page_size);
}
grub_console_init_lately ();
grub_srmdisk_init ();
char buf[512];
grub_alpha_srm_dispatch (0x22, 2, buf, sizeof (buf));
grub_printf ("Hello World %s\n", buf);
}
void
grub_machine_fini (void)
{
}
void
grub_exit (void)
{
while (1);
}
grub_err_t
grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
{
struct grub_alpha_srm_memdesc *memdesc;
unsigned i;
memdesc = (struct grub_alpha_srm_memdesc *)
(GRUB_ALPHA_SRM_HWRPB_ADDR + GRUB_ALPHA_SRM_HWRPB.memory_descriptor_table);
for (i = 0; i < memdesc->num_entries; i++)
switch (memdesc->entries[i].type)
{
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_AVAILABLE:
hook (memdesc->entries[i].start_page << log_page_size,
memdesc->entries[i].num_pages << log_page_size,
GRUB_MEMORY_AVAILABLE, hook_data);
break;
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_NONVOLATILE:
hook (memdesc->entries[i].start_page << log_page_size,
memdesc->entries[i].num_pages << log_page_size,
GRUB_MEMORY_NVRAM, hook_data);
break;
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_RESERVED1:
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_RESERVED2:
default:
hook (memdesc->entries[i].start_page << log_page_size,
memdesc->entries[i].num_pages << log_page_size,
GRUB_MEMORY_RESERVED, hook_data);
break;
}
return GRUB_ERR_NONE;
}
+54
View File
@@ -0,0 +1,54 @@
#include <config.h>
#include <grub/symbol.h>
#include <grub/offsets.h>
.set noreorder
.globl _start
.ent _start
_start:
.prologue 0
/* load GP. */
br $27, 1f
1: ldgp $29, 0($27)
/* Move modules out of the BSS. */
lda $1, __bss_start
lda $2, _end
lda $4, modsize
ldq $3, 0($4)
addq $3, 7, $3
sra $3, 3, $3
sll $3, 3, $4
subq $4, 8, $4
addq $1, $4, $1
addq $2, $4, $2
2:
beq $3, 3f
ldq $4, 0($1)
stq $4, 0($2)
subq $3, 1, $3
subq $1, 8, $1
subq $2, 8, $2
br 2b
3:
/* Clean BSS. */
lda $1, __bss_start
lda $2, _end
subq $2, $1, $2
sra $2, 3, $2
2:
beq $2, 3f
stq $31, 0($1)
subq $2, 1, $2
addq $1, 8, $1
br 2b
3:
/* call main. */
lda $27, EXT_C (grub_main)
jmp ($27)
.end _start
. = _start + GRUB_KERNEL_ALPHA_SRM_TOTAL_MODULE_SIZE
modsize:
.quad 0
+1
View File
@@ -33,6 +33,7 @@
/*
* Null divide-by-zero handler
*/
FUNCTION(__aeabi_unwind_cpp_pr0)
FUNCTION(raise)
mov r0, #0
bx lr
+31 -31
View File
@@ -199,6 +199,9 @@ grub_disk_open (const char *name)
if (! disk)
return 0;
disk->log_sector_size = GRUB_DISK_SECTOR_BITS;
/* Default 1MiB of maximum agglomerate. */
disk->max_agglomerate = 1048576 >> (GRUB_DISK_SECTOR_BITS
+ GRUB_DISK_CACHE_BITS);
p = find_part_sep (name);
if (p)
@@ -311,8 +314,8 @@ grub_disk_close (grub_disk_t disk)
sector is already adjusted and is divisible by cache unit size.
*/
static grub_err_t
grub_disk_read_small (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
{
char *data;
char *tmp_buf;
@@ -389,15 +392,27 @@ grub_disk_read_small (grub_disk_t disk, grub_disk_addr_t sector,
}
}
static grub_err_t
grub_disk_read_small (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
{
grub_err_t err;
err = grub_disk_read_small_real (disk, sector, offset, size, buf);
if (err)
return err;
if (disk->read_hook)
(disk->read_hook) (sector + (offset >> GRUB_DISK_SECTOR_BITS),
offset & (GRUB_DISK_SECTOR_SIZE - 1),
size, disk->read_hook_data);
return GRUB_ERR_NONE;
}
/* Read data from the disk. */
grub_err_t
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
{
grub_off_t real_offset;
grub_disk_addr_t real_sector;
grub_size_t real_size;
/* First of all, check if the region is within the disk. */
if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
{
@@ -408,10 +423,6 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
return grub_errno;
}
real_sector = sector;
real_offset = offset;
real_size = size;
/* First read until first cache boundary. */
if (offset || (sector & (GRUB_DISK_CACHE_SIZE - 1)))
{
@@ -446,7 +457,8 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
/* agglomerate read until we find a first cached entry. */
for (agglomerate = 0; agglomerate
< (size >> (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS));
< (size >> (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
&& agglomerate < disk->max_agglomerate;
agglomerate++)
{
data = grub_disk_cache_fetch (disk->dev->id, disk->id,
@@ -486,6 +498,11 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ (i << (GRUB_DISK_CACHE_BITS
+ GRUB_DISK_SECTOR_BITS)));
if (disk->read_hook)
(disk->read_hook) (sector, 0, agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS),
disk->read_hook_data);
sector += agglomerate << GRUB_DISK_CACHE_BITS;
size -= agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
buf = (char *) buf
@@ -494,6 +511,9 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (data)
{
if (disk->read_hook)
(disk->read_hook) (sector, 0, (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS),
disk->read_hook_data);
sector += GRUB_DISK_CACHE_SIZE;
buf = (char *) buf + (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
size -= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
@@ -509,26 +529,6 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
return err;
}
/* Call the read hook, if any. */
if (disk->read_hook)
{
grub_disk_addr_t s = real_sector;
grub_size_t l = real_size;
grub_off_t o = real_offset;
while (l)
{
grub_size_t cl;
cl = GRUB_DISK_SECTOR_SIZE - o;
if (cl > l)
cl = l;
(disk->read_hook) (s, o, cl, disk->read_hook_data);
s++;
l -= cl;
o = 0;
}
}
return grub_errno;
}
+59 -67
View File
@@ -229,7 +229,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
unsigned i;
Elf_Shdr *s;
grub_size_t tsize = 0, talign = 1;
#if defined (__ia64__) || defined (__powerpc__)
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
grub_size_t tramp;
grub_size_t got;
#endif
@@ -244,7 +244,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
talign = s->sh_addralign;
}
#if defined (__ia64__) || defined (__powerpc__)
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
tramp *= GRUB_ARCH_DL_TRAMP_SIZE;
got *= sizeof (grub_uint64_t);
@@ -313,7 +313,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
mod->segment = seg;
}
}
#if defined (__ia64__) || defined (__powerpc__)
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
mod->tramp = ptr;
ptr += tramp;
@@ -359,7 +359,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
str = (char *) e + s->sh_offset;
for (i = 0;
i < size / entsize;
i * entsize < size;
i++, sym = (Elf_Sym *) ((char *) sym + entsize))
{
unsigned char type = ELF_ST_TYPE (sym->st_info);
@@ -433,6 +433,24 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
return GRUB_ERR_NONE;
}
static Elf_Shdr *
grub_dl_find_section (Elf_Ehdr *e, const char *name)
{
Elf_Shdr *s;
const char *str;
unsigned i;
s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
str = (char *) e + s->sh_offset;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (grub_strcmp (str + s->sh_name, name) == 0)
return s;
return NULL;
}
/* Me, Vladimir Serbinenko, hereby I add this module check as per new
GNU module policy. Note that this license check is informative only.
Modules have to be licensed under GPLv3 or GPLv3+ (optionally
@@ -444,24 +462,11 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
static grub_err_t
grub_dl_check_license (Elf_Ehdr *e)
{
Elf_Shdr *s;
const char *str;
unsigned i;
s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
str = (char *) e + s->sh_offset;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (grub_strcmp (str + s->sh_name, ".module_license") == 0)
{
if (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
Elf_Shdr *s = grub_dl_find_section (e, ".module_license");
if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0)
return GRUB_ERR_NONE;
}
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0))
return GRUB_ERR_NONE;
return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
}
@@ -469,25 +474,14 @@ static grub_err_t
grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
{
Elf_Shdr *s;
const char *str;
unsigned i;
s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
str = (char *) e + s->sh_offset;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (grub_strcmp (str + s->sh_name, ".modname") == 0)
{
mod->name = grub_strdup ((char *) e + s->sh_offset);
if (! mod->name)
return grub_errno;
break;
}
if (i == e->e_shnum)
s = grub_dl_find_section (e, ".modname");
if (!s)
return grub_error (GRUB_ERR_BAD_MODULE, "no module name found");
mod->name = grub_strdup ((char *) e + s->sh_offset);
if (! mod->name)
return grub_errno;
return GRUB_ERR_NONE;
}
@@ -496,42 +490,36 @@ static grub_err_t
grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
{
Elf_Shdr *s;
const char *str;
unsigned i;
s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
str = (char *) e + s->sh_offset;
s = grub_dl_find_section (e, ".moddeps");
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (grub_strcmp (str + s->sh_name, ".moddeps") == 0)
{
const char *name = (char *) e + s->sh_offset;
const char *max = name + s->sh_size;
if (!s)
return GRUB_ERR_NONE;
while ((name < max) && (*name))
{
grub_dl_t m;
grub_dl_dep_t dep;
const char *name = (char *) e + s->sh_offset;
const char *max = name + s->sh_size;
m = grub_dl_load (name);
if (! m)
return grub_errno;
while ((name < max) && (*name))
{
grub_dl_t m;
grub_dl_dep_t dep;
grub_dl_ref (m);
m = grub_dl_load (name);
if (! m)
return grub_errno;
dep = (grub_dl_dep_t) grub_malloc (sizeof (*dep));
if (! dep)
return grub_errno;
grub_dl_ref (m);
dep->mod = m;
dep->next = mod->dep;
mod->dep = dep;
dep = (grub_dl_dep_t) grub_malloc (sizeof (*dep));
if (! dep)
return grub_errno;
name += grub_strlen (name) + 1;
}
}
dep->mod = m;
dep->next = mod->dep;
mod->dep = dep;
name += grub_strlen (name) + 1;
}
return GRUB_ERR_NONE;
}
@@ -565,11 +553,15 @@ grub_dl_unref (grub_dl_t mod)
}
static void
grub_dl_flush_cache (grub_dl_t mod)
grub_dl_flush_cache (grub_dl_t mod __attribute__ ((unused)))
{
grub_dprintf ("modules", "flushing 0x%lx bytes at %p\n",
(unsigned long) mod->sz, mod->base);
#ifdef __alpha__
grub_arch_sync_all_caches ();
#else
grub_arch_sync_caches (mod->base, mod->sz);
#endif
}
/* Load a module from core memory. */
+36 -29
View File
@@ -309,7 +309,34 @@ grub_efi_modules_addr (void)
char *
grub_efi_get_filename (grub_efi_device_path_t *dp)
{
char *name = 0;
char *name = 0, *p;
grub_size_t filesize = 0;
while (1)
{
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
if (type == GRUB_EFI_END_DEVICE_PATH_TYPE)
break;
if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
&& subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE)
{
grub_efi_uint16_t len;
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
/ sizeof (grub_efi_char16_t));
filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 1;
}
dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
}
if (!filesize)
return NULL;
p = name = grub_malloc (filesize);
if (!name)
return NULL;
while (1)
{
@@ -323,45 +350,25 @@ grub_efi_get_filename (grub_efi_device_path_t *dp)
{
grub_efi_file_path_device_path_t *fp;
grub_efi_uint16_t len;
char *p;
grub_size_t size;
if (name)
{
size = grub_strlen (name);
name[size] = '/';
size++;
}
else
size = 0;
if (p != name)
*p++ = '/';
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
/ sizeof (grub_efi_char16_t));
p = grub_realloc (name, size + len * 4 + 1);
if (! p)
{
grub_free (name);
return 0;
}
name = p;
fp = (grub_efi_file_path_device_path_t *) dp;
*grub_utf16_to_utf8 ((grub_uint8_t *) name + size,
fp->path_name, len) = '\0';
p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len);
}
dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
}
if (name)
{
/* EFI breaks paths with backslashes. */
char *p;
*p = '\0';
for (p = name; *p; p++)
if (*p == '\\')
*p = '/';
}
/* EFI breaks paths with backslashes. */
for (p = name; *p; p++)
if (*p == '\\')
*p = '/';
return name;
}
+1
View File
@@ -155,6 +155,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
disk->total_sectors = grub_util_get_fd_size (fd, map[drive].device,
&disk->log_sector_size);
disk->total_sectors >>= disk->log_sector_size;
disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
#if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
{
+1 -1
View File
@@ -22,7 +22,7 @@
#include <grub/types.h>
#include <grub/ieee1275/ieee1275.h>
int (*grub_ieee1275_entry_fn) (void *);
int (*grub_ieee1275_entry_fn) (void *) GRUB_IEEE1275_ENTRY_FN_ATTRIBUTE;
grub_ieee1275_phandle_t grub_ieee1275_chosen;
grub_ieee1275_ihandle_t grub_ieee1275_mmu;
+61 -52
View File
@@ -94,17 +94,6 @@ grub_strcpy (char *dest, const char *src)
return dest;
}
char *
grub_strncpy (char *dest, const char *src, int c)
{
char *p = dest;
while ((*p++ = *src++) != '\0' && --c)
;
return dest;
}
int
grub_printf (const char *fmt, ...)
{
@@ -465,6 +454,15 @@ grub_strndup (const char *s, grub_size_t n)
return p;
}
/* clang detects that we're implementing here a memset so it decides to
optimise and calls memset resulting in infinite recursion. With volatile
we make it not optimise in this way. */
#ifdef __clang__
#define VOLATILE_CLANG volatile
#else
#define VOLATILE_CLANG
#endif
void *
grub_memset (void *s, int c, grub_size_t len)
{
@@ -481,13 +479,13 @@ grub_memset (void *s, int c, grub_size_t len)
while (len > 0 && (((grub_addr_t) p) & (sizeof (unsigned long) - 1)))
{
*(grub_uint8_t *) p = pattern8;
*(VOLATILE_CLANG grub_uint8_t *) p = pattern8;
p = (grub_uint8_t *) p + 1;
len--;
}
while (len >= sizeof (unsigned long))
{
*(unsigned long *) p = patternl;
*(VOLATILE_CLANG unsigned long *) p = patternl;
p = (unsigned long *) p + 1;
len -= sizeof (unsigned long);
}
@@ -495,7 +493,7 @@ grub_memset (void *s, int c, grub_size_t len)
while (len > 0)
{
*(grub_uint8_t *) p = pattern8;
*(VOLATILE_CLANG grub_uint8_t *) p = pattern8;
p = (grub_uint8_t *) p + 1;
len--;
}
@@ -553,7 +551,13 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
grub_uint64_t q = 0;
grub_uint64_t m = 0;
/* ARM and IA64 don't have a fast 32-bit division.
Using that code would just make us use libgcc routines, calling
them twice (once for modulo and once for quotient.
*/
#if !defined (__arm__) && !defined (__ia64__)
/* Skip the slow computation if 32-bit arithmetic is possible. */
#ifndef __alpha__
if (n < 0xffffffff && d < 0xffffffff)
{
if (r)
@@ -561,6 +565,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
return ((grub_uint32_t) n) / (grub_uint32_t) d;
}
#endif
while (bits--)
{
@@ -625,6 +630,31 @@ grub_lltoa (char *str, int c, unsigned long long n)
return p;
}
static inline void
write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch)
{
if (*count < max_len)
str[*count] = ch;
(*count)++;
}
static inline void
write_str (char *str, grub_size_t *count, grub_size_t max_len, const char *s)
{
while (*s)
write_char (str, count, max_len, *s++);
}
static inline void
write_fill (char *str, grub_size_t *count, grub_size_t max_len, const char ch, int count_fill)
{
int i;
for (i = 0; i < count_fill; i++)
write_char (str, count, max_len, ch);
}
static int
grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list args_in)
{
@@ -633,30 +663,6 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
grub_size_t count = 0;
grub_size_t count_args = 0;
const char *fmt;
auto void write_char (unsigned char ch);
auto void write_str (const char *s);
auto void write_fill (const char ch, int count_fill);
void write_char (unsigned char ch)
{
if (count < max_len)
*str++ = ch;
count++;
}
void write_str (const char *s)
{
while (*s)
write_char (*s++);
}
void write_fill (const char ch, int count_fill)
{
int i;
for (i = 0; i < count_fill; i++)
write_char (ch);
}
fmt = fmt0;
while ((c = *fmt++) != 0)
@@ -828,7 +834,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
if (c != '%')
{
write_char (c);
write_char (str, &count, max_len,c);
continue;
}
@@ -882,7 +888,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
if (c == '%')
{
write_char (c);
write_char (str, &count, max_len,c);
continue;
}
@@ -892,7 +898,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
switch (c)
{
case 'p':
write_str ("0x");
write_str (str, &count, max_len, "0x");
c = 'x';
longlongfmt |= (sizeof (void *) == sizeof (long long));
/* Fall through. */
@@ -912,14 +918,14 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
else
grub_lltoa (tmp, c, args[curn].i);
if (! rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - grub_strlen (tmp));
write_str (tmp);
write_fill (str, &count, max_len, zerofill, format1 - grub_strlen (tmp));
write_str (str, &count, max_len, tmp);
if (rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - grub_strlen (tmp));
write_fill (str, &count, max_len, zerofill, format1 - grub_strlen (tmp));
break;
case 'c':
write_char (args[curn].i & 0xff);
write_char (str, &count, max_len,args[curn].i & 0xff);
break;
case 'C':
@@ -955,10 +961,10 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
mask = 0;
}
write_char (mask | (code >> shift));
write_char (str, &count, max_len,mask | (code >> shift));
for (shift -= 6; shift >= 0; shift -= 6)
write_char (0x80 | (0x3f & (code >> shift)));
write_char (str, &count, max_len,0x80 | (0x3f & (code >> shift)));
}
break;
@@ -971,25 +977,28 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
len++;
if (!rightfill && len < format1)
write_fill (zerofill, format1 - len);
write_fill (str, &count, max_len, zerofill, format1 - len);
grub_size_t i;
for (i = 0; i < len; i++)
write_char (*p++);
write_char (str, &count, max_len,*p++);
if (rightfill && len < format1)
write_fill (zerofill, format1 - len);
write_fill (str, &count, max_len, zerofill, format1 - len);
}
break;
default:
write_char (c);
write_char (str, &count, max_len,c);
break;
}
}
*str = '\0';
if (count < max_len)
str[count] = '\0';
else
str[max_len] = '\0';
return count;
}
+3 -2
View File
@@ -194,7 +194,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
{
grub_off_t extra;
extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) % align;
extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) & (align - 1);
if (extra)
extra = align - extra;
@@ -483,7 +483,8 @@ grub_realloc (void *ptr, grub_size_t size)
if (! q)
return q;
grub_memcpy (q, ptr, size);
/* We've already checked that p->size < n. */
grub_memcpy (q, ptr, p->size << GRUB_MM_ALIGN_LOG2);
grub_free (ptr);
return q;
}
+25 -24
View File
@@ -106,6 +106,29 @@ check_varstate (grub_parser_state_t s)
|| s == GRUB_PARSER_STATE_QVARNAME2);
}
static void
add_var (char *varname, char **bp, char **vp,
grub_parser_state_t state, grub_parser_state_t newstate)
{
const char *val;
/* Check if a variable was being read in and the end of the name
was reached. */
if (!(check_varstate (state) && !check_varstate (newstate)))
return;
*((*vp)++) = '\0';
val = grub_env_get (varname);
*vp = varname;
if (!val)
return;
/* Insert the contents of the variable in the buffer. */
for (; *val; val++)
*((*bp)++) = *val;
}
grub_err_t
grub_parser_split_cmdline (const char *cmdline,
grub_reader_getline_t getline, void *getline_data,
@@ -122,28 +145,6 @@ grub_parser_split_cmdline (const char *cmdline,
char *args;
int i;
auto void add_var (grub_parser_state_t newstate);
void add_var (grub_parser_state_t newstate)
{
const char *val;
/* Check if a variable was being read in and the end of the name
was reached. */
if (!(check_varstate (state) && !check_varstate (newstate)))
return;
*(vp++) = '\0';
val = grub_env_get (varname);
vp = varname;
if (!val)
return;
/* Insert the contents of the variable in the buffer. */
for (; *val; val++)
*(bp++) = *val;
}
*argc = 0;
do
{
@@ -168,7 +169,7 @@ grub_parser_split_cmdline (const char *cmdline,
/* If a variable was being processed and this character does
not describe the variable anymore, write the variable to
the buffer. */
add_var (newstate);
add_var (varname, &bp, &vp, state, newstate);
if (check_varstate (newstate))
{
@@ -198,7 +199,7 @@ grub_parser_split_cmdline (const char *cmdline,
/* A special case for when the last character was part of a
variable. */
add_var (GRUB_PARSER_STATE_TEXT);
add_var (varname, &bp, &vp, state, GRUB_PARSER_STATE_TEXT);
if (bp != buffer && *(bp - 1))
{
+2
View File
@@ -38,6 +38,8 @@ grub_arch_dl_check_header (void *ehdr)
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
void
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
+195
View File
@@ -0,0 +1,195 @@
/* Copyright (C) 1992, 1994, 1996, 1997, 2002, 2006, 2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <grub/symbol.h>
#include <grub/dl.h>
#define JB_S0 0
#define JB_S1 1
#define JB_S2 2
#define JB_S3 3
#define JB_S4 4
#define JB_S5 5
#define JB_PC 6
#define JB_FP 7
#define JB_SP 8
#define JB_F2 9
#define JB_F3 10
#define JB_F4 11
#define JB_F5 12
#define JB_F6 13
#define JB_F7 14
#define JB_F8 15
#define JB_F9 16
#define v0 $0 /* function return value */
#define t0 $1 /* temporary registers (caller-saved) */
#define t1 $2
#define t2 $3
#define t3 $4
#define t4 $5
#define t5 $6
#define t6 $7
#define t7 $8
#define s0 $9 /* saved-registers (callee-saved registers) */
#define s1 $10
#define s2 $11
#define s3 $12
#define s4 $13
#define s5 $14
#define s6 $15
#define fp s6 /* frame-pointer (s6 in frame-less procedures) */
#define a0 $16 /* argument registers (caller-saved) */
#define a1 $17
#define a2 $18
#define a3 $19
#define a4 $20
#define a5 $21
#define t8 $22 /* more temps (caller-saved) */
#define t9 $23
#define t10 $24
#define t11 $25
#define ra $26 /* return address register */
#define t12 $27
#define pv t12 /* procedure-variable register */
#define AT $at /* assembler temporary */
#define gp $29 /* global pointer */
#define sp $30 /* stack pointer */
#define zero $31 /* reads as zero, writes are noops */
#define ENTRY(name) \
.globl EXT_C(name); \
.align 4; \
.ent EXT_C(name), 0; \
EXT_C(name): \
.frame sp, 0, ra
GRUB_MOD_LICENSE "GPLv3+"
.text
ENTRY(grub_setjmp)
ldgp gp, 0(pv)
#ifndef PIC
#define FRAME 16
subq sp, FRAME, sp
.frame sp, FRAME, ra, 0
stq ra, 0(sp)
.mask 0x04000000, -FRAME
#else
#define FRAME 0
.frame sp, FRAME, ra, 0
#endif
#ifdef PROF
.set noat
lda AT, _mcount
jsr AT, (AT), _mcount
.set at
#endif
.prologue 1
mov 0, a1
stq s0, JB_S0*8(a0)
stq s1, JB_S1*8(a0)
stq s2, JB_S2*8(a0)
stq s3, JB_S3*8(a0)
stq s4, JB_S4*8(a0)
stq s5, JB_S5*8(a0)
#ifdef PTR_MANGLE
PTR_MANGLE(t1, ra, t0)
stq t1, JB_PC*8(a0)
#else
stq ra, JB_PC*8(a0)
#endif
#if defined(PTR_MANGLE) && FRAME == 0
PTR_MANGLE2(t1, sp, t0)
#else
addq sp, FRAME, t1
# ifdef PTR_MANGLE
PTR_MANGLE2(t1, t1, t0)
# endif
#endif
stq t1, JB_SP*8(a0)
#ifdef PTR_MANGLE
PTR_MANGLE2(t1, fp, t0)
stq t1, JB_FP*8(a0)
#else
stq fp, JB_FP*8(a0)
#endif
stt $f2, JB_F2*8(a0)
stt $f3, JB_F3*8(a0)
stt $f4, JB_F4*8(a0)
stt $f5, JB_F5*8(a0)
stt $f6, JB_F6*8(a0)
stt $f7, JB_F7*8(a0)
stt $f8, JB_F8*8(a0)
stt $f9, JB_F9*8(a0)
mov 0, v0
ret
.end grub_setjmp
ENTRY(grub_longjmp)
#ifdef PROF
ldgp gp, 0(pv)
.set noat
lda AT, _mcount
jsr AT, (AT), _mcount
.set at
.prologue 1
#else
.prologue 0
#endif
mov a1, v0
ldq s0, JB_S0*8(a0)
ldq s1, JB_S1*8(a0)
ldq s2, JB_S2*8(a0)
ldq s3, JB_S3*8(a0)
ldq s4, JB_S4*8(a0)
ldq s5, JB_S5*8(a0)
ldq ra, JB_PC*8(a0)
ldq fp, JB_FP*8(a0)
ldq t0, JB_SP*8(a0)
ldt $f2, JB_F2*8(a0)
ldt $f3, JB_F3*8(a0)
ldt $f4, JB_F4*8(a0)
ldt $f5, JB_F5*8(a0)
ldt $f6, JB_F6*8(a0)
ldt $f7, JB_F7*8(a0)
ldt $f8, JB_F8*8(a0)
ldt $f9, JB_F9*8(a0)
#ifdef PTR_DEMANGLE
PTR_DEMANGLE(ra, t1)
PTR_DEMANGLE2(t0, t1)
PTR_DEMANGLE2(fp, t1)
#endif
cmoveq v0, 1, v0
mov t0, sp
ret
.end EXT_C(grub_longjmp)
+37
View File
@@ -0,0 +1,37 @@
/*
* 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/datetime.h>
#include <grub/dl.h>
#include <grub/misc.h>
GRUB_MOD_LICENSE ("GPLv3+");
grub_err_t
grub_get_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"getting time isn't supported");
}
grub_err_t
grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"setting time isn't supported");
}
+25
View File
@@ -0,0 +1,25 @@
/*
* 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/misc.h>
void
grub_halt (void)
{
while (1);
}
+25
View File
@@ -0,0 +1,25 @@
/*
* 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/misc.h>
void
grub_reboot (void)
{
while (1);
}
+20 -20
View File
@@ -212,6 +212,22 @@ parse_option (grub_extcmd_t cmd, const struct grub_arg_option *opt,
return 0;
}
static inline grub_err_t
add_arg (char ***argl, int *num, char *s)
{
char **p = *argl;
*argl = grub_realloc (*argl, (++(*num) + 1) * sizeof (char *));
if (! *argl)
{
grub_free (p);
return grub_errno;
}
(*argl)[(*num) - 1] = s;
(*argl)[(*num)] = NULL;
return 0;
}
int
grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
struct grub_arg_list *usr, char ***args, int *argnum)
@@ -220,22 +236,6 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
int arglen;
char **argl = 0;
int num = 0;
auto grub_err_t add_arg (char *s);
grub_err_t add_arg (char *s)
{
char **p = argl;
argl = grub_realloc (argl, (++num + 1) * sizeof (char *));
if (! argl)
{
grub_free (p);
return grub_errno;
}
argl[num - 1] = s;
argl[num] = NULL;
return 0;
}
for (curarg = 0; curarg < argc; curarg++)
{
@@ -247,7 +247,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if ((num && (cmd->cmd->flags & GRUB_COMMAND_OPTIONS_AT_START))
|| arg[0] != '-' || grub_strlen (arg) == 1)
{
if (add_arg (arg) != 0)
if (add_arg (&argl, &num, arg) != 0)
goto fail;
continue;
@@ -266,7 +266,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (*curshort)
{
if (add_arg (arg) != 0)
if (add_arg (&argl, &num, arg) != 0)
goto fail;
continue;
}
@@ -319,7 +319,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (grub_strlen (arg) == 2)
{
for (curarg++; curarg < argc; curarg++)
if (add_arg (argv[curarg]) != 0)
if (add_arg (&argl, &num, argv[curarg]) != 0)
goto fail;
break;
}
@@ -341,7 +341,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (!opt && (cmd->cmd->flags & GRUB_COMMAND_ACCEPT_DASH))
{
if (add_arg (arg) != 0)
if (add_arg (&argl, &num, arg) != 0)
goto fail;
continue;
}
+7
View File
@@ -123,6 +123,13 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
len = size & ~((1 << disk->log_sector_size) - 1);
n = size >> disk->log_sector_size;
if (n > (disk->max_agglomerate
<< (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
- disk->log_sector_size)))
n = (disk->max_agglomerate
<< (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
- disk->log_sector_size));
if ((disk->dev->write) (disk, transform_sector (disk, sector),
n, buf) != GRUB_ERR_NONE)
goto finish;
+26 -31
View File
@@ -77,6 +77,7 @@ static struct legacy_command legacy_commands[] =
"Initialize a network device via BOOTP. If the option `--with-configfile'"
" is given, try to load a configuration file specified by the 150 vendor"
" tag."},
/* FIXME: border unsupported. */
{"cat", "cat '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE",
"Print the contents of the file FILE."},
{"chainloader", "chainloader %s '%s'\n", NULL, 0,
@@ -295,6 +296,7 @@ static struct legacy_command legacy_commands[] =
" STOP is the length of stop bit(s). The option --device can be used only"
" in the grub shell, which specifies the file name of a tty device. The"
" default values are COM1, 9600, 8N1."},
/* FIXME: shade unsupported. */
/* FIXME: silent unsupported. */
/* FIXME: splashimage unsupported. */
/* FIXME: setkey unsupported. */ /* NUL_TERMINATE */
@@ -305,7 +307,7 @@ static struct legacy_command legacy_commands[] =
/* FIXME: graphics unsupported. */
{"terminal", NULL, NULL, 0, 0, {}, FLAG_TERMINAL | FLAG_IGNORE_REST,
"[--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] "
"[--silent] [console] [serial] [hercules]",
"[--silent] [console] [serial] [hercules] [graphics]",
"Select a terminal. When multiple terminals are specified, wait until"
" you push any key to continue. If both console and serial are specified,"
" the terminal to which you input a key first will be selected. If no"
@@ -346,6 +348,7 @@ static struct legacy_command legacy_commands[] =
FLAG_FALLBACK, NULL, NULL}
/* FIXME: verbose unsupported. */
/* FIXME: version unsupported. */
/* FIXME: viewport unsupported. */
};
char *
@@ -544,9 +547,9 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
int no_echo = 0, no_edit = 0;
#endif
int hercules = 0;
int console = 0, serial = 0;
int console = 0, serial = 0, graphics = 0;
/* Big enough for any possible resulting command. */
char outbuf[256] = "";
char outbuf[512] = "";
char *outptr;
while (*ptr)
{
@@ -578,46 +581,38 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
serial = 1;
if (grub_memcmp (ptr, "hercules", sizeof ("hercules") - 1) == 0)
hercules = 1;
if (grub_memcmp (ptr, "graphics", sizeof ("graphics") - 1) == 0)
graphics = 1;
while (*ptr && !grub_isspace (*ptr))
ptr++;
while (*ptr && grub_isspace (*ptr))
ptr++;
}
if (!console && !serial)
if (!console && !serial && !hercules && !graphics)
return grub_strdup ("terminal_input; terminal_output; terminfo\n");
grub_strcpy (outbuf, "terminal_input ");
outptr = outbuf + grub_strlen (outbuf);
outptr = outbuf;
if (graphics)
outptr = grub_stpcpy (outptr, "insmod all_video; ");
outptr = grub_stpcpy (outptr, "terminal_input ");
if (serial)
{
grub_strcpy (outptr, "serial ");
outptr += grub_strlen (outptr);
}
if (console || hercules)
{
grub_strcpy (outptr, "console ");
outptr += grub_strlen (outptr);
}
grub_strcpy (outptr, "; terminal_output ");
outptr += grub_strlen (outptr);
outptr = grub_stpcpy (outptr, "serial ");
if (console || hercules || graphics)
outptr = grub_stpcpy (outptr, "console ");
outptr = grub_stpcpy (outptr, "; terminal_output ");
if (serial)
{
grub_strcpy (outptr, "serial ");
outptr += grub_strlen (outptr);
}
outptr = grub_stpcpy (outptr, "serial ");
if (console)
{
grub_strcpy (outptr, "console ");
outptr += grub_strlen (outptr);
}
outptr = grub_stpcpy (outptr, "console ");
if (hercules)
{
grub_strcpy (outptr, "mda_text ");
outptr += grub_strlen (outptr);
}
grub_strcpy (outptr, "; ");
outptr += grub_strlen (outptr);
outptr = grub_stpcpy (outptr, "mda_text ");
if (graphics)
outptr = grub_stpcpy (outptr, "gfxterm ");
outptr = grub_stpcpy (outptr, "; ");
*outptr = '\0';
if (serial)
{
grub_snprintf (outptr, outbuf + sizeof (outbuf) - outptr,
File diff suppressed because it is too large. Load diff
+4 -3
View File
@@ -23,7 +23,7 @@ EXTRA_DIST = Manifest
# Need to include ../src in addition to top_srcdir because gcrypt.h is
# a built header.
AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
AM_CFLAGS = $(GPG_ERROR_CFLAGS)
@@ -35,7 +35,7 @@ libcipher_la_DEPENDENCIES = $(GCRYPT_MODULES)
libcipher_la_LIBADD = $(GCRYPT_MODULES)
libcipher_la_SOURCES = \
cipher.c pubkey.c ac.c md.c \
cipher.c pubkey.c ac.c md.c kdf.c \
hmac-tests.c \
bithelp.h \
primegen.c \
@@ -51,6 +51,7 @@ des.c \
dsa.c \
elgamal.c \
ecc.c \
idea.c \
md4.c \
md5.c \
rijndael.c rijndael-tables.h \
@@ -68,7 +69,7 @@ rfc2268.c \
camellia.c camellia.h camellia-glue.c
if ENABLE_O_FLAG_MUNGING
o_flag_munging = sed -e 's/-O[2-9s]*/-O1/g'
o_flag_munging = sed -e 's/-O\([2-9s][2-9s]*\)/-O1/' -e 's/-Ofast/-O1/g'
else
o_flag_munging = cat
endif
+31 -31
View File
@@ -1,19 +1,19 @@
/* ac.c - Alternative interface for asymmetric cryptography.
Copyright (C) 2003, 2004, 2005, 2006
2007, 2008 Free Software Foundation, Inc.
This file is part of Libgcrypt.
Libgcrypt is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser general Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
Libgcrypt 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
@@ -115,7 +115,7 @@ struct gcry_ac_key_pair
/*
/*
* Functions for working with data sets.
*/
@@ -151,7 +151,7 @@ static void
ac_data_values_destroy (gcry_ac_data_t data)
{
unsigned int i;
for (i = 0; i < data->data_n; i++)
if (data->data[i].flags & GCRY_AC_FLAG_DEALLOC)
{
@@ -256,7 +256,7 @@ _gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
err = ac_data_mpi_copy (data->data, data->data_n, &data_mpis);
if (err)
goto out;
data_new->data_n = data->data_n;
data_new->data = data_mpis;
*data_cp = data_new;
@@ -524,13 +524,13 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
i++;
}
identifiers_n = i;
if (! identifiers_n)
/* If there are NO identifiers, we still add surrounding braces so
that we have a list of named MPI value lists. Otherwise it
wouldn't be too much fun to process these lists. */
sexp_buffer_n += 2;
data_n = _gcry_ac_data_length (data);
for (i = 0; i < data_n; i++)
{
@@ -666,7 +666,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
/* Identifier matches. Now we have to distinguish two
cases:
(i) we are at the last identifier:
leave loop
@@ -725,7 +725,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
skip_name = 0;
/* Create data set from S-expression data. */
err = gcry_ac_data_new (&data_set_new);
if (err)
goto out;
@@ -793,7 +793,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
gcry_sexp_release (sexp_tmp);
gcry_mpi_release (mpi);
gcry_free (string);
if (err)
gcry_ac_data_destroy (data_set_new);
@@ -1005,7 +1005,7 @@ _gcry_ac_io_read (gcry_ac_io_t *ac_io,
unsigned int nread, unsigned char *buffer, size_t *buffer_n)
{
gcry_error_t err;
gcry_assert (ac_io->mode == GCRY_AC_IO_READABLE);
err = 0;
@@ -1072,7 +1072,7 @@ _gcry_ac_io_read_all (gcry_ac_io_t *ac_io, unsigned char **buffer, size_t *buffe
err = gcry_error_from_errno (errno);
break;
}
if (buffer_new != p)
buffer_new = p;
@@ -1132,7 +1132,7 @@ _gcry_ac_io_process (gcry_ac_io_t *ac_io,
/*
/*
* Functions for converting data between the native ac and the
* S-expression structure used by the pk interface.
*/
@@ -1403,7 +1403,7 @@ _gcry_ac_open (gcry_ac_handle_t *handle,
err = _gcry_pk_module_lookup (algorithm, &module);
if (err)
goto out;
/* Allocate. */
handle_new = gcry_malloc (sizeof (*handle_new));
if (! handle_new)
@@ -1420,7 +1420,7 @@ _gcry_ac_open (gcry_ac_handle_t *handle,
*handle = handle_new;
out:
/* Deallocate resources. */
if (err)
_gcry_pk_module_release (module);
@@ -1443,7 +1443,7 @@ _gcry_ac_close (gcry_ac_handle_t handle)
/*
/*
* Key management.
*/
@@ -1662,7 +1662,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits,
out:
/* Deallocate resources. */
gcry_free (genkey_format);
gcry_free (arg_list);
gcry_sexp_release (genkey_sexp_request);
@@ -1682,7 +1682,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits,
/* Returns the key of type WHICH out of the key pair KEY_PAIR. */
gcry_ac_key_t
_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
gcry_ac_key_type_t which)
{
gcry_ac_key_t key;
@@ -1851,7 +1851,7 @@ _gcry_ac_key_get_grip (gcry_ac_handle_t handle,
/*
/*
* Functions performing cryptographic operations.
*/
@@ -2176,7 +2176,7 @@ em_randomize_nonzero (unsigned char *buffer, size_t buffer_n,
for (i = 0; i < buffer_n; i++)
buffer[i] = 0;
do
{
/* Count zeros. */
@@ -2384,7 +2384,7 @@ emsa_pkcs_v1_5_encode (unsigned int flags, void *opts,
unsigned int i;
(void)flags;
options = opts;
buffer = NULL;
md = NULL;
@@ -2656,7 +2656,7 @@ _gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n)
err = gcry_error_from_errno (errno);
goto out;
}
_gcry_ac_mpi_to_os (mpi, buffer, buffer_n);
*os = buffer;
*os_n = buffer_n;
@@ -2676,7 +2676,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
gcry_mpi_t xi;
gcry_mpi_t x;
gcry_mpi_t a;
if (fips_mode ())
return;
@@ -2692,7 +2692,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
gcry_mpi_add (x, x, xi);
gcry_mpi_mul_ui (a, a, 256);
}
gcry_mpi_release (xi);
gcry_mpi_release (a);
@@ -2702,7 +2702,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
/*
/*
* Implementation of Encryption Schemes (ES) and Signature Schemes
* with Appendix (SSA).
*/
@@ -2824,7 +2824,7 @@ ac_dencode_prepare (gcry_ac_handle_t handle, gcry_ac_key_t key, void *opts,
err = gcry_error_from_errno (errno);
goto out;
}
err = (*scheme.dencode_prepare) (handle, key, opts, options_em);
if (err)
goto out;
@@ -3065,7 +3065,7 @@ _gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
goto out;
out:
_gcry_ac_data_destroy (data_encrypted);
gcry_mpi_release (mpi_encrypted);
gcry_mpi_release (mpi_decrypted);
@@ -3270,7 +3270,7 @@ _gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
gcry_mpi_release (mpi_signature);
mpi_signature = NULL;
err = _gcry_ac_data_verify (handle, key, mpi_data, data_signed);
out:
@@ -3287,7 +3287,7 @@ _gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
}
/*
/*
* General functions.
*/
+7 -8
View File
@@ -45,7 +45,7 @@ do_encrypt_stream( ARCFOUR_context *ctx,
register int i = ctx->idx_i;
register int j = ctx->idx_j;
register byte *sbox = ctx->sbox;
register int t;
register int t;
while ( length-- )
{
@@ -56,7 +56,7 @@ do_encrypt_stream( ARCFOUR_context *ctx,
t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t;
*outbuf++ = *inbuf++ ^ sbox[(sbox[i] + sbox[j]) & 255];
}
ctx->idx_i = i;
ctx->idx_j = j;
}
@@ -80,7 +80,7 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
byte karr[256];
ARCFOUR_context *ctx = (ARCFOUR_context *) context;
if (!initialized )
if (!initialized )
{
initialized = 1;
selftest_failed = selftest();
@@ -98,14 +98,14 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
ctx->sbox[i] = i;
for (i=0; i < 256; i++ )
karr[i] = key[i%keylen];
for (i=j=0; i < 256; i++ )
for (i=j=0; i < 256; i++ )
{
int t;
j = (j + ctx->sbox[i] + karr[i]) % 256;
t = ctx->sbox[i];
ctx->sbox[i] = ctx->sbox[j];
ctx->sbox[j] = t;
}
}
memset( karr, 0, 256 );
return GPG_ERR_NO_ERROR;
@@ -125,8 +125,8 @@ static const char*
selftest(void)
{
ARCFOUR_context ctx;
byte scratch[16];
byte scratch[16];
/* Test vector from Cryptlib labeled there: "from the
State/Commerce Department". */
static byte key_1[] =
@@ -153,4 +153,3 @@ gcry_cipher_spec_t _gcry_cipher_spec_arcfour =
"ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context),
arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream,
};
+4 -4
View File
@@ -501,7 +501,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
static int initialized;
static const char *selftest_failed;
if( !initialized )
if( !initialized )
{
initialized = 1;
selftest_failed = selftest();
@@ -513,7 +513,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
for(i=0; i < BLOWFISH_ROUNDS+2; i++ )
c->p[i] = ps[i];
for(i=0; i < 256; i++ )
for(i=0; i < 256; i++ )
{
c->s0[i] = ks0[i];
c->s1[i] = ks1[i];
@@ -521,7 +521,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
c->s3[i] = ks3[i];
}
for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ )
for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ )
{
#ifdef WORDS_BIGENDIAN
((byte*)&data)[0] = key[j];
@@ -545,7 +545,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
c->p[i] = datal;
c->p[i+1] = datar;
}
for(i=0; i < 256; i += 2 )
for(i=0; i < 256; i += 2 )
{
do_encrypt( c, &datal, &datar );
c->s0[i] = datal;
@@ -32,7 +32,7 @@
* space of the library clean. The following macro is thus useful:
*
* #define CAMELLIA_EXT_SYM_PREFIX foo_
*
*
* This prefixes all external symbols with "foo_".
*/
#ifdef HAVE_CONFIG_H
@@ -50,7 +50,7 @@
#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
#endif /*CAMELLIA_EXT_SYM_PREFIX*/
@@ -99,7 +99,7 @@ camellia_setkey(void *c, const byte *key, unsigned keylen)
+(4+32)*sizeof(u32)+2*sizeof(void*) /* camellia_setup192 */
+0+sizeof(int)+2*sizeof(void*) /* Camellia_Ekeygen */
+3*2*sizeof(void*) /* Function calls. */
);
);
return 0;
}
@@ -137,7 +137,7 @@ selftest(void)
{
CAMELLIA_context ctx;
byte scratch[16];
/* These test vectors are from RFC-3713 */
const byte plaintext[]=
{
+13 -13
View File
@@ -19,7 +19,7 @@
*/
/*
* Algorithm Specification
* Algorithm Specification
* http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
*/
@@ -937,7 +937,7 @@ void camellia_setup256(const unsigned char *key, u32 *subkey)
CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw;
dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw);
CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw;
return;
}
@@ -1049,14 +1049,14 @@ void camellia_encrypt128(const u32 *subkey, u32 *io)
io[1] = io[3];
io[2] = t0;
io[3] = t1;
return;
}
void camellia_decrypt128(const u32 *subkey, u32 *io)
{
u32 il,ir,t0,t1; /* temporary valiables */
/* pre whitening but absorb kw2*/
io[0] ^= CamelliaSubkeyL(24);
io[1] ^= CamelliaSubkeyR(24);
@@ -1267,7 +1267,7 @@ void camellia_decrypt256(const u32 *subkey, u32 *io)
/* pre whitening but absorb kw2*/
io[0] ^= CamelliaSubkeyL(32);
io[1] ^= CamelliaSubkeyR(32);
/* main iteration */
CAMELLIA_ROUNDSM(io[0],io[1],
CamelliaSubkeyL(31),CamelliaSubkeyR(31),
@@ -1379,8 +1379,8 @@ void camellia_decrypt256(const u32 *subkey, u32 *io)
* API for compatibility
*/
void Camellia_Ekeygen(const int keyBitLength,
const unsigned char *rawKey,
void Camellia_Ekeygen(const int keyBitLength,
const unsigned char *rawKey,
KEY_TABLE_TYPE keyTable)
{
switch(keyBitLength) {
@@ -1399,9 +1399,9 @@ void Camellia_Ekeygen(const int keyBitLength,
}
void Camellia_EncryptBlock(const int keyBitLength,
const unsigned char *plaintext,
const KEY_TABLE_TYPE keyTable,
void Camellia_EncryptBlock(const int keyBitLength,
const unsigned char *plaintext,
const KEY_TABLE_TYPE keyTable,
unsigned char *ciphertext)
{
u32 tmp[4];
@@ -1430,9 +1430,9 @@ void Camellia_EncryptBlock(const int keyBitLength,
PUTU32(ciphertext + 12, tmp[3]);
}
void Camellia_DecryptBlock(const int keyBitLength,
const unsigned char *ciphertext,
const KEY_TABLE_TYPE keyTable,
void Camellia_DecryptBlock(const int keyBitLength,
const unsigned char *ciphertext,
const KEY_TABLE_TYPE keyTable,
unsigned char *plaintext)
{
u32 tmp[4];
+8 -8
View File
@@ -25,7 +25,7 @@
* space of the library clean. The following macro is thus useful:
*
* #define CAMELLIA_EXT_SYM_PREFIX foo_
*
*
* This prefixes all external symbols with "foo_".
*/
#ifdef HAVE_CONFIG_H
@@ -43,7 +43,7 @@
#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
#endif /*CAMELLIA_EXT_SYM_PREFIX*/
@@ -60,17 +60,17 @@ typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
void Camellia_Ekeygen(const int keyBitLength,
const unsigned char *rawKey,
const unsigned char *rawKey,
KEY_TABLE_TYPE keyTable);
void Camellia_EncryptBlock(const int keyBitLength,
const unsigned char *plaintext,
const KEY_TABLE_TYPE keyTable,
const unsigned char *plaintext,
const KEY_TABLE_TYPE keyTable,
unsigned char *cipherText);
void Camellia_DecryptBlock(const int keyBitLength,
const unsigned char *cipherText,
const KEY_TABLE_TYPE keyTable,
void Camellia_DecryptBlock(const int keyBitLength,
const unsigned char *cipherText,
const KEY_TABLE_TYPE keyTable,
unsigned char *plaintext);
+1 -1
View File
@@ -569,7 +569,7 @@ do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen )
u32 z[4];
u32 k[16];
if( !initialized )
if( !initialized )
{
initialized = 1;
selftest_failed = selftest();
+184 -138
View File
@@ -1,6 +1,6 @@
/* cipher.c - cipher dispatcher
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
* 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
* 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -33,9 +33,12 @@
#define CTX_MAGIC_NORMAL 0x24091964
#define CTX_MAGIC_SECURE 0x46919042
/* Try to use 16 byte aligned cipher context for better performance.
We use the aligned attribute, thus it is only possible to implement
this with gcc. */
#undef NEED_16BYTE_ALIGNED_CONTEXT
#if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__)
#define NEED_16BYTE_ALIGNED_CONTEXT 1
#if defined (__GNUC__)
# define NEED_16BYTE_ALIGNED_CONTEXT 1
#endif
/* A dummy extraspec so that we do not need to tests the extraspec
@@ -58,39 +61,39 @@ static struct cipher_table_entry
&dummy_extra_spec, GCRY_CIPHER_BLOWFISH },
#endif
#if USE_DES
{ &_gcry_cipher_spec_des,
{ &_gcry_cipher_spec_des,
&dummy_extra_spec, GCRY_CIPHER_DES },
{ &_gcry_cipher_spec_tripledes,
&_gcry_cipher_extraspec_tripledes, GCRY_CIPHER_3DES, 1 },
#endif
#if USE_ARCFOUR
{ &_gcry_cipher_spec_arcfour,
{ &_gcry_cipher_spec_arcfour,
&dummy_extra_spec, GCRY_CIPHER_ARCFOUR },
#endif
#if USE_CAST5
{ &_gcry_cipher_spec_cast5,
{ &_gcry_cipher_spec_cast5,
&dummy_extra_spec, GCRY_CIPHER_CAST5 },
#endif
#if USE_AES
{ &_gcry_cipher_spec_aes,
{ &_gcry_cipher_spec_aes,
&_gcry_cipher_extraspec_aes, GCRY_CIPHER_AES, 1 },
{ &_gcry_cipher_spec_aes192,
{ &_gcry_cipher_spec_aes192,
&_gcry_cipher_extraspec_aes192, GCRY_CIPHER_AES192, 1 },
{ &_gcry_cipher_spec_aes256,
{ &_gcry_cipher_spec_aes256,
&_gcry_cipher_extraspec_aes256, GCRY_CIPHER_AES256, 1 },
#endif
#if USE_TWOFISH
{ &_gcry_cipher_spec_twofish,
&dummy_extra_spec, GCRY_CIPHER_TWOFISH },
{ &_gcry_cipher_spec_twofish128,
{ &_gcry_cipher_spec_twofish128,
&dummy_extra_spec, GCRY_CIPHER_TWOFISH128 },
#endif
#if USE_SERPENT
{ &_gcry_cipher_spec_serpent128,
{ &_gcry_cipher_spec_serpent128,
&dummy_extra_spec, GCRY_CIPHER_SERPENT128 },
{ &_gcry_cipher_spec_serpent192,
&dummy_extra_spec, GCRY_CIPHER_SERPENT192 },
{ &_gcry_cipher_spec_serpent256,
{ &_gcry_cipher_spec_serpent256,
&dummy_extra_spec, GCRY_CIPHER_SERPENT256 },
#endif
#if USE_RFC2268
@@ -98,16 +101,20 @@ static struct cipher_table_entry
&dummy_extra_spec, GCRY_CIPHER_RFC2268_40 },
#endif
#if USE_SEED
{ &_gcry_cipher_spec_seed,
{ &_gcry_cipher_spec_seed,
&dummy_extra_spec, GCRY_CIPHER_SEED },
#endif
#if USE_CAMELLIA
{ &_gcry_cipher_spec_camellia128,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA128 },
{ &_gcry_cipher_spec_camellia192,
{ &_gcry_cipher_spec_camellia192,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA192 },
{ &_gcry_cipher_spec_camellia256,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA256 },
#endif
#ifdef USE_IDEA
{ &_gcry_cipher_spec_idea,
&dummy_extra_spec, GCRY_CIPHER_IDEA },
#endif
{ NULL }
};
@@ -137,19 +144,20 @@ static int default_ciphers_registered;
while (0)
/* A VIA processor with the Padlock engine requires an alignment of
most data on a 16 byte boundary. Because we trick out the compiler
while allocating the context, the align attribute as used in
rijndael.c does not work on its own. Thus we need to make sure
that the entire context structure is a aligned on that boundary.
We achieve this by defining a new type and use that instead of our
usual alignment type. */
typedef union
/* A VIA processor with the Padlock engine as well as the Intel AES_NI
instructions require an alignment of most data on a 16 byte
boundary. Because we trick out the compiler while allocating the
context, the align attribute as used in rijndael.c does not work on
its own. Thus we need to make sure that the entire context
structure is a aligned on that boundary. We achieve this by
defining a new type and use that instead of our usual alignment
type. */
typedef union
{
PROPERLY_ALIGNED_TYPE foo;
#ifdef NEED_16BYTE_ALIGNED_CONTEXT
char bar[16] __attribute__ ((aligned (16)));
#endif
#endif
char c[1];
} cipher_context_alignment_t;
@@ -166,7 +174,7 @@ struct gcry_cipher_handle
/* The algorithm id. This is a hack required because the module
interface does not easily allow to retrieve this value. */
int algo;
int algo;
/* A structure with function pointers for bulk operations. Due to
limitations of the module system (we don't want to change the
@@ -174,16 +182,19 @@ struct gcry_cipher_handle
open function intializes them and the actual encryption routines
use them if they are not NULL. */
struct {
void (*cfb_enc)(void *context, unsigned char *iv,
void (*cfb_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*cfb_dec)(void *context, unsigned char *iv,
void (*cfb_dec)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*cbc_enc)(void *context, unsigned char *iv,
void (*cbc_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks, int cbc_mac);
void (*cbc_dec)(void *context, unsigned char *iv,
void (*cbc_dec)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*ctr_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
} bulk;
@@ -197,19 +208,24 @@ struct gcry_cipher_handle
unsigned int iv:1; /* Set to 1 if a IV has been set. */
} marks;
/* The initialization vector. To help code optimization we make
sure that it is aligned on an unsigned long and u32 boundary. */
/* The initialization vector. For best performance we make sure
that it is properly aligned. In particular some implementations
of bulk operations expect an 16 byte aligned IV. */
union {
unsigned long dummy_iv;
u32 dummy_u32_iv;
unsigned char iv[MAX_BLOCKSIZE];
cipher_context_alignment_t iv_align;
unsigned char iv[MAX_BLOCKSIZE];
} u_iv;
/* The counter for CTR mode. This field is also used by AESWRAP and
thus we can't use the U_IV union. */
union {
cipher_context_alignment_t iv_align;
unsigned char ctr[MAX_BLOCKSIZE];
} u_ctr;
/* Space to save an IV or CTR for chaining operations. */
unsigned char lastiv[MAX_BLOCKSIZE];
int unused; /* Number of unused bytes in the IV. */
unsigned char ctr[MAX_BLOCKSIZE]; /* For Counter (CTR) mode. */
int unused; /* Number of unused bytes in LASTIV. */
/* What follows are two contexts of the cipher in use. The first
one needs to be aligned well enough for the cipher operation
@@ -227,7 +243,7 @@ struct gcry_cipher_handle
static gcry_err_code_t
dummy_setkey (void *c, const unsigned char *key, unsigned int keylen)
{
(void)c;
(void)c;
(void)key;
(void)keylen;
return GPG_ERR_NO_ERROR;
@@ -286,7 +302,7 @@ cipher_register_default (void)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
int i;
for (i = 0; !err && cipher_table[i].cipher; i++)
{
if (! cipher_table[i].cipher->setkey)
@@ -389,8 +405,8 @@ _gcry_cipher_register (gcry_cipher_spec_t *cipher,
ath_mutex_lock (&ciphers_registered_lock);
err = _gcry_module_add (&ciphers_registered, 0,
(void *)cipher,
(void *)(extraspec? extraspec : &dummy_extra_spec),
(void *)cipher,
(void *)(extraspec? extraspec : &dummy_extra_spec),
&mod);
ath_mutex_unlock (&ciphers_registered_lock);
@@ -420,7 +436,7 @@ gcry_cipher_unregister (gcry_module_t module)
ispassed as NULL. A pointer to the specification of the module
implementing this algorithm is return in OID_SPEC unless passed as
NULL.*/
static int
static int
search_oid (const char *oid, int *algorithm, gcry_cipher_oid_spec_t *oid_spec)
{
gcry_module_t module;
@@ -484,7 +500,7 @@ gcry_cipher_map_name (const char *string)
}
ath_mutex_unlock (&ciphers_registered_lock);
return algorithm;
}
@@ -593,15 +609,13 @@ check_cipher_algo (int algorithm)
else
err = GPG_ERR_CIPHER_ALGO;
ath_mutex_unlock (&ciphers_registered_lock);
return err;
}
/* Return the standard length of the key for the cipher algorithm with
the identifier ALGORITHM. This function expects a valid algorithm
and will abort if the algorithm is not available or the length of
the key is not known. */
/* Return the standard length in bits of the key for the cipher
algorithm with the identifier ALGORITHM. */
static unsigned int
cipher_get_keylen (int algorithm)
{
@@ -619,17 +633,13 @@ cipher_get_keylen (int algorithm)
log_bug ("cipher %d w/o key length\n", algorithm);
_gcry_module_release (cipher);
}
else
log_bug ("cipher %d not found\n", algorithm);
ath_mutex_unlock (&ciphers_registered_lock);
return len;
}
/* Return the block length of the cipher algorithm with the identifier
ALGORITHM. This function expects a valid algorithm and will abort
if the algorithm is not available or the length of the key is not
known. */
ALGORITHM. This function return 0 for an invalid algorithm. */
static unsigned int
cipher_get_blocksize (int algorithm)
{
@@ -647,8 +657,6 @@ cipher_get_blocksize (int algorithm)
log_bug ("cipher %d w/o blocksize\n", algorithm);
_gcry_module_release (cipher);
}
else
log_bug ("cipher %d not found\n", algorithm);
ath_mutex_unlock (&ciphers_registered_lock);
return len;
@@ -683,7 +691,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle,
/* If the application missed to call the random poll function, we do
it here to ensure that it is used once in a while. */
_gcry_fast_random_poll ();
REGISTER_DEFAULT_CIPHERS;
/* Fetch the according module and check whether the cipher is marked
@@ -711,7 +719,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle,
/* check flags */
if ((! err)
&& ((flags & ~(0
&& ((flags & ~(0
| GCRY_CIPHER_SECURE
| GCRY_CIPHER_ENABLE_SYNC
| GCRY_CIPHER_CBC_CTS
@@ -774,7 +782,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle,
h = gcry_calloc (1, size);
if (! h)
err = gpg_err_code_from_errno (errno);
err = gpg_err_code_from_syserror ();
else
{
size_t off = 0;
@@ -810,9 +818,10 @@ gcry_cipher_open (gcry_cipher_hd_t *handle,
h->bulk.cfb_dec = _gcry_aes_cfb_dec;
h->bulk.cbc_enc = _gcry_aes_cbc_enc;
h->bulk.cbc_dec = _gcry_aes_cbc_dec;
h->bulk.ctr_enc = _gcry_aes_ctr_enc;
break;
#endif /*USE_AES*/
default:
break;
}
@@ -902,7 +911,7 @@ static void
cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen )
{
memset (c->u_iv.iv, 0, c->cipher->blocksize);
if (iv)
if (iv)
{
if (ivlen != c->cipher->blocksize)
{
@@ -932,7 +941,7 @@ cipher_reset (gcry_cipher_hd_t c)
memset (&c->marks, 0, sizeof c->marks);
memset (c->u_iv.iv, 0, c->cipher->blocksize);
memset (c->lastiv, 0, c->cipher->blocksize);
memset (c->ctr, 0, c->cipher->blocksize);
memset (c->u_ctr.ctr, 0, c->cipher->blocksize);
}
@@ -944,7 +953,7 @@ do_ecb_encrypt (gcry_cipher_hd_t c,
{
unsigned int blocksize = c->cipher->blocksize;
unsigned int n, nblocks;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % blocksize))
@@ -975,7 +984,7 @@ do_ecb_decrypt (gcry_cipher_hd_t c,
return GPG_ERR_INV_LENGTH;
nblocks = inbuflen / c->cipher->blocksize;
for (n=0; n < nblocks; n++ )
for (n=0; n < nblocks; n++ )
{
c->cipher->decrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf );
inbuf += blocksize;
@@ -1005,7 +1014,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c,
&& (c->flags & GCRY_CIPHER_CBC_CTS)))
return GPG_ERR_INV_LENGTH;
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
if ((inbuflen % blocksize) == 0)
nblocks--;
@@ -1014,7 +1023,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c,
if (c->bulk.cbc_enc)
{
c->bulk.cbc_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks,
(c->flags & GCRY_CIPHER_CBC_MAC));
(c->flags & GCRY_CIPHER_CBC_MAC));
inbuf += nblocks * blocksize;
if (!(c->flags & GCRY_CIPHER_CBC_MAC))
outbuf += nblocks * blocksize;
@@ -1054,7 +1063,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c,
}
for (; i < blocksize; i++)
outbuf[i] = 0 ^ *ivp++;
c->cipher->encrypt (&c->context.c, outbuf, outbuf);
memcpy (c->u_iv.iv, outbuf, blocksize);
}
@@ -1092,13 +1101,13 @@ do_cbc_decrypt (gcry_cipher_hd_t c,
if (c->bulk.cbc_dec)
{
c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
inbuf += nblocks * blocksize;
outbuf += nblocks * blocksize;
}
else
{
for (n=0; n < nblocks; n++ )
for (n=0; n < nblocks; n++ )
{
/* Because outbuf and inbuf might be the same, we have to
* save the original ciphertext block. We use LASTIV for
@@ -1113,22 +1122,22 @@ do_cbc_decrypt (gcry_cipher_hd_t c,
}
}
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
int restbytes;
if ((inbuflen % blocksize) == 0)
restbytes = blocksize;
else
restbytes = inbuflen % blocksize;
memcpy (c->lastiv, c->u_iv.iv, blocksize ); /* Save Cn-2. */
memcpy (c->u_iv.iv, inbuf + blocksize, restbytes ); /* Save Cn. */
c->cipher->decrypt ( &c->context.c, outbuf, inbuf );
for (ivp=c->u_iv.iv,i=0; i < restbytes; i++ )
outbuf[i] ^= *ivp++;
memcpy(outbuf + blocksize, outbuf, restbytes);
for(i=restbytes; i < blocksize; i++)
c->u_iv.iv[i] = outbuf[i];
@@ -1150,7 +1159,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c,
unsigned char *ivp;
size_t blocksize = c->cipher->blocksize;
size_t blocksize_x_2 = blocksize + blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
@@ -1179,7 +1188,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c,
if (inbuflen >= blocksize_x_2 && c->bulk.cfb_enc)
{
unsigned int nblocks = inbuflen / blocksize;
c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
outbuf += nblocks * blocksize;
inbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
@@ -1209,7 +1218,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c,
*outbuf++ = (*ivp++ ^= *inbuf++);
inbuflen -= blocksize;
}
if ( inbuflen )
if ( inbuflen )
{
/* Save the current IV and then encrypt the IV. */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
@@ -1234,7 +1243,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c,
int i;
size_t blocksize = c->cipher->blocksize;
size_t blocksize_x_2 = blocksize + blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
@@ -1243,7 +1252,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c,
/* Short enough to be encoded by the remaining XOR mask. */
/* XOR the input with the IV and store input into IV. */
for (ivp=c->u_iv.iv+blocksize - c->unused;
inbuflen;
inbuflen;
inbuflen--, c->unused--)
{
temp = *inbuf++;
@@ -1252,7 +1261,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c,
}
return 0;
}
if (c->unused)
{
/* XOR the input with the IV and store input into IV. */
@@ -1264,14 +1273,14 @@ do_cfb_decrypt (gcry_cipher_hd_t c,
*ivp++ = temp;
}
}
/* Now we can process complete blocks. We use a loop as long as we
have at least 2 blocks and use conditions for the rest. This
also allows to use a bulk encryption function if available. */
if (inbuflen >= blocksize_x_2 && c->bulk.cfb_dec)
{
unsigned int nblocks = inbuflen / blocksize;
c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
outbuf += nblocks * blocksize;
inbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
@@ -1309,7 +1318,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c,
}
if (inbuflen)
{
{
/* Save the current IV and then encrypt the IV. */
memcpy ( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
@@ -1363,7 +1372,7 @@ do_ofb_encrypt (gcry_cipher_hd_t c,
/* Encrypt the IV (and save the current one). */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
*outbuf++ = (*ivp++ ^ *inbuf++);
inbuflen -= blocksize;
@@ -1387,7 +1396,7 @@ do_ofb_decrypt (gcry_cipher_hd_t c,
{
unsigned char *ivp;
size_t blocksize = c->cipher->blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
@@ -1417,7 +1426,7 @@ do_ofb_decrypt (gcry_cipher_hd_t c,
*outbuf++ = *ivp++ ^ *inbuf++;
inbuflen -= blocksize;
}
if ( inbuflen )
if ( inbuflen )
{ /* Process the remaining bytes. */
/* Encrypt the IV (and save the current one). */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
@@ -1437,35 +1446,72 @@ do_ctr_encrypt (gcry_cipher_hd_t c,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int n;
unsigned char tmp[MAX_BLOCKSIZE];
int i;
unsigned int blocksize = c->cipher->blocksize;
unsigned int nblocks;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % blocksize))
return GPG_ERR_INV_LENGTH;
for (n=0; n < inbuflen; n++)
/* First process a left over encrypted counter. */
if (c->unused)
{
if ((n % blocksize) == 0)
{
c->cipher->encrypt (&c->context.c, tmp, c->ctr);
for (i = blocksize; i > 0; i--)
{
c->ctr[i-1]++;
if (c->ctr[i-1] != 0)
break;
}
}
/* XOR input with encrypted counter and store in output. */
outbuf[n] = inbuf[n] ^ tmp[n % blocksize];
gcry_assert (c->unused < blocksize);
i = blocksize - c->unused;
for (n=0; c->unused && n < inbuflen; c->unused--, n++, i++)
{
/* XOR input with encrypted counter and store in output. */
outbuf[n] = inbuf[n] ^ c->lastiv[i];
}
inbuf += n;
outbuf += n;
inbuflen -= n;
}
/* Use a bulk method if available. */
nblocks = inbuflen / blocksize;
if (nblocks && c->bulk.ctr_enc)
{
c->bulk.ctr_enc (&c->context.c, c->u_ctr.ctr, outbuf, inbuf, nblocks);
inbuf += nblocks * blocksize;
outbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
}
/* If we don't have a bulk method use the standard method. We also
use this method for the a remaining partial block. */
if (inbuflen)
{
unsigned char tmp[MAX_BLOCKSIZE];
for (n=0; n < inbuflen; n++)
{
if ((n % blocksize) == 0)
{
c->cipher->encrypt (&c->context.c, tmp, c->u_ctr.ctr);
for (i = blocksize; i > 0; i--)
{
c->u_ctr.ctr[i-1]++;
if (c->u_ctr.ctr[i-1] != 0)
break;
}
}
/* XOR input with encrypted counter and store in output. */
outbuf[n] = inbuf[n] ^ tmp[n % blocksize];
}
/* Save the unused bytes of the counter. */
n %= blocksize;
c->unused = (blocksize - n) % blocksize;
if (c->unused)
memcpy (c->lastiv+n, tmp+n, c->unused);
wipememory (tmp, sizeof tmp);
}
wipememory (tmp, sizeof tmp);
return 0;
}
@@ -1495,15 +1541,15 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
#endif
/* We require a cipher with a 128 bit block length. */
if (c->cipher->blocksize != 16)
return GPG_ERR_INV_LENGTH;
return GPG_ERR_INV_LENGTH;
/* The output buffer must be able to hold the input data plus one
additional block. */
if (outbuflen < inbuflen + 8)
return GPG_ERR_BUFFER_TOO_SHORT;
/* Input data must be multiple of 64 bits. */
if (inbuflen % 8)
return GPG_ERR_INV_ARG;
return GPG_ERR_INV_ARG;
n = inbuflen / 8;
@@ -1511,9 +1557,9 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
if (n < 2)
return GPG_ERR_INV_ARG;
r = outbuf;
r = outbuf;
a = outbuf; /* We store A directly in OUTBUF. */
b = c->ctr; /* B is also used to concatenate stuff. */
b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
/* If an IV has been set we use that IV as the Alternative Initial
Value; if it has not been set we use the standard value. */
@@ -1549,7 +1595,7 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
memcpy (r+i*8, b+8, 8);
}
}
return 0;
}
@@ -1570,8 +1616,8 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
#endif
/* We require a cipher with a 128 bit block length. */
if (c->cipher->blocksize != 16)
return GPG_ERR_INV_LENGTH;
return GPG_ERR_INV_LENGTH;
/* The output buffer must be able to hold the input data minus one
additional block. Fixme: The caller has more restrictive checks
- we may want to fix them for this mode. */
@@ -1579,7 +1625,7 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
return GPG_ERR_BUFFER_TOO_SHORT;
/* Input data must be multiple of 64 bits. */
if (inbuflen % 8)
return GPG_ERR_INV_ARG;
return GPG_ERR_INV_ARG;
n = inbuflen / 8;
@@ -1587,9 +1633,9 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
if (n < 3)
return GPG_ERR_INV_ARG;
r = outbuf;
r = outbuf;
a = c->lastiv; /* We use c->LASTIV as buffer for A. */
b = c->ctr; /* B is also used to concatenate stuff. */
b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
/* Copy the inbuf to the outbuf and save A. */
memcpy (a, inbuf, 8);
@@ -1663,7 +1709,7 @@ cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
case GCRY_CIPHER_MODE_CBC:
rc = do_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CFB:
rc = do_cfb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
@@ -1699,7 +1745,7 @@ cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
rc = 0;
}
break;
default:
log_fatal ("cipher_encrypt: invalid mode %d\n", c->mode );
rc = GPG_ERR_INV_CIPHER_MODE;
@@ -1728,7 +1774,7 @@ gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
/* Failsafe: Make sure that the plaintext will never make it into
OUT if the encryption returned an error. */
if (err && out)
memset (out, 0x42, outsize);
memset (out, 0x42, outsize);
return gcry_error (err);
}
@@ -1791,7 +1837,7 @@ cipher_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
rc = 0;
}
break;
default:
log_fatal ("cipher_decrypt: invalid mode %d\n", c->mode );
rc = GPG_ERR_INV_CIPHER_MODE;
@@ -1857,9 +1903,15 @@ gpg_error_t
_gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
{
if (ctr && ctrlen == hd->cipher->blocksize)
memcpy (hd->ctr, ctr, hd->cipher->blocksize);
{
memcpy (hd->u_ctr.ctr, ctr, hd->cipher->blocksize);
hd->unused = 0;
}
else if (!ctr || !ctrlen)
memset (hd->ctr, 0, hd->cipher->blocksize);
{
memset (hd->u_ctr.ctr, 0, hd->cipher->blocksize);
hd->unused = 0;
}
else
return gpg_error (GPG_ERR_INV_ARG);
return 0;
@@ -1918,17 +1970,12 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
break;
case GCRYCTL_SET_CTR: /* Deprecated; use gcry_cipher_setctr. */
if (buffer && buflen == h->cipher->blocksize)
memcpy (h->ctr, buffer, h->cipher->blocksize);
else if (buffer == NULL || buflen == 0)
memset (h->ctr, 0, h->cipher->blocksize);
else
rc = GPG_ERR_INV_ARG;
rc = gpg_err_code (_gcry_cipher_setctr (h, buffer, buflen));
break;
case 61: /* Disable weak key detection (private). */
if (h->extraspec->set_extra_info)
rc = h->extraspec->set_extra_info
rc = h->extraspec->set_extra_info
(&h->context.c, CIPHER_INFO_NO_WEAK_KEY, NULL, 0);
else
rc = GPG_ERR_NOT_SUPPORTED;
@@ -1936,7 +1983,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
case 62: /* Return current input vector (private). */
/* This is the input block as used in CFB and OFB mode which has
initially been set as IV. The returned format is:
initially been set as IV. The returned format is:
1 byte Actual length of the block in bytes.
n byte The block.
If the provided buffer is too short, an error is returned. */
@@ -1947,7 +1994,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
unsigned char *ivp;
unsigned char *dst = buffer;
int n = h->unused;
if (!n)
n = h->cipher->blocksize;
gcry_assert (n <= h->cipher->blocksize);
@@ -1969,10 +2016,10 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
/* Return information about the cipher handle H. CMD is the kind of
information requested. BUFFER and NBYTES are reserved for now.
There are no values for CMD yet defined.
There are no values for CMD yet defined.
The function always returns GPG_ERR_INV_OP.
*/
gcry_error_t
gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes)
@@ -2009,7 +2056,7 @@ gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes)
GCRYCTL_TEST_ALGO:
Returns 0 if the specified algorithm ALGO is available for use.
BUFFER and NBYTES must be zero.
Note: Because this function is in most cases used to return an
integer value, we can make it easier for the caller to just look at
the return value. The caller will in all cases consult the value
@@ -2033,8 +2080,7 @@ gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
if ((ui > 0) && (ui <= 512))
*nbytes = (size_t) ui / 8;
else
/* The only reason is an invalid algo or a strange
blocksize. */
/* The only reason for an error is an invalid algo. */
err = GPG_ERR_CIPHER_ALGO;
}
break;
@@ -2078,7 +2124,7 @@ gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
gcry_cipher_algo_info because it allows for proper type
checking. */
size_t
gcry_cipher_get_algo_keylen (int algo)
gcry_cipher_get_algo_keylen (int algo)
{
size_t n;
@@ -2094,7 +2140,7 @@ gcry_cipher_get_algo_keylen (int algo)
gcry_cipher_algo_info because it allows for proper type
checking. */
size_t
gcry_cipher_get_algo_blklen (int algo)
gcry_cipher_get_algo_blklen (int algo)
{
size_t n;
@@ -2155,7 +2201,7 @@ _gcry_cipher_selftest (int algo, int extended, selftest_report_func_t report)
{
ec = GPG_ERR_CIPHER_ALGO;
if (report)
report ("cipher", algo, "module",
report ("cipher", algo, "module",
module && !(module->flags & FLAG_MODULE_DISABLED)?
"no selftest available" :
module? "algorithm disabled" : "algorithm not found");
+11 -11
View File
@@ -22,7 +22,7 @@
* Bruce Schneier: Applied Cryptography. Second Edition.
* John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff.
* This implementation is according to the definition of DES in FIPS
* PUB 46-2 from December 1993.
* PUB 46-2 from December 1993.
*/
@@ -388,7 +388,7 @@ static byte weak_keys[64][8] =
};
static unsigned char weak_keys_chksum[20] = {
0xD0, 0xCF, 0x07, 0x38, 0x93, 0x70, 0x8A, 0x83, 0x7D, 0xD7,
0x8A, 0x36, 0x65, 0x29, 0x6C, 0x1F, 0x7C, 0x3F, 0xD3, 0x41
0x8A, 0x36, 0x65, 0x29, 0x6C, 0x1F, 0x7C, 0x3F, 0xD3, 0x41
};
@@ -888,12 +888,12 @@ selftest (void)
if (memcmp (input, result, 8))
return "Triple-DES test failed.";
}
/*
* More Triple-DES test. These are testvectors as used by SSLeay,
* thanks to Jeroen C. van Gelderen.
*/
{
{
struct { byte key[24]; byte plain[8]; byte cipher[8]; } testdata[] = {
{ { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
@@ -901,7 +901,7 @@ selftest (void)
{ 0x95,0xF8,0xA5,0xE5,0xDD,0x31,0xD9,0x00 },
{ 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
},
{ { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 },
@@ -966,7 +966,7 @@ selftest (void)
{
tripledes_set3keys (des3, testdata[i].key,
testdata[i].key + 8, testdata[i].key + 16);
tripledes_ecb_encrypt (des3, testdata[i].plain, result);
if (memcmp (testdata[i].cipher, result, 8))
return "Triple-DES SSLeay test failed on encryption.";
@@ -1047,7 +1047,7 @@ do_tripledes_set_extra_info (void *context, int what,
break;
default:
ec = GPG_ERR_INV_OP;
ec = GPG_ERR_INV_OP;
break;
}
return ec;
@@ -1112,7 +1112,7 @@ do_des_decrypt( void *context, byte *outbuf, const byte *inbuf )
/*
/*
Self-test section.
*/
@@ -1123,7 +1123,7 @@ selftest_fips (int extended, selftest_report_func_t report)
{
const char *what;
const char *errtxt;
(void)extended; /* No extended tests available. */
what = "low-level";
@@ -1160,7 +1160,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report)
default:
ec = GPG_ERR_CIPHER_ALGO;
break;
}
return ec;
}
@@ -1189,7 +1189,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_tripledes =
do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt
};
cipher_extra_spec_t _gcry_cipher_extraspec_tripledes =
cipher_extra_spec_t _gcry_cipher_extraspec_tripledes =
{
run_selftests,
do_tripledes_set_extra_info
+56 -45
View File
@@ -74,7 +74,7 @@ static const char sample_secret_key[] =
" 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)"
" (x #11D54E4ADBD3034160F2CED4B7CD292A4EBF3EC0#)))";
/* A sample 1024 bit DSA key used for the selftests (public only). */
static const char sample_public_key[] =
static const char sample_public_key[] =
"(public-key"
" (dsa"
" (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB"
@@ -141,14 +141,19 @@ gen_k( gcry_mpi_t q )
unsigned int nbytes = (nbits+7)/8;
char *rndbuf = NULL;
/* To learn why we don't use mpi_mod to get the requested bit size,
read the paper: "The Insecurity of the Digital Signature
Algorithm with Partially Known Nonces" by Nguyen and Shparlinski.
Journal of Cryptology, New York. Vol 15, nr 3 (2003) */
if ( DBG_CIPHER )
log_debug("choosing a random k ");
for (;;)
for (;;)
{
if( DBG_CIPHER )
progress('.');
if ( !rndbuf || nbits < 32 )
if ( !rndbuf || nbits < 32 )
{
gcry_free(rndbuf);
rndbuf = gcry_random_bytes_secure( (nbits+7)/8, GCRY_STRONG_RANDOM );
@@ -156,13 +161,20 @@ gen_k( gcry_mpi_t q )
else
{ /* Change only some of the higher bits. We could improve
this by directly requesting more memory at the first call
to get_random_bytes() and use this the here maybe it is
easier to do this directly in random.c. */
to get_random_bytes() and use these extra bytes here.
However the required management code is more complex and
thus we better use this simple method. */
char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM );
memcpy( rndbuf,pp, 4 );
gcry_free(pp);
}
_gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 );
/* Make sure we have the requested number of bits. This code
looks a bit funny but it is easy to understand if you
consider that mpi_set_highbit clears all higher bits. We
don't have a clear_highbit, thus we first set the high bit
and then clear it again. */
if ( mpi_test_bit( k, nbits-1 ) )
mpi_set_highbit( k, nbits-1 );
else
@@ -172,7 +184,7 @@ gen_k( gcry_mpi_t q )
}
if( !(mpi_cmp( k, q ) < 0) ) /* check: k < q */
{
{
if( DBG_CIPHER )
progress('+');
continue; /* no */
@@ -188,7 +200,7 @@ gen_k( gcry_mpi_t q )
gcry_free(rndbuf);
if( DBG_CIPHER )
progress('\n');
return k;
}
@@ -315,7 +327,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
mpi_add_ui (h, h, 1);
/* g = h^e mod p */
gcry_mpi_powm (g, h, e, p);
}
}
while (!mpi_cmp_ui (g, 1)); /* Continue until g != 1. */
}
@@ -330,13 +342,13 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
x = mpi_alloc_secure( mpi_get_nlimbs(q) );
mpi_sub_ui( h, q, 1 ); /* put q-1 into h */
rndbuf = NULL;
do
do
{
if( DBG_CIPHER )
progress('.');
if( !rndbuf )
rndbuf = gcry_random_bytes_secure ((qbits+7)/8, random_level);
else
else
{ /* Change only some of the higher bits (= 2 bytes)*/
char *r = gcry_random_bytes_secure (2, random_level);
memcpy(rndbuf, r, 2 );
@@ -345,7 +357,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
_gcry_mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 );
mpi_clear_highbit( x, qbits+1 );
}
}
while ( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, h )<0 ) );
gcry_free(rndbuf);
mpi_free( e );
@@ -355,7 +367,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
y = mpi_alloc( mpi_get_nlimbs(p) );
gcry_mpi_powm( y, g, x, p );
if( DBG_CIPHER )
if( DBG_CIPHER )
{
progress('\n');
log_mpidump("dsa p", p );
@@ -406,8 +418,8 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
const void *seed;
size_t seedlen;
} initial_seed = { NULL, NULL, 0 };
gcry_mpi_t prime_q = NULL;
gcry_mpi_t prime_p = NULL;
gcry_mpi_t prime_q = NULL;
gcry_mpi_t prime_p = NULL;
gcry_mpi_t value_g = NULL; /* The generator. */
gcry_mpi_t value_y = NULL; /* g^x mod p */
gcry_mpi_t value_x = NULL; /* The secret exponent. */
@@ -467,15 +479,15 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
initial_seed.seed = gcry_sexp_nth_data (initial_seed.sexp, 1,
&initial_seed.seedlen);
}
/* Fixme: Enable 186-3 after it has been approved and after fixing
the generation function. */
/* if (use_fips186_2) */
(void)use_fips186_2;
ec = _gcry_generate_fips186_2_prime (nbits, qbits,
initial_seed.seed,
ec = _gcry_generate_fips186_2_prime (nbits, qbits,
initial_seed.seed,
initial_seed.seedlen,
&prime_q, &prime_p,
&prime_q, &prime_p,
r_counter,
r_seed, r_seedlen);
/* else */
@@ -493,33 +505,33 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
mpi_sub_ui (value_e, prime_p, 1);
mpi_fdiv_q (value_e, value_e, prime_q );
value_g = mpi_alloc_like (prime_p);
value_h = mpi_alloc_set_ui (1);
value_h = mpi_alloc_set_ui (1);
do
{
mpi_add_ui (value_h, value_h, 1);
/* g = h^e mod p */
mpi_powm (value_g, value_h, value_e, prime_p);
}
}
while (!mpi_cmp_ui (value_g, 1)); /* Continue until g != 1. */
}
/* Select a random number x with: 0 < x < q */
value_x = gcry_mpi_snew (qbits);
do
do
{
if( DBG_CIPHER )
progress('.');
gcry_mpi_randomize (value_x, qbits, GCRY_VERY_STRONG_RANDOM);
mpi_clear_highbit (value_x, qbits+1);
}
}
while (!(mpi_cmp_ui (value_x, 0) > 0 && mpi_cmp (value_x, prime_q) < 0));
/* y = g^x mod p */
value_y = mpi_alloc_like (prime_p);
gcry_mpi_powm (value_y, value_g, value_x, prime_p);
if (DBG_CIPHER)
if (DBG_CIPHER)
{
progress('\n');
log_mpidump("dsa p", prime_p );
@@ -691,7 +703,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
int use_fips186_2 = 0;
int use_fips186 = 0;
dsa_domain_t domain;
(void)algo; /* No need to check it. */
(void)evalue; /* Not required for DSA. */
@@ -700,7 +712,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
if (genparms)
{
gcry_sexp_t domainsexp;
/* Parse the optional qbits element. */
l1 = gcry_sexp_find_token (genparms, "qbits", 0);
if (l1)
@@ -708,7 +720,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
char buf[50];
const char *s;
size_t n;
s = gcry_sexp_nth_data (l1, 1, &n);
if (!s || n >= DIM (buf) - 1 )
{
@@ -760,7 +772,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
gcry_sexp_release (deriveparms);
return GPG_ERR_INV_VALUE;
}
/* Put all domain parameters into the domain object. */
l1 = gcry_sexp_find_token (domainsexp, "p", 0);
domain.p = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
@@ -804,7 +816,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
{
/* Format the seed-values unless domain parameters are used
for which a H_VALUE of NULL is an indication. */
ec = gpg_err_code (gcry_sexp_build
ec = gpg_err_code (gcry_sexp_build
(&seedinfo, NULL,
"(seed-values(counter %d)(seed %b)(h %m))",
counter, (int)seedlen, seed, h_value));
@@ -879,7 +891,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
p = stpcpy (p, ")");
}
p = stpcpy (p, ")");
/* Allocate space for the list of factors plus one for
an S-expression plus an extra NULL entry for safety
and fill it with the factors. */
@@ -894,8 +906,8 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
for (j=0; j < nfactors; j++)
arg_list[i++] = (*retfactors) + j;
arg_list[i] = NULL;
ec = gpg_err_code (gcry_sexp_build_array
ec = gpg_err_code (gcry_sexp_build_array
(r_extrainfo, NULL, format, arg_list));
}
}
@@ -1023,19 +1035,19 @@ dsa_get_nbits (int algo, gcry_mpi_t *pkey)
/*
/*
Self-test section.
*/
static const char *
selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey)
{
static const char sample_data[] =
"(data (flags pkcs1)"
" (hash sha1 #a0b1c2d3e4f500102030405060708090a1b2c3d4#))";
static const char sample_data_bad[] =
"(data (flags pkcs1)"
" (hash sha1 #a0b1c2d3e4f510102030405060708090a1b2c3d4#))";
static const char sample_data[] =
"(data (flags raw)"
" (value #a0b1c2d3e4f500102030405060708090a1b2c3d4#))";
static const char sample_data_bad[] =
"(data (flags raw)"
" (value #a0b1c2d3e4f510102030405060708090a1b2c3d4#))";
const char *errtxt = NULL;
gcry_error_t err;
@@ -1046,7 +1058,7 @@ selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey)
err = gcry_sexp_sscan (&data, NULL,
sample_data, strlen (sample_data));
if (!err)
err = gcry_sexp_sscan (&data_bad, NULL,
err = gcry_sexp_sscan (&data_bad, NULL,
sample_data_bad, strlen (sample_data_bad));
if (err)
{
@@ -1093,10 +1105,10 @@ selftests_dsa (selftest_report_func_t report)
/* Convert the S-expressions into the internal representation. */
what = "convert";
err = gcry_sexp_sscan (&skey, NULL,
err = gcry_sexp_sscan (&skey, NULL,
sample_secret_key, strlen (sample_secret_key));
if (!err)
err = gcry_sexp_sscan (&pkey, NULL,
err = gcry_sexp_sscan (&pkey, NULL,
sample_public_key, strlen (sample_public_key));
if (err)
{
@@ -1146,7 +1158,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report)
default:
ec = GPG_ERR_PUBKEY_ALGO;
break;
}
return ec;
}
@@ -1163,7 +1175,7 @@ static const char *dsa_names[] =
gcry_pk_spec_t _gcry_pubkey_spec_dsa =
{
"DSA", dsa_names,
"DSA", dsa_names,
"pqgy", "pqgyx", "", "rs", "pqgy",
GCRY_PK_USAGE_SIGN,
dsa_generate,
@@ -1174,9 +1186,8 @@ gcry_pk_spec_t _gcry_pubkey_spec_dsa =
dsa_verify,
dsa_get_nbits
};
pk_extra_spec_t _gcry_pubkey_extraspec_dsa =
pk_extra_spec_t _gcry_pubkey_extraspec_dsa =
{
run_selftests,
dsa_generate_ext
};
File diff suppressed because it is too large. Load diff
+19 -20
View File
@@ -115,7 +115,7 @@ wiener_map( unsigned int n )
};
int i;
for(i=0; t[i].p_n; i++ )
for(i=0; t[i].p_n; i++ )
{
if( n <= t[i].p_n )
return t[i].q_n;
@@ -158,7 +158,7 @@ test_keys ( ELG_secret_key *sk, unsigned int nbits, int nodie )
log_fatal ("Elgamal test key for %s %s failed\n",
(failed & 1)? "encrypt+decrypt":"",
(failed & 2)? "sign+verify":"");
if (failed && DBG_CIPHER)
if (failed && DBG_CIPHER)
log_debug ("Elgamal test key for %s %s failed\n",
(failed & 1)? "encrypt+decrypt":"",
(failed & 2)? "sign+verify":"");
@@ -199,15 +199,15 @@ gen_k( gcry_mpi_t p, int small_k )
if( DBG_CIPHER )
log_debug("choosing a random k ");
mpi_sub_ui( p_1, p, 1);
for(;;)
for(;;)
{
if( !rndbuf || nbits < 32 )
if( !rndbuf || nbits < 32 )
{
gcry_free(rndbuf);
rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM );
}
else
{
{
/* Change only some of the higher bits. We could improve
this by directly requesting more memory at the first call
to get_random_bytes() and use this the here maybe it is
@@ -218,7 +218,7 @@ gen_k( gcry_mpi_t p, int small_k )
gcry_free(pp);
}
_gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 );
for(;;)
{
if( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */
@@ -294,7 +294,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors )
if( DBG_CIPHER )
log_debug("choosing a random x of size %u", xbits );
rndbuf = NULL;
do
do
{
if( DBG_CIPHER )
progress('.');
@@ -314,21 +314,21 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors )
gcry_free(r);
}
}
else
else
{
rndbuf = gcry_random_bytes_secure( (xbits+7)/8,
GCRY_VERY_STRONG_RANDOM );
}
_gcry_mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 );
mpi_clear_highbit( x, xbits+1 );
}
}
while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) );
gcry_free(rndbuf);
y = gcry_mpi_new (nbits);
gcry_mpi_powm( y, g, x, p );
if( DBG_CIPHER )
if( DBG_CIPHER )
{
progress('\n');
log_mpidump("elg p= ", p );
@@ -354,7 +354,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors )
value for the secret key but the one given as X. This is useful to
implement a passphrase based decryption for a public key based
encryption. It has appliactions in backup systems.
Returns: A structure filled with all needed values and an array
with n-1 factors of (p-1). */
static gcry_err_code_t
@@ -399,7 +399,7 @@ generate_using_x (ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t x,
y = gcry_mpi_new (nbits);
gcry_mpi_powm ( y, g, x, p );
if ( DBG_CIPHER )
if ( DBG_CIPHER )
{
progress ('\n');
log_mpidump ("elg p= ", p );
@@ -493,7 +493,7 @@ decrypt(gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey )
mpi_invm( t1, t1, skey->p );
mpi_mulm( output, b, t1, skey->p );
#if 0
if( DBG_CIPHER )
if( DBG_CIPHER )
{
log_mpidump("elg decrypted x= ", skey->x);
log_mpidump("elg decrypted p= ", skey->p);
@@ -533,7 +533,7 @@ sign(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_secret_key *skey )
mpi_mulm(b, t, inv, p_1 );
#if 0
if( DBG_CIPHER )
if( DBG_CIPHER )
{
log_mpidump("elg sign p= ", skey->p);
log_mpidump("elg sign g= ", skey->g);
@@ -652,7 +652,7 @@ elg_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
skey[1] = sk.g;
skey[2] = sk.y;
skey[3] = sk.x;
return ec;
}
@@ -671,7 +671,7 @@ elg_generate (int algo, unsigned int nbits, unsigned long evalue,
skey[1] = sk.g;
skey[2] = sk.y;
skey[3] = sk.x;
return GPG_ERR_NO_ERROR;
}
@@ -692,7 +692,7 @@ elg_check_secret_key (int algo, gcry_mpi_t *skey)
sk.g = skey[1];
sk.y = skey[2];
sk.x = skey[3];
if (! check_secret_key (&sk))
err = GPG_ERR_BAD_SECKEY;
}
@@ -773,7 +773,7 @@ elg_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
resarr[1] = mpi_alloc (mpi_get_nlimbs (sk.p));
sign (resarr[0], resarr[1], data, &sk);
}
return err;
}
@@ -837,10 +837,9 @@ gcry_pk_spec_t _gcry_pubkey_spec_elg =
elg_get_nbits
};
pk_extra_spec_t _gcry_pubkey_extraspec_elg =
pk_extra_spec_t _gcry_pubkey_extraspec_elg =
{
NULL,
elg_generate_ext,
NULL
};
+8 -9
View File
@@ -21,7 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
@@ -35,10 +35,10 @@
describing the error.
DATAMODE controls what will be hashed according to this table:
0 - Hash the supplied DATA of DATALEN.
1 - Hash one million times a 'a'. DATA and DATALEN are ignored.
*/
const char *
_gcry_hash_selftest_check_one (int algo,
@@ -49,14 +49,14 @@ _gcry_hash_selftest_check_one (int algo,
gcry_error_t err = 0;
gcry_md_hd_t hd;
unsigned char *digest;
if (_gcry_md_get_algo_dlen (algo) != expectlen)
return "digest size does not match expected size";
err = _gcry_md_open (&hd, algo, 0);
if (err)
return "gcry_md_open failed";
switch (datamode)
{
case 0:
@@ -64,7 +64,7 @@ _gcry_hash_selftest_check_one (int algo,
break;
case 1: /* Hash one million times an "a". */
{
{
char aaa[1000];
int i;
@@ -82,7 +82,7 @@ _gcry_hash_selftest_check_one (int algo,
if (!result)
{
digest = _gcry_md_read (hd, algo);
if ( memcmp (digest, expect, expectlen) )
result = "digest mismatch";
}
@@ -91,4 +91,3 @@ _gcry_hash_selftest_check_one (int algo,
return result;
}
+3 -3
View File
@@ -21,11 +21,11 @@
#define GCRY_HASH_COMMON_H
const char * _gcry_hash_selftest_check_one
/**/ (int algo,
const char * _gcry_hash_selftest_check_one
/**/ (int algo,
int datamode, const void *data, size_t datalen,
const void *expect, size_t expectlen);
+18 -18
View File
@@ -17,7 +17,7 @@
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/*
/*
Although algorithm self-tests are usually implemented in the module
implementing the algorithm, the case for HMAC is different because
HMAC is implemnetd on a higher level using a special feature of the
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
@@ -47,7 +47,7 @@
succdess or a string describing the failure. */
static const char *
check_one (int algo,
const void *data, size_t datalen,
const void *data, size_t datalen,
const void *key, size_t keylen,
const void *expect, size_t expectlen)
{
@@ -88,7 +88,7 @@ check_one (int algo,
return "does not match";
}
_gcry_md_close (hd);
return NULL;
return NULL;
}
@@ -123,7 +123,7 @@ selftests_sha1 (int extended, selftest_report_func_t report)
"\xa4\x58\x30\x73\x7d\x5c\xc6\xc7\x5d\x24", 20);
if (errtxt)
goto failed;
what = "FIPS-198a, A.3";
for (i=0, j=0x50; i < 100; i++)
key[i] = j++;
@@ -134,7 +134,7 @@ selftests_sha1 (int extended, selftest_report_func_t report)
"\x5c\xaf\x7c\xb0\x92\xec\xf8\xd1\xa3\xaa", 20 );
if (errtxt)
goto failed;
what = "FIPS-198a, A.4";
for (i=0, j=0x70; i < 49; i++)
key[i] = j++;
@@ -160,7 +160,7 @@ selftests_sha1 (int extended, selftest_report_func_t report)
static gpg_err_code_t
selftests_sha224 (int extended, selftest_report_func_t report)
{
static struct
static struct
{
const char * const desc;
const char * const data;
@@ -169,7 +169,7 @@ selftests_sha224 (int extended, selftest_report_func_t report)
} tv[] =
{
{ "data-28 key-4",
"what do ya want for nothing?",
"what do ya want for nothing?",
"Jefe",
{ 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
@@ -248,7 +248,7 @@ selftests_sha224 (int extended, selftest_report_func_t report)
const char *what;
const char *errtxt;
int tvidx;
for (tvidx=0; tv[tvidx].desc; tvidx++)
{
what = tv[tvidx].desc;
@@ -274,7 +274,7 @@ selftests_sha224 (int extended, selftest_report_func_t report)
static gpg_err_code_t
selftests_sha256 (int extended, selftest_report_func_t report)
{
static struct
static struct
{
const char * const desc;
const char * const data;
@@ -283,7 +283,7 @@ selftests_sha256 (int extended, selftest_report_func_t report)
} tv[] =
{
{ "data-28 key-4",
"what do ya want for nothing?",
"what do ya want for nothing?",
"Jefe",
{ 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
@@ -362,7 +362,7 @@ selftests_sha256 (int extended, selftest_report_func_t report)
const char *what;
const char *errtxt;
int tvidx;
for (tvidx=0; tv[tvidx].desc; tvidx++)
{
hmac256_context_t hmachd;
@@ -416,7 +416,7 @@ selftests_sha256 (int extended, selftest_report_func_t report)
static gpg_err_code_t
selftests_sha384 (int extended, selftest_report_func_t report)
{
static struct
static struct
{
const char * const desc;
const char * const data;
@@ -425,7 +425,7 @@ selftests_sha384 (int extended, selftest_report_func_t report)
} tv[] =
{
{ "data-28 key-4",
"what do ya want for nothing?",
"what do ya want for nothing?",
"Jefe",
{ 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
@@ -516,7 +516,7 @@ selftests_sha384 (int extended, selftest_report_func_t report)
const char *what;
const char *errtxt;
int tvidx;
for (tvidx=0; tv[tvidx].desc; tvidx++)
{
what = tv[tvidx].desc;
@@ -542,7 +542,7 @@ selftests_sha384 (int extended, selftest_report_func_t report)
static gpg_err_code_t
selftests_sha512 (int extended, selftest_report_func_t report)
{
static struct
static struct
{
const char * const desc;
const char * const data;
@@ -551,7 +551,7 @@ selftests_sha512 (int extended, selftest_report_func_t report)
} tv[] =
{
{ "data-28 key-4",
"what do ya want for nothing?",
"what do ya want for nothing?",
"Jefe",
{ 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
@@ -654,7 +654,7 @@ selftests_sha512 (int extended, selftest_report_func_t report)
const char *what;
const char *errtxt;
int tvidx;
for (tvidx=0; tv[tvidx].desc; tvidx++)
{
what = tv[tvidx].desc;
Loaded 100 of 245 files, more files were not shown because too many files have changed in this diff. Show more