Merge mainline into legacy_parser

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-05 20:44:42 +02:00
commit 122a9b2cd9
257 changed files with 16640 additions and 6064 deletions

View File

@ -69,6 +69,7 @@ Makefile
mod-*.c
missing
*.pf2
*.pp
po/*.mo
po/grub.pot
stamp-h
@ -91,7 +92,10 @@ texinfo.tex
grub-core/lib/libgcrypt-grub
**/.deps-util
**/.deps-core
**/.dirstamp
Makefile.util.am
grub-core/Makefile.core.am
grub-core/Makefile.gcry.am
grub-core/Makefile.gcry.def
grub-core/*.module
grub-core/*.pp

1158
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@ configuring the GRUB.
On GNU/Linux, you also need:
* libdevmapper (recommended)
* libdevmapper 1.02.34 or later (recommended)
To build grub-emu, you need:

View File

@ -82,4 +82,223 @@ CLEANFILES += widthspec.h
platform_HEADERS = config.h
pkglib_DATA += grub-mkconfig_lib
pkglib_DATA += update-grub_lib
pkglib_DATA += update-grub_lib
if COND_i386_coreboot
BOOTTARGET=coreboot
QEMU32=qemu-system-i386
endif
if COND_i386_multiboot
BOOTTARGET=cd
QEMU32=qemu-system-i386
endif
if COND_i386_ieee1275
BOOTTARGET=cd
QEMU32=qemu-system-i386
endif
if COND_i386_qemu
BOOTTARGET=qemu
QEMU32=qemu-system-i386
endif
if COND_i386_pc
BOOTTARGET=cd
QEMU32=qemu-system-i386
endif
if COND_i386_efi
QEMU32=qemu-system-i386
BOOTTARGET=cd
endif
if COND_x86_64_efi
QEMU32=qemu-system-x86_64
BOOTTARGET=cd
endif
linux.init.x86_64: $(srcdir)/grub-core/tests/boot/linux.init-x86_64.S
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include
kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include
kfreebsd.aout: kfreebsd.elf
$(OBJCOPY) -O a.out-i386-linux $< $@ -R .note.gnu.build-id
pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
$(TARGET_CC) -o $@ $< -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x7c00 -m32
pc-chainloader.bin: pc-chainloader.elf
$(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@;
ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S
$(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0 -m32
ntldr.bin: ntldr.elf
$(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@;
multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S
$(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1
kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
kfreebsd.init.i386: $(srcdir)/grub-core/tests/boot/kfreebsd.init-i386.S
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@
knetbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_NETBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
kopenbsd.init.i386: $(srcdir)/grub-core/tests/boot/kbsd.init-i386.S
$(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DTARGET_OPENBSD=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
knetbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
$(TARGET_CC) -o $@ $< -m64 -DTARGET_NETBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
$(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
linux-initramfs.i386: linux.init.i386 Makefile
TDIR=`mktemp -d`; cp $< $$TDIR/init; (cd $$TDIR; echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@; rm -rf $$TDIR
linux-initramfs.x86_64: linux.init.x86_64 Makefile
TDIR=`mktemp -d`; cp $< $$TDIR/init; (cd $$TDIR; echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@; rm -rf $$TDIR
kfreebsd-mfsroot.i386.img: kfreebsd.init.i386 Makefile
TDIR=`mktemp -d`; mkdir $$TDIR/dev; mkdir $$TDIR/sbin; cp $< $$TDIR/sbin/init; makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR; rm -rf $$TDIR
knetbsd.image.i386: knetbsd.init.i386 $(srcdir)/grub-core/tests/boot/kbsd.spec.txt
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
kopenbsd.image.i386: kopenbsd.init.i386 $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
kopenbsd.image.x86_64: kopenbsd.init.x86_64 $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
knetbsd.miniroot-image.i386.img: knetbsd.image.i386 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386 $@
kfreebsd-mfsroot.x86_64.img: kfreebsd.init.x86_64 Makefile
TDIR=`mktemp -d`; mkdir $$TDIR/dev; mkdir $$TDIR/sbin; cp $< $$TDIR/sbin/init; makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR; rm -rf $$TDIR
knetbsd.image.x86_64: knetbsd.init.x86_64 $(srcdir)/grub-core/tests/boot/kbsd.spec.txt
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
knetbsd.miniroot-image.x86_64.img: knetbsd.image.x86_64 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64 $@
CLEANFILES += linux.init.i386 kfreebsd.init.i386 linux.init.x86_64 linux-initramfs.i386 linux-initramfs.x86_64
kfreebsd-mfsroot.i386.gz: kfreebsd-mfsroot.i386.img
gzip < $< > $@
bootcheck-kfreebsd-i386: kfreebsd-mfsroot.i386.gz $(GRUB_PAYLOADS_DIR)/kfreebsd.i386 $(GRUB_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/grub-core/tests/boot/kfreebsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/mfsroot.gz=kfreebsd-mfsroot.i386.gz --files=/kfreebsd=$(GRUB_PAYLOADS_DIR)/kfreebsd.i386 --files=/kfreebsd_env=$(GRUB_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/grub-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
kfreebsd-mfsroot.x86_64.gz: kfreebsd-mfsroot.x86_64.img
gzip < $< > $@
bootcheck-kfreebsd-x86_64: kfreebsd-mfsroot.x86_64.gz $(GRUB_PAYLOADS_DIR)/kfreebsd.x86_64 $(GRUB_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/grub-core/tests/boot/kfreebsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/mfsroot.gz=kfreebsd-mfsroot.x86_64.gz --files=/kfreebsd=$(GRUB_PAYLOADS_DIR)/kfreebsd.x86_64 --files=/kfreebsd_env=$(GRUB_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/grub-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
knetbsd.miniroot-image.i386.gz: knetbsd.miniroot-image.i386.img
gzip < $< > $@
bootcheck-knetbsd-i386: knetbsd.miniroot-image.i386.gz $(GRUB_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/grub-core/tests/boot/knetbsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/miniroot.gz=knetbsd.miniroot-image.i386.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/grub-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-i386: kopenbsd.image.i386 $(GRUB_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/grub-core/tests/boot/kopenbsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/ramdisk=kopenbsd.image.i386 --files=/kopenbsd=$(GRUB_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/grub-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-x86_64: kopenbsd.image.x86_64 $(GRUB_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/grub-core/tests/boot/kopenbsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/ramdisk=kopenbsd.image.x86_64 --files=/kopenbsd=$(GRUB_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/grub-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
knetbsd.miniroot-image.x86_64.gz: knetbsd.miniroot-image.x86_64.img
gzip < $< > $@
bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/grub-core/tests/boot/knetbsd.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(GRUB_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/grub-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-i386: linux-initramfs.i386 $(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-i386: linux-initramfs.i386 $(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.i386 $(srcdir)/grub-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(GRUB_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/grub-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-multiboot: multiboot.elf $(srcdir)/grub-core/tests/boot/multiboot.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/multiboot.elf=multiboot.elf $(srcdir)/grub-core/tests/boot/multiboot.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-multiboot2: multiboot2.elf $(srcdir)/grub-core/tests/boot/multiboot2.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/multiboot2.elf=multiboot2.elf $(srcdir)/grub-core/tests/boot/multiboot2.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kfreebsd-aout: kfreebsd.aout $(srcdir)/grub-core/tests/boot/kfreebsd-aout.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/kfreebsd.aout=kfreebsd.aout $(srcdir)/grub-core/tests/boot/kfreebsd-aout.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-pc-chainloader: pc-chainloader.bin $(srcdir)/grub-core/tests/boot/pc-chainloader.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/pc-chainloader.bin=pc-chainloader.bin $(srcdir)/grub-core/tests/boot/pc-chainloader.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-ntldr: ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg grub-shell
timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/ntldr.bin=ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
BOOTCHECKS=
if COND_i386_pc
#pc chainloader by definition is only for i386-pc
BOOTCHECKS += bootcheck-pc-chainloader
#ntldr and bootmgr require BIOS.
BOOTCHECKS += bootcheck-ntldr
#legacy protocol makes early BIOS calls.
BOOTCHECKS += bootcheck-linux16-i386 bootcheck-linux16-x86_64
# Crashes early on non-BIOS
BOOTCHECKS += bootcheck-knetbsd-i386
endif
if !COND_i386_coreboot
# Crashes because memory at 0-0x1000 is occupied
BOOTCHECKS += bootcheck-knetbsd-x86_64
# Likewise and require ACPI.
if !COND_i386_multiboot
if !COND_i386_qemu
BOOTCHECKS += bootcheck-kfreebsd-x86_64
BOOTCHECKS += bootcheck-kfreebsd-i386
endif
endif
endif
BOOTCHECKS += bootcheck-kfreebsd-aout
BOOTCHECKS += bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64
BOOTCHECKS += bootcheck-multiboot bootcheck-multiboot2
BOOTCHECKS += bootcheck-linux-i386 bootcheck-linux-x86_64
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64
# Randomly generated
SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d
# tianocore cd access is very slow
BOOTCHECK_TIMEOUT=180
bootcheck: $(BOOTCHECKS)

View File

@ -88,6 +88,7 @@ library = {
common = grub-core/partmap/gpt.c;
common = grub-core/partmap/msdos.c;
common = grub-core/partmap/sun.c;
common = grub-core/partmap/sunpc.c;
common = grub-core/script/function.c;
common = grub-core/script/lexer.c;
common = grub-core/script/main.c;
@ -99,7 +100,7 @@ program = {
name = grub-bin2h;
common = util/bin2h.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
mansection = 1;
};
@ -112,7 +113,7 @@ program = {
extra_dist = util/grub-mkimagexx.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"';
};
@ -123,7 +124,7 @@ program = {
common = util/grub-mkrelpath.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
};
program = {
@ -133,7 +134,7 @@ program = {
common = util/grub-script-check.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
};
program = {
@ -143,7 +144,7 @@ program = {
common = util/grub-editenv.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
};
program = {
@ -153,7 +154,7 @@ program = {
common = util/grub-mkpasswd-pbkdf2.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
cflags = '$(CFLAGS_GCRY)';
cppflags = '$(CPPFLAGS_GCRY)';
};
@ -171,7 +172,7 @@ program = {
common = util/grub-pe2elf.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL)';
ldadd = '$(LIBINTL)';
condition = COND_GRUB_PE2ELF;
};
@ -181,7 +182,7 @@ program = {
common = util/grub-fstest.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
condition = COND_GRUB_FSTEST;
};
@ -194,8 +195,8 @@ program = {
cflags = '$(freetype_cflags)';
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
ldflags = '$(freetype_libs)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
ldadd = '$(freetype_libs)';
condition = COND_GRUB_MKFONT;
};
@ -212,7 +213,7 @@ program = {
sparc64_ieee1275 = util/ieee1275/devicemap.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
};
program = {
@ -222,7 +223,7 @@ program = {
common = util/grub-probe.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
};
program = {
@ -239,7 +240,7 @@ program = {
sparc64_ieee1275 = util/lvm.c;
ldadd = libgrub.a;
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
enable = i386_pc;
enable = sparc64_ieee1275;
@ -252,6 +253,7 @@ program = {
ieee1275 = util/ieee1275/ofpath.c;
ldadd = libgrub.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
enable = sparc64_ieee1275;
};
@ -329,11 +331,12 @@ script = {
script = {
mansection = 1;
name = grub-mkrescue;
x86_noieee1275 = util/grub-mkrescue.in;
x86 = util/grub-mkrescue.in;
powerpc_ieee1275 = util/powerpc/ieee1275/grub-mkrescue.in;
enable = i386_pc;
enable = x86_efi;
enable = i386_qemu;
enable = i386_multiboot;
enable = i386_coreboot;
enable = powerpc_ieee1275;
};
@ -344,15 +347,17 @@ script = {
name = grub-install;
mips = util/grub-install.in;
i386_noefi_noieee1275 = util/grub-install.in;
i386_pc = util/grub-install.in;
i386_qemu = util/grub-install.in;
i386_coreboot = util/grub-install.in;
i386_multiboot = util/grub-install.in;
sparc64_ieee1275 = util/grub-install.in;
x86_efi = util/i386/efi/grub-install.in;
i386_ieee1275 = util/ieee1275/grub-install.in;
powerpc_ieee1275 = util/ieee1275/grub-install.in;
enable = x86;
enable = mips;
enable = powerpc_ieee1275;
enable = noemu;
};
script = {
@ -496,6 +501,36 @@ script = {
common = tests/grub_script_shift.in;
};
script = {
testcase;
name = grub_script_blockarg;
common = tests/grub_script_blockarg.in;
};
script = {
testcase;
name = grub_script_setparams;
common = tests/grub_script_setparams.in;
};
script = {
testcase;
name = grub_script_return;
common = tests/grub_script_return.in;
};
script = {
testcase;
name = grub_cmd_regexp;
common = tests/grub_cmd_regexp.in;
};
script = {
testcase;
name = grub_script_expansion;
common = tests/grub_script_expansion.in;
};
program = {
testcase;
name = example_unit_test;
@ -506,7 +541,7 @@ program = {
common = grub-core/tests/lib/test.c;
cflags = -Wno-format;
ldadd = libgrub.a;
ldflags = '$(LIBDEVMAPPER)';
ldadd = '$(LIBDEVMAPPER)';
};
program = {

95
NEWS
View File

@ -1,3 +1,98 @@
New in 1.99:
* New relocator. Allows for more kernel support and more
straightforward loader writing.
* Handle USB pendrives exposed as floppies.
* New Automake-based build system.
* Add `sendkey' command (i386-pc only).
* ZFS support in `grub-install' and `grub-mkconfig'. Note: complete
functionality requires external ZFS implementation (available from
grub-extras).
* Support 1.x versions of mdadm metadata.
* Fix corruption when reading Reiserfs directory entries.
* Bidirectional text and diacritics support.
* Skip LVM snapshots.
* MIPS Yeeloong firmware port.
* Change grub-mkdevicemap to emit /dev/disk/by-id/ names where possible
on GNU/Linux.
* Add `grub-mkconfig' support for Xen with Linux.
* Add `grub-mkconfig' support for initrd images on Fedora 13.
* Support >3GiB and <16MiB RAM in i386-qemu.
* Add support for Cirrus 5446 and Bochs video cards.
* Load more appropriate video drivers automatically in `grub-mkconfig'.
* USB improvements, including hotplugging/hotunplugging, hub support,
and USB serial support.
* AMD Geode CS5536 support.
* Extensive updates to the Texinfo documentation.
* Add `grub-probe' support for the btrfs filesystem, permitting / to
reside on btrfs as long as /boot is on a filesystem natively supported
by GRUB.
* Handle symbolic links under /dev/mapper on GNU/Linux.
* Handle installation across multiple partition table types.
* Add `cmostest' command (i386/x86_64 only).
* Add support for DM-RAID disk devices on GNU/Linux.
* Remove `grub-mkisofs'. `grub-mkrescue' now uses GNU xorriso to build
CD images.
* `grub-mkrescue' support for EFI, coreboot, and QEMU platforms.
* Unify `grub-mkimage' source code across platforms.
* Fix VGA (as opposed to VBE) video driver, formerly a terminal driver.
* Add menu hotkey support.
* Add support for the nilfs2 filesystem.
* `grub-probe' and `grub-mkconfig' support for NetBSD.
* Support setting a background image in `grub-mkconfig'.
* Support multiple terminals in `grub-mkconfig'.
* Regexp support.
* MIPS multiboot2 support.
* Multiboot2 tag support.
* sunpc partition table support.
* Add a number of new language features to GRUB script: `for', `while',
`until', `elif', function parameters, `break', `continue', and
`shift'.
* Support nested partition tables. GRUB now prefers to name partitions
in the form `(hd0,msdos1,bsd1)' rather than `(hd0,1,a)'.
* Speed up consecutive hostdisk operations on the same device.
* Compile parts of `grub-emu' as modules.
New in 1.98 - 2010-03-06:
* Multiboot on EFI support.

View File

@ -31,7 +31,7 @@ endif
# Other options
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir),,$<)\"
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
CPPFLAGS_DEFAULT += -I$(builddir)
CPPFLAGS_DEFAULT += -I$(srcdir)
CPPFLAGS_DEFAULT += -I$(top_builddir)
@ -115,6 +115,7 @@ pkglib_SCRIPTS =
noinst_PROGRAMS =
grubconf_SCRIPTS =
noinst_LIBRARIES =
dist_noinst_DATA =
TESTS =
EXTRA_DIST =

View File

@ -5,6 +5,11 @@ EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.tpl
EXTRA_DIST += Makefile.util.def
EXTRA_DIST += unicode
EXTRA_DIST += util/import_gcry.py
EXTRA_DIST += util/import_unicode.py
EXTRA_DIST += docs/man
EXTRA_DIST += docs/grub.cfg
@ -26,8 +31,8 @@ EXTRA_DIST += grub-core/genterminallist.sh
EXTRA_DIST += grub-core/genparttoollist.sh
EXTRA_DIST += grub-core/genemuinitheader.sh
EXTRA_DIST += grub-core/lib/libgcrypt/cipher
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/efiemu -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib/posix_wrap -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib/libgcrypt_wrap -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h')

View File

@ -586,6 +586,12 @@ AC_ARG_ENABLE([efiemu],
if test x"$enable_efiemu" = xno ; then
efiemu_excuse="explicitly disabled"
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="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
@ -816,12 +822,23 @@ fi
if test x"$device_mapper_excuse" = x ; then
# Check for device-mapper library.
AC_CHECK_LIB([devmapper], [dm_task_create],
[LIBDEVMAPPER="-ldevmapper"
AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
[Define to 1 if you have the devmapper library.])],
AC_CHECK_LIB([devmapper], [dm_task_create], [],
[device_mapper_excuse="need devmapper library"])
fi
if test x"$device_mapper_excuse" = x ; then
# Check for device-mapper library.
AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
[],
[device_mapper_excuse="need devmapper library"])
fi
if test x"$device_mapper_excuse" = x ; then
LIBDEVMAPPER="-ldevmapper";
AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
[Define to 1 if you have the devmapper library.])
fi
AC_SUBST([LIBDEVMAPPER])
AC_CHECK_LIB([zfs], [libzfs_init],
@ -836,6 +853,8 @@ AC_CHECK_LIB([nvpair], [nvlist_print],
[Define to 1 if you have the NVPAIR library.])],)
AC_SUBST([LIBNVPAIR])
LIBS=""
pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
AC_SUBST(pkglibrootdir)
@ -936,6 +955,11 @@ else
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
fi
fi
if test x"$device_mapper_excuse" = x ; then
echo With devmapper support: Yes
else
echo With devmapper support: No "($device_mapper_excuse)"
fi
if [ x"$enable_mm_debug" = xyes ]; then
echo With memory debugging: Yes
else

View File

@ -46,6 +46,8 @@ Invariant Sections.
@subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
@author Gordon Matzigkeit
@author Yoshinori K. Okuji
@author Colin Watson
@author Colin D. Bennett
@c The following two commands start the copyright page.
@page
@vskip 0pt plus 1filll
@ -77,6 +79,7 @@ This edition documents version @value{VERSION}.
* Installation:: Installing GRUB on your drive
* Booting:: How to boot different operating systems
* Configuration:: Writing your own configuration file
* Theme file format:: Format of GRUB theme files
* Network:: Downloading OS images from a network
* Serial terminal:: Using GRUB via a serial line
* Vendor power-on keys:: Changing GRUB behaviour on vendor power-on keys
@ -85,6 +88,7 @@ This edition documents version @value{VERSION}.
* Interface:: The menu and the command-line
* Commands:: The list of available builtin commands
* Security:: Authentication and authorisation
* Supported kernels:: The list of supported kernels
* Troubleshooting:: Error messages produced by GRUB
* Invoking grub-install:: How to use the GRUB installer
* Invoking grub-mkconfig:: Generate a GRUB configuration file
@ -963,7 +967,6 @@ need to write the whole thing by hand.
* Simple configuration:: Recommended for most users
* Shell-like scripting:: For power users and developers
* Embedded configuration:: Embedding a configuration file into GRUB
* Themes:: Graphical menu themes
@end menu
@ -1125,7 +1128,6 @@ The image will be scaled if necessary to fit the screen.
@item GRUB_THEME
Set a theme for use with the @samp{gfxterm} graphical terminal.
@xref{Themes}.
@item GRUB_GFXPAYLOAD_LINUX
Set to @samp{text} to force the Linux kernel to boot in normal text mode,
@ -1371,9 +1373,372 @@ fi
The embedded configuration file may not contain menu entries directly, but
may only read them from elsewhere using @command{configfile}.
@node Theme file format
@chapter Theme file format
@section Introduction
The GRUB graphical menu supports themes that can customize the layout and
appearance of the GRUB boot menu. The theme is configured through a plain
text file that specifies the layout of the various GUI components (including
the boot menu, timeout progress bar, and text messages) as well as the
appearance using colors, fonts, and images. Example is available in docs/example_theme.txt
@section Theme Elements
@subsection Colors
Colors can be specified in several ways:
@itemize
@item HTML-style ``#RRGGBB'' or ``#RGB'' format, where *R*, *G*, and *B* are hexadecimal digits (e.g., ``#8899FF'')
@item as comma-separated decimal RGB values (e.g., ``128, 128, 255'')
@item with ``SVG 1.0 color names'' (e.g., ``cornflowerblue'') which must be specified in lowercase.
@end itemize
@subsection Fonts
The fonts GRUB uses ``PFF2 font format'' bitmap fonts. Fonts are specified
with full font names. Currently there is no
provision for a preference list of fonts, or deriving one font from another.
Fonts are loaded with the ``loadfont'' command in GRUB. To see the list of
loaded fonts, execute the ``lsfonts'' command. If there are too many fonts to
fit on screen, do ``set pager=1'' before executing ``lsfonts''.
@subsection Progress Bar
@float Figure, Pixmap-styled progress bar
@c @image{Theme_progress_bar,,,,.png}
@end float
@float Figure, Plain progress bar, drawn with solid color.
@c @image{Theme_progress_bar_filled,,,,.png}
@end float
Progress bars are used to display the remaining time before GRUB boots the
default menu entry. To create a progress bar that will display the remaining
time before automatic boot, simply create a ``progress_bar'' component with
the id ``__timeout__''. This indicates to GRUB that the progress bar should
be updated as time passes, and it should be made invisible if the countdown to
automatic boot is interrupted by the user.
Progress bars may optionally have text displayed on them. This is controlled
through the ``show_text'' property, which can be set to either ``true'' or
``false'' to control whether text is displayed. When GRUB is counting down to
automatic boot, the text informs the user of the number of seconds remaining.
@subsection Circular Progress Indicator
@c @image{Theme_circular_progress,,,,.png}
The circular progress indicator functions similarly to the progress bar. When
given an id of ``__timeout__'', GRUB updates the circular progress indicator's
value to indicate the time remaining. For the circular progress indicator,
there are two images used to render it: the *center* image, and the *tick*
image. The center image is rendered in the center of the component, while the
tick image is used to render each mark along the circumference of the
indicator.
@subsection Labels
Text labels can be placed on the boot screen. The font, color, and horizontal
alignment can be specified for labels. If a label is given the id
``__timeout__'', then the ``text'' property for that label is also updated
with a message informing the user of the number of seconds remaining until
automatic boot. This is useful in case you want the text displayed somewhere
else instead of directly on the progress bar.
@subsection Boot Menu
@c @image{Theme_boot_menu,,,,.png}
The boot menu where GRUB displays the menu entries from the ``grub.cfg'' file.
It is a list of items, where each item has a title and an optional icon. The
icon is selected based on the *classes* specified for the menu entry. If
there is a PNG file named ``myclass.png'' in the ``grub/themes/icons''
directory, it will be displayed for items which have the class *myclass*. The
boot menu can be customized in several ways, such as the font and color used
for the menu entry title, and by specifying styled boxes for the menu itself
and for the selected item highlight.
@subsection Styled Boxes
One of the most important features for customizing the layout is the use of
*styled boxes*. A styled box is composed of 9 rectangular (and potentially
empty) regions, which are used to seamlessly draw the styled box on screen:
@multitable @columnfractions 0.3 0.3 0.3
@item Northwest (nw) @tab North (n) @tab Northeast (ne)
@item West (w) @tab Center (c) @tab East (e)
@item Southwest (sw) @tab South (s) @tab Southeast (se)
@end multitable
To support any size of box on screen, the center slice and the slices for the
top, bottom, and sides are all scaled to the correct size for the component on
screen, using the following rules:
@enumerate
@item The edge slices (north, south, east, and west) are scaled in the direction of the edge they are adjacent to. For instance, the west slice is scaled vertically.
@item The corner slices (northwest, northeast, southeast, and southwest) are not scaled.
@item The center slice is scaled to fill the remaining space in the middle.
@end enumerate
As an example of how an image might be sliced up, consider the styled box
used for a terminal view.
@float Figure, An example of the slices (in red) used for a terminal window. This drawing was created and sliced in Inkscape_, as the next section explains.
@c @image{Box_slice_example_terminal,,,,.png}
@end float
@subsection Creating Styled Box Images
The Inkscape_ scalable vector graphics editor is a very useful tool for
creating styled box images. One process that works well for slicing a drawing
into the necessary image slices is:
@enumerate
@item Create or open the drawing you'd like use.
@item Create a new layer on the top of the layer stack. Make it visible. Select this layer as the current layer.
@item Draw 9 rectangles on your drawing where you'd like the slices to be. Clear the fill option, and set the stroke to 1 pixel wide solid stroke. The corners of the slices must meet precisely; if it is off by a single pixel, it will probably be evident when the styled box is rendered in the GRUB menu. You should probably go to File | Document Properties | Grids and enable a grid or create a guide (click on one of the rulers next to the drawing and drag over the drawing; release the mouse button to place the guide) to help place the rectangles precisely.
@item Right click on the center slice rectangle and choose Object Properties. Change the "Id" to ``slice_c`` and click Set. Repeat this for the remaining 8 rectangles, giving them Id values of ``slice_n``, ``slice_ne``, ``slice_e``, and so on according to the location.
@item Save the drawing.
@item Select all the slice rectangles. With the slice layer selected, you can simply press Ctrl+A to select all rectangles. The status bar should indicate that 9 rectangles are selected.
@item Click the layer hide icon for the slice layer in the layer palette. The rectangles will remain selected, even though they are hidden.
@item Choose File | Export Bitmap and check the *Batch export 9 selected objects* box. Make sure that *Hide all except selected* is unchecked. click *Export*. This will create PNG files in the same directory as the drawing, named after the slices. These can now be used for a styled box in a GRUB theme.
@end enumerate
@section Theme File Manual
The theme file is a plain text file. Lines that begin with ``#`` are ignored
and considered comments. (Note: This may not be the case if the previous line
ended where a value was expected.)
The theme file contains two types of statements:
@enumerate
@item Global properties.
@item Component construction.
@end enumerate
@subsection Global Properties
@subsection Format
Global properties are specified with the simple format:
@itemize
@item name1: value1
@item name2: "value which may contain spaces"
@item name3: #88F
@end itemize
In this example, name3 is assigned a color value.
@subsection Global Property List
@multitable @columnfractions 0.3 0.6
@item title-text @tab Specifies the text to display at the top center of the screen as a title.
@item title-font @tab Defines the font used for the title message at the top of the screen.
@item title-color @tab Defines the color of the title message.
@item message-font @tab Defines the font used for messages, such as when GRUB is unable to automatically boot an entry.
@item message-color @tab Defines the color of the message text.
@item message-bg-color @tab Defines the background color of the message text area.
@item desktop-image @tab Specifies the image to use as the background. It will be scaled to fit the screen size.
@item desktop-color @tab Specifies the color for the background if *desktop-image* is not specified.
@item terminal-box @tab Specifies the file name pattern for the styled box slices used for the command line terminal window. For example, ``terminal-box: terminal_*.png'' will use the images ``terminal_c.png`` as the center area, ``terminal_n.png`` as the north (top) edge, ``terminal_nw.png`` as the northwest (upper left) corner, and so on. If the image for any slice is not found, it will simply be left empty.
@end multitable
@subsection Component Construction
Greater customizability comes is provided by components. A tree of components
forms the user interface. *Containers* are components that can contain other
components, and there is always a single root component which is an instance
of a *canvas* container.
Components are created in the theme file by prefixing the type of component
with a '+' sign:
@code{ + label @{ text="GRUB" font="aqui 11" color="#8FF" @} }
properties of a component are specified as "name = value" (whitespace
surrounding tokens is optional and is ignored) where *value* may be:
@itemize
@item a single word (e.g., ``align = center``, ``color = #FF8080``),
@item a quoted string (e.g., ``text = "Hello, World!"``), or
@item a tuple (e.g., ``preferred_size = (120, 80)``).
@end itemize
@subsection Component List
The following is a list of the components and the properties they support.
@itemize
@item label
A label displays a line of text.
Properties:
@multitable @columnfractions 0.2 0.7
@item text @tab The text to display.
@item font @tab The font to use for text display.
@item color @tab The color of the text.
@item align @tab The horizontal alignment of the text within the component. Options are ``left``, ``center``, and ``right``.
@end multitable
@item image
A component that displays an image. The image is scaled to fit the
component, although the preferred size defaults to the image's original
size unless the ``preferred_size`` property is explicitly set.
Properties:
@multitable @columnfractions 0.2 0.7
@item file @tab The full path to the image file to load.
@end multitable
@item progress_bar
Displays a horizontally oriented progress bar. It can be rendered using
simple solid filled rectangles, or using a pair of pixmap styled boxes.
Properties:
@multitable @columnfractions 0.2 0.7
@item fg_color @tab The foreground color for plain solid color rendering.
@item bg_color @tab The background color for plain solid color rendering.
@item border_color @tab The border color for plain solid color rendering.
@item text_color @tab The text color.
@item show_text @tab Boolean value indicating whether or not text should be displayed on the progress bar. If set to *false*, then no text will be displayed on the bar. If set to any other value, text will be displayed on the bar.
@item bar_style @tab The styled box specification for the frame of the progress bar. Example: ``progress_frame_*.png``
@item highlight_style @tab The styled box specification for the highlighted region of the progress bar. This box will be used to paint just the highlighted region of the bar, and will be increased in size as the bar nears completion. Example: ``progress_hl_*.png``.
@item text @tab The text to display on the progress bar. If the progress bar's ID is set to ``__timeout__``, then GRUB will updated this property with an informative message as the timeout approaches.
@item value @tab The progress bar current value. Normally not set manually.
@item start @tab The progress bar start value. Normally not set manually.
@item end @tab The progress bar end value. Normally not set manually.
@end multitable
@item circular_progress
Displays a circular progress indicator. The appearance of this component
is determined by two images: the *center* image and the *tick* image. The
center image is generally larger and will be drawn in the center of the
component. Around the circumference of a circle within the component, the
tick image will be drawn a certain number of times, depending on the
properties of the component.
Properties:
@multitable @columnfractions 0.3 0.6
@item center_bitmap
@tab The file name of the image to draw in the center of the component.
@item tick_bitmap
@tab The file name of the image to draw for the tick marks.
@item num_ticks
@tab The number of ticks that make up a full circle.
@item ticks_disappear
@tab Boolean value indicating whether tick marks should progressively appear,
or progressively disappear as *value* approaches *end*. Specify
``true`` or ``false``.
@item value
@tab The progress indicator current value. Normally not set manually.
@item start
@tab The progress indicator start value. Normally not set manually.
@item end
@tab The progress indicator end value. Normally not set manually.
@end multitable
@item boot_menu
Displays the GRUB boot menu. It allows selecting items and executing them.
Properties:
@multitable @columnfractions 0.4 0.5
@item item_font
@tab The font to use for the menu item titles.
@item selected_item_font
@tab The font to use for the selected menu item, or ``inherit`` (the default)
to use ``item_font`` for the selected menu item as well.
@item item_color
@tab The color to use for the menu item titles.
@item selected_item_color
@tab The color to use for the selected menu item, or ``inherit`` (the default)
to use ``item_color`` for the selected menu item as well.
@item icon_width
@tab The width of menu item icons. Icons are scaled to the specified size.
@item icon_height
@tab The height of menu item icons.
@item item_height
@tab The height of each menu item in pixels.
@item item_padding
@tab The amount of space in pixels to leave on each side of the menu item
contents.
@item item_icon_space
@tab The space between an item's icon and the title text, in pixels.
@item item_spacing
@tab The amount of space to leave between menu items, in pixels.
@item menu_pixmap_style
@tab The image file pattern for the menu frame styled box.
Example: ``menu_*.png`` (this will use images such as ``menu_c.png``,
``menu_w.png``, `menu_nw.png``, etc.)
@item selected_item_pixmap_style
@tab The image file pattern for the selected item highlight styled box.
@item scrollbar
@tab Boolean value indicating whether the scroll bar should be drawn if the
frame and thumb styled boxes are configured.
@item scrollbar_frame
@tab The image file pattern for the entire scroll bar.
Example: ``scrollbar_*.png``
@item scrollbar_thumb
@tab The image file pattern for the scroll bar thumb (the part of the scroll
bar that moves as scrolling occurs).
Example: ``scrollbar_thumb_*.png``
@item max_items_shown
@tab The maximum number of items to show on the menu. If there are more than
*max_items_shown* items in the menu, the list will scroll to make all
items accessible.
@end multitable
@item canvas
Canvas is a container that allows manual placement of components within it.
It does not alter the positions of its child components. It assigns all
child components their preferred sizes.
@item hbox
The *hbox* container lays out its children from left to right, giving each
one its preferred width. The height of each child is set to the maximum of
the preferred heights of all children.
@item vbox
The *vbox* container lays out its children from top to bottom, giving each
one its preferred height. The width of each child is set to the maximum of
the preferred widths of all children.
@end itemize
@subsection Common properties
The following properties are supported by all components:
@table @samp
@item left
The distance from the left border of container to left border of the object in either of three formats:
@multitable @columnfractions 0.2 0.7
@item x @tab Value in pixels
@item p% @tab Percentage
@item p%+x @tab mixture of both
@end multitable
@item top
The distance from the left border of container to left border of the object in same format.
@item width
The width of object in same format.
@item height
The height of object in same format.
@item id
The identifier for the component. This can be any arbitrary string.
The ID can be used by scripts to refer to various components in the GUI
component tree. Currently, there is one special ID value that GRUB
recognizes:
@multitable @columnfractions 0.2 0.7
@item ``__timeout__`` @tab Any component with this ID will have its *text*, *start*, *end*, *value*, and *visible* properties set by GRUB when it is counting down to an automatic boot of the default menu entry.
@end multitable
@end table
@node Themes
@section Graphical menu themes
@node Network
@ -1435,7 +1800,7 @@ The boot file name provided by DHCP. Read-only.
The name of the DHCP server responsible for these boot parameters.
Read-only.
@item net_pxe_blksize
@item pxe_blksize
The PXE transfer block size. Read-write, defaults to 512.
@item pxe_default_server
@ -2862,6 +3227,145 @@ adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2}
commands.
@node Supported kernels
@chapter Supported boot targets
X86 support is summarised in following table. ``Yes'' means that kernel works on the given platform, ``crashes'' means an early kernel crash which we hove will be fixed by concerned kernel developpers. ``no'' means GRUB doesn't load given kernel on a given platform. ``headless'' means that the kernel works but lacks console drivers (you can still use serial or network console). In case of ``no'' and ``crashes'' the reason is given in footnote.
@multitable @columnfractions .50 .22 .22
@item @tab BIOS @tab Coreboot
@item BIOS chainloading @tab yes @tab no (1)
@item NTLDR @tab yes @tab no (1)
@item FreeBSD bootloader @tab yes @tab crashes (1)
@item 32-bit kFreeBSD @tab yes @tab crashes (2,6)
@item 64-bit kFreeBSD @tab yes @tab crashes (2,6)
@item 32-bit kNetBSD @tab yes @tab crashes (1)
@item 64-bit kNetBSD @tab yes @tab crashes (2)
@item 32-bit kOpenBSD @tab yes @tab yes
@item 64-bit kOpenBSD @tab yes @tab yes
@item Multiboot @tab yes @tab yes
@item Multiboot2 @tab yes @tab yes
@item 32-bit Linux (legacy protocol) @tab yes @tab no (1)
@item 64-bit Linux (legacy protocol) @tab yes @tab no (1)
@item 32-bit Linux (modern protocol) @tab yes @tab yes
@item 64-bit Linux (modern protocol) @tab yes @tab yes
@item 32-bit XNU @tab yes @tab ?
@item 64-bit XNU @tab yes @tab ?
@item 32-bit EFI chainloader @tab no (3) @tab no (3)
@item 64-bit EFI chainloader @tab no (3) @tab no (3)
@item Appleloader @tab no (3) @tab no (3)
@end multitable
@multitable @columnfractions .50 .22 .22
@item @tab Multiboot @tab Qemu
@item BIOS chainloading @tab no (1) @tab no (1)
@item NTLDR @tab no (1) @tab no (1)
@item FreeBSD bootloader @tab crashes (1) @tab crashes (1)
@item 32-bit kFreeBSD @tab crashes (6) @tab crashes (6)
@item 64-bit kFreeBSD @tab crashes (6) @tab crashes (6)
@item 32-bit kNetBSD @tab crashes (1) @tab crashes (1)
@item 64-bit kNetBSD @tab yes @tab yes
@item 32-bit kOpenBSD @tab yes @tab yes
@item 64-bit kOpenBSD @tab yes @tab yes
@item Multiboot @tab yes @tab yes
@item Multiboot2 @tab yes @tab yes
@item 32-bit Linux (legacy protocol) @tab no (1) @tab no (1)
@item 64-bit Linux (legacy protocol) @tab no (1) @tab no (1)
@item 32-bit Linux (modern protocol) @tab yes @tab yes
@item 64-bit Linux (modern protocol) @tab yes @tab yes
@item 32-bit XNU @tab ? @tab ?
@item 64-bit XNU @tab ? @tab ?
@item 32-bit EFI chainloader @tab no (3) @tab no (3)
@item 64-bit EFI chainloader @tab no (3) @tab no (3)
@item Appleloader @tab no (3) @tab no (3)
@end multitable
@multitable @columnfractions .50 .22 .22
@item @tab 32-bit EFI @tab 64-bit EFI
@item BIOS chainloading @tab no (1) @tab no (1)
@item NTLDR @tab no (1) @tab no (1)
@item FreeBSD bootloader @tab crashes (1) @tab crashes (1)
@item 32-bit kFreeBSD @tab headless @tab headless
@item 64-bit kFreeBSD @tab headless @tab headless
@item 32-bit kNetBSD @tab crashes (1) @tab crashes (1)
@item 64-bit kNetBSD @tab yes @tab yes
@item 32-bit kOpenBSD @tab headless @tab headless
@item 64-bit kOpenBSD @tab headless @tab headless
@item Multiboot @tab yes @tab yes
@item Multiboot2 @tab yes @tab yes
@item 32-bit Linux (legacy protocol) @tab no (1) @tab no (1)
@item 64-bit Linux (legacy protocol) @tab no (1) @tab no (1)
@item 32-bit Linux (modern protocol) @tab yes @tab yes
@item 64-bit Linux (modern protocol) @tab yes @tab yes
@item 32-bit XNU @tab yes @tab yes
@item 64-bit XNU @tab yes (5) @tab yes
@item 32-bit EFI chainloader @tab yes @tab no (4)
@item 64-bit EFI chainloader @tab no (4) @tab yes
@item Appleloader @tab yes @tab yes
@end multitable
@multitable @columnfractions .50 .22 .22
@item @tab IEEE1275
@item BIOS chainloading @tab no (1)
@item NTLDR @tab no (1)
@item FreeBSD bootloader @tab crashes (1)
@item 32-bit kFreeBSD @tab crashes (6)
@item 64-bit kFreeBSD @tab crashes (6)
@item 32-bit kNetBSD @tab crashes (1)
@item 64-bit kNetBSD @tab ?
@item 32-bit kOpenBSD @tab ?
@item 64-bit kOpenBSD @tab ?
@item Multiboot @tab ?
@item Multiboot2 @tab ?
@item 32-bit Linux (legacy protocol) @tab no (1)
@item 64-bit Linux (legacy protocol) @tab no (1)
@item 32-bit Linux (modern protocol) @tab ?
@item 64-bit Linux (modern protocol) @tab ?
@item 32-bit XNU @tab ?
@item 64-bit XNU @tab ?
@item 32-bit EFI chainloader @tab no (3)
@item 64-bit EFI chainloader @tab no (3)
@item Appleloader @tab no (3)
@end multitable
@enumerate
@item Requires BIOS
@item Crashes because the memory at 0x0-0x1000 isn't available
@item EFI only
@item 32-bit and 64-bit EFI have different structures and work in different CPU modes so it's not possible to chainload 32-bit bootloader on 64-bit platform and vice-versa
@item Some modules may need to be disabled
@item Requires ACPI
@end enumerate
PowerPC and Sparc ports support only Linux. MIPS port supports Linux and multiboot2.
@chapter Boot tests
As you have seen in previous chapter the support matrix is pretty big and some of the configurations are only rarely used. To ensure the quality bootchecks are available for all x86 targets except EFI chainloader, Appleloader and XNU. All x86 platforms have bootcheck facility except ieee1275. Multiboot, multiboot2, BIOS chainloader, ntldr and freebsd-bootloader boot targets are tested only with a fake kernel images. Only Linux is tested among the payloads using Linux protocols.
Following variables must be defined:
@multitable @columnfractions .30 .65
@item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only)
@item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
@item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
@end multitable
Required files are:
@multitable @columnfractions .40 .55
@item kfreebsd_env.i386 @tab 32-bit kFreeBSD device hints
@item kfreebsd.i386 @tab 32-bit FreeBSD kernel image
@item kfreebsd.x86_64, kfreebsd_env.x86_64 @tab same from 64-bit kFreeBSD
@item knetbsd.i386 @tab 32-bit NetBSD kernel image
@item knetbsd.miniroot.i386 @tab 32-bit kNetBSD miniroot.kmod.
@item knetbsd.x86_64, knetbsd.miniroot.x86_64 @tab same from 64-bit kNetBSD
@item kopenbsd.i386 @tab 32-bit OpenBSD kernel bsd.rd image
@item kopenbsd.x86_64 @tab same from 64-bit kOpenBSD
@item linux.i386 @tab 32-bit Linux
@item linux.x86_64 @tab 64-bit Linux
@end multitable
@node Troubleshooting
@chapter Error messages produced by GRUB

View File

@ -10,46 +10,38 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
"powerpc_ieee1275" ]
GROUPS = {}
GROUPS["common"] = GRUB_PLATFORMS[:]
# Groups based on CPU
GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
GROUPS["x86_64"] = [ "x86_64_efi" ]
GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"]
GROUPS["x86_efi"] = [ "i386_efi", "x86_64_efi" ]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
GROUPS["x86_efi_pc"] = GROUPS["x86_efi"] + ["i386_pc"]
GROUPS["x86_noefi"] = GROUPS["x86"][:]; GROUPS["x86_noefi"].remove("i386_efi"); GROUPS["x86_noefi"].remove("x86_64_efi")
GROUPS["i386_noefi"] = GROUPS["i386"][:]; GROUPS["i386_noefi"].remove("i386_efi")
GROUPS["x86_noieee1275"] = GROUPS["x86"][:]; GROUPS["x86_noieee1275"].remove("i386_ieee1275")
GROUPS["i386_noieee1275"] = GROUPS["i386"][:]; GROUPS["i386_noieee1275"].remove("i386_ieee1275")
GROUPS["i386_noefi_noieee1275"] = GROUPS["i386_noefi"][:]; GROUPS["i386_noefi_noieee1275"].remove("i386_ieee1275")
GROUPS["i386_pc_qemu_coreboot"] = ["i386_pc", "i386_qemu", "i386_coreboot"]
GROUPS["i386_coreboot_multiboot"] = ["i386_coreboot", "i386_multiboot"]
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["i386_pc_coreboot_multiboot_qemu"] = ["i386_pc", "i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["mips"] = [ "mips_yeeloong" ]
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
GROUPS["nosparc64"] = GRUB_PLATFORMS[:]; GROUPS["nosparc64"].remove("sparc64_ieee1275")
GROUPS["x86_noefi_mips"] = GROUPS["x86_noefi"] + GROUPS["mips"]
# Groups based on firmware
GROUPS["x86_efi"] = [ "i386_efi", "x86_64_efi" ]
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
GROUPS["noieee1275"] = GRUB_PLATFORMS[:]
for i in GROUPS["ieee1275"]: GROUPS["noieee1275"].remove(i)
GROUPS["ieee1275_mips"] = GROUPS["ieee1275"] + GROUPS["mips"]
GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"]
# emu is a special case so many core functionality isn't needed on this platform
GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
GROUPS["noemu_noieee1275"] = GRUB_PLATFORMS[:]
for i in ["emu"] + GROUPS["ieee1275"]: GROUPS["noemu_noieee1275"].remove(i)
GROUPS["common"] = GRUB_PLATFORMS[:]
# Groups based on hardware features
GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi")
GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"]
GROUPS["usb"] = GROUPS["pci"]
# If gfxterm is main output console integrate it into kernel
GROUPS["videoinkernel"] = ["mips_yeeloong"]
GROUPS["videomodules"] = GRUB_PLATFORMS[:];
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
# Miscelaneous groups schedulded to disappear in future
GROUPS["nosparc64"] = GRUB_PLATFORMS[:]; GROUPS["nosparc64"].remove("sparc64_ieee1275")
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
#
# Create platform => groups reverse map, where groups covering that
@ -486,7 +478,7 @@ chmod a+x [+ name +]
""")
r += gvar_add("CLEANFILES", "[+ name +]")
r += gvar_add("EXTRA_DIST", platform_sources(platform))
r += gvar_add("dist_noinst_DATA", platform_sources(platform))
return r
def module_rules():

View File

@ -58,8 +58,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/elf.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/elfload.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h
@ -70,35 +68,23 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/reader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/symbol.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/types.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
if COND_i386_pc
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/biosdisk.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/vga.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/vbe.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_i386_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
@ -106,63 +92,36 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_i386_coreboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_i386_qemu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_i386_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_x86_64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_mips_yeeloong
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
@ -180,28 +139,17 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/serial.h
endif
if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif
if COND_sparc64_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
endif
if COND_emu
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/time.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/types.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gzio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/menu.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
if COND_GRUB_EMU_SDL
@ -312,7 +260,6 @@ moddep.lst: kernel_syms.lst genmoddep.awk $(DEF_FILES) $(UND_FILES)
| $(AWK) -f $(srcdir)/genmoddep.awk $(UND_FILES) > $@ \
|| (rm -f $@; exit 1)
if COND_i386_pc
if COND_ENABLE_EFIEMU
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
-rm -f $@; \
@ -355,5 +302,3 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
platform_DATA += efiemu32.o efiemu64.o
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
endif
endif

View File

@ -36,7 +36,8 @@ kernel = {
x86_64_efi_startup = kern/x86_64/efi/startup.S;
i386_qemu_startup = kern/i386/qemu/startup.S;
i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
i386_coreboot_multiboot_startup = kern/i386/coreboot/startup.S;
i386_coreboot_startup = kern/i386/coreboot/startup.S;
i386_multiboot_startup = kern/i386/coreboot/startup.S;
mips_yeeloong_startup = kern/mips/startup.S;
sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
@ -65,7 +66,12 @@ kernel = {
noemu_nodist = symlist.c;
noemu_noieee1275 = kern/generic/rtc_get_time_ms.c;
i386_pc = kern/generic/rtc_get_time_ms.c;
x86_efi = kern/generic/rtc_get_time_ms.c;
i386_qemu = kern/generic/rtc_get_time_ms.c;
i386_coreboot = kern/generic/rtc_get_time_ms.c;
i386_multiboot = kern/generic/rtc_get_time_ms.c;
mips_yeeloong = kern/generic/rtc_get_time_ms.c;
ieee1275 = disk/ieee1275/ofdisk.c;
ieee1275 = kern/ieee1275/cmain.c;
@ -74,20 +80,20 @@ kernel = {
ieee1275 = kern/ieee1275/openfw.c;
ieee1275 = term/ieee1275/ofconsole.c;
ieee1275_mips = term/terminfo.c;
ieee1275_mips = term/tparm.c;
ieee1275 = term/terminfo.c;
ieee1275 = term/tparm.c;
mips = term/terminfo.c;
mips = term/tparm.c;
i386 = kern/i386/dl.c;
i386_coreboot_multiboot_qemu = kern/i386/coreboot/init.c;
i386_coreboot_multiboot_qemu = kern/i386/halt.c;
i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c;
i386_pc_coreboot_multiboot_qemu = term/i386/vga_common.c;
i386_coreboot_multiboot_qemu = term/i386/vga_common.c;
i386_pc = term/i386/vga_common.c;
i386_noefi = kern/i386/misc.S;
x86_noieee1275 = kern/i386/pit.c;
x86 = kern/i386/pit.c;
x86_efi = disk/efi/efidisk.c;
x86_efi = kern/efi/efi.c;
@ -118,33 +124,20 @@ kernel = {
i386_multiboot = kern/i386/multiboot_mmap.c;
i386_multiboot = kern/i386/tsc.c;
i386_ieee1275 = kern/i386/ieee1275/init.c;
i386_ieee1275 = kern/ieee1275/init.c;
mips_yeeloong = term/ns8250.c;
mips_yeeloong = bus/bonito.c;
mips_yeeloong = bus/cs5536.c;
mips_yeeloong = bus/pci.c;
mips_yeeloong = commands/extcmd.c;
mips_yeeloong = font/font.c;
mips_yeeloong = font/font_cmd.c;
mips_yeeloong = io/bufio.c;
mips_yeeloong = kern/mips/cache.S;
mips_yeeloong = kern/mips/dl.c;
mips_yeeloong = kern/mips/init.c;
mips_yeeloong = kern/mips/yeeloong/init.c;
mips_yeeloong = lib/arg.c;
mips_yeeloong = term/at_keyboard.c;
mips_yeeloong = term/gfxterm.c;
mips_yeeloong = term/serial.c;
mips_yeeloong = video/bitmap.c;
mips_yeeloong = video/bitmap_scale.c;
mips_yeeloong = video/fb/fbblit.c;
mips_yeeloong = video/fb/fbfill.c;
mips_yeeloong = video/fb/fbutil.c;
mips_yeeloong = video/fb/video_fb.c;
mips_yeeloong = video/sm712.c;
mips_yeeloong = video/video.c;
extra_dist = video/sm712_init.c;
powerpc_ieee1275 = kern/ieee1275/init.c;
powerpc_ieee1275 = kern/powerpc/cache.S;
@ -166,9 +159,23 @@ kernel = {
emu = kern/emu/mm.c;
emu = kern/emu/time.c;
extra_dist = kern/i386/loader.S;
videoinkernel = lib/arg.c;
videoinkernel = term/gfxterm.c;
videoinkernel = commands/extcmd.c;
videoinkernel = font/font.c;
videoinkernel = font/font_cmd.c;
videoinkernel = io/bufio.c;
videoinkernel = video/bitmap.c;
videoinkernel = video/bitmap_scale.c;
videoinkernel = video/fb/fbblit.c;
videoinkernel = video/fb/fbfill.c;
videoinkernel = video/fb/fbutil.c;
videoinkernel = video/fb/video_fb.c;
videoinkernel = video/video.c;
extra_dist = kern/i386/realmode.S;
extra_dist = kern/i386/pc/lzma_decode.S;
extra_dist = kern/mips/cache_flush.S;
};
program = {
@ -305,8 +312,7 @@ module = {
noemu = bus/usb/usbtrans.c;
noemu = bus/usb/usbhub.c;
enable = emu;
enable = i386;
enable = mips_yeeloong;
enable = usb;
emu_condition = COND_GRUB_EMU_USB;
};
@ -314,8 +320,7 @@ module = {
name = usbserial_common;
common = bus/usb/serial/common.c;
enable = emu;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
emu_condition = COND_GRUB_EMU_USB;
};
@ -323,8 +328,7 @@ module = {
name = usbserial_pl2303;
common = bus/usb/serial/pl2303.c;
enable = emu;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
emu_condition = COND_GRUB_EMU_USB;
};
@ -332,22 +336,20 @@ module = {
name = usbserial_ftdi;
common = bus/usb/serial/ftdi.c;
enable = emu;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
emu_condition = COND_GRUB_EMU_USB;
};
module = {
name = uhci;
common = bus/usb/uhci.c;
enable = i386_pc;
enable = x86;
};
module = {
name = ohci;
common = bus/usb/ohci.c;
enable = i386_pc;
enable = mips_yeeloong;
enable = pci;
};
module = {
@ -361,6 +363,7 @@ module = {
enable = x86_efi;
enable = i386_ieee1275;
enable = i386_coreboot;
enable = i386_multiboot;
emu_condition = COND_GRUB_EMU_PCI;
};
@ -379,9 +382,8 @@ library = {
module = {
name = cmostest;
i386 = commands/i386/cmostest.c;
enable = i386_pc;
enable = i386_coreboot;
common = commands/i386/cmostest.c;
enable = cmos;
};
module = {
@ -393,6 +395,7 @@ module = {
module = {
name = regexp;
common = commands/regexp.c;
common = commands/wildcard.c;
ldadd = libgnulib.a;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
@ -401,12 +404,16 @@ module = {
module = {
name = acpi;
i386 = commands/acpi.c;
x86 = commands/acpi.c;
x86_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 = x86_efi;
enable = i386_pc;
enable = i386_coreboot;
enable = i386_multiboot;
};
module = {
@ -486,6 +493,12 @@ module = {
name = halt;
nopc = commands/halt.c;
i386_pc = commands/i386/pc/halt.c;
i386_multiboot = lib/i386/halt.c;
i386_coreboot = lib/i386/halt.c;
i386_qemu = lib/i386/halt.c;
x86_efi = lib/efi/halt.c;
ieee1275 = lib/ieee1275/halt.c;
emu = lib/emu/halt.c;
};
module = {
@ -497,7 +510,7 @@ module = {
name = hdparm;
common = commands/hdparm.c;
common = lib/hexdump.c;
enable = i386_pc;
enable = pci;
};
module = {
@ -542,8 +555,7 @@ module = {
name = lspci;
common = commands/lspci.c;
enable = x86;
enable = mips;
enable = pci;
};
module = {
@ -655,8 +667,7 @@ module = {
module = {
name = usbtest;
common = commands/usbtest.c;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
enable = emu;
emu_condition = COND_GRUB_EMU_USB;
};
@ -731,15 +742,13 @@ module = {
module = {
name = ata;
common = disk/ata.c;
enable = x86;
enable = mips;
enable = pci;
};
module = {
name = ata_pthru;
common = disk/ata_pthru.c;
enable = x86;
enable = mips_yeeloong;
enable = pci;
};
module = {
@ -751,8 +760,7 @@ module = {
module = {
name = usbms;
common = disk/usbms.c;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
enable = emu;
emu_condition = COND_GRUB_EMU_USB;
};
@ -765,19 +773,23 @@ module = {
module = {
name = efiemu;
i386_pc = efiemu/main.c;
i386_pc = efiemu/i386/loadcore32.c;
i386_pc = efiemu/i386/loadcore64.c;
common = efiemu/main.c;
common = efiemu/i386/loadcore32.c;
common = efiemu/i386/loadcore64.c;
i386_pc = efiemu/i386/pc/cfgtables.c;
i386_pc = efiemu/mm.c;
i386_pc = efiemu/loadcore_common.c;
i386_pc = efiemu/symbols.c;
i386_pc = efiemu/loadcore32.c;
i386_pc = efiemu/loadcore64.c;
i386_pc = efiemu/prepare32.c;
i386_pc = efiemu/prepare64.c;
i386_pc = efiemu/pnvram.c;
i386_pc = efiemu/i386/coredetect.c;
i386_coreboot = efiemu/i386/pc/cfgtables.c;
i386_multiboot = efiemu/i386/pc/cfgtables.c;
i386_ieee1275 = efiemu/i386/nocfgtables.c;
i386_qemu = efiemu/i386/nocfgtables.c;
common = efiemu/mm.c;
common = efiemu/loadcore_common.c;
common = efiemu/symbols.c;
common = efiemu/loadcore32.c;
common = efiemu/loadcore64.c;
common = efiemu/prepare32.c;
common = efiemu/prepare64.c;
common = efiemu/pnvram.c;
common = efiemu/i386/coredetect.c;
extra_dist = efiemu/prepare.c;
extra_dist = efiemu/loadcore.c;
@ -785,16 +797,17 @@ module = {
extra_dist = efiemu/runtime/efiemu.c;
enable = i386_pc;
enable = i386_coreboot;
enable = i386_ieee1275;
enable = i386_multiboot;
enable = i386_qemu;
};
module = {
name = font;
common = font/font.c;
common = font/font_cmd.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
@ -962,10 +975,7 @@ module = {
module = {
name = bufio;
common = io/bufio.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
@ -987,26 +997,35 @@ module = {
module = {
name = relocator;
mips = lib/mips/relocator.c;
mips = lib/mips/relocator_asm.S;
common = lib/relocator.c;
x86 = lib/i386/relocator16.S;
x86 = lib/i386/relocator32.S;
x86 = lib/i386/relocator64.S;
i386 = lib/i386/relocator_asm.S;
x86_64 = lib/x86_64/relocator_asm.S;
x86 = lib/i386/relocator.c;
x86 = lib/i386/relocator_asm.S;
x86 = lib/i386/relocator_backward.S;
extra_dist = lib/relocator.c;
ieee1275 = lib/ieee1275/relocator.c;
x86_efi = lib/efi/relocator.c;
mips = lib/mips/relocator_asm.S;
mips = lib/mips/relocator.c;
powerpc = lib/powerpc/relocator_asm.S;
powerpc = lib/powerpc/relocator.c;
extra_dist = lib/i386/relocator_common.S;
extra_dist = kern/powerpc/cache_flush.S;
enable = mips;
enable = powerpc;
enable = x86;
};
module = {
name = datetime;
x86_noefi_mips = lib/cmos_datetime.c;
cmos = lib/cmos_datetime.c;
x86_efi = lib/efi/datetime.c;
sparc64_ieee1275 = lib/ieee1275/datetime.c;
powerpc_ieee1275 = lib/ieee1275/datetime.c;
enable = x86;
enable = mips;
enable = sparc64_ieee1275;
enable = powerpc_ieee1275;
enable = noemu;
};
module = {
@ -1022,28 +1041,19 @@ module = {
module = {
name = aout;
common = loader/aout.c;
enable = i386_pc;
enable = i386_qemu;
enable = i386_coreboot;
enable = i386_multiboot;
enable = i386_ieee1275;
enable = x86;
};
module = {
name = bsd;
i386 = loader/i386/bsd.c;
i386 = loader/i386/bsd32.c;
i386 = loader/i386/bsd64.c;
i386 = loader/i386/bsd_helper.S;
i386 = loader/i386/bsd_trampoline.S;
x86 = loader/i386/bsd.c;
x86 = loader/i386/bsd32.c;
x86 = loader/i386/bsd64.c;
extra_dist = loader/i386/bsdXX.c;
extra_dist = loader/i386/bsd_pagetable.c;
enable = i386_pc;
enable = i386_qemu;
enable = i386_coreboot;
enable = i386_multiboot;
enable = x86;
};
module = {
@ -1052,6 +1062,12 @@ module = {
enable = i386_pc;
};
module = {
name = ntldr;
i386_pc = loader/i386/pc/ntldr.c;
enable = i386_pc;
};
module = {
name = multiboot2;
cppflags = "-DGRUB_USE_MULTIBOOT2";
@ -1072,11 +1088,7 @@ module = {
module = {
name = linux;
i386_noefi_noieee1275 = loader/i386/linux.c;
x86_efi = loader/i386/efi/linux.c;
x86_64_efi = loader/i386/linux_trampoline.S;
i386_ieee1275 = loader/i386/ieee1275/linux.c;
x86 = loader/i386/linux.c;
mips = loader/mips/linux.c;
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
@ -1085,16 +1097,15 @@ module = {
module = {
name = xnu;
x86_efi_pc = loader/xnu_resume.c;
x86_efi_pc = loader/i386/xnu.c;
x86_efi_pc = loader/macho32.c;
x86_efi_pc = loader/macho64.c;
x86_efi_pc = loader/macho.c;
x86_efi_pc = loader/xnu.c;
x86 = loader/xnu_resume.c;
x86 = loader/i386/xnu.c;
x86 = loader/macho32.c;
x86 = loader/macho64.c;
x86 = loader/macho.c;
x86 = loader/xnu.c;
extra_dist = loader/machoXX.c;
enable = i386_pc;
enable = x86_efi;
enable = x86;
};
module = {
@ -1113,34 +1124,15 @@ module = {
module = {
name = mmap;
i386_pc = mmap/mmap.c;
i386_pc = mmap/i386/uppermem.c;
i386_pc = mmap/i386/mmap.c;
common = mmap/mmap.c;
x86 = mmap/i386/uppermem.c;
x86 = mmap/i386/mmap.c;
i386_pc = mmap/i386/pc/mmap.c;
i386_pc = mmap/i386/pc/mmap_helper.S;
x86_efi = mmap/mmap.c;
x86_efi = mmap/i386/uppermem.c;
x86_efi = mmap/i386/mmap.c;
x86_efi = mmap/efi/mmap.c;
i386_coreboot = mmap/mmap.c;
i386_coreboot = mmap/i386/uppermem.c;
i386_coreboot = mmap/i386/mmap.c;
i386_multiboot = mmap/mmap.c;
i386_multiboot = mmap/i386/uppermem.c;
i386_multiboot = mmap/i386/mmap.c;
i386_qemu = mmap/mmap.c;
i386_qemu = mmap/i386/uppermem.c;
i386_qemu = mmap/i386/mmap.c;
i386_ieee1275 = mmap/mmap.c;
i386_ieee1275 = mmap/i386/uppermem.c;
i386_ieee1275 = mmap/i386/mmap.c;
mips_yeeloong = mmap/mmap.c;
mips_yeeloong = mmap/mips/yeeloong/uppermem.c;
enable = x86;
@ -1173,6 +1165,8 @@ module = {
common = script/lexer.c;
common = script/argv.c;
common = commands/menuentry.c;
common = unidata.c;
common_nodist = grub_script.tab.c;
common_nodist = grub_script.yy.c;
@ -1240,10 +1234,7 @@ module = {
module = {
name = gfxterm;
common = term/gfxterm.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
@ -1272,8 +1263,7 @@ module = {
module = {
name = usb_keyboard;
common = term/usb_keyboard.c;
enable = i386_pc;
enable = mips_yeeloong;
enable = usb;
};
module = {
@ -1284,9 +1274,11 @@ module = {
module = {
name = vga_text;
x86 = term/i386/pc/vga_text.c;
x86 = term/i386/vga_common.c;
enable = x86;
common = term/i386/pc/vga_text.c;
common = term/i386/vga_common.c;
enable = i386_pc;
enable = i386_coreboot;
enable = i386_multiboot;
};
module = {
@ -1316,19 +1308,13 @@ module = {
module = {
name = bitmap;
common = video/bitmap.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
name = bitmap_scale;
common = video/bitmap_scale.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
@ -1370,19 +1356,13 @@ module = {
common = video/fb/fbblit.c;
common = video/fb/fbfill.c;
common = video/fb/fbutil.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
name = video;
common = video/video.c;
enable = emu;
enable = x86;
enable = sparc64;
enable = powerpc;
enable = videomodules;
};
module = {
@ -1409,4 +1389,24 @@ module = {
common = commands/legacycfg.c;
common = lib/legacy_parse.c;
enable = i386_pc;
}
module = {
name = test_blockarg;
common = tests/test_blockarg.c;
};
module = {
name = xzio;
common = io/xzio.c;
common = lib/xzembed/xz_dec_bcj.c;
common = lib/xzembed/xz_dec_lzma2.c;
common = lib/xzembed/xz_dec_stream.c;
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed';
};
module = {
name = testload;
common = commands/testload.c;
>>>>>>> MERGE-SOURCE
};

View File

@ -185,7 +185,7 @@ real_code_2:
call LOCAL(move_memory)
/* Check for multiboot signature. */
cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END)
cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_I386_PC_MULTIBOOT_SIGNATURE)
jz 1f
movl (ramdisk_image - start), %esi

