mirror of
http://cgit.git.savannah.gnu.org/git/grub.git
synced 2026-04-28 14:33:34 +00:00
Compare commits
1 Commits
andrey/ext
...
master-bad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
206676601e |
78
Makefile.am
78
Makefile.am
@@ -89,21 +89,16 @@ CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT)
|
||||
|
||||
if COND_STARFIELD
|
||||
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
|
||||
dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -s 10 -o $@ $(DJVU_FONT_SOURCE)
|
||||
CLEANFILES += dejavu_10.pf2
|
||||
dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -s 12 -o $@ $(DJVU_FONT_SOURCE)
|
||||
CLEANFILES += dejavu_12.pf2
|
||||
dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -s 14 -o $@ $(DJVU_FONT_SOURCE)
|
||||
CLEANFILES += dejavu_14.pf2
|
||||
dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -b -s 14 -o $@ $(DJVU_FONT_SOURCE)
|
||||
CLEANFILES += dejavu_bold_14.pf2
|
||||
dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -s 16 -o $@ $(DJVU_FONT_SOURCE)
|
||||
CLEANFILES += dejavu_16.pf2
|
||||
dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE)
|
||||
dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE)
|
||||
dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE)
|
||||
dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE)
|
||||
dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE)
|
||||
else
|
||||
starfield_DATA =
|
||||
endif
|
||||
@@ -111,28 +106,28 @@ endif
|
||||
EXTRA_DIST += $(starfield_theme_files)
|
||||
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
|
||||
|
||||
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
|
||||
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
|
||||
CLEANFILES += unicode.pf2
|
||||
|
||||
# Arrows and lines are needed to draw the menu, so always include them
|
||||
UNICODE_ARROWS=0x2190-0x2193
|
||||
UNICODE_LINES=0x2501-0x251B
|
||||
|
||||
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
CLEANFILES += ascii.pf2
|
||||
|
||||
euro.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
|
||||
./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
euro.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
CLEANFILES += euro.pf2
|
||||
|
||||
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih$(BUILD_EXEEXT)
|
||||
./build-grub-gen-asciih$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
|
||||
./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
CLEANFILES += ascii.h
|
||||
|
||||
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec$(BUILD_EXEEXT)
|
||||
./build-grub-gen-widthspec$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
|
||||
./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
CLEANFILES += widthspec.h
|
||||
|
||||
# Install config.h into platformdir
|
||||
@@ -345,35 +340,33 @@ bootcheck-ntldr: ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg grub-shell
|
||||
./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ntldr.bin=ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
|
||||
|
||||
if COND_i386_efi
|
||||
# NetBSD has no support for finding ACPI on EFI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
|
||||
endif
|
||||
|
||||
if COND_x86_64_efi
|
||||
# NetBSD has no support for finding ACPI on EFI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
|
||||
endif
|
||||
|
||||
if COND_i386_multiboot
|
||||
# *BSD requires ACPI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
|
||||
endif
|
||||
|
||||
|
||||
if COND_i386_qemu
|
||||
# *BSD requires ACPI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
|
||||
# FreeBSD requires ACPI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
|
||||
endif
|
||||
|
||||
if COND_i386_coreboot
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
|
||||
# Freebsd requires ACPI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
|
||||
endif
|
||||
|
||||
if COND_i386_qemu
|
||||
# FreeBSD requires ACPI
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
|
||||
endif
|
||||
|
||||
if COND_i386_pc
|
||||
#pc chainloader by definition is only for i386-pc
|
||||
#ntldr and bootmgr require BIOS.
|
||||
#legacy protocol (linux16) makes early BIOS calls.
|
||||
# 32-bit NetBSD crashes early on non-BIOS
|
||||
#legacy protocol makes early BIOS calls.
|
||||
# NetBSD crashes early on non-BIOS
|
||||
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 bootcheck-pc-chainloader bootcheck-ntldr bootcheck-linux16-i386 bootcheck-linux16-x86_64 bootcheck-knetbsd-i386
|
||||
endif
|
||||
|
||||
@@ -409,9 +402,8 @@ BOOTCHECK_TIMEOUT=180
|
||||
bootcheck: $(BOOTCHECKS)
|
||||
|
||||
if COND_i386_coreboot
|
||||
default_payload.elf: grub-mkstandalone grub-mkimage FORCE
|
||||
test -f $@ && rm $@ || true
|
||||
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
|
||||
default_payload.elf: grub-mkstandalone grub-mkimage
|
||||
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@@ -172,8 +172,6 @@ program = {
|
||||
|
||||
common = util/grub-mkimage.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-mkimage32.c;
|
||||
common = util/grub-mkimage64.c;
|
||||
common = util/resolve.c;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
@@ -416,7 +414,7 @@ program = {
|
||||
ldadd = libgrubgcry.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
};
|
||||
|
||||
data = {
|
||||
@@ -512,8 +510,6 @@ program = {
|
||||
common = util/render-label.c;
|
||||
common = util/glue-efi.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-mkimage32.c;
|
||||
common = util/grub-mkimage64.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
@@ -556,8 +552,6 @@ program = {
|
||||
common = util/render-label.c;
|
||||
common = util/glue-efi.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-mkimage32.c;
|
||||
common = util/grub-mkimage64.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
@@ -601,8 +595,6 @@ program = {
|
||||
common = util/grub-install.c;
|
||||
common = util/probe.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-mkimage32.c;
|
||||
common = util/grub-mkimage64.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
@@ -640,8 +632,6 @@ program = {
|
||||
common = util/grub-mknetdir.c;
|
||||
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-mkimage32.c;
|
||||
common = util/grub-mkimage64.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
|
||||
19
NEWS
19
NEWS
@@ -18,7 +18,6 @@ New in 2.02:
|
||||
* ZFS features support.
|
||||
* ZFS LZ4 support.
|
||||
* XFS V5 format support.
|
||||
* LVM RAID1 support.
|
||||
|
||||
* New/improved terminal and video support:
|
||||
* Monochrome text (matching `hercules' in GRUB Legacy).
|
||||
@@ -50,7 +49,6 @@ New in 2.02:
|
||||
* Improve TFTP robustness.
|
||||
* Parse `nd' disk names in GRUB Legacy configuration files.
|
||||
* Issue separate DNS queries for IPv4 and IPv6.
|
||||
* Support IPv6 Router Advertisement to configure default router.
|
||||
|
||||
* Coreboot improvements:
|
||||
* CBFS support both in on-disk images (loopback) and flash.
|
||||
@@ -61,7 +59,6 @@ New in 2.02:
|
||||
* Command for inspecting coreboot tables (`lscoreboot').
|
||||
* New target default_payload.elf.
|
||||
* Increased maximal core size.
|
||||
* Prefer pmtimer for TSC calibration.
|
||||
|
||||
* New/improved platform support:
|
||||
* New `efifwsetup' and `lsefi' commands on EFI platforms.
|
||||
@@ -92,14 +89,6 @@ New in 2.02:
|
||||
* New platform `none' which builds only user level utilities. This is now
|
||||
default if target CPU is not supported.
|
||||
* Support for booting little-endian Linux kernel on powerpc.
|
||||
* Support network boot with Oracle sun4v vnet devices.
|
||||
* Added SAS disks to the IEEE 1275 Open Firmware device list.
|
||||
* Try multiple methods for TSC (timestamp counter) calibration - PIT, pmtimer,
|
||||
EFI Stall. If everything fails, use hardcoded frequency 800MHz.
|
||||
* Support Hyper-V Gen2 platforms which lack PIT for TSC calibration.
|
||||
* Map UEFI Persistent Memory to E820 persistent memory.
|
||||
* New Xen loader on ARM64.
|
||||
* Respect alignment requirement for block device IO buffers on EFI.
|
||||
|
||||
* Security:
|
||||
* Add optional facility to enforce that all files read by the core image
|
||||
@@ -138,11 +127,6 @@ New in 2.02:
|
||||
menu entry immediately.
|
||||
* New `file' command and grub-file utility to check file types.
|
||||
* New syslinux configuration file parser.
|
||||
* Set menu entry class to primary OS name returned by os-prober to display
|
||||
OS specific icon.
|
||||
* On Linux x86 detect EFI word size in grub-install and automatically select
|
||||
correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel
|
||||
4.0 or higher.
|
||||
|
||||
* Build system:
|
||||
* Remove all uses of nested functions; GRUB no longer requires an
|
||||
@@ -168,9 +152,6 @@ New in 2.02:
|
||||
system.
|
||||
* emu libusb support removed (was broken and unmaintained).
|
||||
* powerpc64le compile support.
|
||||
* Use fixed timestamp when generating GRUB image for reproducible builds.
|
||||
* Verify at build time that modules contain only supported relocations and their
|
||||
structure matches what boot-time module loader expects.
|
||||
|
||||
* Revision control moved to git.
|
||||
|
||||
|
||||
2
README
2
README
@@ -17,4 +17,4 @@ There are a number of important user-visible differences from the
|
||||
first version of GRUB, now known as GRUB Legacy. For a summary, please
|
||||
see:
|
||||
|
||||
info grub Introduction 'Changes from GRUB Legacy'
|
||||
info grub Introduction 'Changes from GRUB Legacy'
|
||||
4
TODO
4
TODO
@@ -7,3 +7,7 @@ glance. So write to <grub-devel@gnu.org> first.
|
||||
For bug tracking, refer to:
|
||||
|
||||
http://savannah.gnu.org/bugs/?group=grub
|
||||
|
||||
Our wiki also lists some areas that need work:
|
||||
|
||||
http://grub.enbug.org/
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
.code16
|
||||
jmp far
|
||||
.org 4
|
||||
jmp nearer
|
||||
.org 6
|
||||
.space 100
|
||||
nearer:
|
||||
.space 200
|
||||
.space 300
|
||||
far:
|
||||
.byte 0
|
||||
|
||||
@@ -23,14 +23,14 @@ fi
|
||||
if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
|
||||
rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
|
||||
fi
|
||||
cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
|
||||
ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
|
||||
cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
|
||||
|
||||
for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c mpih-lshift.c mpih-rshift.c; do
|
||||
if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
|
||||
rm grub-core/lib/libgcrypt-grub/mpi/"$x"
|
||||
fi
|
||||
cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
|
||||
ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
|
||||
done
|
||||
|
||||
echo "Generating Automake input..."
|
||||
|
||||
@@ -21,6 +21,9 @@ if COND_powerpc_ieee1275
|
||||
CFLAGS_PLATFORM += -mcpu=powerpc
|
||||
endif
|
||||
|
||||
#FIXME: discover and check XEN headers
|
||||
CPPFLAGS_XEN = -I/usr/include
|
||||
|
||||
# Other options
|
||||
|
||||
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
|
||||
@@ -38,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
|
||||
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
|
||||
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
|
||||
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags
|
||||
|
||||
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
|
||||
|
||||
@@ -37,6 +37,7 @@ EXTRA_DIST += grub-core/lib/libgcrypt
|
||||
EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
|
||||
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
|
||||
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h')
|
||||
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h')
|
||||
EXTRA_DIST += grub-core/efiemu/runtime/config.h
|
||||
|
||||
EXTRA_DIST += grub-core/lib/LzmaDec.c
|
||||
@@ -50,13 +51,8 @@ EXTRA_DIST += util/import_gcrypth.sed
|
||||
EXTRA_DIST += util/bin2h.c
|
||||
EXTRA_DIST += util/grub-gen-asciih.c
|
||||
EXTRA_DIST += util/grub-gen-widthspec.c
|
||||
EXTRA_DIST += util/grub-module-verifier.c
|
||||
EXTRA_DIST += util/grub-module-verifier32.c
|
||||
EXTRA_DIST += util/grub-module-verifier64.c
|
||||
EXTRA_DIST += util/grub-module-verifierXX.c
|
||||
EXTRA_DIST += util/grub-pe2elf.c
|
||||
|
||||
|
||||
EXTRA_DIST += m4/gnulib-cache.m4
|
||||
EXTRA_DIST += m4/glibc2.m4
|
||||
EXTRA_DIST += m4/gnulib-tool.m4
|
||||
|
||||
163
configure.ac
163
configure.ac
@@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables
|
||||
dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are
|
||||
dnl used for the target type. See INSTALL for full list of variables.
|
||||
|
||||
AC_INIT([GRUB],[2.02~beta3],[bug-grub@gnu.org])
|
||||
AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org])
|
||||
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
|
||||
@@ -315,7 +315,7 @@ AC_PROG_LN_S
|
||||
if test "x$LEX" = "x:"; then
|
||||
AC_MSG_ERROR([flex is not found])
|
||||
else
|
||||
version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
|
||||
version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
|
||||
if test -n "$version" -a "$version" -ge 20535; then
|
||||
:
|
||||
else
|
||||
@@ -388,8 +388,7 @@ fi
|
||||
|
||||
# Check for functions and headers.
|
||||
AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
|
||||
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
|
||||
AC_HEADER_MAJOR
|
||||
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
|
||||
|
||||
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
|
||||
#include <sys/param.h>
|
||||
@@ -784,7 +783,7 @@ 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.
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
|
||||
fi
|
||||
|
||||
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
|
||||
@@ -911,24 +910,12 @@ if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xy
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
|
||||
CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_mno_stack_arg_probe=yes],
|
||||
[grub_cv_cc_mno_stack_arg_probe=no])
|
||||
])
|
||||
|
||||
if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
|
||||
fi
|
||||
|
||||
|
||||
# By default, GCC 4.6 generates .eh_frame sections containing unwind
|
||||
# information in some cases where it previously did not. GRUB doesn't need
|
||||
# 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], [
|
||||
CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
|
||||
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])
|
||||
@@ -938,17 +925,66 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
|
||||
CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_fno_unwind_tables=yes],
|
||||
[grub_cv_cc_fno_unwind_tables=no])
|
||||
])
|
||||
|
||||
if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
|
||||
AC_ARG_ENABLE([efiemu],
|
||||
[AS_HELP_STRING([--enable-efiemu],
|
||||
[build and install the efiemu runtimes (default=guessed)])])
|
||||
if test x"$enable_efiemu" = xno ; then
|
||||
efiemu_excuse="explicitly disabled"
|
||||
fi
|
||||
|
||||
if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
|
||||
efiemu_excuse="not available on cygwin"
|
||||
fi
|
||||
if test x"$target_cpu" != xi386 ; then
|
||||
efiemu_excuse="only available on i386"
|
||||
fi
|
||||
if test x"$platform" = xefi ; then
|
||||
efiemu_excuse="not available on efi"
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_efiemu=yes],
|
||||
[grub_cv_cc_efiemu=no])
|
||||
])
|
||||
if test x$grub_cv_cc_efiemu = xno; then
|
||||
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
|
||||
fi
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
|
||||
grub_cv_target_cc_efiemu64_link_format=unknown
|
||||
for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
LDFLAGS="-m64 -Wl,$format -nostdlib -static"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
asm (".globl _start; _start:");
|
||||
asm (".globl __start; __start:");
|
||||
void __main (void);
|
||||
void __main (void) {}
|
||||
]], [[]])], [flag=1], [flag=0])
|
||||
if test x"$flag" = x1; then
|
||||
grub_cv_target_cc_efiemu64_link_format="$format"
|
||||
break
|
||||
fi
|
||||
done])
|
||||
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
|
||||
efiemu_excuse="no suitable link format for efiemu64 found"
|
||||
else
|
||||
EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
|
||||
fi
|
||||
fi
|
||||
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
|
||||
AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
enable_efiemu=yes
|
||||
else
|
||||
enable_efiemu=no
|
||||
fi
|
||||
AC_SUBST([enable_efiemu])
|
||||
AC_SUBST([EFIEMU64_LINK_FORMAT])
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
@@ -1042,73 +1078,6 @@ else
|
||||
TARGET_IMG_CFLAGS=
|
||||
fi
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
AC_ARG_ENABLE([efiemu],
|
||||
[AS_HELP_STRING([--enable-efiemu],
|
||||
[build and install the efiemu runtimes (default=guessed)])])
|
||||
if test x"$enable_efiemu" = xno ; then
|
||||
efiemu_excuse="explicitly disabled"
|
||||
fi
|
||||
|
||||
if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
|
||||
efiemu_excuse="not available on cygwin"
|
||||
fi
|
||||
if test x"$target_cpu" != xi386 ; then
|
||||
efiemu_excuse="only available on i386"
|
||||
fi
|
||||
if test x"$platform" = xefi ; then
|
||||
efiemu_excuse="not available on efi"
|
||||
fi
|
||||
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_efiemu=yes],
|
||||
[grub_cv_cc_efiemu=no])
|
||||
])
|
||||
if test x$grub_cv_cc_efiemu = xno; then
|
||||
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
|
||||
fi
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
|
||||
grub_cv_target_cc_efiemu64_link_format=unknown
|
||||
for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
LDFLAGS="-m64 -Wl,$format -nostdlib -static"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
asm (".globl _start; _start:");
|
||||
asm (".globl __start; __start:");
|
||||
void __main (void);
|
||||
void __main (void) {}
|
||||
]], [[]])], [flag=1], [flag=0])
|
||||
if test x"$flag" = x1; then
|
||||
grub_cv_target_cc_efiemu64_link_format="$format"
|
||||
break
|
||||
fi
|
||||
done])
|
||||
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
|
||||
efiemu_excuse="no suitable link format for efiemu64 found"
|
||||
else
|
||||
EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
|
||||
fi
|
||||
fi
|
||||
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
|
||||
AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
enable_efiemu=yes
|
||||
else
|
||||
enable_efiemu=no
|
||||
fi
|
||||
AC_SUBST([enable_efiemu])
|
||||
AC_SUBST([EFIEMU64_LINK_FORMAT])
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
|
||||
|
||||
|
||||
@@ -1186,9 +1155,9 @@ CFLAGS="$TARGET_CFLAGS"
|
||||
# Position independent executable.
|
||||
grub_CHECK_PIE
|
||||
[# Need that, because some distributions ship compilers that include
|
||||
# `-fPIE' or '-fpie' in the default specs.
|
||||
# `-fPIE' in the default specs.
|
||||
if [ x"$pie_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
|
||||
fi]
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
109
docs/grub.texi
109
docs/grub.texi
@@ -2538,8 +2538,6 @@ team are:
|
||||
85:3
|
||||
@item Asus EeePC 1005PE
|
||||
84:1 (unconfirmed)
|
||||
@item LENOVO ThinkPad T410s (2912W1C)
|
||||
101:3
|
||||
@end table
|
||||
|
||||
To take full advantage of this function, install GRUB into the MBR
|
||||
@@ -3040,8 +3038,6 @@ These variables have special meaning to GRUB.
|
||||
* cmdpath::
|
||||
* color_highlight::
|
||||
* color_normal::
|
||||
* config_directory::
|
||||
* config_file::
|
||||
* debug::
|
||||
* default::
|
||||
* fallback::
|
||||
@@ -3184,22 +3180,6 @@ matching colors of first half.
|
||||
to support whole rgb24 palette but currently there is no compelling reason
|
||||
to go beyond the current 16 colors.
|
||||
|
||||
|
||||
@node config_directory
|
||||
@subsection config_directory
|
||||
|
||||
This variable is automatically set by GRUB to the directory part of
|
||||
current configuration file name (@pxref{config_file}).
|
||||
|
||||
|
||||
@node config_file
|
||||
@subsection config_file
|
||||
|
||||
This variable is automatically set by GRUB to the name of configuration file that is being
|
||||
processed by commands @command{configfile} (@pxref{configfile}) or @command{normal}
|
||||
(@pxref{normal}). It is restored to the previous value when command completes.
|
||||
|
||||
|
||||
@node debug
|
||||
@subsection debug
|
||||
|
||||
@@ -3859,11 +3839,6 @@ you forget a command, you can run the command @command{help}
|
||||
@comment * vbeinfo:: List available video modes
|
||||
* verify_detached:: Verify detached digital signature
|
||||
* videoinfo:: List available video modes
|
||||
@comment * xen_*:: Xen boot commands
|
||||
* xen_hypervisor:: Load xen hypervisor binary
|
||||
* xen_linux:: Load dom0 kernel for xen hypervisor
|
||||
* xen_initrd:: Load dom0 initrd for dom0 kernel
|
||||
* xen_xsm:: Load xen security module for xen hypervisor
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -4075,15 +4050,12 @@ after @command{configfile} returns.
|
||||
@node cpuid
|
||||
@subsection cpuid
|
||||
|
||||
@deffn Command cpuid [-l] [-p]
|
||||
@deffn Command cpuid [-l]
|
||||
Check for CPU features. This command is only available on x86 systems.
|
||||
|
||||
With the @option{-l} option, return true if the CPU supports long mode
|
||||
(64-bit).
|
||||
|
||||
With the @option{-p} option, return true if the CPU supports Physical
|
||||
Address Extension (PAE).
|
||||
|
||||
If invoked without options, this command currently behaves as if it had been
|
||||
invoked with @option{-l}. This may change in the future.
|
||||
@end deffn
|
||||
@@ -5047,8 +5019,6 @@ the length of @var{string} is zero
|
||||
@var{expression} is false
|
||||
@item @var{expression1} @code{-a} @var{expression2}
|
||||
both @var{expression1} and @var{expression2} are true
|
||||
@item @var{expression1} @var{expression2}
|
||||
both @var{expression1} and @var{expression2} are true. This syntax is not POSIX-compliant and is not recommended.
|
||||
@item @var{expression1} @code{-o} @var{expression2}
|
||||
either @var{expression1} or @var{expression2} is true
|
||||
@end table
|
||||
@@ -5132,39 +5102,6 @@ successfully. If validation fails, it is set to a non-zero value.
|
||||
List available video modes. If resolution is given, show only matching modes.
|
||||
@end deffn
|
||||
|
||||
@node xen_hypervisor
|
||||
@subsection xen_hypervisor
|
||||
|
||||
@deffn Command xen_hypervisor file [arguments] @dots{}
|
||||
Load a Xen hypervisor binary from @var{file}. The rest of the line is passed
|
||||
verbatim as the @dfn{kernel command-line}. Any other binaries must be
|
||||
reloaded after using this command.
|
||||
@end deffn
|
||||
|
||||
@node xen_linux
|
||||
@subsection xen_linux
|
||||
|
||||
@deffn Command xen_linux file [arguments]
|
||||
Load a dom0 kernel image for xen hypervisor at the booting process of xen.
|
||||
The rest of the line is passed verbatim as the module command line.
|
||||
@end deffn
|
||||
|
||||
@node xen_initrd
|
||||
@subsection xen_initrd
|
||||
|
||||
@deffn Command xen_initrd file
|
||||
Load a initrd image for dom0 kernel at the booting process of xen.
|
||||
@end deffn
|
||||
|
||||
@node xen_xsm
|
||||
@subsection xen_xsm
|
||||
|
||||
@deffn Command xen_xsm file
|
||||
Load a xen security module for xen hypervisor at the booting process of xen.
|
||||
See @uref{http://wiki.xen.org/wiki/XSM} for more detail.
|
||||
@end deffn
|
||||
|
||||
|
||||
@node Networking commands
|
||||
@section The list of networking commands
|
||||
|
||||
@@ -5676,16 +5613,6 @@ BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol
|
||||
limitations mips-loongson (with Linux protocol)
|
||||
and mips-qemu_mips can use only memory up to first hole.
|
||||
|
||||
Bootlocation is ability of GRUB to automatically detect where it boots from.
|
||||
``disk'' means the detection is limited to detecting the disk with partition
|
||||
being discovered on install time. ``partition'' means that disk and partiton
|
||||
can be automatically discovered. ``file'' means that boot image file name as
|
||||
well as disk and partition can be discovered. For consistency default install ignores
|
||||
partition and relies solely on disk detection. If no bootlocation discovery is available
|
||||
or boot and grub-root disks are different, UUID is used instead. On ARC if no device
|
||||
to install to is specified, UUID is used instead as well.
|
||||
|
||||
|
||||
@multitable @columnfractions .20 .20 .20 .20 .20
|
||||
@item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu
|
||||
@item video @tab yes @tab yes @tab yes @tab yes
|
||||
@@ -5702,7 +5629,6 @@ to install to is specified, UUID is used instead as well.
|
||||
@item badram @tab yes @tab yes @tab yes @tab yes
|
||||
@item compression @tab always @tab pointless @tab no @tab no
|
||||
@item exit @tab yes @tab no @tab no @tab no
|
||||
@item bootlocation @tab disk @tab no @tab no @tab no
|
||||
@end multitable
|
||||
|
||||
@multitable @columnfractions .20 .20 .20 .20 .20
|
||||
@@ -5721,7 +5647,6 @@ to install to is specified, UUID is used instead as well.
|
||||
@item badram @tab yes @tab yes @tab no @tab yes
|
||||
@item compression @tab no @tab no @tab no @tab no
|
||||
@item exit @tab yes @tab yes @tab yes @tab yes
|
||||
@item bootlocation @tab file @tab file @tab file, ignored @tab file
|
||||
@end multitable
|
||||
|
||||
@multitable @columnfractions .20 .20 .20 .20 .20
|
||||
@@ -5740,26 +5665,24 @@ to install to is specified, UUID is used instead as well.
|
||||
@item badram @tab yes (*) @tab no @tab no @tab no
|
||||
@item compression @tab configurable @tab no @tab no @tab configurable
|
||||
@item exit @tab no @tab yes @tab yes @tab yes
|
||||
@item bootlocation @tab no @tab partition @tab file @tab file (*)
|
||||
@end multitable
|
||||
|
||||
@multitable @columnfractions .20 .20 .20 .20 .20
|
||||
@item @tab MIPS qemu @tab emu @tab xen
|
||||
@item video @tab no @tab yes @tab no
|
||||
@item console charset @tab CP437 @tab Unicode (*) @tab ASCII
|
||||
@item network @tab no @tab yes @tab no
|
||||
@item ATA/AHCI @tab yes @tab no @tab no
|
||||
@item AT keyboard @tab yes @tab no @tab no
|
||||
@item Speaker @tab no @tab no @tab no
|
||||
@item USB @tab N/A @tab yes @tab no
|
||||
@item chainloader @tab yes @tab no @tab yes
|
||||
@item cpuid @tab no @tab no @tab yes
|
||||
@item hints @tab guess @tab no @tab no
|
||||
@item PCI @tab no @tab no @tab no
|
||||
@item badram @tab yes (*) @tab no @tab no
|
||||
@item compression @tab configurable @tab no @tab no
|
||||
@item exit @tab no @tab yes @tab no
|
||||
@item bootlocation @tab no @tab file @tab no
|
||||
@item @tab MIPS qemu @tab emu
|
||||
@item video @tab no @tab yes
|
||||
@item console charset @tab CP437 @tab Unicode (*)
|
||||
@item network @tab no @tab yes
|
||||
@item ATA/AHCI @tab yes @tab no
|
||||
@item AT keyboard @tab yes @tab no
|
||||
@item Speaker @tab no @tab no
|
||||
@item USB @tab N/A @tab yes
|
||||
@item chainloader @tab yes @tab no
|
||||
@item cpuid @tab no @tab no
|
||||
@item hints @tab guess @tab no
|
||||
@item PCI @tab no @tab no
|
||||
@item badram @tab yes (*) @tab no
|
||||
@item compression @tab configurable @tab no
|
||||
@item exit @tab no @tab yes
|
||||
@end multitable
|
||||
|
||||
@node Platform-specific operations
|
||||
|
||||
@@ -729,11 +729,9 @@ def kernel(defn, platform):
|
||||
"""if test x$(TARGET_APPLE_LINKER) = x1; then \
|
||||
$(TARGET_STRIP) -S -x $(""" + cname(defn) + """) -o $@.bin $<; \
|
||||
$(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -ed2016 -wd1106 -nu -nd $@.bin $@; \
|
||||
rm -f $@.bin; \
|
||||
elif test ! -z '$(TARGET_OBJ2ELF)'; then \
|
||||
""" + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \
|
||||
$(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \
|
||||
rm -f $@.bin; \
|
||||
else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \
|
||||
fi"""))
|
||||
|
||||
@@ -761,7 +759,7 @@ def image(defn, platform):
|
||||
if test x$(TARGET_APPLE_LINKER) = x1; then \
|
||||
$(MACHO2IMG) $< $@; \
|
||||
else \
|
||||
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \
|
||||
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
|
||||
fi
|
||||
""")
|
||||
|
||||
|
||||
@@ -39,10 +39,6 @@ gentrigtables$(BUILD_EXEEXT): gentrigtables.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
|
||||
CLEANFILES += gentrigtables$(BUILD_EXEEXT)
|
||||
|
||||
build-grub-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/grub-module-verifier.c $(top_srcdir)/util/grub-module-verifier32.c $(top_srcdir)/util/grub-module-verifier64.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\" $^
|
||||
CLEANFILES += build-grub-module-verifier$(BUILD_EXEEXT)
|
||||
|
||||
# trigtables.c
|
||||
trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
|
||||
./gentrigtables$(BUILD_EXEEXT) > $@
|
||||
@@ -105,9 +101,7 @@ if COND_i386_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
|
||||
endif
|
||||
|
||||
if COND_i386_coreboot
|
||||
@@ -118,12 +112,10 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
endif
|
||||
|
||||
if COND_i386_multiboot
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
endif
|
||||
|
||||
if COND_i386_qemu
|
||||
@@ -162,14 +154,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
|
||||
endif
|
||||
|
||||
if COND_ia64_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
endif
|
||||
|
||||
if COND_mips
|
||||
@@ -244,13 +233,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
endif
|
||||
|
||||
if COND_arm64_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
|
||||
endif
|
||||
|
||||
if COND_emu
|
||||
@@ -396,7 +383,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst
|
||||
platform_DATA += moddep.lst
|
||||
CLEANFILES += config.log syminfo.lst moddep.lst
|
||||
|
||||
$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT)
|
||||
$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT)
|
||||
TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
|
||||
platform_DATA += $(MOD_FILES)
|
||||
platform_DATA += modinfo.sh
|
||||
|
||||
@@ -59,6 +59,9 @@ kernel = {
|
||||
ia64_efi_ldflags = '-Wl,-r,-d';
|
||||
ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
x86_64_xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
i386_xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
arm_efi_ldflags = '-Wl,-r,-d';
|
||||
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
@@ -90,7 +93,7 @@ kernel = {
|
||||
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
||||
emu_cflags = '$(CFLAGS_GNULIB)';
|
||||
emu_cppflags = '$(CPPFLAGS_GNULIB)';
|
||||
arm_uboot_ldflags = '-Wl,-r,-d';
|
||||
arm_uboot_ldflags = '-Wl,-Ttext=0x08000000';
|
||||
arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
i386_pc_startup = kern/i386/pc/startup.S;
|
||||
@@ -171,20 +174,8 @@ kernel = {
|
||||
efi = kern/efi/init.c;
|
||||
efi = kern/efi/mm.c;
|
||||
efi = term/efi/console.c;
|
||||
efi = kern/acpi.c;
|
||||
efi = kern/efi/acpi.c;
|
||||
i386_coreboot = kern/i386/pc/acpi.c;
|
||||
i386_multiboot = kern/i386/pc/acpi.c;
|
||||
i386_coreboot = kern/acpi.c;
|
||||
i386_multiboot = kern/acpi.c;
|
||||
|
||||
x86 = kern/i386/tsc.c;
|
||||
x86 = kern/i386/tsc_pit.c;
|
||||
i386_efi = kern/i386/efi/tsc.c;
|
||||
x86_64_efi = kern/i386/efi/tsc.c;
|
||||
i386_efi = kern/i386/tsc_pmtimer.c;
|
||||
i386_coreboot = kern/i386/tsc_pmtimer.c;
|
||||
x86_64_efi = kern/i386/tsc_pmtimer.c;
|
||||
|
||||
i386_efi = kern/i386/efi/init.c;
|
||||
i386_efi = bus/pci.c;
|
||||
@@ -196,7 +187,6 @@ kernel = {
|
||||
x86_64_efi = bus/pci.c;
|
||||
|
||||
xen = kern/i386/tsc.c;
|
||||
xen = kern/i386/xen/tsc.c;
|
||||
x86_64_xen = kern/x86_64/xen/hypercall.S;
|
||||
i386_xen = kern/i386/xen/hypercall.S;
|
||||
xen = kern/xen/init.c;
|
||||
@@ -213,7 +203,7 @@ kernel = {
|
||||
arm_efi = kern/arm/efi/init.c;
|
||||
arm_efi = kern/arm/efi/misc.c;
|
||||
|
||||
arm64_efi = kern/arm64/efi/init.c;
|
||||
arm64_efi = kern/arm/efi/init.c;
|
||||
|
||||
i386_pc = kern/i386/pc/init.c;
|
||||
i386_pc = kern/i386/pc/mmap.c;
|
||||
@@ -614,6 +604,7 @@ module = {
|
||||
module = {
|
||||
name = lsxen;
|
||||
common = commands/xen/lsxen.c;
|
||||
cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
enable = xen;
|
||||
};
|
||||
@@ -678,8 +669,10 @@ module = {
|
||||
name = acpi;
|
||||
|
||||
common = commands/acpi.c;
|
||||
i386_pc = kern/acpi.c;
|
||||
i386_pc = kern/i386/pc/acpi.c;
|
||||
efi = commands/efi/acpi.c;
|
||||
i386_pc = commands/i386/pc/acpi.c;
|
||||
i386_coreboot = commands/i386/pc/acpi.c;
|
||||
i386_multiboot = commands/i386/pc/acpi.c;
|
||||
|
||||
enable = efi;
|
||||
enable = i386_pc;
|
||||
@@ -832,6 +825,7 @@ module = {
|
||||
i386_coreboot = lib/i386/halt.c;
|
||||
i386_qemu = lib/i386/halt.c;
|
||||
xen = lib/xen/halt.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
efi = lib/efi/halt.c;
|
||||
ieee1275 = lib/ieee1275/halt.c;
|
||||
emu = lib/emu/halt.c;
|
||||
@@ -852,6 +846,7 @@ module = {
|
||||
mips_loongson = lib/mips/loongson/reboot.c;
|
||||
mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
|
||||
xen = lib/xen/reboot.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
uboot = lib/uboot/reboot.c;
|
||||
common = commands/reboot.c;
|
||||
};
|
||||
@@ -1531,6 +1526,7 @@ module = {
|
||||
i386_xen = lib/i386/xen/relocator.S;
|
||||
x86_64_xen = lib/x86_64/xen/relocator.S;
|
||||
xen = lib/i386/relocator_common_c.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
extra_dist = lib/i386/relocator_common.S;
|
||||
extra_dist = kern/powerpc/cache_flush.S;
|
||||
@@ -1551,6 +1547,7 @@ module = {
|
||||
sparc64_ieee1275 = lib/ieee1275/cmos.c;
|
||||
powerpc_ieee1275 = lib/ieee1275/cmos.c;
|
||||
xen = lib/xen/datetime.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
mips_arc = lib/arc/datetime.c;
|
||||
enable = noemu;
|
||||
@@ -1660,6 +1657,7 @@ module = {
|
||||
name = linux;
|
||||
x86 = loader/i386/linux.c;
|
||||
xen = loader/i386/xen.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
i386_pc = lib/i386/pc/vesa_modes_table.c;
|
||||
mips = loader/mips/linux.c;
|
||||
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
|
||||
@@ -1667,6 +1665,7 @@ module = {
|
||||
ia64_efi = loader/ia64/efi/linux.c;
|
||||
arm = loader/arm/linux.c;
|
||||
arm64 = loader/arm64/linux.c;
|
||||
fdt = lib/fdt.c;
|
||||
common = loader/linux.c;
|
||||
common = lib/cmdline.c;
|
||||
enable = noemu;
|
||||
@@ -1675,8 +1674,7 @@ module = {
|
||||
module = {
|
||||
name = fdt;
|
||||
arm64 = loader/arm64/fdt.c;
|
||||
common = lib/fdt.c;
|
||||
enable = fdt;
|
||||
enable = arm64;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -1685,32 +1683,7 @@ module = {
|
||||
x86 = loader/i386/xnu.c;
|
||||
x86 = loader/xnu.c;
|
||||
|
||||
/* Code is pretty generic but relies on RNG which
|
||||
is available only on few platforms. It's not a
|
||||
big deal as xnu needs ACPI anyway and we have
|
||||
RNG on all platforms with ACPI.
|
||||
*/
|
||||
enable = i386_multiboot;
|
||||
enable = i386_coreboot;
|
||||
enable = i386_pc;
|
||||
enable = i386_efi;
|
||||
enable = x86_64_efi;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = random;
|
||||
x86 = lib/i386/random.c;
|
||||
common = lib/random.c;
|
||||
|
||||
i386_multiboot = kern/i386/tsc_pmtimer.c;
|
||||
i386_coreboot = kern/i386/tsc_pmtimer.c;
|
||||
i386_pc = kern/i386/tsc_pmtimer.c;
|
||||
|
||||
enable = i386_multiboot;
|
||||
enable = i386_coreboot;
|
||||
enable = i386_pc;
|
||||
enable = i386_efi;
|
||||
enable = x86_64_efi;
|
||||
enable = x86;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <grub/loader.h>
|
||||
#include <grub/cs5536.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -338,21 +337,6 @@ struct grub_ehci
|
||||
|
||||
static struct grub_ehci *ehci;
|
||||
|
||||
static void
|
||||
sync_all_caches (struct grub_ehci *e)
|
||||
{
|
||||
if (!e)
|
||||
return;
|
||||
if (e->td_virt)
|
||||
grub_arch_sync_dma_caches (e->td_virt, sizeof (struct grub_ehci_td) *
|
||||
GRUB_EHCI_N_TD);
|
||||
if (e->qh_virt)
|
||||
grub_arch_sync_dma_caches (e->qh_virt, sizeof (struct grub_ehci_qh) *
|
||||
GRUB_EHCI_N_QH);
|
||||
if (e->framelist_virt)
|
||||
grub_arch_sync_dma_caches (e->framelist_virt, 4096);
|
||||
}
|
||||
|
||||
/* EHCC registers access functions */
|
||||
static inline grub_uint32_t
|
||||
grub_ehci_ehcc_read32 (struct grub_ehci *e, grub_uint32_t addr)
|
||||
@@ -453,8 +437,6 @@ grub_ehci_reset (struct grub_ehci *e)
|
||||
{
|
||||
grub_uint64_t maxtime;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
|
||||
GRUB_EHCI_CMD_HC_RESET
|
||||
| grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
|
||||
@@ -858,8 +840,6 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||
e->next = ehci;
|
||||
ehci = e;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n");
|
||||
|
||||
grub_dprintf ("ehci",
|
||||
@@ -1040,7 +1020,6 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer)
|
||||
/* Found proper existing (and linked) QH, do setup of QH */
|
||||
grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter);
|
||||
grub_ehci_setup_qh (qh_iter, transfer);
|
||||
sync_all_caches (e);
|
||||
return qh_iter;
|
||||
}
|
||||
|
||||
@@ -1142,7 +1121,7 @@ grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td,
|
||||
token = grub_le_to_cpu32 (td->token);
|
||||
to_transfer = (token & GRUB_EHCI_TOTAL_MASK) >> GRUB_EHCI_TOTAL_OFF;
|
||||
|
||||
/* Check state of TD - if it did not transfer
|
||||
/* Check state of TD - if it did not transfered
|
||||
* whole data then set last_trans - it should be last executed TD
|
||||
* in case when something went wrong. */
|
||||
if (transfer && (td->size != to_transfer))
|
||||
@@ -1310,28 +1289,16 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
|
||||
grub_ehci_td_t td_prev = NULL;
|
||||
int i;
|
||||
struct grub_ehci_transfer_controller_data *cdata;
|
||||
grub_uint32_t status;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
/* Check if EHCI is running and AL is enabled */
|
||||
status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
|
||||
if ((status & GRUB_EHCI_ST_HC_HALTED) != 0)
|
||||
if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
|
||||
& GRUB_EHCI_ST_HC_HALTED) != 0)
|
||||
/* XXX: Fix it: Currently we don't do anything to restart EHCI */
|
||||
{
|
||||
grub_dprintf ("ehci", "setup_transfer: halted, status = 0x%x\n",
|
||||
status);
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
}
|
||||
status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
|
||||
if ((status
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
|
||||
& (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0)
|
||||
/* XXX: Fix it: Currently we don't do anything to restart EHCI */
|
||||
{
|
||||
grub_dprintf ("ehci", "setup_transfer: no AS/PS, status = 0x%x\n",
|
||||
status);
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
}
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
|
||||
/* Allocate memory for controller transfer data. */
|
||||
cdata = grub_malloc (sizeof (*cdata));
|
||||
@@ -1343,7 +1310,6 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
|
||||
cdata->qh_virt = grub_ehci_find_qh (e, transfer);
|
||||
if (!cdata->qh_virt)
|
||||
{
|
||||
grub_dprintf ("ehci", "setup_transfer: no QH\n");
|
||||
grub_free (cdata);
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
}
|
||||
@@ -1353,7 +1319,6 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
|
||||
cdata->td_alt_virt = grub_ehci_alloc_td (e);
|
||||
if (!cdata->td_alt_virt)
|
||||
{
|
||||
grub_dprintf ("ehci", "setup_transfer: no TDs\n");
|
||||
grub_free (cdata);
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
}
|
||||
@@ -1380,7 +1345,6 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
|
||||
grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual);
|
||||
|
||||
grub_free (cdata);
|
||||
grub_dprintf ("ehci", "setup_transfer: no TD\n");
|
||||
return GRUB_USB_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
@@ -1422,8 +1386,6 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
|
||||
* i.e. reset token */
|
||||
cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0);
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
/* Finito */
|
||||
transfer->controller_data = cdata;
|
||||
|
||||
@@ -1472,8 +1434,6 @@ grub_ehci_parse_notrun (grub_usb_controller_t dev,
|
||||
grub_ehci_free_td (e, cdata->td_alt_virt);
|
||||
grub_free (cdata);
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
/* Additionally, do something with EHCI to make it running (what?) */
|
||||
/* Try enable EHCI and AL */
|
||||
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
|
||||
@@ -1509,8 +1469,6 @@ grub_ehci_parse_halt (grub_usb_controller_t dev,
|
||||
grub_ehci_free_td (e, cdata->td_alt_virt);
|
||||
grub_free (cdata);
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
/* Evaluation of error code - currently we don't have GRUB USB error
|
||||
* codes for some EHCI states, GRUB_USB_ERR_DATA is used for them.
|
||||
* Order of evaluation is critical, specially bubble/stall. */
|
||||
@@ -1544,8 +1502,6 @@ grub_ehci_parse_success (grub_usb_controller_t dev,
|
||||
grub_ehci_free_td (e, cdata->td_alt_virt);
|
||||
grub_free (cdata);
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -1559,8 +1515,6 @@ grub_ehci_check_transfer (grub_usb_controller_t dev,
|
||||
transfer->controller_data;
|
||||
grub_uint32_t token, token_ftd;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
grub_dprintf ("ehci",
|
||||
"check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n",
|
||||
grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS),
|
||||
@@ -1627,9 +1581,6 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
|
||||
int i;
|
||||
grub_uint64_t maxtime;
|
||||
grub_uint32_t qh_phys;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
grub_uint32_t interrupt =
|
||||
cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK;
|
||||
|
||||
@@ -1649,7 +1600,6 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
|
||||
grub_ehci_free_tds (e, cdata->td_first_virt, transfer, &actual);
|
||||
grub_ehci_free_td (e, cdata->td_alt_virt);
|
||||
grub_free (cdata);
|
||||
sync_all_caches (e);
|
||||
grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n");
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
@@ -1672,8 +1622,6 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
|
||||
/* Unlink QH from AL */
|
||||
e->qh_virt[i].qh_hptr = cdata->qh_virt->qh_hptr;
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
/* If this is an interrupt transfer, we just wait for the periodic
|
||||
* schedule to advance a few times and then assume that the EHCI
|
||||
* controller has read the updated QH. */
|
||||
@@ -1728,8 +1676,6 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
|
||||
|
||||
grub_dprintf ("ehci", "cancel_transfer: end\n");
|
||||
|
||||
sync_all_caches (e);
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -1831,6 +1777,11 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
|
||||
|
||||
status = grub_ehci_port_read (e, port);
|
||||
|
||||
grub_dprintf ("ehci", "detect_dev: EHCI STATUS: %08x\n",
|
||||
grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
|
||||
grub_dprintf ("ehci", "detect_dev: iobase=%p, port=%d, status=0x%02x\n",
|
||||
e->iobase, port, status);
|
||||
|
||||
/* Connect Status Change bit - it detects change of connection */
|
||||
if (status & GRUB_EHCI_PORT_CONNECT_CH)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <grub/usb.h>
|
||||
#include <grub/usbtrans.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
|
||||
static inline unsigned int
|
||||
@@ -102,8 +101,6 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
||||
data_addr = grub_dma_get_phys (data_chunk);
|
||||
grub_memcpy ((char *) data, data_in, size);
|
||||
|
||||
grub_arch_sync_dma_caches (data, size);
|
||||
|
||||
grub_dprintf ("usb",
|
||||
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n",
|
||||
reqtype, request, value, index, (unsigned long)size);
|
||||
@@ -164,8 +161,6 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
||||
setupdata->value = value;
|
||||
setupdata->index = index;
|
||||
setupdata->length = size;
|
||||
grub_arch_sync_dma_caches (setupdata, sizeof (*setupdata));
|
||||
|
||||
transfer->transactions[0].size = sizeof (*setupdata);
|
||||
transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP;
|
||||
transfer->transactions[0].data = setupdata_addr;
|
||||
@@ -207,13 +202,11 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
||||
grub_free (transfer->transactions);
|
||||
|
||||
grub_free (transfer);
|
||||
grub_dma_free (data_chunk);
|
||||
grub_dma_free (setupdata_chunk);
|
||||
|
||||
grub_arch_sync_dma_caches (data, size0);
|
||||
grub_memcpy (data_in, (char *) data, size0);
|
||||
|
||||
grub_dma_free (data_chunk);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -243,10 +236,7 @@ grub_usb_bulk_setup_readwrite (grub_usb_device_t dev,
|
||||
data = grub_dma_get_virt (data_chunk);
|
||||
data_addr = grub_dma_get_phys (data_chunk);
|
||||
if (type == GRUB_USB_TRANSFER_TYPE_OUT)
|
||||
{
|
||||
grub_memcpy ((char *) data, data_in, size);
|
||||
grub_arch_sync_dma_caches (data, size);
|
||||
}
|
||||
grub_memcpy ((char *) data, data_in, size);
|
||||
|
||||
/* Create a transfer. */
|
||||
transfer = grub_malloc (sizeof (struct grub_usb_transfer));
|
||||
@@ -316,13 +306,9 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer)
|
||||
dev->toggle[transfer->endpoint] = toggle;
|
||||
|
||||
if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN)
|
||||
{
|
||||
grub_arch_sync_dma_caches (grub_dma_get_virt (transfer->data_chunk),
|
||||
transfer->size + 1);
|
||||
grub_memcpy (transfer->data, (void *)
|
||||
grub_dma_get_virt (transfer->data_chunk),
|
||||
transfer->size + 1);
|
||||
}
|
||||
grub_memcpy (transfer->data, (void *)
|
||||
grub_dma_get_virt (transfer->data_chunk),
|
||||
transfer->size + 1);
|
||||
|
||||
grub_free (transfer->transactions);
|
||||
grub_dma_free (transfer->data_chunk);
|
||||
|
||||
@@ -61,6 +61,18 @@ static const struct grub_arg_option options[] = {
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */
|
||||
grub_uint8_t
|
||||
grub_byte_checksum (void *base, grub_size_t size)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
grub_uint8_t ret = 0;
|
||||
for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size;
|
||||
ptr++)
|
||||
ret += *ptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise.
|
||||
rev2 contains the revision of ACPIv2+ to generate or 0 if none. */
|
||||
static int rev1, rev2;
|
||||
@@ -593,9 +605,6 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
||||
if (! table->addr)
|
||||
{
|
||||
free_tables ();
|
||||
grub_free (exclude);
|
||||
grub_free (load_only);
|
||||
grub_free (table);
|
||||
return grub_errno;
|
||||
}
|
||||
table->next = acpi_tables;
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#define grub_dprintf(cond, args...) printf ( args )
|
||||
#define grub_printf printf
|
||||
#define grub_util_fopen fopen
|
||||
#define grub_memcmp memcmp
|
||||
typedef uint64_t grub_uint64_t;
|
||||
typedef uint32_t grub_uint32_t;
|
||||
typedef uint16_t grub_uint16_t;
|
||||
@@ -248,7 +246,6 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
|
||||
if (!add)
|
||||
return -1;
|
||||
break;
|
||||
case GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD:
|
||||
case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD:
|
||||
case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD:
|
||||
{
|
||||
|
||||
@@ -140,13 +140,10 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
}
|
||||
|
||||
if (utcount)
|
||||
{
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
|
||||
for (j = 0; j < utcount; j++)
|
||||
grub_printf ("<%x>", (unsigned int) utbuf[j]);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
}
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
|
||||
for (j = 0; j < utcount; j++)
|
||||
grub_printf ("<%x>", (unsigned int) utbuf[j]);
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
|
||||
grub_xputs ("\n");
|
||||
grub_refresh ();
|
||||
|
||||
@@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
grub_printf
|
||||
("Type Physical start - end #Pages "
|
||||
" Size Attributes\n");
|
||||
" Size Attributes\n");
|
||||
memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size);
|
||||
for (desc = memory_map;
|
||||
desc < memory_map_end;
|
||||
@@ -74,8 +74,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
||||
"ACPI-nvs",
|
||||
"MMIO ",
|
||||
"IO-ports",
|
||||
"PAL-code",
|
||||
"persist ",
|
||||
"PAL-code"
|
||||
};
|
||||
if (desc->type < ARRAY_SIZE (types_str))
|
||||
grub_printf ("%s ", types_str[desc->type]);
|
||||
@@ -88,29 +87,21 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
||||
desc->physical_start + (desc->num_pages << 12) - 1,
|
||||
desc->num_pages);
|
||||
|
||||
size = desc->num_pages << 12; /* 4 KiB page size */
|
||||
/*
|
||||
* Since size is a multiple of 4 KiB, no need to handle units
|
||||
* of just Bytes (which would use a mask of 0x3ff).
|
||||
*
|
||||
* 14 characters would support the largest possible number of 4 KiB
|
||||
* pages that are not a multiple of larger units (e.g., MiB):
|
||||
* 17592186044415 (0xffffff_fffff000), but that uses a lot of
|
||||
* whitespace for a rare case. 6 characters usually suffices;
|
||||
* columns will be off if not, but this is preferable to rounding.
|
||||
*/
|
||||
if (size & 0xfffff)
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "KiB", size >> 10);
|
||||
else if (size & 0x3fffffff)
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "MiB", size >> 20);
|
||||
else if (size & 0xffffffffff)
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "GiB", size >> 30);
|
||||
else if (size & 0x3ffffffffffff)
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "TiB", size >> 40);
|
||||
else if (size & 0xfffffffffffffff)
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "PiB", size >> 50);
|
||||
size = desc->num_pages;
|
||||
size <<= (12 - 10);
|
||||
if (size < 1024)
|
||||
grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size);
|
||||
else
|
||||
grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60);
|
||||
{
|
||||
size /= 1024;
|
||||
if (size < 1024)
|
||||
grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size);
|
||||
else
|
||||
{
|
||||
size /= 1024;
|
||||
grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size);
|
||||
}
|
||||
}
|
||||
|
||||
attr = desc->attribute;
|
||||
if (attr & GRUB_EFI_MEMORY_RUNTIME)
|
||||
@@ -131,12 +122,6 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_printf (" RP");
|
||||
if (attr & GRUB_EFI_MEMORY_XP)
|
||||
grub_printf (" XP");
|
||||
if (attr & GRUB_EFI_MEMORY_NV)
|
||||
grub_printf (" NV");
|
||||
if (attr & GRUB_EFI_MEMORY_MORE_RELIABLE)
|
||||
grub_printf (" MR");
|
||||
if (attr & GRUB_EFI_MEMORY_RO)
|
||||
grub_printf (" RO");
|
||||
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
@@ -37,20 +37,10 @@ static const struct guid_mapping guid_mappings[] =
|
||||
{
|
||||
{ GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
|
||||
{ GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
|
||||
{ GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
|
||||
"CRC32 GUIDED SECTION EXTRACTION"},
|
||||
{ GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
|
||||
{ GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
|
||||
{ GRUB_EFI_HCDP_TABLE_GUID, "HCDP"},
|
||||
{ GRUB_EFI_HOB_LIST_GUID, "HOB LIST"},
|
||||
{ GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
|
||||
{ GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
|
||||
{ GRUB_EFI_MPS_TABLE_GUID, "MPS"},
|
||||
{ GRUB_EFI_SAL_TABLE_GUID, "SAL"},
|
||||
{ GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
|
||||
{ GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
|
||||
{ GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
|
||||
{ GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
|
||||
{ GRUB_EFI_MPS_TABLE_GUID, "MPS"},
|
||||
{ GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
|
||||
@@ -45,7 +45,7 @@ static grub_err_t
|
||||
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int byte = 0, bit = 0;
|
||||
int byte, bit;
|
||||
grub_err_t err;
|
||||
grub_uint8_t value;
|
||||
|
||||
@@ -67,7 +67,7 @@ static grub_err_t
|
||||
grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int byte = 0, bit = 0;
|
||||
int byte, bit;
|
||||
grub_err_t err;
|
||||
grub_uint8_t value;
|
||||
|
||||
@@ -85,7 +85,7 @@ static grub_err_t
|
||||
grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int byte = 0, bit = 0;
|
||||
int byte, bit;
|
||||
grub_err_t err;
|
||||
grub_uint8_t value;
|
||||
|
||||
|
||||
@@ -253,7 +253,6 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
struct grub_command *cmd;
|
||||
char **cutargs;
|
||||
int cutargc;
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -315,8 +314,6 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1));
|
||||
if (!cutargs)
|
||||
return grub_errno;
|
||||
cutargc = argc - 1;
|
||||
grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2));
|
||||
cutargs[0] = args[0];
|
||||
@@ -336,7 +333,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
if (!(cmd->func) (cmd, cutargc, cutargs))
|
||||
{
|
||||
kernel_type = LINUX;
|
||||
goto out;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -351,7 +348,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
if (!(cmd->func) (cmd, argc, args))
|
||||
{
|
||||
kernel_type = MULTIBOOT;
|
||||
goto out;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -416,7 +413,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
if (!(cmd->func) (cmd, cutargc, cutargs))
|
||||
{
|
||||
kernel_type = KFREEBSD;
|
||||
goto out;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -425,8 +422,6 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
char **bsdargs;
|
||||
int bsdargc;
|
||||
char bsddevname[sizeof ("wdXXXXXXXXXXXXY")];
|
||||
int found = 0;
|
||||
|
||||
if (bsd_device == -1)
|
||||
{
|
||||
bsdargs = cutargs;
|
||||
@@ -437,11 +432,6 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
char rbuf[3] = "-r";
|
||||
bsdargc = cutargc + 2;
|
||||
bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc);
|
||||
if (!bsdargs)
|
||||
{
|
||||
err = grub_errno;
|
||||
goto out;
|
||||
}
|
||||
grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0]));
|
||||
bsdargs[argc] = rbuf;
|
||||
bsdargs[argc + 1] = bsddevname;
|
||||
@@ -457,8 +447,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
if (!(cmd->func) (cmd, bsdargc, bsdargs))
|
||||
{
|
||||
kernel_type = KNETBSD;
|
||||
found = 1;
|
||||
goto free_bsdargs;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -471,28 +460,20 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
if (!(cmd->func) (cmd, bsdargc, bsdargs))
|
||||
{
|
||||
kernel_type = KOPENBSD;
|
||||
found = 1;
|
||||
goto free_bsdargs;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
free_bsdargs:
|
||||
if (bsdargs != cutargs)
|
||||
grub_free (bsdargs);
|
||||
if (found)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (0);
|
||||
|
||||
err = grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s",
|
||||
args[0]);
|
||||
out:
|
||||
grub_free (cutargs);
|
||||
return err;
|
||||
return grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s",
|
||||
args[0]);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
@@ -553,17 +534,15 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused
|
||||
char **newargs;
|
||||
grub_err_t err;
|
||||
char nounzipbuf[10] = "--nounzip";
|
||||
|
||||
cmd = grub_command_find ("module");
|
||||
if (!cmd)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
|
||||
"module");
|
||||
|
||||
newargs = grub_malloc ((argc + 1) * sizeof (newargs[0]));
|
||||
if (!newargs)
|
||||
return grub_errno;
|
||||
grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0]));
|
||||
newargs[0] = nounzipbuf;
|
||||
cmd = grub_command_find ("module");
|
||||
if (!cmd)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
|
||||
"module");
|
||||
|
||||
err = cmd->func (cmd, argc + 1, newargs);
|
||||
grub_free (newargs);
|
||||
|
||||
@@ -37,8 +37,6 @@ static const char *names[] =
|
||||
is required to save accross hibernations. */
|
||||
[GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
|
||||
[GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
|
||||
[GRUB_MEMORY_PERSISTENT] = N_("persistent RAM"),
|
||||
[GRUB_MEMORY_PERSISTENT_LEGACY] = N_("persistent RAM (legacy)"),
|
||||
[GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
|
||||
[GRUB_MEMORY_CODE] = N_("RAM holding firmware code")
|
||||
};
|
||||
|
||||
@@ -198,10 +198,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
return grub_errno;
|
||||
|
||||
if (get_uuid (NULL, &uuid_root, 0))
|
||||
{
|
||||
grub_free (mods);
|
||||
return grub_errno;
|
||||
}
|
||||
return grub_errno;
|
||||
|
||||
prefdev = grub_file_get_device_name (prefix);
|
||||
if (grub_errno)
|
||||
@@ -213,8 +210,6 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (get_uuid (prefdev, &uuid_prefix, 0))
|
||||
{
|
||||
grub_free (uuid_root);
|
||||
grub_free (prefdev);
|
||||
grub_free (mods);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
@@ -294,15 +289,12 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
grub_free (uuid_root);
|
||||
grub_free (uuid_prefix);
|
||||
grub_free (prefdev);
|
||||
grub_free (mods);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (uuid_root);
|
||||
grub_free (uuid_prefix);
|
||||
grub_free (prefdev);
|
||||
|
||||
for (i = 0; i < mods_loaded; i++)
|
||||
if (mods[i])
|
||||
@@ -310,8 +302,6 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
mods[i]->fini = 0;
|
||||
grub_dl_unload (mods[i]);
|
||||
}
|
||||
grub_free (mods);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,6 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
if (! cur)
|
||||
{
|
||||
grub_free (parsed);
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
|
||||
args[i]);
|
||||
|
||||
@@ -45,7 +45,6 @@ check_password (const char *user, const char *entered, void *pin)
|
||||
grub_uint8_t *buf;
|
||||
struct pbkdf2_password *pass = pin;
|
||||
gcry_err_code_t err;
|
||||
grub_err_t ret;
|
||||
|
||||
buf = grub_malloc (pass->buflen);
|
||||
if (!buf)
|
||||
@@ -56,17 +55,17 @@ check_password (const char *user, const char *entered, void *pin)
|
||||
pass->salt, pass->saltlen, pass->c,
|
||||
buf, pass->buflen);
|
||||
if (err)
|
||||
ret = grub_crypto_gcry_error (err);
|
||||
else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
|
||||
ret = GRUB_ACCESS_DENIED;
|
||||
else
|
||||
{
|
||||
grub_auth_authenticate (user);
|
||||
ret = GRUB_ERR_NONE;
|
||||
grub_free (buf);
|
||||
return grub_crypto_gcry_error (err);
|
||||
}
|
||||
|
||||
grub_free (buf);
|
||||
return ret;
|
||||
if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
|
||||
return GRUB_ACCESS_DENIED;
|
||||
|
||||
grub_auth_authenticate (user);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
||||
@@ -64,7 +64,7 @@ iterate_device (const char *name, void *data)
|
||||
/* Skip floppy drives when requested. */
|
||||
if (ctx->no_floppy &&
|
||||
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
#ifdef DO_SEARCH_FS_UUID
|
||||
#define compare_fn grub_strcasecmp
|
||||
|
||||
@@ -324,19 +324,19 @@ grub_load_public_key (grub_file_t f)
|
||||
if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
break;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
|
||||
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
break;
|
||||
goto fail;
|
||||
}
|
||||
if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
break;
|
||||
goto fail;
|
||||
}
|
||||
grub_memcpy (buffer, &l, sizeof (l));
|
||||
|
||||
@@ -346,16 +346,10 @@ grub_load_public_key (grub_file_t f)
|
||||
buffer, lb + sizeof (grub_uint16_t), 0))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
break;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < pkalgos[pk].nmpipub)
|
||||
{
|
||||
grub_free (sk);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
GRUB_MD_SHA1->final (fingerprint_context);
|
||||
|
||||
grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20);
|
||||
|
||||
@@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
struct grub_ahci_cmd_head
|
||||
{
|
||||
grub_uint32_t config;
|
||||
grub_uint32_t transferred;
|
||||
grub_uint32_t transfered;
|
||||
grub_uint64_t command_table_base;
|
||||
grub_uint32_t unused[4];
|
||||
};
|
||||
@@ -954,7 +954,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
|
||||
grub_dprintf ("ahci", "AHCI tfd = %x\n",
|
||||
dev->hba->ports[dev->port].task_file_data);
|
||||
|
||||
dev->command_list[0].transferred = 0;
|
||||
dev->command_list[0].transfered = 0;
|
||||
dev->command_list[0].command_table_base
|
||||
= grub_dma_get_phys (dev->command_table_chunk);
|
||||
|
||||
@@ -1044,7 +1044,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
|
||||
dev->hba->ports[dev->port].command_issue,
|
||||
dev->hba->ports[dev->port].intstatus,
|
||||
dev->hba->ports[dev->port].task_file_data,
|
||||
dev->command_list[0].transferred,
|
||||
dev->command_list[0].transfered,
|
||||
dev->hba->ports[dev->port].sata_error,
|
||||
((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x00],
|
||||
((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <grub/fs.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/procfs.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/emu/hostdisk.h>
|
||||
@@ -719,7 +718,6 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
|
||||
newdev->id = last_cryptodisk_id++;
|
||||
newdev->source_id = source->id;
|
||||
newdev->source_dev_id = source->dev->id;
|
||||
newdev->partition_start = grub_partition_get_start (source->partition);
|
||||
newdev->next = cryptodisk_list;
|
||||
cryptodisk_list = newdev;
|
||||
|
||||
@@ -742,9 +740,7 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk)
|
||||
grub_cryptodisk_t dev;
|
||||
for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
|
||||
if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id)
|
||||
if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) ||
|
||||
(!disk->partition && dev->partition_start == 0))
|
||||
return dev;
|
||||
return dev;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -765,7 +761,6 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
|
||||
newdev->cheat_fd = GRUB_UTIL_FD_INVALID;
|
||||
newdev->source_id = source->id;
|
||||
newdev->source_dev_id = source->dev->id;
|
||||
newdev->partition_start = grub_partition_get_start (source->partition);
|
||||
newdev->id = last_cryptodisk_id++;
|
||||
newdev->next = cryptodisk_list;
|
||||
cryptodisk_list = newdev;
|
||||
|
||||
@@ -85,12 +85,6 @@ make_devices (void)
|
||||
{
|
||||
/* Uggh. */
|
||||
grub_free (handles);
|
||||
while (devices)
|
||||
{
|
||||
d = devices->next;
|
||||
grub_free (devices);
|
||||
devices = d;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -493,15 +487,8 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
|
||||
m = d->block_io->media;
|
||||
/* FIXME: Probably it is better to store the block size in the disk,
|
||||
and total sectors should be replaced with total blocks. */
|
||||
grub_dprintf ("efidisk",
|
||||
"m = %p, last block = %llx, block size = %x, io align = %x\n",
|
||||
m, (unsigned long long) m->last_block, m->block_size,
|
||||
m->io_align);
|
||||
|
||||
/* Ensure required buffer alignment is a power of two (or is zero). */
|
||||
if (m->io_align & (m->io_align - 1))
|
||||
return grub_error (GRUB_ERR_IO, "invalid buffer alignment %d", m->io_align);
|
||||
|
||||
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);
|
||||
@@ -531,42 +518,15 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
{
|
||||
struct grub_efidisk_data *d;
|
||||
grub_efi_block_io_t *bio;
|
||||
grub_efi_status_t status;
|
||||
grub_size_t io_align, num_bytes;
|
||||
char *aligned_buf;
|
||||
|
||||
d = disk->data;
|
||||
bio = d->block_io;
|
||||
|
||||
/* Set alignment to 1 if 0 specified */
|
||||
io_align = bio->media->io_align ? bio->media->io_align : 1;
|
||||
num_bytes = size << disk->log_sector_size;
|
||||
|
||||
if ((grub_addr_t) buf & (io_align - 1))
|
||||
{
|
||||
aligned_buf = grub_memalign (io_align, num_bytes);
|
||||
if (! aligned_buf)
|
||||
return GRUB_EFI_OUT_OF_RESOURCES;
|
||||
if (wr)
|
||||
grub_memcpy (aligned_buf, buf, num_bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
aligned_buf = buf;
|
||||
}
|
||||
|
||||
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) num_bytes, aligned_buf);
|
||||
|
||||
if ((grub_addr_t) buf & (io_align - 1))
|
||||
{
|
||||
if (!wr)
|
||||
grub_memcpy (buf, aligned_buf, num_bytes);
|
||||
grub_free (aligned_buf);
|
||||
}
|
||||
|
||||
return status;
|
||||
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
|
||||
@@ -581,9 +541,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
|
||||
status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
|
||||
|
||||
if (status == GRUB_EFI_NO_MEDIA)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name);
|
||||
else if (status != GRUB_EFI_SUCCESS)
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return grub_error (GRUB_ERR_READ_ERROR,
|
||||
N_("failure reading sector 0x%llx from `%s'"),
|
||||
(unsigned long long) sector,
|
||||
@@ -604,9 +562,7 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
|
||||
status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
|
||||
|
||||
if (status == GRUB_EFI_NO_MEDIA)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name);
|
||||
else if (status != GRUB_EFI_SUCCESS)
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return grub_error (GRUB_ERR_WRITE_ERROR,
|
||||
N_("failure writing sector 0x%llx to `%s'"),
|
||||
(unsigned long long) sector, disk->name);
|
||||
|
||||
@@ -227,10 +227,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
||||
|
||||
if (grub_ieee1275_open (alias->path, &ihandle))
|
||||
return;
|
||||
|
||||
/* This method doesn't need memory allocation for the table. Open
|
||||
firmware takes care of all memory management and the result table
|
||||
stays in memory and is never freed. */
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
||||
args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
|
||||
args.ihandle = ihandle;
|
||||
@@ -263,82 +260,6 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
||||
grub_free (buf);
|
||||
return;
|
||||
}
|
||||
else if (grub_strcmp (alias->type, "sas_ioa") == 0)
|
||||
{
|
||||
/* The method returns the number of disks and a table where
|
||||
* each ID is 64-bit long. Example of sas paths:
|
||||
* /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800
|
||||
* /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800
|
||||
* /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */
|
||||
|
||||
struct sas_children
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_cell_t method;
|
||||
grub_ieee1275_cell_t ihandle;
|
||||
grub_ieee1275_cell_t max;
|
||||
grub_ieee1275_cell_t table;
|
||||
grub_ieee1275_cell_t catch_result;
|
||||
grub_ieee1275_cell_t nentries;
|
||||
}
|
||||
args;
|
||||
char *buf, *bufptr;
|
||||
unsigned i;
|
||||
grub_uint64_t *table;
|
||||
grub_uint16_t table_size;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
|
||||
buf = grub_malloc (grub_strlen (alias->path) +
|
||||
sizeof ("/disk@7766554433221100"));
|
||||
if (!buf)
|
||||
return;
|
||||
bufptr = grub_stpcpy (buf, alias->path);
|
||||
|
||||
/* Power machines documentation specify 672 as maximum SAS disks in
|
||||
one system. Using a slightly larger value to be safe. */
|
||||
table_size = 768;
|
||||
table = grub_malloc (table_size * sizeof (grub_uint64_t));
|
||||
|
||||
if (!table)
|
||||
{
|
||||
grub_free (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (grub_ieee1275_open (alias->path, &ihandle))
|
||||
{
|
||||
grub_free (buf);
|
||||
grub_free (table);
|
||||
return;
|
||||
}
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2);
|
||||
args.method = (grub_ieee1275_cell_t) "get-sas-children";
|
||||
args.ihandle = ihandle;
|
||||
args.max = table_size;
|
||||
args.table = (grub_ieee1275_cell_t) table;
|
||||
args.catch_result = 0;
|
||||
args.nentries = 0;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
{
|
||||
grub_ieee1275_close (ihandle);
|
||||
grub_free (table);
|
||||
grub_free (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.nentries; i++)
|
||||
{
|
||||
grub_snprintf (bufptr, sizeof ("/disk@7766554433221100"),
|
||||
"/disk@%" PRIxGRUB_UINT64_T, table[i]);
|
||||
dev_iterate_real (buf, buf);
|
||||
}
|
||||
|
||||
grub_ieee1275_close (ihandle);
|
||||
grub_free (table);
|
||||
grub_free (buf);
|
||||
}
|
||||
|
||||
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
|
||||
&& grub_strcmp (alias->type, "block") == 0)
|
||||
|
||||
@@ -154,10 +154,7 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
|
||||
s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE
|
||||
: GRUB_EFI_RUNTIME_SERVICES_DATA);
|
||||
if (seg->handle < 0)
|
||||
{
|
||||
grub_free (seg);
|
||||
return grub_errno;
|
||||
}
|
||||
return grub_errno;
|
||||
seg->off = 0;
|
||||
}
|
||||
|
||||
@@ -346,7 +343,7 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, const char *filename,
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
|
||||
|
||||
/* Make sure that every section is within the core. */
|
||||
if ((grub_size_t) core_size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum)
|
||||
if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum)
|
||||
return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
|
||||
filename);
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ grub_efiemu_load_file (const char *filename)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_efiemu_unload ();
|
||||
return err;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_dprintf ("efiemu", "mm initialized\n");
|
||||
|
||||
@@ -99,8 +99,7 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
|
||||
grub_size_t align_overhead;
|
||||
struct grub_efiemu_memrequest *ret, *cur, *prev;
|
||||
/* Check that the request is correct */
|
||||
if (type <= GRUB_EFI_LOADER_CODE || type == GRUB_EFI_PERSISTENT_MEMORY ||
|
||||
type >= GRUB_EFI_MAX_MEMORY_TYPE)
|
||||
if (type >= GRUB_EFI_MAX_MEMORY_TYPE || type <= GRUB_EFI_LOADER_CODE)
|
||||
return -2;
|
||||
|
||||
/* Add new size to requested size */
|
||||
@@ -167,13 +166,6 @@ efiemu_alloc_requests (void)
|
||||
GRUB_EFI_MEMORY_MAPPED_IO,
|
||||
GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
|
||||
GRUB_EFI_PAL_CODE
|
||||
|
||||
/*
|
||||
* These are not allocatable:
|
||||
* GRUB_EFI_RESERVED_MEMORY_TYPE
|
||||
* GRUB_EFI_PERSISTENT_MEMORY
|
||||
* >= GRUB_EFI_MAX_MEMORY_TYPE
|
||||
*/
|
||||
};
|
||||
|
||||
/* Compute total memory needed */
|
||||
@@ -410,10 +402,6 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_ACPI_MEMORY_NVS);
|
||||
|
||||
case GRUB_MEMORY_PERSISTENT:
|
||||
case GRUB_MEMORY_PERSISTENT_LEGACY:
|
||||
return grub_efiemu_add_to_mmap (addr, size,
|
||||
GRUB_EFI_PERSISTENT_MEMORY);
|
||||
default:
|
||||
grub_dprintf ("efiemu",
|
||||
"Unknown memory type %d. Assuming unusable\n", type);
|
||||
@@ -457,7 +445,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO:
|
||||
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
|
||||
case GRUB_EFI_PAL_CODE:
|
||||
default:
|
||||
case GRUB_EFI_MAX_MEMORY_TYPE:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_MEMORY_RESERVED, hook_data);
|
||||
break;
|
||||
@@ -480,12 +468,6 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_MEMORY_NVS, hook_data);
|
||||
break;
|
||||
|
||||
case GRUB_EFI_PERSISTENT_MEMORY:
|
||||
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
|
||||
GRUB_MEMORY_PERSISTENT, hook_data);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -521,8 +503,7 @@ grub_efiemu_mmap_sort_and_uniq (void)
|
||||
[GRUB_EFI_ACPI_MEMORY_NVS] = 3,
|
||||
[GRUB_EFI_MEMORY_MAPPED_IO] = 4,
|
||||
[GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 4,
|
||||
[GRUB_EFI_PAL_CODE] = 4,
|
||||
[GRUB_EFI_PERSISTENT_MEMORY] = 4
|
||||
[GRUB_EFI_PAL_CODE] = 4
|
||||
};
|
||||
|
||||
int i, j, k, done;
|
||||
|
||||
@@ -83,16 +83,10 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
|
||||
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
|
||||
|
||||
/* Put pointer to the list of configuration tables in system table */
|
||||
err = grub_efiemu_write_value
|
||||
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
|
||||
conftable_handle, 0, 1,
|
||||
sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
|
||||
if (err)
|
||||
{
|
||||
grub_efiemu_unload ();
|
||||
return err;
|
||||
}
|
||||
|
||||
grub_efiemu_write_value
|
||||
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
|
||||
conftable_handle, 0, 1,
|
||||
sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
|
||||
SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables;
|
||||
|
||||
/* Fill the list of configuration tables */
|
||||
|
||||
@@ -344,16 +344,8 @@ init_cbfsdisk (void)
|
||||
|
||||
ptr = *(grub_uint32_t *) 0xfffffffc;
|
||||
head = (struct cbfs_header *) (grub_addr_t) ptr;
|
||||
grub_dprintf ("cbfs", "head=%p\n", head);
|
||||
|
||||
/* coreboot current supports only ROMs <= 16 MiB. Bigger ROMs will
|
||||
have problems as RCBA is 18 MiB below end of 32-bit typically,
|
||||
so either memory map would have to be rearranged or we'd need to support
|
||||
reading ROMs through controller directly.
|
||||
*/
|
||||
if (ptr < 0xff000000
|
||||
|| 0xffffffff - ptr < (grub_uint32_t) sizeof (*head) + 0xf
|
||||
|| !validate_head (head))
|
||||
if (!validate_head (head))
|
||||
return;
|
||||
|
||||
cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize),
|
||||
|
||||
@@ -89,9 +89,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
|
||||
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
|
||||
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
|
||||
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
|
||||
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
|
||||
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
|
||||
/* Superblock filesystem feature flags (back-incompatible)
|
||||
* A filesystem with any of these enabled should not be attempted to be read
|
||||
* by a driver that does not understand them, since they usually indicate
|
||||
@@ -105,11 +102,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
||||
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
||||
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
||||
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
|
||||
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
|
||||
#define EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM 0x2000 /* use crc32c for bg */
|
||||
#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
|
||||
#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
|
||||
|
||||
/* The set of back-incompatible features this driver DOES support. Add (OR)
|
||||
* flags here as the related features are implemented into the driver. */
|
||||
@@ -117,8 +109,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
| EXT4_FEATURE_INCOMPAT_EXTENTS \
|
||||
| EXT4_FEATURE_INCOMPAT_FLEX_BG \
|
||||
| EXT2_FEATURE_INCOMPAT_META_BG \
|
||||
| EXT4_FEATURE_INCOMPAT_64BIT \
|
||||
| EXT4_FEATURE_INCOMPAT_INLINE_DATA)
|
||||
| EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
/* List of rationales for the ignored "incompatible" features:
|
||||
* needs_recovery: Not really back-incompatible - was added as such to forbid
|
||||
* ext2 drivers from mounting an ext3 volume with a dirty
|
||||
@@ -325,40 +316,12 @@ struct grub_ext4_extent_idx
|
||||
grub_uint16_t unused;
|
||||
};
|
||||
|
||||
#define EXT4_XATTR_MAGIC 0xEA020000
|
||||
#define EXT4_XATTR_INDEX_SYSTEM 7
|
||||
#define EXT4_XATTR_SYSTEM_DATA "data"
|
||||
#define EXT4_INLINE_DOTDOT_SIZE 4
|
||||
|
||||
struct grub_ext4_xattr_entry
|
||||
{
|
||||
grub_uint8_t name_len; /* length of name */
|
||||
grub_uint8_t name_index; /* attribute name index */
|
||||
grub_uint16_t value_offs; /* offset in disk block of value */
|
||||
grub_uint32_t value_block; /* disk block attribute is stored on */
|
||||
grub_uint32_t value_size; /* size of attribute value */
|
||||
grub_uint32_t hash; /* hash value of name and value */
|
||||
char name[0]; /* attribute name */
|
||||
} GRUB_PACKED;
|
||||
|
||||
#define EXT4_XATTR_LEN(name_len) \
|
||||
(ALIGN_UP((name_len) + sizeof(struct grub_ext4_xattr_entry), 4))
|
||||
#define EXT4_XATTR_NEXT(entry) \
|
||||
((struct grub_ext4_xattr_entry *)( \
|
||||
(char *)(entry) + EXT4_XATTR_LEN((entry)->name_len)))
|
||||
#define IS_LAST_ENTRY(entry) (grub_get_unaligned32 (entry) == 0)
|
||||
|
||||
|
||||
struct grub_fshelp_node
|
||||
{
|
||||
struct grub_ext2_data *data;
|
||||
struct grub_ext2_inode inode;
|
||||
grub_uint32_t ino;
|
||||
int ino;
|
||||
int inode_read;
|
||||
grub_disk_addr_t inode_base; /* Inode filesystem block */
|
||||
grub_off_t inode_offs; /* Inode offset in filesystem block */
|
||||
grub_off_t inline_offs; /* Offset of inline data from start of inode */
|
||||
grub_size_t inline_size; /* Size of inline data */
|
||||
};
|
||||
|
||||
/* Information about a "mounted" ext2 filesystem. */
|
||||
@@ -404,66 +367,6 @@ group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
|
||||
is_power_of(group, 3));
|
||||
}
|
||||
|
||||
/* Inline data is stored using inline extended attributes. Attributes consist
|
||||
of entry and value. Entries start after inode proper, following 4 bytes
|
||||
magic header. Each entry is 4 bytes aligned, end of list is marked with
|
||||
4 bytes zero. Values are stored after entries.
|
||||
|
||||
Inline data is stored as system attribute with name "data". First part of
|
||||
data is kept in space reserved for block pointers, so it is valid for value
|
||||
size to be zero. Offset is apparently non-zero even in this case.
|
||||
*/
|
||||
inline static void
|
||||
grub_ext2_find_inline_data (struct grub_fshelp_node *node, grub_size_t isize,
|
||||
struct grub_ext2_inode *inode)
|
||||
{
|
||||
grub_size_t extra;
|
||||
grub_uint8_t *ihdr;
|
||||
struct grub_ext4_xattr_entry *entry;
|
||||
grub_uint8_t *iend = (grub_uint8_t *) inode + isize - sizeof (grub_uint32_t);
|
||||
|
||||
node->inline_offs = 0;
|
||||
|
||||
if (isize < EXT2_GOOD_OLD_INODE_SIZE + sizeof (grub_uint16_t))
|
||||
return;
|
||||
extra = grub_le_to_cpu16 (*((grub_uint16_t *) inode
|
||||
+ (EXT2_GOOD_OLD_INODE_SIZE / 2)));
|
||||
if (EXT2_GOOD_OLD_INODE_SIZE + extra + 4 > isize)
|
||||
return;
|
||||
ihdr = ((grub_uint8_t *) inode
|
||||
+ EXT2_GOOD_OLD_INODE_SIZE + extra);
|
||||
if (grub_get_unaligned32 (ihdr)
|
||||
!= grub_cpu_to_le32_compile_time (EXT4_XATTR_MAGIC))
|
||||
return;
|
||||
entry = (struct grub_ext4_xattr_entry *) (ihdr + 4);
|
||||
for (; (grub_uint8_t *) entry < iend && !IS_LAST_ENTRY(entry);
|
||||
entry = EXT4_XATTR_NEXT(entry))
|
||||
{
|
||||
grub_size_t value_size;
|
||||
grub_off_t value_offs;
|
||||
|
||||
if (entry->value_block)
|
||||
continue;
|
||||
if (entry->name_index != EXT4_XATTR_INDEX_SYSTEM)
|
||||
continue;
|
||||
if (entry->name_len != sizeof (EXT4_XATTR_SYSTEM_DATA) - 1)
|
||||
continue;
|
||||
if (grub_memcmp (entry->name, EXT4_XATTR_SYSTEM_DATA, sizeof (EXT4_XATTR_SYSTEM_DATA) - 1))
|
||||
continue;
|
||||
value_size = grub_le_to_cpu32 (entry->value_size);
|
||||
value_offs = grub_le_to_cpu16 (entry->value_offs);
|
||||
/* extra is additional size of base inode. Extended attributes start
|
||||
after base inode, offset is calculated from the end of extended
|
||||
attributes header.
|
||||
*/
|
||||
if (EXT2_GOOD_OLD_INODE_SIZE + extra + 4 + value_offs + value_size > isize)
|
||||
continue;
|
||||
node->inline_offs = EXT2_GOOD_OLD_INODE_SIZE + extra + 4 + value_offs;
|
||||
node->inline_size = value_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
|
||||
the mounted filesystem DATA. */
|
||||
inline static grub_err_t
|
||||
@@ -665,52 +568,6 @@ grub_ext2_read_file (grub_fshelp_node_t node,
|
||||
grub_disk_read_hook_t read_hook, void *read_hook_data,
|
||||
grub_off_t pos, grub_size_t len, char *buf)
|
||||
{
|
||||
/* Does inode have inine data? */
|
||||
if (node->inline_offs)
|
||||
{
|
||||
grub_size_t cp_len;
|
||||
grub_off_t cp_pos;
|
||||
grub_ssize_t total = 0;
|
||||
|
||||
if (pos < 60)
|
||||
{
|
||||
cp_pos = node->inode_offs + ((char *)&node->inode.blocks - (char *)&node->inode) + pos;
|
||||
cp_len = 60 - pos;
|
||||
if (cp_len > len)
|
||||
cp_len = len;
|
||||
|
||||
node->data->disk->read_hook = read_hook;
|
||||
node->data->disk->read_hook_data = read_hook_data;
|
||||
grub_disk_read (node->data->disk, node->inode_base, cp_pos,
|
||||
cp_len, buf);
|
||||
node->data->disk->read_hook = 0;
|
||||
if (grub_errno)
|
||||
return -1;
|
||||
pos += cp_len;
|
||||
buf += cp_len;
|
||||
len -= cp_len;
|
||||
total = cp_len;
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
pos -= 60;
|
||||
if (pos >= node->inline_size)
|
||||
return 0;
|
||||
if (pos + len > node->inline_size)
|
||||
len = node->inline_size - pos;
|
||||
cp_pos = node->inode_offs + node->inline_offs + pos;
|
||||
node->data->disk->read_hook = read_hook;
|
||||
node->data->disk->read_hook_data = read_hook_data;
|
||||
grub_disk_read (node->data->disk, node->inode_base, cp_pos,
|
||||
len, buf);
|
||||
node->data->disk->read_hook = 0;
|
||||
if (!grub_errno)
|
||||
total += len;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
return grub_fshelp_read_file (node->data->disk, node,
|
||||
read_hook, read_hook_data,
|
||||
pos, len, buf, grub_ext2_read_block,
|
||||
@@ -721,28 +578,17 @@ grub_ext2_read_file (grub_fshelp_node_t node,
|
||||
}
|
||||
|
||||
|
||||
/* Read the inode NODE->INO for the file described by NODE->DATA into NODE->INODE. */
|
||||
/* Read the inode INO for the file described by DATA into INODE. */
|
||||
static grub_err_t
|
||||
grub_ext2_read_inode (struct grub_fshelp_node *node)
|
||||
grub_ext2_read_inode (struct grub_ext2_data *data,
|
||||
int ino, struct grub_ext2_inode *inode)
|
||||
{
|
||||
struct grub_ext2_data *data = node->data;
|
||||
grub_uint32_t ino = node->ino;
|
||||
struct grub_ext2_block_group blkgrp;
|
||||
struct grub_ext2_sblock *sblock = &data->sblock;
|
||||
int inodes_per_block;
|
||||
unsigned int blkno;
|
||||
unsigned int blkoff;
|
||||
grub_disk_addr_t base;
|
||||
struct grub_ext2_inode *full_inode;
|
||||
grub_size_t full_isize;
|
||||
|
||||
if (node->inode_read)
|
||||
return 0;
|
||||
|
||||
full_isize = EXT2_INODE_SIZE (data);
|
||||
full_inode = grub_malloc (full_isize);
|
||||
if (!full_inode)
|
||||
return 0;
|
||||
|
||||
/* It is easier to calculate if the first inode is 0. */
|
||||
ino--;
|
||||
@@ -751,12 +597,9 @@ grub_ext2_read_inode (struct grub_fshelp_node *node)
|
||||
ino / grub_le_to_cpu32 (sblock->inodes_per_group),
|
||||
&blkgrp);
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_free (full_inode);
|
||||
return grub_errno;
|
||||
}
|
||||
return grub_errno;
|
||||
|
||||
inodes_per_block = EXT2_BLOCK_SIZE (data) / full_isize;
|
||||
inodes_per_block = EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data);
|
||||
blkno = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
|
||||
/ inodes_per_block;
|
||||
blkoff = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
|
||||
@@ -768,19 +611,12 @@ grub_ext2_read_inode (struct grub_fshelp_node *node)
|
||||
<< 32);
|
||||
|
||||
/* Read the inode. */
|
||||
node->inode_base = (base + blkno) << LOG2_EXT2_BLOCK_SIZE (data);
|
||||
node->inode_offs = full_isize * blkoff;
|
||||
if (grub_disk_read (data->disk, node->inode_base, node->inode_offs,
|
||||
full_isize, full_inode))
|
||||
{
|
||||
grub_free (full_inode);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_memcpy (&node->inode, full_inode, sizeof (struct grub_ext2_inode));
|
||||
if (grub_disk_read (data->disk,
|
||||
((base + blkno) << LOG2_EXT2_BLOCK_SIZE (data)),
|
||||
EXT2_INODE_SIZE (data) * blkoff,
|
||||
sizeof (struct grub_ext2_inode), inode))
|
||||
return grub_errno;
|
||||
|
||||
node->inode_read = 1;
|
||||
grub_ext2_find_inline_data (node, full_isize, full_inode);
|
||||
grub_free (full_inode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -841,9 +677,11 @@ grub_ext2_mount (grub_disk_t disk)
|
||||
|
||||
data->diropen.data = data;
|
||||
data->diropen.ino = 2;
|
||||
data->diropen.inode_read = 1;
|
||||
|
||||
data->inode = &data->diropen.inode;
|
||||
|
||||
grub_ext2_read_inode (&data->diropen);
|
||||
grub_ext2_read_inode (data, 2, data->inode);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
@@ -863,9 +701,12 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
|
||||
char *symlink;
|
||||
struct grub_fshelp_node *diro = node;
|
||||
|
||||
grub_ext2_read_inode (diro);
|
||||
if (grub_errno)
|
||||
return 0;
|
||||
if (! diro->inode_read)
|
||||
{
|
||||
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
|
||||
if (grub_errno)
|
||||
return 0;
|
||||
}
|
||||
|
||||
symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1);
|
||||
if (! symlink)
|
||||
@@ -901,42 +742,11 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
|
||||
unsigned int fpos = 0;
|
||||
struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
|
||||
|
||||
grub_ext2_read_inode (diro);
|
||||
if (grub_errno)
|
||||
return 0;
|
||||
|
||||
/* Inline directory has only parent inode number and no explicit entries
|
||||
for . or ..; simulate them */
|
||||
if (diro->inline_offs)
|
||||
if (! diro->inode_read)
|
||||
{
|
||||
struct grub_fshelp_node *dot, *dotdot;
|
||||
grub_uint32_t inum;
|
||||
|
||||
dot = grub_malloc (sizeof (struct grub_fshelp_node));
|
||||
if (!dot)
|
||||
return 0;
|
||||
|
||||
dot->inode_read = 0;
|
||||
dot->ino = dir->ino;
|
||||
dot->data = diro->data;
|
||||
if (hook (".", FILETYPE_DIRECTORY, dot, hook_data))
|
||||
return 1;
|
||||
|
||||
/* First 4 bytes of inline directory data is parent inode number */
|
||||
grub_ext2_read_file (diro, 0, 0, 0, EXT4_INLINE_DOTDOT_SIZE, (char *) &inum);
|
||||
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
|
||||
if (grub_errno)
|
||||
return 0;
|
||||
dotdot = grub_malloc (sizeof (struct grub_fshelp_node));
|
||||
if (!dotdot)
|
||||
return 0;
|
||||
|
||||
dotdot->inode_read = 0;
|
||||
dotdot->ino = grub_le_to_cpu32 (inum);
|
||||
dotdot->data = diro->data;
|
||||
if (hook ("..", FILETYPE_DIRECTORY, dotdot, hook_data))
|
||||
return 1;
|
||||
|
||||
fpos = EXT4_INLINE_DOTDOT_SIZE;
|
||||
}
|
||||
|
||||
/* Search the file. */
|
||||
@@ -987,13 +797,17 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
|
||||
{
|
||||
/* The filetype can not be read from the dirent, read
|
||||
the inode to get more information. */
|
||||
grub_ext2_read_inode (fdiro);
|
||||
grub_ext2_read_inode (diro->data,
|
||||
grub_le_to_cpu32 (dirent.inode),
|
||||
&fdiro->inode);
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_free (fdiro);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fdiro->inode_read = 1;
|
||||
|
||||
if ((grub_le_to_cpu16 (fdiro->inode.mode)
|
||||
& FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
|
||||
type = GRUB_FSHELP_DIR;
|
||||
@@ -1038,11 +852,14 @@ grub_ext2_open (struct grub_file *file, const char *name)
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
err = grub_ext2_read_inode (fdiro);
|
||||
if (err)
|
||||
goto fail;
|
||||
if (! fdiro->inode_read)
|
||||
{
|
||||
err = grub_ext2_read_inode (data, fdiro->ino, &fdiro->inode);
|
||||
if (err)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_memcpy (&data->diropen, fdiro, sizeof (struct grub_fshelp_node));
|
||||
grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode));
|
||||
grub_free (fdiro);
|
||||
|
||||
file->size = grub_le_to_cpu32 (data->inode->size);
|
||||
@@ -1101,9 +918,13 @@ grub_ext2_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
||||
struct grub_dirhook_info info;
|
||||
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
grub_ext2_read_inode (node);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
if (! node->inode_read)
|
||||
{
|
||||
grub_ext2_read_inode (ctx->data, node->ino, &node->inode);
|
||||
if (!grub_errno)
|
||||
node->inode_read = 1;
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
if (node->inode_read)
|
||||
{
|
||||
info.mtimeset = 1;
|
||||
|
||||
@@ -681,7 +681,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
|
||||
ctxt->dir.file_size
|
||||
= grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size);
|
||||
ctxt->dir.have_stream = 1;
|
||||
ctxt->dir.is_contiguous = !!(sec.type_specific.stream_extension.flags
|
||||
ctxt->dir.is_contiguous = !!(dir.type_specific.stream_extension.flags
|
||||
& grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS));
|
||||
break;
|
||||
case 0xc1:
|
||||
|
||||
@@ -1308,7 +1308,6 @@ grub_hfs_open (struct grub_file *file, const char *name)
|
||||
if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
|
||||
{
|
||||
grub_free (data);
|
||||
grub_free (found);
|
||||
grub_dl_unref (my_mod);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
@@ -750,15 +750,19 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
|
||||
|
||||
if (dir->data->joliet && !ctx.filename)
|
||||
{
|
||||
char *semicolon;
|
||||
char *oldname, *semicolon;
|
||||
|
||||
oldname = name;
|
||||
ctx.filename = grub_iso9660_convert_string
|
||||
((grub_uint8_t *) name, dirent.namelen >> 1);
|
||||
((grub_uint8_t *) oldname, dirent.namelen >> 1);
|
||||
|
||||
semicolon = grub_strrchr (ctx.filename, ';');
|
||||
if (semicolon)
|
||||
*semicolon = '\0';
|
||||
|
||||
if (ctx.filename_alloc)
|
||||
grub_free (oldname);
|
||||
|
||||
ctx.filename_alloc = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest)
|
||||
if (tag & 1)
|
||||
{
|
||||
grub_uint32_t i, len, delta, code, lmask, dshift;
|
||||
grub_uint16_t word = 0;
|
||||
grub_uint16_t word;
|
||||
|
||||
if (decomp_get16 (cc, &word))
|
||||
return grub_errno;
|
||||
|
||||
@@ -775,10 +775,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
c = de->name[de->len];
|
||||
de->name[de->len] = '\0';
|
||||
if (iterate_dir_call_hook (ino, de->name, &ctx))
|
||||
{
|
||||
de->name[de->len] = c;
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
de->name[de->len] = c;
|
||||
|
||||
de = grub_xfs_inline_next_de(dir->data, head, de);
|
||||
|
||||
@@ -3132,7 +3132,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
|
||||
{
|
||||
void *osp;
|
||||
blkptr_t *bp;
|
||||
grub_size_t ospsize = 0;
|
||||
grub_size_t ospsize;
|
||||
grub_err_t err;
|
||||
|
||||
grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
|
||||
|
||||
@@ -184,8 +184,6 @@ LZ4_uncompress_unknownOutputSize(const char *source,
|
||||
}
|
||||
}
|
||||
/* copy literals */
|
||||
if ((grub_addr_t) length > ~(grub_addr_t)op)
|
||||
goto _output_error;
|
||||
cpy = op + length;
|
||||
if ((cpy > oend - COPYLENGTH) ||
|
||||
(ip + length > iend - COPYLENGTH)) {
|
||||
|
||||
@@ -15,12 +15,12 @@ set -e
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod
|
||||
# genmod.sh moddep.lst normal.module normal.mod
|
||||
#
|
||||
|
||||
moddep=$1
|
||||
infile=$2
|
||||
outfile=$4
|
||||
outfile=$3
|
||||
|
||||
tmpfile=${outfile}.tmp
|
||||
modname=`echo $infile | sed -e 's@\.module.*$@@'`
|
||||
@@ -58,7 +58,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then
|
||||
-K grub_mod_init -K grub_mod_fini \
|
||||
-K _grub_mod_init -K _grub_mod_fini \
|
||||
-R .note.gnu.gold-version -R .note.GNU-stack \
|
||||
-R .note -R .comment -R .ARM.exidx $tmpfile || exit 1
|
||||
-R .note -R .comment $tmpfile || exit 1
|
||||
fi
|
||||
if ! test -z "${TARGET_OBJ2ELF}"; then
|
||||
"${TARGET_OBJ2ELF}" $tmpfile || exit 1
|
||||
@@ -91,9 +91,6 @@ else
|
||||
-nr:_grub_mod_init:grub_mod_init \
|
||||
-nr:_grub_mod_fini:grub_mod_fini \
|
||||
-wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1
|
||||
rm -f $tmpfile.bin
|
||||
fi
|
||||
if test x@platform@ != xemu; then
|
||||
./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@
|
||||
rm -f $name.bin
|
||||
fi
|
||||
mv $tmpfile $outfile
|
||||
|
||||
@@ -29,7 +29,7 @@ BEGIN {
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
|
||||
printf "error: %u: unrecognized input format\n", NR;
|
||||
error++;
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,6 @@ END {
|
||||
if (error >= 1)
|
||||
exit 1;
|
||||
|
||||
total_depcount = 0
|
||||
|
||||
for (mod in modtab) {
|
||||
# Remove duplications.
|
||||
split(modtab[mod], depmods, " ");
|
||||
@@ -54,42 +52,14 @@ END {
|
||||
uniqmods[depmod] = 1;
|
||||
}
|
||||
modlist = ""
|
||||
depcount[mod] = 0
|
||||
for (depmod in uniqmods) {
|
||||
modlist = modlist " " depmod;
|
||||
inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
|
||||
depcount[mod]++
|
||||
total_depcount++
|
||||
}
|
||||
if (mod == "all_video") {
|
||||
continue;
|
||||
}
|
||||
printf "%s:%s\n", mod, modlist;
|
||||
}
|
||||
|
||||
# Check that we have no dependency circles
|
||||
while (total_depcount != 0) {
|
||||
something_done = 0
|
||||
for (mod in depcount) {
|
||||
if (depcount[mod] == 0) {
|
||||
delete depcount[mod]
|
||||
split(inverse_dependencies[mod], inv_depmods, " ");
|
||||
for (ctr in inv_depmods) {
|
||||
depcount[inv_depmods[ctr]]--
|
||||
total_depcount--
|
||||
}
|
||||
delete inverse_dependencies[mod]
|
||||
something_done = 1
|
||||
}
|
||||
}
|
||||
if (something_done == 0) {
|
||||
for (mod in depcount) {
|
||||
circle = circle " " mod
|
||||
}
|
||||
printf "error: modules %s form a dependency circle\n", circle >"/dev/stderr";
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
modlist = ""
|
||||
while (getline <"video.lst") {
|
||||
modlist = modlist " " $1;
|
||||
|
||||
@@ -45,7 +45,6 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
||||
grub_uint32_t *logical;
|
||||
grub_ssize_t logical_len, visual_len;
|
||||
struct grub_unicode_glyph *visual, *ptr;
|
||||
grub_err_t err;
|
||||
|
||||
logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0);
|
||||
if (logical_len < 0)
|
||||
@@ -57,28 +56,24 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
||||
if (visual_len < 0)
|
||||
return grub_errno;
|
||||
|
||||
err = GRUB_ERR_NONE;
|
||||
for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++)
|
||||
{
|
||||
grub_err_t err;
|
||||
struct grub_font_glyph *glyph;
|
||||
glyph = grub_font_construct_glyph (font, ptr);
|
||||
if (!glyph)
|
||||
{
|
||||
err = grub_errno;
|
||||
goto out;
|
||||
}
|
||||
return grub_errno;
|
||||
err = grub_font_draw_glyph (glyph, color, x, baseline_y);
|
||||
if (err)
|
||||
goto out;
|
||||
x += glyph->device_width;
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
out:
|
||||
for (ptr = visual; ptr < visual + visual_len; ptr++)
|
||||
grub_unicode_destroy_glyph (ptr);
|
||||
grub_free (visual);
|
||||
|
||||
return err;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Get the width in pixels of the specified UTF-8 string, when rendered in
|
||||
|
||||
@@ -63,14 +63,14 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
|
||||
"theme");
|
||||
|
||||
err = grub_video_get_info (&mode_info);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
instance = grub_zalloc (sizeof (*instance));
|
||||
if (!instance)
|
||||
return grub_errno;
|
||||
|
||||
err = grub_video_get_info (&mode_info);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (theme_path[0] != '/' && theme_path[0] != '(')
|
||||
{
|
||||
const char *prefix;
|
||||
|
||||
@@ -255,7 +255,7 @@ theme_set_string (grub_gfxmenu_view_t view,
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.height,
|
||||
view->screen.width,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
@@ -275,7 +275,7 @@ theme_set_string (grub_gfxmenu_view_t view,
|
||||
{
|
||||
unsigned int tmp;
|
||||
int err = theme_get_unsigned_int_from_proportional (value,
|
||||
view->screen.height,
|
||||
view->screen.width,
|
||||
&tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2012 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/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/acpi.h>
|
||||
|
||||
/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */
|
||||
grub_uint8_t
|
||||
grub_byte_checksum (void *base, grub_size_t size)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
grub_uint8_t ret = 0;
|
||||
for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size;
|
||||
ptr++)
|
||||
ret += *ptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *
|
||||
grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig)
|
||||
{
|
||||
grub_size_t s;
|
||||
grub_unaligned_uint32_t *ptr;
|
||||
|
||||
if (!rsdt)
|
||||
return 0;
|
||||
|
||||
if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0)
|
||||
return 0;
|
||||
|
||||
ptr = (grub_unaligned_uint32_t *) (rsdt + 1);
|
||||
s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t);
|
||||
for (; s; s--, ptr++)
|
||||
{
|
||||
struct grub_acpi_table_header *tbl;
|
||||
tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val;
|
||||
if (grub_memcmp (tbl->signature, sig, 4) == 0)
|
||||
return tbl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *
|
||||
grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig)
|
||||
{
|
||||
grub_size_t s;
|
||||
grub_unaligned_uint64_t *ptr;
|
||||
|
||||
if (!xsdt)
|
||||
return 0;
|
||||
|
||||
if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0)
|
||||
return 0;
|
||||
|
||||
ptr = (grub_unaligned_uint64_t *) (xsdt + 1);
|
||||
s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t);
|
||||
for (; s; s--, ptr++)
|
||||
{
|
||||
struct grub_acpi_table_header *tbl;
|
||||
#if GRUB_CPU_SIZEOF_VOID_P != 8
|
||||
if (ptr->val >> 32)
|
||||
continue;
|
||||
#endif
|
||||
tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val;
|
||||
if (grub_memcmp (tbl->signature, sig, 4) == 0)
|
||||
return tbl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct grub_acpi_fadt *
|
||||
grub_acpi_find_fadt (void)
|
||||
{
|
||||
struct grub_acpi_fadt *fadt = 0;
|
||||
struct grub_acpi_rsdp_v10 *rsdpv1;
|
||||
struct grub_acpi_rsdp_v20 *rsdpv2;
|
||||
rsdpv1 = grub_machine_acpi_get_rsdpv1 ();
|
||||
if (rsdpv1)
|
||||
fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *)
|
||||
(grub_addr_t) rsdpv1->rsdt_addr,
|
||||
GRUB_ACPI_FADT_SIGNATURE);
|
||||
if (fadt)
|
||||
return fadt;
|
||||
rsdpv2 = grub_machine_acpi_get_rsdpv2 ();
|
||||
if (rsdpv2)
|
||||
fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *)
|
||||
(grub_addr_t) rsdpv2->rsdpv1.rsdt_addr,
|
||||
GRUB_ACPI_FADT_SIGNATURE);
|
||||
if (fadt)
|
||||
return fadt;
|
||||
if (rsdpv2
|
||||
#if GRUB_CPU_SIZEOF_VOID_P != 8
|
||||
&& !(rsdpv2->xsdt_addr >> 32)
|
||||
#endif
|
||||
)
|
||||
fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *)
|
||||
(grub_addr_t) rsdpv2->xsdt_addr,
|
||||
GRUB_ACPI_FADT_SIGNATURE);
|
||||
if (fadt)
|
||||
return fadt;
|
||||
return 0;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ static void
|
||||
increment_timer (grub_efi_event_t event __attribute__ ((unused)),
|
||||
void *context __attribute__ ((unused)))
|
||||
{
|
||||
tmr += 10;
|
||||
tmr++;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -52,7 +52,7 @@ grub_machine_init (void)
|
||||
|
||||
efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL,
|
||||
GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt);
|
||||
efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 100000);
|
||||
efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 10000);
|
||||
|
||||
grub_install_get_time_ms (grub_efi_get_time_ms);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ FUNCTION(_start)
|
||||
VARIABLE(grub_total_module_size)
|
||||
.long 0
|
||||
|
||||
VARIABLE(grub_uboot_machine_type)
|
||||
.long 0
|
||||
VARIABLE(grub_uboot_boot_data)
|
||||
.long 0
|
||||
VARIABLE(grub_modbase)
|
||||
.long 0
|
||||
bss_start_ptr:
|
||||
@@ -62,66 +66,29 @@ bss_start_ptr:
|
||||
end_ptr:
|
||||
.long EXT_C(_end)
|
||||
|
||||
@ Memory map at start:
|
||||
@ * text+data
|
||||
@ * list relocations
|
||||
@ * modules
|
||||
@ Before we enter C, we need to apply the relocations
|
||||
@ and get following map:
|
||||
@ * text+data
|
||||
@ * BSS (cleared)
|
||||
@ * stack
|
||||
@ * modules
|
||||
@
|
||||
@ To make things easier we ensure
|
||||
@ that BSS+stack is larger than list of relocations
|
||||
@ by increasing stack if necessarry.
|
||||
@ This allows us to always unconditionally copy backwards
|
||||
@ Currently list of relocations is ~5K and stack is set
|
||||
@ to be at least 256K
|
||||
|
||||
FUNCTION(codestart)
|
||||
@ Store context: Machine ID, atags/dtb, ...
|
||||
@ U-Boot API signature is stored on the U-Boot heap
|
||||
@ Stack pointer used as start address for signature probing
|
||||
mov r12, sp
|
||||
adr sp, entry_state
|
||||
push {r1-r12,lr} @ store U-Boot context (sp in r12)
|
||||
push {r4-r12,lr} @ store U-Boot context (sp in r12)
|
||||
|
||||
adr r1, _start
|
||||
ldr r0, bss_start_ptr @ src
|
||||
add r0, r0, r1
|
||||
str r1, EXT_C(grub_uboot_machine_type)
|
||||
str r2, EXT_C(grub_uboot_boot_data)
|
||||
|
||||
add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
mvn r2, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
and r0, r0, r2
|
||||
1:
|
||||
ldr r3, [r0], #4 @load next offset
|
||||
@ both -2 and -1 are treated the same as we have only one type of relocs
|
||||
@ -2 means "end of this type of relocs" and -1 means "end of all relocs"
|
||||
add r2, r3, #2
|
||||
cmp r2, #1
|
||||
bls reloc_done
|
||||
@ Adjust next offset
|
||||
ldr r2, [r3, r1]
|
||||
add r2, r2, r1
|
||||
str r2, [r3, r1]
|
||||
b 1b
|
||||
|
||||
reloc_done:
|
||||
|
||||
@ Modules have been stored as a blob
|
||||
@ Modules have been stored as a blob in BSS,
|
||||
@ they need to be manually relocated to _end
|
||||
ldr r0, bss_start_ptr @ src
|
||||
add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
and r0, r0, r1 @ src = aligned end of relocations
|
||||
and r0, r0, r1
|
||||
|
||||
ldr r1, end_ptr @ dst = End of BSS
|
||||
ldr r2, grub_total_module_size @ blob size
|
||||
|
||||
add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE
|
||||
and r1, r1, #~0x7 @ Ensure 8-byte alignment
|
||||
|
||||
sub sp, r1, #8
|
||||
add r1, r1, #1024
|
||||
|
||||
@@ -190,11 +157,6 @@ FUNCTION(grub_uboot_return)
|
||||
.align 3
|
||||
@ U-boot context stack space
|
||||
entry_state_end:
|
||||
VARIABLE(grub_uboot_machine_type)
|
||||
.long 0 @ r1
|
||||
VARIABLE(grub_uboot_boot_data)
|
||||
.long 0 @ r2
|
||||
.long 0 @ r3
|
||||
.long 0 @ r4
|
||||
.long 0 @ r5
|
||||
.long 0 @ r6
|
||||
|
||||
@@ -132,12 +132,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
*abs_place = (grub_uint64_t) sym_addr;
|
||||
}
|
||||
break;
|
||||
case R_AARCH64_ADD_ABS_LO12_NC:
|
||||
grub_arm64_set_abs_lo12 (place, sym_addr);
|
||||
break;
|
||||
case R_AARCH64_LDST64_ABS_LO12_NC:
|
||||
grub_arm64_set_abs_lo12_ldst64 (place, sym_addr);
|
||||
break;
|
||||
case R_AARCH64_CALL26:
|
||||
case R_AARCH64_JUMP26:
|
||||
{
|
||||
@@ -160,18 +154,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
grub_arm64_set_xxxx26_offset (place, offset);
|
||||
}
|
||||
break;
|
||||
case R_AARCH64_ADR_PREL_PG_HI21:
|
||||
{
|
||||
grub_int64_t offset = (sym_addr & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL);
|
||||
|
||||
if (!grub_arm64_check_hi21_signed (offset))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"HI21 out of range");
|
||||
|
||||
grub_arm64_set_hi21 (place, offset);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
|
||||
@@ -53,43 +53,3 @@ grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (offset >> 2) & ~insmask;
|
||||
}
|
||||
|
||||
int
|
||||
grub_arm64_check_hi21_signed (grub_int64_t offset)
|
||||
{
|
||||
if (offset != (grub_int64_t)(grub_int32_t)offset)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0x9f00001f);
|
||||
grub_uint32_t val;
|
||||
|
||||
offset >>= 12;
|
||||
|
||||
val = ((offset & 3) << 29) | (((offset >> 2) & 0x7ffff) << 5);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (val) & ~insmask;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (target << 10) & ~insmask;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfff803ff);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (target << 7) & ~insmask;
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/* init.c - initialize an arm-based EFI system */
|
||||
/*
|
||||
* 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/env.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/loader.h>
|
||||
|
||||
static grub_uint64_t timer_frequency_in_khz;
|
||||
|
||||
static grub_uint64_t
|
||||
grub_efi_get_time_ms (void)
|
||||
{
|
||||
grub_uint64_t tmr;
|
||||
asm volatile("mrs %0, cntvct_el0" : "=r" (tmr));
|
||||
|
||||
return tmr / timer_frequency_in_khz;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
grub_uint64_t timer_frequency;
|
||||
|
||||
grub_efi_init ();
|
||||
|
||||
asm volatile("mrs %0, cntfrq_el0" : "=r" (timer_frequency));
|
||||
timer_frequency_in_khz = timer_frequency / 1000;
|
||||
|
||||
grub_install_get_time_ms (grub_efi_get_time_ms);
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
if (!(flags & GRUB_LOADER_FLAG_NORETURN))
|
||||
return;
|
||||
|
||||
grub_efi_fini ();
|
||||
}
|
||||
@@ -333,11 +333,8 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
break;
|
||||
|
||||
/* Module without symbol table may still be used to pull in dependencies.
|
||||
We verify at build time that such modules do not contain any relocations
|
||||
that may reference symbol table. */
|
||||
if (i == e->e_shnum)
|
||||
return GRUB_ERR_NONE;
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
|
||||
|
||||
#ifdef GRUB_MODULES_MACHINE_READONLY
|
||||
mod->symtab = grub_malloc (s->sh_size);
|
||||
@@ -579,9 +576,6 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
|
||||
if (seg)
|
||||
{
|
||||
if (!mod->symtab)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "relocation without symbol table");
|
||||
|
||||
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -611,7 +605,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
|
||||
}
|
||||
|
||||
/* Make sure that every section is within the core. */
|
||||
if (size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum)
|
||||
if (size < e->e_shoff + e->e_shentsize * e->e_shnum)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "ELF sections outside core");
|
||||
return 0;
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
|
||||
#define GRUB_ELF_ENABLE_BI_ENDIAN 1
|
||||
#else
|
||||
|
||||
@@ -12,7 +12,7 @@ grub_elfXX_load_phdrs (grub_elf_t elf)
|
||||
if (elf->phdrs)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
phdrs_size = (grub_uint32_t) elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize;
|
||||
phdrs_size = elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize;
|
||||
|
||||
grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n",
|
||||
(unsigned long long) elf->ehdr.ehdrXX.e_phoff,
|
||||
|
||||
@@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
struct stat st;
|
||||
# if GRUB_DISK_DEVS_ARE_CHAR
|
||||
if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode))
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
|
||||
# else
|
||||
if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
|
||||
if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
|
||||
# endif
|
||||
data->is_disk = 1;
|
||||
}
|
||||
|
||||
@@ -65,12 +65,6 @@ grub_reboot (void)
|
||||
longjmp (main_env, 1);
|
||||
}
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
{
|
||||
grub_reboot ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
@@ -92,16 +86,11 @@ grub_machine_fini (int flags)
|
||||
|
||||
|
||||
|
||||
#define OPT_MEMDISK 257
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
|
||||
{"device-map", 'm', N_("FILE"), 0,
|
||||
/* TRANSLATORS: There are many devices in device map. */
|
||||
N_("use FILE as the device map [default=%s]"), 0},
|
||||
{"memdisk", OPT_MEMDISK, N_("FILE"), 0,
|
||||
/* TRANSLATORS: There are many devices in device map. */
|
||||
N_("use FILE as memdisk"), 0},
|
||||
{"directory", 'd', N_("DIR"), 0,
|
||||
N_("use GRUB files in the directory DIR [default=%s]"), 0},
|
||||
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
|
||||
@@ -130,7 +119,6 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||
struct arguments
|
||||
{
|
||||
const char *dev_map;
|
||||
const char *mem_disk;
|
||||
int hold;
|
||||
};
|
||||
|
||||
@@ -143,9 +131,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case OPT_MEMDISK:
|
||||
arguments->mem_disk = arg;
|
||||
break;
|
||||
case 'r':
|
||||
free (root_dev);
|
||||
root_dev = xstrdup (arg);
|
||||
@@ -195,13 +180,9 @@ main (int argc, char *argv[])
|
||||
struct arguments arguments =
|
||||
{
|
||||
.dev_map = DEFAULT_DEVICE_MAP,
|
||||
.hold = 0,
|
||||
.mem_disk = 0,
|
||||
.hold = 0
|
||||
};
|
||||
volatile int hold = 0;
|
||||
size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0;
|
||||
struct grub_module_info *modinfo;
|
||||
void *mods;
|
||||
|
||||
grub_util_host_init (&argc, &argv);
|
||||
|
||||
@@ -213,33 +194,6 @@ main (int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (arguments.mem_disk)
|
||||
{
|
||||
memdisk_size = ALIGN_UP(grub_util_get_image_size (arguments.mem_disk), 512);
|
||||
total_module_size += memdisk_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
mods = xmalloc (total_module_size);
|
||||
modinfo = grub_memset (mods, 0, total_module_size);
|
||||
mods = (char *) (modinfo + 1);
|
||||
|
||||
modinfo->magic = GRUB_MODULE_MAGIC;
|
||||
modinfo->offset = sizeof (struct grub_module_info);
|
||||
modinfo->size = total_module_size;
|
||||
|
||||
if (arguments.mem_disk)
|
||||
{
|
||||
struct grub_module_header *header = (struct grub_module_header *) mods;
|
||||
header->type = OBJ_TYPE_MEMDISK;
|
||||
header->size = memdisk_size + sizeof (*header);
|
||||
mods = header + 1;
|
||||
|
||||
grub_util_load_image (arguments.mem_disk, mods);
|
||||
mods = (char *) mods + memdisk_size;
|
||||
}
|
||||
|
||||
grub_modbase = (grub_addr_t) modinfo;
|
||||
|
||||
hold = arguments.hold;
|
||||
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
|
||||
if (hold && verbosity > 0)
|
||||
|
||||
@@ -134,13 +134,11 @@ xasprintf (const char *fmt, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
|
||||
void
|
||||
grub_exit (void)
|
||||
{
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
grub_uint64_t
|
||||
grub_get_time_ms (void)
|
||||
@@ -151,51 +149,3 @@ grub_get_time_ms (void)
|
||||
|
||||
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
||||
}
|
||||
|
||||
size_t
|
||||
grub_util_get_image_size (const char *path)
|
||||
{
|
||||
FILE *f;
|
||||
size_t ret;
|
||||
off_t sz;
|
||||
|
||||
f = grub_util_fopen (path, "rb");
|
||||
|
||||
if (!f)
|
||||
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
|
||||
|
||||
fseeko (f, 0, SEEK_END);
|
||||
|
||||
sz = ftello (f);
|
||||
if (sz < 0)
|
||||
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
|
||||
if (sz != (size_t) sz)
|
||||
grub_util_error (_("file `%s' is too big"), path);
|
||||
ret = (size_t) sz;
|
||||
|
||||
fclose (f);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_load_image (const char *path, char *buf)
|
||||
{
|
||||
FILE *fp;
|
||||
size_t size;
|
||||
|
||||
grub_util_info ("reading %s", path);
|
||||
|
||||
size = grub_util_get_image_size (path);
|
||||
|
||||
fp = grub_util_fopen (path, "rb");
|
||||
if (! fp)
|
||||
grub_util_error (_("cannot open `%s': %s"), path,
|
||||
strerror (errno));
|
||||
|
||||
if (fread (buf, 1, size, fp) != size)
|
||||
grub_util_error (_("cannot read `%s': %s"), path,
|
||||
strerror (errno));
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
@@ -89,11 +89,6 @@ grub_file_open (const char *name)
|
||||
|
||||
file->device = device;
|
||||
|
||||
/* In case of relative pathnames and non-Unix systems (like Windows)
|
||||
* name of host files may not start with `/'. Blocklists for host files
|
||||
* are meaningless as well (for a start, host disk does not allow any direct
|
||||
* access - it is just a marker). So skip host disk in this case.
|
||||
*/
|
||||
if (device->disk && file_name[0] != '/'
|
||||
#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU)
|
||||
&& grub_strcmp (device->disk->name, "host")
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/* kern/i386/tsc.c - x86 TSC time source implementation
|
||||
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
|
||||
* This module uses the PIT to calibrate the TSC to
|
||||
* real time.
|
||||
*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
int
|
||||
grub_tsc_calibrate_from_efi (void)
|
||||
{
|
||||
grub_uint64_t start_tsc, end_tsc;
|
||||
/* Use EFI Time Service to calibrate TSC */
|
||||
start_tsc = grub_get_tsc ();
|
||||
efi_call_1 (grub_efi_system_table->boot_services->stall, 1000);
|
||||
end_tsc = grub_get_tsc ();
|
||||
grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0);
|
||||
return 1;
|
||||
}
|
||||
@@ -44,13 +44,6 @@ FUNCTION(grub_bios_interrupt)
|
||||
movl 24(%edx), %esi
|
||||
movl 28(%edx), %edx
|
||||
|
||||
/*
|
||||
Via C3 CPUs have cache coherence problems, so we need to call
|
||||
wbinvd at these 2 points. As wbinvd slows down boot, don't do
|
||||
it on non-VIA. 9090 is nop nop. */
|
||||
VARIABLE(grub_bios_via_workaround1)
|
||||
.byte 0x90, 0x90
|
||||
|
||||
PROT_TO_REAL
|
||||
.code16
|
||||
pushf
|
||||
@@ -99,10 +92,6 @@ intno:
|
||||
movw %ax, LOCAL(bios_register_es)
|
||||
|
||||
popf
|
||||
|
||||
VARIABLE(grub_bios_via_workaround2)
|
||||
.byte 0x90, 0x90
|
||||
|
||||
REAL_TO_PROT
|
||||
.code32
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <grub/env.h>
|
||||
#include <grub/cache.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/cpu/cpuid.h>
|
||||
#include <grub/cpu/tsc.h>
|
||||
#include <grub/machine/time.h>
|
||||
|
||||
@@ -185,26 +184,6 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern grub_uint16_t grub_bios_via_workaround1, grub_bios_via_workaround2;
|
||||
|
||||
/* Via needs additional wbinvd. */
|
||||
static void
|
||||
grub_via_workaround_init (void)
|
||||
{
|
||||
grub_uint32_t manufacturer[3], max_cpuid;
|
||||
if (! grub_cpu_is_cpuid_supported ())
|
||||
return;
|
||||
|
||||
grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]);
|
||||
|
||||
if (grub_memcmp (manufacturer, "CentaurHauls", 12) != 0)
|
||||
return;
|
||||
|
||||
grub_bios_via_workaround1 = 0x090f;
|
||||
grub_bios_via_workaround2 = 0x090f;
|
||||
asm volatile ("wbinvd");
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
@@ -214,9 +193,6 @@ grub_machine_init (void)
|
||||
#endif
|
||||
grub_addr_t modend;
|
||||
|
||||
/* This has to happen before any BIOS calls. */
|
||||
grub_via_workaround_init ();
|
||||
|
||||
grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR + (_edata - _start);
|
||||
|
||||
/* Initialize the console as early as possible. */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* kern/i386/tsc.c - x86 TSC time source implementation
|
||||
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
|
||||
* This module calibrates the TSC to real time.
|
||||
* This module uses the RTC (via grub_get_rtc()) to calibrate the TSC to
|
||||
* real time.
|
||||
*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
@@ -24,6 +25,12 @@
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/i386/cpuid.h>
|
||||
#ifdef GRUB_MACHINE_XEN
|
||||
#include <grub/xen.h>
|
||||
#else
|
||||
#include <grub/i386/pit.h>
|
||||
#endif
|
||||
#include <grub/cpu/io.h>
|
||||
|
||||
/* This defines the value TSC had at the epoch (that is, when we calibrated it). */
|
||||
static grub_uint64_t tsc_boot_time;
|
||||
@@ -33,6 +40,66 @@ static grub_uint64_t tsc_boot_time;
|
||||
in 32-bit. */
|
||||
grub_uint32_t grub_tsc_rate;
|
||||
|
||||
/* Read the TSC value, which increments with each CPU clock cycle. */
|
||||
static __inline grub_uint64_t
|
||||
grub_get_tsc (void)
|
||||
{
|
||||
grub_uint32_t lo, hi;
|
||||
grub_uint32_t a,b,c,d;
|
||||
|
||||
/* The CPUID instruction is a 'serializing' instruction, and
|
||||
avoids out-of-order execution of the RDTSC instruction. */
|
||||
grub_cpuid (0,a,b,c,d);
|
||||
/* Read TSC value. We cannot use "=A", since this would use
|
||||
%rax on x86_64. */
|
||||
__asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
|
||||
|
||||
return (((grub_uint64_t) hi) << 32) | lo;
|
||||
}
|
||||
|
||||
#ifndef GRUB_MACHINE_XEN
|
||||
|
||||
static __inline int
|
||||
grub_cpu_is_tsc_supported (void)
|
||||
{
|
||||
grub_uint32_t a,b,c,d;
|
||||
if (! grub_cpu_is_cpuid_supported ())
|
||||
return 0;
|
||||
|
||||
grub_cpuid(1,a,b,c,d);
|
||||
|
||||
return (d & (1 << 4)) != 0;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_pit_wait (grub_uint16_t tics)
|
||||
{
|
||||
/* Disable timer2 gate and speaker. */
|
||||
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
||||
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
|
||||
/* Set tics. */
|
||||
grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD,
|
||||
GRUB_PIT_CTRL);
|
||||
grub_outb (tics & 0xff, GRUB_PIT_COUNTER_2);
|
||||
grub_outb (tics >> 8, GRUB_PIT_COUNTER_2);
|
||||
|
||||
/* Enable timer2 gate, keep speaker disabled. */
|
||||
grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA)
|
||||
| GRUB_PIT_SPK_TMR2,
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
|
||||
/* Wait. */
|
||||
while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00);
|
||||
|
||||
/* Disable timer2 gate and speaker. */
|
||||
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
||||
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
}
|
||||
#endif
|
||||
|
||||
static grub_uint64_t
|
||||
grub_tsc_get_time_ms (void)
|
||||
{
|
||||
@@ -43,36 +110,52 @@ grub_tsc_get_time_ms (void)
|
||||
return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
|
||||
}
|
||||
|
||||
static int
|
||||
calibrate_tsc_hardcode (void)
|
||||
#ifndef GRUB_MACHINE_XEN
|
||||
/* Calibrate the TSC based on the RTC. */
|
||||
static void
|
||||
calibrate_tsc (void)
|
||||
{
|
||||
grub_tsc_rate = 5368;/* 800 MHz */
|
||||
return 1;
|
||||
/* First calibrate the TSC rate (relative, not absolute time). */
|
||||
grub_uint64_t end_tsc;
|
||||
|
||||
tsc_boot_time = grub_get_tsc ();
|
||||
grub_pit_wait (0xffff);
|
||||
end_tsc = grub_get_tsc ();
|
||||
|
||||
grub_tsc_rate = 0;
|
||||
if (end_tsc > tsc_boot_time)
|
||||
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
|
||||
if (grub_tsc_rate == 0)
|
||||
grub_tsc_rate = 5368;/* 800 MHz */
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_tsc_init (void)
|
||||
{
|
||||
if (!grub_cpu_is_tsc_supported ())
|
||||
#ifdef GRUB_MACHINE_XEN
|
||||
grub_uint64_t t;
|
||||
tsc_boot_time = grub_get_tsc ();
|
||||
t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul;
|
||||
if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0)
|
||||
t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
else
|
||||
t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
grub_tsc_rate = grub_divmod64 (t, 1000000, 0);
|
||||
grub_install_get_time_ms (grub_tsc_get_time_ms);
|
||||
#else
|
||||
if (grub_cpu_is_tsc_supported ())
|
||||
{
|
||||
calibrate_tsc ();
|
||||
grub_install_get_time_ms (grub_tsc_get_time_ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275)
|
||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||
#else
|
||||
grub_fatal ("no TSC found");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
tsc_boot_time = grub_get_tsc ();
|
||||
|
||||
#ifdef GRUB_MACHINE_XEN
|
||||
(void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
|
||||
#elif defined (GRUB_MACHINE_EFI)
|
||||
(void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
|
||||
#elif defined (GRUB_MACHINE_COREBOOT)
|
||||
(void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
|
||||
#else
|
||||
(void) (grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
|
||||
#endif
|
||||
grub_install_get_time_ms (grub_tsc_get_time_ms);
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/* kern/i386/tsc.c - x86 TSC time source implementation
|
||||
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
|
||||
* This module uses the PIT to calibrate the TSC to
|
||||
* real time.
|
||||
*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/i386/pit.h>
|
||||
#include <grub/cpu/io.h>
|
||||
|
||||
static int
|
||||
grub_pit_wait (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* Disable timer2 gate and speaker. */
|
||||
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
||||
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
|
||||
/* Set tics. */
|
||||
grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD,
|
||||
GRUB_PIT_CTRL);
|
||||
/* 0xffff ticks: 55ms. */
|
||||
grub_outb (0xff, GRUB_PIT_COUNTER_2);
|
||||
grub_outb (0xff, GRUB_PIT_COUNTER_2);
|
||||
|
||||
/* Enable timer2 gate, keep speaker disabled. */
|
||||
grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA)
|
||||
| GRUB_PIT_SPK_TMR2,
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
|
||||
if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00) {
|
||||
ret = 1;
|
||||
/* Wait. */
|
||||
while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00);
|
||||
}
|
||||
|
||||
/* Disable timer2 gate and speaker. */
|
||||
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
||||
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Calibrate the TSC based on the RTC. */
|
||||
int
|
||||
grub_tsc_calibrate_from_pit (void)
|
||||
{
|
||||
/* First calibrate the TSC rate (relative, not absolute time). */
|
||||
grub_uint64_t start_tsc, end_tsc;
|
||||
|
||||
start_tsc = grub_get_tsc ();
|
||||
if (!grub_pit_wait ())
|
||||
return 0;
|
||||
end_tsc = grub_get_tsc ();
|
||||
|
||||
grub_tsc_rate = 0;
|
||||
if (end_tsc > start_tsc)
|
||||
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - start_tsc, 0);
|
||||
if (grub_tsc_rate == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/* kern/i386/tsc.c - x86 TSC time source implementation
|
||||
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
|
||||
* This module uses the PIT to calibrate the TSC to
|
||||
* real time.
|
||||
*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/i386/pmtimer.h>
|
||||
#include <grub/acpi.h>
|
||||
#include <grub/cpu/io.h>
|
||||
|
||||
grub_uint64_t
|
||||
grub_pmtimer_wait_count_tsc (grub_port_t pmtimer,
|
||||
grub_uint16_t num_pm_ticks)
|
||||
{
|
||||
grub_uint32_t start;
|
||||
grub_uint32_t last;
|
||||
grub_uint32_t cur, end;
|
||||
grub_uint64_t start_tsc;
|
||||
grub_uint64_t end_tsc;
|
||||
int num_iter = 0;
|
||||
|
||||
start = grub_inl (pmtimer) & 0xffffff;
|
||||
last = start;
|
||||
end = start + num_pm_ticks;
|
||||
start_tsc = grub_get_tsc ();
|
||||
while (1)
|
||||
{
|
||||
cur = grub_inl (pmtimer) & 0xffffff;
|
||||
if (cur < last)
|
||||
cur |= 0x1000000;
|
||||
num_iter++;
|
||||
if (cur >= end)
|
||||
{
|
||||
end_tsc = grub_get_tsc ();
|
||||
return end_tsc - start_tsc;
|
||||
}
|
||||
/* Check for broken PM timer.
|
||||
50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz)
|
||||
if after this time we still don't have 1 ms on pmtimer, then
|
||||
pmtimer is broken.
|
||||
*/
|
||||
if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
grub_tsc_calibrate_from_pmtimer (void)
|
||||
{
|
||||
struct grub_acpi_fadt *fadt;
|
||||
grub_port_t pmtimer;
|
||||
grub_uint64_t tsc_diff;
|
||||
|
||||
fadt = grub_acpi_find_fadt ();
|
||||
if (!fadt)
|
||||
return 0;
|
||||
pmtimer = fadt->pmtimer;
|
||||
if (!pmtimer)
|
||||
return 0;
|
||||
|
||||
/* It's 3.579545 MHz clock. Wait 1 ms. */
|
||||
tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580);
|
||||
if (tsc_diff == 0)
|
||||
return 0;
|
||||
grub_tsc_rate = grub_divmod64 ((1ULL << 32), tsc_diff, 0);
|
||||
return 1;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/* kern/i386/tsc.c - x86 TSC time source implementation
|
||||
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
|
||||
* This module uses the PIT to calibrate the TSC to
|
||||
* real time.
|
||||
*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/xen.h>
|
||||
|
||||
int
|
||||
grub_tsc_calibrate_from_xen (void)
|
||||
{
|
||||
grub_uint64_t t;
|
||||
t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul;
|
||||
if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0)
|
||||
t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
else
|
||||
t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
grub_tsc_rate = grub_divmod64 (t, 1000000, 0);
|
||||
return 1;
|
||||
}
|
||||
@@ -46,19 +46,11 @@
|
||||
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
|
||||
|
||||
/* The maximum heap size we're going to claim */
|
||||
#ifdef __i386__
|
||||
#define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024)
|
||||
#else
|
||||
#define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/* If possible, we will avoid claiming heap above this address, because it
|
||||
seems to cause relocation problems with OSes that link at 4 MiB */
|
||||
#ifdef __i386__
|
||||
#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024)
|
||||
#else
|
||||
#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
extern char _start[];
|
||||
extern char _end[];
|
||||
@@ -174,7 +166,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
|
||||
{
|
||||
unsigned long *total = data;
|
||||
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
if (type != 1)
|
||||
return 0;
|
||||
|
||||
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
|
||||
|
||||
@@ -25,7 +25,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
{
|
||||
grub_ieee1275_phandle_t root;
|
||||
grub_ieee1275_phandle_t memory;
|
||||
grub_uint32_t available[128];
|
||||
grub_uint32_t available[32];
|
||||
grub_ssize_t available_size;
|
||||
grub_uint32_t address_cells = 1;
|
||||
grub_uint32_t size_cells = 1;
|
||||
@@ -49,9 +49,6 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
sizeof available, &available_size))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"couldn't examine /memory/available property");
|
||||
if (available_size < 0 || (grub_size_t) available_size > sizeof (available))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"/memory response buffer exceeded");
|
||||
|
||||
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS))
|
||||
{
|
||||
|
||||
@@ -740,12 +740,6 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
|
||||
fmt++;
|
||||
|
||||
c = *fmt++;
|
||||
if (c == '%')
|
||||
{
|
||||
n--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == 'l')
|
||||
{
|
||||
c = *fmt++;
|
||||
@@ -882,7 +876,6 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
|
||||
if (c == '%')
|
||||
{
|
||||
write_char (str, &count, max_len,c);
|
||||
n--;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1106,8 +1099,6 @@ grub_fatal (const char *fmt, ...)
|
||||
grub_vprintf (_(fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
grub_refresh ();
|
||||
|
||||
grub_abort ();
|
||||
}
|
||||
|
||||
|
||||
@@ -325,15 +325,6 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
||||
if (!grub_mm_base)
|
||||
goto fail;
|
||||
|
||||
if (size > ~(grub_size_t) align)
|
||||
goto fail;
|
||||
|
||||
/* We currently assume at least a 32-bit grub_size_t,
|
||||
so limiting allocations to <adress space size> - 1MiB
|
||||
in name of sanity is beneficial. */
|
||||
if ((size + align) > ~(grub_size_t) 0x100000)
|
||||
goto fail;
|
||||
|
||||
align = (align >> GRUB_MM_ALIGN_LOG2);
|
||||
if (align == 0)
|
||||
align = 1;
|
||||
|
||||
@@ -268,7 +268,6 @@ grub_parser_execute (char *source)
|
||||
grub_parser_execute_getline (&line, 0, &source);
|
||||
grub_rescue_parse_line (line, grub_parser_execute_getline, &source);
|
||||
grub_free (line);
|
||||
grub_print_error ();
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
|
||||
@@ -43,17 +43,13 @@ grub_rescue_parse_line (char *line,
|
||||
|
||||
/* In case of an assignment set the environment accordingly
|
||||
instead of calling a function. */
|
||||
if (n == 1)
|
||||
if (n == 1 && grub_strchr (line, '='))
|
||||
{
|
||||
char *val = grub_strchr (args[0], '=');
|
||||
|
||||
if (val)
|
||||
{
|
||||
val[0] = 0;
|
||||
grub_env_set (args[0], val + 1);
|
||||
val[0] = '=';
|
||||
goto quit;
|
||||
}
|
||||
val[0] = 0;
|
||||
grub_env_set (args[0], val + 1);
|
||||
val[0] = '=';
|
||||
goto quit;
|
||||
}
|
||||
|
||||
/* Get the command name. */
|
||||
@@ -76,7 +72,6 @@ grub_rescue_parse_line (char *line,
|
||||
}
|
||||
|
||||
quit:
|
||||
/* Arguments are returned in single memory chunk separated by zeroes */
|
||||
grub_free (args[0]);
|
||||
grub_free (args);
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ FUNCTION(grub_longjmp)
|
||||
ldp x29, x30, [x0], #16
|
||||
ldr x2, [x0]
|
||||
mov sp, x2
|
||||
mov x0, #1
|
||||
cmp x1, #0
|
||||
csel x0, x1, x0, ne
|
||||
ret
|
||||
|
||||
@@ -470,8 +470,7 @@ grub_password_get (char buf[], unsigned buf_size)
|
||||
|
||||
if (key == '\b')
|
||||
{
|
||||
if (cur_len)
|
||||
cur_len--;
|
||||
cur_len--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include <grub/fdt.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define FDT_SUPPORTED_VERSION 17
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ void
|
||||
grub_backtrace (void)
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
asm volatile ("movq %%rbp, %%rdi\n"
|
||||
"callq *%%rax": :"a"(grub_backtrace_pointer));
|
||||
asm volatile ("movq %rbp, %rdi\n"
|
||||
"call " EXT_C("grub_backtrace_pointer"));
|
||||
#else
|
||||
asm volatile ("movl %%ebp, %%eax\n"
|
||||
"calll *%%ecx": :"c"(grub_backtrace_pointer));
|
||||
asm volatile ("movl %ebp, %eax\n"
|
||||
"call " EXT_C("grub_backtrace_pointer"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2016 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/random.h>
|
||||
#include <grub/i386/io.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/i386/pmtimer.h>
|
||||
#include <grub/acpi.h>
|
||||
|
||||
static int have_tsc = -1, have_pmtimer = -1;
|
||||
static grub_port_t pmtimer_port;
|
||||
|
||||
static int
|
||||
detect_pmtimer (void)
|
||||
{
|
||||
struct grub_acpi_fadt *fadt;
|
||||
fadt = grub_acpi_find_fadt ();
|
||||
if (!fadt)
|
||||
return 0;
|
||||
pmtimer_port = fadt->pmtimer;
|
||||
if (!pmtimer_port)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
pmtimer_tsc_get_random_bit (void)
|
||||
{
|
||||
/* It's hard to come up with figures about pmtimer and tsc jitter but
|
||||
50 ppm seems to be typical. So we need 10^6/50 tsc cycles to get drift
|
||||
of one tsc cycle. With TSC at least of 800 MHz it means 1/(50*800)
|
||||
= 1/40000 s or about 3579545 / 40000 = 90 pmtimer ticks.
|
||||
This gives us rate of 40000 bit/s or 5 kB/s.
|
||||
*/
|
||||
grub_uint64_t tsc_diff;
|
||||
tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer_port, 90);
|
||||
if (tsc_diff == 0)
|
||||
{
|
||||
have_pmtimer = 0;
|
||||
return -1;
|
||||
}
|
||||
return tsc_diff & 1;
|
||||
}
|
||||
|
||||
static int
|
||||
pmtimer_tsc_get_random_byte (void)
|
||||
{
|
||||
grub_uint8_t ret = 0;
|
||||
int i, c;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
c = pmtimer_tsc_get_random_bit ();
|
||||
if (c < 0)
|
||||
return -1;
|
||||
ret |= c << i;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
pmtimer_fill_buffer (void *buffer, grub_size_t sz)
|
||||
{
|
||||
grub_uint8_t *p = buffer;
|
||||
int c;
|
||||
while (sz)
|
||||
{
|
||||
c = pmtimer_tsc_get_random_byte ();
|
||||
if (c < 0)
|
||||
return 0;
|
||||
*p++ = c;
|
||||
sz--;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
grub_crypto_arch_get_random (void *buffer, grub_size_t sz)
|
||||
{
|
||||
if (have_tsc == -1)
|
||||
have_tsc = grub_cpu_is_tsc_supported ();
|
||||
if (!have_tsc)
|
||||
return 0;
|
||||
if (have_pmtimer == -1)
|
||||
have_pmtimer = detect_pmtimer ();
|
||||
if (!have_pmtimer)
|
||||
return 0;
|
||||
return pmtimer_fill_buffer (buffer, sz);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime)
|
||||
|
||||
datetime->year = args.year;
|
||||
datetime->month = args.month;
|
||||
datetime->day = args.day + 1;
|
||||
datetime->day = args.day;
|
||||
datetime->hour = args.hour;
|
||||
datetime->minute = args.minute;
|
||||
datetime->second = args.second;
|
||||
@@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime)
|
||||
|
||||
args.year = datetime->year;
|
||||
args.month = datetime->month;
|
||||
args.day = datetime->day - 1;
|
||||
args.day = datetime->day;
|
||||
args.hour = datetime->hour;
|
||||
args.minute = datetime->minute;
|
||||
args.second = datetime->second;
|
||||
|
||||
@@ -31,6 +31,7 @@ GRUB_MOD_LICENSE ("GPLv2+");
|
||||
desired derived output length DKLEN. Output buffer is DK which
|
||||
must have room for at least DKLEN octets. The output buffer will
|
||||
be filled with the derived data. */
|
||||
#pragma GCC diagnostic ignored "-Wunreachable-code"
|
||||
|
||||
gcry_err_code_t
|
||||
grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
|
||||
|
||||
@@ -38,17 +38,11 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)),
|
||||
grub_uint64_t now;
|
||||
static grub_uint64_t last_progress_update_time;
|
||||
grub_file_t file = data;
|
||||
const char *e;
|
||||
file->progress_offset += length;
|
||||
|
||||
if (call_depth)
|
||||
return;
|
||||
|
||||
e = grub_env_get ("enable_progress_indicator");
|
||||
if (e && e[0] == '0') {
|
||||
return;
|
||||
}
|
||||
|
||||
call_depth = 1;
|
||||
now = grub_get_time_ms ();
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2016 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/random.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/lib/hexdump.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
grub_err_t
|
||||
grub_crypto_get_random (void *buffer, grub_size_t sz)
|
||||
{
|
||||
/* This is an arbitrer between different methods.
|
||||
TODO: Add more methods in the future. */
|
||||
/* TODO: Add some PRNG smartness to reduce damage from bad entropy. */
|
||||
if (grub_crypto_arch_get_random (buffer, sz))
|
||||
return GRUB_ERR_NONE;
|
||||
return grub_error (GRUB_ERR_IO, "no random sources found");
|
||||
}
|
||||
|
||||
static int
|
||||
get_num_digits (int val)
|
||||
{
|
||||
int ret = 0;
|
||||
while (val != 0)
|
||||
{
|
||||
ret++;
|
||||
val /= 10;
|
||||
}
|
||||
if (ret == 0)
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_hexdump_random (grub_command_t cmd __attribute__ ((unused)), int argc, char **args)
|
||||
{
|
||||
grub_size_t length = 64;
|
||||
grub_err_t err;
|
||||
void *buffer;
|
||||
grub_uint8_t *ptr;
|
||||
int stats[256];
|
||||
int i, digits = 2;
|
||||
char template[10];
|
||||
|
||||
if (argc >= 1)
|
||||
length = grub_strtoull (args[0], 0, 0);
|
||||
|
||||
if (length == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "length pust be positive");
|
||||
|
||||
buffer = grub_malloc (length);
|
||||
if (!buffer)
|
||||
return grub_errno;
|
||||
|
||||
err = grub_crypto_get_random (buffer, length);
|
||||
if (err)
|
||||
{
|
||||
grub_free (buffer);
|
||||
return err;
|
||||
}
|
||||
|
||||
hexdump (0, buffer, length);
|
||||
grub_memset(stats, 0, sizeof(stats));
|
||||
for (ptr = buffer; ptr < (grub_uint8_t *) buffer + length; ptr++)
|
||||
stats[*ptr]++;
|
||||
grub_printf ("Statistics:\n");
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
int z = get_num_digits (stats[i]);
|
||||
if (z > digits)
|
||||
digits = z;
|
||||
}
|
||||
|
||||
grub_snprintf (template, sizeof (template), "%%0%dd ", digits);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
grub_printf ("%s", template);//, stats[i]);
|
||||
if ((i & 0xf) == 0xf)
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
grub_free (buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT (random)
|
||||
{
|
||||
cmd = grub_register_command ("hexdump_random", grub_cmd_hexdump_random,
|
||||
N_("[LENGTH]"),
|
||||
N_("Hexdump random data."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (random)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
||||
@@ -736,36 +736,26 @@ malloc_in_range (struct grub_relocator *rel,
|
||||
}
|
||||
isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
|
||||
&& !nblockfw)));
|
||||
if (from_low_priv) {
|
||||
if (!isinsidebefore && isinsideafter)
|
||||
starta = ALIGN_UP (events[j].pos, align);
|
||||
|
||||
if (isinsidebefore && !isinsideafter)
|
||||
{
|
||||
target = starta;
|
||||
if (target < start)
|
||||
target = start;
|
||||
if (target + size <= end && target + size <= events[j].pos)
|
||||
/* Found an usable address. */
|
||||
goto found;
|
||||
}
|
||||
} else {
|
||||
if (!isinsidebefore && isinsideafter)
|
||||
{
|
||||
if (events[j].pos >= size)
|
||||
starta = ALIGN_DOWN (events[j].pos - size, align) + size;
|
||||
else
|
||||
starta = 0;
|
||||
}
|
||||
if (isinsidebefore && !isinsideafter && starta >= size)
|
||||
{
|
||||
target = starta - size;
|
||||
if (target > end - size)
|
||||
target = end - size;
|
||||
if (target >= start && target >= events[j].pos)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
if (!isinsidebefore && isinsideafter)
|
||||
starta = from_low_priv ? ALIGN_UP (events[j].pos, align)
|
||||
: ALIGN_DOWN (events[j].pos - size, align) + size;
|
||||
if (isinsidebefore && !isinsideafter && from_low_priv)
|
||||
{
|
||||
target = starta;
|
||||
if (target < start)
|
||||
target = start;
|
||||
if (target + size <= end && target + size <= events[j].pos)
|
||||
/* Found an usable address. */
|
||||
goto found;
|
||||
}
|
||||
if (isinsidebefore && !isinsideafter && !from_low_priv)
|
||||
{
|
||||
target = starta - size;
|
||||
if (target > end - size)
|
||||
target = end - size;
|
||||
if (target >= start && target >= events[j].pos)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ VARIABLE(grub_relocator_xen_mfn_list)
|
||||
|
||||
loop 1b
|
||||
|
||||
leaq LOCAL(mmu_op) (%rip), %rdi
|
||||
leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi
|
||||
movq $3, %rsi
|
||||
movq $0, %rdx
|
||||
movq $0x7FF0, %r10
|
||||
@@ -104,7 +104,6 @@ VARIABLE(grub_relocator_xen_remap_continue)
|
||||
|
||||
jmp *%rax
|
||||
|
||||
LOCAL(mmu_op):
|
||||
VARIABLE(grub_relocator_xen_mmu_op)
|
||||
.space 256
|
||||
|
||||
|
||||
@@ -37,6 +37,16 @@
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define XEN_HYPERVISOR_NAME "xen_hypervisor"
|
||||
|
||||
#define MODULE_DEFAULT_ALIGN (0x0)
|
||||
#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN
|
||||
#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN
|
||||
#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN
|
||||
#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN
|
||||
|
||||
#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module"
|
||||
#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module"
|
||||
#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module"
|
||||
#define MODULE_CUSTOM_COMPATIBLE "multiboot,module"
|
||||
|
||||
/* This maximum size is defined in Power.org ePAPR V1.1
|
||||
@@ -64,6 +74,14 @@ enum module_type
|
||||
};
|
||||
typedef enum module_type module_type_t;
|
||||
|
||||
struct fdt_node_info
|
||||
{
|
||||
module_type_t type;
|
||||
|
||||
const char *compat_string;
|
||||
grub_size_t compat_string_size;
|
||||
};
|
||||
|
||||
struct xen_hypervisor_header
|
||||
{
|
||||
struct grub_arm64_linux_kernel_header efi_head;
|
||||
@@ -80,7 +98,7 @@ struct xen_boot_binary
|
||||
{
|
||||
struct xen_boot_binary *next;
|
||||
struct xen_boot_binary **prev;
|
||||
int is_hypervisor;
|
||||
const char *name;
|
||||
|
||||
grub_addr_t start;
|
||||
grub_size_t size;
|
||||
@@ -88,6 +106,8 @@ struct xen_boot_binary
|
||||
|
||||
char *cmdline;
|
||||
int cmdline_size;
|
||||
|
||||
struct fdt_node_info node_info;
|
||||
};
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
@@ -96,6 +116,19 @@ static int loaded;
|
||||
|
||||
static struct xen_boot_binary *xen_hypervisor;
|
||||
static struct xen_boot_binary *module_head;
|
||||
static const grub_size_t module_default_align[] = {
|
||||
MODULE_IMAGE_MIN_ALIGN,
|
||||
MODULE_INITRD_MIN_ALIGN,
|
||||
MODULE_XSM_MIN_ALIGN,
|
||||
MODULE_CUSTOM_MIN_ALIGN
|
||||
};
|
||||
|
||||
static const compat_string_struct_t default_compat_string[] = {
|
||||
FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE),
|
||||
FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE),
|
||||
FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE),
|
||||
FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE)
|
||||
};
|
||||
|
||||
static __inline grub_addr_t
|
||||
xen_boot_address_align (grub_addr_t start, grub_size_t align)
|
||||
@@ -103,6 +136,26 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align)
|
||||
return (align ? (ALIGN_UP (start, align)) : start);
|
||||
}
|
||||
|
||||
/* Parse the option of xen_module command. For now, we support
|
||||
(1) --type <the compatible stream>
|
||||
We also set up the type of module in this function.
|
||||
If there are some "--type" options in the command line,
|
||||
we make a custom compatible stream in this function. */
|
||||
static grub_err_t
|
||||
set_module_type (grub_command_t cmd, struct xen_boot_binary *module, int *file_name_index)
|
||||
{
|
||||
*file_name_index = 0;
|
||||
|
||||
if (!grub_strcmp (cmd->name, "xen_linux"))
|
||||
module->node_info.type = MODULE_IMAGE;
|
||||
else if (!grub_strcmp (cmd->name, "xen_initrd"))
|
||||
module->node_info.type = MODULE_INITRD;
|
||||
else if (!grub_strcmp (cmd->name, "xen_xsm"))
|
||||
module->node_info.type = MODULE_XSM;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
prepare_xen_hypervisor_params (void *xen_boot_fdt)
|
||||
{
|
||||
@@ -156,11 +209,15 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
|
||||
grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name);
|
||||
|
||||
retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible",
|
||||
MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1);
|
||||
module->node_info.compat_string,
|
||||
(grub_uint32_t) module->
|
||||
node_info.compat_string_size);
|
||||
if (retval)
|
||||
return grub_error (GRUB_ERR_IO, "failed to update FDT");
|
||||
|
||||
grub_dprintf ("xen_loader", "Module\n");
|
||||
grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n",
|
||||
module->name, module->node_info.compat_string,
|
||||
module->node_info.compat_string_size);
|
||||
|
||||
retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node,
|
||||
xen_boot_address_align (module->start,
|
||||
@@ -172,7 +229,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
|
||||
if (module->cmdline && module->cmdline_size > 0)
|
||||
{
|
||||
grub_dprintf ("xen_loader",
|
||||
"Module cmdline : %s @ %p size:%d\n",
|
||||
"Module %s cmdline : %s @ %p size:%d\n", module->name,
|
||||
module->cmdline, module->cmdline, module->cmdline_size);
|
||||
|
||||
retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs",
|
||||
@@ -182,7 +239,8 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_dprintf ("xen_loader", "Module has no bootargs!\n");
|
||||
grub_dprintf ("xen_loader", "Module %s has not bootargs!\n",
|
||||
module->name);
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
@@ -199,8 +257,8 @@ finalize_params_xen_boot (void)
|
||||
additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size;
|
||||
FOR_LIST_ELEMENTS (module, module_head)
|
||||
{
|
||||
additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + sizeof(MODULE_CUSTOM_COMPATIBLE) - 1
|
||||
+ module->cmdline_size;
|
||||
additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module->
|
||||
node_info.compat_string_size + module->cmdline_size;
|
||||
}
|
||||
|
||||
xen_boot_fdt = grub_fdt_load (additional_size);
|
||||
@@ -223,7 +281,8 @@ finalize_params_xen_boot (void)
|
||||
{
|
||||
if (module->start && module->size > 0)
|
||||
{
|
||||
grub_dprintf ("xen_loader", "Module @ 0x%lx size:0x%lx\n",
|
||||
grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n",
|
||||
module->name,
|
||||
xen_boot_address_align (module->start, module->align),
|
||||
module->size);
|
||||
if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE)
|
||||
@@ -231,7 +290,7 @@ finalize_params_xen_boot (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_dprintf ("xen_loader", "Module info error!\n");
|
||||
grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -274,16 +333,19 @@ single_binary_unload (struct xen_boot_binary *binary)
|
||||
{
|
||||
grub_free (binary->cmdline);
|
||||
grub_dprintf ("xen_loader",
|
||||
"Module cmdline memory free @ %p size: %d\n",
|
||||
binary->cmdline, binary->cmdline_size);
|
||||
"Module %s cmdline memory free @ %p size: %d\n",
|
||||
binary->name, binary->cmdline, binary->cmdline_size);
|
||||
}
|
||||
|
||||
if (!binary->is_hypervisor)
|
||||
if (binary->node_info.type == MODULE_CUSTOM)
|
||||
grub_free ((void *) binary->node_info.compat_string);
|
||||
|
||||
if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME))
|
||||
grub_list_remove (GRUB_AS_LIST (binary));
|
||||
|
||||
grub_dprintf ("xen_loader",
|
||||
"Module struct memory free @ %p size: 0x%lx\n",
|
||||
binary, sizeof (binary));
|
||||
"Module %s struct memory free @ %p size: 0x%lx\n",
|
||||
binary->name, binary, sizeof (binary));
|
||||
grub_free (binary);
|
||||
|
||||
return;
|
||||
@@ -321,7 +383,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
binary->size = grub_file_size (file);
|
||||
grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size);
|
||||
grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n",
|
||||
binary->name, binary->size);
|
||||
|
||||
binary->start
|
||||
= (grub_addr_t) grub_efi_allocate_pages (0,
|
||||
@@ -334,8 +397,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
|
||||
return;
|
||||
}
|
||||
|
||||
grub_dprintf ("xen_loader", "Xen_boot numpages: 0x%lx\n",
|
||||
GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));
|
||||
grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n",
|
||||
binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));
|
||||
|
||||
if (grub_file_read (file, (void *) xen_boot_address_align (binary->start,
|
||||
binary->align),
|
||||
@@ -359,7 +422,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
|
||||
grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline,
|
||||
binary->cmdline_size);
|
||||
grub_dprintf ("xen_loader",
|
||||
"Xen_boot cmdline @ %p %s, size: %d\n",
|
||||
"Xen_boot %s cmdline @ %p %s, size: %d\n", binary->name,
|
||||
binary->cmdline, binary->cmdline, binary->cmdline_size);
|
||||
}
|
||||
else
|
||||
@@ -373,11 +436,11 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)),
|
||||
int argc, char *argv[])
|
||||
grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[])
|
||||
{
|
||||
|
||||
struct xen_boot_binary *module = NULL;
|
||||
int file_name_index = 0;
|
||||
grub_file_t file = 0;
|
||||
|
||||
if (!argc)
|
||||
@@ -398,20 +461,46 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)),
|
||||
if (!module)
|
||||
return grub_errno;
|
||||
|
||||
module->is_hypervisor = 0;
|
||||
module->align = 4096;
|
||||
/* process all the options and get module type */
|
||||
if (set_module_type (cmd, module, &file_name_index) !=
|
||||
GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
switch (module->node_info.type)
|
||||
{
|
||||
case MODULE_IMAGE:
|
||||
case MODULE_INITRD:
|
||||
case MODULE_XSM:
|
||||
module->node_info.compat_string =
|
||||
default_compat_string[module->node_info.type].compat_string;
|
||||
module->node_info.compat_string_size =
|
||||
default_compat_string[module->node_info.type].size;
|
||||
break;
|
||||
|
||||
grub_dprintf ("xen_loader", "Init module and node info\n");
|
||||
case MODULE_CUSTOM:
|
||||
/* we have set the node_info in set_module_type */
|
||||
break;
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
default:
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
|
||||
}
|
||||
module->name = module->node_info.compat_string;
|
||||
module->align = module_default_align[module->node_info.type];
|
||||
|
||||
grub_dprintf ("xen_loader", "Init %s module and node info:\n"
|
||||
"compatible %s\ncompat_string_size 0x%lx\n",
|
||||
module->name, module->node_info.compat_string,
|
||||
module->node_info.compat_string_size);
|
||||
|
||||
file = grub_file_open (argv[file_name_index]);
|
||||
if (!file)
|
||||
goto fail;
|
||||
|
||||
xen_boot_binary_load (module, file, argc, argv);
|
||||
xen_boot_binary_load (module, file, argc - file_name_index,
|
||||
argv + file_name_index);
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module));
|
||||
|
||||
fail:
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
@@ -455,7 +544,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (!xen_hypervisor)
|
||||
return grub_errno;
|
||||
|
||||
xen_hypervisor->is_hypervisor = 1;
|
||||
xen_hypervisor->name = XEN_HYPERVISOR_NAME;
|
||||
xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment;
|
||||
|
||||
xen_boot_binary_load (xen_hypervisor, file, argc, argv);
|
||||
@@ -479,21 +568,29 @@ fail:
|
||||
}
|
||||
|
||||
static grub_command_t cmd_xen_hypervisor;
|
||||
static grub_command_t cmd_xen_module;
|
||||
static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm;
|
||||
|
||||
GRUB_MOD_INIT (xen_boot)
|
||||
{
|
||||
cmd_xen_hypervisor =
|
||||
grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0,
|
||||
N_("Load a xen hypervisor."));
|
||||
cmd_xen_module =
|
||||
grub_register_command ("xen_module", grub_cmd_xen_module, 0,
|
||||
N_("Load a xen module."));
|
||||
cmd_xen_linux =
|
||||
grub_register_command ("xen_linux", grub_cmd_xen_module, 0,
|
||||
N_("Load a xen linux kernel for dom0."));
|
||||
cmd_xen_initrd =
|
||||
grub_register_command ("xen_initrd", grub_cmd_xen_module, 0,
|
||||
N_("Load a xen initrd for dom0."));
|
||||
cmd_xen_xsm =
|
||||
grub_register_command ("xen_xsm", grub_cmd_xen_module, 0,
|
||||
N_("Load a xen security module."));
|
||||
my_mod = mod;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (xen_boot)
|
||||
{
|
||||
grub_unregister_command (cmd_xen_hypervisor);
|
||||
grub_unregister_command (cmd_xen_module);
|
||||
grub_unregister_command (cmd_xen_linux);
|
||||
grub_unregister_command (cmd_xen_initrd);
|
||||
grub_unregister_command (cmd_xen_xsm);
|
||||
}
|
||||
|
||||
@@ -1889,10 +1889,6 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_err_t err;
|
||||
void *src;
|
||||
|
||||
if (! grub_loader_is_loaded ())
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
|
||||
if (kernel_type != KERNEL_TYPE_FREEBSD)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded");
|
||||
|
||||
@@ -1996,10 +1992,6 @@ grub_cmd_netbsd_module (grub_command_t cmd,
|
||||
{
|
||||
grub_uint32_t type;
|
||||
|
||||
if (! grub_loader_is_loaded ())
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
|
||||
if (kernel_type != KERNEL_TYPE_NETBSD)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded");
|
||||
|
||||
@@ -2078,10 +2070,6 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
if (! grub_loader_is_loaded ())
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
|
||||
if (kernel_type != KERNEL_TYPE_OPENBSD)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded");
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr)
|
||||
if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS))
|
||||
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
|
||||
|
||||
*shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize);
|
||||
*shdr = grub_malloc (e->e_shnum * e->e_shentsize);
|
||||
if (! *shdr)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_file_seek (file, e->e_shoff) == (grub_off_t) -1)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize)
|
||||
!= (grub_ssize_t) ((grub_uint32_t) e->e_shnum * e->e_shentsize))
|
||||
if (grub_file_read (file, *shdr, e->e_shnum * e->e_shentsize)
|
||||
!= e->e_shnum * e->e_shentsize)
|
||||
{
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
@@ -200,8 +200,8 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
|
||||
|
||||
if (chunk_size < sizeof (e))
|
||||
chunk_size = sizeof (e);
|
||||
chunk_size += (grub_uint32_t) e.e_phnum * e.e_phentsize;
|
||||
chunk_size += (grub_uint32_t) e.e_shnum * e.e_shentsize;
|
||||
chunk_size += e.e_phnum * e.e_phentsize;
|
||||
chunk_size += e.e_shnum * e.e_shentsize;
|
||||
|
||||
{
|
||||
grub_relocator_chunk_t ch;
|
||||
@@ -253,14 +253,14 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
|
||||
curload = module + sizeof (e);
|
||||
|
||||
load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_shoff,
|
||||
(grub_uint32_t) e.e_shnum * e.e_shentsize);
|
||||
e.e_shnum * e.e_shentsize);
|
||||
e.e_shoff = curload - module;
|
||||
curload += (grub_uint32_t) e.e_shnum * e.e_shentsize;
|
||||
curload += e.e_shnum * e.e_shentsize;
|
||||
|
||||
load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_phoff,
|
||||
(grub_uint32_t) e.e_phnum * e.e_phentsize);
|
||||
e.e_phnum * e.e_phentsize);
|
||||
e.e_phoff = curload - module;
|
||||
curload += (grub_uint32_t) e.e_phnum * e.e_phentsize;
|
||||
curload += e.e_phnum * e.e_phentsize;
|
||||
|
||||
*kern_end = curload;
|
||||
|
||||
@@ -462,7 +462,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
|
||||
|
||||
chunk_size = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t))
|
||||
+ ALIGN_UP (strsize, sizeof (grub_freebsd_addr_t))
|
||||
+ sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
|
||||
+ sizeof (e) + e.e_shnum * e.e_shentsize;
|
||||
|
||||
symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t));
|
||||
{
|
||||
@@ -498,10 +498,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
|
||||
s2 = (Elf_Shdr *) curload;
|
||||
grub_memcpy (curload, s, e.e_shentsize);
|
||||
if (s == symsh)
|
||||
s2->sh_offset = sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
|
||||
s2->sh_offset = sizeof (e) + e.e_shnum * e.e_shentsize;
|
||||
else if (s == strsh)
|
||||
s2->sh_offset = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t))
|
||||
+ sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
|
||||
+ sizeof (e) + e.e_shnum * e.e_shentsize;
|
||||
else
|
||||
s2->sh_offset = 0;
|
||||
s2->sh_addr = s2->sh_offset;
|
||||
|
||||
@@ -73,9 +73,6 @@ load_kernel (grub_file_t file, const char *filename,
|
||||
if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE)
|
||||
{
|
||||
err = grub_multiboot_load_elf (file, filename, buffer);
|
||||
if (err == GRUB_ERR_NONE) {
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
if (err == GRUB_ERR_UNKNOWN_OS && (header->flags & MULTIBOOT_AOUT_KLUDGE))
|
||||
grub_errno = err = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)),
|
||||
fail:
|
||||
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO");
|
||||
return grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO");
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
@@ -55,11 +55,11 @@ grub_xen_file (grub_file_t file)
|
||||
grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n",
|
||||
(unsigned long long) (lh.setup_sects + 1) * 512
|
||||
+ lh.payload_offset,
|
||||
(unsigned long long) lh.payload_length);
|
||||
(unsigned long long) lh.payload_length - 4);
|
||||
|
||||
off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512
|
||||
+ lh.payload_offset,
|
||||
lh.payload_length);
|
||||
lh.payload_length - 4);
|
||||
if (!off_file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/random.h>
|
||||
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
@@ -339,7 +338,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor *
|
||||
utf8 = grub_malloc (namelen * 4 + 1);
|
||||
if (!utf8)
|
||||
{
|
||||
grub_free (utf16);
|
||||
grub_free (utf8);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
@@ -578,31 +577,11 @@ static grub_err_t
|
||||
grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
|
||||
{
|
||||
struct grub_xnu_devtree_key *efikey;
|
||||
struct grub_xnu_devtree_key *chosenkey;
|
||||
struct grub_xnu_devtree_key *cfgtablekey;
|
||||
struct grub_xnu_devtree_key *curval;
|
||||
struct grub_xnu_devtree_key *runtimesrvkey;
|
||||
struct grub_xnu_devtree_key *platformkey;
|
||||
unsigned i, j;
|
||||
grub_err_t err;
|
||||
|
||||
chosenkey = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen");
|
||||
if (! chosenkey)
|
||||
return grub_errno;
|
||||
|
||||
/* Random seed. */
|
||||
curval = grub_xnu_create_value (&(chosenkey->first_child), "random-seed");
|
||||
if (! curval)
|
||||
return grub_errno;
|
||||
curval->datasize = 64;
|
||||
curval->data = grub_malloc (curval->datasize);
|
||||
if (! curval->data)
|
||||
return grub_errno;
|
||||
/* Our random is not peer-reviewed but xnu uses this seed only for
|
||||
ASLR in kernel. */
|
||||
err = grub_crypto_get_random (curval->data, curval->datasize);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* The value "model". */
|
||||
/* FIXME: may this value be sometimes different? */
|
||||
@@ -918,28 +897,6 @@ grub_xnu_set_video (struct grub_xnu_boot_params_common *params)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
total_ram_hook (grub_uint64_t addr __attribute__ ((unused)), grub_uint64_t size,
|
||||
grub_memory_type_t type,
|
||||
void *data)
|
||||
{
|
||||
grub_uint64_t *result = data;
|
||||
|
||||
if (type != GRUB_MEMORY_AVAILABLE)
|
||||
return 0;
|
||||
*result += size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_uint64_t
|
||||
get_total_ram (void)
|
||||
{
|
||||
grub_uint64_t result = 0;
|
||||
|
||||
grub_mmap_iterate (total_ram_hook, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Boot xnu. */
|
||||
grub_err_t
|
||||
grub_xnu_boot (void)
|
||||
@@ -1016,7 +973,6 @@ grub_xnu_boot (void)
|
||||
{
|
||||
bootparams_common = &bootparams->v2.common;
|
||||
bootparams->v2.fsbfreq = fsbfreq;
|
||||
bootparams->v2.ram_size = get_total_ram();
|
||||
}
|
||||
else
|
||||
bootparams_common = &bootparams->v1.common;
|
||||
@@ -1124,7 +1080,7 @@ grub_xnu_boot (void)
|
||||
bootparams_common->efi_mmap = memory_map_target;
|
||||
bootparams_common->efi_mmap_size = memory_map_size;
|
||||
bootparams_common->heap_start = grub_xnu_heap_target_start;
|
||||
bootparams_common->heap_size = curruntimepage * GRUB_XNU_PAGESIZE - grub_xnu_heap_target_start;
|
||||
bootparams_common->heap_size = grub_xnu_heap_size;
|
||||
|
||||
/* Parameters for asm helper. */
|
||||
grub_xnu_stack = bootparams_common->heap_start
|
||||
|
||||
@@ -240,27 +240,20 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
#ifndef GRUB_USE_MULTIBOOT2
|
||||
grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE;
|
||||
int option_found = 0;
|
||||
|
||||
do
|
||||
if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0)
|
||||
{
|
||||
option_found = 0;
|
||||
if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
option_found = 1;
|
||||
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE;
|
||||
}
|
||||
|
||||
if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
option_found = 1;
|
||||
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
|
||||
}
|
||||
} while (option_found);
|
||||
if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc == 0)
|
||||
|
||||
@@ -72,7 +72,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
|
||||
return grub_error (GRUB_ERR_UNKNOWN_OS, N_("this ELF file is not of the right type"));
|
||||
|
||||
/* FIXME: Should we support program headers at strange locations? */
|
||||
if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
|
||||
if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
|
||||
|
||||
phdr_base = (char *) buffer + ehdr->e_phoff;
|
||||
@@ -164,7 +164,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
|
||||
{
|
||||
grub_uint8_t *shdr, *shdrptr;
|
||||
|
||||
shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize);
|
||||
shdr = grub_malloc (ehdr->e_shnum * ehdr->e_shentsize);
|
||||
if (!shdr)
|
||||
return grub_errno;
|
||||
|
||||
@@ -174,7 +174,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (grub_file_read (file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize)
|
||||
if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize)
|
||||
!= (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize)
|
||||
{
|
||||
if (!grub_errno)
|
||||
|
||||
@@ -420,7 +420,6 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
|
||||
(*mmap_entry)->addr = addr;
|
||||
(*mmap_entry)->len = size;
|
||||
(*mmap_entry)->type = type;
|
||||
(*mmap_entry)->zero = 0;
|
||||
(*mmap_entry)++;
|
||||
|
||||
return 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user