mirror of
http://cgit.git.savannah.gnu.org/git/grub.git
synced 2026-04-28 14:33:34 +00:00
Compare commits
313 Commits
phcoder/po
...
phcoder/ar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a51e8e15 | ||
|
|
5ff249072d | ||
|
|
0277eab701 | ||
|
|
4861b6c851 | ||
|
|
3100cdc7f9 | ||
|
|
ad73cc3312 | ||
|
|
4182262560 | ||
|
|
896f483d49 | ||
|
|
8c534b85f1 | ||
|
|
a846dd4b3a | ||
|
|
aa437b5890 | ||
|
|
b0f311f412 | ||
|
|
59b38922a1 | ||
|
|
0480665b9d | ||
|
|
bbeee1c4a3 | ||
|
|
e5ed2f6947 | ||
|
|
4a73746a04 | ||
|
|
382b500ebe | ||
|
|
3a82f8bb48 | ||
|
|
e3046431da | ||
|
|
bdb6090d83 | ||
|
|
b73b70ebca | ||
|
|
8a3f0a24b5 | ||
|
|
6f07c4e407 | ||
|
|
60d5e9cbd9 | ||
|
|
cd15c394cc | ||
|
|
bb6e299ccb | ||
|
|
85eb579ad9 | ||
|
|
47f88cc94e | ||
|
|
40b5739ff9 | ||
|
|
234d93464a | ||
|
|
0c0eab527f | ||
|
|
44d4884779 | ||
|
|
10955cda06 | ||
|
|
f315b508ae | ||
|
|
9e4e6ddfbf | ||
|
|
5037aa9a7b | ||
|
|
8a952d20d1 | ||
|
|
b29b77fee2 | ||
|
|
be0d45555e | ||
|
|
d74b9a1d1a | ||
|
|
35de6d4bac | ||
|
|
ce55ed0389 | ||
|
|
f70ab525f9 | ||
|
|
9b70860ecc | ||
|
|
095588ef34 | ||
|
|
2dbda2215c | ||
|
|
53cc63bf85 | ||
|
|
471b2683e7 | ||
|
|
8ddf84bfb8 | ||
|
|
fd0df6d098 | ||
|
|
69ca97c820 | ||
|
|
eec893ae49 | ||
|
|
621e167fd6 | ||
|
|
d54f647a4a | ||
|
|
c8a0f1b229 | ||
|
|
726409a513 | ||
|
|
422e6e886c | ||
|
|
af1faca3f8 | ||
|
|
469021b4b3 | ||
|
|
83c256ba42 | ||
|
|
b67422d33d | ||
|
|
827d87e9d6 | ||
|
|
8f236c1419 | ||
|
|
2d76b4d81e | ||
|
|
4f9541226c | ||
|
|
b1f742c103 | ||
|
|
16ef26fd3a | ||
|
|
cf8c80ff77 | ||
|
|
5c7206e45e | ||
|
|
fc3f2b72cd | ||
|
|
34b2003def | ||
|
|
7e90f5ad25 | ||
|
|
ab4f15013a | ||
|
|
1e4b358720 | ||
|
|
9208367d3f | ||
|
|
67b9b7afd7 | ||
|
|
c2b70d0981 | ||
|
|
bee1b5ce3f | ||
|
|
07e3b04742 | ||
|
|
ebd289335a | ||
|
|
d2f7902af0 | ||
|
|
1005bed722 | ||
|
|
d6c92cdc34 | ||
|
|
61e1b9a49d | ||
|
|
c98dd165b0 | ||
|
|
ff1c277ef8 | ||
|
|
c8f7614b98 | ||
|
|
246a434f61 | ||
|
|
5c066a81c2 | ||
|
|
78f961efe9 | ||
|
|
09bc0a577d | ||
|
|
b700a427d2 | ||
|
|
4480b95dcd | ||
|
|
e77c81f6f8 | ||
|
|
971dbee521 | ||
|
|
6f2e82be3a | ||
|
|
9eec9699b9 | ||
|
|
5ae5c54c7e | ||
|
|
7b04fe6c9e | ||
|
|
e67566ce0a | ||
|
|
f93ddcfd1c | ||
|
|
1bba40f578 | ||
|
|
f65e14dc3a | ||
|
|
14a94bba6f | ||
|
|
8109c5d4e2 | ||
|
|
a92b5cb8d8 | ||
|
|
4a23e2fe29 | ||
|
|
a3ba74104e | ||
|
|
e1c22419ac | ||
|
|
189090cee9 | ||
|
|
1a5b7b404f | ||
|
|
9cf12b20af | ||
|
|
63a45330cb | ||
|
|
4a0aaad022 | ||
|
|
095bb1bfa5 | ||
|
|
3937bd962b | ||
|
|
ddb3efc906 | ||
|
|
4e42521d8c | ||
|
|
054efe541f | ||
|
|
a0e1befb57 | ||
|
|
c36c73f681 | ||
|
|
6f4a19f59f | ||
|
|
0d8f04cd83 | ||
|
|
4906052019 | ||
|
|
c6a823e267 | ||
|
|
b7f9aedfac | ||
|
|
7dd0a30361 | ||
|
|
ca120e31f2 | ||
|
|
48eb35cd78 | ||
|
|
7f20dbbcd2 | ||
|
|
55e706c918 | ||
|
|
4e7d433dfb | ||
|
|
7d44ff7de6 | ||
|
|
a8c3e5e3c7 | ||
|
|
4402db3ecc | ||
|
|
7960d3e182 | ||
|
|
8a07b55a04 | ||
|
|
d53f4900d7 | ||
|
|
d3def58c52 | ||
|
|
96fa2d9d02 | ||
|
|
2d6a38fbf7 | ||
|
|
bb2b275b7d | ||
|
|
45bf8b3a75 | ||
|
|
60870be86c | ||
|
|
39ff43c579 | ||
|
|
1bbb796799 | ||
|
|
74e632fea8 | ||
|
|
efb8de492a | ||
|
|
a1f00cc557 | ||
|
|
421db3da06 | ||
|
|
b7526e7806 | ||
|
|
b40ce65180 | ||
|
|
1e8e2e78a5 | ||
|
|
4d5b72cdb4 | ||
|
|
35c2851cc1 | ||
|
|
ea7c1a7d90 | ||
|
|
96adefdb12 | ||
|
|
5e3cb8a747 | ||
|
|
3bf4088b8b | ||
|
|
256ee7ac6a | ||
|
|
f8b4c3b6b3 | ||
|
|
4bf703206d | ||
|
|
a284320e1e | ||
|
|
2df8f43d3e | ||
|
|
6f1bc8bc0f | ||
|
|
04f39f6df8 | ||
|
|
35d4761ce2 | ||
|
|
33d02a42d6 | ||
|
|
7bbb60cfbd | ||
|
|
da93d6753b | ||
|
|
59c943ecf6 | ||
|
|
4336b5d85e | ||
|
|
44ce3a93b6 | ||
|
|
7d400406a7 | ||
|
|
77dae919b6 | ||
|
|
0ab8e025c1 | ||
|
|
b80c2d6d4b | ||
|
|
6aa6077bcc | ||
|
|
66c00cb159 | ||
|
|
3a129dba59 | ||
|
|
8df6eff6da | ||
|
|
889ebe922b | ||
|
|
d4d55b29e0 | ||
|
|
55e2c84fe3 | ||
|
|
15a463d742 | ||
|
|
cd46aa6cef | ||
|
|
9ef81064a3 | ||
|
|
11a7793221 | ||
|
|
080603f0b0 | ||
|
|
4f84ae0ec8 | ||
|
|
ab4366fd49 | ||
|
|
e6a6182d95 | ||
|
|
1a454efe89 | ||
|
|
deaa7052c5 | ||
|
|
7b5d51d837 | ||
|
|
593865b907 | ||
|
|
31c0cd4362 | ||
|
|
c2fdb33116 | ||
|
|
9e18dfe277 | ||
|
|
59ba9d147f | ||
|
|
23012db921 | ||
|
|
6fcec43954 | ||
|
|
a9f25a0819 | ||
|
|
c7995256e4 | ||
|
|
e1aa5b6620 | ||
|
|
da5ed5cf6b | ||
|
|
5757a93e01 | ||
|
|
deca601915 | ||
|
|
a5986276ec | ||
|
|
da45f43ce3 | ||
|
|
0de172a0c0 | ||
|
|
20aea9492f | ||
|
|
1326b9ae2a | ||
|
|
1fe26ab4a0 | ||
|
|
83e9c273e5 | ||
|
|
ec525c18e1 | ||
|
|
93fcc7ad73 | ||
|
|
1d912bd3c9 | ||
|
|
57ffe93485 | ||
|
|
5da5517288 | ||
|
|
2312f06c30 | ||
|
|
2416415c53 | ||
|
|
e6050a683c | ||
|
|
da7703286a | ||
|
|
f02e6b5675 | ||
|
|
035a26c16a | ||
|
|
bc8a6137b2 | ||
|
|
6fe506b04b | ||
|
|
81a2e438dc | ||
|
|
9b45c0733e | ||
|
|
11b2a9b70b | ||
|
|
d743d22de6 | ||
|
|
11da14b548 | ||
|
|
2bdd07195c | ||
|
|
5e77d9cfc1 | ||
|
|
7d5116251d | ||
|
|
81023dbdbd | ||
|
|
b2e9294fb9 | ||
|
|
16a22c3851 | ||
|
|
c9cd02c965 | ||
|
|
8149861554 | ||
|
|
ea57de18f8 | ||
|
|
d0d1e3dacb | ||
|
|
3809f0163b | ||
|
|
46d8a2033b | ||
|
|
c773faf05e | ||
|
|
513eeb61dd | ||
|
|
bc379c1aa1 | ||
|
|
286551b4eb | ||
|
|
16057d6bbb | ||
|
|
f649a6a8fd | ||
|
|
ef28ee8bc1 | ||
|
|
300f48c532 | ||
|
|
2d357558fb | ||
|
|
0c62a5b28e | ||
|
|
b0720b4988 | ||
|
|
d5bab2c0e1 | ||
|
|
3ea0ccb319 | ||
|
|
08772054e9 | ||
|
|
1dcb27157d | ||
|
|
61c22fdf36 | ||
|
|
431e57a797 | ||
|
|
b521bb816d | ||
|
|
7d06b24eac | ||
|
|
3bbeade41d | ||
|
|
ba82db7a0d | ||
|
|
801564c804 | ||
|
|
ac8cac1dac | ||
|
|
4b85f1228a | ||
|
|
c35fcdc0b7 | ||
|
|
15decd26cc | ||
|
|
9c6482b8d6 | ||
|
|
41f26e0ebc | ||
|
|
2def66169e | ||
|
|
9e34a34e44 | ||
|
|
5ccaf90415 | ||
|
|
44a387e0ea | ||
|
|
a388e25576 | ||
|
|
a1ef7718c9 | ||
|
|
65ddb30016 | ||
|
|
31747dd521 | ||
|
|
6a74c4dfff | ||
|
|
394c3e0ac2 | ||
|
|
60d31116c2 | ||
|
|
8445b0115f | ||
|
|
8506a64149 | ||
|
|
66acd9d64c | ||
|
|
348d05359c | ||
|
|
0d2d30bb39 | ||
|
|
631187be8c | ||
|
|
e756ec8284 | ||
|
|
87d62d7d29 | ||
|
|
5460cfeba8 | ||
|
|
8997730612 | ||
|
|
3617c59bab | ||
|
|
881c6a1049 | ||
|
|
2024ade285 | ||
|
|
674ad4f6bc | ||
|
|
5b99970eb7 | ||
|
|
80cfd940cc | ||
|
|
3c2304d55f | ||
|
|
5645cc7995 | ||
|
|
33690255c5 | ||
|
|
c61471fc8b | ||
|
|
54da019fdb | ||
|
|
28668d808e | ||
|
|
9612ebc00e | ||
|
|
1a46a3a4b3 | ||
|
|
2df1255117 | ||
|
|
3c98038174 | ||
|
|
800f63d38f | ||
|
|
5620eb5332 |
17
.gitignore
vendored
17
.gitignore
vendored
@@ -12,7 +12,9 @@ ascii.bitmaps
|
||||
ascii.h
|
||||
autom4te.cache
|
||||
build_env.mk
|
||||
.bzrignore
|
||||
build-grub-gen-asciih
|
||||
build-grub-gen-widthspec
|
||||
build-grub-mkfont
|
||||
cdboot_test
|
||||
cmp_test
|
||||
config.cache
|
||||
@@ -49,6 +51,7 @@ grub_cmd_set_date
|
||||
grub_cmd_sleep
|
||||
grub-editenv
|
||||
grub-emu
|
||||
grub-emu-lite
|
||||
grub_emu_init.c
|
||||
grub_emu_init.h
|
||||
grub-fstest
|
||||
@@ -59,7 +62,7 @@ grub-install
|
||||
grub-kbdcomp
|
||||
grub-macho2img
|
||||
grub-menulst2cfg
|
||||
grub-mk*
|
||||
/grub-mk*
|
||||
grub-mount
|
||||
grub-ofpathname
|
||||
grub-pe2elf
|
||||
@@ -127,6 +130,7 @@ mod-*.c
|
||||
missing
|
||||
netboot_test
|
||||
*.o
|
||||
*.a
|
||||
ohci_test
|
||||
partmap_test
|
||||
pata_test
|
||||
@@ -155,16 +159,15 @@ GPATH
|
||||
GRTAGS
|
||||
GSYMS
|
||||
GTAGS
|
||||
Makefile.tpl
|
||||
compile
|
||||
depcomp
|
||||
mdate-sh
|
||||
texinfo.tex
|
||||
grub-core/lib/libgcrypt-grub
|
||||
**/.deps
|
||||
**/.deps-util
|
||||
**/.deps-core
|
||||
**/.dirstamp
|
||||
.deps
|
||||
.deps-util
|
||||
.deps-core
|
||||
.dirstamp
|
||||
Makefile.util.am
|
||||
contrib
|
||||
grub-core/bootinfo.txt
|
||||
|
||||
18
INSTALL
18
INSTALL
@@ -15,7 +15,20 @@ configuring the GRUB.
|
||||
Note: older versions may work but support is limited
|
||||
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
|
||||
much bigger binaries.
|
||||
Note: clang 3.4 or later works for powerpc
|
||||
earlier versions not tested
|
||||
Note: clang 3.2 or later works for arm
|
||||
earlier versions not tested
|
||||
Note: clang 3.3 or later works for arm64
|
||||
earlier versions have no arm64 support
|
||||
Note: clang 3.3 or later works for mips(el)
|
||||
earlier versions fail to generate .reginfo and hence gprel relocations
|
||||
fail.
|
||||
Note: clang 3.2 or later works for powerpc
|
||||
earlier versions not tested
|
||||
Note: clang has no support for generating 64-bit sparc code and hence you
|
||||
can't compile GRUB for sparc64 with clang
|
||||
Note: clang has no support for ia64 and hence you can't compile GRUB
|
||||
for ia64 with clang
|
||||
* GNU Make
|
||||
* GNU Bison 2.3 or later
|
||||
* GNU gettext 0.17 or later
|
||||
@@ -41,10 +54,9 @@ To build GRUB's graphical terminal (gfxterm), you need:
|
||||
If you use a development snapshot or want to hack on GRUB you may
|
||||
need the following.
|
||||
|
||||
* Python 2.5.2 or later
|
||||
* Python 2.6 or later
|
||||
* Autoconf 2.60 or later
|
||||
* Automake 1.10.1 or later
|
||||
* Autogen 5.10 or later
|
||||
|
||||
Prerequisites for make-check:
|
||||
|
||||
|
||||
49
Makefile.am
49
Makefile.am
@@ -68,12 +68,20 @@ starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/s
|
||||
|
||||
build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
|
||||
CLEANFILES += build-grub-mkfont
|
||||
|
||||
garbage-gen: util/garbage-gen.c
|
||||
$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^
|
||||
CLEANFILES += garbage-gen
|
||||
EXTRA_DIST += util/garbage-gen.c
|
||||
|
||||
build-grub-gen-asciih: util/grub-gen-asciih.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
|
||||
CLEANFILES += build-grub-gen-asciih
|
||||
|
||||
build-grub-gen-widthspec: util/grub-gen-widthspec.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
|
||||
CLEANFILES += build-grub-gen-widthspec
|
||||
|
||||
if COND_STARFIELD
|
||||
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
|
||||
@@ -88,14 +96,14 @@ dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE)
|
||||
else
|
||||
starfield_DATA =
|
||||
starfield_DATA =
|
||||
endif
|
||||
|
||||
EXTRA_DIST += $(starfield_theme_files)
|
||||
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
|
||||
|
||||
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE)
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
|
||||
CLEANFILES += unicode.pf2
|
||||
|
||||
# Arrows and lines are needed to draw the menu, so always include them
|
||||
@@ -103,19 +111,19 @@ UNICODE_ARROWS=0x2190-0x2193
|
||||
UNICODE_LINES=0x2501-0x251B
|
||||
|
||||
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES)
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
CLEANFILES += ascii.pf2
|
||||
|
||||
euro.pf2: $(FONT_SOURCE) build-grub-mkfont
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES)
|
||||
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
|
||||
CLEANFILES += euro.pf2
|
||||
|
||||
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
|
||||
./build-grub-gen-asciih $(FONT_SOURCE) $@
|
||||
./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
CLEANFILES += ascii.h
|
||||
|
||||
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
|
||||
./build-grub-gen-widthspec $(FONT_SOURCE) $@
|
||||
./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
|
||||
CLEANFILES += widthspec.h
|
||||
|
||||
# Install config.h into platformdir
|
||||
@@ -389,4 +397,33 @@ BOOTCHECK_TIMEOUT=180
|
||||
|
||||
bootcheck: $(BOOTCHECKS)
|
||||
|
||||
if COND_i386_coreboot
|
||||
default_payload.elf: grub-mkstandalone grub-mkimage
|
||||
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
|
||||
endif
|
||||
|
||||
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
|
||||
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
|
||||
test -d $(windowsdir) && rm -rf $(windowsdir) || true
|
||||
test -d $(windowsdir) || mkdir $(windowsdir)
|
||||
$(MAKE) -C po $(AM_MAKEFLAGS) windowsdir
|
||||
$(MAKE) -C grub-core $(AM_MAKEFLAGS) windowsdir
|
||||
test -d $(windowsdir)/themes || mkdir $(windowsdir)/themes
|
||||
test -d $(windowsdir)/themes/starfield || mkdir $(windowsdir)/themes/starfield
|
||||
for x in $(PROGRAMS); do \
|
||||
if [ x$(STRIP) != x ]; then $(STRIP) $$x -o $(windowsdir)/$$x; \
|
||||
else cp -fp $$x $(windowsdir)/$$x; fi; \
|
||||
done
|
||||
for x in $(pkgdata_DATA); do \
|
||||
cp -fp $$x $(windowsdir)/$$x; \
|
||||
done
|
||||
for x in $(starfield_DATA); do \
|
||||
cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \
|
||||
done
|
||||
|
||||
windowszip=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows.zip
|
||||
windowszip: windowsdir
|
||||
test -f $(windowszip) && rm $(windowszip) || true
|
||||
zip -r $(windowszip) $(windowsdir)
|
||||
|
||||
EXTRA_DIST += linguas.sh
|
||||
|
||||
@@ -156,6 +156,8 @@ library = {
|
||||
common = grub-core/io/gzio.c;
|
||||
common = grub-core/io/lzopio.c;
|
||||
common = grub-core/kern/ia64/dl_helper.c;
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
common = grub-core/kern/arm64/dl_helper.c;
|
||||
common = grub-core/lib/minilzo/minilzo.c;
|
||||
common = grub-core/lib/xzembed/xz_dec_bcj.c;
|
||||
common = grub-core/lib/xzembed/xz_dec_lzma2.c;
|
||||
@@ -171,8 +173,11 @@ program = {
|
||||
common = util/resolve.c;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
common = grub-core/osdep/config.c;
|
||||
extra_dist = grub-core/osdep/aros/config.c;
|
||||
extra_dist = grub-core/osdep/windows/config.c;
|
||||
extra_dist = grub-core/osdep/unix/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
extra_dist = util/grub-mkimagexx.c;
|
||||
|
||||
@@ -250,7 +255,7 @@ program = {
|
||||
name = grub-macho2img;
|
||||
mansection = 1;
|
||||
common = util/grub-macho2img.c;
|
||||
condition = COND_APPLE_CC;
|
||||
condition = COND_APPLE_LINKER;
|
||||
};
|
||||
|
||||
program = {
|
||||
@@ -310,6 +315,7 @@ program = {
|
||||
installdir = sbin;
|
||||
mansection = 8;
|
||||
common = util/grub-probe.c;
|
||||
common = util/probe.c;
|
||||
common = grub-core/osdep/ofpath.c;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
@@ -479,38 +485,157 @@ script = {
|
||||
installdir = grubconf;
|
||||
};
|
||||
|
||||
script = {
|
||||
program = {
|
||||
mansection = 1;
|
||||
name = grub-mkrescue;
|
||||
common = util/grub-install_header;
|
||||
common = util/grub-mkrescue.in;
|
||||
enable = noemu;
|
||||
|
||||
common = util/grub-mkrescue.c;
|
||||
common = util/render-label.c;
|
||||
common = util/glue-efi.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
common = grub-core/lib/reed_solomon.c;
|
||||
common = grub-core/osdep/random.c;
|
||||
common = grub-core/osdep/ofpath.c;
|
||||
common = grub-core/osdep/platform.c;
|
||||
common = grub-core/osdep/platform_unix.c;
|
||||
common = grub-core/osdep/compress.c;
|
||||
extra_dist = grub-core/osdep/unix/compress.c;
|
||||
extra_dist = grub-core/osdep/basic/compress.c;
|
||||
common = util/editenv.c;
|
||||
common = grub-core/osdep/blocklist.c;
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = grub-core/kern/emu/hostfs.c;
|
||||
common = grub-core/disk/host.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
ldadd = '$(LIBLZMA)';
|
||||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubgcry.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
|
||||
condition = COND_HAVE_EXEC;
|
||||
};
|
||||
|
||||
script = {
|
||||
program = {
|
||||
mansection = 1;
|
||||
name = grub-mkstandalone;
|
||||
common = util/grub-install_header;
|
||||
common = util/grub-mkstandalone.in;
|
||||
common = util/grub-mkstandalone.c;
|
||||
|
||||
common = util/render-label.c;
|
||||
common = util/glue-efi.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
common = grub-core/lib/reed_solomon.c;
|
||||
common = grub-core/osdep/random.c;
|
||||
common = grub-core/osdep/ofpath.c;
|
||||
common = grub-core/osdep/platform.c;
|
||||
common = grub-core/osdep/platform_unix.c;
|
||||
extra_dist = grub-core/osdep/linux/platform.c;
|
||||
extra_dist = grub-core/osdep/basic/platform.c;
|
||||
extra_dist = grub-core/osdep/basic/no_platform.c;
|
||||
extra_dist = grub-core/osdep/unix/platform.c;
|
||||
common = grub-core/osdep/compress.c;
|
||||
common = util/editenv.c;
|
||||
common = grub-core/osdep/blocklist.c;
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = grub-core/kern/emu/hostfs.c;
|
||||
common = grub-core/disk/host.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
ldadd = '$(LIBLZMA)';
|
||||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubgcry.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
};
|
||||
|
||||
script = {
|
||||
program = {
|
||||
mansection = 8;
|
||||
installdir = sbin;
|
||||
name = grub-install;
|
||||
|
||||
common = util/grub-install_header;
|
||||
common = util/grub-install.in;
|
||||
common = util/grub-install.c;
|
||||
common = util/probe.c;
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
common = grub-core/lib/reed_solomon.c;
|
||||
common = grub-core/osdep/random.c;
|
||||
common = grub-core/osdep/ofpath.c;
|
||||
common = grub-core/osdep/platform.c;
|
||||
common = grub-core/osdep/platform_unix.c;
|
||||
common = grub-core/osdep/compress.c;
|
||||
common = util/editenv.c;
|
||||
common = grub-core/osdep/blocklist.c;
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
enable = noemu;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
ldadd = '$(LIBLZMA)';
|
||||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubgcry.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
};
|
||||
|
||||
script = {
|
||||
program = {
|
||||
mansection = 1;
|
||||
installdir = bin;
|
||||
name = grub-mknetdir;
|
||||
|
||||
common = util/grub-install_header;
|
||||
common = util/grub-mknetdir.in;
|
||||
common = util/grub-mknetdir.c;
|
||||
|
||||
common = util/mkimage.c;
|
||||
common = util/grub-install-common.c;
|
||||
common = util/setup_bios.c;
|
||||
common = util/setup_sparc.c;
|
||||
common = grub-core/lib/reed_solomon.c;
|
||||
common = grub-core/osdep/random.c;
|
||||
common = grub-core/osdep/ofpath.c;
|
||||
common = grub-core/osdep/platform.c;
|
||||
common = grub-core/osdep/platform_unix.c;
|
||||
common = grub-core/osdep/compress.c;
|
||||
common = util/editenv.c;
|
||||
common = grub-core/osdep/blocklist.c;
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
ldadd = '$(LIBLZMA)';
|
||||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubgcry.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
|
||||
};
|
||||
|
||||
script = {
|
||||
@@ -558,6 +683,127 @@ script = {
|
||||
installdir = noinst;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = grub-fs-tester;
|
||||
common = tests/util/grub-fs-tester.in;
|
||||
installdir = noinst;
|
||||
dependencies = garbage-gen;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = ext234_test;
|
||||
common = tests/ext234_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = squashfs_test;
|
||||
common = tests/squashfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = iso9660_test;
|
||||
common = tests/iso9660_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = hfsplus_test;
|
||||
common = tests/hfsplus_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = ntfs_test;
|
||||
common = tests/ntfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = reiserfs_test;
|
||||
common = tests/reiserfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = fat_test;
|
||||
common = tests/fat_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = minixfs_test;
|
||||
common = tests/minixfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = xfs_test;
|
||||
common = tests/xfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = nilfs2_test;
|
||||
common = tests/nilfs2_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = romfs_test;
|
||||
common = tests/romfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = exfat_test;
|
||||
common = tests/exfat_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = tar_test;
|
||||
common = tests/tar_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = udf_test;
|
||||
common = tests/udf_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = hfs_test;
|
||||
common = tests/hfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = jfs_test;
|
||||
common = tests/jfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = btrfs_test;
|
||||
common = tests/btrfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = zfs_test;
|
||||
common = tests/zfs_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = cpio_test;
|
||||
common = tests/cpio_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = example_scripted_test;
|
||||
|
||||
80
acinclude.m4
80
acinclude.m4
@@ -134,6 +134,29 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Check nm
|
||||
AC_DEFUN([grub_PROG_NM_WORKS],
|
||||
[AC_MSG_CHECKING([whether nm works])
|
||||
AC_CACHE_VAL(grub_cv_prog_nm_works,
|
||||
[
|
||||
nm_works_tmp_dir="$(mktemp -d "./confXXXXXX")"
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
|
||||
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_works_tmp_dir/ef"
|
||||
if $TARGET_NM "$nm_works_tmp_dir/ef" > /dev/null; then
|
||||
grub_cv_prog_nm_works=yes
|
||||
else
|
||||
grub_cv_prog_nm_minus_p=no
|
||||
fi
|
||||
rm "$nm_works_tmp_dir/ef"
|
||||
rmdir "$nm_works_tmp_dir"
|
||||
])
|
||||
AC_MSG_RESULT([$grub_cv_prog_nm_works])
|
||||
|
||||
if test "x$grub_cv_prog_nm_works" != xyes; then
|
||||
AC_MSG_ERROR([nm does not work])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Supply -P to nm
|
||||
AC_DEFUN([grub_PROG_NM_MINUS_P],
|
||||
[AC_MSG_CHECKING([whether nm accepts -P])
|
||||
@@ -141,13 +164,14 @@ AC_CACHE_VAL(grub_cv_prog_nm_minus_p,
|
||||
[
|
||||
nm_minus_p_tmp_dir="$(mktemp -d "./confXXXXXX")"
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
|
||||
$TARGET_CC conftest.c -o "$nm_minus_p_tmp_dir/ef"
|
||||
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_minus_p_tmp_dir/ef"
|
||||
if $TARGET_NM -P "$nm_minus_p_tmp_dir/ef" 2>&1 > /dev/null; then
|
||||
grub_cv_prog_nm_minus_p=yes
|
||||
else
|
||||
grub_cv_prog_nm_minus_p=no
|
||||
fi
|
||||
rm "$nm_minus_p_tmp_dir/ef"
|
||||
rmdir "$nm_minus_p_tmp_dir"
|
||||
])
|
||||
AC_MSG_RESULT([$grub_cv_prog_nm_minus_p])
|
||||
|
||||
@@ -165,13 +189,14 @@ AC_CACHE_VAL(grub_cv_prog_nm_defined_only,
|
||||
[
|
||||
nm_defined_only_tmp_dir="$(mktemp -d "./confXXXXXX")"
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])])
|
||||
$TARGET_CC conftest.c -o "$nm_defined_only_tmp_dir/ef"
|
||||
$TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_defined_only_tmp_dir/ef"
|
||||
if $TARGET_NM --defined-only "$nm_defined_only_tmp_dir/ef" 2>&1 > /dev/null; then
|
||||
grub_cv_prog_nm_defined_only=yes
|
||||
else
|
||||
grub_cv_prog_nm_defined_only=no
|
||||
fi
|
||||
rm "$nm_defined_only_tmp_dir/ef"
|
||||
rmdir "$nm_defined_only_tmp_dir"
|
||||
])
|
||||
AC_MSG_RESULT([$grub_cv_prog_nm_defined_only])
|
||||
|
||||
@@ -222,37 +247,6 @@ rm -f conftest*])
|
||||
|
||||
AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
|
||||
|
||||
dnl check if our compiler is apple cc
|
||||
dnl because it requires numerous workarounds
|
||||
AC_DEFUN([grub_apple_cc],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_MSG_CHECKING([whether our compiler is apple cc])
|
||||
AC_CACHE_VAL(grub_cv_apple_cc,
|
||||
[if $CC -v 2>&1 | grep "Apple Inc." > /dev/null; then
|
||||
grub_cv_apple_cc=yes
|
||||
else
|
||||
grub_cv_apple_cc=no
|
||||
fi
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([$grub_cv_apple_cc])])
|
||||
|
||||
dnl check if our target compiler is apple cc
|
||||
dnl because it requires numerous workarounds
|
||||
AC_DEFUN([grub_apple_target_cc],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_MSG_CHECKING([whether our target compiler is apple cc])
|
||||
AC_CACHE_VAL(grub_cv_apple_target_cc,
|
||||
[if $CC -v 2>&1 | grep "Apple Inc." > /dev/null; then
|
||||
grub_cv_apple_target_cc=yes
|
||||
else
|
||||
grub_cv_apple_target_cc=no
|
||||
fi
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([$grub_cv_apple_target_cc])])
|
||||
|
||||
|
||||
dnl Later versions of GAS requires that addr32 and data32 prefixes
|
||||
dnl appear in the same lines as the instructions they modify, while
|
||||
dnl earlier versions requires that they appear in separate lines.
|
||||
@@ -480,23 +474,3 @@ dnl program.
|
||||
AC_DEFUN([grub_TRANSFORM],[dnl
|
||||
AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl
|
||||
])
|
||||
|
||||
dnl Check if the C compiler supports `-mno-unaligned-access'.
|
||||
AC_DEFUN([grub_CHECK_NO_UNALIGNED_ACCESS],[
|
||||
[# foobar
|
||||
nua_possible=yes]
|
||||
AC_MSG_CHECKING([whether `$CC' supports `-mno-unaligned-access'])
|
||||
AC_LANG_CONFTEST([AC_LANG_SOURCE([[
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
]])])
|
||||
|
||||
[if eval "$ac_compile -S -mno-unaligned-access -o conftest.s" 2> /dev/null; then]
|
||||
AC_MSG_RESULT([yes])
|
||||
[rm -f conftest.s
|
||||
else
|
||||
nua_possible=no]
|
||||
AC_MSG_RESULT([no])
|
||||
[fi]
|
||||
])
|
||||
|
||||
11
autogen.sh
11
autogen.sh
@@ -8,8 +8,6 @@ unset LC_ALL
|
||||
find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' |sort > po/POTFILES.in
|
||||
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
|
||||
|
||||
autogen --version >/dev/null || exit 1
|
||||
|
||||
echo "Importing unicode..."
|
||||
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
|
||||
|
||||
@@ -32,10 +30,7 @@ for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul
|
||||
ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
|
||||
done
|
||||
|
||||
echo "Creating Makefile.tpl..."
|
||||
python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
|
||||
|
||||
echo "Running autogen..."
|
||||
echo "Generating Automake input..."
|
||||
|
||||
# Automake doesn't like including files from a path outside the project.
|
||||
rm -f contrib grub-core/contrib
|
||||
@@ -59,8 +54,8 @@ for extra in contrib/*/Makefile.core.def; do
|
||||
fi
|
||||
done
|
||||
|
||||
cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
|
||||
cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
|
||||
python gentpl.py $UTIL_DEFS > Makefile.util.am
|
||||
python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
|
||||
|
||||
for extra in contrib/*/Makefile.common; do
|
||||
if test -e "$extra"; then
|
||||
|
||||
@@ -6,22 +6,21 @@ export LC_COLLATE := C
|
||||
unexport LC_ALL
|
||||
|
||||
# Platform specific options
|
||||
if COND_mips_loongson
|
||||
CFLAGS_PLATFORM += -mexplicit-relocs
|
||||
CPPFLAGS_PLATFORM = -DUSE_ASCII_FALLBACK
|
||||
endif
|
||||
if COND_mips
|
||||
CFLAGS_PLATFORM += -mflush-func=grub_red_herring
|
||||
CCASFLAGS_PLATFORM = -march=mips3
|
||||
endif
|
||||
if COND_sparc64_ieee1275
|
||||
CFLAGS_PLATFORM += -mno-app-regs
|
||||
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
|
||||
endif
|
||||
if COND_arm
|
||||
CFLAGS_PLATFORM += -mthumb-interwork -mlong-calls
|
||||
CFLAGS_PLATFORM += -mthumb-interwork
|
||||
CCASFLAGS_PLATFORM = -mthumb-interwork
|
||||
LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
|
||||
endif
|
||||
if COND_arm64
|
||||
CFLAGS_PLATFORM += -mcmodel=large
|
||||
endif
|
||||
|
||||
#FIXME: discover and check XEN headers
|
||||
CPPFLAGS_XEN = -I/usr/include
|
||||
|
||||
# Other options
|
||||
|
||||
@@ -74,7 +73,7 @@ grubconfdir = $(sysconfdir)/grub.d
|
||||
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
|
||||
starfielddir = $(pkgdatadir)/themes/starfield
|
||||
|
||||
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition
|
||||
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
|
||||
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
|
||||
|
||||
CFLAGS_POSIX = -fno-builtin
|
||||
@@ -131,20 +130,15 @@ EXTRA_DIST =
|
||||
CLEANFILES =
|
||||
BUILT_SOURCES =
|
||||
|
||||
# Rules for autogen definition files
|
||||
|
||||
.PRECIOUS: $(top_srcdir)/Makefile.tpl
|
||||
$(top_srcdir)/Makefile.tpl: $(top_srcdir)/gentpl.py
|
||||
python $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||
mv $@.new $@
|
||||
# Rules for Automake input
|
||||
|
||||
.PRECIOUS: $(top_srcdir)/Makefile.util.am
|
||||
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def $(top_srcdir)/Makefile.tpl
|
||||
cat $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
|
||||
python $^ > $@.new || (rm -f $@.new; exit 1)
|
||||
mv $@.new $@
|
||||
|
||||
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
|
||||
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
|
||||
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def
|
||||
if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
|
||||
cat $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||
python $^ > $@.new || (rm -f $@.new; exit 1)
|
||||
mv $@.new $@
|
||||
|
||||
@@ -2,7 +2,6 @@ EXTRA_DIST += autogen.sh
|
||||
EXTRA_DIST += geninit.sh
|
||||
|
||||
EXTRA_DIST += gentpl.py
|
||||
EXTRA_DIST += Makefile.tpl
|
||||
EXTRA_DIST += Makefile.util.def
|
||||
EXTRA_DIST += Makefile.utilgcry.def
|
||||
|
||||
@@ -12,7 +11,9 @@ EXTRA_DIST += util/import_gcry.py
|
||||
EXTRA_DIST += util/import_unicode.py
|
||||
|
||||
EXTRA_DIST += docs/man
|
||||
EXTRA_DIST += docs/autoiso.cfg
|
||||
EXTRA_DIST += docs/grub.cfg
|
||||
EXTRA_DIST += docs/osdetect.cfg
|
||||
|
||||
EXTRA_DIST += conf/i386-pc-cygwin-img-ld.sc
|
||||
|
||||
@@ -26,6 +27,11 @@ EXTRA_DIST += grub-core/gensymlist.sh
|
||||
EXTRA_DIST += grub-core/genemuinit.sh
|
||||
EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
|
||||
EXTRA_DIST += grub-core/gnulib-fix-width.diff
|
||||
EXTRA_DIST += grub-core/gnulib-no-abort.diff
|
||||
EXTRA_DIST += grub-core/gnulib-no-gets.diff
|
||||
|
||||
EXTRA_DIST += grub-core/lib/libgcrypt
|
||||
EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
|
||||
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
|
||||
@@ -103,3 +109,4 @@ EXTRA_DIST += grub-core/osdep/windows/sleep.c
|
||||
EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
|
||||
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
|
||||
|
||||
EXTRA_DIST += coreboot.cfg
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
|
||||
#include <config-util.h>
|
||||
#else
|
||||
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
|
||||
/* Define if C symbols get an underscore after compilation. */
|
||||
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
|
||||
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */
|
||||
|
||||
481
configure.ac
481
configure.ac
@@ -45,7 +45,7 @@ save_program_prefix="${program_prefix}"
|
||||
AC_CANONICAL_TARGET
|
||||
program_prefix="${save_program_prefix}"
|
||||
|
||||
AM_INIT_AUTOMAKE()
|
||||
AM_INIT_AUTOMAKE([1.10.1])
|
||||
AC_PREREQ(2.60)
|
||||
AC_CONFIG_SRCDIR([include/grub/dl.h])
|
||||
AC_CONFIG_HEADER([config-util.h])
|
||||
@@ -75,14 +75,10 @@ if test "x$TARGET_CFLAGS" = x; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
|
||||
fi
|
||||
|
||||
BUILD_CPPFLAGS="$BUILD_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
|
||||
|
||||
# Default HOST_CPPFLAGS
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
|
||||
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
|
||||
@@ -103,6 +99,9 @@ case "$target_cpu" in
|
||||
arm*)
|
||||
target_cpu=arm;
|
||||
;;
|
||||
aarch64*)
|
||||
target_cpu=arm64;
|
||||
;;
|
||||
esac
|
||||
|
||||
# Specify the platform (such as firmware).
|
||||
@@ -123,8 +122,8 @@ if test "x$with_platform" = x; then
|
||||
mipsel-*) platform=loongson ;;
|
||||
mips-*) platform=arc ;;
|
||||
ia64-*) platform=efi ;;
|
||||
alpha-*) platform=srm ;;
|
||||
arm-*) platform=uboot ;;
|
||||
arm64-*) platform=efi ;;
|
||||
*) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
|
||||
esac
|
||||
else
|
||||
@@ -134,6 +133,7 @@ fi
|
||||
case "$target_cpu"-"$platform" in
|
||||
x86_64-efi) ;;
|
||||
x86_64-emu) ;;
|
||||
x86_64-xen) ;;
|
||||
x86_64-*) target_cpu=i386 ;;
|
||||
powerpc64-ieee1275) target_cpu=powerpc ;;
|
||||
esac
|
||||
@@ -142,6 +142,8 @@ esac
|
||||
case "$target_cpu"-"$platform" in
|
||||
i386-efi) ;;
|
||||
x86_64-efi) ;;
|
||||
i386-xen) ;;
|
||||
x86_64-xen) ;;
|
||||
i386-pc) ;;
|
||||
i386-multiboot) ;;
|
||||
i386-coreboot) ;;
|
||||
@@ -160,9 +162,9 @@ case "$target_cpu"-"$platform" in
|
||||
mipsel-yeeloong) platform=loongson ;;
|
||||
mipsel-fuloong) platform=loongson ;;
|
||||
mipsel-loongson) ;;
|
||||
alpha-srm ) ;;
|
||||
arm-uboot) ;;
|
||||
arm-efi) ;;
|
||||
arm64-efi) ;;
|
||||
*-emu) ;;
|
||||
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
|
||||
esac
|
||||
@@ -191,15 +193,21 @@ case "$host_os" in
|
||||
cygwin | windows* | mingw32*) host_kernel=windows ;;
|
||||
esac
|
||||
|
||||
case "$host_os" in
|
||||
cygwin | windows* | mingw32*) have_exec=n ;;
|
||||
aros*) have_exec=n ;;
|
||||
*) have_exec=y;;
|
||||
esac
|
||||
|
||||
case "$platform" in
|
||||
coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
|
||||
multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
|
||||
efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
|
||||
xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
|
||||
ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
|
||||
uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
|
||||
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
|
||||
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
|
||||
srm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ALPHA_SRM=1" ;;
|
||||
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
|
||||
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
@@ -207,6 +215,7 @@ case "$platform" in
|
||||
esac
|
||||
case "$target_cpu" in
|
||||
arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
|
||||
arm64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
|
||||
mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||
sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||
esac
|
||||
@@ -348,12 +357,6 @@ case "$host_os" in
|
||||
;;
|
||||
esac
|
||||
|
||||
grub_apple_cc
|
||||
if test x$grub_cv_apple_cc = xyes ; then
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
|
||||
HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
|
||||
fi
|
||||
|
||||
if test x$USE_NLS = xno; then
|
||||
HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
|
||||
fi
|
||||
@@ -419,6 +422,26 @@ esac
|
||||
# For gnulib.
|
||||
gl_INIT
|
||||
|
||||
WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
|
||||
EXTRA_WARN_FLAGS="-Wold-style-definition -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign"
|
||||
|
||||
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
|
||||
|
||||
AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
grub_cv_cc_w_extra_flags=
|
||||
for x in $EXTRA_WARN_FLAGS; do
|
||||
CFLAGS="$HOST_CFLAGS $x -Werror"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
|
||||
if test x$flag = x1 ; then
|
||||
grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
|
||||
fi
|
||||
done
|
||||
CFLAGS="$SAVED_CFLAGS"
|
||||
])
|
||||
|
||||
HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
|
||||
|
||||
#
|
||||
# Check for target programs.
|
||||
#
|
||||
@@ -468,14 +491,7 @@ CPPFLAGS="$TARGET_CPPFLAGS"
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
LIBS=""
|
||||
|
||||
grub_PROG_NM_MINUS_P
|
||||
grub_PROG_NM_DEFINED_ONLY
|
||||
AC_SUBST(TARGET_NMFLAGS_MINUS_P)
|
||||
AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
|
||||
|
||||
# debug flags.
|
||||
WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
|
||||
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
|
||||
|
||||
@@ -483,8 +499,25 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
|
||||
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
|
||||
|
||||
grub_cv_target_cc_w_extra_flags=
|
||||
for x in $EXTRA_WARN_FLAGS; do
|
||||
CFLAGS="$TARGET_CFLAGS $x -Werror"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
|
||||
if test x$flag = x1 ; then
|
||||
grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
|
||||
|
||||
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
|
||||
[AC_COMPILE_IFELSE(
|
||||
[
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([], [[
|
||||
#ifdef __clang__
|
||||
#error "is clang"
|
||||
@@ -492,11 +525,36 @@ AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
|
||||
]])],
|
||||
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
|
||||
|
||||
# clang doesn't support .code16
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
|
||||
# on x86 clang doesn't support .code16
|
||||
# on arm clang doesn't support .arch directive
|
||||
# on mips clang doesn't support privilegied instructions, doubleword store/load
|
||||
# and crashes with hand-written assembly
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
|
||||
|| test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
|
||||
|| test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
|
||||
fi
|
||||
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
|
||||
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
|
||||
[
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([], [[
|
||||
unsigned int a = 0, b = 0;
|
||||
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
|
||||
if (a)
|
||||
return 1;
|
||||
]])],
|
||||
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
|
||||
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
|
||||
# used by gcrypt
|
||||
if test x$grub_cv_cc_target_clang_ame = xno ; then
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
|
||||
fi
|
||||
@@ -523,6 +581,21 @@ if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
|
||||
fi
|
||||
|
||||
# on mips redirect cache flushing function to non-existant one.
|
||||
if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
|
||||
AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
|
||||
CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_mflush_func=yes],
|
||||
[grub_cv_cc_mflush_func=no])
|
||||
])
|
||||
|
||||
if test "x$grub_cv_cc_mflush_func" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Force no alignment to save space on i386.
|
||||
if test "x$target_cpu" = xi386; then
|
||||
AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
|
||||
@@ -606,52 +679,14 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
|
||||
fi
|
||||
|
||||
grub_apple_target_cc
|
||||
if test x$grub_cv_apple_target_cc = xyes ; then
|
||||
TARGET_APPLE_CC=1
|
||||
AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
|
||||
if test "x$TARGET_OBJCONV" = x ; then
|
||||
AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
|
||||
fi
|
||||
if test "x$TARGET_OBJCONV" = x ; then
|
||||
AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
|
||||
fi
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_CFLAGS="-static"
|
||||
TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||
TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
|
||||
TARGET_LDFLAGS_OLDMAGIC=""
|
||||
else
|
||||
TARGET_APPLE_CC=0
|
||||
TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
|
||||
# Use linker script if present, otherwise use builtin -N script.
|
||||
if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"; then
|
||||
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
|
||||
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
|
||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
else
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_LDFLAGS='-Wl,-N'
|
||||
TARGET_IMG_LDFLAGS_AC='-Wl,-N'
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
fi
|
||||
TARGET_IMG_CFLAGS=
|
||||
fi
|
||||
|
||||
AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
|
||||
|
||||
# For platforms where ELF is not the default link format.
|
||||
AC_MSG_CHECKING([for command to convert module to ELF format])
|
||||
case "${target_os}" in
|
||||
cygwin) TARGET_OBJ2ELF='./build-grub-pe2elf';
|
||||
cygwin)
|
||||
# FIXME: put proper test here
|
||||
NEED_REGISTER_FRAME_INFO=1
|
||||
;;
|
||||
*) NEED_REGISTER_FRAME_INFO=0 ;;
|
||||
esac
|
||||
AC_MSG_RESULT([$TARGET_OBJ2ELF])
|
||||
|
||||
|
||||
AC_ARG_ENABLE([efiemu],
|
||||
@@ -671,7 +706,7 @@ if test x"$platform" = xefi ; then
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
|
||||
CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_efiemu=yes],
|
||||
[grub_cv_cc_efiemu=no])
|
||||
@@ -680,6 +715,30 @@ if test x"$efiemu_excuse" = x ; then
|
||||
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
|
||||
fi
|
||||
fi
|
||||
if test x"$efiemu_excuse" = x ; then
|
||||
AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
|
||||
grub_cv_target_cc_efiemu64_link_format=unknown
|
||||
for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
|
||||
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
|
||||
LDFLAGS="-m64 -Wl,$format -nostdlib -static"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
asm (".globl _start; _start:");
|
||||
asm (".globl __start; __start:");
|
||||
void __main (void);
|
||||
void __main (void) {}
|
||||
]], [[]])], [flag=1], [flag=0])
|
||||
if test x"$flag" = x1; then
|
||||
grub_cv_target_cc_efiemu64_link_format="$format"
|
||||
break;
|
||||
fi
|
||||
done])
|
||||
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
|
||||
efiemu_excuse="no suitable link format for efiemu64 found"
|
||||
else
|
||||
EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
|
||||
fi
|
||||
fi
|
||||
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
|
||||
AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
|
||||
fi
|
||||
@@ -689,43 +748,77 @@ else
|
||||
enable_efiemu=no
|
||||
fi
|
||||
AC_SUBST([enable_efiemu])
|
||||
AC_SUBST([EFIEMU64_LINK_FORMAT])
|
||||
|
||||
case "$target_os" in
|
||||
cygwin)
|
||||
;;
|
||||
freebsd | kfreebsd*-gnu)
|
||||
if test x"$target_cpu" = xi386; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_fbsd"
|
||||
fi
|
||||
if test x"$target_cpu" = xx86_64; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_fbsd"
|
||||
fi
|
||||
;;
|
||||
openbsd*)
|
||||
if test x"$target_cpu" = xi386; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_obsd"
|
||||
fi
|
||||
if test x"$target_cpu" = xx86_64; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_obsd"
|
||||
fi
|
||||
;;
|
||||
haiku*)
|
||||
if test x"$target_cpu" = xi386; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_haiku"
|
||||
fi
|
||||
if test x"$target_cpu" = xx86_64; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_haiku"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if test x"$target_cpu" = xi386; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386"
|
||||
fi
|
||||
if test x"$target_cpu" = xx86_64; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
|
||||
AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
|
||||
grub_cv_target_cc_link_format=unknown
|
||||
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
|
||||
if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
|
||||
continue
|
||||
fi
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
asm (".globl _start; _start:");
|
||||
asm (".globl __start; __start:");
|
||||
void __main (void);
|
||||
void __main (void) {}
|
||||
]], [[]])], [flag=1], [flag=0])
|
||||
if test x"$flag" = x1; then
|
||||
grub_cv_target_cc_link_format="$format"
|
||||
break;
|
||||
fi
|
||||
done])
|
||||
if test x"$grub_cv_target_cc_link_format" = xunknown; then
|
||||
AC_MSG_ERROR([no suitable link format found])
|
||||
fi
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
|
||||
if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
|
||||
TARGET_OBJ2ELF='./build-grub-pe2elf';
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
|
||||
TARGET_APPLE_LINKER=1
|
||||
AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
|
||||
if test "x$TARGET_OBJCONV" = x ; then
|
||||
AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
|
||||
fi
|
||||
if test "x$TARGET_OBJCONV" = x ; then
|
||||
AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
|
||||
fi
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_CFLAGS="-static"
|
||||
TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||
TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
|
||||
TARGET_LDFLAGS_OLDMAGIC=""
|
||||
elif test x$grub_cv_target_cc_link_format = x-mi386pe && test x$platform = xpc; then
|
||||
TARGET_APPLE_LINKER=0
|
||||
TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
|
||||
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
|
||||
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
|
||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
TARGET_IMG_CFLAGS=
|
||||
else
|
||||
TARGET_APPLE_LINKER=0
|
||||
TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_LDFLAGS='-Wl,-N'
|
||||
TARGET_IMG_LDFLAGS_AC='-Wl,-N'
|
||||
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
TARGET_IMG_CFLAGS=
|
||||
fi
|
||||
|
||||
AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
|
||||
|
||||
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
|
||||
if test "$target_cpu" = x86_64; then
|
||||
# Use large model to support 4G memory
|
||||
@@ -735,9 +828,7 @@ if test "$target_cpu" = x86_64; then
|
||||
[grub_cv_cc_mcmodel=yes],
|
||||
[grub_cv_cc_mcmodel=no])
|
||||
])
|
||||
if test "x$grub_cv_cc_mcmodel" = xno; then
|
||||
AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
|
||||
else
|
||||
if test "x$grub_cv_cc_mcmodel" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||
fi
|
||||
fi
|
||||
@@ -757,10 +848,24 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
|
||||
fi
|
||||
|
||||
if test "x$target_cpu" = xarm; then
|
||||
AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
|
||||
CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_mlong_calls=yes],
|
||||
[grub_cv_cc_mlong_calls=no])
|
||||
])
|
||||
if test "x$grub_cv_cc_mlong_calls" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Compiler features.
|
||||
#
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
# Position independent executable.
|
||||
grub_CHECK_PIE
|
||||
[# Need that, because some distributions ship compilers that include
|
||||
@@ -769,14 +874,25 @@ if [ x"$pie_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
|
||||
fi]
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
# Position independent executable.
|
||||
grub_CHECK_PIC
|
||||
[# Need that, because some distributions ship compilers that include
|
||||
# `-fPIC' in the default specs.
|
||||
if [ x"$pic_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
|
||||
[# On most platforms we don't want PIC as it only makes relocations harder
|
||||
# and code less efficient. On mips we want to have one got table per module
|
||||
# and reload $gp in every function.
|
||||
# GCC implements it using symbol __gnu_local_gp in non-PIC as well.
|
||||
# However with clang we need PIC for this reloading to happen.
|
||||
# Since default varies across dictributions use either -fPIC or -fno-PIC
|
||||
# explicitly.
|
||||
if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
|
||||
elif [ x"$pic_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
|
||||
fi]
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
# Smashing stack protector.
|
||||
grub_CHECK_STACK_PROTECTOR
|
||||
# Need that, because some distributions ship compilers that include
|
||||
@@ -784,6 +900,9 @@ grub_CHECK_STACK_PROTECTOR
|
||||
if test "x$ssp_possible" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
|
||||
fi
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
grub_CHECK_STACK_ARG_PROBE
|
||||
# Cygwin's GCC uses alloca() to probe the stackframe on static
|
||||
# stack allocations above some threshold.
|
||||
@@ -791,18 +910,43 @@ if test x"$sap_possible" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
|
||||
fi
|
||||
|
||||
# -mno-unaligned-access
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
# -mno-unaligned-access -mstrict-align
|
||||
if test "$target_cpu" = arm; then
|
||||
grub_CHECK_NO_UNALIGNED_ACCESS
|
||||
if test x"$nua_possible" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
|
||||
AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
|
||||
grub_cv_target_cc_strict_align=
|
||||
for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
|
||||
CFLAGS="$TARGET_CFLAGS $arg -Werror"
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
|
||||
if test x"$flag" = x1; then
|
||||
grub_cv_target_cc_strict_align="$arg"
|
||||
break;
|
||||
fi
|
||||
done])
|
||||
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
|
||||
if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
|
||||
fi
|
||||
AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
|
||||
[CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
#ifdef __ARM_FEATURE_UNALIGNED
|
||||
#error "unaligned"
|
||||
#endif
|
||||
]])],
|
||||
[grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
|
||||
if test x$grub_cv_cc_target_emits_unaligned = xyes; then
|
||||
AC_MSG_ERROR([compiler generates unaligned accesses])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set them to their new values for the tests below.
|
||||
CC="$TARGET_CC"
|
||||
if test "x$TARGET_APPLE_CC" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
|
||||
fi
|
||||
@@ -816,17 +960,19 @@ fi
|
||||
LIBS="$TARGET_LIBGCC"
|
||||
|
||||
grub_ASM_USCORE
|
||||
if test "x$TARGET_APPLE_LINKER" = x0 ; then
|
||||
if test x$grub_cv_asm_uscore = xyes; then
|
||||
CFLAGS="$TARGET_CFLAGS -Wl,--defsym,_abort=_main"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,_abort=_main"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -Wl,--defsym,abort=main"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,abort=main"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for libgcc symbols
|
||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
|
||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
|
||||
|
||||
if test "x$TARGET_APPLE_CC" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib"
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
|
||||
fi
|
||||
@@ -834,12 +980,12 @@ LIBS=""
|
||||
|
||||
# Defined in aclocal.m4.
|
||||
grub_PROG_TARGET_CC
|
||||
if test "x$TARGET_APPLE_CC" != x1 ; then
|
||||
if test "x$TARGET_APPLE_LINKER" != x1 ; then
|
||||
grub_PROG_OBJCOPY_ABSOLUTE
|
||||
fi
|
||||
grub_PROG_LD_BUILD_ID_NONE
|
||||
if test "x$target_cpu" = xi386; then
|
||||
if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
|
||||
if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
|
||||
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
|
||||
# Check symbols provided by linker script.
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
|
||||
@@ -852,6 +998,12 @@ if test "x$target_cpu" = xi386; then
|
||||
grub_I386_ASM_ADDR32
|
||||
fi
|
||||
|
||||
grub_PROG_NM_WORKS
|
||||
grub_PROG_NM_MINUS_P
|
||||
grub_PROG_NM_DEFINED_ONLY
|
||||
AC_SUBST(TARGET_NMFLAGS_MINUS_P)
|
||||
AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
|
||||
|
||||
if test "$platform" != emu; then
|
||||
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
|
||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||
@@ -1118,8 +1270,8 @@ if test x"$grub_build_mkfont_excuse" = x ; then
|
||||
else
|
||||
enable_build_grub_mkfont=no
|
||||
fi
|
||||
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
|
||||
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
|
||||
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
|
||||
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
|
||||
fi
|
||||
|
||||
AC_SUBST([build_freetype_cflags])
|
||||
@@ -1135,7 +1287,14 @@ DJVU_FONT_SOURCE=
|
||||
|
||||
starfield_excuse=
|
||||
|
||||
if test x"$enable_build_grub_mkfont" = xno ; then
|
||||
AC_ARG_ENABLE([grub-themes],
|
||||
[AS_HELP_STRING([--enable-grub-themes],
|
||||
[build and install GRUB themes (default=guessed)])])
|
||||
if test x"$enable_grub_themes" = xno ; then
|
||||
starfield_excuse="explicitly disabled"
|
||||
fi
|
||||
|
||||
if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
|
||||
starfield_excuse="No build-time grub-mkfont"
|
||||
fi
|
||||
|
||||
@@ -1154,6 +1313,10 @@ if test x"$starfield_excuse" = x; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
|
||||
AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
|
||||
fi
|
||||
|
||||
AC_SUBST([DJVU_FONT_SOURCE])
|
||||
|
||||
FONT_SOURCE=
|
||||
@@ -1161,6 +1324,11 @@ FONT_SOURCE=
|
||||
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
|
||||
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
|
||||
if test -f "$dir/unifont.$ext"; then
|
||||
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
|
||||
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
|
||||
if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
|
||||
continue;
|
||||
fi
|
||||
FONT_SOURCE="$dir/unifont.$ext"
|
||||
break 2
|
||||
fi
|
||||
@@ -1171,8 +1339,8 @@ if test x"$enable_build_grub_mkfont" = xno ; then
|
||||
FONT_SOURCE=
|
||||
fi
|
||||
|
||||
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
|
||||
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
|
||||
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
|
||||
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
|
||||
fi
|
||||
|
||||
AC_SUBST([FONT_SOURCE])
|
||||
@@ -1256,10 +1424,32 @@ fi
|
||||
|
||||
AC_SUBST([LIBGEOM])
|
||||
|
||||
AC_ARG_ENABLE([liblzma],
|
||||
[AS_HELP_STRING([--enable-liblzma],
|
||||
[enable liblzma integration (default=guessed)])])
|
||||
if test x"$enable_liblzma" = xno ; then
|
||||
liblzma_excuse="explicitly disabled"
|
||||
fi
|
||||
|
||||
if test x"$liblzma_excuse" = x ; then
|
||||
AC_CHECK_LIB([lzma], [lzma_code],
|
||||
[LIBLZMA="-llzma"
|
||||
AC_DEFINE([HAVE_LIBLZMA], [1],
|
||||
[Define to 1 if you have the LZMA library.])],)
|
||||
[],[liblzma_excuse="need lzma library"])
|
||||
fi
|
||||
if test x"$liblzma_excuse" = x ; then
|
||||
AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
|
||||
fi
|
||||
|
||||
if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
|
||||
AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
|
||||
fi
|
||||
|
||||
|
||||
if test x"$liblzma_excuse" = x ; then
|
||||
LIBLZMA="-llzma"
|
||||
AC_DEFINE([USE_LIBLZMA], [1],
|
||||
[Define to 1 if you have the LZMA library.])
|
||||
fi
|
||||
|
||||
AC_SUBST([LIBLZMA])
|
||||
|
||||
AC_ARG_ENABLE([libzfs],
|
||||
@@ -1308,8 +1498,6 @@ LIBS=""
|
||||
AC_SUBST([FONT_SOURCE])
|
||||
AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
|
||||
[AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
|
||||
AS_IF([test x$TARGET_APPLE_CC = x1],
|
||||
[AC_SUBST([USE_APPLE_CC_FIXES], yes)])
|
||||
|
||||
AC_SUBST(HAVE_ASM_USCORE)
|
||||
AC_SUBST(ADDR32)
|
||||
@@ -1349,7 +1537,6 @@ AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
|
||||
AC_SUBST(TARGET_CPP)
|
||||
AC_SUBST(TARGET_CCAS)
|
||||
AC_SUBST(TARGET_OBJ2ELF)
|
||||
AC_SUBST(TARGET_APPLE_CC)
|
||||
AC_SUBST(TARGET_MODULE_FORMAT)
|
||||
|
||||
AC_SUBST(TARGET_CFLAGS)
|
||||
@@ -1361,6 +1548,7 @@ AC_SUBST(TARGET_IMG_LDSCRIPT)
|
||||
AC_SUBST(TARGET_IMG_LDFLAGS)
|
||||
AC_SUBST(TARGET_IMG_CFLAGS)
|
||||
AC_SUBST(TARGET_IMG_BASE_LDOPT)
|
||||
AC_SUBST(TARGET_APPLE_LINKER)
|
||||
|
||||
AC_SUBST(HOST_CFLAGS)
|
||||
AC_SUBST(HOST_LDFLAGS)
|
||||
@@ -1383,18 +1571,21 @@ AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform =
|
||||
AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
|
||||
AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
|
||||
AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
|
||||
AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
|
||||
AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
|
||||
AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
|
||||
AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
|
||||
AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
|
||||
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
|
||||
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
|
||||
AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
|
||||
AM_CONDITIONAL([COND_alpha_srm], [test x$target_cpu = xalpha -a x$platform = xsrm])
|
||||
AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
|
||||
AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
|
||||
AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
|
||||
AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
|
||||
AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
|
||||
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
|
||||
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
|
||||
|
||||
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
|
||||
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
|
||||
@@ -1411,7 +1602,13 @@ AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
|
||||
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
|
||||
AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
|
||||
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
|
||||
AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
|
||||
if test x$FONT_SOURCE != x ; then
|
||||
HAVE_FONT_SOURCE=1
|
||||
else
|
||||
HAVE_FONT_SOURCE=0
|
||||
fi
|
||||
AC_SUBST(HAVE_FONT_SOURCE)
|
||||
AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
|
||||
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
|
||||
AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
|
||||
AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
|
||||
@@ -1421,6 +1618,20 @@ AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
|
||||
AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
|
||||
AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
|
||||
AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
|
||||
AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
|
||||
|
||||
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
|
||||
test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
|
||||
datarootdir="$(eval echo "$datarootdir")"
|
||||
grub_libdir="$(eval echo "$libdir")"
|
||||
grub_localedir="$(eval echo "$localedir")"
|
||||
grub_datadir="$(eval echo "$datadir")"
|
||||
grub_sysconfdir="$(eval echo "$sysconfdir")"
|
||||
AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
|
||||
AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
|
||||
AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
|
||||
AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
|
||||
|
||||
|
||||
# Output files.
|
||||
cpudir="${target_cpu}"
|
||||
@@ -1532,8 +1743,8 @@ else
|
||||
echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
|
||||
echo "Without unifont (no build-time grub-mkfont)"
|
||||
fi
|
||||
if test "x$LIBLZMA" = x ; then
|
||||
echo "Without liblzma (no support for XZ-compressed mips images)"
|
||||
if test x"$liblzma_excuse" != x ; then
|
||||
echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
|
||||
else
|
||||
echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
|
||||
fi
|
||||
|
||||
3
coreboot.cfg
Normal file
3
coreboot.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
if test -f (cbfsdisk)/etc/grub.cfg; then
|
||||
source (cbfsdisk)/etc/grub.cfg
|
||||
fi
|
||||
@@ -79,7 +79,7 @@ This edition documents version @value{VERSION}.
|
||||
* Contributing Changes::
|
||||
* Porting::
|
||||
* Error Handling::
|
||||
* CIA::
|
||||
* Stack and heap size::
|
||||
* BIOS port memory map::
|
||||
* Video Subsystem::
|
||||
* PFF2 Font File Format::
|
||||
@@ -92,24 +92,36 @@ This edition documents version @value{VERSION}.
|
||||
@node Getting the source code
|
||||
@chapter Getting the source code
|
||||
|
||||
GRUB is maintained using the @uref{http://bazaar-vcs.org/, Bazaar revision
|
||||
control system}. To fetch the primary development branch:
|
||||
GRUB is maintained using the @uref{GIT revision
|
||||
control system}. To fetch:
|
||||
|
||||
@example
|
||||
bzr get http://bzr.savannah.gnu.org/r/grub/trunk/grub
|
||||
git clone git://git.sv.gnu.org/grub.git
|
||||
@end example
|
||||
|
||||
The GRUB developers maintain several other branches with work in progress.
|
||||
Of these, the most interesting is the experimental branch, which is a
|
||||
staging area for new code which we expect to eventually merge into trunk but
|
||||
which is not yet ready:
|
||||
|
||||
Web access is available under
|
||||
@example
|
||||
bzr get http://bzr.savannah.gnu.org/r/grub/branches/experimental
|
||||
http://git.savannah.gnu.org/cgit/grub.git/
|
||||
@end example
|
||||
|
||||
Once you have used @kbd{bzr get} to fetch an initial copy of a branch, you
|
||||
can use @kbd{bzr pull} to keep it up to date. If you have modified your
|
||||
The branches available are:
|
||||
|
||||
@table @samp
|
||||
@item master
|
||||
Main developpement branch.
|
||||
@item grub-legacy
|
||||
GRUB 0.97 codebase. Kept for reference and legal reasons
|
||||
@item multiboot
|
||||
Multiboot specfication
|
||||
@item multiboot2
|
||||
Multiboot2 specfication
|
||||
@item developper branches
|
||||
Prefixed with developper name. Every developper of a team manages his own branches.
|
||||
Developper branches do not need changelog entries.
|
||||
@end table
|
||||
|
||||
Once you have used @kbd{git clone} to fetch an initial copy of a branch, you
|
||||
can use @kbd{git pull} to keep it up to date. If you have modified your
|
||||
local version, you may need to resolve conflicts when pulling.
|
||||
|
||||
@node Coding style
|
||||
@@ -334,10 +346,10 @@ anymore.
|
||||
@itemize
|
||||
@item Always use latest GRUB 2 source code. So get that first.
|
||||
|
||||
For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a Bazaar (bzr) repository.
|
||||
For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a GIT repository.
|
||||
|
||||
Please check Savannah's GRUB project page for details how to get newest bzr:
|
||||
@uref{http://savannah.gnu.org/bzr/?group=grub, GRUB 2 bzr Repository}
|
||||
Please check Savannah's GRUB project page for details how to get newest git:
|
||||
@uref{https://savannah.gnu.org/git/?group=grub, GRUB 2 git Repository}
|
||||
|
||||
@item Compile it and try it out.
|
||||
|
||||
@@ -895,33 +907,68 @@ if (grub_errno != GRUB_ERR_NONE)
|
||||
grub_error_pop ();
|
||||
@end example
|
||||
|
||||
@node CIA
|
||||
@chapter CIA
|
||||
@c By Robert Millan and Carles Pina
|
||||
If you have commit access, please setup CIA in your Bazaar
|
||||
config so those in IRC receive notification of your commits.
|
||||
@node Stack and heap size
|
||||
@chapter Stack and heap size
|
||||
|
||||
In @file{~/.bazaar/bazaar.conf}, add "cia_send_revno = true".
|
||||
Optionally, you can also add "cia_user = myusername" if you'd
|
||||
like CIA service to use a specific account (for statistical purpose).
|
||||
On emu stack and heap are just normal host OS stack and heap. Stack is typically
|
||||
8 MiB although it's OS-dependent.
|
||||
|
||||
In the @file{.bzr/branch/branch.conf} of your checkout branch,
|
||||
"set nickname = /path_to_this_branch" and "cia_project = GNU GRUB".
|
||||
On i386-pc, i386-coreboot, i386-qemu and i386-multiboot the stack is 60KiB.
|
||||
All available space between 1MiB and 4GiB marks is part of heap.
|
||||
|
||||
Additionally, please set cia_send_revno in the [DEFAULT] section
|
||||
of your @file{~/.bazaar/bazaar.conf}. E.g.:
|
||||
On *-xen stack is 4MiB. If compiled for x86-64 with GCC 4.4 or later adressable
|
||||
space is unlimited. When compiled for x86-64 with older GCC version adressable
|
||||
space is limited to 2GiB. When compiling for i386 adressable space is limited
|
||||
to 4GiB. All adressable pages except the ones for stack, GRUB binary, special
|
||||
pages and page table are in the heap.
|
||||
|
||||
@example
|
||||
[DEFAULT]
|
||||
cia_send_revno = true
|
||||
@end example
|
||||
On *-efi GRUB uses same stack as EFI. If compiled for x86-64 with GCC 4.4 or
|
||||
later adressable space is unlimited. When compiled for x86-64 with older GCC
|
||||
version adressable space is limited to 2GiB. For all other platforms adressable
|
||||
space is limited to 4GiB. GRUB allocates pages from EFI for its heap, at most
|
||||
1.6 GiB.
|
||||
|
||||
Remember to install cia-clients (Debian/Ubuntu package) to be able to use CIA.
|
||||
On i386-ieee1275 and powerpc-ieee1275 GRUB uses same stack as IEEE1275.
|
||||
It allocates at most 32MiB for its heap.
|
||||
|
||||
On sparc64-ieee1275 stack is 256KiB and heap is 2MiB.
|
||||
|
||||
On mips(el)-qemu_mips and mipsel-loongson stack is 2MiB (everything below
|
||||
GRUB image) and everything above GRUB image (from 2MiB + kernel size)
|
||||
until 256MiB is part of heap.
|
||||
|
||||
On mips-arc stack is 2MiB (everything below GRUB image) and everything above
|
||||
GRUB image(from 2MiB + kernel size) until 128MiB is part of heap.
|
||||
|
||||
On mipsel-arc stack is 2MiB (everything below GRUB image which is not part
|
||||
of ARC) and everything above GRUB image (from 7MiB + kernel size)
|
||||
until 256MiB is part of heap.
|
||||
|
||||
On arm-uboot stack is 256KiB and heap is 2MiB.
|
||||
|
||||
In short:
|
||||
|
||||
@multitable @columnfractions .15 .25 .5
|
||||
@headitem Platform @tab Stack @tab Heap
|
||||
@item emu @tab 8 MiB @tab ?
|
||||
@item i386-pc @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-coreboot @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-multiboot @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-qemu @tab 60 KiB @tab < 4 GiB
|
||||
@item *-efi @tab ? @tab < 1.6 GiB
|
||||
@item i386-ieee1275 @tab ? @tab < 32 MiB
|
||||
@item powerpc-ieee1275 @tab ? @tab < 32 MiB
|
||||
@item sparc64-ieee1275 @tab 256KiB @tab 2 MiB
|
||||
@item arm-uboot @tab 256KiB @tab 2 MiB
|
||||
@item mips(el)-qemu_mips @tab 2MiB @tab 253 MiB
|
||||
@item mipsel-loongson @tab 2MiB @tab 253 MiB
|
||||
@item mips-arc @tab 2MiB @tab 125 MiB
|
||||
@item mipsel-arc @tab 2MiB @tab 248 MiB
|
||||
@item x86_64-xen (GCC >= 4.4) @tab 4MiB @tab unlimited
|
||||
@item x86_64-xen (GCC < 4.4) @tab 4MiB @tab < 2GiB
|
||||
@item i386-xen @tab 4MiB @tab < 4GiB
|
||||
@end multitable
|
||||
|
||||
Keep in mind Bazaar sends notifications for all commits to branches that have
|
||||
this setting, regardless of whether they're bound branches (checkouts) or not.
|
||||
So if you make local commits in a non-bound branch and it bothers you that
|
||||
others can read them, do not use this setting.
|
||||
|
||||
@node BIOS port memory map
|
||||
@chapter BIOS port memory map
|
||||
@@ -934,9 +981,8 @@ others can read them, do not use this setting.
|
||||
@item ? @tab 0x2000 - 1 @tab Real mode stack
|
||||
@item 0x7C00 @tab 0x7D00 - 1 @tab Boot sector
|
||||
@item 0x8000 @tab ? @tab GRUB kernel
|
||||
@item 0x68000 @tab 0x78000 - 1 @tab Disk buffer
|
||||
@item 0x68000 @tab 0x71000 - 1 @tab Disk buffer
|
||||
@item ? @tab 0x80000 - 1 @tab Protected mode stack
|
||||
@item 0x80000 @tab ? @tab Heap
|
||||
@item ? @tab 0xA0000 - 1 @tab Extended BIOS Data Area
|
||||
@item 0xA0000 @tab 0xC0000 - 1 @tab Video RAM
|
||||
@item 0xC0000 @tab 0x100000 - 1 @tab BIOS
|
||||
@@ -1766,7 +1812,9 @@ right edges of two adjacent glyphs. The @strong{device width} field determines
|
||||
the effective leading value that is used to render the font.
|
||||
|
||||
@end itemize
|
||||
@image{font_char_metrics,,,,png}
|
||||
@ifnottex
|
||||
@image{font_char_metrics,,,,.png}
|
||||
@end ifnottex
|
||||
|
||||
An illustration of how the various font metrics apply to characters.
|
||||
|
||||
|
||||
166
docs/grub.texi
166
docs/grub.texi
@@ -1277,8 +1277,9 @@ works it's not recommended since titles often contain unstable device names
|
||||
and may be translated
|
||||
|
||||
If you set this to @samp{saved}, then the default menu entry will be that
|
||||
saved by @samp{GRUB_SAVEDEFAULT}, @command{grub-set-default}, or
|
||||
@command{grub-reboot}.
|
||||
saved by @samp{GRUB_SAVEDEFAULT} or @command{grub-set-default}. This relies on
|
||||
the environment block, which may not be available in all situations
|
||||
(@pxref{Environment block}).
|
||||
|
||||
The default is @samp{0}.
|
||||
|
||||
@@ -1287,7 +1288,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save
|
||||
it as a new default entry for use by future runs of GRUB. This is only
|
||||
useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
|
||||
@samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
|
||||
@command{grub-set-default} or @command{grub-reboot}. Unset by default.
|
||||
@command{grub-set-default}. Unset by default.
|
||||
This option relies on the environment block, which may not be available in
|
||||
all situations (@pxref{Environment block}).
|
||||
|
||||
@@ -1297,23 +1298,26 @@ a key is pressed. The default is @samp{5}. Set to @samp{0} to boot
|
||||
immediately without displaying the menu, or to @samp{-1} to wait
|
||||
indefinitely.
|
||||
|
||||
@item GRUB_HIDDEN_TIMEOUT
|
||||
Wait this many seconds for @key{ESC} to be pressed before displaying the menu.
|
||||
If no @key{ESC} is pressed during that time, display the menu for the number of
|
||||
seconds specified in GRUB_TIMEOUT before booting the default entry. We expect
|
||||
that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set
|
||||
to @samp{0} so that the menu is not displayed at all unless @key{ESC} is
|
||||
pressed.
|
||||
Unset by default.
|
||||
If @samp{GRUB_TIMEOUT_STYLE} is set to @samp{countdown} or @samp{hidden},
|
||||
the timeout is instead counted before the menu is displayed.
|
||||
|
||||
@item GRUB_HIDDEN_TIMEOUT_QUIET
|
||||
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
|
||||
suppress the verbose countdown while waiting for a key to be pressed before
|
||||
displaying the menu. Unset by default.
|
||||
@item GRUB_TIMEOUT_STYLE
|
||||
If this option is unset or set to @samp{menu}, then GRUB will display the
|
||||
menu and then wait for the timeout set by @samp{GRUB_TIMEOUT} to expire
|
||||
before booting the default entry. Pressing a key interrupts the timeout.
|
||||
|
||||
If this option is set to @samp{countdown} or @samp{hidden}, then, before
|
||||
displaying the menu, GRUB will wait for the timeout set by
|
||||
@samp{GRUB_TIMEOUT} to expire. If @key{ESC} is pressed during that time, it
|
||||
will display the menu and wait for input. If a hotkey associated with a
|
||||
menu entry is pressed, it will boot the associated menu entry immediately.
|
||||
If the timeout expires before either of these happens, it will boot the
|
||||
default entry. In the @samp{countdown} case, it will show a one-line
|
||||
indication of the remaining time.
|
||||
|
||||
@item GRUB_DEFAULT_BUTTON
|
||||
@itemx GRUB_TIMEOUT_BUTTON
|
||||
@itemx GRUB_HIDDEN_TIMEOUT_BUTTON
|
||||
@itemx GRUB_TIMEOUT_STYLE_BUTTON
|
||||
@itemx GRUB_BUTTON_CMOS_ADDRESS
|
||||
Variants of the corresponding variables without the @samp{_BUTTON} suffix,
|
||||
used to support vendor-specific power buttons. @xref{Vendor power-on keys}.
|
||||
@@ -1450,6 +1454,22 @@ Normally, @command{grub-mkconfig} will try to use the external
|
||||
systems installed on the same system and generate appropriate menu entries
|
||||
for them. Set this option to @samp{true} to disable this.
|
||||
|
||||
@item GRUB_OS_PROBER_SKIP_LIST
|
||||
List of space-separated FS UUIDs of filesystems to be ignored from os-prober
|
||||
output. For efi chainloaders it's <UUID>@@<EFI FILE>
|
||||
|
||||
@item GRUB_DISABLE_SUBMENU
|
||||
Normally, @command{grub-mkconfig} will generate top level menu entry for
|
||||
the kernel with highest version number and put all other found kernels
|
||||
or alternative menu entries for recovery mode in submenu. For entries returned
|
||||
by @command{os-prober} first entry will be put on top level and all others
|
||||
in submenu. If this option is set to @samp{y}, flat menu with all entries
|
||||
on top level will be generated instead. Changing this option will require
|
||||
changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback})
|
||||
and @samp{default} (@pxref{default}) environment variables as well as saved
|
||||
default entry using @command{grub-set-default} and value used with
|
||||
@command{grub-reboot}.
|
||||
|
||||
@item GRUB_ENABLE_CRYPTODISK
|
||||
If set to @samp{y}, @command{grub-mkconfig} and @command{grub-install} will
|
||||
check for encrypted disks and generate additional commands needed to access
|
||||
@@ -1472,6 +1492,44 @@ Each module will be loaded as early as possible, at the start of
|
||||
|
||||
@end table
|
||||
|
||||
The following options are still accepted for compatibility with existing
|
||||
configurations, but have better replacements:
|
||||
|
||||
@table @samp
|
||||
@item GRUB_HIDDEN_TIMEOUT
|
||||
Wait this many seconds before displaying the menu. If @key{ESC} is pressed
|
||||
during that time, display the menu and wait for input according to
|
||||
@samp{GRUB_TIMEOUT}. If a hotkey associated with a menu entry is pressed,
|
||||
boot the associated menu entry immediately. If the timeout expires before
|
||||
either of these happens, display the menu for the number of seconds
|
||||
specified in @samp{GRUB_TIMEOUT} before booting the default entry.
|
||||
|
||||
If you set @samp{GRUB_HIDDEN_TIMEOUT}, you should also set
|
||||
@samp{GRUB_TIMEOUT=0} so that the menu is not displayed at all unless
|
||||
@key{ESC} is pressed.
|
||||
|
||||
This option is unset by default, and is deprecated in favour of the less
|
||||
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
|
||||
@samp{GRUB_TIMEOUT_STYLE=hidden}.
|
||||
|
||||
@item GRUB_HIDDEN_TIMEOUT_QUIET
|
||||
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
|
||||
suppress the verbose countdown while waiting for a key to be pressed before
|
||||
displaying the menu.
|
||||
|
||||
This option is unset by default, and is deprecated in favour of the less
|
||||
confusing @samp{GRUB_TIMEOUT_STYLE=countdown}.
|
||||
|
||||
@item GRUB_HIDDEN_TIMEOUT_BUTTON
|
||||
Variant of @samp{GRUB_HIDDEN_TIMEOUT}, used to support vendor-specific power
|
||||
buttons. @xref{Vendor power-on keys}.
|
||||
|
||||
This option is unset by default, and is deprecated in favour of the less
|
||||
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
|
||||
@samp{GRUB_TIMEOUT_STYLE=hidden}.
|
||||
|
||||
@end table
|
||||
|
||||
For more detailed customisation of @command{grub-mkconfig}'s output, you may
|
||||
edit the scripts in @file{/etc/grub.d} directly.
|
||||
@file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
|
||||
@@ -2460,15 +2518,16 @@ menu requires several fancy features of your terminal.
|
||||
@node Vendor power-on keys
|
||||
@chapter Using GRUB with vendor power-on keys
|
||||
|
||||
Some laptop vendors provide an additional power-on button which boots another
|
||||
OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
|
||||
@samp{GRUB_DEFAULT_BUTTON}, @samp{GRUB_HIDDEN_TIMEOUT_BUTTON} and
|
||||
Some laptop vendors provide an additional power-on button which boots
|
||||
another OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
|
||||
@samp{GRUB_TIMEOUT_STYLE_BUTTON}, @samp{GRUB_DEFAULT_BUTTON}, and
|
||||
@samp{GRUB_BUTTON_CMOS_ADDRESS} variables in default/grub (@pxref{Simple
|
||||
configuration}). @samp{GRUB_TIMEOUT_BUTTON}, @samp{GRUB_DEFAULT_BUTTON} and
|
||||
@samp{GRUB_HIDDEN_TIMEOUT_BUTTON} are used instead of the corresponding
|
||||
variables without the @samp{_BUTTON} suffix when powered on using the special
|
||||
button. @samp{GRUB_BUTTON_CMOS_ADDRESS} is vendor-specific and partially
|
||||
model-specific. Values known to the GRUB team are:
|
||||
configuration}). @samp{GRUB_TIMEOUT_BUTTON},
|
||||
@samp{GRUB_TIMEOUT_STYLE_BUTTON}, and @samp{GRUB_DEFAULT_BUTTON} are used
|
||||
instead of the corresponding variables without the @samp{_BUTTON} suffix
|
||||
when powered on using the special button. @samp{GRUB_BUTTON_CMOS_ADDRESS}
|
||||
is vendor-specific and partially model-specific. Values known to the GRUB
|
||||
team are:
|
||||
|
||||
@table @key
|
||||
@item Dell XPS M1330M
|
||||
@@ -2652,6 +2711,7 @@ Heavily limited platforms:
|
||||
Lightly limited platforms:
|
||||
|
||||
@itemize
|
||||
@item *-xen: limited only by adress space and RAM size.
|
||||
@item i386-qemu: kernel.img (.text + .data + .bss) is limited by 392704 bytes.
|
||||
(core.img would be limited by ROM size but it's unlimited on qemu
|
||||
@item All EFI platforms: limited by contiguous RAM size and possibly firmware bugs
|
||||
@@ -2707,9 +2767,9 @@ by a digit, like @samp{fd0}, or @samp{cd}.
|
||||
AHCI, PATA (ata), crypto, USB use the name of driver followed by a number.
|
||||
Memdisk and host are limited to one disk and so it's refered just by driver
|
||||
name.
|
||||
RAID (md), ofdisk (ieee1275 and nand), LVM (lvm), LDM and arcdisk (arc) use
|
||||
intrinsic name of disk prefixed by driver name. Additionally just ``nand''
|
||||
refers to the disk aliased as ``nand''.
|
||||
RAID (md), ofdisk (ieee1275 and nand), LVM (lvm), LDM, virtio (vdsk)
|
||||
and arcdisk (arc) use intrinsic name of disk prefixed by driver name.
|
||||
Additionally just ``nand'' refers to the disk aliased as ``nand''.
|
||||
Conflicts are solved by suffixing a number if necessarry.
|
||||
Commas need to be escaped.
|
||||
Loopback uses whatever name specified to @command{loopback} command.
|
||||
@@ -2975,6 +3035,7 @@ These variables have special meaning to GRUB.
|
||||
* biosnum::
|
||||
* check_signatures::
|
||||
* chosen::
|
||||
* cmdpath::
|
||||
* color_highlight::
|
||||
* color_normal::
|
||||
* debug::
|
||||
@@ -3011,6 +3072,7 @@ These variables have special meaning to GRUB.
|
||||
* superusers::
|
||||
* theme::
|
||||
* timeout::
|
||||
* timeout_style::
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -3044,6 +3106,16 @@ the titles of each of the submenus starting from the top level followed by
|
||||
the title of the menu entry itself, separated by @samp{>}.
|
||||
|
||||
|
||||
@node cmdpath
|
||||
@subsection cmdpath
|
||||
|
||||
The location from which @file{core.img} was loaded as an absolute
|
||||
directory name (@pxref{File name syntax}). This is set by GRUB at
|
||||
startup based on information returned by platform firmware. Not every
|
||||
platform provides this information and some may return only device
|
||||
without path name.
|
||||
|
||||
|
||||
@node color_highlight
|
||||
@subsection color_highlight
|
||||
|
||||
@@ -3433,8 +3505,21 @@ keyboard input before booting the default menu entry. A timeout of @samp{0}
|
||||
means to boot the default entry immediately without displaying the menu; a
|
||||
timeout of @samp{-1} (or unset) means to wait indefinitely.
|
||||
|
||||
This variable is often set by @samp{GRUB_TIMEOUT} or
|
||||
@samp{GRUB_HIDDEN_TIMEOUT} (@pxref{Simple configuration}).
|
||||
If @samp{timeout_style} (@pxref{timeout_style}) is set to @samp{countdown}
|
||||
or @samp{hidden}, the timeout is instead counted before the menu is
|
||||
displayed.
|
||||
|
||||
This variable is often set by @samp{GRUB_TIMEOUT} (@pxref{Simple
|
||||
configuration}).
|
||||
|
||||
|
||||
@node timeout_style
|
||||
@subsection timeout_style
|
||||
|
||||
This variable may be set to @samp{menu}, @samp{countdown}, or @samp{hidden}
|
||||
to control the way in which the timeout (@pxref{timeout}) interacts with
|
||||
displaying the menu. See the documentation of @samp{GRUB_TIMEOUT_STYLE}
|
||||
(@pxref{Simple configuration}) for details.
|
||||
|
||||
|
||||
@node Environment block
|
||||
@@ -4391,7 +4476,7 @@ List devices or files.
|
||||
With no arguments, print all devices known to GRUB.
|
||||
|
||||
If the argument is a device name enclosed in parentheses (@pxref{Device
|
||||
syntax}), then list all files at the root directory of that device.
|
||||
syntax}), then print the name of the filesystem of that device.
|
||||
|
||||
If the argument is a directory given as an absolute file name (@pxref{File
|
||||
name syntax}), then list the contents of that directory.
|
||||
@@ -4854,7 +4939,8 @@ Alias for @code{hashsum --hash sha512 arg @dots{}}. See command @command{hashsum
|
||||
@deffn Command sleep [@option{--verbose}] [@option{--interruptible}] count
|
||||
Sleep for @var{count} seconds. If option @option{--interruptible} is given,
|
||||
allow @key{ESC} to interrupt sleep. With @option{--verbose} show countdown
|
||||
of remaining seconds.
|
||||
of remaining seconds. Exit code is set to 0 if timeout expired and to 1
|
||||
if timeout was interrupted by @key{ESC}.
|
||||
@end deffn
|
||||
|
||||
|
||||
@@ -5191,12 +5277,14 @@ is given, use default list of servers.
|
||||
|
||||
|
||||
@node Internationalisation
|
||||
@chapter Charset
|
||||
@chapter Internationalisation
|
||||
|
||||
@section Charset
|
||||
GRUB uses UTF-8 internally other than in rendering where some GRUB-specific
|
||||
appropriate representation is used. All text files (including config) are
|
||||
assumed to be encoded in UTF-8.
|
||||
|
||||
@chapter Filesystems
|
||||
@section Filesystems
|
||||
NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of
|
||||
ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read
|
||||
as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix,
|
||||
@@ -5230,7 +5318,7 @@ treated as distinct from u+combining diaresis. This however means that in
|
||||
order to access file on HFS+ its name must be specified in normalisation form D.
|
||||
On normalized ZFS subvolumes filenames out of normalisation are inaccessible.
|
||||
|
||||
@chapter Output terminal
|
||||
@section Output terminal
|
||||
Firmware output console ``console'' on ARC and IEEE1275 are limited to ASCII.
|
||||
|
||||
BIOS firmware console and VGA text are limited to ASCII and some pseudographics.
|
||||
@@ -5264,7 +5352,7 @@ called ``annotation characters'' If you can complete either of
|
||||
two lists or, better, propose a patch to improve rendering, please contact
|
||||
developer team.
|
||||
|
||||
@chapter Input terminal
|
||||
@section Input terminal
|
||||
Firmware console on BIOS, IEEE1275 and ARC doesn't allow you to enter non-ASCII
|
||||
characters. EFI specification allows for such but author is unaware of any
|
||||
actual implementations. Serial input is currently limited for latin1 (unlikely
|
||||
@@ -5274,15 +5362,15 @@ So no dead keys or advanced input method. Also there is no keymap change hotkey.
|
||||
In practice it makes difficult to enter any text using non-Latin alphabet.
|
||||
Moreover all current input consumers are limited to ASCII.
|
||||
|
||||
@chapter Gettext
|
||||
@section Gettext
|
||||
GRUB supports being translated. For this you need to have language *.mo files in $prefix/locale, load gettext module and set ``lang'' variable.
|
||||
|
||||
@chapter Regexp
|
||||
@section Regexp
|
||||
Regexps work on unicode characters, however no attempt at checking cannonical
|
||||
equivalence has been made. Moreover the classes like [:alpha:] match only
|
||||
ASCII subset.
|
||||
|
||||
@chapter Other
|
||||
@section Other
|
||||
Currently GRUB always uses YEAR-MONTH-DAY HOUR:MINUTE:SECOND [WEEKDAY] 24-hour
|
||||
datetime format but weekdays are translated.
|
||||
GRUB always uses the decimal number format with [0-9] as digits and . as
|
||||
@@ -5752,7 +5840,7 @@ X86 support is summarised in the following table. ``Yes'' means that the kernel
|
||||
PowerPC, IA64 and Sparc64 ports support only Linux. MIPS port supports Linux
|
||||
and multiboot2.
|
||||
|
||||
@chapter Boot tests
|
||||
@section Boot tests
|
||||
|
||||
As you have seen in previous chapter the support matrix is pretty big and some of the configurations are only rarely used. To ensure the quality bootchecks are available for all x86 targets except EFI chainloader, Appleloader and XNU. All x86 platforms have bootcheck facility except ieee1275. Multiboot, multiboot2, BIOS chainloader, ntldr and freebsd-bootloader boot targets are tested only with a fake kernel images. Only Linux is tested among the payloads using Linux protocols.
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ CCAS=$(TARGET_CC)
|
||||
RANLIB=$(TARGET_RANLIB)
|
||||
STRIP=$(TARGET_STRIP)
|
||||
|
||||
if COND_HAVE_FONT_SOURCE
|
||||
TARGET_CFLAGS += -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1
|
||||
endif
|
||||
|
||||
MACHO2IMG=$(top_builddir)/grub-macho2img
|
||||
|
||||
AM_CFLAGS = $(TARGET_CFLAGS)
|
||||
@@ -130,6 +126,24 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
|
||||
endif
|
||||
|
||||
if COND_i386_xen
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||
endif
|
||||
|
||||
if COND_x86_64_xen
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/x86_64/xen/hypercall.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||
endif
|
||||
|
||||
if COND_x86_64_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
@@ -142,12 +156,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
endif
|
||||
|
||||
if COND_alpha_srm
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/alpha/divide.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||
endif
|
||||
|
||||
if COND_mips
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
|
||||
endif
|
||||
@@ -222,6 +230,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
endif
|
||||
|
||||
if COND_arm64_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
endif
|
||||
|
||||
if COND_emu
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
|
||||
@@ -376,43 +389,44 @@ CLEANFILES += $(MOD_FILES)
|
||||
|
||||
if COND_ENABLE_EFIEMU
|
||||
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
|
||||
-rm -f $@; \
|
||||
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -DAPPLE_CC -m32 -Wall -Werror -nostdlib -O2 -c -o $@.bin $< || exit 1; \
|
||||
$(OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
|
||||
rm -f $@.bin; \
|
||||
-rm -f $@
|
||||
-rm -f $@.bin
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
|
||||
if test "x$(TARGET_APPLE_LINKER)" = x1; then \
|
||||
$(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
|
||||
rm -f $@.bin ; \
|
||||
elif test ! -z "$(TARGET_OBJ2ELF)"; then \
|
||||
$(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
|
||||
mv $@.bin $@ ; \
|
||||
else \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -m32 -Wall -Werror -nostdlib -O2 -c -o $@ $< || exit 1; \
|
||||
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
|
||||
mv $@.bin $@ ; \
|
||||
fi
|
||||
|
||||
# Link format -arch,x86_64 means Apple linker
|
||||
efiemu64_c.o: efiemu/runtime/efiemu.c
|
||||
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \
|
||||
else \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
|
||||
fi
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
|
||||
|
||||
efiemu64_s.o: efiemu/runtime/efiemu.S
|
||||
-rm -f $@
|
||||
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \
|
||||
else \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
|
||||
fi
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
|
||||
|
||||
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
|
||||
-rm -f $@; \
|
||||
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||
rm -f $@.bin; \
|
||||
$(TARGET_CC) -m64 -Wl,-r -nostdlib -o $@.bin $^ || exit 1; \
|
||||
$(OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
|
||||
-rm -f $@
|
||||
-rm -f $@.bin
|
||||
$(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
|
||||
if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
|
||||
$(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
|
||||
rm -f $@.bin; \
|
||||
else \
|
||||
$(TARGET_CC) -m64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \
|
||||
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
|
||||
mv $@.bin $@ ; \
|
||||
fi
|
||||
|
||||
platform_DATA += efiemu32.o efiemu64.o
|
||||
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
|
||||
endif
|
||||
|
||||
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
|
||||
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
|
||||
test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
|
||||
for x in $(platform_DATA); do \
|
||||
cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \
|
||||
done
|
||||
|
||||
@@ -59,9 +59,17 @@ kernel = {
|
||||
ia64_efi_ldflags = '-Wl,-r,-d';
|
||||
ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
x86_64_xen_ldflags = '-Wl,-Ttext=0';
|
||||
x86_64_xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
i386_xen_ldflags = '-Wl,-Ttext=0';
|
||||
i386_xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
arm_efi_ldflags = '-Wl,-r,-d';
|
||||
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
arm64_efi_ldflags = '-Wl,-r,-d';
|
||||
arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
||||
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
|
||||
|
||||
@@ -70,8 +78,6 @@ kernel = {
|
||||
|
||||
ldadd = '$(LDADD_KERNEL)';
|
||||
|
||||
alpha_srm_cflags = '-mcpu=ev4 -mno-fp-regs -ffixed-8';
|
||||
|
||||
i386_coreboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_multiboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000';
|
||||
@@ -80,10 +86,8 @@ kernel = {
|
||||
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
|
||||
mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
|
||||
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
|
||||
alpha_srm_ldflags = '-Wl,-Ttext,0x20000000';
|
||||
|
||||
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
|
||||
mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
|
||||
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
||||
emu_cflags = '$(CFLAGS_GNULIB)';
|
||||
emu_cppflags = '$(CPPFLAGS_GNULIB)';
|
||||
@@ -93,6 +97,8 @@ kernel = {
|
||||
i386_pc_startup = kern/i386/pc/startup.S;
|
||||
i386_efi_startup = kern/i386/efi/startup.S;
|
||||
x86_64_efi_startup = kern/x86_64/efi/startup.S;
|
||||
i386_xen_startup = kern/i386/xen/startup.S;
|
||||
x86_64_xen_startup = kern/x86_64/xen/startup.S;
|
||||
i386_qemu_startup = kern/i386/qemu/startup.S;
|
||||
i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
|
||||
i386_coreboot_startup = kern/i386/coreboot/startup.S;
|
||||
@@ -100,9 +106,9 @@ kernel = {
|
||||
mips_startup = kern/mips/startup.S;
|
||||
sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
|
||||
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
|
||||
alpha_srm_startup = kern/alpha/srm/startup.S;
|
||||
arm_uboot_startup = kern/arm/uboot/startup.S;
|
||||
arm_efi_startup = kern/arm/efi/startup.S;
|
||||
arm64_efi_startup = kern/arm64/efi/startup.S;
|
||||
|
||||
common = kern/command.c;
|
||||
common = kern/corecmd.c;
|
||||
@@ -129,7 +135,6 @@ kernel = {
|
||||
noemu_nodist = symlist.c;
|
||||
|
||||
mips = kern/generic/rtc_get_time_ms.c;
|
||||
alpha_srm = kern/generic/rtc_get_time_ms.c;
|
||||
|
||||
ieee1275 = disk/ieee1275/ofdisk.c;
|
||||
ieee1275 = kern/ieee1275/cmain.c;
|
||||
@@ -151,6 +156,7 @@ kernel = {
|
||||
terminfoinkernel = lib/arg.c;
|
||||
|
||||
i386 = kern/i386/dl.c;
|
||||
i386_xen = kern/i386/dl.c;
|
||||
|
||||
i386_coreboot = kern/i386/coreboot/init.c;
|
||||
i386_multiboot = kern/i386/coreboot/init.c;
|
||||
@@ -169,11 +175,20 @@ kernel = {
|
||||
i386_efi = kern/i386/efi/init.c;
|
||||
i386_efi = bus/pci.c;
|
||||
|
||||
x86_64_efi = kern/x86_64/dl.c;
|
||||
x86_64 = kern/x86_64/dl.c;
|
||||
x86_64_xen = kern/x86_64/dl.c;
|
||||
x86_64_efi = kern/x86_64/efi/callwrap.S;
|
||||
x86_64_efi = kern/i386/efi/init.c;
|
||||
x86_64_efi = bus/pci.c;
|
||||
|
||||
xen = kern/i386/tsc.c;
|
||||
x86_64_xen = kern/x86_64/xen/hypercall.S;
|
||||
i386_xen = kern/i386/xen/hypercall.S;
|
||||
xen = kern/xen/init.c;
|
||||
xen = term/xen/console.c;
|
||||
xen = disk/xen/xendisk.c;
|
||||
xen = commands/boot.c;
|
||||
|
||||
ia64_efi = kern/ia64/efi/startup.S;
|
||||
ia64_efi = kern/ia64/efi/init.c;
|
||||
ia64_efi = kern/ia64/dl.c;
|
||||
@@ -182,6 +197,8 @@ kernel = {
|
||||
arm_efi = kern/arm/efi/init.c;
|
||||
arm_efi = kern/arm/efi/misc.c;
|
||||
|
||||
arm64_efi = kern/arm/efi/init.c;
|
||||
|
||||
i386_pc = kern/i386/pc/init.c;
|
||||
i386_pc = kern/i386/pc/mmap.c;
|
||||
i386_pc = term/i386/pc/console.c;
|
||||
@@ -242,15 +259,10 @@ kernel = {
|
||||
arm = kern/arm/cache.c;
|
||||
arm = kern/arm/misc.S;
|
||||
|
||||
alpha_srm = kern/alpha/srm/dispatch.S;
|
||||
alpha_srm = kern/alpha/dl.c;
|
||||
alpha_srm = kern/alpha/cache.S;
|
||||
alpha_srm = kern/alpha/divide.S;
|
||||
alpha_srm = kern/alpha/srm/pal_init.c;
|
||||
alpha_srm = kern/alpha/srm/init.c;
|
||||
alpha_srm = term/alpha/srm/console.c;
|
||||
alpha_srm = disk/alpha/srm/srmdisk.c;
|
||||
alpha_srm = commands/boot.c;
|
||||
arm64 = kern/arm64/cache.c;
|
||||
arm64 = kern/arm64/cache_flush.S;
|
||||
arm64 = kern/arm64/dl.c;
|
||||
arm64 = kern/arm64/dl_helper.c;
|
||||
|
||||
emu = disk/host.c;
|
||||
emu = kern/emu/cache_s.S;
|
||||
@@ -561,6 +573,7 @@ module = {
|
||||
module = {
|
||||
name = pci;
|
||||
common = bus/pci.c;
|
||||
i386_ieee1275 = bus/i386/ieee1275/pci.c;
|
||||
|
||||
enable = i386_pc;
|
||||
enable = i386_ieee1275;
|
||||
@@ -594,15 +607,16 @@ module = {
|
||||
};
|
||||
|
||||
module = {
|
||||
name = check_nt_hiberfil;
|
||||
common = commands/i386/nthibr.c;
|
||||
name = lsxen;
|
||||
common = commands/xen/lsxen.c;
|
||||
cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
enable = xen;
|
||||
};
|
||||
|
||||
library = {
|
||||
name = libgnulib.a;
|
||||
common = gnulib/regex.c;
|
||||
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
|
||||
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
|
||||
module = {
|
||||
name = check_nt_hiberfil;
|
||||
common = commands/i386/nthibr.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -656,8 +670,7 @@ module = {
|
||||
name = regexp;
|
||||
common = commands/regexp.c;
|
||||
common = commands/wildcard.c;
|
||||
ldadd = libgnulib.a;
|
||||
dependencies = libgnulib.a;
|
||||
common = gnulib/regex.c;
|
||||
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
|
||||
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
|
||||
};
|
||||
@@ -740,6 +753,7 @@ module = {
|
||||
enable = mips_arc;
|
||||
enable = ia64_efi;
|
||||
enable = arm_efi;
|
||||
enable = arm64_efi;
|
||||
enable = arm_uboot;
|
||||
};
|
||||
|
||||
@@ -760,8 +774,10 @@ module = {
|
||||
|
||||
module = {
|
||||
name = cpuid;
|
||||
x86 = commands/i386/cpuid.c;
|
||||
common = commands/i386/cpuid.c;
|
||||
enable = x86;
|
||||
enable = i386_xen;
|
||||
enable = x86_64_xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -818,10 +834,10 @@ module = {
|
||||
i386_multiboot = lib/i386/halt.c;
|
||||
i386_coreboot = lib/i386/halt.c;
|
||||
i386_qemu = lib/i386/halt.c;
|
||||
xen = lib/xen/halt.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
efi = lib/efi/halt.c;
|
||||
ieee1275 = lib/ieee1275/halt.c;
|
||||
alpha_srm = lib/alpha/srm/halt.c;
|
||||
|
||||
emu = lib/emu/halt.c;
|
||||
uboot = lib/uboot/halt.c;
|
||||
};
|
||||
@@ -833,13 +849,15 @@ module = {
|
||||
ia64_efi = lib/efi/reboot.c;
|
||||
x86_64_efi = lib/efi/reboot.c;
|
||||
arm_efi = lib/efi/reboot.c;
|
||||
arm64_efi = lib/efi/reboot.c;
|
||||
powerpc_ieee1275 = lib/ieee1275/reboot.c;
|
||||
sparc64_ieee1275 = lib/ieee1275/reboot.c;
|
||||
mips_arc = lib/mips/arc/reboot.c;
|
||||
mips_loongson = lib/mips/loongson/reboot.c;
|
||||
mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
|
||||
xen = lib/xen/reboot.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
uboot = lib/uboot/reboot.c;
|
||||
alpha_srm = lib/alpha/srm/reboot.c;
|
||||
common = commands/reboot.c;
|
||||
};
|
||||
|
||||
@@ -1462,6 +1480,11 @@ module = {
|
||||
common = io/gzio.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = offsetio;
|
||||
common = io/offset.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = bufio;
|
||||
common = io/bufio.c;
|
||||
@@ -1495,13 +1518,21 @@ module = {
|
||||
x86 = lib/i386/relocator64.S;
|
||||
i386 = lib/i386/relocator_asm.S;
|
||||
x86_64 = lib/x86_64/relocator_asm.S;
|
||||
i386_xen = lib/i386/relocator_asm.S;
|
||||
x86_64_xen = lib/x86_64/relocator_asm.S;
|
||||
x86 = lib/i386/relocator.c;
|
||||
x86 = lib/i386/relocator_common_c.c;
|
||||
ieee1275 = lib/ieee1275/relocator.c;
|
||||
efi = lib/efi/relocator.c;
|
||||
mips = lib/mips/relocator_asm.S;
|
||||
mips = lib/mips/relocator.c;
|
||||
powerpc = lib/powerpc/relocator_asm.S;
|
||||
powerpc = lib/powerpc/relocator.c;
|
||||
xen = lib/xen/relocator.c;
|
||||
i386_xen = lib/i386/xen/relocator.S;
|
||||
x86_64_xen = lib/x86_64/xen/relocator.S;
|
||||
xen = lib/i386/relocator_common_c.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
extra_dist = lib/i386/relocator_common.S;
|
||||
extra_dist = kern/powerpc/cache_flush.S;
|
||||
@@ -1509,6 +1540,7 @@ module = {
|
||||
enable = mips;
|
||||
enable = powerpc;
|
||||
enable = x86;
|
||||
enable = xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -1520,9 +1552,10 @@ module = {
|
||||
powerpc_ieee1275 = lib/ieee1275/datetime.c;
|
||||
sparc64_ieee1275 = lib/ieee1275/cmos.c;
|
||||
powerpc_ieee1275 = lib/ieee1275/cmos.c;
|
||||
xen = lib/xen/datetime.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
|
||||
mips_arc = lib/arc/datetime.c;
|
||||
alpha_srm = lib/alpha/srm/datetime.c;
|
||||
enable = noemu;
|
||||
};
|
||||
|
||||
@@ -1536,7 +1569,8 @@ module = {
|
||||
extra_dist = lib/powerpc/setjmp.S;
|
||||
extra_dist = lib/ia64/setjmp.S;
|
||||
extra_dist = lib/ia64/longjmp.S;
|
||||
extra_dist = lib/alpha/setjmp.S;
|
||||
extra_dist = lib/arm/setjmp.S;
|
||||
extra_dist = lib/arm64/setjmp.S;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -1595,6 +1629,7 @@ module = {
|
||||
cppflags = "-DGRUB_USE_MULTIBOOT2";
|
||||
|
||||
common = loader/multiboot.c;
|
||||
common = lib/cmdline.c;
|
||||
common = loader/multiboot_mbi2.c;
|
||||
enable = x86;
|
||||
enable = mips;
|
||||
@@ -1603,6 +1638,7 @@ module = {
|
||||
module = {
|
||||
name = multiboot;
|
||||
common = loader/multiboot.c;
|
||||
common = lib/cmdline.c;
|
||||
x86 = loader/i386/multiboot_mbi.c;
|
||||
extra_dist = loader/multiboot_elfxx.c;
|
||||
enable = x86;
|
||||
@@ -1611,6 +1647,12 @@ module = {
|
||||
module = {
|
||||
name = linux;
|
||||
x86 = loader/i386/linux.c;
|
||||
xen = loader/i386/xen.c;
|
||||
xen = loader/i386/xen_file.c;
|
||||
xen = loader/i386/xen_file32.c;
|
||||
xen = loader/i386/xen_file64.c;
|
||||
extra_dist = loader/i386/xen_fileXX.c;
|
||||
xen_cppflags = '$(CPPFLAGS_XEN)';
|
||||
i386_pc = lib/i386/pc/vesa_modes_table.c;
|
||||
mips = loader/mips/linux.c;
|
||||
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
|
||||
@@ -1649,6 +1691,7 @@ module = {
|
||||
efi = loader/efi/chainloader.c;
|
||||
i386_pc = loader/i386/pc/chainloader.c;
|
||||
i386_coreboot = loader/i386/coreboot/chainloader.c;
|
||||
i386_coreboot = lib/LzmaDec.c;
|
||||
enable = i386_pc;
|
||||
enable = i386_coreboot;
|
||||
enable = efi;
|
||||
@@ -1670,6 +1713,7 @@ module = {
|
||||
enable = x86;
|
||||
enable = ia64_efi;
|
||||
enable = arm_efi;
|
||||
enable = arm64_efi;
|
||||
enable = mips;
|
||||
};
|
||||
|
||||
@@ -1874,6 +1918,32 @@ module = {
|
||||
common = tests/setjmp_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = signature_test;
|
||||
common = tests/signature_test.c;
|
||||
common = tests/signatures.h;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = xnu_uuid_test;
|
||||
common = tests/xnu_uuid_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = pbkdf2_test;
|
||||
common = tests/pbkdf2_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = legacy_password_test;
|
||||
common = tests/legacy_password_test.c;
|
||||
enable = i386_pc;
|
||||
enable = i386_efi;
|
||||
enable = x86_64_efi;
|
||||
enable = emu;
|
||||
enable = xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = div_test;
|
||||
common = tests/div_test.c;
|
||||
@@ -2032,11 +2102,13 @@ module = {
|
||||
emu = lib/i386/pc/vesa_modes_table.c;
|
||||
i386_efi = lib/i386/pc/vesa_modes_table.c;
|
||||
x86_64_efi = lib/i386/pc/vesa_modes_table.c;
|
||||
xen = lib/i386/pc/vesa_modes_table.c;
|
||||
|
||||
enable = i386_pc;
|
||||
enable = i386_efi;
|
||||
enable = x86_64_efi;
|
||||
enable = emu;
|
||||
enable = xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
@@ -2070,8 +2142,12 @@ module = {
|
||||
module = {
|
||||
name = backtrace;
|
||||
x86 = lib/i386/backtrace.c;
|
||||
i386_xen = lib/i386/backtrace.c;
|
||||
x86_64_xen = lib/i386/backtrace.c;
|
||||
common = lib/backtrace.c;
|
||||
enable = x86;
|
||||
enable = i386_xen;
|
||||
enable = x86_64_xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
||||
@@ -31,27 +31,32 @@
|
||||
.macro floppy
|
||||
part_start:
|
||||
|
||||
probe_values:
|
||||
LOCAL(probe_values):
|
||||
.byte 36, 18, 15, 9, 0
|
||||
|
||||
LOCAL(floppy_probe):
|
||||
pushw %dx
|
||||
/*
|
||||
* Perform floppy probe.
|
||||
*/
|
||||
|
||||
movw $probe_values - 1, %si
|
||||
#ifdef __APPLE__
|
||||
LOCAL(probe_values_minus_one) = LOCAL(probe_values) - 1
|
||||
movw MACRO_DOLLAR(LOCAL(probe_values_minus_one)), %si
|
||||
#else
|
||||
movw MACRO_DOLLAR(LOCAL(probe_values)) - 1, %si
|
||||
#endif
|
||||
|
||||
LOCAL(probe_loop):
|
||||
/* reset floppy controller INT 13h AH=0 */
|
||||
xorw %ax, %ax
|
||||
int $0x13
|
||||
int MACRO_DOLLAR(0x13)
|
||||
|
||||
incw %si
|
||||
movb (%si), %cl
|
||||
|
||||
/* if number of sectors is 0, display error and die */
|
||||
cmpb $0, %cl
|
||||
jne 1f
|
||||
testb %cl, %cl
|
||||
jnz 1f
|
||||
|
||||
/*
|
||||
* Floppy disk probe failure.
|
||||
@@ -64,20 +69,20 @@ fd_probe_error_string: .asciz "Floppy"
|
||||
|
||||
1:
|
||||
/* perform read */
|
||||
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
||||
movw MACRO_DOLLAR(GRUB_BOOT_MACHINE_BUFFER_SEG), %bx
|
||||
movw %bx, %es
|
||||
xorw %bx, %bx
|
||||
movw $0x201, %ax
|
||||
movb $0, %ch
|
||||
movb $0, %dh
|
||||
int $0x13
|
||||
movw MACRO_DOLLAR(0x201), %ax
|
||||
movb MACRO_DOLLAR(0), %ch
|
||||
movb MACRO_DOLLAR(0), %dh
|
||||
int MACRO_DOLLAR(0x13)
|
||||
|
||||
/* if error, jump to "LOCAL(probe_loop)" */
|
||||
jc LOCAL(probe_loop)
|
||||
|
||||
/* %cl is already the correct value! */
|
||||
movb $1, %dh
|
||||
movb $79, %ch
|
||||
movb MACRO_DOLLAR(1), %dh
|
||||
movb MACRO_DOLLAR(79), %ch
|
||||
|
||||
jmp LOCAL(final_init)
|
||||
.endm
|
||||
@@ -180,7 +185,9 @@ kernel_address:
|
||||
#ifndef HYBRID_BOOT
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
kernel_sector:
|
||||
.long 1, 0
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
|
||||
@@ -285,7 +292,7 @@ lba_mode:
|
||||
/* the absolute address */
|
||||
movl kernel_sector, %ebx
|
||||
movl %ebx, 8(%si)
|
||||
movl kernel_sector + 4, %ebx
|
||||
movl kernel_sector_high, %ebx
|
||||
movl %ebx, 12(%si)
|
||||
|
||||
/* the segment of buffer address */
|
||||
@@ -318,11 +325,12 @@ LOCAL(chs_mode):
|
||||
int $0x13
|
||||
jnc LOCAL(final_init)
|
||||
|
||||
popw %dx
|
||||
/*
|
||||
* The call failed, so maybe use the floppy probe instead.
|
||||
*/
|
||||
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
||||
jz LOCAL(floppy_probe)
|
||||
testb %dl, %dl
|
||||
jnb LOCAL(floppy_probe)
|
||||
|
||||
/* Nope, we definitely have a hard disk, and we're screwed. */
|
||||
ERR(hd_probe_error_string)
|
||||
@@ -353,7 +361,7 @@ LOCAL(final_init):
|
||||
|
||||
setup_sectors:
|
||||
/* load logical sector start (top half) */
|
||||
movl kernel_sector + 4, %eax
|
||||
movl kernel_sector_high, %eax
|
||||
|
||||
orl %eax, %eax
|
||||
jnz LOCAL(geometry_error)
|
||||
@@ -505,7 +513,9 @@ LOCAL(message):
|
||||
#ifdef HYBRID_BOOT
|
||||
. = _start + 0x1b0
|
||||
kernel_sector:
|
||||
.long 1, 0
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
.long 0
|
||||
#endif
|
||||
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
|
||||
nt_magic:
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
.extern __bss_start
|
||||
.extern _end
|
||||
.extern _edata
|
||||
|
||||
.globl __start, _start, start
|
||||
.set noreorder
|
||||
@@ -248,8 +249,9 @@ cmdlinedone:
|
||||
#include "../../kern/mips/cache_flush.S"
|
||||
|
||||
/* Decompress the payload. */
|
||||
lui $a0, %hi(__bss_start)
|
||||
addiu $a0, $a0, %lo(__bss_start)
|
||||
lui $a0, %hi(_edata)
|
||||
addiu $a0, $a0, %lo(_edata)
|
||||
|
||||
lui $t0, %hi(base)
|
||||
addiu $t0, $t0, %lo(base)
|
||||
subu $a0, $a0, $t0
|
||||
@@ -265,16 +267,16 @@ cmdlinedone:
|
||||
*/
|
||||
move $s6, $a3
|
||||
|
||||
lui $t0, %hi(EXT_C(grub_decompress_core))
|
||||
addiu $t0, $t0, %lo(EXT_C(grub_decompress_core))
|
||||
lui $t9, %hi(EXT_C(grub_decompress_core))
|
||||
addiu $t9, $t9, %lo(EXT_C(grub_decompress_core))
|
||||
|
||||
#ifdef GRUB_MACHINE_ARC
|
||||
lui $sp, %hi(_start - 512)
|
||||
jalr $t0
|
||||
jalr $t9
|
||||
addiu $sp, $sp, %lo(_start - 512)
|
||||
#else
|
||||
lui $sp, %hi(_start - 256)
|
||||
jalr $t0
|
||||
jalr $t9
|
||||
addiu $sp, $sp, %lo(_start - 256)
|
||||
#endif
|
||||
move $a0, $s1
|
||||
@@ -287,3 +289,11 @@ cmdlinedone:
|
||||
|
||||
jr $t1
|
||||
nop
|
||||
/* Ensure that .data section is created. In code we suppose that _edata
|
||||
is first location not in decompressor image. Strictly speaking it's
|
||||
_edata only when .data is present and _etext otherwise. But checking
|
||||
for .data presence would cost more in code than it is to ensure that
|
||||
.data is created.
|
||||
*/
|
||||
.data
|
||||
.long 0
|
||||
|
||||
@@ -48,7 +48,7 @@ kernel_byte: .xword (2 << 9)
|
||||
boot_path_end:
|
||||
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||
#else
|
||||
#define boot_path (_start + 512)
|
||||
#define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
|
||||
#define boot_path_end (_start + 1024)
|
||||
#include <grub/offsets.h>
|
||||
|
||||
@@ -140,7 +140,11 @@ prom_call:
|
||||
|
||||
boot_continue:
|
||||
mov %o7, PIC_REG /* PIC base */
|
||||
#ifndef CDBOOT
|
||||
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
|
||||
#else
|
||||
GET_ABS(_start + 512, %l1) /* OF argument slots */
|
||||
#endif
|
||||
|
||||
/* Find the /chosen node so we can fetch the stdout handle,
|
||||
* and thus perform console output.
|
||||
|
||||
42
grub-core/bus/i386/ieee1275/pci.c
Normal file
42
grub-core/bus/i386/ieee1275/pci.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/pci.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
volatile void *
|
||||
grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
|
||||
grub_addr_t base,
|
||||
grub_size_t size)
|
||||
{
|
||||
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE))
|
||||
return (volatile void *) base;
|
||||
if (grub_ieee1275_map (base, base, size, 7))
|
||||
grub_fatal ("couldn't map 0x%lx", base);
|
||||
return (volatile void *) base;
|
||||
}
|
||||
|
||||
void
|
||||
grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
|
||||
volatile void *mem __attribute__ ((unused)),
|
||||
grub_size_t size __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
@@ -534,11 +534,20 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||
"EHCI grub_ehci_pci_iter: registers above 4G are not supported\n");
|
||||
return 0;
|
||||
}
|
||||
base &= GRUB_PCI_ADDR_MEM_MASK;
|
||||
if (!base)
|
||||
{
|
||||
grub_dprintf ("ehci",
|
||||
"EHCI: EHCI is not mapped\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word(addr,
|
||||
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
|
||||
GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| grub_pci_read_word(addr));
|
||||
|
||||
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n");
|
||||
}
|
||||
|
||||
@@ -265,16 +265,20 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
base = grub_pci_read (addr);
|
||||
|
||||
#if 0
|
||||
/* Stop if there is no IO space base address defined. */
|
||||
if (! (base & 1))
|
||||
return 0;
|
||||
#endif
|
||||
base &= GRUB_PCI_ADDR_MEM_MASK;
|
||||
if (!base)
|
||||
{
|
||||
grub_dprintf ("ehci",
|
||||
"EHCI: EHCI is not mapper\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word(addr,
|
||||
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
|
||||
GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| grub_pci_read_word(addr));
|
||||
|
||||
grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x\n",
|
||||
class, subclass, interf);
|
||||
|
||||
@@ -217,12 +217,6 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
||||
if (class != 0x0c || subclass != 0x03 || interf != 0x00)
|
||||
return 0;
|
||||
|
||||
/* Set bus master - needed for coreboot or broken BIOSes */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| grub_pci_read_word (addr));
|
||||
|
||||
/* Determine IO base address. */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
|
||||
base = grub_pci_read (addr);
|
||||
@@ -233,6 +227,13 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
||||
if ((base & GRUB_UHCI_IOMASK) == 0)
|
||||
return 0;
|
||||
|
||||
/* Set bus master - needed for coreboot or broken BIOSes */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| grub_pci_read_word (addr));
|
||||
|
||||
grub_dprintf ("uhci", "base = %x\n", base);
|
||||
|
||||
/* Allocate memory for the controller and register it. */
|
||||
|
||||
@@ -146,8 +146,7 @@ grub_loader_boot (void)
|
||||
return grub_error (GRUB_ERR_NO_KERNEL,
|
||||
N_("you need to load the kernel first"));
|
||||
|
||||
if (grub_loader_flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_machine_fini ();
|
||||
grub_machine_fini (grub_loader_flags);
|
||||
|
||||
for (cur = preboots_head; cur; cur = cur->next)
|
||||
{
|
||||
|
||||
@@ -63,17 +63,23 @@ hextoval (char c)
|
||||
static grub_err_t
|
||||
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (context, hash->contextsize);
|
||||
grub_uint8_t readbuf[4096];
|
||||
void *context;
|
||||
grub_uint8_t *readbuf;
|
||||
#define BUF_SIZE 4096
|
||||
readbuf = grub_malloc (BUF_SIZE);
|
||||
if (!readbuf)
|
||||
return grub_errno;
|
||||
context = grub_zalloc (hash->contextsize);
|
||||
if (!readbuf || !context)
|
||||
goto fail;
|
||||
|
||||
grub_memset (context, 0, sizeof (context));
|
||||
hash->init (context);
|
||||
while (1)
|
||||
{
|
||||
grub_ssize_t r;
|
||||
r = grub_file_read (file, readbuf, sizeof (readbuf));
|
||||
r = grub_file_read (file, readbuf, BUF_SIZE);
|
||||
if (r < 0)
|
||||
return grub_errno;
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, readbuf, r);
|
||||
@@ -81,7 +87,15 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
hash->final (context);
|
||||
grub_memcpy (result, hash->read (context), hash->mdlen);
|
||||
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
@@ -90,12 +104,15 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
{
|
||||
grub_file_t hashlist, file;
|
||||
char *buf = NULL;
|
||||
grub_uint8_t expected[hash->mdlen];
|
||||
grub_uint8_t actual[hash->mdlen];
|
||||
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_err_t err;
|
||||
unsigned i;
|
||||
unsigned unread = 0, mismatch = 0;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
hashlist = grub_file_open (hashfilename);
|
||||
if (!hashlist)
|
||||
return grub_errno;
|
||||
@@ -205,6 +222,9 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
if (!hash)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
if (state[2].set)
|
||||
prefix = state[2].arg;
|
||||
|
||||
@@ -218,7 +238,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
|
||||
for (i = 0; i < (unsigned) argc; i++)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (result, hash->mdlen);
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
|
||||
grub_file_t file;
|
||||
grub_err_t err;
|
||||
unsigned j;
|
||||
|
||||
@@ -81,7 +81,25 @@ grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
|
||||
return grub_cmos_write (byte, value & (~(1 << bit)));
|
||||
}
|
||||
|
||||
static grub_command_t cmd, cmd_clean;
|
||||
static grub_err_t
|
||||
grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int byte, bit;
|
||||
grub_err_t err;
|
||||
grub_uint8_t value;
|
||||
|
||||
err = parse_args (argc, argv, &byte, &bit);
|
||||
if (err)
|
||||
return err;
|
||||
err = grub_cmos_read (byte, &value);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return grub_cmos_write (byte, value | (1 << bit));
|
||||
}
|
||||
|
||||
static grub_command_t cmd, cmd_clean, cmd_set;
|
||||
|
||||
|
||||
GRUB_MOD_INIT(cmostest)
|
||||
@@ -92,10 +110,14 @@ GRUB_MOD_INIT(cmostest)
|
||||
cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
|
||||
N_("BYTE:BIT"),
|
||||
N_("Clean bit at BYTE:BIT in CMOS."));
|
||||
cmd_set = grub_register_command ("cmosset", grub_cmd_cmosset,
|
||||
N_("BYTE:BIT"),
|
||||
N_("Set bit at BYTE:BIT in CMOS."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(cmostest)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
grub_unregister_command (cmd_clean);
|
||||
grub_unregister_command (cmd_set);
|
||||
}
|
||||
|
||||
@@ -553,8 +553,13 @@ check_password_md5_real (const char *entered,
|
||||
grub_size_t enteredlen = grub_strlen (entered);
|
||||
unsigned char alt_result[MD5_HASHLEN];
|
||||
unsigned char *digest;
|
||||
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
|
||||
grub_uint8_t *ctx;
|
||||
grub_size_t i;
|
||||
int ret;
|
||||
|
||||
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
|
||||
if (!ctx)
|
||||
return 0;
|
||||
|
||||
GRUB_MD_MD5->init (ctx);
|
||||
GRUB_MD_MD5->write (ctx, entered, enteredlen);
|
||||
@@ -600,7 +605,9 @@ check_password_md5_real (const char *entered,
|
||||
GRUB_MD_MD5->final (ctx);
|
||||
}
|
||||
|
||||
return (grub_crypto_memcmp (digest, pw->hash, MD5_HASHLEN) == 0);
|
||||
ret = (grub_crypto_memcmp (digest, pw->hash, MD5_HASHLEN) == 0);
|
||||
grub_free (ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
@@ -723,18 +730,12 @@ grub_cmd_legacy_password (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
int
|
||||
grub_legacy_check_md5_password (int argc, char **args,
|
||||
char *entered)
|
||||
{
|
||||
struct legacy_md5_password *pw = NULL;
|
||||
char entered[GRUB_AUTH_MAX_PASSLEN];
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
grub_puts_ (N_("Enter password: "));
|
||||
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
|
||||
return GRUB_ACCESS_DENIED;
|
||||
int ret;
|
||||
|
||||
if (args[0][0] != '-' || args[0][1] != '-')
|
||||
{
|
||||
@@ -743,17 +744,33 @@ grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unuse
|
||||
grub_memset (correct, 0, sizeof (correct));
|
||||
grub_strncpy (correct, args[0], sizeof (correct));
|
||||
|
||||
if (grub_crypto_memcmp (entered, correct, GRUB_AUTH_MAX_PASSLEN) != 0)
|
||||
return GRUB_ACCESS_DENIED;
|
||||
return GRUB_ERR_NONE;
|
||||
return grub_crypto_memcmp (entered, correct, GRUB_AUTH_MAX_PASSLEN) == 0;
|
||||
}
|
||||
|
||||
pw = parse_legacy_md5 (argc, args);
|
||||
|
||||
if (!pw)
|
||||
return 0;
|
||||
|
||||
ret = check_password_md5_real (entered, pw);
|
||||
grub_free (pw);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
char entered[GRUB_AUTH_MAX_PASSLEN];
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
grub_puts_ (N_("Enter password: "));
|
||||
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
|
||||
return GRUB_ACCESS_DENIED;
|
||||
|
||||
if (!check_password_md5_real (entered, pw))
|
||||
if (!grub_legacy_check_md5_password (argc, args,
|
||||
entered))
|
||||
return GRUB_ACCESS_DENIED;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
@@ -70,12 +70,12 @@ get_uuid (const char *name, char **uuid, int getnative)
|
||||
case GRUB_DISK_DEVICE_ARCDISK_ID:
|
||||
case GRUB_DISK_DEVICE_HOSTDISK_ID:
|
||||
case GRUB_DISK_DEVICE_UBOOTDISK_ID:
|
||||
case GRUB_DISK_DEVICE_SRMDISK_ID:
|
||||
break;
|
||||
|
||||
/* Native disks. */
|
||||
case GRUB_DISK_DEVICE_ATA_ID:
|
||||
case GRUB_DISK_DEVICE_SCSI_ID:
|
||||
case GRUB_DISK_DEVICE_XEN:
|
||||
if (getnative)
|
||||
break;
|
||||
|
||||
|
||||
@@ -192,22 +192,39 @@ free_pk (struct grub_public_key *pk)
|
||||
struct grub_public_subkey *nsk, *sk;
|
||||
for (sk = pk->subkeys; sk; sk = nsk)
|
||||
{
|
||||
grub_size_t i;
|
||||
for (i = 0; i < ARRAY_SIZE (sk->mpis); i++)
|
||||
if (sk->mpis[i])
|
||||
gcry_mpi_release (sk->mpis[i]);
|
||||
nsk = sk->next;
|
||||
grub_free (sk);
|
||||
}
|
||||
grub_free (pk);
|
||||
}
|
||||
|
||||
#define READBUF_SIZE 4096
|
||||
|
||||
struct grub_public_key *
|
||||
grub_load_public_key (grub_file_t f)
|
||||
{
|
||||
grub_err_t err;
|
||||
struct grub_public_key *ret;
|
||||
struct grub_public_subkey **last = 0;
|
||||
void *fingerprint_context = NULL;
|
||||
grub_uint8_t *buffer = NULL;
|
||||
|
||||
ret = grub_zalloc (sizeof (*ret));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
{
|
||||
grub_free (fingerprint_context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer = grub_zalloc (READBUF_SIZE);
|
||||
fingerprint_context = grub_zalloc (GRUB_MD_SHA1->contextsize);
|
||||
|
||||
if (!buffer || !fingerprint_context)
|
||||
goto fail;
|
||||
|
||||
last = &ret->subkeys;
|
||||
|
||||
@@ -221,7 +238,6 @@ grub_load_public_key (grub_file_t f)
|
||||
struct grub_public_subkey *sk;
|
||||
grub_size_t i;
|
||||
grub_uint16_t len_be;
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (fingerprint_context, GRUB_MD_SHA1->contextsize);
|
||||
|
||||
err = read_packet_header (f, &type, &len);
|
||||
|
||||
@@ -230,7 +246,11 @@ grub_load_public_key (grub_file_t f)
|
||||
if (type == 0xfe)
|
||||
continue;
|
||||
if (type == 0xff)
|
||||
return ret;
|
||||
{
|
||||
grub_free (fingerprint_context);
|
||||
grub_free (buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_dprintf ("crypt", "len = %x\n", (int) len);
|
||||
|
||||
@@ -294,7 +314,6 @@ grub_load_public_key (grub_file_t f)
|
||||
{
|
||||
grub_uint16_t l;
|
||||
grub_size_t lb;
|
||||
grub_uint8_t buffer[4096];
|
||||
if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
@@ -302,7 +321,7 @@ grub_load_public_key (grub_file_t f)
|
||||
}
|
||||
|
||||
lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
|
||||
if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
|
||||
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
@@ -337,6 +356,8 @@ grub_load_public_key (grub_file_t f)
|
||||
}
|
||||
fail:
|
||||
free_pk (ret);
|
||||
grub_free (fingerprint_context);
|
||||
grub_free (buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -464,7 +485,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (context, hash->contextsize);
|
||||
void *context = NULL;
|
||||
unsigned char *hval;
|
||||
grub_ssize_t rem = grub_be_to_cpu16 (v4.hashed_sub);
|
||||
grub_uint32_t headlen = grub_cpu_to_be32 (rem + 6);
|
||||
@@ -475,18 +496,22 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
gcry_mpi_t hmpi;
|
||||
grub_uint64_t keyid = 0;
|
||||
struct grub_public_subkey *sk;
|
||||
grub_uint8_t *readbuf = NULL;
|
||||
|
||||
context = grub_zalloc (hash->contextsize);
|
||||
readbuf = grub_zalloc (READBUF_SIZE);
|
||||
if (!context || !readbuf)
|
||||
goto fail;
|
||||
|
||||
grub_memset (context, 0, sizeof (context));
|
||||
hash->init (context);
|
||||
if (buf)
|
||||
hash->write (context, buf, size);
|
||||
else
|
||||
while (1)
|
||||
{
|
||||
grub_uint8_t readbuf[4096];
|
||||
r = grub_file_read (f, readbuf, sizeof (readbuf));
|
||||
r = grub_file_read (f, readbuf, READBUF_SIZE);
|
||||
if (r < 0)
|
||||
return grub_errno;
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, readbuf, r);
|
||||
@@ -496,10 +521,10 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
hash->write (context, &v4, sizeof (v4));
|
||||
while (rem)
|
||||
{
|
||||
grub_uint8_t readbuf[4096];
|
||||
r = grub_file_read (sig, readbuf, rem < (grub_ssize_t) sizeof (readbuf) ? rem : (grub_ssize_t) sizeof (readbuf));
|
||||
r = grub_file_read (sig, readbuf,
|
||||
rem < READBUF_SIZE ? rem : READBUF_SIZE);
|
||||
if (r < 0)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, readbuf, r);
|
||||
@@ -511,17 +536,16 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
hash->write (context, &headlen, sizeof (headlen));
|
||||
r = grub_file_read (sig, &unhashed_sub, sizeof (unhashed_sub));
|
||||
if (r != sizeof (unhashed_sub))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
{
|
||||
grub_uint8_t readbuf[4096];
|
||||
grub_uint8_t *ptr;
|
||||
grub_uint32_t l;
|
||||
rem = grub_be_to_cpu16 (unhashed_sub);
|
||||
if (rem > (int) sizeof (readbuf))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
if (rem > READBUF_SIZE)
|
||||
goto fail;
|
||||
r = grub_file_read (sig, readbuf, rem);
|
||||
if (r != rem)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
for (ptr = readbuf; ptr < readbuf + rem; ptr += l)
|
||||
{
|
||||
if (*ptr < 192)
|
||||
@@ -552,9 +576,9 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
hval = hash->read (context);
|
||||
|
||||
if (grub_file_read (sig, hash_start, sizeof (hash_start)) != sizeof (hash_start))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
|
||||
grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (sig));
|
||||
|
||||
@@ -562,25 +586,24 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
{
|
||||
grub_uint16_t l;
|
||||
grub_size_t lb;
|
||||
grub_uint8_t buffer[4096];
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
lb = (grub_be_to_cpu16 (l) + 7) / 8;
|
||||
grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l));
|
||||
if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
|
||||
goto fail;
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
if (grub_file_read (sig, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
if (grub_file_read (sig, readbuf + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
|
||||
goto fail;
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
grub_memcpy (buffer, &l, sizeof (l));
|
||||
grub_memcpy (readbuf, &l, sizeof (l));
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
|
||||
if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP,
|
||||
buffer, lb + sizeof (grub_uint16_t), 0))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
readbuf, lb + sizeof (grub_uint16_t), 0))
|
||||
goto fail;
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
}
|
||||
|
||||
@@ -589,18 +612,42 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
else
|
||||
sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid);
|
||||
if (!sk)
|
||||
/* TRANSLATORS: %08x is 32-bit key id. */
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
|
||||
{
|
||||
/* TRANSLATORS: %08x is 32-bit key id. */
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"),
|
||||
keyid);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (pkalgos[pk].pad (&hmpi, hval, hash, sk))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
goto fail;
|
||||
if (!*pkalgos[pk].algo)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), pkalgos[pk].module);
|
||||
if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0))
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
}
|
||||
{
|
||||
grub_dl_load (pkalgos[pk].module);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
if (!*pkalgos[pk].algo)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"),
|
||||
pkalgos[pk].module);
|
||||
goto fail;
|
||||
}
|
||||
if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0))
|
||||
goto fail;
|
||||
|
||||
grub_free (context);
|
||||
grub_free (readbuf);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (context);
|
||||
grub_free (readbuf);
|
||||
if (!grub_errno)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
return grub_errno;
|
||||
}
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
@@ -697,8 +744,8 @@ static grub_err_t
|
||||
grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_file_t f, sig;
|
||||
grub_err_t err;
|
||||
grub_file_t f = NULL, sig = NULL;
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
struct grub_public_key *pk = NULL;
|
||||
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
@@ -729,19 +776,27 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
||||
grub_file_filter_disable_all ();
|
||||
f = grub_file_open (args[0]);
|
||||
if (!f)
|
||||
return grub_errno;
|
||||
{
|
||||
err = grub_errno;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_file_filter_disable_all ();
|
||||
sig = grub_file_open (args[1]);
|
||||
if (!sig)
|
||||
{
|
||||
grub_file_close (f);
|
||||
return grub_errno;
|
||||
err = grub_errno;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = grub_verify_signature (f, sig, pk);
|
||||
grub_file_close (f);
|
||||
grub_file_close (sig);
|
||||
fail:
|
||||
if (sig)
|
||||
grub_file_close (sig);
|
||||
if (f)
|
||||
grub_file_close (f);
|
||||
if (pk)
|
||||
free_pk (pk);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
90
grub-core/commands/xen/lsxen.c
Normal file
90
grub-core/commands/xen/lsxen.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/xen.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static int
|
||||
hook (const char *dir, void *hook_data __attribute__ ((unused)))
|
||||
{
|
||||
grub_printf ("%s\n", dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_lsxen (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
char *dir;
|
||||
grub_err_t err;
|
||||
char *buf;
|
||||
|
||||
if (argc >= 1)
|
||||
return grub_xenstore_dir (args[0], hook, NULL);
|
||||
|
||||
buf = grub_xenstore_get_file ("domid", NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
dir = grub_xasprintf ("/local/domain/%s", buf);
|
||||
grub_free (buf);
|
||||
err = grub_xenstore_dir (dir, hook, NULL);
|
||||
grub_free (dir);
|
||||
return err;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_catxen (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
const char *dir = "domid";
|
||||
char *buf;
|
||||
|
||||
if (argc >= 1)
|
||||
dir = args[0];
|
||||
|
||||
buf = grub_xenstore_get_file (dir, NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
grub_xputs (buf);
|
||||
grub_xputs ("\n");
|
||||
grub_free (buf);
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
}
|
||||
|
||||
static grub_command_t cmd_ls, cmd_cat;
|
||||
|
||||
GRUB_MOD_INIT (lsxen)
|
||||
{
|
||||
cmd_ls = grub_register_command ("xen_ls", grub_cmd_lsxen, "[DIR]",
|
||||
N_("List XEN storage."));
|
||||
cmd_cat = grub_register_command ("xen_cat", grub_cmd_catxen, "[DIR]",
|
||||
N_("List XEN storage."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (lsxen)
|
||||
{
|
||||
grub_unregister_command (cmd_ls);
|
||||
grub_unregister_command (cmd_cat);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_uint8_t *xnu_uuid;
|
||||
char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
|
||||
char *ptr;
|
||||
grub_uint8_t ctx[GRUB_MD_MD5->contextsize];
|
||||
void *ctx;
|
||||
int low = 0;
|
||||
|
||||
if (argc < 1)
|
||||
@@ -65,11 +65,14 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16));
|
||||
|
||||
GRUB_MD_MD5->init (&ctx);
|
||||
GRUB_MD_MD5->write (&ctx, hash_prefix, sizeof (hash_prefix));
|
||||
GRUB_MD_MD5->write (&ctx, &serial, sizeof (serial));
|
||||
GRUB_MD_MD5->final (&ctx);
|
||||
xnu_uuid = GRUB_MD_MD5->read (&ctx);
|
||||
ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
|
||||
if (!ctx)
|
||||
return grub_errno;
|
||||
GRUB_MD_MD5->init (ctx);
|
||||
GRUB_MD_MD5->write (ctx, hash_prefix, sizeof (hash_prefix));
|
||||
GRUB_MD_MD5->write (ctx, &serial, sizeof (serial));
|
||||
GRUB_MD_MD5->final (ctx);
|
||||
xnu_uuid = GRUB_MD_MD5->read (ctx);
|
||||
|
||||
grub_snprintf (uuid_string, sizeof (uuid_string),
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
@@ -91,6 +94,8 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc > 1)
|
||||
grub_env_set (args[1], uuid_string);
|
||||
|
||||
grub_free (ctx);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ diffuse (const gcry_md_spec_t * hash, grub_uint8_t * src,
|
||||
|
||||
grub_size_t fullblocks = size / hash->mdlen;
|
||||
int padding = size % hash->mdlen;
|
||||
grub_uint8_t final[hash->mdlen];
|
||||
grub_uint8_t temp[sizeof (IV) + hash->mdlen];
|
||||
grub_uint8_t final[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t temp[sizeof (IV) + GRUB_CRYPTO_MAX_MDLEN];
|
||||
|
||||
/* hash block the whole data set with different IVs to produce
|
||||
* more than just a single data block
|
||||
@@ -76,6 +76,9 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
|
||||
if (bufblock == NULL)
|
||||
return GPG_ERR_OUT_OF_MEMORY;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
grub_memset (bufblock, 0, blocksize);
|
||||
for (i = 0; i < blocknumbers - 1; i++)
|
||||
{
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
/* ofdisk.c - Open Firmware disk access. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2004,2006,2007,2008,2009,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/alpha/srm/srm.h>
|
||||
|
||||
static grub_srm_fileno_t last_handle = 0;
|
||||
static char *last_path = NULL;
|
||||
|
||||
static int lnum = 0;
|
||||
|
||||
struct srmdisk_hash_ent
|
||||
{
|
||||
char *devpath;
|
||||
int num;
|
||||
struct srmdisk_hash_ent *next;
|
||||
};
|
||||
|
||||
#define SRMDISK_HASH_SZ 8
|
||||
static struct srmdisk_hash_ent *srmdisk_hash[SRMDISK_HASH_SZ];
|
||||
|
||||
static int
|
||||
srmdisk_hash_fn (const char *devpath)
|
||||
{
|
||||
int hash = 0;
|
||||
while (*devpath)
|
||||
hash ^= *devpath++;
|
||||
return (hash & (SRMDISK_HASH_SZ - 1));
|
||||
}
|
||||
|
||||
static struct srmdisk_hash_ent *
|
||||
srmdisk_hash_find (const char *devpath)
|
||||
{
|
||||
struct srmdisk_hash_ent *p = srmdisk_hash[srmdisk_hash_fn (devpath)];
|
||||
|
||||
while (p)
|
||||
{
|
||||
if (!grub_strcmp (p->devpath, devpath))
|
||||
break;
|
||||
p = p->next;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static struct srmdisk_hash_ent *
|
||||
srmdisk_hash_add (char *devpath)
|
||||
{
|
||||
struct srmdisk_hash_ent *p;
|
||||
struct srmdisk_hash_ent **head = &srmdisk_hash[srmdisk_hash_fn(devpath)];
|
||||
|
||||
p = grub_malloc (sizeof (*p));
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->devpath = devpath;
|
||||
p->next = *head;
|
||||
p->num = lnum++;
|
||||
*head = p;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
grub_srmdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull)
|
||||
{
|
||||
(void) hook;
|
||||
(void) pull;
|
||||
(void) hook_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
reopen (const char *name)
|
||||
{
|
||||
grub_uint64_t r;
|
||||
|
||||
if (last_path && grub_strcmp (last_path, name) == 0)
|
||||
{
|
||||
grub_dprintf ("srmdisk", "using already opened %s\n", name);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
if (last_path)
|
||||
{
|
||||
grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_CLOSE, last_handle);
|
||||
grub_free (last_path);
|
||||
last_path = NULL;
|
||||
last_handle = 0;
|
||||
}
|
||||
|
||||
grub_dprintf ("srmdisk", "opening %s\n", name);
|
||||
r = grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_OPEN, name, grub_strlen (name));
|
||||
grub_printf ("<%lx>", r);
|
||||
while (1);
|
||||
if (r & (1ULL << 63))
|
||||
{
|
||||
grub_dprintf ("srmdisk", "couldn't open %s\n", name);
|
||||
return grub_error (GRUB_ERR_IO, "couldn't open %s", name);
|
||||
}
|
||||
last_path = grub_strdup (name);
|
||||
if (!last_path)
|
||||
return grub_errno;
|
||||
last_handle = r & 0xffffffff;
|
||||
grub_dprintf ("srmdisk", "opened %s\n", name);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_srmdisk_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
char *fullname;
|
||||
grub_err_t err;
|
||||
struct srmdisk_hash_ent *hash;
|
||||
|
||||
if (grub_memcmp (name, "srm/", 4) != 0)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not srm device");
|
||||
fullname = grub_strdup (name + 4);
|
||||
if (!fullname)
|
||||
return grub_errno;
|
||||
disk->data = fullname;
|
||||
grub_dprintf ("srmdisk", "opening %s\n", fullname);
|
||||
|
||||
hash = srmdisk_hash_find (fullname);
|
||||
if (!hash)
|
||||
hash = srmdisk_hash_add (fullname);
|
||||
if (!hash)
|
||||
return grub_errno;
|
||||
|
||||
err = reopen (fullname);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
{
|
||||
grub_uint64_t res = 0;
|
||||
int i;
|
||||
|
||||
/* FIXME: findout the block size. */
|
||||
for (i = 31; i >= 0; i--)
|
||||
{
|
||||
char buf[512];
|
||||
grub_dprintf ("srmdisk",
|
||||
"seek to 0x%" PRIxGRUB_UINT64_T "\n",
|
||||
res | (1UL << i));
|
||||
if (grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_READ, last_handle, 512,
|
||||
buf, res | (1ULL << i)) & (1ULL << 63))
|
||||
continue;
|
||||
res |= (1ULL << i);
|
||||
}
|
||||
grub_dprintf ("srmdisk",
|
||||
"determined disk size 0x%" PRIxGRUB_UINT64_T "\n", res);
|
||||
disk->total_sectors = res;
|
||||
}
|
||||
|
||||
disk->id = hash->num;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_srmdisk_close (grub_disk_t disk)
|
||||
{
|
||||
grub_free (disk->data);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_srmdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
err = reopen (disk->data);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* FIXME: handle incomplete read. */
|
||||
if (grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_READ, last_handle,
|
||||
size << 9,
|
||||
buf, sector) & (1ULL << 63))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "read failed");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_srmdisk_write (grub_disk_t disk __attribute ((unused)),
|
||||
grub_disk_addr_t sector __attribute ((unused)),
|
||||
grub_size_t size __attribute ((unused)),
|
||||
const char *buf __attribute ((unused)))
|
||||
{
|
||||
return GRUB_ERR_NOT_IMPLEMENTED_YET;
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_srmdisk_dev =
|
||||
{
|
||||
.name = "srmdisk",
|
||||
.id = GRUB_DISK_DEVICE_SRMDISK_ID,
|
||||
.iterate = grub_srmdisk_iterate,
|
||||
.open = grub_srmdisk_open,
|
||||
.close = grub_srmdisk_close,
|
||||
.read = grub_srmdisk_read,
|
||||
.write = grub_srmdisk_write,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
void
|
||||
grub_srmdisk_init (void)
|
||||
{
|
||||
grub_disk_dev_register (&grub_srmdisk_dev);
|
||||
}
|
||||
|
||||
void
|
||||
grub_srmdisk_fini (void)
|
||||
{
|
||||
if (last_path)
|
||||
{
|
||||
grub_alpha_srm_dispatch (GRUB_ALPHA_SRM_CLOSE, last_handle);
|
||||
grub_free (last_path);
|
||||
last_path = NULL;
|
||||
last_handle = 0;
|
||||
}
|
||||
|
||||
grub_disk_dev_unregister (&grub_srmdisk_dev);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
SCSI 0 1004 0 2 200 0 0
|
||||
@@ -109,7 +109,9 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
|
||||
void *iv)
|
||||
{
|
||||
grub_uint8_t *inptr, *outptr, *end;
|
||||
grub_uint8_t ivt[cipher->cipher->blocksize];
|
||||
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
if (!cipher->cipher->decrypt)
|
||||
return GPG_ERR_NOT_SUPPORTED;
|
||||
if (size % cipher->cipher->blocksize != 0)
|
||||
@@ -132,7 +134,9 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
|
||||
void *iv)
|
||||
{
|
||||
grub_uint8_t *inptr, *outptr, *end;
|
||||
grub_uint8_t ivt[cipher->cipher->blocksize];
|
||||
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
if (!cipher->cipher->decrypt)
|
||||
return GPG_ERR_NOT_SUPPORTED;
|
||||
if (size % cipher->cipher->blocksize != 0)
|
||||
@@ -218,6 +222,9 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
grub_size_t i;
|
||||
gcry_err_code_t err;
|
||||
|
||||
if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
/* The only mode without IV. */
|
||||
if (dev->mode == GRUB_CRYPTODISK_MODE_ECB && !dev->rekey)
|
||||
return (do_encrypt ? grub_crypto_ecb_encrypt (dev->cipher, data, data, len)
|
||||
@@ -228,7 +235,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
grub_size_t sz = ((dev->cipher->cipher->blocksize
|
||||
+ sizeof (grub_uint32_t) - 1)
|
||||
/ sizeof (grub_uint32_t));
|
||||
grub_uint32_t iv[sz];
|
||||
grub_uint32_t iv[(GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE + 3) / 4];
|
||||
|
||||
if (dev->rekey)
|
||||
{
|
||||
@@ -242,7 +249,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
}
|
||||
}
|
||||
|
||||
grub_memset (iv, 0, sz * sizeof (iv[0]));
|
||||
grub_memset (iv, 0, sizeof (iv));
|
||||
switch (dev->mode_iv)
|
||||
{
|
||||
case GRUB_CRYPTODISK_MODE_IV_NULL:
|
||||
@@ -250,9 +257,11 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH:
|
||||
{
|
||||
grub_uint64_t tmp;
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (ctx, dev->iv_hash->contextsize);
|
||||
void *ctx;
|
||||
|
||||
grub_memset (ctx, 0, sizeof (ctx));
|
||||
ctx = grub_zalloc (dev->iv_hash->contextsize);
|
||||
if (!ctx)
|
||||
return GPG_ERR_OUT_OF_MEMORY;
|
||||
|
||||
tmp = grub_cpu_to_le64 (sector << dev->log_sector_size);
|
||||
dev->iv_hash->init (ctx);
|
||||
@@ -261,6 +270,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
dev->iv_hash->final (ctx);
|
||||
|
||||
grub_memcpy (iv, dev->iv_hash->read (ctx), sizeof (iv));
|
||||
grub_free (ctx);
|
||||
}
|
||||
break;
|
||||
case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
|
||||
@@ -407,7 +417,9 @@ grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t ke
|
||||
if (dev->mode_iv == GRUB_CRYPTODISK_MODE_IV_ESSIV)
|
||||
{
|
||||
grub_size_t essiv_keysize = dev->essiv_hash->mdlen;
|
||||
grub_uint8_t hashed_key[essiv_keysize];
|
||||
grub_uint8_t hashed_key[GRUB_CRYPTO_MAX_MDLEN];
|
||||
if (essiv_keysize > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
grub_crypto_hash (dev->essiv_hash, hashed_key, key, keysize);
|
||||
err = grub_crypto_cipher_set_key (dev->essiv_cipher,
|
||||
@@ -999,12 +1011,14 @@ hex (grub_uint8_t val)
|
||||
|
||||
/* Open a file named NAME and initialize FILE. */
|
||||
static char *
|
||||
luks_script_get (void)
|
||||
luks_script_get (grub_size_t *sz)
|
||||
{
|
||||
grub_cryptodisk_t i;
|
||||
grub_size_t size = 0;
|
||||
char *ptr, *ret;
|
||||
|
||||
*sz = 0;
|
||||
|
||||
for (i = cryptodisk_list; i != NULL; i = i->next)
|
||||
if (grub_strcmp (i->modname, "luks") == 0)
|
||||
{
|
||||
@@ -1086,6 +1100,7 @@ luks_script_get (void)
|
||||
*ptr++ = '\n';
|
||||
}
|
||||
*ptr = '\0';
|
||||
*sz = ptr - ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -934,7 +934,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
totsize = (nmemb - level / 3) * disk_size;
|
||||
totsize = (nmemb - ((unsigned) level / 3U)) * disk_size;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -146,7 +146,10 @@ geli_rekey (struct grub_cryptodisk *dev, grub_uint64_t zoneno)
|
||||
grub_uint64_t zone;
|
||||
} __attribute__ ((packed)) tohash
|
||||
= { {'e', 'k', 'e', 'y'}, grub_cpu_to_le64 (zoneno) };
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (key, dev->hash->mdlen);
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (key, GRUB_CRYPTO_MAX_MDLEN);
|
||||
|
||||
if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
grub_dprintf ("geli", "rekeying %" PRIuGRUB_UINT64_T " keysize=%d\n",
|
||||
zoneno, dev->rekey_derived_size);
|
||||
@@ -163,11 +166,13 @@ static inline gcry_err_code_t
|
||||
make_uuid (const struct grub_geli_phdr *header,
|
||||
char *uuid)
|
||||
{
|
||||
grub_uint8_t uuidbin[GRUB_MD_SHA256->mdlen];
|
||||
grub_uint8_t uuidbin[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
|
||||
gcry_err_code_t err;
|
||||
grub_uint8_t *iptr;
|
||||
char *optr;
|
||||
|
||||
if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
|
||||
return GPG_ERR_TOO_LARGE;
|
||||
err = grub_crypto_hmac_buffer (GRUB_MD_SHA256,
|
||||
header->salt, sizeof (header->salt),
|
||||
"uuid", sizeof ("uuid") - 1, uuidbin);
|
||||
@@ -175,7 +180,7 @@ make_uuid (const struct grub_geli_phdr *header,
|
||||
return err;
|
||||
|
||||
optr = uuid;
|
||||
for (iptr = uuidbin; iptr < &uuidbin[ARRAY_SIZE (uuidbin)]; iptr++)
|
||||
for (iptr = uuidbin; iptr < &uuidbin[GRUB_MD_SHA256->mdlen]; iptr++)
|
||||
{
|
||||
grub_snprintf (optr, 3, "%02x", *iptr);
|
||||
optr += 2;
|
||||
@@ -242,10 +247,13 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
||||
const struct gcry_cipher_spec *ciph;
|
||||
const char *ciphername = NULL;
|
||||
gcry_err_code_t gcry_err;
|
||||
char uuid[GRUB_MD_SHA256->mdlen * 2 + 1];
|
||||
char uuid[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
|
||||
grub_disk_addr_t sector;
|
||||
grub_err_t err;
|
||||
|
||||
if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
|
||||
return NULL;
|
||||
|
||||
sector = grub_disk_get_size (disk);
|
||||
if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
|
||||
return NULL;
|
||||
@@ -379,10 +387,10 @@ static grub_err_t
|
||||
recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
||||
{
|
||||
grub_size_t keysize;
|
||||
grub_uint8_t digest[dev->hash->mdlen];
|
||||
grub_uint8_t geomkey[dev->hash->mdlen];
|
||||
grub_uint8_t verify_key[dev->hash->mdlen];
|
||||
grub_uint8_t zero[dev->cipher->cipher->blocksize];
|
||||
grub_uint8_t digest[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
char passphrase[MAX_PASSPHRASE] = "";
|
||||
unsigned i;
|
||||
gcry_err_code_t gcry_err;
|
||||
@@ -391,6 +399,12 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
||||
grub_disk_addr_t sector;
|
||||
grub_err_t err;
|
||||
|
||||
if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return grub_error (GRUB_ERR_BUG, "cipher block is too long");
|
||||
|
||||
if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
sector = grub_disk_get_size (source);
|
||||
if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
|
||||
return grub_error (GRUB_ERR_BUG, "not a geli");
|
||||
@@ -452,12 +466,12 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
||||
}
|
||||
|
||||
gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
|
||||
sizeof (geomkey), "\1", 1, digest);
|
||||
dev->hash->mdlen, "\1", 1, digest);
|
||||
if (gcry_err)
|
||||
return grub_crypto_gcry_error (gcry_err);
|
||||
|
||||
gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
|
||||
sizeof (geomkey), "\0", 1, verify_key);
|
||||
dev->hash->mdlen, "\0", 1, verify_key);
|
||||
if (gcry_err)
|
||||
return grub_crypto_gcry_error (gcry_err);
|
||||
|
||||
@@ -467,7 +481,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
||||
for (i = 0; i < ARRAY_SIZE (header.keys); i++)
|
||||
{
|
||||
struct grub_geli_key candidate_key;
|
||||
grub_uint8_t key_hmac[dev->hash->mdlen];
|
||||
grub_uint8_t key_hmac[GRUB_CRYPTO_MAX_MDLEN];
|
||||
|
||||
/* Check if keyslot is enabled. */
|
||||
if (! (header.keys_used & (1 << i)))
|
||||
@@ -488,7 +502,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
||||
return grub_crypto_gcry_error (gcry_err);
|
||||
|
||||
gcry_err = grub_crypto_hmac_buffer (dev->hash, verify_key,
|
||||
sizeof (verify_key),
|
||||
dev->hash->mdlen,
|
||||
&candidate_key,
|
||||
(sizeof (candidate_key)
|
||||
- sizeof (candidate_key.hmac)),
|
||||
|
||||
@@ -426,6 +426,10 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
||||
disk->total_sectors = total_sectors;
|
||||
/* Limit the max to 0x7f because of Phoenix EDD. */
|
||||
disk->max_agglomerate = 0x7f >> GRUB_DISK_CACHE_BITS;
|
||||
COMPILE_TIME_ASSERT ((0x7f >> GRUB_DISK_CACHE_BITS
|
||||
<< (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
|
||||
+ sizeof (struct grub_biosdisk_dap)
|
||||
< GRUB_MEMORY_MACHINE_SCRATCH_SIZE);
|
||||
|
||||
disk->data = data;
|
||||
|
||||
|
||||
@@ -31,11 +31,14 @@ static grub_ieee1275_ihandle_t last_ihandle;
|
||||
struct ofdisk_hash_ent
|
||||
{
|
||||
char *devpath;
|
||||
char *open_path;
|
||||
char *grub_devpath;
|
||||
int is_boot;
|
||||
int is_cdrom;
|
||||
/* Pointer to shortest available name on nodes representing canonical names,
|
||||
otherwise NULL. */
|
||||
const char *shortest;
|
||||
const char *grub_shortest;
|
||||
struct ofdisk_hash_ent *next;
|
||||
};
|
||||
|
||||
@@ -70,12 +73,50 @@ ofdisk_hash_add_real (char *devpath)
|
||||
{
|
||||
struct ofdisk_hash_ent *p;
|
||||
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
|
||||
const char *iptr;
|
||||
char *optr;
|
||||
|
||||
p = grub_zalloc (sizeof (*p));
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->devpath = devpath;
|
||||
|
||||
p->grub_devpath = grub_malloc (sizeof ("ieee1275/")
|
||||
+ 2 * grub_strlen (p->devpath));
|
||||
|
||||
if (!p->grub_devpath)
|
||||
{
|
||||
grub_free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
|
||||
{
|
||||
p->open_path = grub_malloc (grub_strlen (p->devpath) + 3);
|
||||
if (!p->open_path)
|
||||
{
|
||||
grub_free (p->grub_devpath);
|
||||
grub_free (p);
|
||||
return NULL;
|
||||
}
|
||||
optr = grub_stpcpy (p->open_path, p->devpath);
|
||||
*optr++ = ':';
|
||||
*optr++ = '0';
|
||||
*optr = '\0';
|
||||
}
|
||||
else
|
||||
p->open_path = p->devpath;
|
||||
|
||||
optr = grub_stpcpy (p->grub_devpath, "ieee1275/");
|
||||
for (iptr = p->devpath; *iptr; )
|
||||
{
|
||||
if (*iptr == ',')
|
||||
*optr++ = '\\';
|
||||
*optr++ = *iptr++;
|
||||
}
|
||||
*optr = 0;
|
||||
|
||||
p->next = *head;
|
||||
*head = p;
|
||||
return p;
|
||||
@@ -104,7 +145,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
||||
|
||||
if (!curcan)
|
||||
{
|
||||
p->shortest = devpath;
|
||||
p->shortest = p->devpath;
|
||||
p->grub_shortest = p->grub_devpath;
|
||||
if (check_string_cdrom (devpath))
|
||||
p->is_cdrom = 1;
|
||||
return p;
|
||||
@@ -125,7 +167,10 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
||||
{
|
||||
if (!pcan->shortest
|
||||
|| grub_strlen (pcan->shortest) > grub_strlen (devpath))
|
||||
pcan->shortest = devpath;
|
||||
{
|
||||
pcan->shortest = p->devpath;
|
||||
pcan->grub_shortest = p->grub_devpath;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
@@ -288,21 +333,8 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
if (!ent->is_boot && ent->is_cdrom)
|
||||
continue;
|
||||
|
||||
{
|
||||
char buffer[sizeof ("ieee1275/") + 2 * grub_strlen (ent->shortest)];
|
||||
const char *iptr;
|
||||
char *optr;
|
||||
optr = grub_stpcpy (buffer, "ieee1275/");
|
||||
for (iptr = ent->shortest; *iptr; )
|
||||
{
|
||||
if (*iptr == ',')
|
||||
*optr++ = '\\';
|
||||
*optr++ = *iptr++;
|
||||
}
|
||||
*optr = 0;
|
||||
if (hook (buffer, hook_data))
|
||||
return 1;
|
||||
}
|
||||
if (hook (ent->grub_shortest, hook_data))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -396,7 +428,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
||||
if (!op)
|
||||
return grub_errno;
|
||||
disk->id = (unsigned long) op;
|
||||
disk->data = op->devpath;
|
||||
disk->data = op->open_path;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -428,20 +460,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
|
||||
last_ihandle = 0;
|
||||
last_devpath = NULL;
|
||||
|
||||
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
|
||||
{
|
||||
char name2[grub_strlen (disk->data) + 3];
|
||||
char *p;
|
||||
|
||||
grub_strcpy (name2, disk->data);
|
||||
p = name2 + grub_strlen (name2);
|
||||
*p++ = ':';
|
||||
*p++ = '0';
|
||||
*p = 0;
|
||||
grub_ieee1275_open (name2, &last_ihandle);
|
||||
}
|
||||
else
|
||||
grub_ieee1275_open (disk->data, &last_ihandle);
|
||||
grub_ieee1275_open (disk->data, &last_ihandle);
|
||||
if (! last_ihandle)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
last_devpath = disk->data;
|
||||
|
||||
@@ -316,6 +316,8 @@ luks_recover_key (grub_disk_t source,
|
||||
|
||||
grub_puts_ (N_("Attempting to decrypt master key..."));
|
||||
keysize = grub_be_to_cpu32 (header.keyBytes);
|
||||
if (keysize > GRUB_CRYPTODISK_MAX_KEYLEN)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "key is too long");
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
|
||||
if (grub_be_to_cpu32 (header.keyblock[i].active) == LUKS_KEY_ENABLED
|
||||
@@ -344,8 +346,8 @@ luks_recover_key (grub_disk_t source,
|
||||
for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
|
||||
{
|
||||
gcry_err_code_t gcry_err;
|
||||
grub_uint8_t candidate_key[keysize];
|
||||
grub_uint8_t digest[keysize];
|
||||
grub_uint8_t candidate_key[GRUB_CRYPTODISK_MAX_KEYLEN];
|
||||
grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN];
|
||||
|
||||
/* Check if keyslot is enabled. */
|
||||
if (grub_be_to_cpu32 (header.keyblock[i].active) != LUKS_KEY_ENABLED)
|
||||
|
||||
@@ -184,9 +184,10 @@ grub_mdraid_detect (grub_disk_t disk,
|
||||
{
|
||||
grub_disk_addr_t sector;
|
||||
grub_uint64_t size;
|
||||
struct grub_raid_super_09 sb;
|
||||
struct grub_raid_super_09 *sb = NULL;
|
||||
grub_uint32_t *uuid;
|
||||
grub_uint32_t level;
|
||||
struct grub_diskfilter_vg *ret;
|
||||
|
||||
/* The sector where the mdraid 0.90 superblock is stored, if available. */
|
||||
size = grub_disk_get_size (disk);
|
||||
@@ -195,27 +196,31 @@ grub_mdraid_detect (grub_disk_t disk,
|
||||
return NULL;
|
||||
sector = NEW_SIZE_SECTORS (size);
|
||||
|
||||
if (grub_disk_read (disk, sector, 0, SB_BYTES, &sb))
|
||||
sb = grub_malloc (sizeof (*sb));
|
||||
if (!sb)
|
||||
return NULL;
|
||||
|
||||
if (grub_disk_read (disk, sector, 0, SB_BYTES, sb))
|
||||
goto fail;
|
||||
|
||||
/* Look whether there is a mdraid 0.90 superblock. */
|
||||
if (sb.md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
|
||||
if (sb->md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
|
||||
/* not 0.9x raid. */
|
||||
return NULL;
|
||||
goto fail;
|
||||
|
||||
if (sb.major_version != grub_cpu_to_md32_compile_time (0)
|
||||
|| sb.minor_version != grub_cpu_to_md32_compile_time (90))
|
||||
if (sb->major_version != grub_cpu_to_md32_compile_time (0)
|
||||
|| sb->minor_version != grub_cpu_to_md32_compile_time (90))
|
||||
/* Unsupported version. */
|
||||
return NULL;
|
||||
goto fail;
|
||||
|
||||
/* No need for explicit check that sb.size is 0 (unspecified) since
|
||||
/* No need for explicit check that sb->size is 0 (unspecified) since
|
||||
0 >= non-0 is false. */
|
||||
if (((grub_disk_addr_t) grub_md_to_cpu32 (sb.size)) * 2 >= size)
|
||||
return NULL;
|
||||
if (((grub_disk_addr_t) grub_md_to_cpu32 (sb->size)) * 2 >= size)
|
||||
goto fail;
|
||||
|
||||
/* FIXME: Check the checksum. */
|
||||
|
||||
level = grub_md_to_cpu32 (sb.level);
|
||||
level = grub_md_to_cpu32 (sb->level);
|
||||
/* Multipath. */
|
||||
if ((int) level == -4)
|
||||
level = 1;
|
||||
@@ -225,37 +230,43 @@ grub_mdraid_detect (grub_disk_t disk,
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"unsupported RAID level: %d", level);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
if (grub_md_to_cpu32 (sb.this_disk.number) == 0xffff
|
||||
|| grub_md_to_cpu32 (sb.this_disk.number) == 0xfffe)
|
||||
if (grub_md_to_cpu32 (sb->this_disk.number) == 0xffff
|
||||
|| grub_md_to_cpu32 (sb->this_disk.number) == 0xfffe)
|
||||
/* Spares aren't implemented. */
|
||||
return NULL;
|
||||
goto fail;
|
||||
|
||||
uuid = grub_malloc (16);
|
||||
if (!uuid)
|
||||
return NULL;
|
||||
goto fail;
|
||||
|
||||
uuid[0] = grub_swap_bytes32 (sb.set_uuid0);
|
||||
uuid[1] = grub_swap_bytes32 (sb.set_uuid1);
|
||||
uuid[2] = grub_swap_bytes32 (sb.set_uuid2);
|
||||
uuid[3] = grub_swap_bytes32 (sb.set_uuid3);
|
||||
uuid[0] = grub_swap_bytes32 (sb->set_uuid0);
|
||||
uuid[1] = grub_swap_bytes32 (sb->set_uuid1);
|
||||
uuid[2] = grub_swap_bytes32 (sb->set_uuid2);
|
||||
uuid[3] = grub_swap_bytes32 (sb->set_uuid3);
|
||||
|
||||
*start_sector = 0;
|
||||
|
||||
id->uuidlen = 0;
|
||||
id->id = grub_md_to_cpu32 (sb.this_disk.number);
|
||||
id->id = grub_md_to_cpu32 (sb->this_disk.number);
|
||||
|
||||
char buf[32];
|
||||
grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb.md_minor));
|
||||
return grub_diskfilter_make_raid (16, (char *) uuid,
|
||||
grub_md_to_cpu32 (sb.raid_disks), buf,
|
||||
(sb.size) ? ((grub_disk_addr_t)
|
||||
grub_md_to_cpu32 (sb.size)) * 2
|
||||
: sector,
|
||||
grub_md_to_cpu32 (sb.chunk_size) >> 9,
|
||||
grub_md_to_cpu32 (sb.layout),
|
||||
level);
|
||||
grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb->md_minor));
|
||||
ret = grub_diskfilter_make_raid (16, (char *) uuid,
|
||||
grub_md_to_cpu32 (sb->raid_disks), buf,
|
||||
(sb->size) ? ((grub_disk_addr_t)
|
||||
grub_md_to_cpu32 (sb->size)) * 2
|
||||
: sector,
|
||||
grub_md_to_cpu32 (sb->chunk_size) >> 9,
|
||||
grub_md_to_cpu32 (sb->layout),
|
||||
level);
|
||||
grub_free (sb);
|
||||
return ret;
|
||||
|
||||
fail:
|
||||
grub_free (sb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct grub_diskfilter grub_mdraid_dev = {
|
||||
|
||||
@@ -402,9 +402,15 @@ grub_pata_pciinit (grub_pci_device_t dev,
|
||||
bar2 = grub_pci_read (addr);
|
||||
|
||||
/* Check if the BARs describe an IO region. */
|
||||
if ((bar1 & 1) && (bar2 & 1))
|
||||
if ((bar1 & 1) && (bar2 & 1) && (bar1 & ~3))
|
||||
{
|
||||
rega = bar1 & ~3;
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word (addr, grub_pci_read_word (addr)
|
||||
| GRUB_PCI_COMMAND_IO_ENABLED
|
||||
| GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ grub_ubootdisk_register (struct device_info *newdev)
|
||||
{
|
||||
case DT_STOR_IDE:
|
||||
case DT_STOR_SATA:
|
||||
case DT_STOR_SCSI:
|
||||
case DT_STOR_MMC:
|
||||
case DT_STOR_USB:
|
||||
/* hd */
|
||||
|
||||
458
grub-core/disk/xen/xendisk.c
Normal file
458
grub-core/disk/xen/xendisk.c
Normal file
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/xen.h>
|
||||
#include <grub/time.h>
|
||||
#include <xen/io/blkif.h>
|
||||
|
||||
struct virtdisk
|
||||
{
|
||||
int handle;
|
||||
char *fullname;
|
||||
char *backend_dir;
|
||||
char *frontend_dir;
|
||||
struct blkif_sring *shared_page;
|
||||
struct blkif_front_ring ring;
|
||||
grub_xen_grant_t grant;
|
||||
grub_xen_evtchn_t evtchn;
|
||||
void *dma_page;
|
||||
grub_xen_grant_t dma_grant;
|
||||
};
|
||||
|
||||
#define xen_wmb() mb()
|
||||
#define xen_mb() mb()
|
||||
|
||||
static struct virtdisk *virtdisks;
|
||||
static grub_size_t vdiskcnt;
|
||||
|
||||
static int
|
||||
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull)
|
||||
{
|
||||
grub_size_t i;
|
||||
|
||||
if (pull != GRUB_DISK_PULL_NONE)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < vdiskcnt; i++)
|
||||
if (hook (virtdisks[i].fullname, hook_data))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_virtdisk_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
grub_size_t i;
|
||||
grub_uint32_t secsize;
|
||||
char fdir[200];
|
||||
char *buf;
|
||||
|
||||
for (i = 0; i < vdiskcnt; i++)
|
||||
if (grub_strcmp (name, virtdisks[i].fullname) == 0)
|
||||
break;
|
||||
if (i == vdiskcnt)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
|
||||
disk->data = &virtdisks[i];
|
||||
disk->id = i;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
disk->total_sectors = grub_strtoull (buf, 0, 10);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size",
|
||||
virtdisks[i].backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
secsize = grub_strtoull (buf, 0, 10);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if ((secsize & (secsize - 1)) || !secsize || secsize < 512
|
||||
|| secsize > GRUB_XEN_PAGE_SIZE)
|
||||
return grub_error (GRUB_ERR_IO, "unsupported sector size %d", secsize);
|
||||
|
||||
for (disk->log_sector_size = 0;
|
||||
(1U << disk->log_sector_size) < secsize; disk->log_sector_size++);
|
||||
|
||||
disk->total_sectors >>= disk->log_sector_size - 9;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_virtdisk_close (grub_disk_t disk __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_virtdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
{
|
||||
struct virtdisk *data = disk->data;
|
||||
|
||||
while (size)
|
||||
{
|
||||
grub_size_t cur;
|
||||
struct blkif_request *req;
|
||||
struct blkif_response *resp;
|
||||
int sta = 0;
|
||||
struct evtchn_send send;
|
||||
cur = size;
|
||||
if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
|
||||
cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
|
||||
while (RING_FULL (&data->ring))
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
|
||||
req->operation = BLKIF_OP_READ;
|
||||
req->nr_segments = 1;
|
||||
req->handle = data->handle;
|
||||
req->id = 0;
|
||||
req->sector_number = sector << (disk->log_sector_size - 9);
|
||||
req->seg[0].gref = data->dma_grant;
|
||||
req->seg[0].first_sect = 0;
|
||||
req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
|
||||
data->ring.req_prod_pvt++;
|
||||
RING_PUSH_REQUESTS (&data->ring);
|
||||
mb ();
|
||||
send.port = data->evtchn;
|
||||
grub_xen_event_channel_op (EVTCHNOP_send, &send);
|
||||
|
||||
while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
|
||||
{
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
mb ();
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
int wtd;
|
||||
RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
|
||||
if (!wtd)
|
||||
break;
|
||||
resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
|
||||
data->ring.rsp_cons++;
|
||||
if (resp->status)
|
||||
sta = resp->status;
|
||||
}
|
||||
if (sta)
|
||||
return grub_error (GRUB_ERR_IO, "read failed");
|
||||
grub_memcpy (buf, data->dma_page, cur << disk->log_sector_size);
|
||||
size -= cur;
|
||||
sector += cur;
|
||||
buf += cur << disk->log_sector_size;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_virtdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, const char *buf)
|
||||
{
|
||||
struct virtdisk *data = disk->data;
|
||||
|
||||
while (size)
|
||||
{
|
||||
grub_size_t cur;
|
||||
struct blkif_request *req;
|
||||
struct blkif_response *resp;
|
||||
int sta = 0;
|
||||
struct evtchn_send send;
|
||||
cur = size;
|
||||
if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
|
||||
cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
|
||||
|
||||
grub_memcpy (data->dma_page, buf, cur << disk->log_sector_size);
|
||||
|
||||
while (RING_FULL (&data->ring))
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
|
||||
req->operation = BLKIF_OP_WRITE;
|
||||
req->nr_segments = 1;
|
||||
req->handle = data->handle;
|
||||
req->id = 0;
|
||||
req->sector_number = sector << (disk->log_sector_size - 9);
|
||||
req->seg[0].gref = data->dma_grant;
|
||||
req->seg[0].first_sect = 0;
|
||||
req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
|
||||
data->ring.req_prod_pvt++;
|
||||
RING_PUSH_REQUESTS (&data->ring);
|
||||
mb ();
|
||||
send.port = data->evtchn;
|
||||
grub_xen_event_channel_op (EVTCHNOP_send, &send);
|
||||
|
||||
while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
|
||||
{
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
mb ();
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
int wtd;
|
||||
RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
|
||||
if (!wtd)
|
||||
break;
|
||||
resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
|
||||
data->ring.rsp_cons++;
|
||||
if (resp->status)
|
||||
sta = resp->status;
|
||||
}
|
||||
if (sta)
|
||||
return grub_error (GRUB_ERR_IO, "write failed");
|
||||
size -= cur;
|
||||
sector += cur;
|
||||
buf += cur << disk->log_sector_size;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_virtdisk_dev = {
|
||||
.name = "xen",
|
||||
.id = GRUB_DISK_DEVICE_XEN,
|
||||
.iterate = grub_virtdisk_iterate,
|
||||
.open = grub_virtdisk_open,
|
||||
.close = grub_virtdisk_close,
|
||||
.read = grub_virtdisk_read,
|
||||
.write = grub_virtdisk_write,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
static int
|
||||
count (const char *dir __attribute__ ((unused)), void *data)
|
||||
{
|
||||
grub_size_t *ctr = data;
|
||||
(*ctr)++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
fill (const char *dir, void *data)
|
||||
{
|
||||
grub_size_t *ctr = data;
|
||||
domid_t dom;
|
||||
/* "dir" is just a number, at most 19 characters. */
|
||||
char fdir[200];
|
||||
char num[20];
|
||||
grub_err_t err;
|
||||
void *buf;
|
||||
struct evtchn_alloc_unbound alloc_unbound;
|
||||
|
||||
/* Shouldn't happen unles some hotplug happened. */
|
||||
if (vdiskcnt >= *ctr)
|
||||
return 1;
|
||||
virtdisks[vdiskcnt].handle = grub_strtoul (dir, 0, 10);
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_errno = 0;
|
||||
return 0;
|
||||
}
|
||||
virtdisks[vdiskcnt].fullname = 0;
|
||||
virtdisks[vdiskcnt].backend_dir = 0;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend", dir);
|
||||
virtdisks[vdiskcnt].backend_dir = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!virtdisks[vdiskcnt].backend_dir)
|
||||
goto out_fail_1;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/dev",
|
||||
virtdisks[vdiskcnt].backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
{
|
||||
grub_errno = 0;
|
||||
virtdisks[vdiskcnt].fullname = grub_xasprintf ("xenid/%s", dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
virtdisks[vdiskcnt].fullname = grub_xasprintf ("xen/%s", (char *) buf);
|
||||
grub_free (buf);
|
||||
}
|
||||
if (!virtdisks[vdiskcnt].fullname)
|
||||
goto out_fail_1;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend-id", dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
goto out_fail_1;
|
||||
|
||||
dom = grub_strtoul (buf, 0, 10);
|
||||
grub_free (buf);
|
||||
if (grub_errno)
|
||||
goto out_fail_1;
|
||||
|
||||
virtdisks[vdiskcnt].shared_page =
|
||||
grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].grant);
|
||||
if (!virtdisks[vdiskcnt].shared_page)
|
||||
goto out_fail_1;
|
||||
|
||||
virtdisks[vdiskcnt].dma_page =
|
||||
grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].dma_grant);
|
||||
if (!virtdisks[vdiskcnt].dma_page)
|
||||
goto out_fail_2;
|
||||
|
||||
alloc_unbound.dom = DOMID_SELF;
|
||||
alloc_unbound.remote_dom = dom;
|
||||
|
||||
grub_xen_event_channel_op (EVTCHNOP_alloc_unbound, &alloc_unbound);
|
||||
virtdisks[vdiskcnt].evtchn = alloc_unbound.port;
|
||||
|
||||
SHARED_RING_INIT (virtdisks[vdiskcnt].shared_page);
|
||||
FRONT_RING_INIT (&virtdisks[vdiskcnt].ring, virtdisks[vdiskcnt].shared_page,
|
||||
GRUB_XEN_PAGE_SIZE);
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/ring-ref", dir);
|
||||
grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].grant);
|
||||
err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
|
||||
if (err)
|
||||
goto out_fail_3;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/event-channel", dir);
|
||||
grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].evtchn);
|
||||
err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
|
||||
if (err)
|
||||
goto out_fail_3;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/protocol", dir);
|
||||
err = grub_xenstore_write_file (fdir, XEN_IO_PROTO_ABI_NATIVE,
|
||||
grub_strlen (XEN_IO_PROTO_ABI_NATIVE));
|
||||
if (err)
|
||||
goto out_fail_3;
|
||||
|
||||
struct gnttab_dump_table dt;
|
||||
dt.dom = DOMID_SELF;
|
||||
grub_xen_grant_table_op (GNTTABOP_dump_table, (void *) &dt, 1);
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/state", dir);
|
||||
err = grub_xenstore_write_file (fdir, "3", 1);
|
||||
if (err)
|
||||
goto out_fail_3;
|
||||
|
||||
while (1)
|
||||
{
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/state",
|
||||
virtdisks[vdiskcnt].backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
goto out_fail_3;
|
||||
if (grub_strcmp (buf, "2") != 0)
|
||||
break;
|
||||
grub_free (buf);
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
}
|
||||
grub_dprintf ("xen", "state=%s\n", (char *) buf);
|
||||
grub_free (buf);
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s", dir);
|
||||
|
||||
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
|
||||
|
||||
vdiskcnt++;
|
||||
return 0;
|
||||
|
||||
out_fail_3:
|
||||
grub_xen_free_shared_page (virtdisks[vdiskcnt].dma_page);
|
||||
out_fail_2:
|
||||
grub_xen_free_shared_page (virtdisks[vdiskcnt].shared_page);
|
||||
out_fail_1:
|
||||
grub_free (virtdisks[vdiskcnt].backend_dir);
|
||||
grub_free (virtdisks[vdiskcnt].fullname);
|
||||
|
||||
grub_errno = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_xendisk_init (void)
|
||||
{
|
||||
grub_size_t ctr = 0;
|
||||
if (grub_xenstore_dir ("device/vbd", count, &ctr))
|
||||
grub_errno = 0;
|
||||
|
||||
if (!ctr)
|
||||
return;
|
||||
|
||||
virtdisks = grub_malloc (ctr * sizeof (virtdisks[0]));
|
||||
if (!virtdisks)
|
||||
return;
|
||||
if (grub_xenstore_dir ("device/vbd", fill, &ctr))
|
||||
grub_errno = 0;
|
||||
|
||||
grub_disk_dev_register (&grub_virtdisk_dev);
|
||||
}
|
||||
|
||||
void
|
||||
grub_xendisk_fini (void)
|
||||
{
|
||||
char fdir[200];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < vdiskcnt; i++)
|
||||
{
|
||||
char *buf;
|
||||
struct evtchn_close close_op = {.port = virtdisks[i].evtchn };
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/state",
|
||||
virtdisks[i].frontend_dir);
|
||||
grub_xenstore_write_file (fdir, "6", 1);
|
||||
|
||||
while (1)
|
||||
{
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/state",
|
||||
virtdisks[i].backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
grub_dprintf ("xen", "state=%s\n", (char *) buf);
|
||||
|
||||
if (!buf || grub_strcmp (buf, "6") == 0)
|
||||
break;
|
||||
grub_free (buf);
|
||||
grub_xen_sched_op (SCHEDOP_yield, 0);
|
||||
}
|
||||
grub_free (buf);
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/ring-ref",
|
||||
virtdisks[i].frontend_dir);
|
||||
grub_xenstore_write_file (fdir, NULL, 0);
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/event-channel",
|
||||
virtdisks[i].frontend_dir);
|
||||
grub_xenstore_write_file (fdir, NULL, 0);
|
||||
|
||||
grub_xen_free_shared_page (virtdisks[i].dma_page);
|
||||
grub_xen_free_shared_page (virtdisks[i].shared_page);
|
||||
|
||||
grub_xen_event_channel_op (EVTCHNOP_close, &close_op);
|
||||
|
||||
/* Prepare for handoff. */
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/state",
|
||||
virtdisks[i].frontend_dir);
|
||||
grub_xenstore_write_file (fdir, "1", 1);
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,10 @@ SUFFIX (grub_efiemu_crc) (void)
|
||||
int handle;
|
||||
grub_off_t off;
|
||||
struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
|
||||
grub_uint8_t crc32_context[GRUB_MD_CRC32->contextsize];
|
||||
grub_uint32_t crc32_val;
|
||||
|
||||
if (GRUB_MD_CRC32->mdlen != 4)
|
||||
return grub_error (GRUB_ERR_BUG, "incorrect mdlen");
|
||||
|
||||
/* compute CRC32 of runtime_services */
|
||||
err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
|
||||
@@ -134,12 +137,11 @@ SUFFIX (grub_efiemu_crc) (void)
|
||||
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
|
||||
|
||||
runtime_services->hdr.crc32 = 0;
|
||||
GRUB_MD_CRC32->init(crc32_context);
|
||||
GRUB_MD_CRC32->write(crc32_context, runtime_services, runtime_services->hdr.header_size);
|
||||
GRUB_MD_CRC32->final(crc32_context);
|
||||
|
||||
grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
|
||||
runtime_services, runtime_services->hdr.header_size);
|
||||
runtime_services->hdr.crc32 =
|
||||
grub_be_to_cpu32(*(grub_uint32_t*)GRUB_MD_CRC32->read(crc32_context));
|
||||
grub_be_to_cpu32(crc32_val);
|
||||
|
||||
err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
|
||||
if (err)
|
||||
@@ -147,12 +149,11 @@ SUFFIX (grub_efiemu_crc) (void)
|
||||
|
||||
/* compute CRC32 of system table */
|
||||
SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
|
||||
GRUB_MD_CRC32->init(crc32_context);
|
||||
GRUB_MD_CRC32->write(crc32_context, SUFFIX (grub_efiemu_system_table),
|
||||
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
|
||||
GRUB_MD_CRC32->final(crc32_context);
|
||||
grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
|
||||
SUFFIX (grub_efiemu_system_table),
|
||||
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
|
||||
SUFFIX (grub_efiemu_system_table)->hdr.crc32 =
|
||||
grub_be_to_cpu32(*(grub_uint32_t*)GRUB_MD_CRC32->read(crc32_context));
|
||||
grub_be_to_cpu32(crc32_val);
|
||||
|
||||
grub_dprintf ("efiemu","system_table = %p, runtime_services = %p\n",
|
||||
SUFFIX (grub_efiemu_system_table), runtime_services);
|
||||
|
||||
@@ -19,16 +19,18 @@
|
||||
|
||||
#define GRUB_TYPES_CPU_HEADER 1
|
||||
|
||||
#ifdef ELF32
|
||||
#ifdef __i386__
|
||||
# define SIZEOF_VOID_P 4
|
||||
# define SIZEOF_LONG 4
|
||||
# define GRUB_TARGET_SIZEOF_VOID_P 4
|
||||
# define GRUB_TARGET_SIZEOF_LONG 4
|
||||
# define EFI_FUNC(x) x
|
||||
#else
|
||||
#elif defined (__x86_64__)
|
||||
# define SIZEOF_VOID_P 8
|
||||
# define SIZEOF_LONG 8
|
||||
# define GRUB_TARGET_SIZEOF_VOID_P 8
|
||||
# define GRUB_TARGET_SIZEOF_LONG 8
|
||||
# define EFI_FUNC(x) x ## _real
|
||||
#else
|
||||
#error "Unknown architecture"
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#ifdef USE_ASCII_FALLBACK
|
||||
#if HAVE_FONT_SOURCE
|
||||
#include "ascii.h"
|
||||
#endif
|
||||
|
||||
@@ -110,43 +110,65 @@ static struct grub_font null_font;
|
||||
/* Flag to ensure module is initialized only once. */
|
||||
static grub_uint8_t font_loader_initialized;
|
||||
|
||||
#ifdef USE_ASCII_FALLBACK
|
||||
static struct grub_font_glyph *ascii_font_glyph[0x80];
|
||||
#if HAVE_FONT_SOURCE
|
||||
static struct grub_font_glyph *ascii_font_glyph[ASCII_NUM];
|
||||
static struct grub_font_glyph *arrows_font_glyph[ARROWS_NUM];
|
||||
static struct grub_font_glyph *lines_font_glyph[LINES_NUM];
|
||||
|
||||
static void
|
||||
init_fallback (struct grub_font_glyph **glyphs, const unsigned char *stored,
|
||||
grub_uint32_t len)
|
||||
{
|
||||
grub_uint32_t current;
|
||||
for (current = 0; current < len; current++)
|
||||
{
|
||||
glyphs[current] =
|
||||
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
|
||||
if (!glyphs[current])
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
glyphs[current]->width = 8;
|
||||
glyphs[current]->height = 16;
|
||||
glyphs[current]->offset_x = 0;
|
||||
glyphs[current]->offset_y = -2;
|
||||
glyphs[current]->device_width = 8;
|
||||
glyphs[current]->font = NULL;
|
||||
|
||||
grub_memcpy (glyphs[current]->bitmap,
|
||||
&stored[current * ASCII_BITMAP_SIZE],
|
||||
ASCII_BITMAP_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct grub_font_glyph *
|
||||
ascii_glyph_lookup (grub_uint32_t code)
|
||||
{
|
||||
#ifdef USE_ASCII_FALLBACK
|
||||
static int ascii_failback_initialized = 0;
|
||||
#if HAVE_FONT_SOURCE
|
||||
static int ascii_fallback_initialized = 0;
|
||||
struct grub_font_glyph **p;
|
||||
|
||||
if (code >= 0x80)
|
||||
if (code < ASCII_NUM)
|
||||
p = &ascii_font_glyph[code];
|
||||
else if (code >= ARROWS_START && code < ARROWS_START + ARROWS_NUM)
|
||||
p = &arrows_font_glyph[code - ARROWS_START];
|
||||
else if (code >= LINES_START && code < LINES_START + LINES_NUM)
|
||||
p = &lines_font_glyph[code - LINES_START];
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (ascii_failback_initialized == 0)
|
||||
if (ascii_fallback_initialized == 0)
|
||||
{
|
||||
int current;
|
||||
for (current = 0; current < 0x80; current++)
|
||||
{
|
||||
ascii_font_glyph[current] =
|
||||
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
|
||||
|
||||
ascii_font_glyph[current]->width = 8;
|
||||
ascii_font_glyph[current]->height = 16;
|
||||
ascii_font_glyph[current]->offset_x = 0;
|
||||
ascii_font_glyph[current]->offset_y = -2;
|
||||
ascii_font_glyph[current]->device_width = 8;
|
||||
ascii_font_glyph[current]->font = NULL;
|
||||
|
||||
grub_memcpy (ascii_font_glyph[current]->bitmap,
|
||||
&ascii_bitmaps[current * ASCII_BITMAP_SIZE],
|
||||
ASCII_BITMAP_SIZE);
|
||||
}
|
||||
|
||||
ascii_failback_initialized = 1;
|
||||
init_fallback (ascii_font_glyph, ascii_bitmaps, ASCII_NUM);
|
||||
init_fallback (arrows_font_glyph, arrows_bitmaps, ARROWS_NUM);
|
||||
init_fallback (lines_font_glyph, lines_bitmaps, LINES_NUM);
|
||||
ascii_fallback_initialized = 1;
|
||||
}
|
||||
|
||||
return ascii_font_glyph[code];
|
||||
return *p;
|
||||
#else
|
||||
(void) code;
|
||||
return NULL;
|
||||
|
||||
@@ -911,7 +911,6 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
|
||||
{
|
||||
grub_uint32_t total_size, cblock_size;
|
||||
grub_size_t ret = 0;
|
||||
unsigned char buf[GRUB_BTRFS_LZO_BLOCK_SIZE];
|
||||
char *ibuf0 = ibuf;
|
||||
|
||||
total_size = grub_le_to_cpu32 (grub_get_unaligned32 (ibuf));
|
||||
@@ -955,13 +954,21 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
|
||||
if (off > 0 || osize < GRUB_BTRFS_LZO_BLOCK_SIZE)
|
||||
{
|
||||
grub_size_t to_copy = GRUB_BTRFS_LZO_BLOCK_SIZE - off;
|
||||
grub_uint8_t *buf;
|
||||
|
||||
if (to_copy > osize)
|
||||
to_copy = osize;
|
||||
|
||||
buf = grub_malloc (GRUB_BTRFS_LZO_BLOCK_SIZE);
|
||||
if (!buf)
|
||||
return -1;
|
||||
|
||||
if (lzo1x_decompress_safe ((lzo_bytep)ibuf, cblock_size, buf, &usize,
|
||||
NULL) != LZO_E_OK)
|
||||
return -1;
|
||||
{
|
||||
grub_free (buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (to_copy > usize)
|
||||
to_copy = usize;
|
||||
@@ -972,6 +979,8 @@ grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
|
||||
obuf += to_copy;
|
||||
ibuf += cblock_size;
|
||||
off = 0;
|
||||
|
||||
grub_free (buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,8 @@ grub_cbfs_close (grub_file_t file)
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) \
|
||||
&& !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
|
||||
|
||||
static char *cbfsdisk_addr;
|
||||
static grub_off_t cbfsdisk_size = 0;
|
||||
@@ -375,7 +376,7 @@ static struct grub_fs grub_cbfs_fs = {
|
||||
|
||||
GRUB_MOD_INIT (cbfs)
|
||||
{
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
|
||||
init_cbfsdisk ();
|
||||
#endif
|
||||
grub_fs_register (&grub_cbfs_fs);
|
||||
@@ -384,7 +385,7 @@ GRUB_MOD_INIT (cbfs)
|
||||
GRUB_MOD_FINI (cbfs)
|
||||
{
|
||||
grub_fs_unregister (&grub_cbfs_fs);
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||
#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
|
||||
fini_cbfsdisk ();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -247,6 +247,7 @@ struct ext2_dirent
|
||||
{
|
||||
grub_uint32_t inode;
|
||||
grub_uint16_t direntlen;
|
||||
#define MAX_NAMELEN 255
|
||||
grub_uint8_t namelen;
|
||||
grub_uint8_t filetype;
|
||||
};
|
||||
@@ -344,11 +345,12 @@ grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
|
||||
}
|
||||
|
||||
static struct grub_ext4_extent_header *
|
||||
grub_ext4_find_leaf (struct grub_ext2_data *data, grub_properly_aligned_t *buf,
|
||||
grub_ext4_find_leaf (struct grub_ext2_data *data,
|
||||
struct grub_ext4_extent_header *ext_block,
|
||||
grub_uint32_t fileblock)
|
||||
{
|
||||
struct grub_ext4_extent_idx *index;
|
||||
void *buf = NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -357,8 +359,8 @@ grub_ext4_find_leaf (struct grub_ext2_data *data, grub_properly_aligned_t *buf,
|
||||
|
||||
index = (struct grub_ext4_extent_idx *) (ext_block + 1);
|
||||
|
||||
if (grub_le_to_cpu16(ext_block->magic) != EXT4_EXT_MAGIC)
|
||||
return 0;
|
||||
if (ext_block->magic != grub_cpu_to_le16_compile_time (EXT4_EXT_MAGIC))
|
||||
goto fail;
|
||||
|
||||
if (ext_block->depth == 0)
|
||||
return ext_block;
|
||||
@@ -370,17 +372,24 @@ grub_ext4_find_leaf (struct grub_ext2_data *data, grub_properly_aligned_t *buf,
|
||||
}
|
||||
|
||||
if (--i < 0)
|
||||
return 0;
|
||||
goto fail;
|
||||
|
||||
block = grub_le_to_cpu16 (index[i].leaf_hi);
|
||||
block = (block << 32) | grub_le_to_cpu32 (index[i].leaf);
|
||||
if (!buf)
|
||||
buf = grub_malloc (EXT2_BLOCK_SIZE(data));
|
||||
if (!buf)
|
||||
goto fail;
|
||||
if (grub_disk_read (data->disk,
|
||||
block << LOG2_EXT2_BLOCK_SIZE (data),
|
||||
0, EXT2_BLOCK_SIZE(data), buf))
|
||||
return 0;
|
||||
goto fail;
|
||||
|
||||
ext_block = (struct grub_ext4_extent_header *) buf;
|
||||
ext_block = buf;
|
||||
}
|
||||
fail:
|
||||
grub_free (buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_disk_addr_t
|
||||
@@ -388,20 +397,21 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||
{
|
||||
struct grub_ext2_data *data = node->data;
|
||||
struct grub_ext2_inode *inode = &node->inode;
|
||||
grub_disk_addr_t blknr = -1;
|
||||
unsigned int blksz = EXT2_BLOCK_SIZE (data);
|
||||
grub_disk_addr_t blksz_quarter = blksz / 4;
|
||||
int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data);
|
||||
int log_perblock = log2_blksz + 9 - 2;
|
||||
grub_uint32_t indir;
|
||||
int shift;
|
||||
|
||||
if (inode->flags & grub_cpu_to_le32_compile_time (EXT4_EXTENTS_FLAG))
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (buf, EXT2_BLOCK_SIZE(data));
|
||||
struct grub_ext4_extent_header *leaf;
|
||||
struct grub_ext4_extent *ext;
|
||||
int i;
|
||||
grub_disk_addr_t ret;
|
||||
|
||||
leaf = grub_ext4_find_leaf (data, buf,
|
||||
(struct grub_ext4_extent_header *) inode->blocks.dir_blocks,
|
||||
fileblock);
|
||||
leaf = grub_ext4_find_leaf (data, (struct grub_ext4_extent_header *) inode->blocks.dir_blocks, fileblock);
|
||||
if (! leaf)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid extent");
|
||||
@@ -419,7 +429,7 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||
{
|
||||
fileblock -= grub_le_to_cpu32 (ext[i].block);
|
||||
if (fileblock >= grub_le_to_cpu16 (ext[i].len))
|
||||
return 0;
|
||||
ret = 0;
|
||||
else
|
||||
{
|
||||
grub_disk_addr_t start;
|
||||
@@ -427,98 +437,64 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||
start = grub_le_to_cpu16 (ext[i].start_hi);
|
||||
start = (start << 32) + grub_le_to_cpu32 (ext[i].start);
|
||||
|
||||
return fileblock + start;
|
||||
ret = fileblock + start;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "something wrong with extent");
|
||||
return -1;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (leaf != (struct grub_ext4_extent_header *) inode->blocks.dir_blocks)
|
||||
grub_free (leaf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Direct blocks. */
|
||||
if (fileblock < INDIRECT_BLOCKS)
|
||||
blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);
|
||||
return grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);
|
||||
fileblock -= INDIRECT_BLOCKS;
|
||||
/* Indirect. */
|
||||
else if (fileblock < INDIRECT_BLOCKS + blksz / 4)
|
||||
if (fileblock < blksz_quarter)
|
||||
{
|
||||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (inode->blocks.indir_block))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);
|
||||
indir = inode->blocks.indir_block;
|
||||
shift = 0;
|
||||
goto indirect;
|
||||
}
|
||||
fileblock -= blksz_quarter;
|
||||
/* Double indirect. */
|
||||
else if (fileblock < INDIRECT_BLOCKS
|
||||
+ blksz / 4 * ((grub_disk_addr_t) blksz / 4 + 1))
|
||||
if (fileblock < blksz_quarter * blksz_quarter)
|
||||
{
|
||||
int log_perblock = log2_blksz + 9 - 2;
|
||||
grub_disk_addr_t rblock = fileblock - (INDIRECT_BLOCKS
|
||||
+ blksz / 4);
|
||||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (inode->blocks.double_indir_block))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[rblock >> log_perblock]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
|
||||
blknr = grub_le_to_cpu32 (indir[rblock & ((1 << log_perblock) - 1)]);
|
||||
indir = inode->blocks.double_indir_block;
|
||||
shift = 1;
|
||||
goto indirect;
|
||||
}
|
||||
/* triple indirect. */
|
||||
else if (fileblock < INDIRECT_BLOCKS + blksz / 4 * ((grub_disk_addr_t) blksz / 4 + 1)
|
||||
+ ((grub_disk_addr_t) blksz / 4) * ((grub_disk_addr_t) blksz / 4)
|
||||
* ((grub_disk_addr_t) blksz / 4 + 1))
|
||||
fileblock -= blksz_quarter * blksz_quarter;
|
||||
/* Triple indirect. */
|
||||
if (fileblock < blksz_quarter * blksz_quarter * (blksz_quarter + 1))
|
||||
{
|
||||
int log_perblock = log2_blksz + 9 - 2;
|
||||
grub_disk_addr_t rblock = fileblock - (INDIRECT_BLOCKS + blksz / 4
|
||||
* (blksz / 4 + 1));
|
||||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (inode->blocks.triple_indir_block))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[(rblock >> log_perblock) >> log_perblock]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[(rblock >> log_perblock) & ((1 << log_perblock) - 1)]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
blknr = grub_le_to_cpu32 (indir[rblock & ((1 << log_perblock) - 1)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"ext2fs doesn't support quadruple indirect blocks");
|
||||
indir = inode->blocks.triple_indir_block;
|
||||
shift = 2;
|
||||
goto indirect;
|
||||
}
|
||||
return grub_error (GRUB_ERR_BAD_FS,
|
||||
"ext2fs doesn't support quadruple indirect blocks");
|
||||
|
||||
return blknr;
|
||||
indirect:
|
||||
do {
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t) grub_le_to_cpu32 (indir))
|
||||
<< log2_blksz,
|
||||
((fileblock >> (log_perblock * shift))
|
||||
& ((1 << log_perblock) - 1))
|
||||
* sizeof (indir),
|
||||
sizeof (indir), &indir))
|
||||
return grub_errno;
|
||||
} while (shift--);
|
||||
|
||||
return grub_le_to_cpu32 (indir);
|
||||
}
|
||||
|
||||
/* Read LEN bytes from the file described by DATA starting with byte
|
||||
@@ -719,7 +695,7 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
|
||||
|
||||
if (dirent.inode != 0 && dirent.namelen != 0)
|
||||
{
|
||||
char filename[dirent.namelen + 1];
|
||||
char filename[MAX_NAMELEN + 1];
|
||||
struct grub_fshelp_node *fdiro;
|
||||
enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
|
||||
|
||||
|
||||
@@ -72,10 +72,13 @@ struct grub_jfs_extent
|
||||
grub_uint32_t blk2;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define GRUB_JFS_IAG_INODES_OFFSET 3072
|
||||
#define GRUB_JFS_IAG_INODES_COUNT 128
|
||||
|
||||
struct grub_jfs_iag
|
||||
{
|
||||
grub_uint8_t unused[3072];
|
||||
struct grub_jfs_extent inodes[128];
|
||||
grub_uint8_t unused[GRUB_JFS_IAG_INODES_OFFSET];
|
||||
struct grub_jfs_extent inodes[GRUB_JFS_IAG_INODES_COUNT];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
@@ -283,20 +286,25 @@ getblk (struct grub_jfs_treehead *treehead,
|
||||
|
||||
if (found != -1)
|
||||
{
|
||||
grub_int64_t ret = -1;
|
||||
struct
|
||||
{
|
||||
struct grub_jfs_treehead treehead;
|
||||
struct grub_jfs_tree_extent extents[254];
|
||||
} tree;
|
||||
} *tree;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
|
||||
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||||
- GRUB_DISK_SECTOR_BITS), 0,
|
||||
sizeof (tree), (char *) &tree))
|
||||
tree = grub_zalloc (sizeof (*tree));
|
||||
if (!tree)
|
||||
return -1;
|
||||
|
||||
return getblk (&tree.treehead, &tree.extents[0], data, blk);
|
||||
if (!grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
|
||||
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||||
- GRUB_DISK_SECTOR_BITS), 0,
|
||||
sizeof (*tree), (char *) tree))
|
||||
ret = getblk (&tree->treehead, &tree->extents[0], data, blk);
|
||||
grub_free (tree);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -316,7 +324,7 @@ static grub_err_t
|
||||
grub_jfs_read_inode (struct grub_jfs_data *data, grub_uint32_t ino,
|
||||
struct grub_jfs_inode *inode)
|
||||
{
|
||||
struct grub_jfs_iag iag;
|
||||
struct grub_jfs_extent iag_inodes[GRUB_JFS_IAG_INODES_COUNT];
|
||||
grub_uint32_t iagnum = ino / 4096;
|
||||
unsigned inoext = (ino % 4096) / 32;
|
||||
unsigned inonum = (ino % 4096) % 32;
|
||||
@@ -330,11 +338,12 @@ grub_jfs_read_inode (struct grub_jfs_data *data, grub_uint32_t ino,
|
||||
/* Read in the IAG. */
|
||||
if (grub_disk_read (data->disk,
|
||||
iagblk << (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||||
- GRUB_DISK_SECTOR_BITS), 0,
|
||||
sizeof (struct grub_jfs_iag), &iag))
|
||||
- GRUB_DISK_SECTOR_BITS),
|
||||
GRUB_JFS_IAG_INODES_OFFSET,
|
||||
sizeof (iag_inodes), &iag_inodes))
|
||||
return grub_errno;
|
||||
|
||||
inoblk = grub_le_to_cpu32 (iag.inodes[inoext].blk2);
|
||||
inoblk = grub_le_to_cpu32 (iag_inodes[inoext].blk2);
|
||||
inoblk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||||
- GRUB_DISK_SECTOR_BITS);
|
||||
inoblk += inonum;
|
||||
|
||||
@@ -128,10 +128,11 @@ grub_procfs_open (struct grub_file *file, const char *path)
|
||||
FOR_LIST_ELEMENTS((entry), (grub_procfs_entries))
|
||||
if (grub_strcmp (pathptr, entry->name) == 0)
|
||||
{
|
||||
file->data = entry->get_contents ();
|
||||
grub_size_t sz;
|
||||
file->data = entry->get_contents (&sz);
|
||||
if (!file->data)
|
||||
return grub_errno;
|
||||
file->size = grub_strlen (file->data);
|
||||
file->size = sz;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ LEAF_HASH (int bs, grub_uint64_t h, zap_leaf_phys_t *l)
|
||||
static inline int
|
||||
ZAP_LEAF_NUMCHUNKS (int bs)
|
||||
{
|
||||
return (((1 << bs) - 2 * ZAP_LEAF_HASH_NUMENTRIES (bs)) /
|
||||
return (((1U << bs) - 2 * ZAP_LEAF_HASH_NUMENTRIES (bs)) /
|
||||
ZAP_LEAF_CHUNKSIZE - 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,11 +71,7 @@ VARIABLE(grub_gdb_stack)
|
||||
#define REG \reg
|
||||
#define NDX \ndx
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
xorl %eax, %eax
|
||||
#else
|
||||
movl $0, %eax
|
||||
#endif
|
||||
movw REG, EXT_C(grub_gdb_regs)+(NDX * 4)
|
||||
movw %ax, EXT_C(grub_gdb_regs)+(NDX * 4 + 2)
|
||||
movl EXT_C(grub_gdb_regs)+(EAX * 4), %eax
|
||||
@@ -190,11 +186,7 @@ VARIABLE(grub_gdb_stack)
|
||||
.text
|
||||
1:
|
||||
.if EC
|
||||
#ifdef __APPLE__
|
||||
add $$4, %esp
|
||||
#else
|
||||
add $4, %esp
|
||||
#endif
|
||||
add MACRO_DOLLAR(4), %esp
|
||||
.endif
|
||||
|
||||
save_context
|
||||
|
||||
@@ -35,7 +35,7 @@ deps=`grep ^$modname: $moddep | sed s@^.*:@@`
|
||||
# remove old files if any
|
||||
rm -f $tmpfile $outfile
|
||||
|
||||
if test x@TARGET_APPLE_CC@ != x1; then
|
||||
if test x@TARGET_APPLE_LINKER@ != x1; then
|
||||
# stripout .modname and .moddeps sections from input module
|
||||
@TARGET_OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ BEGIN {
|
||||
} else if ($1 == "undefined") {
|
||||
if ($3 in symtab)
|
||||
modtab[$2] = modtab[$2] " " symtab[$3];
|
||||
else if ($3 != "__gnu_local_gp") {
|
||||
else if ($3 != "__gnu_local_gp" && $3 != "_gp_disp") {
|
||||
printf "%s in %s is not defined\n", $3, $2 >"/dev/stderr";
|
||||
error++;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,12 @@ module=$1
|
||||
modname=`echo $module | sed -e 's@\.module.*$@@'`
|
||||
|
||||
# Print all symbols defined by module
|
||||
if test x"@TARGET_NMFLAGS_DEFINED_ONLY@" = x; then
|
||||
@TARGET_NM@ -g @TARGET_NMFLAGS_MINUS_P@ -p $module | \
|
||||
if test x"@TARGET_NMFLAGS_DEFINED_ONLY@" = x && test x"@TARGET_NMFLAGS_MINUS_P@" = x; then
|
||||
@TARGET_NM@ -g -p $module | \
|
||||
sed -n "s@^\([0-9a-fA-F]*\) *[TBRDS] *\([^ ]*\).*@defined $modname \2@p"
|
||||
elif test x"@TARGET_NMFLAGS_DEFINED_ONLY@" = x; then
|
||||
@TARGET_NM@ -g @TARGET_NMFLAGS_MINUS_P@ -p $module | \
|
||||
sed -n "s@^\([^ ]*\) *[TBRDS] *\([0-9a-fA-F]*\).*@defined $modname \1@p"
|
||||
else
|
||||
@TARGET_NM@ -g --defined-only @TARGET_NMFLAGS_MINUS_P@ -p $module | \
|
||||
sed "s@^\([^ ]*\).*@defined $modname \1@g"
|
||||
|
||||
@@ -240,12 +240,7 @@ parse_angle (const char *value)
|
||||
/* Unicode symbol of degrees (a circle, U+b0). Put here in UTF-8 to
|
||||
avoid potential problem with text file reesncoding */
|
||||
|| grub_strcmp (ptr, "\xc2\xb0") == 0)
|
||||
{
|
||||
if (angle >= 0)
|
||||
angle = ((unsigned) angle * 64 + 45) / 90;
|
||||
else
|
||||
angle = -((unsigned) -angle * 64 + 45) / 90;
|
||||
}
|
||||
angle = grub_divide_round (angle * 64, 90);
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,15 +166,17 @@ read_block_data (struct grub_lzopio *lzopio)
|
||||
|
||||
if (lzopio->ccheck_fun)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (context, lzopio->ccheck_fun->contextsize);
|
||||
grub_uint8_t computed_hash[GRUB_CRYPTO_MAX_MDLEN];
|
||||
|
||||
lzopio->ccheck_fun->init (context);
|
||||
lzopio->ccheck_fun->write (context, lzopio->block.cdata,
|
||||
lzopio->block.csize);
|
||||
lzopio->ccheck_fun->final (context);
|
||||
if (lzopio->ccheck_fun->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return -1;
|
||||
|
||||
grub_crypto_hash (lzopio->ccheck_fun, computed_hash,
|
||||
lzopio->block.cdata,
|
||||
lzopio->block.csize);
|
||||
|
||||
if (grub_memcmp
|
||||
(lzopio->ccheck_fun->read (context), &lzopio->block.ccheck,
|
||||
(computed_hash, &lzopio->block.ccheck,
|
||||
sizeof (lzopio->block.ccheck)) != 0)
|
||||
return -1;
|
||||
}
|
||||
@@ -212,15 +214,17 @@ uncompress_block (struct grub_lzopio *lzopio)
|
||||
|
||||
if (lzopio->ucheck_fun)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (context, lzopio->ucheck_fun->contextsize);
|
||||
grub_uint8_t computed_hash[GRUB_CRYPTO_MAX_MDLEN];
|
||||
|
||||
lzopio->ucheck_fun->init (context);
|
||||
lzopio->ucheck_fun->write (context, lzopio->block.udata,
|
||||
lzopio->block.usize);
|
||||
lzopio->ucheck_fun->final (context);
|
||||
if (lzopio->ucheck_fun->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return -1;
|
||||
|
||||
grub_crypto_hash (lzopio->ucheck_fun, computed_hash,
|
||||
lzopio->block.udata,
|
||||
lzopio->block.usize);
|
||||
|
||||
if (grub_memcmp
|
||||
(lzopio->ucheck_fun->read (context), &lzopio->block.ucheck,
|
||||
(computed_hash, &lzopio->block.ucheck,
|
||||
sizeof (lzopio->block.ucheck)) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
111
grub-core/io/offset.c
Normal file
111
grub-core/io/offset.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/file.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
struct grub_offset_file
|
||||
{
|
||||
grub_file_t parent;
|
||||
grub_off_t off;
|
||||
};
|
||||
|
||||
static grub_ssize_t
|
||||
grub_offset_read (grub_file_t file, char *buf, grub_size_t len)
|
||||
{
|
||||
struct grub_offset_file *data = file->data;
|
||||
if (grub_file_seek (data->parent, data->off + file->offset) == (grub_off_t) -1)
|
||||
return -1;
|
||||
return grub_file_read (data->parent, buf, len);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_offset_close (grub_file_t file)
|
||||
{
|
||||
struct grub_offset_file *data = file->data;
|
||||
|
||||
if (data->parent)
|
||||
grub_file_close (data->parent);
|
||||
|
||||
/* No need to close the same device twice. */
|
||||
file->device = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct grub_fs grub_offset_fs = {
|
||||
.name = "offset",
|
||||
.dir = 0,
|
||||
.open = 0,
|
||||
.read = grub_offset_read,
|
||||
.close = grub_offset_close,
|
||||
.label = 0,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
void
|
||||
grub_file_offset_close (grub_file_t file)
|
||||
{
|
||||
struct grub_offset_file *off_data = file->data;
|
||||
off_data->parent = NULL;
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
||||
grub_file_t
|
||||
grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size)
|
||||
{
|
||||
struct grub_offset_file *off_data;
|
||||
grub_file_t off_file, last_off_file;
|
||||
grub_file_filter_id_t filter;
|
||||
|
||||
off_file = grub_zalloc (sizeof (*off_file));
|
||||
off_data = grub_zalloc (sizeof (*off_data));
|
||||
if (!off_file || !off_data)
|
||||
{
|
||||
grub_free (off_file);
|
||||
grub_free (off_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_data->off = start;
|
||||
off_data->parent = parent;
|
||||
|
||||
off_file->device = parent->device;
|
||||
off_file->data = off_data;
|
||||
off_file->fs = &grub_offset_fs;
|
||||
off_file->size = size;
|
||||
|
||||
last_off_file = NULL;
|
||||
for (filter = GRUB_FILE_FILTER_COMPRESSION_FIRST;
|
||||
off_file && filter <= GRUB_FILE_FILTER_COMPRESSION_LAST; filter++)
|
||||
if (grub_file_filters_enabled[filter])
|
||||
{
|
||||
last_off_file = off_file;
|
||||
off_file = grub_file_filters_enabled[filter] (off_file, parent->name);
|
||||
}
|
||||
|
||||
if (!off_file)
|
||||
{
|
||||
off_data->parent = NULL;
|
||||
grub_file_close (last_off_file);
|
||||
return 0;
|
||||
}
|
||||
return off_file;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
|
||||
FUNCTION (grub_arch_sync_all_caches)
|
||||
call_pal 134
|
||||
ret $31,($26)
|
||||
@@ -1,114 +0,0 @@
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.set noat
|
||||
|
||||
.macro PREAMBLE
|
||||
|
||||
subq $30, 31 * 8, $30
|
||||
stq $0, (0 * 8)($30)
|
||||
stq $1, (1 * 8)($30)
|
||||
stq $2, (2 * 8)($30)
|
||||
stq $3, (3 * 8)($30)
|
||||
stq $4, (4 * 8)($30)
|
||||
stq $5, (5 * 8)($30)
|
||||
stq $6, (6 * 8)($30)
|
||||
stq $7, (7 * 8)($30)
|
||||
stq $8, (8 * 8)($30)
|
||||
stq $9, (9 * 8)($30)
|
||||
stq $10, (10 * 8)($30)
|
||||
stq $11, (11 * 8)($30)
|
||||
stq $12, (12 * 8)($30)
|
||||
stq $13, (13 * 8)($30)
|
||||
stq $14, (14 * 8)($30)
|
||||
stq $15, (15 * 8)($30)
|
||||
stq $16, (16 * 8)($30)
|
||||
stq $17, (17 * 8)($30)
|
||||
stq $18, (18 * 8)($30)
|
||||
stq $19, (19 * 8)($30)
|
||||
stq $20, (20 * 8)($30)
|
||||
stq $21, (21 * 8)($30)
|
||||
stq $22, (22 * 8)($30)
|
||||
stq $23, (23 * 8)($30)
|
||||
stq $24, (24 * 8)($30)
|
||||
stq $25, (25 * 8)($30)
|
||||
stq $26, (26 * 8)($30)
|
||||
stq $28, (28 * 8)($30)
|
||||
stq $29, (29 * 8)($30)
|
||||
addq $30, (30 * 8), $18
|
||||
/* load GP. */
|
||||
br $27, 1f
|
||||
1: ldgp $29, 0($27)
|
||||
.endm
|
||||
|
||||
.macro POSTAMBLE
|
||||
ldq $0, (0 * 8)($30)
|
||||
ldq $1, (1 * 8)($30)
|
||||
ldq $2, (2 * 8)($30)
|
||||
ldq $3, (3 * 8)($30)
|
||||
ldq $4, (4 * 8)($30)
|
||||
ldq $5, (5 * 8)($30)
|
||||
ldq $6, (6 * 8)($30)
|
||||
ldq $7, (7 * 8)($30)
|
||||
ldq $8, (8 * 8)($30)
|
||||
ldq $9, (9 * 8)($30)
|
||||
ldq $10, (10 * 8)($30)
|
||||
ldq $11, (11 * 8)($30)
|
||||
ldq $12, (12 * 8)($30)
|
||||
ldq $13, (13 * 8)($30)
|
||||
ldq $14, (14 * 8)($30)
|
||||
ldq $15, (15 * 8)($30)
|
||||
ldq $16, (16 * 8)($30)
|
||||
ldq $17, (17 * 8)($30)
|
||||
ldq $18, (18 * 8)($30)
|
||||
ldq $19, (19 * 8)($30)
|
||||
ldq $20, (20 * 8)($30)
|
||||
ldq $21, (21 * 8)($30)
|
||||
ldq $22, (22 * 8)($30)
|
||||
ldq $23, (23 * 8)($30)
|
||||
ldq $24, (24 * 8)($30)
|
||||
ldq $25, (25 * 8)($30)
|
||||
ldq $26, (26 * 8)($30)
|
||||
ldq $28, (28 * 8)($30)
|
||||
ldq $29, (29 * 8)($30)
|
||||
addq $30, 31 * 8, $30
|
||||
ret $31,($23)
|
||||
.endm
|
||||
|
||||
FUNCTION (__divqu)
|
||||
PREAMBLE
|
||||
mov $24, $16
|
||||
mov $25, $17
|
||||
jsr $26, EXT_C (grub_divmod64)
|
||||
mov $0, $27
|
||||
POSTAMBLE
|
||||
|
||||
FUNCTION (__remqu)
|
||||
PREAMBLE
|
||||
mov $24, $16
|
||||
mov $25, $17
|
||||
jsr $26, EXT_C (grub_divmod64)
|
||||
ldq $27, (30 * 8)($30)
|
||||
POSTAMBLE
|
||||
|
||||
FUNCTION (__divlu)
|
||||
PREAMBLE
|
||||
sll $24, 32, $16
|
||||
sra $16, 32, $16
|
||||
sll $25, 32, $17
|
||||
sra $17, 32, $17
|
||||
mov $24, $16
|
||||
mov $25, $17
|
||||
jsr $26, EXT_C (grub_divmod64)
|
||||
mov $0, $27
|
||||
POSTAMBLE
|
||||
|
||||
FUNCTION (__remlu)
|
||||
PREAMBLE
|
||||
sll $24, 32, $16
|
||||
sra $16, 32, $16
|
||||
sll $25, 32, $17
|
||||
sra $17, 32, $17
|
||||
jsr $26, EXT_C (grub_divmod64)
|
||||
ldq $27, (30 * 8)($30)
|
||||
POSTAMBLE
|
||||
@@ -1,257 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/cpu/types.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
void
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
const Elf64_Ehdr *e = ehdr;
|
||||
grub_size_t cntt = 0, cntg = 0;;
|
||||
const Elf64_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
/* Find a symbol table. */
|
||||
for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
|
||||
i < grub_le_to_cpu16 (e->e_shnum);
|
||||
i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
|
||||
if (grub_le_to_cpu32 (s->sh_type) == SHT_SYMTAB)
|
||||
break;
|
||||
|
||||
if (i == grub_le_to_cpu16 (e->e_shnum))
|
||||
return;
|
||||
|
||||
|
||||
for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
|
||||
i < grub_le_to_cpu16 (e->e_shnum);
|
||||
i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
|
||||
if (grub_le_to_cpu32 (s->sh_type) == SHT_RELA)
|
||||
{
|
||||
Elf64_Rela *rel, *max;
|
||||
|
||||
for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu32 (s->sh_offset)),
|
||||
max = rel + grub_le_to_cpu32 (s->sh_size) / grub_le_to_cpu16 (s->sh_entsize);
|
||||
rel < max; rel++)
|
||||
switch (ELF64_R_TYPE (grub_le_to_cpu32 (rel->r_info)))
|
||||
{
|
||||
case R_ALPHA_LITERAL:
|
||||
cntg++;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
*tramp = cntt;
|
||||
*got = cntg;
|
||||
}
|
||||
|
||||
|
||||
/* Check if EHDR is a valid ELF header. */
|
||||
grub_err_t
|
||||
grub_arch_dl_check_header (void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
|
||||
/* Check the magic numbers. */
|
||||
if (e->e_ident[EI_CLASS] != ELFCLASS64
|
||||
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|
||||
|| e->e_machine != EM_ALPHA)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Relocate symbols. */
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
Elf_Shdr *s;
|
||||
Elf_Word entsize;
|
||||
unsigned i;
|
||||
grub_uint8_t *gp;
|
||||
grub_uint64_t *gpptr;
|
||||
|
||||
gp = (grub_uint8_t *) mod->got;
|
||||
gpptr = (grub_uint64_t *) mod->got;
|
||||
|
||||
/* Find a symbol table. */
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
break;
|
||||
|
||||
if (i == e->e_shnum)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
|
||||
|
||||
entsize = s->sh_entsize;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_RELA)
|
||||
{
|
||||
grub_dl_segment_t seg;
|
||||
|
||||
/* Find the target segment. */
|
||||
for (seg = mod->segment; seg; seg = seg->next)
|
||||
if (seg->section == s->sh_info)
|
||||
break;
|
||||
|
||||
if (seg)
|
||||
{
|
||||
Elf_Rela *rel, *max;
|
||||
|
||||
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
|
||||
max = (Elf_Rela *) ((char *) rel + s->sh_size);
|
||||
rel < max;
|
||||
rel++)
|
||||
{
|
||||
grub_uint8_t *addr;
|
||||
Elf_Sym *sym;
|
||||
grub_uint64_t value;
|
||||
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
addr = (grub_uint8_t *) seg->addr + rel->r_offset;
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ entsize * ELF_R_SYM (rel->r_info));
|
||||
|
||||
value = sym->st_value + rel->r_addend;
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_ALPHA_REFQUAD:
|
||||
*(grub_uint64_t *) addr += value;
|
||||
break;
|
||||
case R_ALPHA_REFLONG:
|
||||
*(grub_uint32_t *) addr += value;
|
||||
break;
|
||||
|
||||
case R_ALPHA_GPREL32:
|
||||
*(grub_uint32_t *) addr += value - (grub_addr_t) gp;
|
||||
break;
|
||||
|
||||
case R_ALPHA_GPDISP:
|
||||
{
|
||||
grub_int64_t off = gp - addr;
|
||||
|
||||
if (off < (-2147483647L - 1)
|
||||
|| off > 2147483647L)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"gpdisp offset too large");
|
||||
/* Lower part is
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
*(grub_uint16_t *) addr = (off + 0x8000) >> 16;
|
||||
*(grub_uint16_t *) (addr + rel->r_addend) = off;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_ALPHA_GPRELHIGH:
|
||||
{
|
||||
Elf_Rela *rel2;
|
||||
|
||||
/* Handle partner lo16 relocation. Lower part is
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
value += (*(grub_uint16_t *) addr << 16);
|
||||
value -= (grub_addr_t) gp;
|
||||
for (rel2 = rel + 1; rel2 < max; rel2++)
|
||||
if (ELF_R_SYM (rel2->r_info)
|
||||
== ELF_R_SYM (rel->r_info)
|
||||
&& ELF_R_TYPE (rel2->r_info) == R_ALPHA_GPRELLOW)
|
||||
{
|
||||
value += *(grub_int16_t *)
|
||||
((char *) seg->addr + rel2->r_offset);
|
||||
break;
|
||||
}
|
||||
/* Handle partner lo16 relocation. Lower part is
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
if ((grub_int64_t) value < (-2147483647L - 1)
|
||||
|| (grub_int64_t) value > 2147483647L)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"gpdisp offset too large");
|
||||
value += 0x8000;
|
||||
*(grub_uint16_t *) addr = (value >> 16) & 0xffff;
|
||||
break;
|
||||
}
|
||||
case R_ALPHA_GPRELLOW:
|
||||
value -= (grub_addr_t) gp;
|
||||
*(grub_uint16_t *) addr += value & 0xffff;
|
||||
break;
|
||||
case R_ALPHA_LITERAL:
|
||||
*gpptr = value + *(grub_uint16_t *) addr;
|
||||
*(grub_uint16_t *) addr = ((grub_uint8_t *) gpptr - gp);
|
||||
gpptr++;
|
||||
break;
|
||||
case R_ALPHA_SREL32:
|
||||
*(grub_uint32_t *) addr += value - (grub_addr_t) seg->addr;
|
||||
break;
|
||||
case R_ALPHA_BRSGP:
|
||||
value += (((*(grub_uint32_t *) addr)
|
||||
& ((1 << 21) - 1)) << 2);
|
||||
value -= (grub_addr_t) addr;
|
||||
if (sym->st_other == STO_ALPHA_STD_GPLOAD)
|
||||
value += 4;
|
||||
else
|
||||
value -= 4;
|
||||
if (value & 3)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"unaligned branch");
|
||||
|
||||
if ((value & ~((1UL << 22) - 1)) != 0
|
||||
&& (value & ~((1UL << 22) - 1)) != ~((1UL << 22) - 1))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"brs offset too large (%lx)",
|
||||
value);
|
||||
|
||||
*(grub_uint32_t *) addr
|
||||
= ((*(grub_uint32_t *) addr & ~((1 << 21) - 1))
|
||||
| ((value >> 2) & ((1 << 21) - 1)));
|
||||
break;
|
||||
|
||||
case R_ALPHA_LITUSE:
|
||||
case R_ALPHA_HINT:
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unknown relocation type %d\n",
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/cache.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/machine/srm.h>
|
||||
#include <grub/machine/console.h>
|
||||
|
||||
/* FIXME: determine va_size. */
|
||||
static void *kseg_addr = (void *) 0xfffffc0000000000;
|
||||
static grub_uint64_t log_page_size;
|
||||
|
||||
extern char _start[];
|
||||
extern char _end[];
|
||||
|
||||
grub_uint32_t grub_arch_pccclock;
|
||||
|
||||
/* FIXME: use interrupt to count high. */
|
||||
grub_uint64_t
|
||||
grub_get_rtc (void)
|
||||
{
|
||||
static grub_uint32_t high = 0;
|
||||
static grub_uint32_t last = 0;
|
||||
grub_uint32_t low;
|
||||
|
||||
asm volatile ("rpcc %0" : "=r" (low));
|
||||
if (low < last)
|
||||
high++;
|
||||
last = low;
|
||||
|
||||
return (((grub_uint64_t) high) << 32) | low;
|
||||
}
|
||||
|
||||
static grub_addr_t
|
||||
get_pfn (grub_addr_t va, grub_uint64_t ptbr)
|
||||
{
|
||||
grub_uint64_t *l1;
|
||||
grub_uint64_t l1n;
|
||||
grub_uint64_t *l2;
|
||||
grub_uint64_t l2n;
|
||||
grub_uint64_t *l3;
|
||||
grub_uint64_t l3n;
|
||||
|
||||
l3n = va >> log_page_size;
|
||||
l2n = l3n >> (log_page_size - 3);
|
||||
l1n = l2n >> (log_page_size - 3);
|
||||
l3n &= ((1 << (log_page_size - 3)) - 1);
|
||||
l2n &= ((1 << (log_page_size - 3)) - 1);
|
||||
l1n &= ((1 << (log_page_size - 3)) - 1);
|
||||
|
||||
l1 = ((grub_uint64_t *) kseg_addr + (ptbr << (log_page_size - 3))
|
||||
+ l1n);
|
||||
l2 = ((grub_uint64_t *) kseg_addr + ((*l1 >> 32) << (log_page_size - 3))
|
||||
+ l2n);
|
||||
l3 = ((grub_uint64_t *) kseg_addr + ((*l2 >> 32) << (log_page_size - 3))
|
||||
+ l3n);
|
||||
return (*l3 >> 32);
|
||||
}
|
||||
|
||||
void pal_init(void);
|
||||
|
||||
grub_addr_t grub_modbase;
|
||||
|
||||
void
|
||||
grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
||||
char **path __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
unsigned i;
|
||||
struct grub_alpha_srm_memdesc *memdesc;
|
||||
struct grub_alpha_srm_hwpcb *pcb;
|
||||
grub_addr_t a;
|
||||
grub_addr_t start, end;
|
||||
grub_uint64_t low_pfn = ~0ULL, high_pfn = 0;
|
||||
|
||||
grub_arch_pccclock = GRUB_ALPHA_SRM_HWRPB.pcc_freq;
|
||||
grub_modbase = (grub_addr_t) _end;
|
||||
|
||||
grub_console_init_early ();
|
||||
|
||||
pal_init ();
|
||||
|
||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||
|
||||
for (log_page_size = 0;
|
||||
!((1 << log_page_size) & GRUB_ALPHA_SRM_HWRPB.page_size);
|
||||
log_page_size++);
|
||||
|
||||
memdesc = (struct grub_alpha_srm_memdesc *)
|
||||
(GRUB_ALPHA_SRM_HWRPB_ADDR + GRUB_ALPHA_SRM_HWRPB.memory_descriptor_table);
|
||||
|
||||
pcb = (void *) (GRUB_ALPHA_SRM_HWRPB_ADDR
|
||||
+ GRUB_ALPHA_SRM_HWRPB.cpu_slots_offset
|
||||
+ (GRUB_ALPHA_SRM_HWRPB.primary_cpu_id
|
||||
* GRUB_ALPHA_SRM_HWRPB.cpu_slot_size));
|
||||
|
||||
start = ALIGN_DOWN ((grub_addr_t) (&_start[0]),
|
||||
GRUB_ALPHA_SRM_HWRPB.page_size);
|
||||
end = ALIGN_UP (grub_modules_get_end (), GRUB_ALPHA_SRM_HWRPB.page_size);
|
||||
for (a = start; a < end; a += GRUB_ALPHA_SRM_HWRPB.page_size)
|
||||
{
|
||||
grub_uint64_t curpfn = get_pfn (a, pcb->ptbr);
|
||||
if (curpfn > high_pfn)
|
||||
high_pfn = curpfn;
|
||||
if (curpfn < low_pfn)
|
||||
low_pfn = curpfn;
|
||||
}
|
||||
|
||||
for (i = 0; i < memdesc->num_entries; i++)
|
||||
{
|
||||
grub_uint64_t from, to;
|
||||
if (memdesc->entries[i].type
|
||||
!= GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_AVAILABLE)
|
||||
continue;
|
||||
from = memdesc->entries[i].start_page;
|
||||
to = memdesc->entries[i].start_page + memdesc->entries[i].num_pages;
|
||||
if ((to > low_pfn) && (from < high_pfn + 1))
|
||||
{
|
||||
if (from < low_pfn)
|
||||
/* from .. (lowpfn - 1) */
|
||||
grub_mm_init_region ((char *) kseg_addr + (from << log_page_size),
|
||||
(low_pfn - from) << log_page_size);
|
||||
if (high_pfn + 1 < to)
|
||||
/* (high_pfn + 1) .. (to - 1) */
|
||||
grub_mm_init_region ((char *) kseg_addr
|
||||
+ ((high_pfn + 1) << log_page_size),
|
||||
(to - high_pfn - 1) << log_page_size);
|
||||
}
|
||||
else
|
||||
/* from .. (to - 1) */
|
||||
grub_mm_init_region ((char *) kseg_addr
|
||||
+ (from << log_page_size),
|
||||
(to - from) << log_page_size);
|
||||
}
|
||||
|
||||
grub_console_init_lately ();
|
||||
|
||||
grub_srmdisk_init ();
|
||||
|
||||
char buf[512];
|
||||
grub_alpha_srm_dispatch (0x22, 2, buf, sizeof (buf));
|
||||
grub_printf ("Hello World %s\n", buf);
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
{
|
||||
while (1);
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
{
|
||||
struct grub_alpha_srm_memdesc *memdesc;
|
||||
unsigned i;
|
||||
|
||||
memdesc = (struct grub_alpha_srm_memdesc *)
|
||||
(GRUB_ALPHA_SRM_HWRPB_ADDR + GRUB_ALPHA_SRM_HWRPB.memory_descriptor_table);
|
||||
|
||||
for (i = 0; i < memdesc->num_entries; i++)
|
||||
switch (memdesc->entries[i].type)
|
||||
{
|
||||
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_AVAILABLE:
|
||||
hook (memdesc->entries[i].start_page << log_page_size,
|
||||
memdesc->entries[i].num_pages << log_page_size,
|
||||
GRUB_MEMORY_AVAILABLE, hook_data);
|
||||
break;
|
||||
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_NONVOLATILE:
|
||||
hook (memdesc->entries[i].start_page << log_page_size,
|
||||
memdesc->entries[i].num_pages << log_page_size,
|
||||
GRUB_MEMORY_NVRAM, hook_data);
|
||||
break;
|
||||
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_RESERVED1:
|
||||
case GRUB_ALPHA_SRM_MEMDESC_ENTRY_TYPE_RESERVED2:
|
||||
default:
|
||||
hook (memdesc->entries[i].start_page << log_page_size,
|
||||
memdesc->entries[i].num_pages << log_page_size,
|
||||
GRUB_MEMORY_RESERVED, hook_data);
|
||||
break;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
.set noreorder
|
||||
.globl _start
|
||||
.ent _start
|
||||
_start:
|
||||
.prologue 0
|
||||
/* load GP. */
|
||||
br $27, 1f
|
||||
1: ldgp $29, 0($27)
|
||||
|
||||
/* Move modules out of the BSS. */
|
||||
lda $1, __bss_start
|
||||
lda $2, _end
|
||||
lda $4, modsize
|
||||
ldq $3, 0($4)
|
||||
addq $3, 7, $3
|
||||
sra $3, 3, $3
|
||||
sll $3, 3, $4
|
||||
subq $4, 8, $4
|
||||
addq $1, $4, $1
|
||||
addq $2, $4, $2
|
||||
|
||||
2:
|
||||
beq $3, 3f
|
||||
ldq $4, 0($1)
|
||||
stq $4, 0($2)
|
||||
subq $3, 1, $3
|
||||
subq $1, 8, $1
|
||||
subq $2, 8, $2
|
||||
br 2b
|
||||
3:
|
||||
|
||||
/* Clean BSS. */
|
||||
lda $1, __bss_start
|
||||
lda $2, _end
|
||||
subq $2, $1, $2
|
||||
sra $2, 3, $2
|
||||
2:
|
||||
beq $2, 3f
|
||||
stq $31, 0($1)
|
||||
subq $2, 1, $2
|
||||
addq $1, 8, $1
|
||||
br 2b
|
||||
3:
|
||||
/* call main. */
|
||||
lda $27, EXT_C (grub_main)
|
||||
jmp ($27)
|
||||
.end _start
|
||||
. = _start + GRUB_KERNEL_ALPHA_SRM_TOTAL_MODULE_SIZE
|
||||
modsize:
|
||||
.quad 0
|
||||
@@ -21,7 +21,12 @@
|
||||
.file "cache.S"
|
||||
.text
|
||||
.syntax unified
|
||||
#if !defined (__thumb2__) || !defined (ARMV7)
|
||||
.arm
|
||||
#else
|
||||
.thumb
|
||||
#endif
|
||||
|
||||
#if !defined (ARMV6) && !defined (ARMV7)
|
||||
# error Unsupported architecture version!
|
||||
#endif
|
||||
@@ -32,11 +37,16 @@
|
||||
* Simple cache maintenance functions
|
||||
*/
|
||||
|
||||
dlinesz_addr:
|
||||
.long EXT_C(grub_arch_cache_dlinesz)
|
||||
ilinesz_addr:
|
||||
.long EXT_C(grub_arch_cache_ilinesz)
|
||||
|
||||
@ r0 - *beg (inclusive)
|
||||
@ r1 - *end (exclusive)
|
||||
clean_dcache_range:
|
||||
@ Clean data cache for range to point-of-unification
|
||||
ldr r2, =EXT_C(grub_arch_cache_dlinesz)
|
||||
ldr r2, dlinesz_addr
|
||||
ldr r2, [r2]
|
||||
sub r3, r2, #1 @ align "beg" to start of line
|
||||
mvn r3, r3
|
||||
@@ -57,7 +67,7 @@ clean_dcache_range:
|
||||
@ r1 - *end (exclusive)
|
||||
invalidate_icache_range:
|
||||
@ Invalidate instruction cache for range to point-of-unification
|
||||
ldr r2, =EXT_C(grub_arch_cache_ilinesz)
|
||||
ldr r2, ilinesz_addr
|
||||
ldr r2, [r2]
|
||||
sub r3, r2, #1 @ align "beg" to start of line
|
||||
mvn r3, r3
|
||||
|
||||
@@ -21,6 +21,8 @@ void grub_arch_sync_caches_armv6 (void *address, grub_size_t len);
|
||||
void grub_arch_sync_caches_armv7 (void *address, grub_size_t len);
|
||||
void grub_arm_disable_caches_mmu_armv6 (void);
|
||||
void grub_arm_disable_caches_mmu_armv7 (void);
|
||||
grub_uint32_t grub_arm_main_id (void);
|
||||
grub_uint32_t grub_arm_cache_type (void);
|
||||
|
||||
static void
|
||||
probe_caches (void)
|
||||
@@ -28,7 +30,7 @@ probe_caches (void)
|
||||
grub_uint32_t main_id, cache_type;
|
||||
|
||||
/* Read main ID Register */
|
||||
asm volatile ("mrc p15, 0, %0, c0, c0, 0": "=r"(main_id));
|
||||
main_id = grub_arm_main_id ();
|
||||
|
||||
switch ((main_id >> 16) & 0xf)
|
||||
{
|
||||
@@ -44,7 +46,7 @@ probe_caches (void)
|
||||
}
|
||||
|
||||
/* Read Cache Type Register */
|
||||
asm volatile ("mrc p15, 0, %0, c0, c0, 1": "=r"(cache_type));
|
||||
cache_type = grub_arm_cache_type ();
|
||||
|
||||
switch (cache_type >> 24)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
.syntax unified
|
||||
.arm
|
||||
.arch armv6
|
||||
|
||||
# define DMB mcr p15, 0, r0, c7, c10, 5
|
||||
# define DSB mcr p15, 0, r0, c7, c10, 4
|
||||
# define ISB mcr p15, 0, r0, c7, c5, 4
|
||||
@@ -32,4 +33,12 @@ clean_invalidate_dcache:
|
||||
mcr p15, 0, r0, c7, c14, 0 @ Clean/Invalidate D-cache
|
||||
bx lr
|
||||
|
||||
#include "cache.S"
|
||||
#include "cache.S"
|
||||
|
||||
FUNCTION(grub_arm_main_id)
|
||||
mrc p15, 0, r0, c0, c0, 0
|
||||
bx lr
|
||||
|
||||
FUNCTION(grub_arm_cache_type)
|
||||
mrc p15, 0, r0, c0, c0, 1
|
||||
bx lr
|
||||
@@ -21,8 +21,13 @@
|
||||
.file "cache_armv7.S"
|
||||
.text
|
||||
.syntax unified
|
||||
.arm
|
||||
#if !defined (__thumb2__)
|
||||
.arch armv7a
|
||||
.arm
|
||||
#else
|
||||
.arch armv7
|
||||
.thumb
|
||||
#endif
|
||||
# define DMB dmb
|
||||
# define DSB dsb
|
||||
# define ISB isb
|
||||
@@ -58,11 +63,17 @@ clean_invalidate_dcache:
|
||||
@ read current cache information
|
||||
mrc p15, 1, r8, c0, c0, 0 @ Read CCSIDR
|
||||
lsr r3, r8, #13 @ Number of sets -1
|
||||
ldr r9, =0x3fff
|
||||
and r3, r3, r9
|
||||
|
||||
@ Keep only 14 bits of r3
|
||||
lsl r3, r3, #18
|
||||
lsr r3, r3, #18
|
||||
|
||||
lsr r4, r8, #3 @ Number of ways -1
|
||||
ldr r9, =0x1ff
|
||||
and r4, r4, r9
|
||||
|
||||
@ Keep only 9 bits of r4
|
||||
lsl r4, r4, #23
|
||||
lsr r4, r4, #23
|
||||
|
||||
and r7, r8, #7 @ log2(line size in words) - 2
|
||||
add r7, r7, #2 @ adjust
|
||||
mov r8, #1
|
||||
|
||||
@@ -25,45 +25,113 @@
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/arm/reloc.h>
|
||||
|
||||
struct trampoline_arm
|
||||
{
|
||||
#define ARM_LOAD_IP 0xe59fc000
|
||||
#define ARM_BX 0xe12fff1c
|
||||
#define ARM_MOV_PC 0xe1a0f00c
|
||||
grub_uint32_t load_ip; /* ldr ip, [pc] */
|
||||
grub_uint32_t bx; /* bx ip or mov pc, ip*/
|
||||
grub_uint32_t addr;
|
||||
};
|
||||
|
||||
static grub_uint16_t thumb_template[8] =
|
||||
{
|
||||
0x468c, /* mov ip, r1 */
|
||||
0x4903, /* ldr r1, [pc, #12] ; (10 <.text+0x10>) */
|
||||
/* Exchange R1 and IP in limited Thumb instruction set.
|
||||
IP gets negated but we compensate it by C code. */
|
||||
/* R1 IP */
|
||||
/* -A R1 */
|
||||
0x4461, /* add r1, ip */ /* R1-A R1 */
|
||||
0x4249, /* negs r1, r1 */ /* A-R1 R1 */
|
||||
0x448c, /* add ip, r1 */ /* A-R1 A */
|
||||
0x4249, /* negs r1, r1 */ /* R1-A A */
|
||||
0x4461, /* add r1, ip */ /* R1 A */
|
||||
0x4760 /* bx ip */
|
||||
};
|
||||
|
||||
struct trampoline_thumb
|
||||
{
|
||||
grub_uint16_t template[8];
|
||||
grub_uint32_t neg_addr;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
grub_err_t
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
const Elf_Ehdr *e = ehdr;
|
||||
const Elf_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
*tramp = 0;
|
||||
*got = 0;
|
||||
|
||||
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL)
|
||||
{
|
||||
const Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
|
||||
max = rel + s->sh_size / s->sh_entsize;
|
||||
rel < max;
|
||||
rel++)
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_ARM_CALL:
|
||||
case R_ARM_JUMP24:
|
||||
{
|
||||
*tramp += sizeof (struct trampoline_arm);
|
||||
break;
|
||||
}
|
||||
case R_ARM_THM_CALL:
|
||||
case R_ARM_THM_JUMP24:
|
||||
case R_ARM_THM_JUMP19:
|
||||
{
|
||||
*tramp += sizeof (struct trampoline_thumb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grub_dprintf ("dl", "trampoline size %x\n", *tramp);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* Runtime dynamic linker with helper functions. *
|
||||
*************************************************/
|
||||
static grub_err_t
|
||||
do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
Elf_Shdr *s, grub_dl_segment_t seg)
|
||||
{
|
||||
grub_dl_segment_t seg;
|
||||
Elf_Rel *rel;
|
||||
Elf_Sym *sym;
|
||||
int i, entnum;
|
||||
Elf_Rel *rel, *max;
|
||||
|
||||
entnum = relhdr->sh_size / sizeof (Elf_Rel);
|
||||
|
||||
/* Find the target segment for this relocation section. */
|
||||
for (seg = mod->segment ; seg ; seg = seg->next)
|
||||
if (seg->section == relhdr->sh_info)
|
||||
break;
|
||||
if (!seg)
|
||||
return grub_error (GRUB_ERR_EOF, N_("relocation segment not found"));
|
||||
|
||||
rel = (Elf_Rel *) ((grub_addr_t) e + relhdr->sh_offset);
|
||||
|
||||
/* Step through all relocations */
|
||||
for (i = 0, sym = mod->symtab; i < entnum; i++)
|
||||
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
|
||||
max = (Elf_Rel *) ((char *) rel + s->sh_size);
|
||||
rel < max;
|
||||
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
|
||||
{
|
||||
Elf_Addr *target, sym_addr;
|
||||
int relsym, reltype;
|
||||
grub_err_t retval;
|
||||
Elf_Sym *sym;
|
||||
|
||||
if (seg->size < rel[i].r_offset)
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
relsym = ELF_R_SYM (rel[i].r_info);
|
||||
reltype = ELF_R_TYPE (rel[i].r_info);
|
||||
target = (void *) ((grub_addr_t) seg->addr + rel[i].r_offset);
|
||||
target = (void *) ((char *) seg->addr + rel->r_offset);
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ mod->symsize * ELF_R_SYM (rel->r_info));
|
||||
|
||||
sym_addr = sym[relsym].st_value;
|
||||
sym_addr = sym->st_value;
|
||||
|
||||
switch (reltype)
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_ARM_ABS32:
|
||||
{
|
||||
@@ -76,16 +144,58 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
|
||||
case R_ARM_CALL:
|
||||
case R_ARM_JUMP24:
|
||||
{
|
||||
retval = grub_arm_reloc_jump24 (target, sym_addr);
|
||||
if (retval != GRUB_ERR_NONE)
|
||||
return retval;
|
||||
grub_int32_t offset;
|
||||
|
||||
sym_addr += grub_arm_jump24_get_offset (target);
|
||||
offset = sym_addr - (grub_uint32_t) target;
|
||||
|
||||
if ((sym_addr & 1) || !grub_arm_jump24_check_offset (offset))
|
||||
{
|
||||
struct trampoline_arm *tp = mod->trampptr;
|
||||
mod->trampptr = tp + 1;
|
||||
tp->load_ip = ARM_LOAD_IP;
|
||||
tp->bx = (sym_addr & 1) ? ARM_BX : ARM_MOV_PC;
|
||||
tp->addr = sym_addr + 8;
|
||||
offset = (grub_uint8_t *) tp - (grub_uint8_t *) target - 8;
|
||||
}
|
||||
if (!grub_arm_jump24_check_offset (offset))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"trampoline out of range");
|
||||
grub_arm_jump24_set_offset (target, offset);
|
||||
}
|
||||
break;
|
||||
case R_ARM_THM_CALL:
|
||||
case R_ARM_THM_JUMP24:
|
||||
{
|
||||
/* Thumb instructions can be 16-bit aligned */
|
||||
retval = grub_arm_reloc_thm_call ((grub_uint16_t *) target, sym_addr);
|
||||
grub_int32_t offset;
|
||||
|
||||
sym_addr += grub_arm_thm_call_get_offset ((grub_uint16_t *) target);
|
||||
|
||||
grub_dprintf ("dl", " sym_addr = 0x%08x\n", sym_addr);
|
||||
|
||||
offset = sym_addr - (grub_uint32_t) target;
|
||||
|
||||
grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
|
||||
target, sym_addr, offset);
|
||||
|
||||
if (!(sym_addr & 1) || (offset < -0x200000 || offset >= 0x200000))
|
||||
{
|
||||
struct trampoline_thumb *tp = mod->trampptr;
|
||||
mod->trampptr = tp + 1;
|
||||
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
|
||||
tp->neg_addr = -sym_addr - 4;
|
||||
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
|
||||
}
|
||||
|
||||
if (offset < -0x200000 || offset >= 0x200000)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"trampoline out of range");
|
||||
|
||||
grub_dprintf ("dl", " relative destination = %p\n",
|
||||
(char *) target + offset);
|
||||
|
||||
retval = grub_arm_thm_call_set_offset ((grub_uint16_t *) target, offset);
|
||||
if (retval != GRUB_ERR_NONE)
|
||||
return retval;
|
||||
}
|
||||
@@ -98,15 +208,37 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
|
||||
case R_ARM_THM_JUMP19:
|
||||
{
|
||||
/* Thumb instructions can be 16-bit aligned */
|
||||
retval = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
|
||||
if (retval != GRUB_ERR_NONE)
|
||||
return retval;
|
||||
grub_int32_t offset;
|
||||
|
||||
if (!(sym_addr & 1))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("Relocation targeting wrong execution state"));
|
||||
|
||||
sym_addr += grub_arm_thm_jump19_get_offset ((grub_uint16_t *) target);
|
||||
|
||||
offset = sym_addr - (grub_uint32_t) target;
|
||||
|
||||
if (!grub_arm_thm_jump19_check_offset (offset)
|
||||
|| !(sym_addr & 1))
|
||||
{
|
||||
struct trampoline_thumb *tp = mod->gotptr;
|
||||
mod->gotptr = tp + 1;
|
||||
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
|
||||
tp->neg_addr = -sym_addr - 4;
|
||||
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
|
||||
}
|
||||
|
||||
if (!grub_arm_thm_jump19_check_offset (offset))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"trampoline out of range");
|
||||
|
||||
grub_arm_thm_jump19_set_offset ((grub_uint16_t *) target, offset);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
reltype);
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,77 +262,3 @@ grub_arch_dl_check_header (void *ehdr)
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that provided ELF header contains reference to a symbol table
|
||||
*/
|
||||
static int
|
||||
has_symtab (Elf_Ehdr * e)
|
||||
{
|
||||
int i;
|
||||
Elf_Shdr *s;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((grub_uint32_t) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((grub_uint32_t) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* grub_arch_dl_relocate_symbols():
|
||||
* Only externally visible function in this file.
|
||||
* Locates the relocations section of the ELF object, and calls
|
||||
* do_relocations() to deal with it.
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
Elf_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
if (!has_symtab (e))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
|
||||
|
||||
#define FIRST_SHDR(x) ((Elf_Shdr *) ((grub_addr_t)(x) + (x)->e_shoff))
|
||||
#define NEXT_SHDR(x, y) ((Elf_Shdr *) ((grub_addr_t)(y) + (x)->e_shentsize))
|
||||
|
||||
for (i = 0, s = FIRST_SHDR (e); i < e->e_shnum; i++, s = NEXT_SHDR (e, s))
|
||||
{
|
||||
grub_err_t ret;
|
||||
|
||||
switch (s->sh_type)
|
||||
{
|
||||
case SHT_REL:
|
||||
{
|
||||
/* Relocations, no addends */
|
||||
ret = do_relocations (s, e, mod);
|
||||
if (ret != GRUB_ERR_NONE)
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case SHT_NULL:
|
||||
case SHT_PROGBITS:
|
||||
case SHT_SYMTAB:
|
||||
case SHT_STRTAB:
|
||||
case SHT_NOBITS:
|
||||
case SHT_ARM_ATTRIBUTES:
|
||||
break;
|
||||
case SHT_RELA:
|
||||
default:
|
||||
{
|
||||
grub_dprintf ("dl", "unhandled section_type: %d (0x%08x)\n",
|
||||
s->sh_type, s->sh_type);
|
||||
return GRUB_ERR_NOT_IMPLEMENTED_YET;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#undef FIRST_SHDR
|
||||
#undef NEXT_SHDR
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
|
||||
tmp = grub_le_to_cpu32 (*target);
|
||||
tmp += sym_addr;
|
||||
*target = grub_cpu_to_le32 (tmp);
|
||||
grub_dprintf ("dl", " %s: reloc_abs32 0x%08x => 0x%08x", __FUNCTION__,
|
||||
(unsigned int) sym_addr, (unsigned int) tmp);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -51,37 +49,16 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
|
||||
* little-endian, requiring some additional fiddling. *
|
||||
********************************************************************/
|
||||
|
||||
/*
|
||||
* R_ARM_THM_CALL/THM_JUMP24
|
||||
*
|
||||
* Relocate Thumb (T32) instruction set relative branches:
|
||||
* B.W, BL and BLX
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
grub_int32_t
|
||||
grub_arm_thm_call_get_offset (grub_uint16_t *target)
|
||||
{
|
||||
grub_int32_t offset, offset_low, offset_high;
|
||||
grub_uint32_t sign, j1, j2, is_blx;
|
||||
grub_uint32_t insword, insmask;
|
||||
grub_uint32_t sign, j1, j2;
|
||||
grub_uint32_t insword;
|
||||
grub_int32_t offset;
|
||||
|
||||
/* Extract instruction word in alignment-safe manner */
|
||||
insword = (grub_le_to_cpu16 (*target) << 16)
|
||||
| (grub_le_to_cpu16(*(target + 1)));
|
||||
insmask = 0xf800d000;
|
||||
|
||||
/* B.W/BL or BLX? Affects range and expected target state */
|
||||
if (((insword >> 12) & 0xd) == 0xc)
|
||||
is_blx = 1;
|
||||
else
|
||||
is_blx = 0;
|
||||
|
||||
/* If BLX, target symbol must be ARM (target address LSB == 0) */
|
||||
if (is_blx && (sym_addr & 1))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("Relocation targeting wrong execution state"));
|
||||
|
||||
offset_low = -16777216;
|
||||
offset_high = is_blx ? 16777212 : 16777214;
|
||||
|
||||
/* Extract bitfields from instruction words */
|
||||
sign = (insword >> 26) & 1;
|
||||
@@ -95,22 +72,32 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
if (offset & (1 << 24))
|
||||
offset -= (1 << 25);
|
||||
|
||||
grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
|
||||
return offset;
|
||||
}
|
||||
|
||||
offset += sym_addr;
|
||||
#ifndef GRUB_UTIL
|
||||
offset -= (grub_uint32_t) target;
|
||||
#endif
|
||||
grub_err_t
|
||||
grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
|
||||
{
|
||||
grub_uint32_t sign, j1, j2;
|
||||
const grub_uint32_t insmask = 0xf800d000;
|
||||
grub_uint32_t insword;
|
||||
int is_blx;
|
||||
|
||||
grub_dprintf("dl", " %s: target=%p, sym_addr=0x%08x, offset=%d\n",
|
||||
is_blx ? "BLX" : "BL", target, sym_addr, offset);
|
||||
/* Extract instruction word in alignment-safe manner */
|
||||
insword = (grub_le_to_cpu16 (*target) << 16)
|
||||
| (grub_le_to_cpu16(*(target + 1)));
|
||||
|
||||
if ((offset < offset_low) || (offset > offset_high))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("THM_CALL Relocation out of range."));
|
||||
if (((insword >> 12) & 0xd) == 0xc)
|
||||
is_blx = 1;
|
||||
else
|
||||
is_blx = 0;
|
||||
|
||||
grub_dprintf ("dl", " relative destination = %p",
|
||||
(char *) target + offset);
|
||||
if (!is_blx && !(offset & 1))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "bl/b.w targettting ARM");
|
||||
|
||||
/* Transform blx into bl if necessarry. */
|
||||
if (is_blx && (offset & 1))
|
||||
insword |= (1 << 12);
|
||||
|
||||
/* Reassemble instruction word */
|
||||
sign = (offset >> 24) & 1;
|
||||
@@ -130,21 +117,15 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* R_ARM_THM_JUMP19
|
||||
*
|
||||
* Relocate conditional Thumb (T32) B<c>.W
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
grub_int32_t
|
||||
grub_arm_thm_jump19_get_offset (grub_uint16_t *target)
|
||||
{
|
||||
grub_int32_t offset;
|
||||
grub_uint32_t insword, insmask;
|
||||
grub_uint32_t insword;
|
||||
|
||||
/* Extract instruction word in alignment-safe manner */
|
||||
insword = grub_le_to_cpu16 ((*target)) << 16
|
||||
| grub_le_to_cpu16 (*(target + 1));
|
||||
insmask = 0xfbc0d000;
|
||||
insword = (grub_le_to_cpu16 (*target) << 16)
|
||||
| (grub_le_to_cpu16(*(target + 1)));
|
||||
|
||||
/* Extract and sign extend offset */
|
||||
offset = ((insword >> 26) & 1) << 19
|
||||
@@ -156,18 +137,22 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
if (offset & (1 << 20))
|
||||
offset -= (1 << 21);
|
||||
|
||||
/* Adjust and re-truncate offset */
|
||||
offset += sym_addr;
|
||||
#ifndef GRUB_UTIL
|
||||
offset -= (grub_uint32_t) target;
|
||||
#endif
|
||||
if ((offset > 1048574) || (offset < -1048576))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("THM_JUMP19 Relocation out of range."));
|
||||
return offset;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
|
||||
{
|
||||
grub_uint32_t insword;
|
||||
const grub_uint32_t insmask = 0xfbc0d000;
|
||||
|
||||
offset >>= 1;
|
||||
offset &= 0xfffff;
|
||||
|
||||
/* Extract instruction word in alignment-safe manner */
|
||||
insword = grub_le_to_cpu16 ((*target)) << 16
|
||||
| grub_le_to_cpu16 (*(target + 1));
|
||||
|
||||
/* Reassemble instruction word and write back */
|
||||
insword &= insmask;
|
||||
insword |= ((offset >> 19) & 1) << 26
|
||||
@@ -177,9 +162,15 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
| (offset & 0x7ff);
|
||||
*target = grub_cpu_to_le16 (insword >> 16);
|
||||
*(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
grub_arm_thm_jump19_check_offset (grub_int32_t offset)
|
||||
{
|
||||
if ((offset > 1048574) || (offset < -1048576))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************
|
||||
@@ -188,35 +179,38 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
|
||||
* ARM instructions are 32-bit in size and 32-bit aligned. *
|
||||
***********************************************************/
|
||||
|
||||
/*
|
||||
* R_ARM_JUMP24
|
||||
*
|
||||
* Relocate ARM (A32) B
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
|
||||
grub_int32_t
|
||||
grub_arm_jump24_get_offset (grub_uint32_t *target)
|
||||
{
|
||||
grub_uint32_t insword;
|
||||
grub_int32_t offset;
|
||||
|
||||
if (sym_addr & 1)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("Relocation targeting wrong execution state"));
|
||||
grub_uint32_t insword;
|
||||
|
||||
insword = grub_le_to_cpu32 (*target);
|
||||
|
||||
offset = (insword & 0x00ffffff) << 2;
|
||||
if (offset & 0x02000000)
|
||||
offset -= 0x04000000;
|
||||
offset += sym_addr;
|
||||
#ifndef GRUB_UTIL
|
||||
offset -= (grub_uint32_t) target;
|
||||
#endif
|
||||
return offset;
|
||||
}
|
||||
|
||||
int
|
||||
grub_arm_jump24_check_offset (grub_int32_t offset)
|
||||
{
|
||||
if (offset >= 0x02000000 || offset < -0x02000000)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm_jump24_set_offset (grub_uint32_t *target,
|
||||
grub_int32_t offset)
|
||||
{
|
||||
grub_uint32_t insword;
|
||||
|
||||
insword = grub_le_to_cpu32 (*target);
|
||||
|
||||
insword &= 0xff000000;
|
||||
insword |= (offset >> 2) & 0x00ffffff;
|
||||
|
||||
*target = grub_cpu_to_le32 (insword);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <grub/mm.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/loader.h>
|
||||
|
||||
static grub_uint64_t tmr;
|
||||
static grub_efi_event_t tmr_evt;
|
||||
@@ -57,10 +58,13 @@ grub_machine_init (void)
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_efi_boot_services_t *b;
|
||||
|
||||
if (!(flags & GRUB_LOADER_FLAG_NORETURN))
|
||||
return;
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
|
||||
efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 0);
|
||||
|
||||
@@ -33,4 +33,4 @@ FUNCTION(_start)
|
||||
str r1, [ip]
|
||||
ldr ip, =EXT_C(grub_main)
|
||||
bx ip
|
||||
.end
|
||||
END
|
||||
|
||||
@@ -30,6 +30,54 @@
|
||||
|
||||
.align 2
|
||||
|
||||
FUNCTION(__muldi3)
|
||||
FUNCTION(__aeabi_lmul)
|
||||
stmfd sp!, {r4, fp}
|
||||
add fp, sp, #4
|
||||
sub sp, sp, #16
|
||||
str r0, [fp, #-12]
|
||||
str r1, [fp, #-8]
|
||||
str r2, [fp, #-20]
|
||||
str r3, [fp, #-16]
|
||||
ldr r3, [fp, #-8]
|
||||
ldr r2, [fp, #-20]
|
||||
mul r2, r3, r2
|
||||
ldr r3, [fp, #-16]
|
||||
ldr r1, [fp, #-12]
|
||||
mul r3, r1, r3
|
||||
add r2, r2, r3
|
||||
ldr r0, [fp, #-12]
|
||||
ldr r1, [fp, #-20]
|
||||
umull r3, r4, r0, r1
|
||||
add r2, r2, r4
|
||||
mov r4, r2
|
||||
mov r0, r3
|
||||
mov r1, r4
|
||||
mov sp, fp
|
||||
sub sp, sp, #4
|
||||
ldmfd sp!, {r4, fp}
|
||||
bx lr
|
||||
|
||||
.macro division parent
|
||||
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #12
|
||||
mov r2, r1
|
||||
add r1, sp, #4
|
||||
str r1, [sp, #0]
|
||||
mov r1, #0
|
||||
mov r3, #0
|
||||
bl \parent
|
||||
ldr r1, [sp, #4]
|
||||
add sp, sp, #12
|
||||
ldmfd sp!, {lr}
|
||||
bx lr
|
||||
.endm
|
||||
|
||||
FUNCTION(__aeabi_uidivmod)
|
||||
division grub_divmod64
|
||||
|
||||
|
||||
/*
|
||||
* Null divide-by-zero handler
|
||||
*/
|
||||
@@ -38,4 +86,4 @@ FUNCTION(raise)
|
||||
mov r0, #0
|
||||
bx lr
|
||||
|
||||
.end
|
||||
END
|
||||
|
||||
@@ -51,31 +51,40 @@ FUNCTION(_start)
|
||||
b codestart
|
||||
|
||||
@ Size of final image integrated module blob - set by grub-mkimage
|
||||
. = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
.org _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
VARIABLE(grub_total_module_size)
|
||||
.long 0
|
||||
|
||||
VARIABLE(grub_uboot_machine_type)
|
||||
.long 0
|
||||
VARIABLE(grub_uboot_boot_data)
|
||||
.long 0
|
||||
VARIABLE(grub_modbase)
|
||||
.long 0
|
||||
bss_start_ptr:
|
||||
.long EXT_C(__bss_start)
|
||||
end_ptr:
|
||||
.long EXT_C(_end)
|
||||
|
||||
FUNCTION(codestart)
|
||||
@ Store context: Machine ID, atags/dtb, ...
|
||||
@ U-Boot API signature is stored on the U-Boot heap
|
||||
@ Stack pointer used as start address for signature probing
|
||||
mov r12, sp
|
||||
ldr sp, =entry_state
|
||||
adr sp, entry_state
|
||||
push {r4-r12,lr} @ store U-Boot context (sp in r12)
|
||||
|
||||
ldr r12, =EXT_C(grub_uboot_machine_type)
|
||||
str r1, [r12]
|
||||
ldr r12, =EXT_C(grub_uboot_boot_data)
|
||||
str r2, [r12]
|
||||
str r1, EXT_C(grub_uboot_machine_type)
|
||||
str r2, EXT_C(grub_uboot_boot_data)
|
||||
|
||||
@ Modules have been stored as a blob in BSS,
|
||||
@ they need to be manually relocated to _end
|
||||
ldr r0, =EXT_C(__bss_start) @ src
|
||||
ldr r0, bss_start_ptr @ src
|
||||
add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
|
||||
and r0, r0, r1
|
||||
|
||||
ldr r1, =EXT_C(_end) @ dst = End of BSS
|
||||
ldr r1, end_ptr @ dst = End of BSS
|
||||
ldr r2, grub_total_module_size @ blob size
|
||||
|
||||
add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE
|
||||
@@ -83,8 +92,7 @@ FUNCTION(codestart)
|
||||
sub sp, r1, #8
|
||||
add r1, r1, #1024
|
||||
|
||||
ldr r12, =EXT_C(grub_modbase)
|
||||
str r1, [r12]
|
||||
str r1, EXT_C(grub_modbase)
|
||||
|
||||
add r1, r1, r2
|
||||
add r0, r0, r2
|
||||
@@ -98,14 +106,14 @@ FUNCTION(codestart)
|
||||
|
||||
@ Since we _are_ the C run-time, we need to manually zero the BSS
|
||||
@ region before continuing
|
||||
ldr r0, =EXT_C(__bss_start) @ zero from here
|
||||
ldr r0, bss_start_ptr @ zero from here
|
||||
@ If unaligned, bytewise zero until base address aligned.
|
||||
mov r2, #0
|
||||
1: tst r0, #3
|
||||
beq 2f
|
||||
strb r2, [r0], #1
|
||||
b 1b
|
||||
2: ldr r1, =EXT_C(_end) @ to here
|
||||
2: ldr r1, end_ptr @ to here
|
||||
1: str r2, [r0], #4
|
||||
cmp r0, r1
|
||||
bne 1b
|
||||
@@ -120,37 +128,39 @@ FUNCTION(codestart)
|
||||
* U-Boot (Global Data Pointer) and preserve it for Grub.
|
||||
*/
|
||||
FUNCTION(grub_uboot_syscall)
|
||||
ldr ip, =transition_space
|
||||
stm ip, {r8, lr}
|
||||
ldr ip, =gd_backup
|
||||
ldr r8, [ip]
|
||||
ldr ip, =grub_uboot_syscall_ptr
|
||||
str r8, transition_space
|
||||
str lr, transition_space + 4
|
||||
str r9, transition_space + 8
|
||||
|
||||
ldr r8, gd_backup
|
||||
ldr r9, gd_backup + 4
|
||||
|
||||
mov lr, pc
|
||||
ldr pc, [ip]
|
||||
ldr ip, =gd_backup
|
||||
str r8, [ip]
|
||||
ldr ip, =transition_space
|
||||
ldm ip, {r8, lr}
|
||||
ldr pc, grub_uboot_syscall_ptr
|
||||
|
||||
ldr r8, transition_space
|
||||
ldr lr, transition_space + 4
|
||||
ldr r9, transition_space + 8
|
||||
|
||||
bx lr
|
||||
|
||||
FUNCTION(grub_uboot_return)
|
||||
ldr sp, =entry_state_end
|
||||
adr sp, entry_state_end
|
||||
pop {r4-r12, lr}
|
||||
mov sp, r12
|
||||
bx lr
|
||||
|
||||
|
||||
.data
|
||||
.align 3 @ 8-byte alignment for stack
|
||||
.align 3
|
||||
@ U-boot context stack space
|
||||
entry_state_end:
|
||||
entry_state_end:
|
||||
.long 0 @ r4
|
||||
.long 0 @ r5
|
||||
.long 0 @ r6
|
||||
.long 0 @ r7
|
||||
gd_backup:
|
||||
.long 0 @ r8 - U-Boot global data pointer
|
||||
.long 0 @ r9
|
||||
.long 0 @ r8 - U-Boot global data pointer up to 2013-09-21
|
||||
.long 0 @ r9 - U-Boot global data pointer 2013-09-21 onwards
|
||||
.long 0 @ r10
|
||||
.long 0 @ r11
|
||||
VARIABLE(grub_uboot_search_hint)@ U-Boot stack pointer -
|
||||
@@ -162,8 +172,9 @@ entry_state: @ backup for U-Boot context
|
||||
transition_space:
|
||||
.long 0 @ r8
|
||||
.long 0 @ lr
|
||||
.long 0 @ r9
|
||||
|
||||
VARIABLE(grub_uboot_syscall_ptr)
|
||||
.long 0 @
|
||||
|
||||
.end
|
||||
END
|
||||
|
||||
63
grub-core/kern/arm64/cache.c
Normal file
63
grub-core/kern/arm64/cache.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/cache.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
static grub_int64_t dlinesz;
|
||||
static grub_int64_t ilinesz;
|
||||
|
||||
/* Prototypes for asm functions. */
|
||||
void grub_arch_clean_dcache_range (grub_addr_t beg, grub_addr_t end,
|
||||
grub_uint64_t line_size);
|
||||
void grub_arch_invalidate_icache_range (grub_addr_t beg, grub_addr_t end,
|
||||
grub_uint64_t line_size);
|
||||
|
||||
static void
|
||||
probe_caches (void)
|
||||
{
|
||||
grub_uint64_t cache_type;
|
||||
|
||||
/* Read Cache Type Register */
|
||||
asm volatile ("mrs %0, ctr_el0": "=r"(cache_type));
|
||||
|
||||
dlinesz = 4 << ((cache_type >> 16) & 0xf);
|
||||
ilinesz = 4 << (cache_type & 0xf);
|
||||
|
||||
grub_dprintf("cache", "D$ line size: %lld\n", (long long) dlinesz);
|
||||
grub_dprintf("cache", "I$ line size: %lld\n", (long long) ilinesz);
|
||||
}
|
||||
|
||||
void
|
||||
grub_arch_sync_caches (void *address, grub_size_t len)
|
||||
{
|
||||
grub_uint64_t start, end, max_align;
|
||||
|
||||
if (dlinesz == 0)
|
||||
probe_caches();
|
||||
if (dlinesz == 0)
|
||||
grub_fatal ("Unknown cache line size!");
|
||||
|
||||
max_align = dlinesz > ilinesz ? dlinesz : ilinesz;
|
||||
|
||||
start = ALIGN_DOWN ((grub_uint64_t) address, max_align);
|
||||
end = ALIGN_UP ((grub_uint64_t) address + len, max_align);
|
||||
|
||||
grub_arch_clean_dcache_range (start, end, dlinesz);
|
||||
grub_arch_invalidate_icache_range (start, end, ilinesz);
|
||||
}
|
||||
55
grub-core/kern/arm64/cache_flush.S
Normal file
55
grub-core/kern/arm64/cache_flush.S
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.file "cache_flush.S"
|
||||
.text
|
||||
|
||||
/*
|
||||
* Simple cache maintenance functions
|
||||
*/
|
||||
|
||||
// x0 - *beg (inclusive)
|
||||
// x1 - *end (exclusive)
|
||||
// x2 - line size
|
||||
FUNCTION(grub_arch_clean_dcache_range)
|
||||
// Clean data cache for range to point-of-unification
|
||||
1: cmp x0, x1
|
||||
b.ge 2f
|
||||
dc cvau, x0 // Clean Virtual Address to PoU
|
||||
add x0, x0, x2 // Next line
|
||||
b 1b
|
||||
2: dsb ish
|
||||
isb
|
||||
ret
|
||||
|
||||
// x0 - *beg (inclusive)
|
||||
// x1 - *end (exclusive)
|
||||
// x2 - line size
|
||||
FUNCTION(grub_arch_invalidate_icache_range)
|
||||
// Invalidate instruction cache for range to point-of-unification
|
||||
1: cmp x0, x1
|
||||
b.ge 2f
|
||||
ic ivau, x0 // Invalidate Virtual Address to PoU
|
||||
add x0, x0, x2 // Next line
|
||||
b 1b
|
||||
// Branch predictor invalidation not needed on AArch64
|
||||
2: dsb ish
|
||||
isb
|
||||
ret
|
||||
165
grub-core/kern/arm64/dl.c
Normal file
165
grub-core/kern/arm64/dl.c
Normal file
@@ -0,0 +1,165 @@
|
||||
/* dl.c - arch-dependent part of loadable module support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/cpu/reloc.h>
|
||||
|
||||
struct trampoline
|
||||
{
|
||||
#define LDR 0x58000050
|
||||
#define BR 0xd61f0200
|
||||
grub_uint32_t ldr; /* ldr x16, 8 */
|
||||
grub_uint32_t br; /* br x16 */
|
||||
grub_uint64_t addr;
|
||||
};
|
||||
|
||||
/*
|
||||
* Check if EHDR is a valid ELF header.
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arch_dl_check_header (void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
|
||||
/* Check the magic numbers. */
|
||||
if (e->e_ident[EI_CLASS] != ELFCLASS64
|
||||
|| e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_AARCH64)
|
||||
return grub_error (GRUB_ERR_BAD_OS,
|
||||
N_("invalid arch-dependent ELF magic"));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
grub_err_t
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
const Elf_Ehdr *e = ehdr;
|
||||
const Elf_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
*tramp = 0;
|
||||
*got = 0;
|
||||
|
||||
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
|
||||
{
|
||||
const Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
|
||||
max = rel + s->sh_size / s->sh_entsize;
|
||||
rel < max;
|
||||
rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_AARCH64_CALL26:
|
||||
case R_AARCH64_JUMP26:
|
||||
{
|
||||
*tramp += sizeof (struct trampoline);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unified function for both REL and RELA
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
Elf_Shdr *s, grub_dl_segment_t seg)
|
||||
{
|
||||
Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
|
||||
max = (Elf_Rel *) ((char *) rel + s->sh_size);
|
||||
rel < max;
|
||||
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
|
||||
{
|
||||
Elf_Sym *sym;
|
||||
void *place;
|
||||
grub_uint64_t sym_addr;
|
||||
|
||||
if (rel->r_offset >= seg->size)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ mod->symsize * ELF_R_SYM (rel->r_info));
|
||||
|
||||
sym_addr = sym->st_value;
|
||||
if (s->sh_type == SHT_RELA)
|
||||
sym_addr += ((Elf_Rela *) rel)->r_addend;
|
||||
|
||||
place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
|
||||
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_AARCH64_ABS64:
|
||||
{
|
||||
grub_uint64_t *abs_place = place;
|
||||
|
||||
grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n",
|
||||
place, (unsigned long long) sym_addr);
|
||||
|
||||
*abs_place = (grub_uint64_t) sym_addr;
|
||||
}
|
||||
break;
|
||||
case R_AARCH64_CALL26:
|
||||
case R_AARCH64_JUMP26:
|
||||
{
|
||||
grub_int64_t offset = sym_addr - (grub_uint64_t) place;
|
||||
|
||||
if (!grub_arm_64_check_xxxx26_offset (offset))
|
||||
{
|
||||
struct trampoline *tp = mod->trampptr;
|
||||
mod->trampptr = tp + 1;
|
||||
tp->ldr = LDR;
|
||||
tp->br = BR;
|
||||
tp->addr = sym_addr;
|
||||
offset = (grub_uint8_t *) tp - (grub_uint8_t *) place;
|
||||
}
|
||||
|
||||
if (!grub_arm_64_check_xxxx26_offset (offset))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("Trampoline out of range"));
|
||||
|
||||
grub_arm64_set_xxxx26_offset (place, offset);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
55
grub-core/kern/arm64/dl_helper.c
Normal file
55
grub-core/kern/arm64/dl_helper.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* dl_helper.c - relocation helper functions for modules and grub-mkimage */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/arm64/reloc.h>
|
||||
|
||||
/*
|
||||
* grub_arm64_reloc_xxxx26():
|
||||
*
|
||||
* JUMP26/CALL26 relocations for B and BL instructions.
|
||||
*/
|
||||
|
||||
int
|
||||
grub_arm_64_check_xxxx26_offset (grub_int64_t offset)
|
||||
{
|
||||
const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1;
|
||||
|
||||
if ((offset < offset_low) || (offset > offset_high))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfc000000);
|
||||
|
||||
grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
|
||||
place, offset > 0 ? '+' : '-',
|
||||
offset < 0 ? (long long) -(unsigned long long) offset : offset);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (offset >> 2) & ~insmask;
|
||||
}
|
||||
39
grub-core/kern/arm64/efi/startup.S
Normal file
39
grub-core/kern/arm64/efi/startup.S
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.file "startup.S"
|
||||
.text
|
||||
FUNCTION(_start)
|
||||
/*
|
||||
* EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0.
|
||||
*/
|
||||
ldr x2, efi_image_handle_val
|
||||
str x0, [x2]
|
||||
ldr x2, efi_system_table_val
|
||||
str x1, [x2]
|
||||
ldr x2, grub_main_val
|
||||
br x2
|
||||
grub_main_val:
|
||||
.quad EXT_C(grub_main)
|
||||
efi_system_table_val:
|
||||
.quad EXT_C(grub_efi_system_table)
|
||||
efi_image_handle_val:
|
||||
.quad EXT_C(grub_efi_image_handle)
|
||||
|
||||
@@ -229,9 +229,10 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
unsigned i;
|
||||
Elf_Shdr *s;
|
||||
grub_size_t tsize = 0, talign = 1;
|
||||
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
|
||||
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
|
||||
grub_size_t tramp;
|
||||
grub_size_t got;
|
||||
grub_err_t err;
|
||||
#endif
|
||||
char *ptr;
|
||||
|
||||
@@ -244,10 +245,10 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
talign = s->sh_addralign;
|
||||
}
|
||||
|
||||
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
|
||||
grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
tramp *= GRUB_ARCH_DL_TRAMP_SIZE;
|
||||
got *= sizeof (grub_uint64_t);
|
||||
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
|
||||
err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
if (err)
|
||||
return err;
|
||||
tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
if (talign < GRUB_ARCH_DL_TRAMP_ALIGN)
|
||||
talign = GRUB_ARCH_DL_TRAMP_ALIGN;
|
||||
@@ -313,12 +314,14 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
mod->segment = seg;
|
||||
}
|
||||
}
|
||||
#if defined (__ia64__) || defined (__alpha__) || defined (__powerpc__)
|
||||
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
mod->tramp = ptr;
|
||||
mod->trampptr = ptr;
|
||||
ptr += tramp;
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN);
|
||||
mod->got = ptr;
|
||||
mod->gotptr = ptr;
|
||||
ptr += got;
|
||||
#endif
|
||||
|
||||
@@ -351,6 +354,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
||||
#else
|
||||
mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset);
|
||||
#endif
|
||||
mod->symsize = s->sh_entsize;
|
||||
sym = mod->symtab;
|
||||
size = s->sh_size;
|
||||
entsize = s->sh_entsize;
|
||||
@@ -359,7 +363,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
||||
str = (char *) e + s->sh_offset;
|
||||
|
||||
for (i = 0;
|
||||
i * entsize < size;
|
||||
i < size / entsize;
|
||||
i++, sym = (Elf_Sym *) ((char *) sym + entsize))
|
||||
{
|
||||
unsigned char type = ELF_ST_TYPE (sym->st_info);
|
||||
@@ -553,15 +557,42 @@ grub_dl_unref (grub_dl_t mod)
|
||||
}
|
||||
|
||||
static void
|
||||
grub_dl_flush_cache (grub_dl_t mod __attribute__ ((unused)))
|
||||
grub_dl_flush_cache (grub_dl_t mod)
|
||||
{
|
||||
grub_dprintf ("modules", "flushing 0x%lx bytes at %p\n",
|
||||
(unsigned long) mod->sz, mod->base);
|
||||
#ifdef __alpha__
|
||||
grub_arch_sync_all_caches ();
|
||||
#else
|
||||
grub_arch_sync_caches (mod->base, mod->sz);
|
||||
#endif
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
Elf_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
|
||||
{
|
||||
grub_dl_segment_t seg;
|
||||
grub_err_t err;
|
||||
|
||||
/* Find the target segment. */
|
||||
for (seg = mod->segment; seg; seg = seg->next)
|
||||
if (seg->section == s->sh_info)
|
||||
break;
|
||||
|
||||
if (seg)
|
||||
{
|
||||
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Load a module from core memory. */
|
||||
@@ -610,7 +641,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
|
||||
|| grub_dl_resolve_dependencies (mod, e)
|
||||
|| grub_dl_load_segments (mod, e)
|
||||
|| grub_dl_resolve_symbols (mod, e)
|
||||
|| grub_arch_dl_relocate_symbols (mod, e))
|
||||
|| grub_dl_relocate_symbols (mod, e))
|
||||
{
|
||||
mod->fini = 0;
|
||||
grub_dl_unload (mod);
|
||||
|
||||
@@ -307,10 +307,13 @@ grub_efi_modules_addr (void)
|
||||
#pragma GCC diagnostic error "-Wcast-align"
|
||||
|
||||
char *
|
||||
grub_efi_get_filename (grub_efi_device_path_t *dp)
|
||||
grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
{
|
||||
char *name = 0, *p;
|
||||
grub_size_t filesize = 0;
|
||||
grub_efi_device_path_t *dp;
|
||||
|
||||
dp = dp0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -334,6 +337,8 @@ grub_efi_get_filename (grub_efi_device_path_t *dp)
|
||||
if (!filesize)
|
||||
return NULL;
|
||||
|
||||
dp = dp0;
|
||||
|
||||
p = name = grub_malloc (filesize);
|
||||
if (!name)
|
||||
return NULL;
|
||||
@@ -736,12 +741,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_file_path_device_path_t *fp;
|
||||
grub_uint8_t buf[(len - 4) * 2 + 1];
|
||||
grub_uint8_t *buf;
|
||||
fp = (grub_efi_file_path_device_path_t *) dp;
|
||||
*grub_utf16_to_utf8 (buf, fp->path_name,
|
||||
(len - 4) / sizeof (grub_efi_char16_t))
|
||||
= '\0';
|
||||
buf = grub_malloc ((len - 4) * 2 + 1);
|
||||
if (buf)
|
||||
*grub_utf16_to_utf8 (buf, fp->path_name,
|
||||
(len - 4) / sizeof (grub_efi_char16_t))
|
||||
= '\0';
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_printf ("/File(%s)", buf);
|
||||
grub_free (buf);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
||||
#define PAGES_TO_BYTES(pages) ((pages) << 12)
|
||||
|
||||
#if defined (__code_model_large__) || !defined (__x86_64__)
|
||||
#define MAX_USABLE_ADDRESS 0xffffffff
|
||||
#else
|
||||
#define MAX_USABLE_ADDRESS 0x7fffffff
|
||||
#endif
|
||||
|
||||
/* The size of a memory map obtained from the firmware. This must be
|
||||
a multiplier of 4KB. */
|
||||
#define MEMORY_MAP_SIZE 0x3000
|
||||
@@ -58,7 +64,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
|
||||
#if 1
|
||||
/* Limit the memory access to less than 4GB for 32-bit platforms. */
|
||||
if (address > 0xffffffff)
|
||||
if (address > MAX_USABLE_ADDRESS)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
@@ -66,7 +72,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
if (address == 0)
|
||||
{
|
||||
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
||||
address = 0xffffffff;
|
||||
address = MAX_USABLE_ADDRESS;
|
||||
}
|
||||
else
|
||||
type = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||
@@ -86,7 +92,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
{
|
||||
/* Uggh, the address 0 was allocated... This is too annoying,
|
||||
so reallocate another one. */
|
||||
address = 0xffffffff;
|
||||
address = MAX_USABLE_ADDRESS;
|
||||
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
grub_efi_free_pages (0, pages);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
@@ -319,7 +325,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
{
|
||||
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
||||
#if 1
|
||||
&& desc->physical_start <= 0xffffffff
|
||||
&& desc->physical_start <= MAX_USABLE_ADDRESS
|
||||
#endif
|
||||
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
||||
&& desc->num_pages != 0)
|
||||
@@ -337,9 +343,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
#if 1
|
||||
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
||||
+ filtered_desc->num_pages
|
||||
> BYTES_TO_PAGES (0x100000000LL))
|
||||
> BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
|
||||
filtered_desc->num_pages
|
||||
= (BYTES_TO_PAGES (0x100000000LL)
|
||||
= (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
|
||||
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,14 +39,17 @@ grub_arch_dl_check_header (void *ehdr)
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
Elf_Shdr *s, grub_dl_segment_t seg)
|
||||
{
|
||||
(void) mod;
|
||||
(void) ehdr;
|
||||
(void) s;
|
||||
(void) seg;
|
||||
return GRUB_ERR_BAD_MODULE;
|
||||
}
|
||||
|
||||
#if defined (__ia64__) || defined (__powerpc__)
|
||||
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
|
||||
void grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
|
||||
grub_size_t *tramp, grub_size_t *got)
|
||||
{
|
||||
|
||||
@@ -609,3 +609,78 @@ grub_util_biosdisk_get_osdev (grub_disk_t disk)
|
||||
|
||||
return map[disk->id].device;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
grub_util_path_concat_real (size_t n, int ext, va_list ap)
|
||||
{
|
||||
size_t totlen = 0;
|
||||
char **l = xmalloc ((n + ext) * sizeof (l[0]));
|
||||
char *r, *p, *pi;
|
||||
size_t i;
|
||||
int first = 1;
|
||||
|
||||
for (i = 0; i < n + ext; i++)
|
||||
{
|
||||
l[i] = va_arg (ap, char *);
|
||||
if (l[i])
|
||||
totlen += strlen (l[i]) + 1;
|
||||
}
|
||||
|
||||
r = xmalloc (totlen + 10);
|
||||
|
||||
p = r;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
pi = l[i];
|
||||
if (!pi)
|
||||
continue;
|
||||
while (*pi == '/')
|
||||
pi++;
|
||||
if ((p != r || (pi != l[i] && first)) && (p == r || *(p - 1) != '/'))
|
||||
*p++ = '/';
|
||||
first = 0;
|
||||
p = grub_stpcpy (p, pi);
|
||||
while (p != r && p != r + 1 && *(p - 1) == '/')
|
||||
p--;
|
||||
}
|
||||
|
||||
if (ext && l[i])
|
||||
p = grub_stpcpy (p, l[i]);
|
||||
|
||||
*p = '\0';
|
||||
|
||||
free (l);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_util_path_concat (size_t n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *r;
|
||||
|
||||
va_start (ap, n);
|
||||
|
||||
r = grub_util_path_concat_real (n, 0, ap);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_util_path_concat_ext (size_t n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *r;
|
||||
|
||||
va_start (ap, n);
|
||||
|
||||
r = grub_util_path_concat_real (n, 1, ap);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,9 @@ is_dir (const char *path, const char *name)
|
||||
{
|
||||
int len1 = strlen(path);
|
||||
int len2 = strlen(name);
|
||||
int ret;
|
||||
|
||||
char pathname[len1 + 1 + len2 + 1 + 13];
|
||||
char *pathname = xmalloc (len1 + 1 + len2 + 1 + 13);
|
||||
strcpy (pathname, path);
|
||||
|
||||
/* Avoid UNC-path "//name" on Cygwin. */
|
||||
@@ -49,7 +50,9 @@ is_dir (const char *path, const char *name)
|
||||
|
||||
strcat (pathname, name);
|
||||
|
||||
return grub_util_is_directory (pathname);
|
||||
ret = grub_util_is_directory (pathname);
|
||||
free (pathname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct grub_hostfs_data
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <grub/env.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/loader.h>
|
||||
#include <grub/util/misc.h>
|
||||
|
||||
#include "progname.h"
|
||||
@@ -75,9 +76,10 @@ grub_machine_get_bootlocation (char **device, char **path)
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_console_fini ();
|
||||
if (flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_console_fini ();
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +166,8 @@ static struct argp argp = {
|
||||
|
||||
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -223,7 +227,7 @@ main (int argc, char *argv[])
|
||||
grub_hostfs_fini ();
|
||||
grub_host_fini ();
|
||||
|
||||
grub_machine_fini ();
|
||||
grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,9 +87,6 @@ grub_file_open (const char *name)
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
file->name = grub_strdup (name);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
file->device = device;
|
||||
|
||||
if (device->disk && file_name[0] != '/')
|
||||
@@ -105,6 +102,9 @@ grub_file_open (const char *name)
|
||||
if ((file->fs->open) (file, file_name) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
|
||||
file->name = grub_strdup (name);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled);
|
||||
filter++)
|
||||
if (grub_file_filters_enabled[filter])
|
||||
@@ -187,6 +187,7 @@ grub_file_close (grub_file_t file)
|
||||
|
||||
if (file->device)
|
||||
grub_device_close (file->device);
|
||||
grub_free (file->name);
|
||||
grub_free (file);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
@@ -130,8 +130,9 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_vga_text_fini ();
|
||||
if (flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_vga_text_fini ();
|
||||
grub_stop_floppy ();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
/* For stack parameters. */
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
@@ -40,75 +40,42 @@ grub_arch_dl_check_header (void *ehdr)
|
||||
|
||||
/* Relocate symbols. */
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
Elf_Shdr *s, grub_dl_segment_t seg)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
Elf_Shdr *s;
|
||||
Elf_Word entsize;
|
||||
unsigned i;
|
||||
Elf_Rel *rel, *max;
|
||||
|
||||
/* Find a symbol table. */
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
break;
|
||||
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
|
||||
max = (Elf_Rel *) ((char *) rel + s->sh_size);
|
||||
rel < max;
|
||||
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
|
||||
{
|
||||
Elf_Word *addr;
|
||||
Elf_Sym *sym;
|
||||
|
||||
if (i == e->e_shnum)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
entsize = s->sh_entsize;
|
||||
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ mod->symsize * ELF_R_SYM (rel->r_info));
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL)
|
||||
{
|
||||
grub_dl_segment_t seg;
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_386_32:
|
||||
*addr += sym->st_value;
|
||||
break;
|
||||
|
||||
/* Find the target segment. */
|
||||
for (seg = mod->segment; seg; seg = seg->next)
|
||||
if (seg->section == s->sh_info)
|
||||
break;
|
||||
|
||||
if (seg)
|
||||
{
|
||||
Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
|
||||
max = rel + s->sh_size / s->sh_entsize;
|
||||
rel < max;
|
||||
rel++)
|
||||
{
|
||||
Elf_Word *addr;
|
||||
Elf_Sym *sym;
|
||||
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ entsize * ELF_R_SYM (rel->r_info));
|
||||
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_386_32:
|
||||
*addr += sym->st_value;
|
||||
break;
|
||||
|
||||
case R_386_PC32:
|
||||
*addr += (sym->st_value - (Elf_Word) seg->addr
|
||||
- rel->r_offset);
|
||||
break;
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case R_386_PC32:
|
||||
*addr += (sym->st_value - (grub_addr_t) addr);
|
||||
break;
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/loader.h>
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
@@ -35,7 +36,8 @@ grub_machine_init (void)
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_efi_fini ();
|
||||
if (flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_efi_fini ();
|
||||
}
|
||||
|
||||
@@ -161,13 +161,13 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
|
||||
void *data __attribute__ ((unused)))
|
||||
{
|
||||
/* Avoid the lower memory. */
|
||||
if (addr < 0x100000)
|
||||
if (addr < GRUB_MEMORY_MACHINE_UPPER_START)
|
||||
{
|
||||
if (size <= 0x100000 - addr)
|
||||
if (size <= GRUB_MEMORY_MACHINE_UPPER_START - addr)
|
||||
return 0;
|
||||
|
||||
size -= 0x100000 - addr;
|
||||
addr = 0x100000;
|
||||
size -= GRUB_MEMORY_MACHINE_UPPER_START - addr;
|
||||
addr = GRUB_MEMORY_MACHINE_UPPER_START;
|
||||
}
|
||||
|
||||
/* Ignore >4GB. */
|
||||
@@ -239,8 +239,9 @@ grub_machine_init (void)
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_console_fini ();
|
||||
if (flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_console_fini ();
|
||||
grub_stop_floppy ();
|
||||
}
|
||||
|
||||
@@ -96,17 +96,8 @@ struct iterator_ctx
|
||||
grub_size_t nresources;
|
||||
};
|
||||
|
||||
static int
|
||||
count_cards (grub_pci_device_t dev __attribute__ ((unused)),
|
||||
grub_pci_id_t pciid __attribute__ ((unused)),
|
||||
void *data)
|
||||
{
|
||||
int *cnt = data;
|
||||
|
||||
(*cnt)++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* We don't support bridges, so can't have more than 32 devices. */
|
||||
#define MAX_DEVICES 32
|
||||
|
||||
static int
|
||||
find_resources (grub_pci_device_t dev,
|
||||
@@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev,
|
||||
struct iterator_ctx *ctx = data;
|
||||
int bar;
|
||||
|
||||
if (ctx->nresources >= MAX_DEVICES * 6)
|
||||
return 1;
|
||||
|
||||
for (bar = 0; bar < 6; bar++)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
@@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev,
|
||||
static void
|
||||
grub_pci_assign_addresses (void)
|
||||
{
|
||||
int ncards = 0;
|
||||
struct iterator_ctx ctx;
|
||||
|
||||
grub_pci_iterate (count_cards, &ncards);
|
||||
|
||||
{
|
||||
struct resource resources[ncards * 6];
|
||||
struct resource resources[MAX_DEVICES * 6];
|
||||
int done;
|
||||
unsigned i;
|
||||
ctx.nresources = 0;
|
||||
@@ -277,8 +268,9 @@ grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
grub_machine_fini (int flags)
|
||||
{
|
||||
grub_vga_text_fini ();
|
||||
if (flags & GRUB_LOADER_FLAG_NORETURN)
|
||||
grub_vga_text_fini ();
|
||||
grub_stop_floppy ();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
|
||||
/*
|
||||
* Note: These functions defined in this file may be called from C.
|
||||
@@ -196,8 +196,6 @@ protcseg:
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
|
||||
prot_to_real:
|
||||
/* just in case, set GDT */
|
||||
lgdt gdtdesc
|
||||
|
||||
@@ -25,7 +25,11 @@
|
||||
#include <grub/misc.h>
|
||||
#include <grub/i386/tsc.h>
|
||||
#include <grub/i386/cpuid.h>
|
||||
#ifdef GRUB_MACHINE_XEN
|
||||
#include <grub/xen.h>
|
||||
#else
|
||||
#include <grub/i386/pit.h>
|
||||
#endif
|
||||
#include <grub/cpu/io.h>
|
||||
|
||||
/* This defines the value TSC had at the epoch (that is, when we calibrated it). */
|
||||
@@ -65,6 +69,8 @@ grub_cpu_is_tsc_supported (void)
|
||||
return (d & (1 << 4)) != 0;
|
||||
}
|
||||
|
||||
#ifndef GRUB_MACHINE_XEN
|
||||
|
||||
static void
|
||||
grub_pit_wait (grub_uint16_t tics)
|
||||
{
|
||||
@@ -92,6 +98,7 @@ grub_pit_wait (grub_uint16_t tics)
|
||||
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
||||
GRUB_PIT_SPEAKER_PORT);
|
||||
}
|
||||
#endif
|
||||
|
||||
static grub_uint64_t
|
||||
grub_tsc_get_time_ms (void)
|
||||
@@ -103,6 +110,7 @@ grub_tsc_get_time_ms (void)
|
||||
return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
|
||||
}
|
||||
|
||||
#ifndef GRUB_MACHINE_XEN
|
||||
/* Calibrate the TSC based on the RTC. */
|
||||
static void
|
||||
calibrate_tsc (void)
|
||||
@@ -116,10 +124,22 @@ calibrate_tsc (void)
|
||||
|
||||
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_tsc_init (void)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_XEN
|
||||
grub_uint64_t t;
|
||||
tsc_boot_time = grub_get_tsc ();
|
||||
t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul;
|
||||
if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0)
|
||||
t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
else
|
||||
t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
|
||||
grub_tsc_rate = grub_divmod64 (t, 1000000, 0);
|
||||
grub_install_get_time_ms (grub_tsc_get_time_ms);
|
||||
#else
|
||||
if (grub_cpu_is_tsc_supported ())
|
||||
{
|
||||
calibrate_tsc ();
|
||||
@@ -133,4 +153,5 @@ grub_tsc_init (void)
|
||||
grub_fatal ("no TSC found");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
43
grub-core/kern/i386/xen/hypercall.S
Normal file
43
grub-core/kern/i386/xen/hypercall.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/* hypercall.S - wrappers for Xen hypercalls */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/xen.h>
|
||||
|
||||
FUNCTION(grub_xen_hypercall)
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
|
||||
/* call number already in %eax. */
|
||||
/* %edx -> %ebx*/
|
||||
/* %ecx -> %ecx*/
|
||||
movl %edx, %ebx
|
||||
movl 8(%ebp), %edx
|
||||
movl 12(%ebp), %esi
|
||||
movl 16(%ebp), %edi
|
||||
movl 20(%ebp), %ebp
|
||||
int $0x82
|
||||
popl %ebx
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %ebp
|
||||
retl $16
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user