View File

@ -55,12 +55,12 @@ struct grub_ohci_td
grub_uint32_t next_td; /* LittleEndian physical address */
grub_uint32_t buffer_end; /* LittleEndian physical address */
/* next values are not for OHCI HW */
volatile struct grub_ohci_td *link_td; /* pointer to next free/chained TD
* pointer as uint32 */
grub_uint32_t prev_td_phys; /* we need it to find previous TD
* physical address in CPU endian */
grub_uint32_t link_td; /* pointer to next free/chained TD
* pointer as uint32 */
grub_uint32_t tr_index; /* index of TD in transfer */
grub_uint8_t pad[4]; /* padding to 32 bytes */
grub_uint8_t pad[8 - sizeof (volatile struct grub_ohci_td *)]; /* padding to 32 bytes */
} __attribute__((packed));
/* OHCI Endpoint Descriptor. */
@ -334,7 +334,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
/* Preset free TDs chain in TDs */
grub_memset ((void*)o->td, 0, sizeof(struct grub_ohci_td) * GRUB_OHCI_TDS);
for (j=0; j < (GRUB_OHCI_TDS-1); j++)
o->td[j].link_td = (grub_uint32_t)&o->td[j+1];
o->td[j].link_td = &o->td[j+1];
grub_dprintf ("ohci", "TDs: chunk=%p, virt=%p, phys=0x%02x\n",
o->td_chunk, o->td, o->td_addr);
@ -561,7 +561,7 @@ static void
grub_ohci_free_td (struct grub_ohci *o, grub_ohci_td_t td)
{
grub_memset ( (void*)td, 0, sizeof(struct grub_ohci_td) );
td->link_td = (grub_uint32_t) o->td_free; /* Cahin new free TD & rest */
td->link_td = o->td_free; /* Cahin new free TD & rest */
o->td_free = td; /* Change address of first free TD */
}
@ -604,8 +604,8 @@ grub_ohci_transaction (grub_ohci_td_t td,
grub_uint32_t buffer;
grub_uint32_t buffer_end;
grub_dprintf ("ohci", "OHCI transaction td=%p type=%d, toggle=%d, size=%d\n",
td, type, toggle, size);
grub_dprintf ("ohci", "OHCI transaction td=%p type=%d, toggle=%d, size=%lu\n",
td, type, toggle, (unsigned long) size);
switch (type)
{
@ -781,7 +781,7 @@ grub_ohci_transfer (grub_usb_controller_t dev,
}
/* Chain TDs */
td_current_virt->link_td = (grub_uint32_t) td_next_virt;
td_current_virt->link_td = td_next_virt;
td_current_virt->next_td = grub_cpu_to_le32 (
grub_ohci_td_virt2phys (o,
td_next_virt) );
@ -1406,6 +1406,8 @@ static struct grub_usb_controller_dev usb_controller =
GRUB_MOD_INIT(ohci)
{
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
grub_ohci_inithw ();
grub_usb_controller_dev_register (&usb_controller);
grub_loader_register_preboot_hook (grub_ohci_fini_hw, grub_ohci_restore_hw,

View File

@ -228,7 +228,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
/* Link all Transfer Descriptors in a list of available Transfer
Descriptors. */
for (i = 0; i < 256; i++)
u->td[i].linkptr = (grub_uint32_t) &u->td[i + 1];
u->td[i].linkptr = (grub_uint32_t) (grub_addr_t) &u->td[i + 1];
u->td[255 - 1].linkptr = 0;
u->tdfree = u->td;
@ -238,20 +238,20 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
/* Setup the frame list pointers. Since no isochronous transfers
are and will be supported, they all point to the (same!) queue
head. */
fp = (grub_uint32_t) u->qh & (~15);
fp = (grub_uint32_t) (grub_addr_t) u->qh & (~15);
/* Mark this as a queue head. */
fp |= 2;
for (i = 0; i < 1024; i++)
u->framelist[i] = fp;
/* Program the framelist address into the UHCI controller. */
grub_uhci_writereg32 (u, GRUB_UHCI_REG_FLBASEADD,
(grub_uint32_t) u->framelist);
(grub_uint32_t) (grub_addr_t) u->framelist);
/* Make the Queue Heads point to each other. */
for (i = 0; i < 256; i++)
{
/* Point to the next QH. */
u->qh[i].linkptr = (grub_uint32_t) (&u->qh[i + 1]) & (~15);
u->qh[i].linkptr = (grub_uint32_t) (grub_addr_t) (&u->qh[i + 1]) & (~15);
/* This is a QH. */
u->qh[i].linkptr |= GRUB_UHCI_LINK_QUEUE_HEAD;
@ -319,7 +319,7 @@ grub_alloc_td (struct grub_uhci *u)
return NULL;
ret = u->tdfree;
u->tdfree = (grub_uhci_td_t) u->tdfree->linkptr;
u->tdfree = (grub_uhci_td_t) (grub_addr_t) u->tdfree->linkptr;
return ret;
}
@ -327,7 +327,7 @@ grub_alloc_td (struct grub_uhci *u)
static void
grub_free_td (struct grub_uhci *u, grub_uhci_td_t td)
{
td->linkptr = (grub_uint32_t) u->tdfree;
td->linkptr = (grub_uint32_t) (grub_addr_t) u->tdfree;
u->tdfree = td;
}
@ -352,7 +352,7 @@ grub_free_queue (struct grub_uhci *u, grub_uhci_td_t td,
/* Unlink the queue. */
tdprev = td;
td = (grub_uhci_td_t) td->linkptr2;
td = (grub_uhci_td_t) (grub_addr_t) td->linkptr2;
/* Free the TD. */
grub_free_td (u, tdprev);
@ -413,8 +413,8 @@ grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
}
grub_dprintf ("uhci",
"transaction: endp=%d, type=%d, addr=%d, toggle=%d, size=%d data=0x%x td=%p\n",
endp, type, addr, toggle, size, data, td);
"transaction: endp=%d, type=%d, addr=%d, toggle=%d, size=%lu data=0x%x td=%p\n",
endp, type, addr, toggle, (unsigned long) size, data, td);
/* Don't point to any TD, just terminate. */
td->linkptr = 1;
@ -484,8 +484,8 @@ grub_uhci_transfer (grub_usb_controller_t dev,
td_first = td;
else
{
td_prev->linkptr2 = (grub_uint32_t) td;
td_prev->linkptr = (grub_uint32_t) td;
td_prev->linkptr2 = (grub_uint32_t) (grub_addr_t) td;
td_prev->linkptr = (grub_uint32_t) (grub_addr_t) td;
td_prev->linkptr |= 4;
}
td_prev = td;
@ -497,7 +497,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
/* Link it into the queue and terminate. Now the transaction can
take place. */
qh->elinkptr = (grub_uint32_t) td_first;
qh->elinkptr = (grub_uint32_t) (grub_addr_t) td_first;
grub_dprintf ("uhci", "initiate transaction\n");
@ -508,7 +508,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
{
grub_uhci_td_t errtd;
errtd = (grub_uhci_td_t) (qh->elinkptr & ~0x0f);
errtd = (grub_uhci_td_t) (grub_addr_t) (qh->elinkptr & ~0x0f);
grub_dprintf ("uhci", ">t status=0x%02x data=0x%02x td=%p\n",
errtd->ctrl_status, errtd->buffer & (~15), errtd);

View File

@ -54,8 +54,8 @@ grub_usb_control_msg (grub_usb_device_t dev,
grub_memcpy ((char *) data, data_in, size);
grub_dprintf ("usb",
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%d\n",
reqtype, request, value, index, size);
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n",
reqtype, request, value, index, (unsigned long)size);
/* Create a transfer. */
transfer = grub_malloc (sizeof (*transfer));
@ -179,7 +179,8 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
struct grub_pci_dma_chunk *data_chunk;
grub_size_t size = size0;
grub_dprintf ("usb", "bulk: size=0x%02x type=%d\n", size, type);
grub_dprintf ("usb", "bulk: size=0x%02lx type=%d\n", (unsigned long) size,
type);
/* FIXME: avoid allocation any kind of buffer in a first place. */
data_chunk = grub_memalign_dma32 (128, size);

View File

@ -23,7 +23,6 @@
#include <grub/disk.h>
#include <grub/term.h>
#include <grub/misc.h>
#include <grub/gzio.h>
#include <grub/acpi.h>
#include <grub/mm.h>
#include <grub/machine/memory.h>
@ -458,10 +457,9 @@ free_tables (void)
}
static grub_err_t
grub_cmd_acpi (struct grub_extcmd *cmd,
int argc, char **args)
grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
struct grub_acpi_rsdp_v10 *rsdp;
struct efiemu_acpi_table *cur, *t;
grub_err_t err;
@ -629,7 +627,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
grub_size_t size;
char *buf;
file = grub_gzfile_open (args[i], 1);
file = grub_file_open (args[i]);
if (! file)
{
free_tables ();

View File

@ -82,6 +82,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
grub_file_filter_disable_compression ();
file = grub_file_open (args[0]);
if (! file)
return grub_errno;

View File

@ -22,7 +22,6 @@
#include <grub/disk.h>
#include <grub/term.h>
#include <grub/misc.h>
#include <grub/gzio.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
@ -33,9 +32,9 @@ static const struct grub_arg_option options[] =
};
static grub_err_t
grub_cmd_cat (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
int dos = 0;
grub_file_t file;
char buf[GRUB_DISK_SECTOR_SIZE];
@ -48,7 +47,7 @@ grub_cmd_cat (grub_extcmd_t cmd, int argc, char **args)
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
file = grub_gzfile_open (args[0], 1);
file = grub_file_open (args[0]);
if (! file)
return grub_errno;

View File

@ -21,7 +21,6 @@
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/gzio.h>
#include <grub/command.h>
#include <grub/i18n.h>
@ -44,8 +43,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
grub_printf ("Compare file `%s' with `%s':\n", args[0],
args[1]);
file1 = grub_gzfile_open (args[0], 1);
file2 = grub_gzfile_open (args[1], 1);
file1 = grub_file_open (args[0]);
file2 = grub_file_open (args[1]);
if (! file1 || ! file2)
goto cleanup;

View File

@ -38,6 +38,7 @@ grub_cmd_crc (grub_command_t cmd __attribute__ ((unused)),
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
grub_file_filter_disable_compression ();
file = grub_file_open (args[0]);
if (! file)
return 0;

View File

@ -30,9 +30,9 @@ static const struct grub_arg_option options[] =
};
static grub_err_t
grub_cmd_echo (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
int newline = 1;
int i;

View File

@ -21,46 +21,55 @@
#include <grub/list.h>
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/script_sh.h>
static grub_err_t
grub_extcmd_dispatcher (struct grub_command *cmd,
int argc, char **args)
grub_err_t
grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
struct grub_script *script)
{
int new_argc;
char **new_args;
struct grub_arg_option *parser;
struct grub_arg_list *state;
int maxargs = 0;
struct grub_extcmd_context context;
grub_err_t ret;
grub_extcmd_t ext;
grub_extcmd_t ext = cmd->data;
ext = cmd->data;
parser = (struct grub_arg_option *) ext->options;
while (parser && (parser++)->doc)
maxargs++;
context.state = 0;
context.extcmd = ext;
context.script = script;
/* Set up the option state. */
state = grub_zalloc (sizeof (struct grub_arg_list) * maxargs);
if (! ext->options)
{
ret = (ext->func) (&context, argc, args);
return ret;
}
state = grub_arg_list_alloc (ext, argc, args);
if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
{
ext->state = state;
ret = (ext->func) (ext, new_argc, new_args);
context.state = state;
ret = (ext->func) (&context, new_argc, new_args);
grub_free (new_args);
grub_free (state);
return ret;
}
else
ret = grub_errno;
grub_free (state);
return grub_errno;
}
return ret;
static grub_err_t
grub_extcmd_dispatch (struct grub_command *cmd, int argc, char **args)
{
return grub_extcmd_dispatcher (cmd, argc, args, 0);
}
grub_extcmd_t
grub_register_extcmd (const char *name, grub_extcmd_func_t func,
unsigned flags, const char *summary,
const char *description,
const struct grub_arg_option *parser)
grub_register_extcmd_prio (const char *name, grub_extcmd_func_t func,
unsigned flags, const char *summary,
const char *description,
const struct grub_arg_option *parser,
int prio)
{
grub_extcmd_t ext;
grub_command_t cmd;
@ -69,8 +78,8 @@ grub_register_extcmd (const char *name, grub_extcmd_func_t func,
if (! ext)
return 0;
cmd = grub_register_command_prio (name, grub_extcmd_dispatcher,
summary, description, 1);
cmd = grub_register_command_prio (name, grub_extcmd_dispatch,
summary, description, prio);
if (! cmd)
{
grub_free (ext);
@ -88,6 +97,16 @@ grub_register_extcmd (const char *name, grub_extcmd_func_t func,
return ext;
}
grub_extcmd_t
grub_register_extcmd (const char *name, grub_extcmd_func_t func,
unsigned flags, const char *summary,
const char *description,
const struct grub_arg_option *parser)
{
return grub_register_extcmd_prio (name, func, flags,
summary, description, parser, 1);
}
void
grub_unregister_extcmd (grub_extcmd_t ext)
{

View File

@ -32,6 +32,7 @@ static const struct grub_arg_option options[] = {
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
ARG_TYPE_STRING},
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
{"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -80,7 +81,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
static grub_err_t
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
const char *prefix, int keep)
const char *prefix, int keep, int uncompress)
{
grub_file_t hashlist, file;
char *buf = NULL;
@ -115,11 +116,17 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
filename = grub_xasprintf ("%s/%s", prefix, p);
if (!filename)
return grub_errno;
if (!uncompress)
grub_file_filter_disable_compression ();
file = grub_file_open (filename);
grub_free (filename);
}
else
file = grub_file_open (p);
{
if (!uncompress)
grub_file_filter_disable_compression ();
file = grub_file_open (p);
}
if (!file)
{
grub_file_close (hashlist);
@ -165,19 +172,20 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
}
static grub_err_t
grub_cmd_hashsum (struct grub_extcmd *cmd,
grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
const char *hashname = NULL;
const char *prefix = NULL;
const gcry_md_spec_t *hash;
unsigned i;
int keep = state[3].set;
int uncompress = state[4].set;
unsigned unread = 0;
for (i = 0; i < ARRAY_SIZE (aliases); i++)
if (grub_strcmp (cmd->cmd->name, aliases[i].name) == 0)
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
hashname = aliases[i].hashname;
if (state[0].set)
hashname = state[0].arg;
@ -197,7 +205,7 @@ grub_cmd_hashsum (struct grub_extcmd *cmd,
if (argc != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"--check is incompatible with file list");
return check_list (hash, state[1].arg, prefix, keep);
return check_list (hash, state[1].arg, prefix, keep, uncompress);
}
for (i = 0; i < (unsigned) argc; i++)
@ -206,6 +214,8 @@ grub_cmd_hashsum (struct grub_extcmd *cmd,
grub_file_t file;
grub_err_t err;
unsigned j;
if (!uncompress)
grub_file_filter_disable_compression ();
file = grub_file_open (args[i]);
if (!file)
{

View File

@ -270,9 +270,9 @@ static int get_int_arg (const struct grub_arg_list *state)
}
static grub_err_t
grub_cmd_hdparm (grub_extcmd_t cmd, int argc, char **args) // state????
grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) // state????
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
/* Check command line. */
if (argc != 1)

View File

@ -27,7 +27,7 @@
#include <grub/charset.h>
static grub_err_t
grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
char **args)
{
int cnt = 0;
@ -112,7 +112,8 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
if (cnt++ > 0)
grub_printf ("\n\n");
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
if ((cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) &&
! (cmd->flags & GRUB_COMMAND_FLAG_DYNCMD))
grub_arg_show_help ((grub_extcmd_t) cmd->data);
else
grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary),

View File

@ -21,7 +21,6 @@
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/misc.h>
#include <grub/gzio.h>
#include <grub/lib/hexdump.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
@ -34,9 +33,9 @@ static const struct grub_arg_option options[] = {
};
static grub_err_t
grub_cmd_hexdump (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
char buf[GRUB_DISK_SECTOR_SIZE * 4];
grub_ssize_t size, length;
grub_disk_addr_t skip;
@ -89,7 +88,7 @@ grub_cmd_hexdump (grub_extcmd_t cmd, int argc, char **args)
{
grub_file_t file;
file = grub_gzfile_open (args[0], 1);
file = grub_file_open (args[0]);
if (! file)
return 0;

View File

@ -43,7 +43,7 @@ static const struct grub_arg_option options[] =
unsigned char grub_cpuid_has_longmode = 0;
static grub_err_t
grub_cmd_cpuid (grub_extcmd_t cmd __attribute__ ((unused)),
grub_cmd_cpuid (grub_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{

View File

@ -196,13 +196,13 @@ list_mappings (void)
}
static grub_err_t
grub_cmd_drivemap (struct grub_extcmd *cmd, int argc, char **args)
grub_cmd_drivemap (struct grub_extcmd_context *ctxt, int argc, char **args)
{
if (cmd->state[OPTIDX_LIST].set)
if (ctxt->state[OPTIDX_LIST].set)
{
return list_mappings ();
}
else if (cmd->state[OPTIDX_RESET].set)
else if (ctxt->state[OPTIDX_RESET].set)
{
/* Reset: just delete all mappings, freeing their memory. */
drivemap_node_t *curnode = map_head;
@ -216,7 +216,7 @@ grub_cmd_drivemap (struct grub_extcmd *cmd, int argc, char **args)
map_head = 0;
return GRUB_ERR_NONE;
}
else if (!cmd->state[OPTIDX_SWAP].set && argc == 0)
else if (!ctxt->state[OPTIDX_SWAP].set && argc == 0)
{
/* No arguments */
return list_mappings ();
@ -248,11 +248,11 @@ grub_cmd_drivemap (struct grub_extcmd *cmd, int argc, char **args)
}
/* Set the mapping for the disk (overwrites any existing mapping). */
grub_dprintf ("drivemap", "%s %s (%02x) = %s (%02x)\n",
cmd->state[OPTIDX_SWAP].set ? "Swapping" : "Mapping",
ctxt->state[OPTIDX_SWAP].set ? "Swapping" : "Mapping",
args[1], mapto, args[0], mapfrom);
err = drivemap_set (mapto, mapfrom);
/* If -s, perform the reverse mapping too (only if the first was OK). */
if (cmd->state[OPTIDX_SWAP].set && err == GRUB_ERR_NONE)
if (ctxt->state[OPTIDX_SWAP].set && err == GRUB_ERR_NONE)
err = drivemap_set (mapfrom, mapto);
return err;
}

View File

@ -21,6 +21,7 @@
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/machine/int.h>
static const struct grub_arg_option options[] =
{
@ -28,13 +29,76 @@ static const struct grub_arg_option options[] =
{0, 0, 0, 0, 0, 0}
};
static inline void __attribute__ ((noreturn))
stop (void)
{
while (1)
{
asm volatile ("hlt");
}
}
/*
* Halt the system, using APM if possible. If NO_APM is true, don't use
* APM even if it is available.
*/
void
grub_halt (int no_apm)
{
struct grub_bios_int_registers regs;
if (no_apm)
stop ();
/* detect APM */
regs.eax = 0x5300;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* disconnect APM first */
regs.eax = 0x5304;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
/* connect APM */
regs.eax = 0x5301;
regs.ebx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
regs.eax = 0x530E;
regs.ebx = 0;
regs.ecx = 0x0101;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
stop ();
/* set the power state to off */
regs.eax = 0x5307;
regs.ebx = 1;
regs.ecx = 3;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
/* shouldn't reach here */
stop ();
}
static grub_err_t
grub_cmd_halt (grub_extcmd_t cmd,
grub_cmd_halt (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
int no_apm = 0;
if (state[0].set)
no_apm = 1;

View File

@ -284,9 +284,9 @@ grub_sendkey_preboot (int noret __attribute__ ((unused)))
}
static grub_err_t
grub_cmd_sendkey (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
auto int find_key_code (char *key);
auto int find_ascii_code (char *key);

View File

@ -36,7 +36,7 @@ static const struct grub_arg_option options[] =
static grub_err_t
grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
{
grub_target_addr_t addr;
grub_uint32_t value = 0;
@ -46,7 +46,7 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
addr = grub_strtoul (argv[0], 0, 0);
switch (cmd->cmd->name[sizeof ("in") - 1])
switch (ctxt->extcmd->cmd->name[sizeof ("in") - 1])
{
case 'l':
value = grub_inl (addr);
@ -61,10 +61,10 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
break;
}
if (cmd->state[0].set)
if (ctxt->state[0].set)
{
grub_snprintf (buf, sizeof (buf), "%x", value);
grub_env_set (cmd->state[0].arg, buf);
grub_env_set (ctxt->state[0].arg, buf);
}
else
grub_printf ("0x%x\n", value);

View File

@ -34,11 +34,11 @@ static const struct grub_arg_option options[] =
#define grub_cur_term_input grub_term_get_current_input ()
static grub_err_t
grub_cmd_keystatus (grub_extcmd_t cmd,
grub_cmd_keystatus (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
int expect_mods = 0;
int mods;

View File

@ -56,6 +56,7 @@ open_envblk_file (char *filename)
grub_strcpy (filename, prefix);
filename[len] = '/';
grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
grub_file_filter_disable_compression ();
file = grub_file_open (filename);
grub_free (filename);
return file;
@ -67,6 +68,7 @@ open_envblk_file (char *filename)
}
}
grub_file_filter_disable_compression ();
return grub_file_open (filename);
}
@ -111,11 +113,11 @@ read_envblk_file (grub_file_t file)
}
static grub_err_t
grub_cmd_load_env (grub_extcmd_t cmd,
grub_cmd_load_env (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
grub_envblk_t envblk;
@ -143,11 +145,11 @@ grub_cmd_load_env (grub_extcmd_t cmd,
}
static grub_err_t
grub_cmd_list_env (grub_extcmd_t cmd,
grub_cmd_list_env (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
grub_envblk_t envblk;
@ -280,9 +282,9 @@ write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
}
static grub_err_t
grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
grub_envblk_t envblk;
struct blocklist *head = 0;

View File

@ -105,6 +105,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
/* XXX: For ext2fs symlinks are detected as files while they
should be reported as directories. */
grub_file_filter_disable_compression ();
file = grub_file_open (pathname);
if (! file)
{
@ -211,6 +212,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
struct grub_dirhook_info info;
grub_errno = 0;
grub_file_filter_disable_compression ();
file = grub_file_open (dirname);
if (! file)
goto fail;
@ -248,9 +250,9 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
}
static grub_err_t
grub_cmd_ls (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_ls (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
if (argc == 0)
grub_ls_list_devices (state[0].set);

View File

@ -211,11 +211,11 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
}
static grub_err_t
grub_cmd_lspci (grub_extcmd_t cmd,
grub_cmd_lspci (grub_extcmd_context_t ctxt,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
iospace = cmd->state[0].set;
iospace = ctxt->state[0].set;
grub_pci_iterate (grub_lspci_iter);
return GRUB_ERR_NONE;
}

View File

@ -35,7 +35,7 @@ static const struct grub_arg_option options[] =
static grub_err_t
grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
{
grub_target_addr_t addr;
grub_uint32_t value = 0;
@ -45,7 +45,7 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments");
addr = grub_strtoul (argv[0], 0, 0);
switch (cmd->cmd->name[sizeof ("read_") - 1])
switch (ctxt->extcmd->cmd->name[sizeof ("read_") - 1])
{
case 'd':
value = *((volatile grub_uint32_t *) addr);
@ -60,10 +60,10 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
break;
}
if (cmd->state[0].set)
if (ctxt->state[0].set)
{
grub_snprintf (buf, sizeof (buf), "%x", value);
grub_env_set (cmd->state[0].arg, buf);
grub_env_set (ctxt->state[0].arg, buf);
}
else
grub_printf ("0x%x\n", value);

View File

@ -0,0 +1,285 @@
/* menuentry.c - menuentry command */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/normal.h>
static const struct grub_arg_option options[] =
{
{"class", 1, GRUB_ARG_OPTION_REPEATABLE,
N_("Menu entry type."), "STRING", ARG_TYPE_STRING},
{"users", 2, 0,
N_("Users allowed to boot this entry."), "USERNAME", ARG_TYPE_STRING},
{"hotkey", 3, 0,
N_("Keyboard key for this entry."), "KEY", ARG_TYPE_STRING},
{"source", 4, 0,
N_("Menu entry definition as a string."), "STRING", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
static struct
{
char *name;
int key;
} hotkey_aliases[] =
{
{"backspace", '\b'},
{"tab", '\t'},
{"delete", GRUB_TERM_DC}
};
/* Add a menu entry to the current menu context (as given by the environment
variable data slot `menu'). As the configuration file is read, the script
parser calls this when a menu entry is to be created. */
static grub_err_t
append_menu_entry (int argc, const char **args, char **classes,
const char *users, const char *hotkey,
const char *prefix, const char *sourcecode)
{
unsigned i;
int menu_hotkey = 0;
char **menu_args = NULL;
char *menu_users = NULL;
char *menu_title = NULL;
char *menu_sourcecode = NULL;
struct grub_menu_entry_class *menu_classes = NULL;
grub_menu_t menu;
grub_menu_entry_t *last;
menu = grub_env_get_menu ();
if (! menu)
return grub_error (GRUB_ERR_MENU, "no menu context");
last = &menu->entry_list;
menu_sourcecode = grub_xasprintf ("%s%s", prefix ?: "", sourcecode);
if (! menu_sourcecode)
return grub_errno;
if (classes)
{
for (i = 0; classes[i]; i++); /* count # of menuentry classes */
menu_classes = grub_zalloc (sizeof (struct grub_menu_entry_class) * i);
if (! menu_classes)
goto fail;
for (i = 0; classes[i]; i++)
{
menu_classes[i].name = grub_strdup (classes[i]);
if (! menu_classes[i].name)
goto fail;
menu_classes[i].next = classes[i + 1] ? &menu_classes[i + 1] : NULL;
}
}
if (users)
{
menu_users = grub_strdup (users);
if (! menu_users)
goto fail;
}
if (hotkey)
{
for (i = 0; i < ARRAY_SIZE (hotkey_aliases); i++)
if (grub_strcmp (hotkey, hotkey_aliases[i].name) == 0)
{
menu_hotkey = hotkey_aliases[i].key;
break;
}
if (i == ARRAY_SIZE (hotkey_aliases))
menu_hotkey = hotkey[0];
}
if (! argc)
{
grub_error (GRUB_ERR_MENU, "menuentry is missing title");
goto fail;
}
menu_title = grub_strdup (args[0]);
if (! menu_title)
goto fail;
/* Save argc, args to pass as parameters to block arg later. */
menu_args = grub_malloc (sizeof (char*) * (argc + 1));
if (! menu_args)
goto fail;
for (i = 0; args[i]; i++)
{
menu_args[i] = grub_strdup (args[i]);
if (! menu_args[i])
goto fail;
}
menu_args[argc] = NULL;
/* Add the menu entry at the end of the list. */
while (*last)
last = &(*last)->next;
*last = grub_zalloc (sizeof (**last));
if (! *last)
goto fail;
(*last)->title = menu_title;
(*last)->hotkey = menu_hotkey;
(*last)->classes = menu_classes;
if (menu_users)
(*last)->restricted = 1;
(*last)->users = menu_users;
(*last)->argc = argc;
(*last)->args = menu_args;
(*last)->sourcecode = menu_sourcecode;
menu->size++;
return GRUB_ERR_NONE;
fail:
grub_free (menu_sourcecode);
for (i = 0; menu_classes && menu_classes[i].name; i++)
grub_free (menu_classes[i].name);
grub_free (menu_classes);
for (i = 0; menu_args && menu_args[i]; i++)
grub_free (menu_args[i]);
grub_free (menu_args);
grub_free (menu_users);
grub_free (menu_title);
return grub_errno;
}
static char *
setparams_prefix (int argc, char **args)
{
int i;
int j;
char *p;
char *result;
grub_size_t len = 10;
static const char *escape_characters = "\"\\";
auto char *strescpy (char *, const char *, const char *);
char * strescpy (char *d, const char *s, const char *escapes)
{
while (*s)
{
if (grub_strchr (escapes, *s))
*d++ = '\\';
*d++ = *s++;
}
*d = '\0';
return d;
}
/* Count resulting string length */
for (i = 0; i < argc; i++)
{
len += 3; /* 3 = 1 space + 2 quotes */
p = args[i];
while (*p)
len += grub_strchr (escape_characters, *p++) ? 2 : 1;
}
result = grub_malloc (len + 2);
if (! result)
return 0;
grub_strcpy (result, "setparams");
i = 9;
for (j = 0; j < argc; j++)
{
result[i++] = ' ';
result[i++] = '"';
i = strescpy (result + i, args[j], escape_characters) - result;
result[i++] = '"';
}
result[i++] = '\n';
result[i] = '\0';
return result;
}
static grub_err_t
grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
{
char ch;
char *src;
char *prefix;
unsigned len;
grub_err_t r;
if (! argc)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments");
if (ctxt->state[3].set && ctxt->script)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple menuentry definitions");
if (! ctxt->state[3].set && ! ctxt->script)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition");
if (! ctxt->script)
return append_menu_entry (argc, (const char **) args,
ctxt->state[0].args, ctxt->state[1].arg,
ctxt->state[2].arg, 0, ctxt->state[3].arg);
src = args[argc - 1];
args[argc - 1] = NULL;
len = grub_strlen(src);
ch = src[len - 1];
src[len - 1] = '\0';
prefix = setparams_prefix (argc - 1, args);
if (! prefix)
return grub_errno;
r = append_menu_entry (argc - 1, (const char **) args,
ctxt->state[0].args, ctxt->state[1].arg,
ctxt->state[2].arg, prefix, src + 1);
src[len - 1] = ch;
args[argc - 1] = src;
grub_free (prefix);
return r;
}
static grub_extcmd_t cmd;
void
grub_menu_init (void)
{
cmd = grub_register_extcmd ("menuentry", grub_cmd_menuentry,
GRUB_COMMAND_FLAG_BOTH | GRUB_COMMAND_FLAG_BLOCKS,
N_("BLOCK"), N_("Define a menuentry."), options);
}
void
grub_menu_fini (void)
{
grub_unregister_extcmd (cmd);
}

View File

@ -142,112 +142,6 @@ grub_mini_cmd_root (struct grub_command *cmd __attribute__ ((unused)),
return 0;
}
#if 0
static void
grub_rescue_cmd_testload (int argc, char *argv[])
{
grub_file_t file;
char *buf;
grub_ssize_t size;
grub_ssize_t pos;
auto void read_func (unsigned long sector, unsigned offset, unsigned len);
void read_func (unsigned long sector __attribute__ ((unused)),
unsigned offset __attribute__ ((unused)),
unsigned len __attribute__ ((unused)))
{
grub_putchar ('.');
grub_refresh ();
}
if (argc < 1)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
return;
}
file = grub_file_open (argv[0]);
if (! file)
return;
size = grub_file_size (file) & ~(GRUB_DISK_SECTOR_SIZE - 1);
if (size == 0)
{
grub_file_close (file);
return;
}
buf = grub_malloc (size);
if (! buf)
goto fail;
grub_printf ("Reading %s sequentially", argv[0]);
file->read_hook = read_func;
if (grub_file_read (file, buf, size) != size)
goto fail;
grub_printf (" Done.\n");
/* Read sequentially again. */
grub_printf ("Reading %s sequentially again", argv[0]);
if (grub_file_seek (file, 0) < 0)
goto fail;
for (pos = 0; pos < size; pos += GRUB_DISK_SECTOR_SIZE)
{
char sector[GRUB_DISK_SECTOR_SIZE];
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
goto fail;
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
{
grub_printf ("\nDiffers in %d\n", pos);
goto fail;
}
}
grub_printf (" Done.\n");
/* Read backwards and compare. */
grub_printf ("Reading %s backwards", argv[0]);
pos = size;
while (pos > 0)
{
char sector[GRUB_DISK_SECTOR_SIZE];
pos -= GRUB_DISK_SECTOR_SIZE;
if (grub_file_seek (file, pos) < 0)
goto fail;
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
goto fail;
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
{
int i;
grub_printf ("\nDiffers in %d\n", pos);
for (i = 0; i < GRUB_DISK_SECTOR_SIZE; i++)
grub_putchar (buf[pos + i]);
if (i)
grub_refresh ();
goto fail;
}
}
grub_printf (" Done.\n");
fail:
grub_file_close (file);
grub_free (buf);
}
#endif
/* dump ADDRESS [SIZE] */
static grub_err_t
grub_mini_cmd_dump (struct grub_command *cmd __attribute__ ((unused)),

View File

@ -45,9 +45,9 @@ static const struct grub_arg_option options[] =
};
static grub_err_t
grub_cmd_probe (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
grub_device_t dev;
grub_fs_t fs;
char *ptr;

View File

@ -20,37 +20,104 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/command.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/script_sh.h>
#include <regex.h>
static const struct grub_arg_option options[] =
{
{ "set", 's', GRUB_ARG_OPTION_REPEATABLE,
N_("Variable names to update with matches."),
N_("[NUMBER:]VARNAME"), ARG_TYPE_STRING },
{ 0, 0, 0, 0, 0, 0 }
};
static grub_err_t
grub_cmd_regexp (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
set_matches (char **varnames, char *str, grub_size_t nmatches,
regmatch_t *matches)
{
int i;
char ch;
char *p;
char *q;
grub_err_t err;
unsigned long j;
auto void setvar (char *v, regmatch_t *m);
void setvar (char *v, regmatch_t *m)
{
ch = str[m->rm_eo];
str[m->rm_eo] = '\0';
err = grub_env_set (v, str + m->rm_so);
str[m->rm_eo] = ch;
}
for (i = 0; varnames && varnames[i]; i++)
{
if (! (p = grub_strchr (varnames[i], ':')))
{
/* varname w/o index defaults to 1 */
if (nmatches < 2 || matches[1].rm_so == -1)
grub_env_unset (varnames[i]);
else
setvar (varnames[i], &matches[1]);
}
else
{
j = grub_strtoul (varnames[i], &q, 10);
if (q != p)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"invalid variable name format %s", varnames[i]);
if (nmatches <= j || matches[j].rm_so == -1)
grub_env_unset (p + 1);
else
setvar (p + 1, &matches[j]);
}
if (err != GRUB_ERR_NONE)
return err;
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args)
{
int argn = 0;
int matches = 0;
regex_t regex;
int ret;
grub_size_t s;
char *comperr;
grub_err_t err;
regmatch_t *matches = 0;
if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "2 arguments expected");
ret = regcomp (&regex, args[0], RE_SYNTAX_GNU_AWK);
ret = regcomp (&regex, args[0], REG_EXTENDED);
if (ret)
goto fail;
ret = regexec (&regex, args[1], 0, 0, 0);
matches = grub_zalloc (sizeof (*matches) * (regex.re_nsub + 1));
if (! matches)
goto fail;
ret = regexec (&regex, args[1], regex.re_nsub + 1, matches, 0);
if (!ret)
{
err = set_matches (ctxt->state[0].args, args[1],
regex.re_nsub + 1, matches);
regfree (&regex);
return GRUB_ERR_NONE;
grub_free (matches);
return err;
}
fail:
grub_free (matches);
s = regerror (ret, &regex, 0, 0);
comperr = grub_malloc (s);
if (!comperr)
@ -65,16 +132,20 @@ grub_cmd_regexp (grub_command_t cmd __attribute__ ((unused)),
return err;
}
static grub_command_t cmd;
static grub_extcmd_t cmd;
GRUB_MOD_INIT(regexp)
{
cmd = grub_register_command ("regexp", grub_cmd_regexp,
N_("REGEXP STRING"),
N_("Test if REGEXP matches STRING."));
cmd = grub_register_extcmd ("regexp", grub_cmd_regexp,
GRUB_COMMAND_FLAG_BOTH, N_("REGEXP STRING"),
N_("Test if REGEXP matches STRING."), options);
/* Setup GRUB script wildcard translator. */
grub_wildcard_translator = &grub_filename_translator;
}
GRUB_MOD_FINI(regexp)
{
grub_unregister_command (cmd);
grub_unregister_extcmd (cmd);
grub_wildcard_translator = 0;
}

View File

@ -54,6 +54,7 @@ FUNC_NAME (const char *key, const char *var, int no_floppy)
if (! buf)
return 1;
grub_file_filter_disable_compression ();
file = grub_file_open (buf);
if (file)
{

View File

@ -50,9 +50,9 @@ enum options
};
static grub_err_t
grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
const char *var = 0;
if (argc == 0)

View File

@ -155,7 +155,7 @@ grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
}
static grub_err_t
grub_cmd_setpci (grub_extcmd_t cmd, int argc, char **argv)
grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
{
const char *ptr;
unsigned i;
@ -163,14 +163,14 @@ grub_cmd_setpci (grub_extcmd_t cmd, int argc, char **argv)
pciid_check_value = 0;
pciid_check_mask = 0;
if (cmd->state[0].set)
if (ctxt->state[0].set)
{
ptr = cmd->state[0].arg;
ptr = ctxt->state[0].arg;
pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff);
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
grub_errno = GRUB_ERR_NONE;
ptr = cmd->state[0].arg;
ptr = ctxt->state[0].arg;
}
else
pciid_check_mask |= 0xffff;
@ -191,11 +191,11 @@ grub_cmd_setpci (grub_extcmd_t cmd, int argc, char **argv)
check_bus = check_device = check_function = 0;
if (cmd->state[1].set)
if (ctxt->state[1].set)
{
const char *optr;
ptr = cmd->state[1].arg;
ptr = ctxt->state[1].arg;
optr = ptr;
bus = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno == GRUB_ERR_BAD_NUMBER)
@ -229,8 +229,8 @@ grub_cmd_setpci (grub_extcmd_t cmd, int argc, char **argv)
}
}
if (cmd->state[2].set)
varname = cmd->state[2].arg;
if (ctxt->state[2].set)
varname = ctxt->state[2].arg;
else
varname = NULL;

View File

@ -60,9 +60,9 @@ grub_interruptible_millisleep (grub_uint32_t ms)
}
static grub_err_t
grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_sleep (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
struct grub_arg_list *state = ctxt->state;
int n;
if (argc != 1)

View File

@ -334,6 +334,7 @@ test_parse (char **args, int *argn, int argc)
if (grub_strcmp (args[*argn], "-s") == 0)
{
grub_file_t file;
grub_file_filter_disable_compression ();
file = grub_file_open (args[*argn + 1]);
update_val (file && (grub_file_size (file) != 0));
if (file)

View File

@ -0,0 +1,155 @@
/* minicmd.c - commands for the rescue mode */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/dl.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/term.h>
#include <grub/loader.h>
#include <grub/command.h>
#include <grub/i18n.h>
static grub_err_t
grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file;
char *buf;
grub_size_t size;
grub_off_t pos;
auto void NESTED_FUNC_ATTR read_func (grub_disk_addr_t sector, unsigned offset, unsigned len);
void NESTED_FUNC_ATTR read_func (grub_disk_addr_t sector __attribute__ ((unused)),
unsigned offset __attribute__ ((unused)),
unsigned len __attribute__ ((unused)))
{
grub_xputs (".");
grub_refresh ();
}
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
file = grub_file_open (argv[0]);
if (! file)
return grub_errno;
size = grub_file_size (file) & ~(GRUB_DISK_SECTOR_SIZE - 1);
if (size == 0)
{
grub_file_close (file);
return GRUB_ERR_NONE;
}
buf = grub_malloc (size);
if (! buf)
goto fail;
grub_printf ("Reading %s sequentially", argv[0]);
file->read_hook = read_func;
if (grub_file_read (file, buf, size) != (grub_ssize_t) size)
goto fail;
grub_printf (" Done.\n");
/* Read sequentially again. */
grub_printf ("Reading %s sequentially again", argv[0]);
grub_file_seek (file, 0);
for (pos = 0; pos < size; pos += GRUB_DISK_SECTOR_SIZE)
{
char sector[GRUB_DISK_SECTOR_SIZE];
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
goto fail;
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
{
grub_printf ("\nDiffers in %lld\n", (unsigned long long) pos);
goto fail;
}
}
grub_printf (" Done.\n");
/* Read backwards and compare. */
grub_printf ("Reading %s backwards", argv[0]);
pos = size;
while (pos > 0)
{
char sector[GRUB_DISK_SECTOR_SIZE];
pos -= GRUB_DISK_SECTOR_SIZE;
grub_file_seek (file, pos);
if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
!= GRUB_DISK_SECTOR_SIZE)
goto fail;
if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
{
int i;
grub_printf ("\nDiffers in %lld\n", (unsigned long long) pos);
for (i = 0; i < GRUB_DISK_SECTOR_SIZE; i++)
{
grub_printf ("%02x ", buf[pos + i]);
if ((i & 15) == 15)
grub_printf ("\n");
}
if (i)
grub_refresh ();
goto fail;
}
}
grub_printf (" Done.\n");
return GRUB_ERR_NONE;
fail:
grub_file_close (file);
grub_free (buf);
if (!grub_errno)
grub_error (GRUB_ERR_IO, "bad read");
return grub_errno;
}
static grub_command_t cmd;
GRUB_MOD_INIT(testload)
{
cmd =
grub_register_command ("testload", grub_cmd_testload,
N_("FILE"),
N_("Load the same file in multiple ways."));
}
GRUB_MOD_FINI(testload)
{
grub_unregister_command (cmd);
}

View File

@ -0,0 +1,494 @@
/* wildcard.c - Wildcard character expansion for GRUB script. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/mm.h>
#include <grub/fs.h>
#include <grub/env.h>
#include <grub/file.h>
#include <grub/device.h>
#include <grub/script_sh.h>
#include <regex.h>
static inline int isregexop (char ch);
static char ** merge (char **lhs, char **rhs);
static char *make_dir (const char *prefix, const char *start, const char *end);
static int make_regex (const char *regex_start, const char *regex_end,
regex_t *regexp);
static void split_path (const char *path, const char **suffix_end, const char **regex_end);
static char ** match_devices (const regex_t *regexp, int noparts);
static char ** match_files (const char *prefix, const char *suffix_start,
const char *suffix_end, const regex_t *regexp);
static char* wildcard_escape (const char *s);
static char* wildcard_unescape (const char *s);
static grub_err_t wildcard_expand (const char *s, char ***strs);
struct grub_script_wildcard_translator grub_filename_translator = {
.expand = wildcard_expand,
.escape = wildcard_escape,
.unescape = wildcard_unescape
};
static char **
merge (char **dest, char **ps)
{
int i;
int j;
char **p;
if (! dest)
return ps;
if (! ps)
return dest;
for (i = 0; dest[i]; i++)
;
for (j = 0; ps[j]; j++)
;
p = grub_realloc (dest, sizeof (char*) * (i + j + 1));
if (! p)
{
grub_free (dest);
grub_free (ps);
return 0;
}
dest = p;
for (j = 0; ps[j]; j++)
dest[i++] = ps[j];
dest[i] = 0;
grub_free (ps);
return dest;
}
static inline int
isregexop (char ch)
{
return grub_strchr ("*.\\", ch) ? 1 : 0;
}
static char *
make_dir (const char *prefix, const char *start, const char *end)
{
char ch;
unsigned i;
unsigned n;
char *result;
i = grub_strlen (prefix);
n = i + end - start;
result = grub_malloc (n + 1);
if (! result)
return 0;
grub_strcpy (result, prefix);
while (start < end && (ch = *start++))
if (ch == '\\' && isregexop (*start))
result[i++] = *start++;
else
result[i++] = ch;
result[i] = '\0';
return result;
}
static int
make_regex (const char *start, const char *end, regex_t *regexp)
{
char ch;
int i = 0;
unsigned len = end - start;
char *buffer = grub_malloc (len * 2 + 2 + 1); /* worst case size. */
if (! buffer)
return 1;
buffer[i++] = '^';
while (start < end)
{
/* XXX Only * expansion for now. */
switch ((ch = *start++))
{
case '\\':
buffer[i++] = ch;
if (*start != '\0')
buffer[i++] = *start++;
break;
case '.':
buffer[i++] = '\\';
buffer[i++] = '.';
break;
case '*':
buffer[i++] = '.';
buffer[i++] = '*';
break;
default:
buffer[i++] = ch;
}
}
buffer[i++] = '$';
buffer[i] = '\0';
if (regcomp (regexp, buffer, RE_SYNTAX_GNU_AWK))
{
grub_free (buffer);
return 1;
}
grub_free (buffer);
return 0;
}
/* Split `str' into two parts: (1) dirname that is regexop free (2)
dirname that has a regexop. */
static void
split_path (const char *str, const char **noregexop, const char **regexop)
{
char ch = 0;
int regex = 0;
const char *end;
const char *split; /* points till the end of dirnaname that doesn't
need expansion. */
split = end = str;
while ((ch = *end))
{
if (ch == '\\' && end[1])
end++;
else if (isregexop (ch))
regex = 1;
else if (ch == '/' && ! regex)
split = end + 1; /* forward to next regexop-free dirname */
else if (ch == '/' && regex)
break; /* stop at the first dirname with a regexop */
end++;
}
*regexop = end;
if (! regex)
*noregexop = end;
else
*noregexop = split;
}
static char **
match_devices (const regex_t *regexp, int noparts)
{
int i;
int ndev;
char **devs;
auto int match (const char *name);
int match (const char *name)
{
char **t;
char *buffer;
/* skip partitions if asked to. */
if (noparts && grub_strchr(name, ','))
return 0;
buffer = grub_xasprintf ("(%s)", name);
if (! buffer)
return 1;
grub_dprintf ("expand", "matching: %s\n", buffer);
if (regexec (regexp, buffer, 0, 0, 0))
{
grub_free (buffer);
return 0;
}
t = grub_realloc (devs, sizeof (char*) * (ndev + 2));
if (! t)
return 1;
devs = t;
devs[ndev++] = buffer;
devs[ndev] = 0;
return 0;
}
ndev = 0;
devs = 0;
if (grub_device_iterate (match))
goto fail;
return devs;
fail:
for (i = 0; devs && devs[i]; i++)
grub_free (devs[i]);
if (devs)
grub_free (devs);
return 0;
}
static char **
match_files (const char *prefix, const char *suffix, const char *end,
const regex_t *regexp)
{
int i;
int error;
char **files;
unsigned nfile;
char *dir;
const char *path;
char *device_name;
grub_fs_t fs;
grub_device_t dev;
auto int match (const char *name, const struct grub_dirhook_info *info);
int match (const char *name, const struct grub_dirhook_info *info)
{
char **t;
char *buffer;
/* skip . and .. names */
if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0)
return 0;
grub_dprintf ("expand", "matching: %s in %s\n", name, dir);
if (regexec (regexp, name, 0, 0, 0))
return 0;
buffer = grub_xasprintf ("%s%s", dir, name);
if (! buffer)
return 1;
t = grub_realloc (files, sizeof (char*) * (nfile + 2));
if (! t)
{
grub_free (buffer);
return 1;
}
files = t;
files[nfile++] = buffer;
files[nfile] = 0;
return 0;
}
nfile = 0;
files = 0;
dev = 0;
device_name = 0;
grub_error_push ();
dir = make_dir (prefix, suffix, end);
if (! dir)
goto fail;
device_name = grub_file_get_device_name (dir);
dev = grub_device_open (device_name);
if (! dev)
goto fail;
fs = grub_fs_probe (dev);
if (! fs)
goto fail;
path = grub_strchr (dir, ')');
if (! path)
goto fail;
path++;
if (fs->dir (dev, path, match))
goto fail;
grub_free (dir);
grub_device_close (dev);
grub_free (device_name);
grub_error_pop ();
return files;
fail:
if (dir)
grub_free (dir);
for (i = 0; files && files[i]; i++)
grub_free (files[i]);
if (files)
grub_free (files);
if (dev)
grub_device_close (dev);
if (device_name)
grub_free (device_name);
grub_error_pop ();
return 0;
}
static char*
wildcard_escape (const char *s)
{
int i;
int len;
char ch;
char *p;
len = grub_strlen (s);
p = grub_malloc (len * 2 + 1);
if (! p)
return NULL;
i = 0;
while ((ch = *s++))
{
if (isregexop (ch))
p[i++] = '\\';
p[i++] = ch;
}
p[i] = '\0';
return p;
}
static char*
wildcard_unescape (const char *s)
{
int i;
int len;
char ch;
char *p;
len = grub_strlen (s);
p = grub_malloc (len + 1);
if (! p)
return NULL;
i = 0;
while ((ch = *s++))
{
if (ch == '\\' && isregexop (*s))
p[i++] = *s++;
else
p[i++] = ch;
}
p[i] = '\0';
return p;
}
static grub_err_t
wildcard_expand (const char *s, char ***strs)
{
const char *start;
const char *regexop;
const char *noregexop;
char **paths = 0;
unsigned i;
regex_t regexp;
start = s;
while (*start)
{
split_path (start, &noregexop, &regexop);
if (noregexop >= regexop) /* no more wildcards */
break;
if (make_regex (noregexop, regexop, &regexp))
goto fail;
if (paths == 0)
{
if (start == noregexop) /* device part has regexop */
paths = match_devices (&regexp, *start != '(');
else if (*start == '(') /* device part explicit wo regexop */
paths = match_files ("", start, noregexop, &regexp);
else if (*start == '/') /* no device part */
{
char **r;
unsigned n;
char *root;
char *prefix;
root = grub_env_get ("root");
if (! root)
goto fail;
prefix = grub_xasprintf ("(%s)", root);
if (! prefix)
goto fail;
paths = match_files (prefix, start, noregexop, &regexp);
grub_free (prefix);
}
}
else
{
char **r = 0;
for (i = 0; paths[i]; i++)
{
char **p;
p = match_files (paths[i], start, noregexop, &regexp);
if (! p)
continue;
r = merge (r, p);
if (! r)
goto fail;
}
paths = r;
}
regfree (&regexp);
if (! paths)
goto done;
start = regexop;
}
done:
*strs = paths;
return 0;
fail:
for (i = 0; paths && paths[i]; i++)
grub_free (paths[i]);
grub_free (paths[i]);
regfree (&regexp);
return grub_errno;
}

View File

@ -19,6 +19,7 @@
#include <grub/machine/biosdisk.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/machine/int.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/mm.h>
@ -28,6 +29,219 @@
#include <grub/term.h>
static int cd_drive = 0;
static int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
static int grub_biosdisk_get_num_floppies (void)
{
struct grub_bios_int_registers regs;
int drive;
/* reset the disk system first */
regs.eax = 0;
regs.edx = 0;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
for (drive = 0; drive < 2; drive++)
{
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT | GRUB_CPU_INT_FLAGS_CARRY;
regs.edx = drive;
/* call GET DISK TYPE */
regs.eax = 0x1500;
grub_bios_interrupt (0x13, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
break;
/* check if this drive exists */
if (!(regs.eax & 0x300))
break;
}
return drive;
}
/*
* Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
* is passed for disk address packet. If an error occurs, return
* non-zero, otherwise zero.
*/
static int
grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap)
{
struct grub_bios_int_registers regs;
regs.eax = ah << 8;
/* compute the address of disk_address_packet */
regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;
regs.esi = (((grub_addr_t) dap) & 0xffff);
regs.edx = drive;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
return (regs.eax >> 8) & 0xff;
}
/*
* Call standard and old INT13 (int 13 %ah=AH) for DRIVE. Read/write
* NSEC sectors from COFF/HOFF/SOFF into SEGMENT. If an error occurs,
* return non-zero, otherwise zero.
*/
static int
grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment)
{
int ret, i;
/* Try 3 times. */
for (i = 0; i < 3; i++)
{
struct grub_bios_int_registers regs;
/* set up CHS information */
/* set %ch to low eight bits of cylinder */
regs.ecx = (coff << 8) & 0xff00;
/* set bits 6-7 of %cl to high two bits of cylinder */
regs.ecx |= (coff >> 2) & 0xc0;
/* set bits 0-5 of %cl to sector */
regs.ecx |= soff & 0x3f;
/* set %dh to head and %dl to drive */
regs.edx = (drive & 0xff) | ((hoff << 8) & 0xff00);
/* set %ah to AH */
regs.eax = (ah << 8) & 0xff00;
/* set %al to NSEC */
regs.eax |= nsec & 0xff;
regs.ebx = 0;
regs.es = segment;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
/* check if successful */
if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY))
return 0;
/* save return value */
ret = regs.eax >> 8;
/* if fail, reset the disk system */
regs.eax = 0;
regs.edx = (drive & 0xff);
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
}
return ret;
}
/*
* Check if LBA is supported for DRIVE. If it is supported, then return
* the major version of extensions, otherwise zero.
*/
static int
grub_biosdisk_check_int13_extensions (int drive)
{
struct grub_bios_int_registers regs;
regs.edx = drive & 0xff;
regs.eax = 0x4100;
regs.ebx = 0x55aa;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
return 0;
if ((regs.ebx & 0xffff) != 0xaa55)
return 0;
/* check if AH=0x42 is supported */
if (!(regs.ecx & 1))
return 0;
return (regs.eax >> 8) & 0xff;
}
/*
* Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
* error occurs, then return non-zero, otherwise zero.
*/
static int
grub_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders,
unsigned long *heads,
unsigned long *sectors)
{
struct grub_bios_int_registers regs;
regs.eax = 0x0800;
regs.edx = drive & 0xff;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
/* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8;
/* bogus BIOSes may not return an error number */
/* 0 sectors means no disk */
if (!(regs.ecx & 0x3f))
/* XXX 0x60 is one of the unused error numbers */
return 0x60;
/* the number of heads is counted from zero */
*heads = ((regs.edx >> 8) & 0xff) + 1;
*cylinders = (((regs.ecx >> 8) & 0xff) | ((regs.ecx << 2) & 0x0300)) + 1;
*sectors = regs.ecx & 0x3f;
return 0;
}
static int
grub_biosdisk_get_diskinfo_real (int drive, void *drp, grub_uint16_t ax)
{
struct grub_bios_int_registers regs;
regs.eax = ax;
/* compute the address of drive parameters */
regs.esi = ((grub_addr_t) drp) & 0xf;
regs.ds = ((grub_addr_t) drp) >> 4;
regs.edx = drive & 0xff;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, &regs);
/* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8;
return 0;
}
/*
* Return the cdrom information of DRIVE in CDRP. If an error occurs,
* then return non-zero, otherwise zero.
*/
static int
grub_biosdisk_get_cdinfo_int13_extensions (int drive, void *cdrp)
{
return grub_biosdisk_get_diskinfo_real (drive, cdrp, 0x4b01);
}
/*
* Return the geometry of DRIVE in a drive parameters, DRP. If an error
* occurs, then return non-zero, otherwise zero.
*/
static int
grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp)
{
return grub_biosdisk_get_diskinfo_real (drive, drp, 0x4800);
}
static int
grub_biosdisk_get_drive (const char *name)

View File

@ -71,9 +71,9 @@ delete_loopback (const char *name)
/* The command to add and remove loopback devices. */
static grub_err_t
grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = state = cmd->state;
struct grub_arg_list *state = ctxt->state;
grub_file_t file;
struct grub_loopback *newdev;
grub_err_t ret;
@ -167,8 +167,11 @@ grub_loopback_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
/* Use the filesize for the disk size, round up to a complete sector. */
disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
/ GRUB_DISK_SECTOR_SIZE);
if (dev->file->size != GRUB_FILE_SIZE_UNKNOWN)
disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
/ GRUB_DISK_SECTOR_SIZE);
else
disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
disk->id = (unsigned long) dev;
disk->has_partitions = dev->has_partitions;

View File

@ -17,7 +17,6 @@
*/
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/command.h>
#define cpuid(num,a,b,c,d) \

View File

@ -1,3 +1,4 @@
/* Register SMBIOS and ACPI tables. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
@ -16,12 +17,14 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_LOADER_MACHINE_HEADER
#define GRUB_LOADER_MACHINE_HEADER 1
#include <grub/err.h>
#include <grub/efiemu/efiemu.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/acpi.h>
/* The symbol shared between the normal mode and rescue mode
loader. */
void grub_rescue_cmd_linux (int argc, char *argv[]);
void grub_rescue_cmd_initrd (int argc, char *argv[]);
#endif /* ! GRUB_LOADER_MACHINE_HEADER */
grub_err_t
grub_machine_efiemu_init_tables (void)
{
return GRUB_ERR_NONE;
}

View File

@ -19,7 +19,6 @@
#include <grub/err.h>
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/acpi.h>

View File

@ -22,7 +22,6 @@
#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/cpu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/elf.h>
/* ELF symbols and their values */

View File

@ -29,7 +29,6 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/command.h>
#include <grub/i18n.h>
@ -183,22 +182,6 @@ grub_cmd_efiemu_prepare (grub_command_t cmd __attribute__ ((unused)),
int
grub_efiemu_exit_boot_services (grub_efi_uintn_t map_key
__attribute__ ((unused)))
{
/* Nothing to do here yet */
return 1;
}
int
grub_efiemu_finish_boot_services (void)
{
/* Nothing to do here yet */
return 1;
}
/* Load the runtime from the file FILENAME. */
static grub_err_t
grub_efiemu_load_file (const char *filename)

View File

@ -323,6 +323,25 @@ grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
return 1;
}
grub_err_t
grub_efiemu_finish_boot_services (grub_efi_uintn_t *memory_map_size,
grub_efi_memory_descriptor_t *memory_map,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version)
{
int val = grub_efiemu_get_memory_map (memory_map_size,
memory_map, map_key,
descriptor_size,
descriptor_version);
if (val == 1)
return GRUB_ERR_NONE;
if (val == -1)
return grub_errno;
return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
}
/* Free everything */
grub_err_t
grub_efiemu_mm_unload (void)

View File

@ -1,4 +0,0 @@
gcc -c -m32 -DELF32 -o efiemu32.o ./efiemu.c -Wall -Werror -nostdlib -O2 -I. -I../../include
gcc -c -m64 -DELF64 -o efiemu64_c.o ./efiemu.c -Wall -Werror -mcmodel=large -O2 -I. -I../../include
gcc -c -m64 -DELF64 -o efiemu64_s.o ./efiemu.S -Wall -Werror -mcmodel=large -O2 -I. -I../../include
ld -o efiemu64.o -r efiemu64_s.o efiemu64_c.o -nostdlib

View File

@ -27,6 +27,7 @@
#include <grub/env.h>
#include <grub/machine/pxe.h>
#include <grub/machine/int.h>
#include <grub/machine/memory.h>
#define SEGMENT(x) ((x) >> 4)
@ -40,7 +41,7 @@ struct grub_pxe_disk_data
grub_uint32_t gateway_ip;
};
struct grub_pxenv *grub_pxe_pxenv;
struct grub_pxe_bangpxe *grub_pxe_pxenv;
static grub_uint32_t grub_pxe_your_ip;
static grub_uint32_t grub_pxe_default_server_ip;
static grub_uint32_t grub_pxe_default_gateway_ip;
@ -55,6 +56,51 @@ struct grub_pxe_data
char filename[0];
};
static grub_uint32_t pxe_rm_entry = 0;
static struct grub_pxe_bangpxe *
grub_pxe_scan (void)
{
struct grub_bios_int_registers regs;
struct grub_pxenv *pxenv;
struct grub_pxe_bangpxe *bangpxe;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
regs.ebx = 0;
regs.ecx = 0;
regs.eax = 0x5650;
regs.es = 0;
grub_bios_interrupt (0x1a, &regs);
if ((regs.eax & 0xffff) != 0x564e)
return NULL;
pxenv = (struct grub_pxenv *) ((regs.es << 4) + (regs.ebx & 0xffff));
if (grub_memcmp (pxenv->signature, GRUB_PXE_SIGNATURE,
sizeof (pxenv->signature))
!= 0)
return NULL;
if (pxenv->version < 0x201)
return NULL;
bangpxe = (void *) ((((pxenv->pxe_ptr & 0xffff0000) >> 16) << 4)
+ (pxenv->pxe_ptr & 0xffff));
if (!bangpxe)
return NULL;
if (grub_memcmp (bangpxe->signature, GRUB_PXE_BANGPXE_SIGNATURE,
sizeof (bangpxe->signature)) != 0)
return NULL;
pxe_rm_entry = bangpxe->rm_entry;
return bangpxe;
}
static int
grub_pxe_iterate (int (*hook) (const char *name))
{
@ -202,14 +248,14 @@ grub_pxefs_open (struct grub_file *file, const char *name)
if (curr_file != 0)
{
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c.c2);
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c.c2, pxe_rm_entry);
curr_file = 0;
}
c.c1.server_ip = disk_data->server_ip;
c.c1.gateway_ip = disk_data->gateway_ip;
grub_strcpy ((char *)&c.c1.filename[0], name);
grub_pxe_call (GRUB_PXENV_TFTP_GET_FSIZE, &c.c1);
grub_pxe_call (GRUB_PXENV_TFTP_GET_FSIZE, &c.c1, pxe_rm_entry);
if (c.c1.status)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
@ -217,7 +263,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
c.c2.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT);
c.c2.packet_size = grub_pxe_blksize;
grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &c.c2);
grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &c.c2, pxe_rm_entry);
if (c.c2.status)
return grub_error (GRUB_ERR_BAD_FS, "open fails");
@ -236,6 +282,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
}
file->data = data;
file->not_easly_seekable = 1;
grub_memcpy (file_int, file, sizeof (struct grub_file));
curr_file = file_int;
@ -275,14 +322,14 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
struct grub_pxenv_tftp_open o;
if (curr_file != 0)
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o);
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o, pxe_rm_entry);
o.server_ip = disk_data->server_ip;
o.gateway_ip = disk_data->gateway_ip;
grub_strcpy ((char *)&o.filename[0], data->filename);
o.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT);
o.packet_size = grub_pxe_blksize;
grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &o);
o.packet_size = data->block_size;
grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &o, pxe_rm_entry);
if (o.status)
{
grub_error (GRUB_ERR_BAD_FS, "open fails");
@ -297,7 +344,7 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
while (pn >= data->packet_number)
{
c.buffer_size = data->block_size;
grub_pxe_call (GRUB_PXENV_TFTP_READ, &c);
grub_pxe_call (GRUB_PXENV_TFTP_READ, &c, pxe_rm_entry);
if (c.status)
{
grub_error (GRUB_ERR_BAD_FS, "read fails");
@ -318,7 +365,7 @@ grub_pxefs_close (grub_file_t file)
if (curr_file == file)
{
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c);
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c, pxe_rm_entry);
curr_file = 0;
}
@ -443,7 +490,7 @@ parse_dhcp_vendor (void *vend, int limit)
static void
grub_pxe_detect (void)
{
struct grub_pxenv *pxenv;
struct grub_pxe_bangpxe *pxenv;
struct grub_pxenv_get_cached_info ci;
struct grub_pxenv_boot_player *bp;
@ -454,7 +501,7 @@ grub_pxe_detect (void)
ci.packet_type = GRUB_PXENV_PACKET_TYPE_DHCP_ACK;
ci.buffer = 0;
ci.buffer_size = 0;
grub_pxe_call (GRUB_PXENV_GET_CACHED_INFO, &ci);
grub_pxe_call (GRUB_PXENV_GET_CACHED_INFO, &ci, pxe_rm_entry);
if (ci.status)
return;

View File

@ -718,10 +718,13 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
grub_uint64_t partition_size;
int valid[2];
int swp = 0;
grub_err_t err;
/* Read first super block. */
grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
sizeof (struct grub_nilfs2_super_block), &data->sblock);
err = grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
sizeof (struct grub_nilfs2_super_block), &data->sblock);
if (err)
return err;
/* Make sure if 1st super block is valid. */
valid[0] = grub_nilfs2_valid_sb (&data->sblock);
@ -729,17 +732,21 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
{
/* Read second super block. */
grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
sizeof (struct grub_nilfs2_super_block), &sb2);
/* Make sure if 2nd super block is valid. */
valid[1] = grub_nilfs2_valid_sb (&sb2);
err = grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
sizeof (struct grub_nilfs2_super_block), &sb2);
if (err)
{
valid[1] = 0;
grub_errno = GRUB_ERR_NONE;
}
else
/* Make sure if 2nd super block is valid. */
valid[1] = grub_nilfs2_valid_sb (&sb2);
}
else
/* 2nd super block may not exist, so it's invalid. */
valid[1] = 0;
if (!valid[0] && !valid[1])
return grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
@ -752,8 +759,7 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
grub_memcpy (&data->sblock, &sb2,
sizeof (struct grub_nilfs2_super_block));
grub_errno = GRUB_ERR_NONE;
return grub_errno;
return GRUB_ERR_NONE;
}
static struct grub_nilfs2_data *

View File

@ -26,7 +26,6 @@
#include <grub/normal.h>
#include <grub/file.h>
#include <grub/kernel.h>
#include <grub/gzio.h>
#include <grub/i18n.h>
/*
@ -219,7 +218,7 @@ grub_gettext_translate (const char *orig)
return ret;
}
/* This is similar to grub_gzfile_open. */
/* This is similar to grub_file_open. */
static grub_file_t
grub_mofile_open (const char *filename)
{
@ -229,7 +228,7 @@ grub_mofile_open (const char *filename)
/* Using fd_mo and not another variable because
it's needed for grub_gettext_get_info. */
fd_mo = grub_gzfile_open (filename, 1);
fd_mo = grub_file_open (filename);
grub_errno = GRUB_ERR_NONE;
if (!fd_mo)

View File

@ -27,7 +27,7 @@
#include <grub/i18n.h>
static grub_err_t
grub_cmd_hello (struct grub_extcmd *cmd __attribute__ ((unused)),
grub_cmd_hello (grub_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{

View File

@ -74,6 +74,7 @@ grub_bufio_open (grub_file_t io, int size)
file->data = bufio;
file->read_hook = 0;
file->fs = &grub_bufio_fs;
file->not_easly_seekable = io->not_easly_seekable;
return file;
}

View File

@ -40,7 +40,7 @@
#include <grub/misc.h>
#include <grub/fs.h>
#include <grub/file.h>
#include <grub/gzio.h>
#include <grub/dl.h>
/*
* Window Size
@ -206,7 +206,7 @@ test_header (grub_file_t file)
|| ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1))
|| ((hdr.flags & COMMENT) && eat_field (gzio->file, -1)))
{
grub_error (GRUB_ERR_BAD_GZIP_DATA, "unsupported gzip format");
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "unsupported gzip format");
return 0;
}
@ -214,12 +214,14 @@ test_header (grub_file_t file)
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
if (grub_file_seekable (gzio->file))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0;
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0;
}
}
/* FIXME: this does not handle files whose original size is over 4GB.
But how can we know the real original size? */
file->size = grub_le_to_cpu32 (orig_len);
@ -644,7 +646,7 @@ inflate_codes_in_window (grub_file_t file)
{
if (e == 99)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"an unused code found");
return 1;
}
@ -683,7 +685,7 @@ inflate_codes_in_window (grub_file_t file)
{
if (e == 99)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"an unused code found");
return 1;
}
@ -769,7 +771,7 @@ init_stored_block (grub_file_t file)
DUMPBITS (16);
NEEDBITS (16);
if (gzio->block_len != (int) ((~b) & 0xffff))
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"the length of a stored block does not match");
DUMPBITS (16);
@ -803,7 +805,7 @@ init_fixed_block (grub_file_t file)
if (huft_build (l, 288, 257, cplens, cplext, &gzio->tl, &gzio->bl) != 0)
{
if (grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"failed in building a Huffman code table");
return;
}
@ -815,7 +817,7 @@ init_fixed_block (grub_file_t file)
if (huft_build (l, 30, 0, cpdist, cpdext, &gzio->td, &gzio->bd) > 1)
{
if (grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"failed in building a Huffman code table");
huft_free (gzio->tl);
gzio->tl = 0;
@ -862,7 +864,7 @@ init_dynamic_block (grub_file_t file)
DUMPBITS (4);
if (nl > 286 || nd > 30)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA, "too much data");
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too much data");
return;
}
@ -880,7 +882,7 @@ init_dynamic_block (grub_file_t file)
gzio->bl = 7;
if (huft_build (ll, 19, 19, NULL, NULL, &gzio->tl, &gzio->bl) != 0)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"failed in building a Huffman code table");
return;
}
@ -904,7 +906,7 @@ init_dynamic_block (grub_file_t file)
DUMPBITS (2);
if ((unsigned) i + j > n)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA, "too many codes found");
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
return;
}
while (j--)
@ -917,7 +919,7 @@ init_dynamic_block (grub_file_t file)
DUMPBITS (3);
if ((unsigned) i + j > n)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA, "too many codes found");
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
return;
}
while (j--)
@ -932,7 +934,7 @@ init_dynamic_block (grub_file_t file)
DUMPBITS (7);
if ((unsigned) i + j > n)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA, "too many codes found");
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
return;
}
while (j--)
@ -954,7 +956,7 @@ init_dynamic_block (grub_file_t file)
gzio->bl = lbits;
if (huft_build (ll, nl, 257, cplens, cplext, &gzio->tl, &gzio->bl) != 0)
{
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"failed in building a Huffman code table");
return;
}
@ -963,7 +965,7 @@ init_dynamic_block (grub_file_t file)
{
huft_free (gzio->tl);
gzio->tl = 0;
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"failed in building a Huffman code table");
return;
}
@ -1039,7 +1041,7 @@ inflate_window (grub_file_t file)
}
if (gzio->block_type > INFLATE_DYNAMIC)
grub_error (GRUB_ERR_BAD_GZIP_DATA,
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"unknown block type %d", gzio->block_type);
if (grub_errno != GRUB_ERR_NONE)
@ -1111,8 +1113,8 @@ initialize_tables (grub_file_t file)
/* Open a new decompressing object on the top of IO. If TRANSPARENT is true,
even if IO does not contain data compressed by gzip, return a valid file
object. Note that this function won't close IO, even if an error occurs. */
grub_file_t
grub_gzio_open (grub_file_t io, int transparent)
static grub_file_t
grub_gzio_open (grub_file_t io)
{
grub_file_t file;
grub_gzio_t gzio = 0;
@ -1135,6 +1137,7 @@ grub_gzio_open (grub_file_t io, int transparent)
file->data = gzio;
file->read_hook = 0;
file->fs = &grub_gzio_fs;
file->not_easly_seekable = 1;
if (! test_header (file))
{
@ -1142,33 +1145,11 @@ grub_gzio_open (grub_file_t io, int transparent)
grub_free (file);
grub_file_seek (io, 0);
if (grub_errno == GRUB_ERR_BAD_FILE_TYPE && transparent)
if (grub_errno == GRUB_ERR_BAD_FILE_TYPE)
{
grub_errno = GRUB_ERR_NONE;
return io;
}
else
return 0;
}
return file;
}
/* This is similar to grub_gzio_open, but takes a file name as an argument. */
grub_file_t
grub_gzfile_open (const char *name, int transparent)
{
grub_file_t io, file;
io = grub_file_open (name);
if (! io)
return 0;
file = grub_gzio_open (io, transparent);
if (! file)
{
grub_file_close (io);
return 0;
}
return file;
@ -1249,3 +1230,13 @@ static struct grub_fs grub_gzio_fs =
.label = 0,
.next = 0
};
GRUB_MOD_INIT(gzio)
{
grub_file_filter_register (GRUB_FILE_FILTER_GZIO, grub_gzio_open);
}
GRUB_MOD_FINI(gzio)
{
grub_file_filter_unregister (GRUB_FILE_FILTER_GZIO);
}

353
grub-core/io/xzio.c Normal file
View File

@ -0,0 +1,353 @@
/* xzio.c - decompression support for xz */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/file.h>
#include <grub/fs.h>
#include <grub/dl.h>
#include "xz.h"
#include "xz_stream.h"
#define XZBUFSIZ 0x2000
#define VLI_MAX_DIGITS 9
#define XZ_STREAM_FOOTER_SIZE 12
struct grub_xzio
{
grub_file_t file;
struct xz_buf buf;
struct xz_dec *dec;
grub_uint8_t inbuf[XZBUFSIZ];
grub_uint8_t outbuf[XZBUFSIZ];
grub_off_t saved_offset;
};
typedef struct grub_xzio *grub_xzio_t;
static struct grub_fs grub_xzio_fs;
static grub_size_t
decode_vli (const grub_uint8_t buf[], grub_size_t size_max,
grub_uint64_t * num)
{
if (size_max == 0)
return 0;
if (size_max > VLI_MAX_DIGITS)
size_max = VLI_MAX_DIGITS;
*num = buf[0] & 0x7F;
grub_size_t i = 0;
while (buf[i++] & 0x80)
{
if (i >= size_max || buf[i] == 0x00)
return 0;
*num |= (uint64_t) (buf[i] & 0x7F) << (i * 7);
}
return i;
}
static grub_ssize_t
read_vli (grub_file_t file, grub_uint64_t * num)
{
grub_uint8_t buf[VLI_MAX_DIGITS];
grub_ssize_t read;
grub_size_t dec;
read = grub_file_read (file, buf, VLI_MAX_DIGITS);
if (read < 0)
return -1;
dec = decode_vli (buf, read, num);
grub_file_seek (file, file->offset - (read - dec));
return dec;
}
/* Function xz_dec_run() should consume header and ask for more (XZ_OK)
* else file is corrupted (or options not supported) or not xz. */
static int
test_header (grub_file_t file)
{
grub_xzio_t xzio = file->data;
xzio->buf.in_size = grub_file_read (xzio->file, xzio->inbuf,
STREAM_HEADER_SIZE);
if (xzio->buf.in_size != STREAM_HEADER_SIZE)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0;
}
enum xz_ret ret = xz_dec_run (xzio->dec, &xzio->buf);
if (ret == XZ_FORMAT_ERROR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0;
}
if (ret != XZ_OK)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "not supported xz options");
return 0;
}
return 1;
}
/* Try to find out size of uncompressed data,
* also do some footer sanity checks. */
static int
test_footer (grub_file_t file)
{
grub_xzio_t xzio = file->data;
grub_uint8_t footer[FOOTER_MAGIC_SIZE];
grub_uint32_t backsize;
grub_uint8_t imarker;
grub_uint64_t uncompressed_size_total = 0;
grub_uint64_t uncompressed_size;
grub_uint64_t records;
grub_file_seek (xzio->file, xzio->file->size - FOOTER_MAGIC_SIZE);
if (grub_file_read (xzio->file, footer, FOOTER_MAGIC_SIZE) !=
FOOTER_MAGIC_SIZE
|| grub_memcmp (footer, FOOTER_MAGIC, FOOTER_MAGIC_SIZE) != 0)
goto ERROR;
grub_file_seek (xzio->file, xzio->file->size - 8);
if (grub_file_read (xzio->file, &backsize, sizeof (backsize))
!= sizeof (backsize))
goto ERROR;
/* Calculate real backward size. */
backsize = (grub_le_to_cpu32 (backsize) + 1) * 4;
/* Set file to the beginning of stream index. */
grub_file_seek (xzio->file,
xzio->file->size - XZ_STREAM_FOOTER_SIZE - backsize);
/* Test index marker. */
if (grub_file_read (xzio->file, &imarker, sizeof (imarker)) !=
sizeof (imarker) && imarker != 0x00)
goto ERROR;
if (read_vli (xzio->file, &records) <= 0)
goto ERROR;
for (; records != 0; records--)
{
if (read_vli (xzio->file, &uncompressed_size) <= 0) /* Ignore unpadded. */
goto ERROR;
if (read_vli (xzio->file, &uncompressed_size) <= 0) /* Uncompressed. */
goto ERROR;
uncompressed_size_total += uncompressed_size;
}
file->size = uncompressed_size_total;
grub_file_seek (xzio->file, STREAM_HEADER_SIZE);
return 1;
ERROR:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "bad footer magic");
return 0;
}
static grub_file_t
grub_xzio_open (grub_file_t io)
{
grub_file_t file;
grub_xzio_t xzio;
file = (grub_file_t) grub_zalloc (sizeof (*file));
if (!file)
return 0;
xzio = grub_zalloc (sizeof (*xzio));
if (!xzio)
{
grub_free (file);
return 0;
}
xzio->file = io;
xzio->saved_offset = 0;
file->device = io->device;
file->offset = 0;
file->data = xzio;
file->read_hook = 0;
file->fs = &grub_xzio_fs;
file->size = GRUB_FILE_SIZE_UNKNOWN;
file->not_easly_seekable = 1;
if (grub_file_tell (xzio->file) != 0)
grub_file_seek (xzio->file, 0);
/* Allocated 64KiB for dictionary.
* Decoder will relocate if bigger is needed. */
xzio->dec = xz_dec_init (1 << 16);
if (!xzio->dec)
{
grub_free (file);
grub_free (xzio);
return 0;
}
xzio->buf.in = xzio->inbuf;
xzio->buf.in_pos = 0;
xzio->buf.in_size = 0;
xzio->buf.out = xzio->outbuf;
xzio->buf.out_pos = 0;
xzio->buf.out_size = XZBUFSIZ;
if (!test_header (file) || !(grub_file_seekable (io) && test_footer (file)))
{
grub_errno = GRUB_ERR_NONE;
grub_file_seek (io, 0);
xz_dec_end (xzio->dec);
grub_free (xzio);
grub_free (file);
return io;
}
return file;
}
static grub_ssize_t
grub_xzio_read (grub_file_t file, char *buf, grub_size_t len)
{
grub_ssize_t ret = 0;
grub_ssize_t readret;
enum xz_ret xzret;
grub_xzio_t xzio = file->data;
grub_off_t current_offset;
/* If seek backward need to reset decoder and start from beginning of file.
TODO Possible improvement by jumping blocks. */
if (file->offset < xzio->saved_offset)
{
xz_dec_reset (xzio->dec);
xzio->saved_offset = 0;
xzio->buf.out_pos = 0;
xzio->buf.in_pos = 0;
xzio->buf.in_size = 0;
grub_file_seek (xzio->file, 0);
}
current_offset = xzio->saved_offset;
while (len > 0)
{
xzio->buf.out_size = grub_min (file->offset + ret + len - current_offset,
XZBUFSIZ);
/* Feed input. */
if (xzio->buf.in_pos == xzio->buf.in_size)
{
readret = grub_file_read (xzio->file, xzio->inbuf, XZBUFSIZ);
if (readret < 0)
return -1;
xzio->buf.in_size = readret;
xzio->buf.in_pos = 0;
}
xzret = xz_dec_run (xzio->dec, &xzio->buf);
switch (xzret)
{
case XZ_MEMLIMIT_ERROR:
case XZ_FORMAT_ERROR:
case XZ_OPTIONS_ERROR:
case XZ_DATA_ERROR:
case XZ_BUF_ERROR:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"file corrupted or unsupported block options");
return -1;
default:
break;
}
{
grub_off_t new_offset = current_offset + xzio->buf.out_pos;
if (file->offset <= new_offset)
/* Store first chunk of data in buffer. */
{
grub_size_t delta = new_offset - (file->offset + ret);
grub_memmove (buf, xzio->buf.out + (xzio->buf.out_pos - delta),
delta);
len -= delta;
buf += delta;
ret += delta;
}
current_offset = new_offset;
}
xzio->buf.out_pos = 0;
if (xzret == XZ_STREAM_END) /* Stream end, EOF. */
break;
}
if (ret >= 0)
xzio->saved_offset = file->offset + ret;
return ret;
}
/* Release everything, including the underlying file object. */
static grub_err_t
grub_xzio_close (grub_file_t file)
{
grub_xzio_t xzio = file->data;
xz_dec_end (xzio->dec);
grub_file_close (xzio->file);
grub_free (xzio);
/* Device must not be closed twice. */
file->device = 0;
return grub_errno;
}
static struct grub_fs grub_xzio_fs = {
.name = "xzio",
.dir = 0,
.open = 0,
.read = grub_xzio_read,
.close = grub_xzio_close,
.label = 0,
.next = 0
};
GRUB_MOD_INIT (xzio)
{
grub_file_filter_register (GRUB_FILE_FILTER_XZIO, grub_xzio_open);
}
GRUB_MOD_FINI (xzio)
{
grub_file_filter_unregister (GRUB_FILE_FILTER_XZIO);
}

View File

@ -682,20 +682,3 @@ grub_dl_unload_unneeded (void)
p = p->next;
}
}
/* Unload all modules. */
void
grub_dl_unload_all (void)
{
while (grub_dl_head)
{
grub_dl_t p;
grub_dl_unload_unneeded ();
/* Force to decrement the ref count. This will purge pre-loaded
modules and manually inserted modules. */
for (p = grub_dl_head; p; p = p->next)
p->ref_count--;
}
}

View File

@ -174,26 +174,6 @@ grub_reboot (void)
}
#endif
void
grub_halt (void)
{
grub_efi_fini ();
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
for (;;) ;
}
int
grub_efi_exit_boot_services (grub_efi_uintn_t map_key)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
b = grub_efi_system_table->boot_services;
status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle, map_key);
return status == GRUB_EFI_SUCCESS;
}
grub_err_t
grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
grub_efi_uintn_t descriptor_size,
@ -760,26 +740,3 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
dp = (grub_efi_device_path_t *) ((char *) dp + len);
}
}
int
grub_efi_finish_boot_services (void)
{
grub_efi_uintn_t mmap_size = 0;
grub_efi_uintn_t map_key;
grub_efi_uintn_t desc_size;
grub_efi_uint32_t desc_version;
void *mmap_buf = 0;
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
&desc_size, &desc_version) < 0)
return 0;
mmap_buf = grub_malloc (mmap_size);
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
&desc_size, &desc_version) <= 0)
return 0;
return grub_efi_exit_boot_services (map_key);
}

View File

@ -49,6 +49,12 @@ static struct allocated_page *allocated_pages = 0;
#define MIN_HEAP_SIZE 0x100000
#define MAX_HEAP_SIZE (1600 * 0x100000)
static void *finish_mmap_buf = 0;
static grub_efi_uintn_t finish_mmap_size = 0;
static grub_efi_uintn_t finish_key = 0;
static grub_efi_uintn_t finish_desc_size;
static grub_efi_uint32_t finish_desc_version;
int grub_efi_is_finished = 0;
/* Allocate pages. Return the pointer to the first of allocated pages. */
void *
@ -140,6 +146,51 @@ grub_efi_free_pages (grub_efi_physical_address_t address,
efi_call_2 (b->free_pages, address, pages);
}
grub_err_t
grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *efi_desc_size,
grub_efi_uint32_t *efi_desc_version)
{
grub_efi_boot_services_t *b;
grub_efi_status_t status;
if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
&finish_desc_size, &finish_desc_version) < 0)
return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
if (outbuf && *outbuf_size < finish_mmap_size)
return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
finish_mmap_buf = grub_malloc (finish_mmap_size);
if (!finish_mmap_buf)
return grub_errno;
if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
&finish_desc_size, &finish_desc_version) <= 0)
return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
b = grub_efi_system_table->boot_services;
status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
finish_key);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
grub_efi_is_finished = 1;
if (outbuf_size)
*outbuf_size = finish_mmap_size;
if (outbuf)
grub_memcpy (outbuf, finish_mmap_buf, finish_mmap_size);
if (map_key)
*map_key = finish_key;
if (efi_desc_size)
*efi_desc_size = finish_desc_size;
if (efi_desc_version)
*efi_desc_version = finish_desc_version;
return GRUB_ERR_NONE;
}
/* Get the memory map as defined in the EFI spec. Return 1 if successful,
return 0 if partial, or return -1 if an error occurs. */
int
@ -154,6 +205,29 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
grub_efi_uintn_t key;
grub_efi_uint32_t version;
if (grub_efi_is_finished)
{
int ret = 1;
if (*memory_map_size < finish_mmap_size)
{
grub_memcpy (memory_map, finish_mmap_buf, *memory_map_size);
ret = 0;
}
else
{
grub_memcpy (memory_map, finish_mmap_buf, finish_mmap_size);
ret = 1;
}
*memory_map_size = finish_mmap_size;
if (map_key)
*map_key = finish_key;
if (descriptor_size)
*descriptor_size = finish_desc_size;
if (descriptor_version)
*descriptor_version = finish_desc_version;
return ret;
}
/* Allow some parameters to be missing. */
if (! map_key)
map_key = &key;

View File

@ -21,7 +21,6 @@
#include <grub/elf.h>
#include <grub/elfload.h>
#include <grub/file.h>
#include <grub/gzio.h>
#include <grub/misc.h>
#include <grub/mm.h>
@ -95,7 +94,7 @@ grub_elf_open (const char *name)
grub_file_t file;
grub_elf_t elf;
file = grub_gzfile_open (name, 1);
file = grub_file_open (name);
if (! file)
return 0;
@ -140,7 +139,7 @@ grub_elf32_load_phdrs (grub_elf_t elf)
return GRUB_ERR_NONE;
}
static grub_err_t
grub_err_t
grub_elf32_phdr_iterate (grub_elf_t elf,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *),
void *hook_arg)
@ -326,7 +325,7 @@ grub_elf64_load_phdrs (grub_elf_t elf)
return GRUB_ERR_NONE;
}
static grub_err_t
grub_err_t
grub_elf64_phdr_iterate (grub_elf_t elf,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *),
void *hook_arg)

View File

@ -66,16 +66,6 @@ grub_reboot (void)
longjmp (main_env, 1);
}
void
grub_halt (
#ifdef GRUB_MACHINE_PCBIOS
int no_apm __attribute__ ((unused))
#endif
)
{
grub_reboot ();
}
void
grub_machine_init (void)
{

View File

@ -24,6 +24,9 @@
#include <grub/fs.h>
#include <grub/device.h>
grub_file_filter_t grub_file_filters_all[GRUB_FILE_FILTER_MAX];
grub_file_filter_t grub_file_filters_enabled[GRUB_FILE_FILTER_MAX];
/* Get the device part of the filename NAME. It is enclosed by parentheses. */
char *
grub_file_get_device_name (const char *name)
@ -54,14 +57,15 @@ grub_file_get_device_name (const char *name)
grub_file_t
grub_file_open (const char *name)
{
grub_device_t device;
grub_file_t file = 0;
grub_device_t device = 0;
grub_file_t file = 0, last_file = 0;
char *device_name;
char *file_name;
grub_file_filter_id_t filter;
device_name = grub_file_get_device_name (name);
if (grub_errno)
return 0;
goto fail;
/* Get the file part of NAME. */
file_name = grub_strchr (name, ')');
@ -94,6 +98,19 @@ grub_file_open (const char *name)
if ((file->fs->open) (file, file_name) != GRUB_ERR_NONE)
goto fail;
for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled);
filter++)
if (grub_file_filters_enabled[filter])
{
last_file = file;
file = grub_file_filters_enabled[filter] (file);
}
if (!file)
grub_file_close (last_file);
grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
sizeof (grub_file_filters_enabled));
return file;
fail:
@ -104,6 +121,9 @@ grub_file_open (const char *name)
grub_free (file);
grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
sizeof (grub_file_filters_enabled));
return 0;
}

View File

@ -19,7 +19,6 @@
#include <grub/kernel.h>
#include <grub/mm.h>
#include <grub/machine/time.h>
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/machine/console.h>
#include <grub/types.h>
@ -32,33 +31,21 @@
#include <grub/time.h>
#include <grub/symbol.h>
#include <grub/cpu/io.h>
#include <grub/cpu/floppy.h>
#include <grub/cpu/tsc.h>
#ifdef GRUB_MACHINE_QEMU
#include <grub/machine/kernel.h>
#endif
#define GRUB_FLOPPY_REG_DIGITAL_OUTPUT 0x3f2
extern char _start[];
extern char _end[];
grub_addr_t grub_os_area_addr;
grub_size_t grub_os_area_size;
grub_uint32_t
grub_get_rtc (void)
{
grub_fatal ("grub_get_rtc() is not implemented.\n");
}
/* Stop the floppy drive from spinning, so that other software is
jumped to with a known state. */
void
grub_stop_floppy (void)
{
grub_outb (0, GRUB_FLOPPY_REG_DIGITAL_OUTPUT);
}
void
grub_exit (void)
{
@ -103,20 +90,7 @@ grub_machine_init (void)
}
}
if (addr == GRUB_MEMORY_MACHINE_UPPER_START
|| (addr >= GRUB_MEMORY_MACHINE_LOWER_SIZE
&& addr <= GRUB_MEMORY_MACHINE_UPPER_START
&& (addr + size > GRUB_MEMORY_MACHINE_UPPER_START)))
{
grub_size_t quarter = size >> 2;
grub_os_area_addr = addr;
grub_os_area_size = size - quarter;
grub_mm_init_region ((void *) (grub_os_area_addr + grub_os_area_size),
quarter);
}
else
grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size);
grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size);
return 0;
}

View File

@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
/*
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
@ -85,7 +85,3 @@ codestart:
*/
#include "../realmode.S"
/*
* Routines needed by Linux and Multiboot loaders.
*/
#include "../loader.S"

View File

@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
movl %eax, EXT_C(grub_ieee1275_entry_fn)
@ -63,7 +63,3 @@ codestart:
*/
#include "../realmode.S"
/*
* Routines needed by Linux and Multiboot loaders.
*/
#include "../loader.S"

View File

@ -1,120 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,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/>.
*/
/*
* Note: These functions defined in this file may be called from C.
* Be careful of that you must not modify some registers. Quote
* from gcc-2.95.2/gcc/config/i386/i386.h:
1 for registers not available across function calls.
These must include the FIXED_REGISTERS and also any
registers that can be used without being saved.
The latter must include the registers where values are returned
and the register where structure-value addresses are passed.
Aside from that, you can include as many other registers as you like.
ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg
{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
*/
/*
* Note: GRUB is compiled with the options -mrtd and -mregparm=3.
* So the first three arguments are passed in %eax, %edx, and %ecx,
* respectively, and if a function has a fixed number of arguments
* and the number if greater than three, the function must return
* with "ret $N" where N is ((the number of arguments) - 3) * 4.
*/
/*
* This is the area for all of the special variables.
*/
.p2align 2 /* force 4-byte alignment */
/*
* void grub_linux_boot_zimage (void)
*/
VARIABLE(grub_linux_prot_size)
.long 0
VARIABLE(grub_linux_tmp_addr)
.long 0
VARIABLE(grub_linux_real_addr)
.long 0
VARIABLE(grub_linux_is_bzimage)
.long 0
FUNCTION(grub_linux16_real_boot)
/* Must be done before zImage copy. */
call EXT_C(grub_dl_unload_all)
movl EXT_C(grub_linux_is_bzimage), %ebx
test %ebx, %ebx
jne bzimage
/* copy the kernel */
movl EXT_C(grub_linux_prot_size), %ecx
addl $3, %ecx
shrl $2, %ecx
movl $GRUB_LINUX_BZIMAGE_ADDR, %esi
movl $GRUB_LINUX_ZIMAGE_ADDR, %edi
cld
rep
movsl
bzimage:
movl EXT_C(grub_linux_real_addr), %ebx
/* copy the real mode code */
movl EXT_C(grub_linux_tmp_addr), %esi
movl %ebx, %edi
movl $GRUB_LINUX_SETUP_MOVE_SIZE, %ecx
cld
rep
movsb
/* change %ebx to the segment address */
shrl $4, %ebx
movl %ebx, %eax
addl $0x20, %eax
movw %ax, linux_setup_seg
/* XXX new stack pointer in safe area for calling functions */
movl $0x4000, %esp
call EXT_C(grub_stop_floppy)
/* final setup for linux boot */
call prot_to_real
.code16
cli
movw %bx, %ss
movw $GRUB_LINUX_SETUP_STACK, %sp
movw %bx, %ds
movw %bx, %es
movw %bx, %fs
movw %bx, %gs
/* ljmp */
.byte 0xea
.word 0
linux_setup_seg:
.word 0
.code32

View File

@ -1,29 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,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/symbol.h>
.text
/*
* This call is special... it never returns... in fact it should simply
* hang at this point!
*/
FUNCTION(grub_stop)
cli
1: hlt
jmp 1b

View File

@ -16,7 +16,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/types.h>
#include <grub/multiboot.h>

View File

@ -23,6 +23,7 @@
#include <grub/machine/memory.h>
#include <grub/machine/console.h>
#include <grub/machine/kernel.h>
#include <grub/machine/int.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/dl.h>
@ -44,9 +45,6 @@ struct mem_region
static struct mem_region mem_regions[MAX_REGIONS];
static int num_regions;
grub_addr_t grub_os_area_addr;
grub_size_t grub_os_area_size;
static char *
make_install_device (void)
{
@ -142,6 +140,22 @@ compact_mem_regions (void)
}
}
/*
*
* grub_get_conv_memsize(i) : return the conventional memory size in KB.
* BIOS call "INT 12H" to get conventional memory size
* The return value in AX.
*/
static inline grub_uint16_t
grub_get_conv_memsize (void)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x12, &regs);
return regs.eax & 0xffff;
}
void
grub_machine_init (void)
{
@ -151,7 +165,7 @@ grub_machine_init (void)
/* Initialize the console as early as possible. */
grub_console_init ();
grub_lower_mem = grub_get_memsize (0) << 10;
grub_lower_mem = grub_get_conv_memsize () << 10;
/* Sanity check. */
if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END)
@ -203,25 +217,9 @@ grub_machine_init (void)
compact_mem_regions ();
/* Add the memory regions to free memory, except for the region starting
from 1MB. This region is partially used for loading OS images.
For now, 1/4 of this is added to free memory. */
for (i = 0; i < num_regions; i++)
if (mem_regions[i].addr == 0x100000)
{
grub_size_t quarter = mem_regions[i].size >> 2;
grub_os_area_addr = mem_regions[i].addr;
grub_os_area_size = mem_regions[i].size - quarter;
grub_mm_init_region ((void *) (grub_os_area_addr + grub_os_area_size),
quarter);
}
else
grub_mm_init_region ((void *) mem_regions[i].addr, mem_regions[i].size);
if (! grub_os_area_addr)
grub_fatal ("no upper memory");
grub_tsc_init ();
}

View File

@ -17,11 +17,98 @@
*/
#include <grub/machine/init.h>
#include <grub/machine/int.h>
#include <grub/machine/memory.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/misc.h>
/*
* grub_get_ext_memsize() : return the extended memory size in KB.
* BIOS call "INT 15H, AH=88H" to get extended memory size
* The return value in AX.
*
*/
static inline grub_uint16_t
grub_get_ext_memsize (void)
{
struct grub_bios_int_registers regs;
regs.eax = 0x8800;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x15, &regs);
return regs.eax & 0xffff;
}
/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB
in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. If error, return zero.
BIOS call "INT 15H, AH=E801H" to get EISA memory map,
AX = memory between 1M and 16M in 1K parts.
BX = memory above 16M in 64K parts.
*/
static inline grub_uint32_t
grub_get_eisa_mmap (void)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
regs.eax = 0xe801;
grub_bios_interrupt (0x15, &regs);
if ((regs.eax & 0xff00) == 0x8600)
return 0;
return (regs.eax & 0xffff) | (regs.ebx << 16);
}
/*
*
* grub_get_mmap_entry(addr, cont) : address and old continuation value (zero to
* start), for the Query System Address Map BIOS call.
*
* Sets the first 4-byte int value of "addr" to the size returned by
* the call. If the call fails, sets it to zero.
*
* Returns: new (non-zero) continuation value, 0 if done.
*/
/* Get a memory map entry. Return next continuation value. Zero means
the end. */
static grub_uint32_t
grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
grub_uint32_t cont)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
/* place address (+4) in ES:DI */
regs.es = ((grub_addr_t) &entry->addr) >> 4;
regs.edi = ((grub_addr_t) &entry->addr) & 0xf;
/* set continuation value */
regs.ebx = cont;
/* set default maximum buffer size */
regs.ecx = sizeof (*entry) - sizeof (entry->size);
/* set EDX to 'SMAP' */
regs.edx = 0x534d4150;
regs.eax = 0xe820;
grub_bios_interrupt (0x15, &regs);
/* write length of buffer (zero if error) into ADDR */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) || regs.eax != 0x534d4150
|| regs.ecx < 0x14 || regs.ecx > 0x400)
entry->size = 0;
else
entry->size = regs.ecx;
/* return the continuation value */
return regs.ebx;
}
grub_err_t
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
{
@ -61,7 +148,7 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MACHINE_MEMORY_AVAILABLE);
}
else
hook (0x100000, grub_get_memsize (1) << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MACHINE_MEMORY_AVAILABLE);
}
return 0;

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,6 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/machine/boot.h>
#include <grub/types.h>
@ -68,6 +67,11 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
GRUB_MACHINE_MEMORY_AVAILABLE))
return 1;
if (hook ((grub_addr_t) _end,
0xa0000 - (grub_addr_t) _end,
GRUB_MACHINE_MEMORY_AVAILABLE))
return 1;
if (hook (GRUB_MEMORY_MACHINE_UPPER,
0x100000 - GRUB_MEMORY_MACHINE_UPPER,
GRUB_MACHINE_MEMORY_RESERVED))

View File

@ -39,7 +39,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
/* Relocate to low memory. First we figure out our location.
@ -94,6 +94,9 @@ codestart:
call EXT_C(grub_main)
/* This should never happen. */
jmp EXT_C(grub_stop)
cli
1:
hlt
jmp 1b
#include "../realmode.S"

View File

@ -423,14 +423,3 @@ grub_reboot (void)
for (;;) ;
}
#endif
void
grub_halt (void)
{
/* Not standardized. We try three known commands. */
grub_ieee1275_interpret ("shut-down", 0);
grub_ieee1275_interpret ("power-off", 0);
grub_ieee1275_interpret ("poweroff", 0);
for (;;) ;
}

View File

@ -154,7 +154,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
#ifdef GRUB_MACHINE_MIPS_YEELOONG
VARIABLE (grub_arch_busclock)
.long 0

View File

@ -184,6 +184,7 @@ grub_real_dprintf (const char *file, const int line, const char *condition,
va_start (args, fmt);
grub_vprintf (fmt, args);
va_end (args);
grub_refresh ();
}
}
@ -989,7 +990,7 @@ grub_abort (void)
grub_exit ();
}
#ifndef APPLE_CC
#if ! defined (APPLE_CC) && !defined (GRUB_UTIL)
/* GCC emits references to abort(). */
void abort (void) __attribute__ ((alias ("grub_abort")));
#endif

View File

@ -65,6 +65,7 @@
#include <grub/types.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/mm_private.h>
#ifdef MM_DEBUG
# undef grub_malloc
@ -74,45 +75,9 @@
# undef grub_memalign
#endif
/* Magic words. */
#define GRUB_MM_FREE_MAGIC 0x2d3c2808
#define GRUB_MM_ALLOC_MAGIC 0x6db08fa4
typedef struct grub_mm_header
{
struct grub_mm_header *next;
grub_size_t size;
grub_size_t magic;
#if GRUB_CPU_SIZEOF_VOID_P == 4
char padding[4];
#elif GRUB_CPU_SIZEOF_VOID_P == 8
char padding[8];
#else
# error "unknown word size"
#endif
}
*grub_mm_header_t;
#if GRUB_CPU_SIZEOF_VOID_P == 4
# define GRUB_MM_ALIGN_LOG2 4
#elif GRUB_CPU_SIZEOF_VOID_P == 8
# define GRUB_MM_ALIGN_LOG2 5
#endif
#define GRUB_MM_ALIGN (1 << GRUB_MM_ALIGN_LOG2)
typedef struct grub_mm_region
{
struct grub_mm_header *first;
struct grub_mm_region *next;
grub_addr_t addr;
grub_size_t size;
}
*grub_mm_region_t;
static grub_mm_region_t base;
grub_mm_region_t grub_mm_base;
/* Get a header from the pointer PTR, and set *P and *R to a pointer
to the header and a pointer to its region, respectively. PTR must
@ -123,9 +88,9 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
if ((grub_addr_t) ptr & (GRUB_MM_ALIGN - 1))
grub_fatal ("unaligned pointer %p", ptr);
for (*r = base; *r; *r = (*r)->next)
if ((grub_addr_t) ptr > (*r)->addr
&& (grub_addr_t) ptr <= (*r)->addr + (*r)->size)
for (*r = grub_mm_base; *r; *r = (*r)->next)
if ((grub_addr_t) ptr > (grub_addr_t) ((*r) + 1)
&& (grub_addr_t) ptr <= (grub_addr_t) ((*r) + 1) + (*r)->size)
break;
if (! *r)
@ -156,18 +121,18 @@ grub_mm_init_region (void *addr, grub_size_t size)
if (size < GRUB_MM_ALIGN)
return;
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
h = (grub_mm_header_t) (r + 1);
h->next = h;
h->magic = GRUB_MM_FREE_MAGIC;
h->size = (size >> GRUB_MM_ALIGN_LOG2);
r->first = h;
r->addr = (grub_addr_t) h;
r->pre_size = (grub_addr_t) r - (grub_addr_t) addr;
r->size = (h->size << GRUB_MM_ALIGN_LOG2);
/* Find where to insert this region. Put a smaller one before bigger ones,
to prevent fragmentation. */
for (p = &base, q = *p; q; p = &(q->next), q = *p)
for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p)
if (q->size > r->size)
break;
@ -206,6 +171,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
if (p->size >= n + extra)
{
extra += (p->size - extra - n) & (~(align - 1));
if (extra == 0 && p->size == n)
{
/* There is no special alignment requirement and memory block
@ -284,10 +250,10 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
r = p + extra + n;
r->magic = GRUB_MM_FREE_MAGIC;
r->size = p->size - extra - n;
r->next = p->next;
r->next = p;
p->size = extra;
p->next = r;
q->next = r;
p += extra;
}
@ -318,13 +284,16 @@ grub_memalign (grub_size_t align, grub_size_t size)
grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
int count = 0;
if (!grub_mm_base)
goto fail;
align = (align >> GRUB_MM_ALIGN_LOG2);
if (align == 0)
align = 1;
again:
for (r = base; r; r = r->next)
for (r = grub_mm_base; r; r = r->next)
{
void *p;
@ -352,6 +321,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
break;
}
fail:
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
return 0;
}
@ -485,7 +455,7 @@ grub_mm_dump_free (void)
{
grub_mm_region_t r;
for (r = base; r; r = r->next)
for (r = grub_mm_base; r; r = r->next)
{
grub_mm_header_t p;
@ -512,13 +482,13 @@ grub_mm_dump (unsigned lineno)
grub_mm_region_t r;
grub_printf ("called at line %u\n", lineno);
for (r = base; r; r = r->next)
for (r = grub_mm_base; r; r = r->next)
{
grub_mm_header_t p;
for (p = (grub_mm_header_t) ((r->addr + GRUB_MM_ALIGN - 1)
& (~(GRUB_MM_ALIGN - 1)));
(grub_addr_t) p < r->addr + r->size;
for (p = (grub_mm_header_t) ALIGN_UP ((grub_addr_t) (r + 1),
GRUB_MM_ALIGN);
(grub_addr_t) p < (grub_addr_t) (r+1) + r->size;
p++)
{
switch (p->magic)

View File

@ -1,7 +1,7 @@
/* cache.S - Flush the processor cache for a specific region. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2007 Free Software Foundation, Inc.
* Copyright (C) 2004,2007,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,32 +17,10 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#define CACHE_LINE_BYTES 32
.text
.align 2
.globl grub_arch_sync_caches
grub_arch_sync_caches:
/* `address' may not be CACHE_LINE_BYTES-aligned. */
andi. 6, 3, CACHE_LINE_BYTES - 1 /* Find the misalignment. */
add 4, 4, 6 /* Adjust `size' to compensate. */
/* Force the dcache lines to memory. */
li 5, 0
1: dcbst 5, 3
addi 5, 5, CACHE_LINE_BYTES
cmpw 5, 4
blt 1b
sync /* Force all dcbsts to complete. */
/* Invalidate the icache lines. */
li 5, 0
1: icbi 5, 3
addi 5, 5, CACHE_LINE_BYTES
cmpw 5, 4
blt 1b
sync /* Force all icbis to complete. */
isync /* Discard partially executed instructions that were
loaded from the invalid icache. */
#include "cache_flush.S"
blr

View File

@ -0,0 +1,43 @@
/* cache.S - Flush the processor cache for a specific region. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2007,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#undef CACHE_LINE_BYTES
#define CACHE_LINE_BYTES 32
/* `address' may not be CACHE_LINE_BYTES-aligned. */
andi. 6, 3, CACHE_LINE_BYTES - 1 /* Find the misalignment. */
add 4, 4, 6 /* Adjust `size' to compensate. */
/* Force the dcache lines to memory. */
li 5, 0
1: dcbst 5, 3
addi 5, 5, CACHE_LINE_BYTES
cmpw 5, 4
blt 1b
sync /* Force all dcbsts to complete. */
/* Invalidate the icache lines. */
li 5, 0
1: icbi 5, 3
addi 5, 5, CACHE_LINE_BYTES
cmpw 5, 4
blt 1b
sync /* Force all icbis to complete. */
isync /* Discard partially executed instructions that were
loaded from the invalid icache. */

View File

@ -39,7 +39,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
li 2, 0

View File

@ -42,7 +42,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_DATA_END
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
/* Copy the modules past the end of the kernel image.

View File

@ -209,8 +209,16 @@ parse_option (grub_extcmd_t cmd, int key, char *arg, struct grub_arg_list *usr)
if (found == -1)
return -1;
usr[found].set = 1;
usr[found].arg = arg;
if (opt->flags & GRUB_ARG_OPTION_REPEATABLE)
{
usr[found].args[usr[found].set++] = arg;
usr[found].args[usr[found].set] = NULL;
}
else
{
usr[found].set = 1;
usr[found].arg = arg;
}
}
}
@ -230,10 +238,15 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
grub_err_t add_arg (char *s)
{
argl = grub_realloc (argl, (++num) * sizeof (char *));
char **p = argl;
argl = grub_realloc (argl, (++num + 1) * sizeof (char *));
if (! argl)
return grub_errno;
{
grub_free (p);
return grub_errno;
}
argl[num - 1] = s;
argl[num] = NULL;
return 0;
}
@ -310,8 +323,11 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (option) {
arglen = option - arg - 2;
option++;
} else
} else {
arglen = grub_strlen (arg) - 2;
if (argv[curarg + 1])
option = argv[curarg + 1][0] == '-' ? 0 : argv[++curarg];
}
opt = find_long (cmd->options, arg + 2, arglen);
if (! opt)
@ -390,3 +406,43 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
fail:
return complete;
}
struct grub_arg_list*
grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
char **argv __attribute__((unused)))
{
int i;
char **args;
unsigned argcnt;
struct grub_arg_list *list;
const struct grub_arg_option *options;
options = extcmd->options;
if (! options)
return 0;
argcnt = 0;
for (i = 0; options[i].doc; i++)
{
if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
argcnt += (argc + 1) / 2 + 1; /* max possible for any option */
}
list = grub_zalloc (sizeof (*list) * i + sizeof (char*) * argcnt);
if (! list)
return 0;
args = (char**) (list + i);
for (i = 0; options[i].doc; i++)
{
list[i].set = 0;
list[i].arg = 0;
if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
{
list[i].args = args;
args += argc / 2 + 1;
}
}
return list;
}

View File

@ -1,6 +1,7 @@
/* efi.c - generic EFI support */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2004,2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,7 +17,18 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_LOADER_MACHINE_HEADER
#define GRUB_LOADER_MACHINE_HEADER 1
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/kernel.h>
#endif /* ! GRUB_LOADER_MACHINE_HEADER */
void
grub_halt (void)
{
grub_machine_fini ();
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
while (1);
}

View File

@ -0,0 +1,104 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/relocator.h>
#include <grub/relocator_private.h>
#include <grub/memory.h>
#include <grub/efi/efi.h>
#include <grub/efi/api.h>
#include <grub/term.h>
#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
unsigned
grub_relocator_firmware_get_max_events (void)
{
grub_efi_uintn_t mmapsize = 0, descriptor_size = 0;
grub_efi_uint32_t descriptor_version = 0;
grub_efi_uintn_t key;
grub_efi_get_memory_map (&mmapsize, NULL, &key, &descriptor_size,
&descriptor_version);
/* Since grub_relocator_firmware_fill_events uses malloc
we need some reserve. Hence +10. */
return 2 * (mmapsize / descriptor_size + 10);
}
unsigned
grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events)
{
grub_efi_uintn_t mmapsize = 0, desc_size = 0;
grub_efi_uint32_t descriptor_version = 0;
grub_efi_memory_descriptor_t *descs = NULL;
grub_efi_uintn_t key;
int counter = 0;
grub_efi_memory_descriptor_t *desc;
grub_efi_get_memory_map (&mmapsize, NULL, &key, &desc_size,
&descriptor_version);
descs = grub_malloc (mmapsize);
if (!descs)
return 0;
grub_efi_get_memory_map (&mmapsize, descs, &key, &desc_size,
&descriptor_version);
for (desc = descs;
(char *) desc < ((char *) descs + mmapsize);
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
{
if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
continue;
events[counter].type = REG_FIRMWARE_START;
events[counter].pos = desc->physical_start;
counter++;
events[counter].type = REG_FIRMWARE_END;
events[counter].pos = desc->physical_start + (desc->num_pages << 12);
counter++;
}
return counter;
}
int
grub_relocator_firmware_alloc_region (grub_addr_t start, grub_size_t size)
{
grub_efi_boot_services_t *b;
grub_efi_physical_address_t address = start;
grub_efi_status_t status;
if (grub_efi_is_finished)
return 1;
b = grub_efi_system_table->boot_services;
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ADDRESS,
GRUB_EFI_LOADER_DATA, size >> 12, &address);
return (status == GRUB_EFI_SUCCESS);
}
void
grub_relocator_firmware_free_region (grub_addr_t start, grub_size_t size)
{
grub_efi_boot_services_t *b;
if (grub_efi_is_finished)
return;
b = grub_efi_system_table->boot_services;
efi_call_2 (b->free_pages, start, size >> 12);
}

View File

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,9 +16,10 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_MACHINE_EFI_EMU_HEADER
#define GRUB_MACHINE_EFI_EMU_HEADER 1
#include <grub/misc.h>
grub_err_t grub_machine_efiemu_init_tables (void);
#endif
void
grub_halt (void)
{
grub_reboot ();
}

View File

@ -17,11 +17,24 @@
*/
#include <grub/cpu/io.h>
#include <grub/machine/init.h>
#include <grub/misc.h>
const char bochs_shutdown[] = "Shutdown";
/*
* This call is special... it never returns... in fact it should simply
* hang at this point!
*/
static inline void __attribute__ ((noreturn))
stop (void)
{
asm volatile ("cli");
while (1)
{
asm volatile ("hlt");
}
}
void
grub_halt (void)
{
@ -38,5 +51,5 @@ grub_halt (void)
/* In order to return we'd have to check what the previous status of IF
flag was. But user most likely doesn't want to return anyway ... */
grub_stop ();
stop ();
}

View File

@ -19,84 +19,252 @@
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/types.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/term.h>
#include <grub/i386/relocator.h>
#include <grub/relocator_private.h>
extern grub_uint8_t grub_relocator32_forward_start;
extern grub_uint8_t grub_relocator32_forward_end;
extern grub_uint8_t grub_relocator32_backward_start;
extern grub_uint8_t grub_relocator32_backward_end;
extern grub_uint8_t grub_relocator_forward_start;
extern grub_uint8_t grub_relocator_forward_end;
extern grub_uint8_t grub_relocator_backward_start;
extern grub_uint8_t grub_relocator_backward_end;
extern grub_uint32_t grub_relocator32_backward_dest;
extern grub_uint32_t grub_relocator32_backward_size;
extern grub_addr_t grub_relocator32_backward_src;
extern void *grub_relocator_backward_dest;
extern void *grub_relocator_backward_src;
extern grub_size_t grub_relocator_backward_chunk_size;
extern grub_uint32_t grub_relocator32_forward_dest;
extern grub_uint32_t grub_relocator32_forward_size;
extern grub_addr_t grub_relocator32_forward_src;
extern void *grub_relocator_forward_dest;
extern void *grub_relocator_forward_src;
extern grub_size_t grub_relocator_forward_chunk_size;
extern grub_uint32_t grub_relocator32_forward_eax;
extern grub_uint32_t grub_relocator32_forward_ebx;
extern grub_uint32_t grub_relocator32_forward_ecx;
extern grub_uint32_t grub_relocator32_forward_edx;
extern grub_uint32_t grub_relocator32_forward_eip;
extern grub_uint32_t grub_relocator32_forward_esp;
extern grub_uint8_t grub_relocator16_start;
extern grub_uint8_t grub_relocator16_end;
extern grub_uint16_t grub_relocator16_cs;
extern grub_uint16_t grub_relocator16_ip;
extern grub_uint16_t grub_relocator16_ds;
extern grub_uint16_t grub_relocator16_es;
extern grub_uint16_t grub_relocator16_fs;
extern grub_uint16_t grub_relocator16_gs;
extern grub_uint16_t grub_relocator16_ss;
extern grub_uint16_t grub_relocator16_sp;
extern grub_uint32_t grub_relocator16_edx;
extern grub_uint32_t grub_relocator32_backward_eax;
extern grub_uint32_t grub_relocator32_backward_ebx;
extern grub_uint32_t grub_relocator32_backward_ecx;
extern grub_uint32_t grub_relocator32_backward_edx;
extern grub_uint32_t grub_relocator32_backward_eip;
extern grub_uint32_t grub_relocator32_backward_esp;
extern grub_uint8_t grub_relocator32_start;
extern grub_uint8_t grub_relocator32_end;
extern grub_uint32_t grub_relocator32_eax;
extern grub_uint32_t grub_relocator32_ebx;
extern grub_uint32_t grub_relocator32_ecx;
extern grub_uint32_t grub_relocator32_edx;
extern grub_uint32_t grub_relocator32_eip;
extern grub_uint32_t grub_relocator32_esp;
extern grub_uint32_t grub_relocator32_ebp;
extern grub_uint32_t grub_relocator32_esi;
extern grub_uint32_t grub_relocator32_edi;
#define RELOCATOR_SIZEOF(x) (&grub_relocator32_##x##_end - &grub_relocator32_##x##_start)
#define RELOCATOR_ALIGN 16
#define PREFIX(x) grub_relocator32_ ## x
extern grub_uint8_t grub_relocator64_start;
extern grub_uint8_t grub_relocator64_end;
extern grub_uint64_t grub_relocator64_rax;
extern grub_uint64_t grub_relocator64_rbx;
extern grub_uint64_t grub_relocator64_rcx;
extern grub_uint64_t grub_relocator64_rdx;
extern grub_uint64_t grub_relocator64_rip;
extern grub_uint64_t grub_relocator64_rip_addr;
extern grub_uint64_t grub_relocator64_rsp;
extern grub_uint64_t grub_relocator64_rsi;
extern grub_addr_t grub_relocator64_cr3;
static void
write_call_relocator_bw (void *ptr, void *src, grub_uint32_t dest,
grub_size_t size, struct grub_relocator32_state state)
#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
grub_size_t grub_relocator_align = 1;
grub_size_t grub_relocator_forward_size;
grub_size_t grub_relocator_backward_size;
#ifdef __x86_64__
grub_size_t grub_relocator_jumper_size = 12;
#else
grub_size_t grub_relocator_jumper_size = 7;
#endif
void
grub_cpu_relocator_init (void)
{
grub_relocator32_backward_dest = dest;
grub_relocator32_backward_src = PTR_TO_UINT64 (src);
grub_relocator32_backward_size = size;
grub_relocator32_backward_eax = state.eax;
grub_relocator32_backward_ebx = state.ebx;
grub_relocator32_backward_ecx = state.ecx;
grub_relocator32_backward_edx = state.edx;
grub_relocator32_backward_eip = state.eip;
grub_relocator32_backward_esp = state.esp;
grub_memmove (ptr,
&grub_relocator32_backward_start,
RELOCATOR_SIZEOF (backward));
((void (*) (void)) ptr) ();
grub_relocator_forward_size = RELOCATOR_SIZEOF(_forward);
grub_relocator_backward_size = RELOCATOR_SIZEOF(_backward);
}
static void
write_call_relocator_fw (void *ptr, void *src, grub_uint32_t dest,
grub_size_t size, struct grub_relocator32_state state)
void
grub_cpu_relocator_jumper (void *rels, grub_addr_t addr)
{
grub_relocator32_forward_dest = dest;
grub_relocator32_forward_src = PTR_TO_UINT64 (src);
grub_relocator32_forward_size = size;
grub_relocator32_forward_eax = state.eax;
grub_relocator32_forward_ebx = state.ebx;
grub_relocator32_forward_ecx = state.ecx;
grub_relocator32_forward_edx = state.edx;
grub_relocator32_forward_eip = state.eip;
grub_relocator32_forward_esp = state.esp;
grub_memmove (ptr,
&grub_relocator32_forward_start,
RELOCATOR_SIZEOF (forward));
((void (*) (void)) ptr) ();
grub_uint8_t *ptr;
ptr = rels;
#ifdef __x86_64__
/* movq imm64, %rax (for relocator) */
*(grub_uint8_t *) ptr = 0x48;
ptr++;
*(grub_uint8_t *) ptr = 0xb8;
ptr++;
*(grub_uint64_t *) ptr = addr;
ptr += sizeof (grub_uint64_t);
#else
/* movl imm32, %eax (for relocator) */
*(grub_uint8_t *) ptr = 0xb8;
ptr++;
*(grub_uint32_t *) ptr = addr;
ptr += sizeof (grub_uint32_t);
#endif
/* jmp $eax/$rax */
*(grub_uint8_t *) ptr = 0xff;
ptr++;
*(grub_uint8_t *) ptr = 0xe0;
ptr++;
}
#include "../relocator.c"
void
grub_cpu_relocator_backward (void *ptr, void *src, void *dest,
grub_size_t size)
{
grub_relocator_backward_dest = dest;
grub_relocator_backward_src = src;
grub_relocator_backward_chunk_size = size;
grub_memmove (ptr,
&grub_relocator_backward_start,
RELOCATOR_SIZEOF (_backward));
}
void
grub_cpu_relocator_forward (void *ptr, void *src, void *dest,
grub_size_t size)
{
grub_relocator_forward_dest = dest;
grub_relocator_forward_src = src;
grub_relocator_forward_chunk_size = size;
grub_memmove (ptr,
&grub_relocator_forward_start,
RELOCATOR_SIZEOF (_forward));
}
grub_err_t
grub_relocator32_boot (struct grub_relocator *rel,
struct grub_relocator32_state state)
{
grub_err_t err;
void *relst;
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
(0xffffffff - RELOCATOR_SIZEOF (32))
+ 1, RELOCATOR_SIZEOF (32), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
if (err)
return err;
grub_relocator32_eax = state.eax;
grub_relocator32_ebx = state.ebx;
grub_relocator32_ecx = state.ecx;
grub_relocator32_edx = state.edx;
grub_relocator32_eip = state.eip;
grub_relocator32_esp = state.esp;
grub_relocator32_ebp = state.ebp;
grub_relocator32_esi = state.esi;
grub_relocator32_edi = state.edi;
grub_memmove (get_virtual_current_address (ch), &grub_relocator32_start,
RELOCATOR_SIZEOF (32));
err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
&relst, NULL);
if (err)
return err;
asm volatile ("cli");
((void (*) (void)) relst) ();
/* Not reached. */
return GRUB_ERR_NONE;
}
grub_err_t
grub_relocator16_boot (struct grub_relocator *rel,
struct grub_relocator16_state state)
{
grub_err_t err;
void *relst;
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
0xa0000 - RELOCATOR_SIZEOF (16),
RELOCATOR_SIZEOF (16), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
if (err)
return err;
grub_relocator16_cs = state.cs;
grub_relocator16_ip = state.ip;
grub_relocator16_ds = state.ds;
grub_relocator16_es = state.es;
grub_relocator16_fs = state.fs;
grub_relocator16_gs = state.gs;
grub_relocator16_ss = state.ss;
grub_relocator16_sp = state.sp;
grub_relocator16_edx = state.edx;
grub_memmove (get_virtual_current_address (ch), &grub_relocator16_start,
RELOCATOR_SIZEOF (16));
err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
&relst, NULL);
if (err)
return err;
asm volatile ("cli");
((void (*) (void)) relst) ();
/* Not reached. */
return GRUB_ERR_NONE;
}
grub_err_t
grub_relocator64_boot (struct grub_relocator *rel,
struct grub_relocator64_state state,
grub_addr_t min_addr, grub_addr_t max_addr)
{
grub_err_t err;
void *relst;
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (rel, &ch, min_addr,
max_addr - RELOCATOR_SIZEOF (64),
RELOCATOR_SIZEOF (64), 16,
GRUB_RELOCATOR_PREFERENCE_NONE);
if (err)
return err;
grub_relocator64_rax = state.rax;
grub_relocator64_rbx = state.rbx;
grub_relocator64_rcx = state.rcx;
grub_relocator64_rdx = state.rdx;
grub_relocator64_rip = state.rip;
grub_relocator64_rsp = state.rsp;
grub_relocator64_rsi = state.rsi;
grub_relocator64_cr3 = state.cr3;
grub_memmove (get_virtual_current_address (ch), &grub_relocator64_start,
RELOCATOR_SIZEOF (64));
err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
&relst, NULL);
if (err)
return err;
asm volatile ("cli");
((void (*) (void)) relst) ();
/* Not reached. */
return GRUB_ERR_NONE;
}

View File

@ -0,0 +1,193 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/* The code segment of the protected mode. */
#define CODE_SEGMENT 0x08
/* The data segment of the protected mode. */
#define DATA_SEGMENT 0x10
#define PSEUDO_REAL_CSEG 0x18
#define PSEUDO_REAL_DSEG 0x20
#include "relocator_common.S"
.p2align 4 /* force 16-byte alignment */
VARIABLE(grub_relocator16_start)
PREAMBLE
movl %esi, %eax
movw %ax, (LOCAL (cs_base_bytes12) - LOCAL (base)) (RSI, 1)
shrl $16, %eax
movb %al, (LOCAL (cs_base_byte3) - LOCAL (base)) (RSI, 1)
RELOAD_GDT
.code32
/* Update other registers. */
movl $DATA_SEGMENT, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
DISABLE_PAGING
#ifdef __x86_64__
/* Disable amd64. */
movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
rdmsr
andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
wrmsr
#endif
/* Turn off PAE. */
movl %cr4, %eax
andl $(~GRUB_MEMORY_CPU_CR4_PAE_ON), %eax
movl %eax, %cr4
/* Update other registers. */
movl $PSEUDO_REAL_DSEG, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
movl %esi, %eax
shrl $4, %eax
movw %ax, (LOCAL (segment) - LOCAL (base)) (%esi, 1)
/* jump to a 16 bit segment */
ljmp $PSEUDO_REAL_CSEG, $(LOCAL (cont2) - LOCAL(base))
LOCAL(cont2):
.code16
/* clear the PE bit of CR0 */
movl %cr0, %eax
andl $(~GRUB_MEMORY_CPU_CR0_PE_ON), %eax
movl %eax, %cr0
/* flush prefetch queue, reload %cs */
/* ljmp */
.byte 0xea
.word LOCAL(cont3)-LOCAL(base)
LOCAL(segment):
.word 0
LOCAL(cont3):
/* we are in real mode now
* set up the real mode segment registers : DS, SS, ES
*/
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_ds)
.word 0
movw %ax, %ds
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_es)
.word 0
movw %ax, %es
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_fs)
.word 0
movw %ax, %fs
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_gs)
.word 0
movw %ax, %gs
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_ss)
.word 0
movw %ax, %ss
/* movw imm16, %ax. */
.byte 0xb8
VARIABLE(grub_relocator16_sp)
.word 0
movw %ax, %ss
/* movw imm32, %edx. */
.byte 0x66, 0xba
VARIABLE(grub_relocator16_edx)
.long 0
/* Cleared direction flag is of no problem with any current
payload and makes this implementation easier. */
cld
/* ljmp */
.byte 0xea
VARIABLE(grub_relocator16_ip)
.word 0
VARIABLE(grub_relocator16_cs)
.word 0
.code32
/* GDT. Copied from loader/i386/linux.c. */
.p2align 4
LOCAL(gdt):
.word 0, 0
.byte 0, 0, 0, 0
/* -- code segment --
* base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
* type = 32bit code execute/read, DPL = 0
*/
.word 0xFFFF, 0
.byte 0, 0x9A, 0xCF, 0
/* -- data segment --
* base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
* type = 32 bit data read/write, DPL = 0
*/
.word 0xFFFF, 0
.byte 0, 0x92, 0xCF, 0
/* -- 16 bit real mode CS --
* base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
* type = 16 bit code execute/read only/conforming, DPL = 0
*/
.word 0xFFFF
LOCAL(cs_base_bytes12):
.word 0
LOCAL(cs_base_byte3):
.byte 0
.byte 0x9E, 0, 0
/* -- 16 bit real mode DS --
* base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
* type = 16 bit data read/write, DPL = 0
*/
.word 0xFFFF, 0
.byte 0, 0x92, 0, 0
LOCAL(gdt_end):
VARIABLE(grub_relocator16_end)

View File

@ -0,0 +1,134 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/* The code segment of the protected mode. */
#define CODE_SEGMENT 0x10
/* The data segment of the protected mode. */
#define DATA_SEGMENT 0x18
#include "relocator_common.S"
.p2align 4 /* force 16-byte alignment */
VARIABLE(grub_relocator32_start)
PREAMBLE
RELOAD_GDT
.code32
/* Update other registers. */
movl $DATA_SEGMENT, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
DISABLE_PAGING
#ifdef __x86_64__
/* Disable amd64. */
movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
rdmsr
andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
wrmsr
#endif
/* Turn off PAE. */
movl %cr4, %eax
andl $(~GRUB_MEMORY_CPU_CR4_PAE_ON), %eax
movl %eax, %cr4
jmp LOCAL(cont2)
LOCAL(cont2):
.code32
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator32_esp)
.long 0
movl %eax, %esp
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator32_ebp)
.long 0
movl %eax, %ebp
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator32_esi)
.long 0
movl %eax, %esi
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator32_edi)
.long 0
movl %eax, %edi
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator32_eax)
.long 0
/* mov imm32, %ebx */
.byte 0xbb
VARIABLE(grub_relocator32_ebx)
.long 0
/* mov imm32, %ecx */
.byte 0xb9
VARIABLE(grub_relocator32_ecx)
.long 0
/* mov imm32, %edx */
.byte 0xba
VARIABLE(grub_relocator32_edx)
.long 0
/* Cleared direction flag is of no problem with any current
payload and makes this implementation easier. */
cld
.byte 0xea
VARIABLE(grub_relocator32_eip)
.long 0
.word CODE_SEGMENT
/* GDT. Copied from loader/i386/linux.c. */
.p2align 4
LOCAL(gdt):
/* NULL. */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/* Reserved. */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/* Code segment. */
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
/* Data segment. */
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
LOCAL(gdt_end):
VARIABLE(grub_relocator32_end)

View File

@ -0,0 +1,160 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#define CODE32_SEGMENT 0x18
#define CODE_SEGMENT 0x08
/* The data segment of the protected mode. */
#define DATA_SEGMENT 0x10
#include "relocator_common.S"
.p2align 4 /* force 16-byte alignment */
VARIABLE(grub_relocator64_start)
PREAMBLE
#ifndef __x86_64__
DISABLE_PAGING
/* Turn on PAE. */
movl %cr4, %eax
orl $(GRUB_MEMORY_CPU_CR4_PAE_ON | GRUB_MEMORY_CPU_CR4_PSE_ON), %eax
movl %eax, %cr4
/* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator64_cr3)
.long 0
movl %eax, %cr3
/* Turn on amd64. */
movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
rdmsr
orl $GRUB_MEMORY_CPU_AMD64_MSR_ON, %eax
wrmsr
/* Enable paging. */
movl %cr0, %eax
orl $GRUB_MEMORY_CPU_CR0_PAGING_ON, %eax
movl %eax, %cr0
RELOAD_GDT
#else
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator64_cr3)
.quad 0
movq %rax, %cr3
#endif
.code64
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator64_rsp)
.quad 0
movq %rax, %rsp
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator64_rsi)
.quad 0
movq %rax, %rsi
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator64_rax)
.quad 0
/* mov imm64, %rbx */
.byte 0x48
.byte 0xbb
VARIABLE(grub_relocator64_rbx)
.quad 0
/* mov imm64, %rcx */
.byte 0x48
.byte 0xb9
VARIABLE(grub_relocator64_rcx)
.quad 0
/* mov imm64, %rdx */
.byte 0x48
.byte 0xba
VARIABLE(grub_relocator64_rdx)
.quad 0
/* Cleared direction flag is of no problem with any current
payload and makes this implementation easier. */
cld
jmp *LOCAL(jump_addr) (%rip)
LOCAL(jump_addr):
VARIABLE(grub_relocator64_rip)
.quad 0
#ifndef __x86_64__
.p2align 4
LOCAL(gdt):
/* NULL. */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/* 64-bit segment. */
.word 0xffff /* Limit xffff. */
.word 0x0000 /* Base xxxx0000. */
.byte 0x00 /* Base xx00xxxx. */
.byte (0x8 /* Type 8. */ | (1 << 4) /* Code. */ \
| (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
.byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
| (1 << 5) /* 64-bit. */ | (0 << 6) \
| (1 << 7) /* 4K granular. */)
.byte 0x00 /* Base 00xxxxxx. */
/* Data segment*/
.word 0xffff /* Limit xffff. */
.word 0x0000 /* Base xxxx0000. */
.byte 0x00 /* Base xx00xxxx. */
.byte (0x0 /* Type 0. */ | (0 << 4) /* Data. */ \
| (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
.byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
| (0 << 5) /* Data. */ | (0 << 6) \
| (1 << 7) /* 4K granular. */)
.byte 0x00 /* Base 00xxxxxx. */
/* Compatibility segment. */
.word 0xffff /* Limit xffff. */
.word 0x0000 /* Base xxxx0000. */
.byte 0x00 /* Base xx00xxxx. */
.byte (0x8 /* Type 8. */ | (1 << 4) /* Code. */ \
| (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
.byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
| (0 << 5) /* 32-bit. */ | (1 << 6) /* 32-bit. */ \
| (1 << 7) /* 4K granular. */)
.byte 0x00 /* Base 00xxxxxx. */
LOCAL(gdt_end):
#endif
VARIABLE(grub_relocator64_end)

View File

@ -19,232 +19,62 @@
#include <grub/symbol.h>
#include <grub/i386/memory.h>
#ifdef BACKWARD
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_backward_ ## x)
#else
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_forward_ ## x)
#endif
#ifdef __x86_64__
#define RAX %rax
#define RCX %rcx
#define RDI %rdi
#define RSI %rdi
#else
#define RAX %eax
#define RCX %ecx
#define RDI %edi
#define RSI %esi
#endif
.p2align 2
/* The code segment of the protected mode. */
#define CODE_SEGMENT 0x10
/* The data segment of the protected mode. */
#define DATA_SEGMENT 0x18
.p2align 4 /* force 16-byte alignment */
RELOCATOR_VARIABLE(start)
#ifdef BACKWARD
LOCAL(base):
#endif
cli
#ifndef __x86_64__
VARIABLE(grub_relocator_backward_start)
/* mov imm32, %eax */
.byte 0xb8
RELOCATOR_VARIABLE(dest)
VARIABLE(grub_relocator_backward_dest)
.long 0
movl %eax, %edi
/* mov imm32, %eax */
.byte 0xb8
RELOCATOR_VARIABLE(src)
VARIABLE(grub_relocator_backward_src)
.long 0
movl %eax, %esi
/* mov imm32, %ecx */
.byte 0xb9
RELOCATOR_VARIABLE(size)
VARIABLE(grub_relocator_backward_chunk_size)
.long 0
#else
xorq %rax, %rax
/* mov imm32, %eax */
.byte 0xb8
RELOCATOR_VARIABLE(dest)
.long 0
movq %rax, %rdi
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
RELOCATOR_VARIABLE(src)
.long 0, 0
movq %rax, %rsi
xorq %rcx, %rcx
/* mov imm32, %ecx */
.byte 0xb9
RELOCATOR_VARIABLE(size)
.long 0
#endif
mov RDI, RAX
#ifdef BACKWARD
add RCX, RSI
add RCX, RDI
#endif
#ifndef BACKWARD
add RCX, RAX
#endif
add $0x3, RCX
shr $2, RCX
add %ecx, %esi
add %ecx, %edi
#ifdef BACKWARD
/* Backward movsl is implicitly off-by-four. compensate that. */
sub $4, RSI
sub $4, RDI
/* Backward movsb is implicitly off-by-one. compensate that. */
sub $1, %esi
sub $1, %edi
/* Backward copy. */
std
rep
movsl
movsb
VARIABLE(grub_relocator_backward_end)
#else
/* Forward copy. */
cld
rep
movsl
#endif
/* %rax contains now our new 'base'. */
mov RAX, RSI
add $(LOCAL(cont0) - LOCAL(base)), RAX
jmp *RAX
LOCAL(cont0):
lea (LOCAL(cont1) - LOCAL(base)) (RSI, 1), RAX
movl %eax, (LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
lea (LOCAL(gdt) - LOCAL(base)) (RSI, 1), RAX
mov RAX, (LOCAL(gdt_addr) - LOCAL(base)) (RSI, 1)
/* Switch to compatibility mode. */
lgdt (LOCAL(gdtdesc) - LOCAL(base)) (RSI, 1)
/* Update %cs. */
ljmp *(LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
LOCAL(cont1):
.code32
/* Update other registers. */
movl $DATA_SEGMENT, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
/* Disable paging. */
movl %cr0, %eax
andl $(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
movl %eax, %cr0
#ifdef __x86_64__
/* Disable amd64. */
movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
rdmsr
andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
wrmsr
#endif
/* Turn off PAE. */
movl %cr4, %eax
andl $GRUB_MEMORY_CPU_CR4_PAE_ON, %eax
movl %eax, %cr4
jmp LOCAL(cont2)
LOCAL(cont2):
.code32
VARIABLE(grub_relocator_forward_start)
/* mov imm32, %eax */
.byte 0xb8
RELOCATOR_VARIABLE (esp)
VARIABLE(grub_relocator_forward_dest)
.long 0
movl %eax, %edi
movl %eax, %esp
/* mov imm32, %eax */
/* mov imm32, %rax */
.byte 0xb8
RELOCATOR_VARIABLE (eax)
.long 0
/* mov imm32, %ebx */
.byte 0xbb
RELOCATOR_VARIABLE (ebx)
VARIABLE(grub_relocator_forward_src)
.long 0
movl %eax, %esi
/* mov imm32, %ecx */
.byte 0xb9
RELOCATOR_VARIABLE (ecx)
VARIABLE(grub_relocator_forward_chunk_size)
.long 0
/* mov imm32, %edx */
.byte 0xba
RELOCATOR_VARIABLE (edx)
.long 0
/* Cleared direction flag is of no problem with any current
payload and makes this implementation easier. */
/* Forward copy. */
cld
.byte 0xea
RELOCATOR_VARIABLE (eip)
.long 0
.word CODE_SEGMENT
/* GDT. Copied from loader/i386/linux.c. */
.p2align 4
LOCAL(gdt):
/* NULL. */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/* Reserved. */
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/* Code segment. */
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
/* Data segment. */
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
.p2align 4
LOCAL(gdtdesc):
.word 0x27
LOCAL(gdt_addr):
#ifdef __x86_64__
/* Filled by the code. */
.quad 0
#else
/* Filled by the code. */
.long 0
#endif
.p2align 4
LOCAL(jump_vector):
/* Jump location. Is filled by the code */
.long 0
.long CODE_SEGMENT
#ifndef BACKWARD
LOCAL(base):
#endif
RELOCATOR_VARIABLE(end)
rep
movsb
VARIABLE(grub_relocator_forward_end)

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