merge from trunk
This commit is contained in:
commit
e6127bed25
360 changed files with 38433 additions and 8956 deletions
|
@ -25,6 +25,8 @@ docs/version.texi
|
|||
*.exec
|
||||
genkernsyms.sh
|
||||
gensymlist.sh
|
||||
gentrigtables
|
||||
grub-bin2h
|
||||
grub-dumpbios
|
||||
grub-editenv
|
||||
grub-emu
|
||||
|
@ -40,8 +42,13 @@ grub-pe2elf
|
|||
grub-probe
|
||||
grub_probe_init.c
|
||||
grub_probe_init.h
|
||||
grub-reboot
|
||||
grub-script-check
|
||||
grub_script_check_init.c
|
||||
grub_script_check_init.h
|
||||
grub_script.tab.c
|
||||
grub_script.tab.h
|
||||
grub-set-default
|
||||
grub-setup
|
||||
grub_setup_init.c
|
||||
grub_setup_init.h
|
||||
|
@ -62,4 +69,5 @@ stamp-h
|
|||
stamp-h1
|
||||
stamp-h.in
|
||||
symlist.c
|
||||
trigtables.c
|
||||
update-grub_lib
|
||||
|
|
5
INSTALL
5
INSTALL
|
@ -14,6 +14,7 @@ configuring the GRUB.
|
|||
* GCC 4.1.3 or later
|
||||
* GNU Make
|
||||
* GNU Bison 2.3 or later
|
||||
* GNU gettext 0.17 or later
|
||||
* GNU binutils 2.9.1.0.23 or later
|
||||
* Other standard GNU/Unix tools
|
||||
|
||||
|
@ -25,6 +26,10 @@ need the following.
|
|||
* Autoconf 2.60 or later
|
||||
* Automake 1.10.1 or later
|
||||
|
||||
Prerequisites for make-check:
|
||||
|
||||
* qemu, specifically the binary 'qemu-system-i386'
|
||||
|
||||
Configuring the GRUB
|
||||
====================
|
||||
|
||||
|
|
63
Makefile.in
63
Makefile.in
|
@ -35,6 +35,7 @@ sysconfdir = @sysconfdir@
|
|||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
localedir = @localedir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
|
@ -43,6 +44,10 @@ pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '
|
|||
|
||||
# Internationalization library.
|
||||
LIBINTL = @LIBINTL@
|
||||
TARGET_NO_MODULES = @TARGET_NO_MODULES@
|
||||
|
||||
# Util library.
|
||||
LIBUTIL = @LIBUTIL@
|
||||
|
||||
XGETTEXT = @XGETTEXT@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
|
@ -75,27 +80,31 @@ MKDIR_P = @MKDIR_P@
|
|||
|
||||
mkinstalldirs = $(srcdir)/mkinstalldirs
|
||||
|
||||
LIBS = @LIBS@ $(LIBINTL)
|
||||
LIBS = @LIBS@ $(LIBINTL) $(LIBUTIL)
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
POSIX_CFLAGS = -I$(srcdir)/lib/posix_wrap
|
||||
GNULIB_UTIL_CFLAGS = -Wno-undef -Wno-sign-compare -Wno-unused -D_GL_UNUSED="__attribute__ ((unused))" -I$(srcdir)/gnulib
|
||||
GNULIB_CFLAGS = $(GNULIB_UTIL_CFLAGS) $(POSIX_CFLAGS)
|
||||
ASFLAGS = @ASFLAGS@
|
||||
LDFLAGS = @LDFLAGS@ $(LIBS)
|
||||
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
||||
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
|
||||
TARGET_CC = @TARGET_CC@
|
||||
TARGET_CFLAGS = @TARGET_CFLAGS@
|
||||
TARGET_ASFLAGS = @TARGET_ASFLAGS@
|
||||
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
|
||||
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
|
||||
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
|
||||
TARGET_APPLE_CC = @TARGET_APPLE_CC@
|
||||
OBJCONV = @OBJCONV@
|
||||
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
|
||||
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
|
||||
-Wall -W
|
||||
TARGET_LDFLAGS = @TARGET_LDFLAGS@
|
||||
TARGET_LDFLAGS = -nostdlib -static-libgcc @TARGET_LDFLAGS@
|
||||
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
|
||||
TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
|
||||
TARGET_IMG_LDFLAGS = -nostdlib @TARGET_IMG_LDFLAGS@
|
||||
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
|
||||
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
|
||||
kernel_img_LDFLAGS = -lgcc
|
||||
EXEEXT = @EXEEXT@
|
||||
OBJCOPY = @OBJCOPY@
|
||||
STRIP = @STRIP@
|
||||
|
@ -114,12 +123,15 @@ endif
|
|||
AWK = @AWK@
|
||||
LIBCURSES = @LIBCURSES@
|
||||
LIBUSB = @LIBUSB@
|
||||
LIBSDL = @LIBSDL@
|
||||
LIBPCIACCESS = @LIBPCIACCESS@
|
||||
LEX = @LEX@
|
||||
YACC = @YACC@
|
||||
FONT_SOURCE = @FONT_SOURCE@
|
||||
|
||||
# Options.
|
||||
enable_grub_emu_usb = @enable_grub_emu_usb@
|
||||
enable_grub_emu_sdl = @enable_grub_emu_sdl@
|
||||
enable_grub_emu_pci = @enable_grub_emu_pci@
|
||||
enable_grub_fstest = @enable_grub_fstest@
|
||||
enable_grub_pe2elf = @enable_grub_pe2elf@
|
||||
|
@ -130,7 +142,7 @@ enable_efiemu = @enable_efiemu@
|
|||
|
||||
### General variables.
|
||||
|
||||
RMKFILES = $(wildcard conf/*.rmk)
|
||||
RMKFILES = $(wildcard $(srcdir)/conf/*.rmk)
|
||||
|
||||
MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
|
||||
|
||||
|
@ -145,11 +157,13 @@ INFOS = $(info_INFOS)
|
|||
CLEANFILES =
|
||||
MOSTLYCLEANFILES =
|
||||
DISTCLEANFILES = config.status config.cache config.log config.h \
|
||||
Makefile stamp-h include/grub/cpu include/grub/machine \
|
||||
Makefile stamp-h stamp-h1 include/grub/cpu include/grub/machine \
|
||||
gensymlist.sh genkernsyms.sh build_env.mk \
|
||||
docs/grub.info docs/version.texi docs/stamp-vti
|
||||
|
||||
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \
|
||||
MAINTAINER_CLEANFILES = $(srcdir)/configure $(srcdir)/aclocal.m4 \
|
||||
$(MKFILES) $(srcdir)/config.guess \
|
||||
$(srcdir)/config.sub $(srcdir)/install-sh $(srcdir)/missing \
|
||||
$(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS)
|
||||
|
||||
# The default target.
|
||||
|
@ -173,10 +187,17 @@ include $(srcdir)/conf/tests.mk
|
|||
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_NO_MODULES), yes)
|
||||
TARGET_CFLAGS += -DGRUB_TARGET_NO_MODULES=1
|
||||
CFLAGS += -DGRUB_TARGET_NO_MODULES=1
|
||||
endif
|
||||
|
||||
### General targets.
|
||||
|
||||
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst
|
||||
endif
|
||||
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
|
||||
cat $(DEFSYMFILES) /dev/null \
|
||||
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|
||||
|
@ -237,6 +258,7 @@ else
|
|||
ifeq ($(enable_grub_mkfont),yes)
|
||||
|
||||
pkgdata_DATA += unicode.pf2 ascii.pf2 ascii.h
|
||||
CLEANFILES += ascii.bitmaps
|
||||
|
||||
# Arrows and lines are needed to draw the menu, so we always include them
|
||||
UNICODE_ARROWS=0x2190-0x2193
|
||||
|
@ -276,7 +298,7 @@ build_env.mk: Makefile
|
|||
) > $@
|
||||
pkglib_BUILDDIR += config.h grub_script.tab.h
|
||||
|
||||
all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
|
||||
all-local: $(PROGRAMS) $(GRUB_EMU) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
|
||||
|
||||
install: install-local
|
||||
|
||||
|
@ -297,7 +319,7 @@ install-local: all
|
|||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \
|
||||
done
|
||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
|
||||
@list='$(bin_UTILITIES)'; for file in $$list; do \
|
||||
@list='$(bin_UTILITIES) $(GRUB_EMU)'; for file in $$list; do \
|
||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
||||
$(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
|
||||
|
@ -373,7 +395,7 @@ uninstall:
|
|||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
||||
rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
|
||||
done
|
||||
@list='$(bin_UTILITIES) $(bin_SCRIPTS)'; for file in $$list; do \
|
||||
@list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU)'; for file in $$list; do \
|
||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
||||
rm -f $(DESTDIR)$(bindir)/$$dest; \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$dest.1; \
|
||||
|
@ -390,7 +412,6 @@ uninstall:
|
|||
@list='$(lib_SCRIPTS)'; \
|
||||
for file in $$list; do \
|
||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
||||
echo rm -f $(DESTDIR)$(libdir)/$$dest; \
|
||||
rm -f $(DESTDIR)$(libdir)/grub/$$dest; \
|
||||
done
|
||||
@list='$(info_INFOS)'; \
|
||||
|
@ -419,6 +440,8 @@ distclean: mostlyclean
|
|||
|
||||
maintainer-clean: distclean
|
||||
-test -z "$(MAINTAINER_CLEANFILES)" || rm -f $(MAINTAINER_CLEANFILES)
|
||||
-rmdir $(srcdir)/lib/libgcrypt-grub/cipher
|
||||
-rmdir $(srcdir)/lib/libgcrypt-grub
|
||||
|
||||
info:
|
||||
|
||||
|
@ -473,23 +496,21 @@ distcheck: dist
|
|||
|
||||
check: all $(UNIT_TESTS) $(FUNCTIONAL_TESTS) $(SCRIPTED_TESTS)
|
||||
@list="$(UNIT_TESTS)"; \
|
||||
set -e; \
|
||||
for file in $$list; do \
|
||||
$(builddir)/$$file; \
|
||||
done
|
||||
@list="$(FUNCTIONAL_TESTS)"; \
|
||||
set -e; \
|
||||
for file in $$list; do \
|
||||
mod=`basename $$file .mod`; \
|
||||
echo "insmod functional_test; insmod $$mod; functional_test" \
|
||||
| $(builddir)/grub-shell; \
|
||||
done
|
||||
@list="$(SCRIPTED_TESTS)"; \
|
||||
set -e; \
|
||||
for file in $$list; do \
|
||||
echo "$$file:"; \
|
||||
if $(builddir)/$$file; then \
|
||||
echo "$$file: PASS"; \
|
||||
else \
|
||||
echo "$$file: FAIL"; \
|
||||
fi; \
|
||||
$(builddir)/$$file; \
|
||||
done
|
||||
|
||||
.SUFFIX:
|
||||
|
@ -524,8 +545,8 @@ genkernsyms.sh: genkernsyms.sh.in config.status
|
|||
$(SHELL) ./config.status
|
||||
|
||||
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
|
||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_
|
||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell
|
||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES --keyword=_ --keyword=N_
|
||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES-shell -j --language=Shell
|
||||
|
||||
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
|
||||
$(MSGMERGE) -U $@ $^
|
||||
|
|
19
NEWS
19
NEWS
|
@ -1,4 +1,21 @@
|
|||
New in 1.98:
|
||||
New in 1.98 - 2010-03-06:
|
||||
|
||||
* Multiboot on EFI support.
|
||||
|
||||
* Graphical menu support.
|
||||
|
||||
* MIPS support.
|
||||
|
||||
* Saved default menu entry support, with new utilities `grub-reboot' and
|
||||
`grub-set-default'.
|
||||
|
||||
* Unit testing framework.
|
||||
|
||||
* Support for multiple terminals.
|
||||
|
||||
* Encrypted password support, with a new utility `grub-mkpasswd-pbkdf2'.
|
||||
|
||||
* `grub-mkfloppy' removed; use `grub-mkrescue' to create floppy images.
|
||||
|
||||
* Add grub-probe support for GNU/Hurd.
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ else
|
|||
fi
|
||||
grub_cv_prog_objcopy_absolute=yes
|
||||
for link_addr in 0x2000 0x8000 0x7C00; do
|
||||
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
|
||||
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC}$link_addr conftest.o -o conftest.exec]); then :
|
||||
else
|
||||
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
|
||||
fi
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
/* Print message string */
|
||||
#define MSG(x) movw $x, %si; call LOCAL(message)
|
||||
#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
|
||||
|
||||
.file "boot.S"
|
||||
|
||||
|
@ -233,7 +234,7 @@ LOCAL(chs_mode):
|
|||
jz LOCAL(floppy_probe)
|
||||
|
||||
/* Nope, we definitely have a hard disk, and we're screwed. */
|
||||
jmp LOCAL(hd_probe_error)
|
||||
ERR(hd_probe_error_string)
|
||||
|
||||
LOCAL(final_init):
|
||||
/* set the mode to zero */
|
||||
|
@ -360,22 +361,15 @@ LOCAL(copy_buffer):
|
|||
* BIOS Geometry translation error (past the end of the disk geometry!).
|
||||
*/
|
||||
LOCAL(geometry_error):
|
||||
MSG(geometry_error_string)
|
||||
jmp LOCAL(general_error)
|
||||
|
||||
/*
|
||||
* Disk probe failure.
|
||||
*/
|
||||
LOCAL(hd_probe_error):
|
||||
MSG(hd_probe_error_string)
|
||||
jmp LOCAL(general_error)
|
||||
ERR(geometry_error_string)
|
||||
|
||||
/*
|
||||
* Read error on the disk.
|
||||
*/
|
||||
LOCAL(read_error):
|
||||
MSG(read_error_string)
|
||||
|
||||
movw $read_error_string, %si
|
||||
LOCAL(error_message):
|
||||
call LOCAL(message)
|
||||
LOCAL(general_error):
|
||||
MSG(general_error_string)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2000,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,6 +16,8 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/boot.h>
|
||||
|
||||
.file "pxeboot.S"
|
||||
.text
|
||||
|
||||
|
@ -28,7 +30,7 @@ _start:
|
|||
start:
|
||||
|
||||
/* Use drive number 0x7F for PXE */
|
||||
movb $0x7F, %dl
|
||||
movb $GRUB_BOOT_MACHINE_PXE_DL, %dl
|
||||
|
||||
/* Jump to the real world */
|
||||
ljmp $0, $0x8200
|
||||
|
|
|
@ -63,5 +63,8 @@ VARIABLE(grub_core_entry_addr)
|
|||
*right here* and this is why we need this kludge. */
|
||||
|
||||
. = GRUB_BOOT_MACHINE_SIZE - 16
|
||||
|
||||
.code16
|
||||
|
||||
jmp _start
|
||||
. = GRUB_BOOT_MACHINE_SIZE
|
||||
|
|
|
@ -45,8 +45,9 @@ boot_version: .byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
|
|||
* load address plus the size of the prepended A.OUT header (32 bytes).
|
||||
*/
|
||||
boot_path:
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
kernel_sector: .xword 2
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
|
||||
boot_path_end:
|
||||
kernel_byte: .xword (2 << 9)
|
||||
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||
|
||||
prom_finddev_name: .asciz "finddevice"
|
||||
|
@ -77,10 +78,22 @@ prom_error:
|
|||
/* %o0: OF call name
|
||||
* %o1: input arg 1
|
||||
*/
|
||||
prom_call_1_1:
|
||||
prom_call_1_1_o2:
|
||||
clr %o2
|
||||
ba prom_call_x_1
|
||||
mov 1, %g1
|
||||
ba prom_call
|
||||
mov 1, %o5
|
||||
|
||||
prom_call_getprop:
|
||||
mov 4, %g1
|
||||
stx %g1, [%l1 + 256]
|
||||
mov CHOSEN_NODE_REG, %o1
|
||||
ba prom_call_x_1
|
||||
GET_ABS(prom_getprop_name, %o0)
|
||||
|
||||
prom_call_3_1_o1:
|
||||
ba prom_call_3_1
|
||||
mov BOOTDEV_REG, %o1
|
||||
|
||||
|
||||
/* %o2: message string
|
||||
* %o3: message length
|
||||
|
@ -97,6 +110,7 @@ console_write:
|
|||
*/
|
||||
prom_call_3_1:
|
||||
mov 3, %g1
|
||||
prom_call_x_1:
|
||||
mov 1, %o5
|
||||
/* fallthru */
|
||||
|
||||
|
@ -118,7 +132,7 @@ prom_call:
|
|||
|
||||
boot_continue:
|
||||
mov %o7, PIC_REG /* PIC base */
|
||||
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
|
||||
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
|
||||
|
||||
/* Find the /chosen node so we can fetch the stdout handle,
|
||||
* and thus perform console output.
|
||||
|
@ -126,23 +140,17 @@ boot_continue:
|
|||
* chosen_node = prom_finddevice("/chosen")
|
||||
*/
|
||||
GET_ABS(prom_finddev_name, %o0)
|
||||
call prom_call_1_1_o2
|
||||
GET_ABS(prom_chosen_path, %o1)
|
||||
call prom_call_1_1
|
||||
clr %o2
|
||||
|
||||
ldx [%l1 + 0x20], CHOSEN_NODE_REG
|
||||
brz CHOSEN_NODE_REG, prom_error
|
||||
|
||||
/* getprop(chosen_node, "stdout", &buffer, buffer_size) */
|
||||
GET_ABS(prom_getprop_name, %o0)
|
||||
mov 4, %g1
|
||||
mov 1, %o5
|
||||
mov CHOSEN_NODE_REG, %o1
|
||||
GET_ABS(prom_stdout_name, %o2)
|
||||
add %l1, 256, %o3
|
||||
call prom_call_getprop
|
||||
mov 1024, %o4
|
||||
call prom_call
|
||||
stx %g1, [%l1 + 256]
|
||||
|
||||
lduw [%l1 + 256], STDOUT_NODE_REG
|
||||
brz,pn STDOUT_NODE_REG, prom_error
|
||||
|
@ -152,15 +160,25 @@ boot_continue:
|
|||
call console_write
|
||||
mov GRUB_NAME_LEN, %o3
|
||||
|
||||
GET_ABS(boot_path, %o3)
|
||||
ldub [%o3], %o1
|
||||
brnz,pn %o1, bootpath_known
|
||||
|
||||
/* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
|
||||
GET_ABS(prom_bootpath_name, %o2)
|
||||
call prom_call_getprop
|
||||
mov (boot_path_end - boot_path), %o4
|
||||
|
||||
bootpath_known:
|
||||
|
||||
/* Open up the boot_path, and use that handle to read the
|
||||
* first block of the GRUB kernel image.
|
||||
*
|
||||
* bootdev_handle = open(boot_path)
|
||||
*/
|
||||
GET_ABS(prom_open_name, %o0)
|
||||
call prom_call_1_1_o2
|
||||
GET_ABS(boot_path, %o1)
|
||||
call prom_call_1_1
|
||||
clr %o2
|
||||
|
||||
ldx [%l1 + 0x20], BOOTDEV_REG
|
||||
brz,pn BOOTDEV_REG, prom_open_error
|
||||
|
@ -168,28 +186,23 @@ boot_continue:
|
|||
/* Since we have 64-bit cells, the high cell of the seek offset
|
||||
* is zero and the low cell is the entire value.
|
||||
*
|
||||
* seek(bootdev, 0, *kernel_sector << 9)
|
||||
* seek(bootdev, 0, *kernel_byte)
|
||||
*/
|
||||
GET_ABS(prom_seek_name, %o0)
|
||||
mov BOOTDEV_REG, %o1
|
||||
clr %o2
|
||||
LDX_ABS(kernel_sector, 0x00, %o3)
|
||||
call prom_call_3_1
|
||||
sllx %o3, 9, %o3
|
||||
call prom_call_3_1_o1
|
||||
LDX_ABS(kernel_byte, 0x00, %o3)
|
||||
|
||||
/* read(bootdev, *kernel_address, 512) */
|
||||
GET_ABS(prom_read_name, %o0)
|
||||
mov BOOTDEV_REG, %o1
|
||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||
call prom_call_3_1
|
||||
call prom_call_3_1_o1
|
||||
mov 512, %o3
|
||||
|
||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||
jmpl %o2, %o7
|
||||
nop
|
||||
|
||||
1: ba,a 1b
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_CODE_END
|
||||
|
||||
/* the last 4 bytes in the sector 0 contain the signature */
|
||||
|
|
|
@ -81,7 +81,7 @@ prom_call:
|
|||
|
||||
|
||||
after_info_block:
|
||||
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
|
||||
sethi %hi(SCRATCH_PAD_DISKBOOT), %l1 /* OF argument slots */
|
||||
|
||||
GET_ABS(notification_string, %o2)
|
||||
call console_write
|
||||
|
@ -129,7 +129,7 @@ bootit:
|
|||
mov NOTIFICATION_DONE_LEN, %o3
|
||||
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
||||
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
||||
mov CIF_REG, %o0
|
||||
mov CIF_REG, %o4
|
||||
1: ba,a 1b
|
||||
|
||||
lastlist:
|
||||
|
|
|
@ -105,14 +105,14 @@ grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
|
|||
grub_usb_err_t
|
||||
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
||||
grub_uint8_t request, grub_uint16_t value,
|
||||
grub_uint16_t index, grub_size_t size, char *data)
|
||||
grub_uint16_t idx, grub_size_t size, char *data)
|
||||
{
|
||||
usb_dev_handle *devh;
|
||||
struct usb_device *d = dev->data;
|
||||
|
||||
devh = usb_open (d);
|
||||
if (usb_control_msg (devh, reqtype, request,
|
||||
value, index, data, size, 20) < 0)
|
||||
value, idx, data, size, 20) < 0)
|
||||
{
|
||||
usb_close (devh);
|
||||
return GRUB_USB_ERR_STALL;
|
|
@ -90,7 +90,6 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"this command is available only for disk devices");
|
||||
|
||||
if (file->device->disk->partition)
|
||||
part_start = grub_partition_get_start (file->device->disk->partition);
|
||||
|
||||
file->read_hook = read_blocklist;
|
||||
|
|
|
@ -41,7 +41,7 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
file = grub_gzfile_open (args[0], 1);
|
||||
if (! file)
|
||||
return 0;
|
||||
return grub_errno;
|
||||
|
||||
while ((size = grub_file_read (file, buf, sizeof (buf))) > 0
|
||||
&& key != GRUB_TERM_ESC)
|
||||
|
|
|
@ -24,13 +24,14 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"hash", 'h', 0, "Specify hash to use.", "HASH", ARG_TYPE_STRING},
|
||||
{"check", 'c', 0, "Check hash list file.", "FILE", ARG_TYPE_STRING},
|
||||
{"prefix", 'p', 0, "Base directory for hash list.", "DIRECTORY",
|
||||
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
|
||||
{"check", 'c', 0, N_("Check hash list file."), N_("FILE"), ARG_TYPE_STRING},
|
||||
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
|
||||
ARG_TYPE_STRING},
|
||||
{"keep-going", 'k', 0, "Don't stop after first error.", 0, 0},
|
||||
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -57,7 +58,7 @@ static grub_err_t
|
|||
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
grub_uint8_t context[hash->contextsize];
|
||||
char *readbuf[4096];
|
||||
grub_uint8_t readbuf[4096];
|
||||
|
||||
grub_memset (context, 0, sizeof (context));
|
||||
hash->init (context);
|
||||
|
@ -249,21 +250,21 @@ GRUB_MOD_INIT(hashsum)
|
|||
options);
|
||||
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"md5sum [-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]",
|
||||
"Compute or check hash checksum.",
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"sha256sum [-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]",
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
"Compute or check hash checksum.",
|
||||
options);
|
||||
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"sha512sum [-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]",
|
||||
"Compute or check hash checksum.",
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
||||
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
||||
else
|
||||
grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary),
|
||||
grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary),
|
||||
_(cmd->description));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,7 +403,6 @@ GRUB_MOD_INIT (drivemap)
|
|||
grub_get_root_biosnumber = grub_get_root_biosnumber_drivemap;
|
||||
cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"drivemap"
|
||||
N_("-l | -r | [-s] grubdev osdisk."),
|
||||
N_("Manage the BIOS drive mappings."),
|
||||
options);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#define INT13H_OFFSET(x) ((x) - EXT_C(grub_drivemap_handler))
|
||||
#define INT13H_OFFSET(x) ((x) - LOCAL (base))
|
||||
|
||||
.code16
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
|||
|
||||
/* The replacement int13 handler. Preserve all registers. */
|
||||
FUNCTION(grub_drivemap_handler)
|
||||
LOCAL (base):
|
||||
/* Save %dx for future restore. */
|
||||
push %dx
|
||||
/* Push flags. Used to simulate interrupt with original flags. */
|
||||
|
@ -35,12 +36,7 @@ FUNCTION(grub_drivemap_handler)
|
|||
/* Map the drive number (always in DL). */
|
||||
push %ax
|
||||
push %bx
|
||||
#ifdef APPLE_CC
|
||||
grub_drivemap_mapstart_ofs = INT13H_OFFSET(EXT_C(grub_drivemap_mapstart))
|
||||
movw $grub_drivemap_mapstart_ofs, %bx
|
||||
#else
|
||||
movw $INT13H_OFFSET(EXT_C(grub_drivemap_mapstart)), %bx
|
||||
#endif
|
||||
movw $INT13H_OFFSET(LOCAL (mapstart)), %bx
|
||||
|
||||
more_remaining:
|
||||
movw %cs:(%bx), %ax
|
||||
|
@ -66,12 +62,7 @@ not_found:
|
|||
popf
|
||||
pushf
|
||||
|
||||
#ifdef APPLE_CC
|
||||
grub_drivemap_oldhandler_ofs = INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
||||
lcall *%cs:grub_drivemap_oldhandler_ofs
|
||||
#else
|
||||
lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
||||
#endif
|
||||
lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
|
||||
|
||||
push %bp
|
||||
mov %sp, %bp
|
||||
|
@ -94,11 +85,7 @@ norestore:
|
|||
popf
|
||||
pushf
|
||||
|
||||
#ifdef APPLE_CC
|
||||
lcall *%cs:grub_drivemap_oldhandler_ofs
|
||||
#else
|
||||
lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
||||
#endif
|
||||
lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
|
||||
|
||||
push %bp
|
||||
mov %sp, %bp
|
||||
|
@ -111,9 +98,13 @@ norestore:
|
|||
/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
|
||||
IVT entries (thus PI:SC in mem). */
|
||||
VARIABLE(grub_drivemap_oldhandler)
|
||||
LOCAL (oldhandler):
|
||||
.word 0x0, 0x0
|
||||
|
||||
/* This label MUST be at the end of the copied block, since the installer code
|
||||
reserves additional space for mappings at runtime and copies them over it. */
|
||||
.align 2
|
||||
.align 2
|
||||
|
||||
VARIABLE(grub_drivemap_mapstart)
|
||||
LOCAL (mapstart):
|
||||
.byte 0
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#define BASE_TEMPO 120
|
||||
#define BASE_TEMPO (60 * GRUB_TICKS_PER_SECOND)
|
||||
|
||||
/* The speaker port. */
|
||||
#define SPEAKER 0x61
|
||||
|
@ -101,13 +101,13 @@
|
|||
#define PIT_CTRL_COUNT_BINARY 0x00 /* 16-bit binary counter. */
|
||||
#define PIT_CTRL_COUNT_BCD 0x01 /* 4-decade BCD counter. */
|
||||
|
||||
#define T_REST ((short) 0)
|
||||
#define T_FINE ((short) -1)
|
||||
#define T_REST ((grub_uint16_t) 0)
|
||||
#define T_FINE ((grub_uint16_t) -1)
|
||||
|
||||
struct note
|
||||
{
|
||||
short pitch;
|
||||
short duration;
|
||||
grub_uint16_t pitch;
|
||||
grub_uint16_t duration;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -120,7 +120,7 @@ beep_off (void)
|
|||
}
|
||||
|
||||
static void
|
||||
beep_on (short pitch)
|
||||
beep_on (grub_uint16_t pitch)
|
||||
{
|
||||
unsigned char status;
|
||||
unsigned int counter;
|
||||
|
@ -143,60 +143,115 @@ beep_on (short pitch)
|
|||
grub_outb (status | SPEAKER_TMR2 | SPEAKER_DATA, SPEAKER);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
/* Returns whether playing should continue. */
|
||||
static int
|
||||
play (unsigned tempo, struct note *note)
|
||||
{
|
||||
grub_file_t file;
|
||||
struct note buf;
|
||||
int tempo;
|
||||
unsigned int to;
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
if (note->pitch == T_FINE || grub_checkkey () >= 0)
|
||||
return 1;
|
||||
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
grub_dprintf ("play", "pitch = %d, duration = %d\n", note->pitch,
|
||||
note->duration);
|
||||
|
||||
if (grub_file_read (file, &tempo, sizeof(tempo)) != sizeof(tempo))
|
||||
{
|
||||
grub_file_close (file);
|
||||
return grub_error (GRUB_ERR_FILE_READ_ERROR,
|
||||
"file doesn't even contains a full tempo record");
|
||||
}
|
||||
|
||||
grub_dprintf ("play","tempo = %d\n", tempo);
|
||||
|
||||
while (grub_file_read (file, &buf,
|
||||
sizeof (struct note)) == sizeof (struct note)
|
||||
&& buf.pitch != T_FINE && grub_checkkey () < 0)
|
||||
{
|
||||
|
||||
grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch,
|
||||
buf.duration);
|
||||
|
||||
switch (buf.pitch)
|
||||
switch (note->pitch)
|
||||
{
|
||||
case T_REST:
|
||||
beep_off ();
|
||||
break;
|
||||
|
||||
default:
|
||||
beep_on (buf.pitch);
|
||||
beep_on (note->pitch);
|
||||
break;
|
||||
}
|
||||
|
||||
to = grub_get_rtc () + BASE_TEMPO * buf.duration / tempo;
|
||||
to = grub_get_rtc () + BASE_TEMPO * note->duration / tempo;
|
||||
while (((unsigned int) grub_get_rtc () <= to) && (grub_checkkey () < 0))
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name or tempo and notes required");
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
struct note buf;
|
||||
grub_uint32_t tempo;
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (args[0]);
|
||||
|
||||
if (! file)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
|
||||
if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
|
||||
{
|
||||
grub_file_close (file);
|
||||
return grub_error (GRUB_ERR_FILE_READ_ERROR,
|
||||
"file doesn't even contains a full tempo record");
|
||||
}
|
||||
|
||||
tempo = grub_le_to_cpu32 (tempo);
|
||||
grub_dprintf ("play","tempo = %d\n", tempo);
|
||||
|
||||
while (grub_file_read (file, &buf,
|
||||
sizeof (struct note)) == sizeof (struct note))
|
||||
{
|
||||
buf.pitch = grub_le_to_cpu16 (buf.pitch);
|
||||
buf.duration = grub_le_to_cpu16 (buf.duration);
|
||||
|
||||
if (play (tempo, &buf))
|
||||
break;
|
||||
}
|
||||
|
||||
grub_file_close (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *end;
|
||||
unsigned tempo;
|
||||
struct note note;
|
||||
int i;
|
||||
|
||||
tempo = grub_strtoul (args[0], &end, 0);
|
||||
|
||||
if (*end)
|
||||
/* Was not a number either, assume it was supposed to be a file name. */
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
|
||||
|
||||
grub_dprintf ("play","tempo = %d\n", tempo);
|
||||
|
||||
for (i = 1; i + 1 < argc; i += 2)
|
||||
{
|
||||
note.pitch = grub_strtoul (args[i], &end, 0);
|
||||
if (*end)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_NUMBER, "bogus pitch number");
|
||||
break;
|
||||
}
|
||||
|
||||
note.duration = grub_strtoul (args[i + 1], &end, 0);
|
||||
if (*end)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_NUMBER, "bogus duration number");
|
||||
break;
|
||||
}
|
||||
|
||||
if (play (tempo, ¬e))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
beep_off ();
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
while (grub_checkkey () > 0)
|
||||
grub_getkey ();
|
||||
|
||||
|
@ -208,7 +263,8 @@ static grub_command_t cmd;
|
|||
GRUB_MOD_INIT(play)
|
||||
{
|
||||
cmd = grub_register_command ("play", grub_cmd_play,
|
||||
N_("FILE"), N_("Play a tune."));
|
||||
N_("FILE | TEMPO [PITCH1 DURATION1] [PITCH2 DURATION2] ... "),
|
||||
N_("Play a tune."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(play)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <grub/term.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/vbe.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
|
|
150
commands/iorw.c
Normal file
150
commands/iorw.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
/* memrw.c - command to read / write physical memory */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 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/extcmd.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword;
|
||||
static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword;
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
{0, 'v', 0, N_("Save read value into variable VARNAME."),
|
||||
N_("VARNAME"), ARG_TYPE_STRING},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
|
||||
{
|
||||
grub_target_addr_t addr;
|
||||
grub_uint32_t value = 0;
|
||||
char buf[sizeof ("XXXXXXXX")];
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||
|
||||
addr = grub_strtoul (argv[0], 0, 0);
|
||||
switch (cmd->cmd->name[sizeof ("in") - 1])
|
||||
{
|
||||
case 'l':
|
||||
value = grub_inl (addr);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
value = grub_inw (addr);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
value = grub_inb (addr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd->state[0].set)
|
||||
{
|
||||
grub_snprintf (buf, sizeof (buf), "%x", value);
|
||||
grub_env_set (cmd->state[0].arg, buf);
|
||||
}
|
||||
else
|
||||
grub_printf ("0x%x\n", value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_write (grub_command_t cmd, int argc, char **argv)
|
||||
{
|
||||
grub_target_addr_t addr;
|
||||
grub_uint32_t value;
|
||||
grub_uint32_t mask = 0xffffffff;
|
||||
|
||||
if (argc != 2 && argc != 3)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||
|
||||
addr = grub_strtoul (argv[0], 0, 0);
|
||||
value = grub_strtoul (argv[1], 0, 0);
|
||||
if (argc == 3)
|
||||
mask = grub_strtoul (argv[2], 0, 0);
|
||||
value &= mask;
|
||||
switch (cmd->name[sizeof ("out") - 1])
|
||||
{
|
||||
case 'l':
|
||||
if (mask != 0xffffffff)
|
||||
grub_outl ((grub_inl (addr) & ~mask) | value, addr);
|
||||
else
|
||||
grub_outl (value, addr);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if ((mask & 0xffff) != 0xffff)
|
||||
grub_outw ((grub_inw (addr) & ~mask) | value, addr);
|
||||
else
|
||||
grub_outw (value, addr);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
if ((mask & 0xff) != 0xff)
|
||||
grub_outb ((grub_inb (addr) & ~mask) | value, addr);
|
||||
else
|
||||
grub_outb (value, addr);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT(memrw)
|
||||
{
|
||||
cmd_read_byte =
|
||||
grub_register_extcmd ("inb", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||
N_("PORT"), N_("Read byte from PORT."), options);
|
||||
cmd_read_word =
|
||||
grub_register_extcmd ("inw", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||
N_("PORT"), N_("Read word from PORT."), options);
|
||||
cmd_read_dword =
|
||||
grub_register_extcmd ("inl", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||
N_("PORT"), N_("Read dword from PORT."), options);
|
||||
cmd_write_byte =
|
||||
grub_register_command ("outb", grub_cmd_write,
|
||||
N_("PORT VALUE [MASK]"),
|
||||
N_("Write byte VALUE to PORT."));
|
||||
cmd_write_word =
|
||||
grub_register_command ("outw", grub_cmd_write,
|
||||
N_("PORT VALUE [MASK]"),
|
||||
N_("Write word VALUE to PORT."));
|
||||
cmd_write_dword =
|
||||
grub_register_command ("outl", grub_cmd_write,
|
||||
N_("ADDR VALUE [MASK]"),
|
||||
N_("Write dword VALUE to PORT."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(memrw)
|
||||
{
|
||||
grub_unregister_extcmd (cmd_read_byte);
|
||||
grub_unregister_extcmd (cmd_read_word);
|
||||
grub_unregister_extcmd (cmd_read_dword);
|
||||
grub_unregister_command (cmd_write_byte);
|
||||
grub_unregister_command (cmd_write_word);
|
||||
grub_unregister_command (cmd_write_dword);
|
||||
}
|
|
@ -235,10 +235,8 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
/* One more sanity check. Re-read all sectors by blocklists, and compare
|
||||
those with the data read via a file. */
|
||||
disk = file->device->disk;
|
||||
if (disk->partition)
|
||||
|
||||
part_start = grub_partition_get_start (disk->partition);
|
||||
else
|
||||
part_start = 0;
|
||||
|
||||
buf = grub_envblk_buffer (envblk);
|
||||
for (p = blocklists, index = 0; p; index += p->length, p = p->next)
|
||||
|
@ -268,10 +266,7 @@ write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
|
||||
buf = grub_envblk_buffer (envblk);
|
||||
disk = file->device->disk;
|
||||
if (disk->partition)
|
||||
part_start = grub_partition_get_start (disk->partition);
|
||||
else
|
||||
part_start = 0;
|
||||
|
||||
index = 0;
|
||||
for (p = blocklists; p; index += p->length, p = p->next)
|
||||
|
|
|
@ -87,14 +87,13 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
int print_files_long (const char *filename,
|
||||
const struct grub_dirhook_info *info)
|
||||
{
|
||||
char *pathname;
|
||||
|
||||
if ((! all) && (filename[0] == '.'))
|
||||
return 0;
|
||||
|
||||
if (! info->dir)
|
||||
{
|
||||
grub_file_t file;
|
||||
char *pathname;
|
||||
|
||||
if (dirname[grub_strlen (dirname) - 1] == '/')
|
||||
pathname = grub_xasprintf ("%s%s", dirname, filename);
|
||||
|
@ -110,6 +109,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
if (! file)
|
||||
{
|
||||
grub_errno = 0;
|
||||
grub_free (pathname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
|
||||
}
|
||||
grub_file_close (file);
|
||||
grub_free (pathname);
|
||||
}
|
||||
else
|
||||
grub_printf ("%-12s", "DIR");
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
#include <grub/machine/memory.h>
|
||||
#endif
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
|
@ -34,7 +36,9 @@ grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
|
|||
(long long) addr, (long long) size, type);
|
||||
return 0;
|
||||
}
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
grub_machine_mmap_iterate (hook);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,6 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
|
|||
grub_printf ("%s", dep->mod->name);
|
||||
}
|
||||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
/* Load modules. */
|
||||
#ifndef GRUB_UTIL
|
||||
#if !GRUB_NO_MODULES
|
||||
{
|
||||
const char *prefix;
|
||||
prefix = grub_env_get ("prefix");
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
|
||||
|
@ -186,8 +187,8 @@ GRUB_MOD_INIT(password_pbkdf2)
|
|||
{
|
||||
my_mod = mod;
|
||||
cmd = grub_register_command ("password_pbkdf2", grub_cmd_password,
|
||||
"password_pbkdf2 USER PBKDF2_PASSWORD",
|
||||
"Set user password (PBKDF2). ");
|
||||
N_("USER PBKDF2_PASSWORD"),
|
||||
N_("Set user password (PBKDF2). "));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(password_pbkdf2)
|
||||
|
|
80
commands/regexp.c
Normal file
80
commands/regexp.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* regexp.c -- The regexp command. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <regex.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_regexp (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
int argn = 0;
|
||||
int matches = 0;
|
||||
regex_t regex;
|
||||
int ret;
|
||||
grub_size_t s;
|
||||
char *comperr;
|
||||
grub_err_t err;
|
||||
|
||||
if (argc != 2)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "2 arguments expected");
|
||||
|
||||
ret = regcomp (®ex, args[0], RE_SYNTAX_GNU_AWK);
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
ret = regexec (®ex, args[1], 0, 0, 0);
|
||||
if (!ret)
|
||||
{
|
||||
regfree (®ex);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
fail:
|
||||
s = regerror (ret, ®ex, 0, 0);
|
||||
comperr = grub_malloc (s);
|
||||
if (!comperr)
|
||||
{
|
||||
regfree (®ex);
|
||||
return grub_errno;
|
||||
}
|
||||
regerror (ret, ®ex, comperr, s);
|
||||
err = grub_error (GRUB_ERR_TEST_FAILURE, "%s", comperr);
|
||||
regfree (®ex);
|
||||
grub_free (comperr);
|
||||
return err;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(regexp)
|
||||
{
|
||||
cmd = grub_register_command ("regexp", grub_cmd_regexp,
|
||||
N_("REGEXP STRING"),
|
||||
N_("Test if REGEXP matches STRING."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(regexp)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
|
@ -149,11 +149,11 @@ grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
|
|||
static grub_command_t cmd;
|
||||
|
||||
#ifdef DO_SEARCH_FILE
|
||||
GRUB_MOD_INIT(search_file)
|
||||
GRUB_MOD_INIT(search_fs_file)
|
||||
#elif defined (DO_SEARCH_FS_UUID)
|
||||
GRUB_MOD_INIT(search_fs_uuid)
|
||||
#else
|
||||
GRUB_MOD_INIT(search_fs_label)
|
||||
GRUB_MOD_INIT(search_label)
|
||||
#endif
|
||||
{
|
||||
cmd =
|
||||
|
@ -163,11 +163,11 @@ GRUB_MOD_INIT(search_fs_label)
|
|||
}
|
||||
|
||||
#ifdef DO_SEARCH_FILE
|
||||
GRUB_MOD_FINI(search_file)
|
||||
GRUB_MOD_FINI(search_fs_file)
|
||||
#elif defined (DO_SEARCH_FS_UUID)
|
||||
GRUB_MOD_FINI(search_fs_uuid)
|
||||
#else
|
||||
GRUB_MOD_FINI(search_fs_label)
|
||||
GRUB_MOD_FINI(search_label)
|
||||
#endif
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/extcmd.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
struct pci_register
|
||||
{
|
||||
|
@ -329,9 +330,9 @@ static grub_extcmd_t cmd;
|
|||
GRUB_MOD_INIT(setpci)
|
||||
{
|
||||
cmd = grub_register_extcmd ("setpci", grub_cmd_setpci, GRUB_COMMAND_FLAG_BOTH,
|
||||
"setpci [-s POSITION] [-d DEVICE] [-v VAR] "
|
||||
"[REGISTER][=VALUE[:MASK]]",
|
||||
"Manipulate PCI devices.", options);
|
||||
N_("[-s POSITION] [-d DEVICE] [-v VAR] "
|
||||
"[REGISTER][=VALUE[:MASK]]"),
|
||||
N_("Manipulate PCI devices."), options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(setpci)
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/time.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
|
|
|
@ -26,32 +26,43 @@
|
|||
struct grub_term_autoload *grub_term_input_autoload = NULL;
|
||||
struct grub_term_autoload *grub_term_output_autoload = NULL;
|
||||
|
||||
struct abstract_terminal
|
||||
{
|
||||
struct abstract_terminal *next;
|
||||
const char *name;
|
||||
grub_err_t (*init) (void);
|
||||
grub_err_t (*fini) (void);
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||
struct abstract_terminal **disabled,
|
||||
struct grub_term_autoload *autoloads,
|
||||
const char *active_str,
|
||||
const char *available_str)
|
||||
{
|
||||
int i;
|
||||
grub_term_input_t term;
|
||||
struct abstract_terminal *term;
|
||||
struct grub_term_autoload *aut;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_puts_ (N_ ("Active input terminals:"));
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
grub_puts_ (active_str);
|
||||
for (term = *enabled; term; term = term->next)
|
||||
grub_printf ("%s ", term->name);
|
||||
grub_printf ("\n");
|
||||
grub_puts_ (N_ ("Available input terminals:"));
|
||||
FOR_DISABLED_TERM_INPUTS(term)
|
||||
grub_puts_ (available_str);
|
||||
for (term = *disabled; term; term = term->next)
|
||||
grub_printf ("%s ", term->name);
|
||||
/* This is quadratic but we don't expect mode than 30 terminal
|
||||
modules ever. */
|
||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
||||
for (aut = autoloads; aut; aut = aut->next)
|
||||
{
|
||||
FOR_DISABLED_TERM_INPUTS(term)
|
||||
for (term = *disabled; term; term = term->next)
|
||||
if (grub_strcmp (term->name, aut->name) == 0)
|
||||
break;
|
||||
if (!term)
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
for (term = *enabled; term; term = term->next)
|
||||
if (grub_strcmp (term->name, aut->name) == 0)
|
||||
break;
|
||||
if (!term)
|
||||
|
@ -74,11 +85,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
int again = 0;
|
||||
while (1)
|
||||
{
|
||||
FOR_DISABLED_TERM_INPUTS(term)
|
||||
for (term = *disabled; term; term = term->next)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term == 0)
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
for (term = *enabled; term; term = term->next)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
|
@ -86,7 +97,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (again)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
||||
args[i]);
|
||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
||||
for (aut = autoloads; aut; aut = aut->next)
|
||||
if (grub_strcmp (args[i], aut->name) == 0)
|
||||
{
|
||||
grub_dl_t mod;
|
||||
|
@ -107,7 +118,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
FOR_DISABLED_TERM_INPUTS(term)
|
||||
for (term = *disabled; term; term = term->next)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
|
@ -115,10 +126,8 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -128,27 +137,25 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
for (term = *enabled; term; term = term->next)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
{
|
||||
if (!term->next && term == grub_term_inputs)
|
||||
if (!term->next && term == *enabled)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
FOR_DISABLED_TERM_INPUTS(term)
|
||||
for (term = *disabled; term; term = term->next)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
|
@ -156,193 +163,64 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
struct abstract_terminal *next;
|
||||
for (term = *enabled; term; term = next)
|
||||
{
|
||||
next = term->next;
|
||||
for (i = 0; i < argc; i++)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (i == argc)
|
||||
{
|
||||
if (!term->next && term == grub_term_inputs)
|
||||
if (!term->next && term == *enabled)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
|
||||
return handle_command (argc, args,
|
||||
(struct abstract_terminal **) &grub_term_inputs,
|
||||
(struct abstract_terminal **) &grub_term_inputs_disabled,
|
||||
grub_term_input_autoload,
|
||||
N_ ("Active input terminals:"),
|
||||
N_ ("Available input terminals:"));
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
grub_term_output_t term;
|
||||
struct grub_term_autoload *aut;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_puts_ (N_ ("Active output terminals:"));
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
grub_printf ("%s ", term->name);
|
||||
grub_printf ("\n");
|
||||
grub_puts_ (N_ ("Available output terminals:"));
|
||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
||||
grub_printf ("%s ", term->name);
|
||||
/* This is quadratic but we don't expect mode than 30 terminal
|
||||
modules ever. */
|
||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
||||
{
|
||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (term->name, aut->name) == 0)
|
||||
break;
|
||||
if (!term)
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (term->name, aut->name) == 0)
|
||||
break;
|
||||
if (!term)
|
||||
grub_printf ("%s ", aut->name);
|
||||
}
|
||||
grub_printf ("\n");
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
i = 0;
|
||||
|
||||
if (grub_strcmp (args[0], "--append") == 0
|
||||
|| grub_strcmp (args[0], "--remove") == 0)
|
||||
i++;
|
||||
|
||||
if (i == argc)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified"));
|
||||
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
int again = 0;
|
||||
while (1)
|
||||
{
|
||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term == 0)
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
break;
|
||||
if (again)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
||||
args[i]);
|
||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
||||
if (grub_strcmp (args[i], aut->name) == 0)
|
||||
{
|
||||
grub_dl_t mod;
|
||||
mod = grub_dl_load (aut->modname);
|
||||
if (mod)
|
||||
grub_dl_ref (mod);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
break;
|
||||
}
|
||||
if (!aut)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
||||
args[i]);
|
||||
again = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (grub_strcmp (args[0], "--append") == 0)
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
if (grub_strcmp (args[0], "--remove") == 0)
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
{
|
||||
if (!term->next && term == grub_term_outputs)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
if (grub_strcmp (args[i], term->name) == 0)
|
||||
break;
|
||||
if (i == argc)
|
||||
{
|
||||
if (!term->next && term == grub_term_outputs)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
|
||||
return handle_command (argc, args, (struct abstract_terminal **) &grub_term_outputs,
|
||||
(struct abstract_terminal **) &grub_term_outputs_disabled,
|
||||
grub_term_output_autoload,
|
||||
N_ ("Active output terminals:"),
|
||||
N_ ("Available output terminals:"));
|
||||
}
|
||||
|
||||
static grub_command_t cmd_terminal_input, cmd_terminal_output;
|
||||
|
@ -351,14 +229,14 @@ GRUB_MOD_INIT(terminal)
|
|||
{
|
||||
cmd_terminal_input =
|
||||
grub_register_command ("terminal_input", grub_cmd_terminal_input,
|
||||
"[--append|--remove] "
|
||||
"[TERMINAL1] [TERMINAL2] ...",
|
||||
"List or select an input terminal.");
|
||||
N_("[--append|--remove] "
|
||||
"[TERMINAL1] [TERMINAL2] ..."),
|
||||
N_("List or select an input terminal."));
|
||||
cmd_terminal_output =
|
||||
grub_register_command ("terminal_output", grub_cmd_terminal_output,
|
||||
"[--append|--remove] "
|
||||
"[TERMINAL1] [TERMINAL2] ...",
|
||||
"List or select an output terminal.");
|
||||
N_("[--append|--remove] "
|
||||
"[TERMINAL1] [TERMINAL2] ..."),
|
||||
N_("List or select an output terminal."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(terminal)
|
||||
|
|
|
@ -69,9 +69,9 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
color = grub_video_map_rgb (0, 255, 255);
|
||||
grub_video_fill_rect (color, 100, 100, 100, 100);
|
||||
|
||||
sansbig = grub_font_get ("Helvetica Bold 24");
|
||||
sans = grub_font_get ("Helvetica Bold 14");
|
||||
sanssmall = grub_font_get ("Helvetica 8");
|
||||
sansbig = grub_font_get ("Unknown Regular 16");
|
||||
sans = grub_font_get ("Unknown Regular 16");
|
||||
sanssmall = grub_font_get ("Unknown Regular 16");
|
||||
fixed = grub_font_get ("Fixed 20");
|
||||
if (! sansbig || ! sans || ! sanssmall || ! fixed)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
||||
|
@ -126,11 +126,6 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_font_draw_string (str, fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
/* Some character don't exist in the Helvetica font, so the font engine
|
||||
will fall back to using glyphs from another font that does contain them.
|
||||
TODO The font engine should be smart about selecting a replacement font
|
||||
and prioritize fonts with similar sizes. */
|
||||
|
||||
texty += grub_font_get_ascent(sansbig);
|
||||
grub_font_draw_string (str, sansbig, color, 16, texty);
|
||||
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
|
||||
|
|
163
conf/any-emu.rmk
163
conf/any-emu.rmk
|
@ -1,103 +1,114 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
|
||||
|
||||
sbin_UTILITIES += grub-emu
|
||||
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
|
||||
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
|
||||
commands/configfile.c commands/echo.c commands/help.c \
|
||||
commands/handler.c commands/ls.c commands/test.c \
|
||||
commands/search_wrap.c commands/search_file.c \
|
||||
commands/search_label.c commands/search_uuid.c \
|
||||
commands/blocklist.c commands/hexdump.c \
|
||||
lib/hexdump.c commands/halt.c commands/reboot.c \
|
||||
lib/envblk.c commands/loadenv.c \
|
||||
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
|
||||
commands/password.c commands/keystatus.c \
|
||||
disk/host.c disk/loopback.c disk/scsi.c \
|
||||
fs/fshelp.c \
|
||||
\
|
||||
io/gzio.c \
|
||||
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
|
||||
kern/err.c kern/list.c kern/handler.c \
|
||||
kern/command.c kern/corecmd.c commands/extcmd.c kern/file.c \
|
||||
kern/fs.c commands/boot.c kern/main.c kern/misc.c kern/parser.c \
|
||||
kern/partition.c kern/term.c \
|
||||
kernel_img_RELOCATABLE = yes
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||
kern/err.c kern/list.c kern/handler.c kern/command.c \
|
||||
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
||||
kern/parser.c kern/partition.c kern/term.c \
|
||||
kern/rescue_reader.c kern/rescue_parser.c \
|
||||
lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \
|
||||
normal/handler.c normal/auth.c lib/crypto.c normal/autofs.c \
|
||||
normal/completion.c normal/main.c normal/color.c \
|
||||
normal/menu.c normal/menu_entry.c \
|
||||
normal/menu_text.c normal/crypto.c normal/term.c \
|
||||
commands/terminal.c normal/context.c lib/charset.c \
|
||||
script/main.c script/execute.c script/function.c \
|
||||
script/lexer.c script/script.c grub_script.tab.c \
|
||||
partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \
|
||||
partmap/acorn.c partmap/gpt.c \
|
||||
\
|
||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
kern/emu/main.c kern/emu/mm.c kern/emu/misc.c \
|
||||
kern/emu/getroot.c kern/emu/time.c kern/emu/hostdisk.c \
|
||||
kern/emu/hostfs.c kern/emu/console.c \
|
||||
\
|
||||
util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
|
||||
util/hostdisk.c util/getroot.c \
|
||||
\
|
||||
disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \
|
||||
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
||||
commands/parttool.c parttool/msdospart.c \
|
||||
lib/libgcrypt-grub/cipher/md5.c \
|
||||
grub_emu_init.c gnulib/progname.c
|
||||
grub_emu_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap
|
||||
gnulib/progname.c disk/host.c
|
||||
kernel_img_HEADERS += datetime.h emu/misc.h
|
||||
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-char-subscripts -Wno-unused -Wno-deprecated-declarations -Wno-undef -I$(srcdir)/gnulib
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
TARGET_NO_STRIP = yes
|
||||
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
kernel_img_SOURCES += symlist.c kern/$(target_cpu)/dl.c
|
||||
ifneq ($(target_cpu), i386)
|
||||
ifneq ($(target_cpu), x86_64)
|
||||
kernel_img_SOURCES += kern/$(target_cpu)/cache.S
|
||||
endif
|
||||
endif
|
||||
else
|
||||
kernel_img_SOURCES += grub_emu_init.c
|
||||
endif
|
||||
|
||||
# For halt.mod.
|
||||
pkglib_MODULES += halt.mod
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
ifeq ($(target_cpu), i386)
|
||||
grub_emu_SOURCES += commands/i386/cpuid.c
|
||||
pkglib_MODULES += cpuid.mod
|
||||
cpuid_mod_SOURCES = commands/i386/cpuid.c
|
||||
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
endif
|
||||
|
||||
grub_emu_LDFLAGS = $(LIBCURSES)
|
||||
|
||||
ifeq ($(enable_grub_emu_usb), yes)
|
||||
grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
|
||||
commands/usbtest.c
|
||||
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
|
||||
kernel_img_HEADERS += libusb.h
|
||||
|
||||
pkglib_MODULES += libusb.mod
|
||||
libusb_mod_SOURCES = bus/usb/emu/usb.c
|
||||
libusb_mod_CFLAGS =
|
||||
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For usb.mod
|
||||
pkglib_MODULES += usb.mod
|
||||
usb_mod_SOURCES = bus/usb/usb.c
|
||||
usb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For usbtest.mod
|
||||
pkglib_MODULES += usbtest.mod
|
||||
usbtest_mod_SOURCES = commands/usbtest.c
|
||||
usbtest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
usbtest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For usbms.mod
|
||||
pkglib_MODULES += usbms.mod
|
||||
usbms_mod_SOURCES = disk/usbms.c
|
||||
usbms_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
usbms_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
grub_emu_LDFLAGS += $(LIBUSB)
|
||||
endif
|
||||
|
||||
ifeq ($(enable_grub_emu_sdl), yes)
|
||||
pkglib_MODULES += sdl.mod
|
||||
sdl_mod_SOURCES = video/emu/sdl.c
|
||||
sdl_mod_CFLAGS =
|
||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
grub_emu_LDFLAGS += $(LIBSDL)
|
||||
kernel_img_HEADERS += sdl.h
|
||||
endif
|
||||
|
||||
ifeq ($(enable_grub_emu_pci), yes)
|
||||
grub_emu_SOURCES += util/pci.c commands/lspci.c
|
||||
pkglib_MODULES += pci.mod
|
||||
pci_mod_SOURCES = bus/emu/pci.c commands/lspci.c
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||
kernel_img_HEADERS += libpciaccess.h
|
||||
endif
|
||||
|
||||
grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
|
||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
||||
DISTCLEANFILES += grub_emu_init.lst
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
||||
grub_emu_init.h: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninitheader.sh
|
||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
||||
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
|
||||
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
|
||||
DISTCLEANFILES += grub_emu_init.h
|
||||
|
||||
grub_emu_init.c: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninit.sh grub_emu_init.h
|
||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
||||
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES) grub_emu_init.h
|
||||
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
|
||||
DISTCLEANFILES += grub_emu_init.c
|
||||
|
||||
|
||||
|
||||
|
||||
# FIXME: this could be shared with common.rmk
|
||||
|
||||
# For grub-mkfont.
|
||||
ifeq ($(enable_grub_mkfont), yes)
|
||||
bin_UTILITIES += grub-mkfont
|
||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
||||
CLEANFILES += grub-emu
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
grub-emu: $(pkglib_PROGRAMS)
|
||||
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||
else
|
||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
||||
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||
endif
|
||||
GRUB_EMU=grub-emu
|
||||
|
||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
||||
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
|
||||
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
|
||||
|
||||
bin_UTILITIES += grub-bin2h
|
||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||
|
|
243
conf/common.rmk
243
conf/common.rmk
|
@ -1,10 +1,13 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
|
||||
sbin_UTILITIES += grub-mkdevicemap
|
||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||
util/deviceiter.c \
|
||||
util/misc.c \
|
||||
kern/env.c kern/err.c kern/list.c kern/misc.c
|
||||
util/misc.c kern/emu/misc.c \
|
||||
kern/env.c kern/err.c kern/list.c kern/misc.c kern/emu/mm.c
|
||||
|
||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
||||
|
@ -14,26 +17,26 @@ endif
|
|||
|
||||
# For grub-mkelfimage.
|
||||
bin_UTILITIES += grub-mkelfimage
|
||||
grub_mkelfimage_SOURCES = gnulib/progname.c \
|
||||
util/elf/grub-mkimage.c util/misc.c \
|
||||
util/resolve.c
|
||||
grub_mkelfimage_SOURCES = gnulib/progname.c util/elf/grub-mkimage.c \
|
||||
util/misc.c kern/emu/misc.c util/resolve.c
|
||||
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
# For grub-probe.
|
||||
sbin_UTILITIES += grub-probe
|
||||
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||
util/hostdisk.c util/misc.c util/getroot.c \
|
||||
kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c \
|
||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||
kern/parser.c kern/partition.c kern/file.c \
|
||||
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
||||
\
|
||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
\
|
||||
partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\
|
||||
partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \
|
||||
partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
||||
kern/fs.c kern/env.c fs/fshelp.c \
|
||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c
|
||||
|
||||
|
@ -53,12 +56,12 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
|
|||
gnulib/error.c gnulib/progname.c
|
||||
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||
-I$(srcdir)/util/mkisofs/include \
|
||||
-Wno-all -Werror
|
||||
-Wno-all -Werror $(GNULIB_UTIL_CFLAGS)
|
||||
|
||||
# For grub-fstest.
|
||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
||||
util/misc.c \
|
||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \
|
||||
util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
||||
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
||||
|
@ -66,12 +69,12 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
|||
\
|
||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
|
||||
fs/befs_be.c fs/tar.c \
|
||||
\
|
||||
kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \
|
||||
partmap/gpt.c \
|
||||
kern/partition.c partmap/msdos.c partmap/bsdlabel.c \
|
||||
partmap/apple.c partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
||||
kern/fs.c kern/env.c fs/fshelp.c disk/raid.c \
|
||||
disk/raid5_recover.c disk/raid6_recover.c \
|
||||
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
||||
|
@ -80,25 +83,50 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
|||
# For grub-mkfont.
|
||||
ifeq ($(enable_grub_mkfont), yes)
|
||||
bin_UTILITIES += grub-mkfont
|
||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c
|
||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
||||
endif
|
||||
|
||||
# For grub-mkrelpath.
|
||||
bin_UTILITIES += grub-mkrelpath
|
||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c kern/emu/misc.c
|
||||
|
||||
bin_UTILITIES += grub-bin2h
|
||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||
|
||||
# For the lexer.
|
||||
grub_script.yy.c grub_script.yy.h: script/yylex.l
|
||||
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $(srcdir)/script/yylex.l
|
||||
DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||
|
||||
# For grub-script-check.
|
||||
bin_UTILITIES += grub-script-check
|
||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||
grub_script_check_SOURCES = gnulib/progname.c util/grub-script-check.c util/misc.c \
|
||||
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
||||
util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||
script/main.c script/script.c script/function.c script/lexer.c \
|
||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c
|
||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||
grub_script.yy.c
|
||||
grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS)
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
list.h handler.h command.h i18n.h env_private.h libgcc.h
|
||||
|
||||
ifneq ($(platform), emu)
|
||||
kernel_img_HEADERS += machine/memory.h machine/loader.h machine/kernel.h
|
||||
endif
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# For the parser.
|
||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
||||
|
@ -159,7 +187,7 @@ DISTCLEANFILES += grub_fstest_init.c
|
|||
|
||||
# for grub-editenv
|
||||
bin_UTILITIES += grub-editenv
|
||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/misc.c kern/err.c
|
||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/misc.c kern/err.c
|
||||
CLEANFILES += grub-editenv
|
||||
|
||||
# Needed for genmk.rb to work
|
||||
|
@ -167,7 +195,7 @@ ifeq (0,1)
|
|||
bin_UTILITIES += grub-macho2img grub-pe2elf
|
||||
endif
|
||||
|
||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c
|
||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c kern/emu/misc.c
|
||||
CLEANFILES += grub-pe2elf
|
||||
|
||||
grub_macho2img_SOURCES = util/grub-macho2img.c
|
||||
|
@ -270,6 +298,12 @@ minix_mod_SOURCES = fs/minix.c
|
|||
minix_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
minix_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For nilfs2.mod.
|
||||
pkglib_MODULES += nilfs2.mod
|
||||
nilfs2_mod_SOURCES = fs/nilfs2.c
|
||||
nilfs2_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
nilfs2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For hfs.mod.
|
||||
hfs_mod_SOURCES = fs/hfs.c
|
||||
hfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -377,6 +411,16 @@ part_gpt_mod_SOURCES = partmap/gpt.c
|
|||
part_gpt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
part_gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += part_bsd.mod
|
||||
part_bsd_mod_SOURCES = partmap/bsdlabel.c
|
||||
part_bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
part_bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += part_sunpc.mod
|
||||
part_sunpc_mod_SOURCES = partmap/sunpc.c
|
||||
part_sunpc_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
part_sunpc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# Special disk structures and generic drivers
|
||||
|
||||
pkglib_MODULES += raid.mod raid5rec.mod raid6rec.mod mdraid.mod dm_nv.mod \
|
||||
|
@ -452,6 +496,28 @@ hello_mod_SOURCES = hello/hello.c
|
|||
hello_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
hello_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For gfxmenu.mod.
|
||||
pkglib_MODULES += gfxmenu.mod
|
||||
gfxmenu_mod_SOURCES = \
|
||||
gfxmenu/gfxmenu.c \
|
||||
gfxmenu/model.c \
|
||||
gfxmenu/view.c \
|
||||
gfxmenu/icon_manager.c \
|
||||
gfxmenu/theme_loader.c \
|
||||
gfxmenu/widget-box.c \
|
||||
gfxmenu/gui_canvas.c \
|
||||
gfxmenu/gui_circular_progress.c \
|
||||
gfxmenu/gui_box.c \
|
||||
gfxmenu/gui_label.c \
|
||||
gfxmenu/gui_list.c \
|
||||
gfxmenu/gui_image.c \
|
||||
gfxmenu/gui_progress_bar.c \
|
||||
gfxmenu/gui_util.c \
|
||||
gfxmenu/gui_string_util.c \
|
||||
gfxmenu/named_colors.c
|
||||
gfxmenu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
gfxmenu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For parttool.mod.
|
||||
parttool_mod_SOURCES = commands/parttool.c
|
||||
parttool_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -595,64 +661,82 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|||
|
||||
# For sh.mod.
|
||||
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
|
||||
script/function.c script/lexer.c grub_script.tab.c
|
||||
sh_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
||||
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
|
||||
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
ifneq (, $(FONT_SOURCE))
|
||||
font/font.c_DEPENDENCIES = ascii.h
|
||||
endif
|
||||
|
||||
# Common Video Subsystem specific modules.
|
||||
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
|
||||
png.mod gfxterm.mod video_fb.mod
|
||||
# On Yeeloong it's part of kernel
|
||||
ifneq ($(platform), yeeloong)
|
||||
|
||||
# For video.mod.
|
||||
pkglib_MODULES += video.mod
|
||||
video_mod_SOURCES = video/video.c
|
||||
video_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
video_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += video_fb.mod
|
||||
video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \
|
||||
video/fb/fbfill.c video/fb/fbutil.c
|
||||
video_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For videotest.mod.
|
||||
videotest_mod_SOURCES = commands/videotest.c
|
||||
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For bitmap.mod
|
||||
pkglib_MODULES += bitmap.mod
|
||||
bitmap_mod_SOURCES = video/bitmap.c
|
||||
bitmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
bitmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For tga.mod
|
||||
tga_mod_SOURCES = video/readers/tga.c
|
||||
tga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For jpeg.mod.
|
||||
jpeg_mod_SOURCES = video/readers/jpeg.c
|
||||
jpeg_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
jpeg_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For png.mod.
|
||||
png_mod_SOURCES = video/readers/png.c
|
||||
png_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
png_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
# For bitmap_scale.mod
|
||||
pkglib_MODULES += bitmap_scale.mod
|
||||
bitmap_scale_mod_SOURCES = video/bitmap_scale.c
|
||||
bitmap_scale_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
bitmap_scale_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += font.mod
|
||||
ifneq (, $(FONT_SOURCE))
|
||||
font/font.c_DEPENDENCIES = ascii.h
|
||||
endif
|
||||
font_mod_SOURCES = font/font_cmd.c font/font.c
|
||||
font_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
font_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For gfxterm.mod.
|
||||
pkglib_MODULES += gfxterm.mod
|
||||
gfxterm_mod_SOURCES = term/gfxterm.c
|
||||
gfxterm_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
gfxterm_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
endif
|
||||
|
||||
# For videotest.mod.
|
||||
pkglib_MODULES += videotest.mod
|
||||
videotest_mod_SOURCES = commands/videotest.c
|
||||
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For tga.mod
|
||||
pkglib_MODULES += tga.mod
|
||||
tga_mod_SOURCES = video/readers/tga.c
|
||||
tga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For jpeg.mod.
|
||||
pkglib_MODULES += jpeg.mod
|
||||
jpeg_mod_SOURCES = video/readers/jpeg.c
|
||||
jpeg_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
jpeg_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For png.mod.
|
||||
pkglib_MODULES += png.mod
|
||||
png_mod_SOURCES = video/readers/png.c
|
||||
png_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
png_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
|
||||
# Misc.
|
||||
pkglib_MODULES += gzio.mod bufio.mod elf.mod
|
||||
pkglib_MODULES += gzio.mod elf.mod
|
||||
|
||||
# For elf.mod.
|
||||
elf_mod_SOURCES = kern/elf.c
|
||||
|
@ -664,10 +748,14 @@ gzio_mod_SOURCES = io/gzio.c
|
|||
gzio_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
gzio_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# On Yeeloong it's part of kernel
|
||||
ifneq ($(platform), yeeloong)
|
||||
# For bufio.mod.
|
||||
pkglib_MODULES += bufio.mod
|
||||
bufio_mod_SOURCES = io/bufio.c
|
||||
bufio_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
bufio_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
endif
|
||||
|
||||
# For gettext.mod.
|
||||
pkglib_MODULES += gettext.mod
|
||||
|
@ -683,6 +771,18 @@ xnu_uuid_mod_SOURCES = commands/xnu_uuid.c
|
|||
xnu_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += trig.mod
|
||||
trig_mod_SOURCES = trigtables.c
|
||||
trig_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
trig_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
trigtables.c: gentrigtables
|
||||
./gentrigtables > $@
|
||||
DISTCLEANFILES += trigtables.c
|
||||
gentrigtables: gentrigtables.c
|
||||
$(CC) -o $@ $^ $(CPPFLAGS) -lm
|
||||
DISTCLEANFILES += gentrigtables
|
||||
|
||||
pkglib_MODULES += setjmp.mod
|
||||
setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S
|
||||
setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
@ -693,6 +793,11 @@ charset_mod_SOURCES = lib/charset.c
|
|||
charset_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
charset_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += regexp.mod
|
||||
regexp_mod_SOURCES = gnulib/regex.c commands/regexp.c
|
||||
regexp_mod_CFLAGS = $(COMMON_CFLAGS) $(GNULIB_CFLAGS)
|
||||
regexp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += terminal.mod
|
||||
terminal_mod_SOURCES = commands/terminal.c
|
||||
terminal_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -719,8 +824,44 @@ password_pbkdf2_mod_SOURCES = commands/password_pbkdf2.c
|
|||
password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
pkglib_MODULES += memdisk.mod
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
pkglib_MODULES += reboot.mod
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
pkglib_MODULES += date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
pkglib_MODULES += datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
pkglib_MODULES += lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c
|
||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/err.c
|
||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
||||
|
||||
include $(srcdir)/conf/gcry.mk
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
||||
COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
|
||||
COMMON_LDFLAGS = -m32 -nostdlib
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||
|
||||
# Images.
|
||||
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||
|
||||
ifeq ($(platform), coreboot)
|
||||
|
||||
pkglib_PROGRAMS += kernel.img
|
||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/multiboot_mmap.c \
|
||||
kern/i386/coreboot/mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
|
@ -31,73 +24,9 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
|||
kern/env.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||
symlist.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
machine/boot.h machine/console.h machine/init.h \
|
||||
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
|
||||
env_private.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(platform), qemu)
|
||||
|
||||
GRUB_BOOT_MACHINE_LINK_ADDR = 0xffe00
|
||||
|
||||
pkglib_IMAGES += boot.img
|
||||
boot_img_SOURCES = boot/i386/qemu/boot.S
|
||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
boot_img_FORMAT = binary
|
||||
|
||||
bin_UTILITIES += grub-mkimage
|
||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
||||
util/resolve.c gnulib/progname.c
|
||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
|
||||
pkglib_IMAGES += kernel.img
|
||||
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
||||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/qemu/mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c \
|
||||
kern/env.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||
symlist.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
machine/boot.h machine/console.h machine/init.h \
|
||||
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
|
||||
env_private.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
kernel_img_FORMAT = binary
|
||||
endif
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
||||
|
||||
sbin_SCRIPTS += grub-install
|
||||
grub_install_SOURCES = util/grub-install.in
|
||||
|
@ -106,17 +35,7 @@ bin_SCRIPTS += grub-mkrescue
|
|||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = linux.mod \
|
||||
aout.mod play.mod serial.mod \
|
||||
memdisk.mod pci.mod lspci.mod reboot.mod \
|
||||
halt.mod datetime.mod date.mod datehook.mod \
|
||||
lsmmap.mod mmap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||
|
@ -129,21 +48,11 @@ linux_mod_SOURCES = loader/i386/linux.c
|
|||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For serial.mod.
|
||||
serial_mod_SOURCES = term/serial.c
|
||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For aout.mod.
|
||||
aout_mod_SOURCES = loader/aout.c
|
||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -156,45 +65,10 @@ bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For play.mod.
|
||||
play_mod_SOURCES = commands/i386/pc/play.c
|
||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -1,166 +1,5 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
||||
COMMON_CFLAGS = -fno-builtin -m32
|
||||
COMMON_LDFLAGS = -melf_i386 -nostdlib
|
||||
COMMON_LDFLAGS = -melf_i386
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
|
||||
# Utilities.
|
||||
bin_UTILITIES = grub-mkimage
|
||||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
||||
util/misc.c util/resolve.c
|
||||
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
# For grub-setup.
|
||||
#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
|
||||
# util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||
# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
|
||||
# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
|
||||
# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
|
||||
# kern/fs.c kern/env.c fs/fshelp.c
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
||||
# For grub-install.
|
||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
pkglib_MODULES = chain.mod appleldr.mod \
|
||||
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod
|
||||
|
||||
# For kernel.img.
|
||||
kernel_img_RELOCATABLE = yes
|
||||
kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
||||
term/efi/console.c disk/efi/efidisk.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h \
|
||||
i18n.h env_private.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For acpi.mod.
|
||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
||||
mmap/efi/mmap.c
|
||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For chain.mod.
|
||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For appleldr.mod.
|
||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/efi/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For loadbios.mod
|
||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For fixvideo.mod
|
||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_uga.mod
|
||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_gop.mod
|
||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
include $(srcdir)/conf/x86-efi.mk
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
|
||||
COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
|
||||
COMMON_LDFLAGS = -nostdlib
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||
|
||||
# Images.
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
|
@ -29,23 +24,10 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \
|
|||
term/ieee1275/ofconsole.c \
|
||||
disk/ieee1275/ofdisk.c \
|
||||
symlist.c
|
||||
kernel_img_HEADERS = cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
ieee1275/ieee1275.h machine/kernel.h machine/loader.h machine/memory.h \
|
||||
list.h handler.h command.h i18n.h env_private.h
|
||||
kernel_img_HEADERS += ieee1275/ieee1275.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
@ -54,16 +36,10 @@ sbin_SCRIPTS = grub-install
|
|||
grub_install_SOURCES = util/ieee1275/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = halt.mod reboot.mod suspend.mod \
|
||||
aout.mod serial.mod linux.mod \
|
||||
nand.mod memdisk.mod pci.mod lspci.mod datetime.mod \
|
||||
date.mod datehook.mod lsmmap.mod mmap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
pkglib_MODULES = halt.mod suspend.mod \
|
||||
aout.mod linux.mod \
|
||||
nand.mod datetime.mod \
|
||||
mmap.mod
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||
|
@ -81,21 +57,11 @@ suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
|||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For serial.mod.
|
||||
serial_mod_SOURCES = term/serial.c
|
||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -106,40 +72,10 @@ nand_mod_SOURCES = disk/ieee1275/nand.c
|
|||
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
74
conf/i386-multiboot.rmk
Normal file
74
conf/i386-multiboot.rmk
Normal file
|
@ -0,0 +1,74 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||
|
||||
# Images.
|
||||
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||
|
||||
pkglib_PROGRAMS += kernel.img
|
||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/multiboot_mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c \
|
||||
kern/env.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||
symlist.c
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
||||
|
||||
sbin_SCRIPTS += grub-install
|
||||
grub_install_SOURCES = util/grub-install.in
|
||||
|
||||
bin_SCRIPTS += grub-mkrescue
|
||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For aout.mod.
|
||||
aout_mod_SOURCES = loader/aout.c
|
||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For bsd.mod
|
||||
pkglib_MODULES += bsd.mod
|
||||
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
||||
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
111
conf/i386-pc.rmk
111
conf/i386-pc.rmk
|
@ -2,12 +2,7 @@
|
|||
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
||||
COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
|
||||
COMMON_LDFLAGS = -m32 -nostdlib
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||
|
||||
# Images.
|
||||
pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \
|
||||
|
@ -59,52 +54,39 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \
|
|||
kern/env.c \
|
||||
term/i386/pc/console.c term/i386/vga_common.c \
|
||||
symlist.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \
|
||||
machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \
|
||||
machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h \
|
||||
i18n.h env_private.h
|
||||
kernel_img_HEADERS += machine/biosdisk.h machine/vga.h machine/vbe.h \
|
||||
machine/pxe.h i386/pit.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
|
||||
kernel_img_FORMAT = binary
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# Utilities.
|
||||
bin_UTILITIES = grub-mkimage
|
||||
sbin_UTILITIES = grub-setup
|
||||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||
kern/emu/misc.c util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
# For grub-setup.
|
||||
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||
grub_setup_SOURCES = gnulib/progname.c \
|
||||
util/i386/pc/grub-setup.c util/hostdisk.c \
|
||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
||||
kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
|
||||
grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c \
|
||||
util/misc.c kern/emu/misc.c kern/emu/getroot.c \
|
||||
kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c \
|
||||
kern/misc.c kern/parser.c kern/partition.c kern/file.c \
|
||||
kern/emu/mm.c kern/fs.c kern/env.c kern/list.c fs/fshelp.c \
|
||||
\
|
||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
\
|
||||
partmap/msdos.c partmap/gpt.c \
|
||||
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
||||
partmap/gpt.c \
|
||||
\
|
||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||
util/raid.c util/lvm.c \
|
||||
|
@ -117,20 +99,14 @@ bin_SCRIPTS += grub-mkrescue
|
|||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||
|
||||
pkglib_MODULES = biosdisk.mod chain.mod \
|
||||
reboot.mod halt.mod \
|
||||
vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \
|
||||
vga.mod memdisk.mod pci.mod lspci.mod \
|
||||
aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \
|
||||
datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \
|
||||
halt.mod \
|
||||
vbe.mod vbetest.mod vbeinfo.mod \
|
||||
vga.mod \
|
||||
aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod \
|
||||
ata_pthru.mod hdparm.mod \
|
||||
usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \
|
||||
efiemu.mod mmap.mod acpi.mod drivemap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For drivemap.mod.
|
||||
drivemap_mod_SOURCES = commands/i386/pc/drivemap.c \
|
||||
commands/i386/pc/drivemap_int13h.S
|
||||
|
@ -187,21 +163,11 @@ xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/i386/pc/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For serial.mod.
|
||||
serial_mod_SOURCES = term/serial.c
|
||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For vbe.mod.
|
||||
vbe_mod_SOURCES = video/i386/pc/vbe.c
|
||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -217,31 +183,11 @@ vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
|
|||
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For play.mod.
|
||||
play_mod_SOURCES = commands/i386/pc/play.c
|
||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For vga.mod.
|
||||
vga_mod_SOURCES = term/i386/pc/vga.c
|
||||
vga_mod_SOURCES = video/i386/pc/vga.c
|
||||
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For aout.mod
|
||||
aout_mod_SOURCES = loader/aout.c
|
||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
@ -298,21 +244,6 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
|
|||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For ata_pthru.mod.
|
||||
ata_pthru_mod_SOURCES = disk/ata_pthru.c
|
||||
ata_pthru_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
|
|
@ -1,2 +1,88 @@
|
|||
# -*- makefile -*-
|
||||
include $(srcdir)/conf/i386-coreboot.mk
|
||||
|
||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||
|
||||
# Images.
|
||||
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||
GRUB_BOOT_MACHINE_LINK_ADDR = 0xffe00
|
||||
|
||||
pkglib_IMAGES += boot.img
|
||||
boot_img_SOURCES = boot/i386/qemu/boot.S
|
||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
boot_img_FORMAT = binary
|
||||
|
||||
bin_UTILITIES += grub-mkimage
|
||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c kern/emu/misc.c \
|
||||
util/resolve.c gnulib/progname.c
|
||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
pkglib_IMAGES += kernel.img
|
||||
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
||||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/qemu/mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c \
|
||||
kern/env.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||
symlist.c
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
kernel_img_FORMAT = binary
|
||||
|
||||
sbin_SCRIPTS += grub-install
|
||||
grub_install_SOURCES = util/grub-install.in
|
||||
|
||||
bin_SCRIPTS += grub-mkrescue
|
||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For aout.mod.
|
||||
aout_mod_SOURCES = loader/aout.c
|
||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For bsd.mod
|
||||
pkglib_MODULES += bsd.mod
|
||||
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
||||
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -33,17 +33,43 @@ setpci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
setpci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot.mod
|
||||
multiboot_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/i386/multiboot_mbi.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot_mod_SOURCES = loader/multiboot.c loader/i386/multiboot_mbi.c
|
||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot2.mod
|
||||
multiboot2_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/i386/multiboot_mbi.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot2_mod_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c
|
||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For serial.mod.
|
||||
pkglib_MODULES += serial.mod
|
||||
serial_mod_SOURCES = term/serial.c
|
||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pkglib_MODULES += pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
pkglib_MODULES += lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For play.mod.
|
||||
pkglib_MODULES += play.mod
|
||||
play_mod_SOURCES = commands/i386/pc/play.c
|
||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For iorw.mod.
|
||||
pkglib_MODULES += iorw.mod
|
||||
iorw_mod_SOURCES = commands/iorw.c
|
||||
iorw_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
iorw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
|
|
@ -18,6 +18,5 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
|||
symlist.c kern/$(target_cpu)/cache.S
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
||||
-Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
||||
kernel_img_FORMAT = binary
|
||||
|
|
|
@ -3,6 +3,9 @@ LINK_BASE = 0x80200000
|
|||
target_machine=yeeloong
|
||||
COMMON_CFLAGS += -march=mips3
|
||||
COMMON_ASFLAGS += -march=mips3
|
||||
|
||||
kernel_img_HEADERS += pci.h bitmap.h video.h gfxterm.h font.h bitmap_scale.h bufio.h
|
||||
|
||||
include $(srcdir)/conf/mips.mk
|
||||
|
||||
pkglib_IMAGES = kernel.img
|
||||
|
@ -21,13 +24,12 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
|||
font/font_cmd.c font/font.c io/bufio.c \
|
||||
video/video.c video/fb/video_fb.c video/fb/fbblit.c \
|
||||
video/fb/fbfill.c video/fb/fbutil.c video/bitmap.c \
|
||||
video/sm712.c bus/pci.c bus/bonito.c \
|
||||
video/bitmap_scale.c video/sm712.c bus/pci.c bus/bonito.c \
|
||||
term/gfxterm.c commands/extcmd.c lib/arg.c \
|
||||
symlist.c
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DUSE_ASCII_FAILBACK
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
||||
-Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
||||
kernel_img_FORMAT = binary
|
||||
|
||||
# For ata.mod.
|
||||
|
@ -61,19 +63,11 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
|
|||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
pkglib_MODULES += date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
pkglib_MODULES += datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += linux.mod
|
||||
linux_mod_SOURCES = loader/$(target_cpu)/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
sbin_SCRIPTS += grub-install
|
||||
grub_install_SOURCES = util/grub-install.in
|
||||
|
||||
|
|
|
@ -1,33 +1,10 @@
|
|||
|
||||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS += -nostdinc
|
||||
COMMON_CFLAGS += -ffreestanding -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
||||
COMMON_LDFLAGS += -nostdlib
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS += -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
||||
|
||||
# Images.
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
|
||||
symbol.h term.h time.h types.h loader.h partition.h \
|
||||
msdos_partition.h machine/kernel.h handler.h list.h \
|
||||
command.h machine/memory.h cpu/libgcc.h cpu/cache.h i18n.h env_private.h
|
||||
|
||||
ifeq ($(platform), yeeloong)
|
||||
kernel_img_HEADERS += pci.h
|
||||
endif
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
kernel_img_HEADERS += cpu/cache.h
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS =
|
||||
|
@ -36,30 +13,10 @@ bin_SCRIPTS =
|
|||
# For grub-mkimage.
|
||||
bin_UTILITIES += grub-mkimage
|
||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||
kern/emu/misc.c util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = memdisk.mod \
|
||||
lsmmap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For serial.mod.
|
||||
pkglib_MODULES += serial.mod
|
||||
serial_mod_SOURCES = term/serial.c
|
||||
|
@ -73,10 +30,11 @@ relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += linux.mod
|
||||
linux_mod_SOURCES = loader/$(target_cpu)/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
pkglib_MODULES += multiboot2.mod
|
||||
multiboot2_mod_SOURCES = loader/multiboot.c \
|
||||
loader/multiboot_mbi2.c
|
||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -1,29 +1,9 @@
|
|||
|
||||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -D__ASSEMBLY__
|
||||
COMMON_CFLAGS = -ffreestanding
|
||||
COMMON_LDFLAGS += -nostdlib
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
|
||||
# Images.
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
|
||||
symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \
|
||||
msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \
|
||||
command.h i18n.h env_private.h
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
kernel_img_HEADERS += ieee1275/ieee1275.h
|
||||
|
||||
# Programs
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
|
@ -43,8 +23,7 @@ kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \
|
|||
symlist.c kern/$(target_cpu)/cache.S
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
||||
-Wl,-N,-S,-Ttext,0x200000,-Bstatic
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x200000,-Bstatic
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
@ -57,47 +36,33 @@ grub_install_SOURCES = util/ieee1275/grub-install.in
|
|||
grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = halt.mod \
|
||||
linux.mod \
|
||||
reboot.mod \
|
||||
suspend.mod \
|
||||
memdisk.mod \
|
||||
lsmmap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
pkglib_MODULES += ieee1275_fb.mod
|
||||
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
||||
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
pkglib_MODULES += linux.mod
|
||||
linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For suspend.mod
|
||||
pkglib_MODULES += suspend.mod
|
||||
suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
||||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod
|
||||
pkglib_MODULES += halt.mod
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
# For datetime.mod
|
||||
pkglib_MODULES += datetime.mod
|
||||
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
|
||||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -m64
|
||||
COMMON_CFLAGS = -ffreestanding -m64 -mno-app-regs
|
||||
COMMON_LDFLAGS = -melf64_sparc -nostdlib -mno-relax
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
COMMON_CFLAGS = -mno-app-regs
|
||||
COMMON_LDFLAGS = -melf64_sparc -mno-relax
|
||||
|
||||
# Images.
|
||||
pkglib_IMAGES = boot.img diskboot.img kernel.img
|
||||
|
@ -23,15 +19,7 @@ diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|||
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
|
||||
diskboot_img_FORMAT = binary
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
list.h handler.h command.h i18n.h \
|
||||
sparc64/libgcc.h ieee1275/ieee1275.h machine/kernel.h \
|
||||
sparc64/ieee1275/ieee1275.h env_private.h
|
||||
kernel_img_HEADERS += ieee1275/ieee1275.h cpu/ieee1275/ieee1275.h
|
||||
kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
||||
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
||||
|
@ -48,46 +36,42 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
|||
symlist.c kern/$(target_cpu)/cache.S
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
||||
kernel_img_LDFLAGS += -nostdlib -Wl,-N,-Ttext,0x4400,-Bstatic,-melf64_sparc
|
||||
kernel_img_FORMAT = binary
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# Utilities.
|
||||
bin_UTILITIES = grub-mkimage
|
||||
sbin_UTILITIES = grub-setup grub-ofpathname
|
||||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
|
||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c kern/emu/misc.c \
|
||||
util/resolve.c gnulib/progname.c
|
||||
|
||||
# For grub-setup.
|
||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
||||
kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
|
||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c \
|
||||
util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c \
|
||||
kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c \
|
||||
kern/disk.c kern/err.c kern/misc.c kern/parser.c \
|
||||
kern/partition.c kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||
fs/fshelp.c \
|
||||
\
|
||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||
\
|
||||
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
||||
partmap/sun.c partmap/acorn.c \
|
||||
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
||||
\
|
||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||
util/raid.c util/lvm.c gnulib/progname.c \
|
||||
grub_setup_init.c
|
||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c util/raid.c \
|
||||
util/lvm.c gnulib/progname.c grub_setup_init.c
|
||||
|
||||
# For grub-ofpathname.
|
||||
grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \
|
||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
||||
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
||||
util/ieee1275/ofpath.c util/misc.c kern/emu/misc.c \
|
||||
gnulib/progname.c
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
@ -96,41 +80,27 @@ sbin_SCRIPTS = grub-install
|
|||
grub_install_SOURCES = util/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_MODULES = halt.mod \
|
||||
linux.mod \
|
||||
reboot.mod \
|
||||
memdisk.mod \
|
||||
lsmmap.mod
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
pkglib_MODULES += ieee1275_fb.mod
|
||||
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
||||
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
pkglib_MODULES += linux.mod
|
||||
linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
pkglib_MODULES += halt.mod
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For memdisk.mod.
|
||||
memdisk_mod_SOURCES = disk/memdisk.c
|
||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lsmmap.mod
|
||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
# For datetime.mod
|
||||
pkglib_MODULES += datetime.mod
|
||||
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -37,12 +37,56 @@ example_scripted_test_SOURCES = tests/example_scripted_test.in
|
|||
check_SCRIPTS += example_grub_script_test
|
||||
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
||||
|
||||
#
|
||||
# Rules for real tests
|
||||
#
|
||||
|
||||
check_SCRIPTS += grub_script_echo1
|
||||
grub_script_echo1_SOURCES = tests/grub_script_echo1.in
|
||||
|
||||
check_SCRIPTS += grub_script_echo_keywords
|
||||
grub_script_echo_keywords_SOURCES = tests/grub_script_echo_keywords.in
|
||||
|
||||
check_SCRIPTS += grub_script_vars1
|
||||
grub_script_vars1_SOURCES = tests/grub_script_vars1.in
|
||||
|
||||
check_SCRIPTS += grub_script_for1
|
||||
grub_script_for1_SOURCES = tests/grub_script_for1.in
|
||||
|
||||
check_SCRIPTS += grub_script_while1
|
||||
grub_script_while1_SOURCES = tests/grub_script_while1.in
|
||||
|
||||
check_SCRIPTS += grub_script_if
|
||||
grub_script_if_SOURCES = tests/grub_script_if.in
|
||||
|
||||
check_SCRIPTS += grub_script_blanklines
|
||||
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
||||
|
||||
check_SCRIPTS += grub_script_final_semicolon
|
||||
grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
||||
|
||||
check_SCRIPTS += grub_script_dollar
|
||||
grub_script_dollar_SOURCES = tests/grub_script_dollar.in
|
||||
|
||||
check_SCRIPTS += grub_script_comments
|
||||
grub_script_comments_SOURCES = tests/grub_script_comments.in
|
||||
|
||||
# List of tests to execute on "make check"
|
||||
SCRIPTED_TESTS = example_scripted_test
|
||||
SCRIPTED_TESTS += example_grub_script_test
|
||||
UNIT_TESTS = example_unit_test
|
||||
FUNCTIONAL_TESTS = example_functional_test.mod
|
||||
# SCRIPTED_TESTS = example_scripted_test
|
||||
# SCRIPTED_TESTS += example_grub_script_test
|
||||
# UNIT_TESTS = example_unit_test
|
||||
# FUNCTIONAL_TESTS = example_functional_test.mod
|
||||
|
||||
SCRIPTED_TESTS = grub_script_echo1
|
||||
SCRIPTED_TESTS += grub_script_echo_keywords
|
||||
SCRIPTED_TESTS += grub_script_vars1
|
||||
SCRIPTED_TESTS += grub_script_for1
|
||||
SCRIPTED_TESTS += grub_script_while1
|
||||
SCRIPTED_TESTS += grub_script_if
|
||||
SCRIPTED_TESTS += grub_script_blanklines
|
||||
SCRIPTED_TESTS += grub_script_final_semicolon
|
||||
SCRIPTED_TESTS += grub_script_dollar
|
||||
SCRIPTED_TESTS += grub_script_comments
|
||||
|
||||
# dependencies between tests and testing-tools
|
||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
||||
|
|
117
conf/x86-efi.rmk
Normal file
117
conf/x86-efi.rmk
Normal file
|
@ -0,0 +1,117 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
# Utilities.
|
||||
bin_UTILITIES = grub-mkimage
|
||||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
||||
util/misc.c kern/emu/misc.c util/resolve.c
|
||||
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
||||
# For grub-install.
|
||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
pkglib_MODULES = chain.mod appleldr.mod \
|
||||
linux.mod halt.mod \
|
||||
datetime.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod
|
||||
|
||||
# For kernel.img.
|
||||
kernel_img_RELOCATABLE = yes
|
||||
kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
||||
term/efi/console.c disk/efi/efidisk.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c
|
||||
ifeq ($(target_cpu),x86_64)
|
||||
kernel_img_SOURCES += kern/x86_64/efi/callwrap.S
|
||||
endif
|
||||
kernel_img_HEADERS += efi/efi.h efi/time.h efi/disk.h i386/pit.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS)
|
||||
|
||||
# For acpi.mod.
|
||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
||||
mmap/efi/mmap.c
|
||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For chain.mod.
|
||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For appleldr.mod.
|
||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
ifeq ($(target_cpu), x86_64)
|
||||
linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
else
|
||||
linux_mod_SOURCES = loader/i386/efi/linux.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
endif
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For loadbios.mod
|
||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For fixvideo.mod
|
||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_uga.mod
|
||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_gop.mod
|
||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
|
@ -1,166 +1,5 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m64
|
||||
COMMON_CFLAGS = -fno-builtin -m64
|
||||
COMMON_LDFLAGS = -melf_x86_64 -nostdlib
|
||||
COMMON_LDFLAGS = -melf_x86_64
|
||||
|
||||
# Used by various components. These rules need to precede them.
|
||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||
|
||||
# Utilities.
|
||||
bin_UTILITIES = grub-mkimage
|
||||
|
||||
# For grub-mkimage.
|
||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
||||
util/misc.c util/resolve.c
|
||||
|
||||
# For grub-setup.
|
||||
#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
|
||||
# util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||
# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
|
||||
# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
|
||||
# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
|
||||
# kern/fs.c kern/env.c fs/fshelp.c
|
||||
|
||||
# Scripts.
|
||||
sbin_SCRIPTS = grub-install
|
||||
|
||||
# For grub-install.
|
||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||
|
||||
# Modules.
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
pkglib_MODULES = chain.mod appleldr.mod \
|
||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod
|
||||
|
||||
# For kernel.img.
|
||||
kernel_img_RELOCATABLE = yes
|
||||
kernel_img_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
|
||||
kern/main.c kern/device.c \
|
||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||
kern/misc.c kern/mm.c kern/term.c \
|
||||
kern/rescue_parser.c kern/rescue_reader.c \
|
||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||
kern/i386/tsc.c kern/i386/pit.c \
|
||||
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c \
|
||||
term/efi/console.c disk/efi/efidisk.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h \
|
||||
handler.h command.h i18n.h env_private.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For acpi.mod.
|
||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
||||
mmap/efi/mmap.c
|
||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For chain.mod.
|
||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For appleldr.mod.
|
||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For halt.mod.
|
||||
halt_mod_SOURCES = commands/halt.c
|
||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For reboot.mod.
|
||||
reboot_mod_SOURCES = commands/reboot.c
|
||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For lspci.mod
|
||||
lspci_mod_SOURCES = commands/lspci.c
|
||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datetime.mod
|
||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For date.mod
|
||||
date_mod_SOURCES = commands/date.c
|
||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For datehook.mod
|
||||
datehook_mod_SOURCES = hook/datehook.c
|
||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For loadbios.mod
|
||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For fixvideo.mod
|
||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_uga.mod
|
||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += efi_gop.mod
|
||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += xnu.mod
|
||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
include $(srcdir)/conf/x86-efi.mk
|
||||
|
|
154
configure.ac
154
configure.ac
|
@ -31,7 +31,7 @@ dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
|
|||
dnl type.
|
||||
|
||||
|
||||
AC_INIT([GRUB],[1.97],[bug-grub@gnu.org])
|
||||
AC_INIT([GRUB],[1.98],[bug-grub@gnu.org])
|
||||
AM_INIT_AUTOMAKE()
|
||||
AC_PREREQ(2.60)
|
||||
AC_CONFIG_SRCDIR([include/grub/dl.h])
|
||||
|
@ -51,6 +51,7 @@ fi
|
|||
|
||||
case "$target_cpu" in
|
||||
i[[3456]]86) target_cpu=i386 ;;
|
||||
amd64) target_cpu=x86_64 ;;
|
||||
sparc) target_cpu=sparc64 ;;
|
||||
mipsel|mips64el)
|
||||
target_cpu=mips;
|
||||
|
@ -90,6 +91,7 @@ fi
|
|||
if test -z "$target_alias"; then
|
||||
case "$target_cpu"-"$platform" in
|
||||
x86_64-efi) ;;
|
||||
x86_64-emu) ;;
|
||||
x86_64-*) target_cpu=i386 ;;
|
||||
powerpc64-ieee1275) target_cpu=powerpc ;;
|
||||
esac
|
||||
|
@ -100,6 +102,7 @@ case "$target_cpu"-"$platform" in
|
|||
i386-efi) ;;
|
||||
x86_64-efi) ;;
|
||||
i386-pc) ;;
|
||||
i386-multiboot) ;;
|
||||
i386-coreboot) ;;
|
||||
i386-linuxbios) platform=coreboot ;;
|
||||
i386-ieee1275) ;;
|
||||
|
@ -128,19 +131,26 @@ case "$host_os" in
|
|||
gnu*) host_kernel=hurd ;;
|
||||
linux*) host_kernel=linux ;;
|
||||
freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
|
||||
netbsd*) host_kernel=netbsd ;;
|
||||
cygwin) host_kernel=windows ;;
|
||||
esac
|
||||
|
||||
case "$platform" in
|
||||
coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
||||
multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
|
||||
efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
||||
ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
||||
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
||||
pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
|
||||
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
|
||||
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
esac
|
||||
case "$target_cpu" in
|
||||
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||
esac
|
||||
|
||||
CFLAGS="$CFLAGS $machine_CFLAGS"
|
||||
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
|
||||
|
@ -177,9 +187,21 @@ done
|
|||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_AWK
|
||||
AC_PROG_LEX
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_MKDIR_P
|
||||
|
||||
if test "x$LEX" = x; then
|
||||
AC_MSG_ERROR([flex is not found])
|
||||
else
|
||||
version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
|
||||
if test -n "$version" -a "$version" -ge 20535; then
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
|
||||
fi
|
||||
fi
|
||||
|
||||
# These are not a "must".
|
||||
AC_PATH_PROG(RUBY, ruby)
|
||||
AC_PATH_PROG(MAKEINFO, makeinfo)
|
||||
|
@ -223,6 +245,20 @@ AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
|
|||
AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
|
||||
AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
|
||||
|
||||
# For opendisk() and getrawpartition() on NetBSD.
|
||||
# Used in util/deviceiter.c and in util/hostdisk.c.
|
||||
AC_CHECK_HEADER([util.h], [
|
||||
AC_CHECK_LIB([util], [opendisk], [
|
||||
LIBUTIL="-lutil"
|
||||
AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
|
||||
])
|
||||
AC_CHECK_LIB([util], [getrawpartition], [
|
||||
LIBUTIL="-lutil"
|
||||
AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
|
||||
])
|
||||
])
|
||||
AC_SUBST([LIBUTIL])
|
||||
|
||||
#
|
||||
# Check for target programs.
|
||||
#
|
||||
|
@ -326,7 +362,7 @@ else
|
|||
if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
|
||||
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
||||
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT} -Wl,-Ttext,"
|
||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc -Wl,-Ttext,"
|
||||
else
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_LDFLAGS='-Wl,-N -Wl,-Ttext,'
|
||||
|
@ -342,7 +378,11 @@ AC_SUBST(TARGET_IMG_CFLAGS)
|
|||
# For platforms where ELF is not the default link format.
|
||||
AC_MSG_CHECKING([for command to convert module to ELF format])
|
||||
case "${host_os}" in
|
||||
cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;;
|
||||
cygwin) TARGET_OBJ2ELF='grub-pe2elf';
|
||||
# FIXME: put proper test here
|
||||
AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
|
||||
[Define to 1 if GCC generates calls to __register_frame_info()])
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
AC_SUBST(TARGET_OBJ2ELF)
|
||||
|
@ -352,6 +392,7 @@ AC_MSG_RESULT([$TARGET_OBJ2ELF])
|
|||
if test "x$target_m32" = x1; then
|
||||
# Force 32-bit mode.
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
|
||||
TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
|
||||
TARGET_MODULE_FORMAT="elf32"
|
||||
fi
|
||||
|
@ -359,6 +400,7 @@ fi
|
|||
if test "x$target_m64" = x1; then
|
||||
# Force 64-bit mode.
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
|
||||
TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
|
||||
TARGET_MODULE_FORMAT="elf64"
|
||||
fi
|
||||
|
@ -373,9 +415,7 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
|
|||
[grub_cv_cc_mcmodel=no])
|
||||
])
|
||||
if test "x$grub_cv_cc_mcmodel" = xno; then
|
||||
CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
|
||||
AC_MSG_WARN([-mcmodel=large not supported. You won't be able to use the memory over 4GiB. Upgrade your gcc])
|
||||
AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
|
||||
else
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||
fi
|
||||
|
@ -443,12 +483,19 @@ CC="$TARGET_CC"
|
|||
if test "x$TARGET_APPLE_CC" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wl,--defsym,abort=main -Wno-error"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
|
||||
fi
|
||||
CPPFLAGS="$TARGET_CPPFLAGS"
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
LIBS=-lgcc
|
||||
|
||||
grub_ASM_USCORE
|
||||
if test x$grub_cv_asm_uscore = xyes; then
|
||||
CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
|
||||
else
|
||||
CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
|
||||
fi
|
||||
|
||||
# Check for libgcc symbols
|
||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
|
||||
|
||||
|
@ -457,6 +504,7 @@ CFLAGS="$TARGET_CFLAGS -nostdlib"
|
|||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
|
||||
fi
|
||||
LIBS=""
|
||||
|
||||
# Defined in aclocal.m4.
|
||||
grub_PROG_TARGET_CC
|
||||
|
@ -464,13 +512,12 @@ if test "x$TARGET_APPLE_CC" != x1 ; then
|
|||
grub_PROG_OBJCOPY_ABSOLUTE
|
||||
fi
|
||||
grub_PROG_LD_BUILD_ID_NONE
|
||||
grub_ASM_USCORE
|
||||
if test "x$target_cpu" = xi386; then
|
||||
if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
|
||||
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
|
||||
# Check symbols provided by linker script.
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC}8000 -Wl,--defsym,___main=0x8100"
|
||||
fi
|
||||
if test "x$TARGET_APPLE_CC" != x1 ; then
|
||||
grub_CHECK_BSS_START_SYMBOL
|
||||
grub_CHECK_END_SYMBOL
|
||||
fi
|
||||
|
@ -515,6 +562,21 @@ enable_efiemu=no
|
|||
fi
|
||||
AC_SUBST([enable_efiemu])
|
||||
|
||||
if test "$platform" != emu; then
|
||||
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
|
||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
||||
int va_arg_func (int fixed, va_list args);]], [[]])],
|
||||
[grub_cv_cc_isystem=yes],
|
||||
[grub_cv_cc_isystem=no])
|
||||
CPPFLAGS="$SAVED_CPPFLAGS"
|
||||
])
|
||||
|
||||
if test x"$grub_cv_cc_isystem" = xyes ; then
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Restore the flags.
|
||||
CC="$tmp_CC"
|
||||
|
@ -538,10 +600,18 @@ AC_ARG_ENABLE([grub-emu-usb],
|
|||
[AS_HELP_STRING([--enable-grub-emu-usb],
|
||||
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-sdl],
|
||||
[AS_HELP_STRING([--enable-grub-emu-sdl],
|
||||
[build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-pci],
|
||||
[AS_HELP_STRING([--enable-grub-emu-pci],
|
||||
[build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-modules],
|
||||
[AS_HELP_STRING([--enable-grub-emu-modules],
|
||||
[Support module loading in `grub-emu' debugging utility (default=no)])])
|
||||
|
||||
if test "$platform" = emu; then
|
||||
missing_ncurses=
|
||||
[# Check for curses libraries.]
|
||||
|
@ -560,6 +630,19 @@ if test x"$missing_ncurses" = xtrue ; then
|
|||
AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_modules" = xyes ; then
|
||||
TARGET_NO_MODULES=no
|
||||
else
|
||||
TARGET_NO_MODULES=yes
|
||||
fi
|
||||
AC_SUBST(TARGET_NO_MODULES)
|
||||
|
||||
if test "$TARGET_NO_MODULES" = yes ; then
|
||||
# Do not convert modules, otherwise linkage may fail (Cygwin only).
|
||||
# FIXME: Should be checked above before TARGET_OBJ2ELF is set first.
|
||||
TARGET_OBJ2ELF=
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_usb" = xno ; then
|
||||
grub_emu_usb_excuse="explicitly disabled"
|
||||
fi
|
||||
|
@ -588,6 +671,31 @@ else
|
|||
enable_grub_emu_usb=no
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_sdl" = xno ; then
|
||||
grub_emu_sdl_excuse="explicitely disabled"
|
||||
fi
|
||||
[if [ x"$grub_emu_sdl_excuse" = x ]; then
|
||||
# Check for libSDL libraries.]
|
||||
AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
|
||||
[grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
|
||||
AC_SUBST([LIBSDL])
|
||||
[fi]
|
||||
|
||||
[if [ x"$grub_emu_sdl_excuse" = x ]; then
|
||||
# Check for headers.]
|
||||
AC_CHECK_HEADERS([SDL/SDL.h], [],
|
||||
[grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
|
||||
[fi]
|
||||
|
||||
if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
|
||||
AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
|
||||
fi
|
||||
if test x"$grub_emu_sdl_excuse" = x ; then
|
||||
enable_grub_emu_sdl=yes
|
||||
else
|
||||
enable_grub_emu_sdl=no
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_pci" != xyes ; then
|
||||
grub_emu_pci_excuse="not enabled"
|
||||
fi
|
||||
|
@ -611,9 +719,11 @@ fi
|
|||
if test x"$grub_emu_pci_excuse" = x ; then
|
||||
enable_grub_emu_pci=yes
|
||||
else
|
||||
|
||||
enable_grub_emu_pci=no
|
||||
fi
|
||||
|
||||
AC_SUBST([enable_grub_emu_sdl])
|
||||
AC_SUBST([enable_grub_emu_usb])
|
||||
AC_SUBST([enable_grub_emu_pci])
|
||||
fi
|
||||
|
@ -647,6 +757,16 @@ if test x"$grub_mkfont_excuse" = x ; then
|
|||
freetype_cflags=`freetype-config --cflags`
|
||||
freetype_libs=`freetype-config --libs`
|
||||
fi
|
||||
|
||||
if test x"$grub_mkfont_excuse" = x ; then
|
||||
# Check for freetype libraries.
|
||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $freetype_cflags"
|
||||
AC_CHECK_HEADERS([ft2build.h], [],
|
||||
[grub_mkfont_excuse=["need freetype2 headers"]])
|
||||
CPPFLAGS="$SAVED_CPPFLAGS"
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
|
||||
AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
|
||||
fi
|
||||
|
@ -706,11 +826,21 @@ echo USB support for grub-emu: Yes
|
|||
else
|
||||
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
|
||||
fi
|
||||
if [ x"$grub_emu_sdl_excuse" = x ]; then
|
||||
echo SDL support for grub-emu: Yes
|
||||
else
|
||||
echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
|
||||
fi
|
||||
if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
echo PCI support for grub-emu: Yes
|
||||
else
|
||||
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
|
||||
fi
|
||||
if [ x"$TARGET_NO_MODULES" = xno ]; then
|
||||
echo Module support for grub-emu: Yes
|
||||
else
|
||||
echo Module support for grub-emu: No
|
||||
fi
|
||||
fi
|
||||
if [ x"$enable_mm_debug" = xyes ]; then
|
||||
echo With memory debugging: Yes
|
||||
|
|
|
@ -825,7 +825,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
if (! disk)
|
||||
return 1;
|
||||
|
||||
if (disk->id == GRUB_DISK_DEVICE_EFIDISK_ID)
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_EFIDISK_ID)
|
||||
{
|
||||
struct grub_efidisk_data *d;
|
||||
|
||||
|
|
|
@ -307,8 +307,17 @@ grub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
while (size)
|
||||
{
|
||||
grub_size_t len;
|
||||
grub_size_t cdoff = 0;
|
||||
|
||||
len = get_safe_sectors (sector, data->sectors);
|
||||
|
||||
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
|
||||
{
|
||||
cdoff = (sector & 3) << GRUB_DISK_SECTOR_BITS;
|
||||
len = ALIGN_UP (sector + len, 4) - (sector & ~3);
|
||||
sector &= ~3;
|
||||
}
|
||||
|
||||
if (len > size)
|
||||
len = size;
|
||||
|
||||
|
@ -316,7 +325,7 @@ grub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (buf, (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
|
||||
grub_memcpy (buf, (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + cdoff),
|
||||
len << GRUB_DISK_SECTOR_BITS);
|
||||
buf += len << GRUB_DISK_SECTOR_BITS;
|
||||
sector += len;
|
||||
|
@ -332,6 +341,9 @@ grub_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
{
|
||||
struct grub_biosdisk_data *data = disk->data;
|
||||
|
||||
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
|
||||
return grub_error (GRUB_ERR_IO, "can't write to CDROM");
|
||||
|
||||
while (size)
|
||||
{
|
||||
grub_size_t len;
|
||||
|
|
|
@ -118,7 +118,7 @@ grub_ofdisk_iterate (int (*hook) (const char *name))
|
|||
static char *
|
||||
compute_dev_path (const char *name)
|
||||
{
|
||||
char *devpath = grub_malloc (grub_strlen (name) + 2);
|
||||
char *devpath = grub_malloc (grub_strlen (name) + 3);
|
||||
char *p, c;
|
||||
|
||||
if (!devpath)
|
||||
|
@ -172,16 +172,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
grub_dprintf ("disk", "Opening `%s'.\n", op->devpath);
|
||||
|
||||
grub_ieee1275_open (op->devpath, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
|
||||
(void *) (unsigned long) dev_ihandle);
|
||||
|
||||
if (grub_ieee1275_finddevice (op->devpath, &dev))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties");
|
||||
|
@ -201,6 +191,16 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
grub_ieee1275_open (op->devpath, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
|
||||
(void *) (unsigned long) dev_ihandle);
|
||||
|
||||
/* XXX: There is no property to read the number of blocks. There
|
||||
should be a property `#blocks', but it is not there. Perhaps it
|
||||
is possible to use seek for this. */
|
||||
|
@ -234,21 +234,17 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
grub_ssize_t status, actual;
|
||||
unsigned long long pos;
|
||||
|
||||
grub_dprintf ("disk",
|
||||
"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n",
|
||||
(void *) disk->data, (long long) sector, (long) size, buf);
|
||||
|
||||
pos = sector * 512UL;
|
||||
|
||||
grub_ieee1275_seek ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
|
||||
(int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
|
||||
pos, &status);
|
||||
if (status < 0)
|
||||
return grub_error (GRUB_ERR_READ_ERROR,
|
||||
"seek error, can't seek block %llu",
|
||||
(long long) sector);
|
||||
grub_ieee1275_read ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
|
||||
buf, size * 512UL, &actual);
|
||||
if (actual != actual)
|
||||
if (actual != (grub_ssize_t) (size * 512UL))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "read error on block: %llu",
|
||||
(long long) sector);
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ static struct grub_disk_dev grub_loopback_dev =
|
|||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(loop)
|
||||
GRUB_MOD_INIT(loopback)
|
||||
{
|
||||
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
|
@ -251,7 +251,7 @@ GRUB_MOD_INIT(loop)
|
|||
grub_disk_dev_register (&grub_loopback_dev);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(loop)
|
||||
GRUB_MOD_FINI(loopback)
|
||||
{
|
||||
grub_unregister_extcmd (cmd);
|
||||
grub_disk_dev_unregister (&grub_loopback_dev);
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/lvm.h>
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/emu/misc.h>
|
||||
#endif
|
||||
|
||||
static struct grub_lvm_vg *vg_list;
|
||||
static int lv_count;
|
||||
|
||||
|
@ -68,6 +72,9 @@ grub_lvm_memberlist (grub_disk_t disk)
|
|||
if (lv->vg->pvs)
|
||||
for (pv = lv->vg->pvs; pv; pv = pv->next)
|
||||
{
|
||||
if (!pv->disk)
|
||||
grub_util_error ("Couldn't find PV %s. Check your device.map",
|
||||
pv->name);
|
||||
tmp = grub_malloc (sizeof (*tmp));
|
||||
tmp->disk = pv->disk;
|
||||
tmp->next = list;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
static char *memdisk_addr;
|
||||
static grub_off_t memdisk_size = 0;
|
||||
|
|
|
@ -208,12 +208,14 @@ grub_scsi_iterate (int (*hook) (const char *name))
|
|||
for (i = 0; i < luns; i++)
|
||||
{
|
||||
char *sname;
|
||||
int ret;
|
||||
sname = grub_xasprintf ("%s%c", name, 'a' + i);
|
||||
if (!sname)
|
||||
return 1;
|
||||
if (hook (sname))
|
||||
return 1;
|
||||
ret = hook (sname);
|
||||
grub_free (sname);
|
||||
if (ret)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1126,6 +1126,7 @@ you forget a command, you can run the command @command{help}
|
|||
* insmod:: Insert a module
|
||||
* keystatus:: Check key modifier status
|
||||
* ls:: List devices or files
|
||||
* play:: Play a tune
|
||||
* reboot:: Reboot your computer
|
||||
* set:: Set an environment variable
|
||||
* unset:: Unset an environment variable
|
||||
|
@ -1364,6 +1365,25 @@ name syntax}), then list the contents of that directory.
|
|||
@end deffn
|
||||
|
||||
|
||||
@node play
|
||||
@subsection play
|
||||
|
||||
@deffn Command play file | tempo [pitch1 duration1] [pitch2 duration2] ...
|
||||
Plays a tune
|
||||
|
||||
If the argument is a file name (@pxref{File name syntax}), play the tune
|
||||
recorded in it. The file format is first the tempo as an unsigned 32bit
|
||||
little-endian number, then pairs of unsigned 16bit little-endian numbers for
|
||||
pitch and duration pairs.
|
||||
|
||||
If the arguments are a series of numbers, play the inline tune.
|
||||
|
||||
The tempo is the base for all note durations. 60 gives a 1-second base, 120
|
||||
gives a half-second base, etc. Pitches are Hz. Set pitch to 0 to produce
|
||||
a rest.
|
||||
@end deffn
|
||||
|
||||
|
||||
@node reboot
|
||||
@subsection reboot
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <grub/efiemu/efiemu.h>
|
||||
#include <grub/machine/efiemu.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
/* System table. Two version depending on mode */
|
||||
grub_efi_system_table32_t *grub_efiemu_system_table32 = 0;
|
||||
|
@ -265,7 +266,7 @@ grub_efiemu_autocore (void)
|
|||
grub_free (filename);
|
||||
if (err)
|
||||
return err;
|
||||
#ifndef GRUB_UTIL
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
err = grub_machine_efiemu_init_tables ();
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -313,7 +314,7 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
|
|||
err = grub_efiemu_load_file (args[0]);
|
||||
if (err)
|
||||
return err;
|
||||
#ifndef GRUB_UTIL
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
err = grub_machine_efiemu_init_tables ();
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -327,15 +328,15 @@ GRUB_MOD_INIT(efiemu)
|
|||
{
|
||||
cmd_loadcore = grub_register_command ("efiemu_loadcore",
|
||||
grub_cmd_efiemu_load,
|
||||
"FILE",
|
||||
"Load and initialize EFI emulator.");
|
||||
N_("FILE"),
|
||||
N_("Load and initialize EFI emulator."));
|
||||
cmd_prepare = grub_register_command ("efiemu_prepare",
|
||||
grub_cmd_efiemu_prepare,
|
||||
0,
|
||||
"Finalize loading of EFI emulator.");
|
||||
N_("Finalize loading of EFI emulator."));
|
||||
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
|
||||
0,
|
||||
"Unload EFI emulator.");
|
||||
N_("Unload EFI emulator."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(efiemu)
|
||||
|
|
|
@ -281,7 +281,7 @@ grub_efiemu_mmap_init (void)
|
|||
// the place for memory used by efiemu itself
|
||||
mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1;
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
grub_machine_mmap_iterate (bounds_hook);
|
||||
#endif
|
||||
|
||||
|
@ -394,7 +394,7 @@ grub_efiemu_mmap_fill (void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
grub_machine_mmap_iterate (fill_hook);
|
||||
#endif
|
||||
|
||||
|
|
180
font/font.c
180
font/font.c
|
@ -26,6 +26,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/fontformat.h>
|
||||
|
||||
#ifdef USE_ASCII_FAILBACK
|
||||
#include "ascii.h"
|
||||
|
@ -89,22 +90,8 @@ struct font_file_section
|
|||
int eof;
|
||||
};
|
||||
|
||||
/* Font file format constants. */
|
||||
static const char pff2_magic[4] = { 'P', 'F', 'F', '2' };
|
||||
static const char section_names_file[4] = { 'F', 'I', 'L', 'E' };
|
||||
static const char section_names_font_name[4] = { 'N', 'A', 'M', 'E' };
|
||||
static const char section_names_point_size[4] = { 'P', 'T', 'S', 'Z' };
|
||||
static const char section_names_weight[4] = { 'W', 'E', 'I', 'G' };
|
||||
static const char section_names_max_char_width[4] = { 'M', 'A', 'X', 'W' };
|
||||
static const char section_names_max_char_height[4] = { 'M', 'A', 'X', 'H' };
|
||||
static const char section_names_ascent[4] = { 'A', 'S', 'C', 'E' };
|
||||
static const char section_names_descent[4] = { 'D', 'E', 'S', 'C' };
|
||||
static const char section_names_char_index[4] = { 'C', 'H', 'I', 'X' };
|
||||
static const char section_names_data[4] = { 'D', 'A', 'T', 'A' };
|
||||
|
||||
/* Replace unknown glyphs with a rounded question mark. */
|
||||
static grub_uint8_t unknown_glyph_bitmap[] =
|
||||
{
|
||||
static grub_uint8_t unknown_glyph_bitmap[] = {
|
||||
/* 76543210 */
|
||||
0x7C, /* ooooo */
|
||||
0x82, /* o o */
|
||||
|
@ -153,8 +140,8 @@ ascii_glyph_lookup (grub_uint32_t code)
|
|||
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] =
|
||||
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
|
||||
|
||||
ascii_font_glyph[current]->width = 8;
|
||||
ascii_font_glyph[current]->height = 16;
|
||||
|
@ -185,9 +172,9 @@ grub_font_loader_init (void)
|
|||
return;
|
||||
|
||||
/* Make glyph for unknown glyph. */
|
||||
unknown_glyph = grub_malloc(sizeof(struct grub_font_glyph)
|
||||
+ sizeof(unknown_glyph_bitmap));
|
||||
if (! unknown_glyph)
|
||||
unknown_glyph = grub_malloc (sizeof (struct grub_font_glyph)
|
||||
+ sizeof (unknown_glyph_bitmap));
|
||||
if (!unknown_glyph)
|
||||
return;
|
||||
|
||||
unknown_glyph->width = 8;
|
||||
|
@ -195,13 +182,13 @@ grub_font_loader_init (void)
|
|||
unknown_glyph->offset_x = 0;
|
||||
unknown_glyph->offset_y = -3;
|
||||
unknown_glyph->device_width = 8;
|
||||
grub_memcpy(unknown_glyph->bitmap,
|
||||
unknown_glyph_bitmap, sizeof(unknown_glyph_bitmap));
|
||||
grub_memcpy (unknown_glyph->bitmap,
|
||||
unknown_glyph_bitmap, sizeof (unknown_glyph_bitmap));
|
||||
|
||||
/* Initialize the null font. */
|
||||
font_init (&null_font);
|
||||
null_font.name = "<No Font>";
|
||||
null_font.ascent = unknown_glyph->height-3;
|
||||
null_font.ascent = unknown_glyph->height - 3;
|
||||
null_font.descent = 3;
|
||||
null_font.max_char_width = unknown_glyph->width;
|
||||
null_font.max_char_height = unknown_glyph->height;
|
||||
|
@ -301,7 +288,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
|
|||
grub_uint32_t last_code;
|
||||
|
||||
#if FONT_DEBUG >= 2
|
||||
grub_printf("load_font_index(sect_length=%d)\n", sect_length);
|
||||
grub_printf ("load_font_index(sect_length=%d)\n", sect_length);
|
||||
#endif
|
||||
|
||||
/* Sanity check: ensure section length is divisible by the entry size. */
|
||||
|
@ -320,10 +307,10 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
|
|||
/* Allocate the character index array. */
|
||||
font->char_index = grub_malloc (font->num_chars
|
||||
* sizeof (struct char_index_entry));
|
||||
if (! font->char_index)
|
||||
if (!font->char_index)
|
||||
return 1;
|
||||
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
|
||||
if (! font->bmp_idx)
|
||||
if (!font->bmp_idx)
|
||||
{
|
||||
grub_free (font->char_index);
|
||||
return 1;
|
||||
|
@ -332,7 +319,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
|
|||
|
||||
|
||||
#if FONT_DEBUG >= 2
|
||||
grub_printf("num_chars=%d)\n", font->num_chars);
|
||||
grub_printf ("num_chars=%d)\n", font->num_chars);
|
||||
#endif
|
||||
|
||||
last_code = 0;
|
||||
|
@ -376,7 +363,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
|
|||
#if FONT_DEBUG >= 5
|
||||
/* Print the 1st 10 characters. */
|
||||
if (i < 10)
|
||||
grub_printf("c=%d o=%d\n", entry->code, entry->offset);
|
||||
grub_printf ("c=%d o=%d\n", entry->code, entry->offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -392,7 +379,7 @@ read_section_as_string (struct font_file_section *section)
|
|||
grub_ssize_t ret;
|
||||
|
||||
str = grub_malloc (section->length + 1);
|
||||
if (! str)
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
ret = grub_file_read (section->file, str, section->length);
|
||||
|
@ -410,7 +397,8 @@ read_section_as_string (struct font_file_section *section)
|
|||
which is stored into *VALUE.
|
||||
Returns 0 upon success, nonzero upon failure. */
|
||||
static int
|
||||
read_section_as_short (struct font_file_section *section, grub_int16_t *value)
|
||||
read_section_as_short (struct font_file_section *section,
|
||||
grub_int16_t * value)
|
||||
{
|
||||
grub_uint16_t raw_value;
|
||||
|
||||
|
@ -420,8 +408,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value)
|
|||
"font file format error: section %c%c%c%c length "
|
||||
"is %d but should be 2",
|
||||
section->name[0], section->name[1],
|
||||
section->name[2], section->name[3],
|
||||
section->length);
|
||||
section->name[2], section->name[3], section->length);
|
||||
return 1;
|
||||
}
|
||||
if (grub_file_read (section->file, &raw_value, 2) != 2)
|
||||
|
@ -442,7 +429,7 @@ grub_font_load (const char *filename)
|
|||
grub_font_t font = 0;
|
||||
|
||||
#if FONT_DEBUG >= 1
|
||||
grub_printf("add_font(%s)\n", filename);
|
||||
grub_printf ("add_font(%s)\n", filename);
|
||||
#endif
|
||||
|
||||
file = grub_buffile_open (filename, 1024);
|
||||
|
@ -450,7 +437,7 @@ grub_font_load (const char *filename)
|
|||
goto fail;
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("file opened\n");
|
||||
grub_printf ("file opened\n");
|
||||
#endif
|
||||
|
||||
/* Read the FILE section. It indicates the file format. */
|
||||
|
@ -458,9 +445,10 @@ grub_font_load (const char *filename)
|
|||
goto fail;
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("opened FILE section\n");
|
||||
grub_printf ("opened FILE section\n");
|
||||
#endif
|
||||
if (grub_memcmp (section.name, section_names_file, 4) != 0)
|
||||
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FONT,
|
||||
"font file format error: 1st section must be FILE");
|
||||
|
@ -468,7 +456,7 @@ grub_font_load (const char *filename)
|
|||
}
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("section name ok\n");
|
||||
grub_printf ("section name ok\n");
|
||||
#endif
|
||||
if (section.length != 4)
|
||||
{
|
||||
|
@ -479,17 +467,17 @@ grub_font_load (const char *filename)
|
|||
}
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("section length ok\n");
|
||||
grub_printf ("section length ok\n");
|
||||
#endif
|
||||
/* Check the file format type code. */
|
||||
if (grub_file_read (file, magic, 4) != 4)
|
||||
goto fail;
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("read magic ok\n");
|
||||
grub_printf ("read magic ok\n");
|
||||
#endif
|
||||
|
||||
if (grub_memcmp (magic, pff2_magic, 4) != 0)
|
||||
if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x",
|
||||
magic[0], magic[1], magic[2], magic[3]);
|
||||
|
@ -497,19 +485,19 @@ grub_font_load (const char *filename)
|
|||
}
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("compare magic ok\n");
|
||||
grub_printf ("compare magic ok\n");
|
||||
#endif
|
||||
|
||||
/* Allocate the font object. */
|
||||
font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
|
||||
if (! font)
|
||||
if (!font)
|
||||
goto fail;
|
||||
|
||||
font_init (font);
|
||||
font->file = file;
|
||||
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("allocate font ok; loading font info\n");
|
||||
grub_printf ("allocate font ok; loading font info\n");
|
||||
#endif
|
||||
|
||||
/* Load the font information. */
|
||||
|
@ -524,23 +512,29 @@ grub_font_load (const char *filename)
|
|||
}
|
||||
|
||||
#if FONT_DEBUG >= 2
|
||||
grub_printf("opened section %c%c%c%c ok\n",
|
||||
grub_printf ("opened section %c%c%c%c ok\n",
|
||||
section.name[0], section.name[1],
|
||||
section.name[2], section.name[3]);
|
||||
#endif
|
||||
|
||||
if (grub_memcmp (section.name, section_names_font_name, 4) == 0)
|
||||
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
|
||||
{
|
||||
font->name = read_section_as_string (§ion);
|
||||
if (!font->name)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_point_size, 4) == 0)
|
||||
else if (grub_memcmp (section.name,
|
||||
FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
|
||||
1) == 0)
|
||||
{
|
||||
if (read_section_as_short (§ion, &font->point_size) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_weight, 4) == 0)
|
||||
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
|
||||
== 0)
|
||||
{
|
||||
char *wt;
|
||||
wt = read_section_as_string (§ion);
|
||||
|
@ -553,32 +547,47 @@ grub_font_load (const char *filename)
|
|||
font->weight = FONT_WEIGHT_BOLD;
|
||||
grub_free (wt);
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_max_char_width, 4) == 0)
|
||||
else if (grub_memcmp (section.name,
|
||||
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
|
||||
- 1) == 0)
|
||||
{
|
||||
if (read_section_as_short (§ion, &font->max_char_width) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_max_char_height, 4) == 0)
|
||||
else if (grub_memcmp (section.name,
|
||||
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
|
||||
- 1) == 0)
|
||||
{
|
||||
if (read_section_as_short (§ion, &font->max_char_height) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_ascent, 4) == 0)
|
||||
else if (grub_memcmp (section.name,
|
||||
FONT_FORMAT_SECTION_NAMES_ASCENT,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
|
||||
== 0)
|
||||
{
|
||||
if (read_section_as_short (§ion, &font->ascent) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_descent, 4) == 0)
|
||||
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
|
||||
== 0)
|
||||
{
|
||||
if (read_section_as_short (§ion, &font->descent) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_char_index, 4) == 0)
|
||||
else if (grub_memcmp (section.name,
|
||||
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
|
||||
1) == 0)
|
||||
{
|
||||
if (load_font_index (file, section.length, font) != 0)
|
||||
goto fail;
|
||||
}
|
||||
else if (grub_memcmp (section.name, section_names_data, 4) == 0)
|
||||
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA,
|
||||
sizeof (FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
|
||||
{
|
||||
/* When the DATA section marker is reached, we stop reading. */
|
||||
break;
|
||||
|
@ -587,7 +596,7 @@ grub_font_load (const char *filename)
|
|||
{
|
||||
/* Unhandled section type, simply skip past it. */
|
||||
#if FONT_DEBUG >= 3
|
||||
grub_printf("Unhandled section type, skipping.\n");
|
||||
grub_printf ("Unhandled section type, skipping.\n");
|
||||
#endif
|
||||
grub_off_t section_end = grub_file_tell (file) + section.length;
|
||||
if ((int) grub_file_seek (file, section_end) == -1)
|
||||
|
@ -595,7 +604,7 @@ grub_font_load (const char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
if (! font->name)
|
||||
if (!font->name)
|
||||
{
|
||||
grub_printf ("Note: Font has no name.\n");
|
||||
font->name = grub_strdup ("Unknown");
|
||||
|
@ -606,16 +615,13 @@ grub_font_load (const char *filename)
|
|||
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
|
||||
font->name,
|
||||
font->ascent, font->descent,
|
||||
font->max_char_width, font->max_char_height,
|
||||
font->num_chars);
|
||||
font->max_char_width, font->max_char_height, font->num_chars);
|
||||
#endif
|
||||
|
||||
if (font->max_char_width == 0
|
||||
|| font->max_char_height == 0
|
||||
|| font->num_chars == 0
|
||||
|| font->char_index == 0
|
||||
|| font->ascent == 0
|
||||
|| font->descent == 0)
|
||||
|| font->char_index == 0 || font->ascent == 0 || font->descent == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FONT,
|
||||
"invalid font file: missing some required data");
|
||||
|
@ -665,7 +671,7 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
|
|||
table = font->char_index;
|
||||
|
||||
/* Use BMP index if possible. */
|
||||
if (code < 0x10000)
|
||||
if (code < 0x10000 && font->bmp_idx)
|
||||
{
|
||||
if (font->bmp_idx[code] == 0xffff)
|
||||
return 0;
|
||||
|
@ -676,7 +682,7 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
|
|||
lo = 0;
|
||||
hi = font->num_chars - 1;
|
||||
|
||||
if (! table)
|
||||
if (!table)
|
||||
return 0;
|
||||
|
||||
while (lo <= hi)
|
||||
|
@ -716,7 +722,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
|
|||
/* Return cached glyph. */
|
||||
return index_entry->glyph;
|
||||
|
||||
if (! font->file)
|
||||
if (!font->file)
|
||||
/* No open file, can't load any glyphs. */
|
||||
return 0;
|
||||
|
||||
|
@ -727,11 +733,11 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
|
|||
grub_file_seek (font->file, index_entry->offset);
|
||||
|
||||
/* Read the glyph width, height, and baseline. */
|
||||
if (read_be_uint16(font->file, &width) != 0
|
||||
|| read_be_uint16(font->file, &height) != 0
|
||||
|| read_be_int16(font->file, &xoff) != 0
|
||||
|| read_be_int16(font->file, &yoff) != 0
|
||||
|| read_be_int16(font->file, &dwidth) != 0)
|
||||
if (read_be_uint16 (font->file, &width) != 0
|
||||
|| read_be_uint16 (font->file, &height) != 0
|
||||
|| read_be_int16 (font->file, &xoff) != 0
|
||||
|| read_be_int16 (font->file, &yoff) != 0
|
||||
|| read_be_int16 (font->file, &dwidth) != 0)
|
||||
{
|
||||
remove_font (font);
|
||||
return 0;
|
||||
|
@ -739,7 +745,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
|
|||
|
||||
len = (width * height + 7) / 8;
|
||||
glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
|
||||
if (! glyph)
|
||||
if (!glyph)
|
||||
{
|
||||
remove_font (font);
|
||||
return 0;
|
||||
|
@ -801,7 +807,7 @@ register_font (grub_font_t font)
|
|||
struct grub_font_node *node = 0;
|
||||
|
||||
node = grub_malloc (sizeof (struct grub_font_node));
|
||||
if (! node)
|
||||
if (!node)
|
||||
return 1;
|
||||
|
||||
node->value = font;
|
||||
|
@ -819,8 +825,7 @@ remove_font (grub_font_t font)
|
|||
struct grub_font_node **nextp, *cur;
|
||||
|
||||
for (nextp = &grub_font_list, cur = *nextp;
|
||||
cur;
|
||||
nextp = &cur->next, cur = cur->next)
|
||||
cur; nextp = &cur->next, cur = cur->next)
|
||||
{
|
||||
if (cur->value == font)
|
||||
{
|
||||
|
@ -859,7 +864,7 @@ grub_font_get (const char *font_name)
|
|||
return &null_font;
|
||||
}
|
||||
|
||||
/* Get the full name of the font. For instance, "Helvetica Bold 12". */
|
||||
/* Get the full name of the font. */
|
||||
const char *
|
||||
grub_font_get_name (grub_font_t font)
|
||||
{
|
||||
|
@ -924,7 +929,7 @@ grub_font_get_string_width (grub_font_t font, const char *str)
|
|||
const grub_uint8_t *ptr;
|
||||
|
||||
for (ptr = (const grub_uint8_t *) str, width = 0;
|
||||
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; )
|
||||
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
|
||||
{
|
||||
glyph = grub_font_get_glyph_with_fallback (font, code);
|
||||
width += glyph->device_width;
|
||||
|
@ -939,7 +944,8 @@ grub_font_get_string_width (grub_font_t font, const char *str)
|
|||
struct grub_font_glyph *
|
||||
grub_font_get_glyph (grub_font_t font, grub_uint32_t code)
|
||||
{
|
||||
struct grub_font_glyph *glyph;
|
||||
struct grub_font_glyph *glyph = 0;
|
||||
if (font)
|
||||
glyph = grub_font_get_glyph_internal (font, code);
|
||||
if (glyph == 0)
|
||||
{
|
||||
|
@ -957,7 +963,7 @@ grub_font_get_glyph (grub_font_t font, grub_uint32_t code)
|
|||
sizes are used so that tiny 8 point glyphs are not mixed into a string
|
||||
of 24 point text unless there is no other choice. */
|
||||
static int
|
||||
get_font_diversity(grub_font_t a, grub_font_t b)
|
||||
get_font_diversity (grub_font_t a, grub_font_t b)
|
||||
{
|
||||
int d;
|
||||
|
||||
|
@ -1048,9 +1054,8 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
|
|||
baseline of the character, while the x coordinate designates the left
|
||||
side location of the character. */
|
||||
grub_err_t
|
||||
grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y)
|
||||
grub_font_draw_glyph (struct grub_font_glyph * glyph,
|
||||
grub_video_color_t color, int left_x, int baseline_y)
|
||||
{
|
||||
struct grub_video_bitmap glyph_bitmap;
|
||||
|
||||
|
@ -1061,8 +1066,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
|||
glyph_bitmap.mode_info.width = glyph->width;
|
||||
glyph_bitmap.mode_info.height = glyph->height;
|
||||
glyph_bitmap.mode_info.mode_type =
|
||||
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
|
||||
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
|
||||
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
|
||||
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
|
||||
glyph_bitmap.mode_info.bpp = 1;
|
||||
|
||||
|
@ -1077,7 +1081,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
|||
glyph_bitmap.mode_info.bg_green = 0;
|
||||
glyph_bitmap.mode_info.bg_blue = 0;
|
||||
glyph_bitmap.mode_info.bg_alpha = 0;
|
||||
grub_video_unmap_color(color,
|
||||
grub_video_unmap_color (color,
|
||||
&glyph_bitmap.mode_info.fg_red,
|
||||
&glyph_bitmap.mode_info.fg_green,
|
||||
&glyph_bitmap.mode_info.fg_blue,
|
||||
|
@ -1090,8 +1094,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
|||
|
||||
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
bitmap_left, bitmap_top,
|
||||
0, 0,
|
||||
glyph->width, glyph->height);
|
||||
0, 0, glyph->width, glyph->height);
|
||||
}
|
||||
|
||||
/* Draw a UTF-8 string of text on the current video render target.
|
||||
|
@ -1101,8 +1104,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
|||
a glyph from another loaded font may be used instead. */
|
||||
grub_err_t
|
||||
grub_font_draw_string (const char *str, grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y)
|
||||
grub_video_color_t color, int left_x, int baseline_y)
|
||||
{
|
||||
int x;
|
||||
struct grub_font_glyph *glyph;
|
||||
|
@ -1110,15 +1112,13 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
|||
const grub_uint8_t *ptr;
|
||||
|
||||
for (ptr = (const grub_uint8_t *) str, x = left_x;
|
||||
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; )
|
||||
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
|
||||
{
|
||||
glyph = grub_font_get_glyph_with_fallback (font, code);
|
||||
if (grub_font_draw_glyph (glyph, color, x, baseline_y)
|
||||
!= GRUB_ERR_NONE)
|
||||
if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
x += glyph->device_width;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static grub_err_t
|
||||
loadfont_command (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
@ -56,20 +57,20 @@ lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
static grub_command_t cmd_loadfont, cmd_lsfonts;
|
||||
|
||||
GRUB_MOD_INIT(font_manager)
|
||||
GRUB_MOD_INIT(font)
|
||||
{
|
||||
grub_font_loader_init ();
|
||||
|
||||
cmd_loadfont =
|
||||
grub_register_command ("loadfont", loadfont_command,
|
||||
"FILE...",
|
||||
"Specify one or more font files to load.");
|
||||
N_("FILE..."),
|
||||
N_("Specify one or more font files to load."));
|
||||
cmd_lsfonts =
|
||||
grub_register_command ("lsfonts", lsfonts_command,
|
||||
0, "List the loaded fonts.");
|
||||
0, N_("List the loaded fonts."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(font_manager)
|
||||
GRUB_MOD_FINI(font)
|
||||
{
|
||||
/* TODO: Determine way to free allocated resources.
|
||||
Warning: possible pointer references could be in use. */
|
||||
|
|
|
@ -436,7 +436,8 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
grub_le_to_cpu32 (inode->blocks.indir_block)
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (inode->blocks.indir_block))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
@ -452,13 +453,15 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
grub_le_to_cpu32 (inode->blocks.double_indir_block)
|
||||
((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_le_to_cpu32 (indir[rblock / perblock])
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[rblock / perblock]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
|
1
fs/fat.c
1
fs/fat.c
|
@ -592,6 +592,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
|
|||
}
|
||||
|
||||
grub_free (filename);
|
||||
grub_free (unibuf);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
|
|
@ -173,12 +173,15 @@ static struct grub_disk_dev grub_pxe_dev =
|
|||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_pxefs_dir (grub_device_t device __attribute__ ((unused)),
|
||||
grub_pxefs_dir (grub_device_t device,
|
||||
const char *path __attribute__ ((unused)),
|
||||
int (*hook) (const char *filename,
|
||||
const struct grub_dirhook_info *info)
|
||||
__attribute__ ((unused)))
|
||||
{
|
||||
if (device->disk->dev->id != GRUB_DISK_DEVICE_PXE_ID)
|
||||
return grub_error (GRUB_ERR_IO, "not a pxe disk");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -194,6 +197,9 @@ grub_pxefs_open (struct grub_file *file, const char *name)
|
|||
struct grub_pxe_disk_data *disk_data = file->device->disk->data;
|
||||
grub_file_t file_int, bufio;
|
||||
|
||||
if (file->device->disk->dev->id != GRUB_DISK_DEVICE_PXE_ID)
|
||||
return grub_error (GRUB_ERR_IO, "not a pxe disk");
|
||||
|
||||
if (curr_file != 0)
|
||||
{
|
||||
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &c.c2);
|
||||
|
@ -562,21 +568,21 @@ GRUB_MOD_INIT(pxe)
|
|||
|
||||
buf = grub_xasprintf ("%d", grub_pxe_blksize);
|
||||
if (buf)
|
||||
grub_env_set ("net_pxe_blksize", buf);
|
||||
grub_env_set ("pxe_blksize", buf);
|
||||
grub_free (buf);
|
||||
|
||||
set_ip_env ("pxe_default_server", grub_pxe_default_server_ip);
|
||||
set_ip_env ("pxe_default_gateway", grub_pxe_default_gateway_ip);
|
||||
set_ip_env ("net_pxe_ip", grub_pxe_your_ip);
|
||||
grub_register_variable_hook ("net_pxe_default_server", 0,
|
||||
grub_register_variable_hook ("pxe_default_server", 0,
|
||||
grub_env_write_pxe_default_server);
|
||||
grub_register_variable_hook ("net_pxe_default_gateway", 0,
|
||||
grub_register_variable_hook ("pxe_default_gateway", 0,
|
||||
grub_env_write_pxe_default_gateway);
|
||||
|
||||
/* XXX: Is it possible to change IP in PXE? */
|
||||
grub_register_variable_hook ("net_pxe_ip", 0,
|
||||
grub_env_write_readonly);
|
||||
grub_register_variable_hook ("net_pxe_blksize", 0,
|
||||
grub_register_variable_hook ("pxe_blksize", 0,
|
||||
grub_env_write_pxe_blocksize);
|
||||
grub_disk_dev_register (&grub_pxe_dev);
|
||||
grub_fs_register (&grub_pxefs_fs);
|
||||
|
|
|
@ -136,7 +136,6 @@ struct grub_iso9660_data
|
|||
struct grub_iso9660_primary_voldesc voldesc;
|
||||
grub_disk_t disk;
|
||||
unsigned int first_sector;
|
||||
unsigned int length;
|
||||
int rockridge;
|
||||
int susp_skip;
|
||||
int joliet;
|
||||
|
@ -630,12 +629,16 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
|
|||
|
||||
if (dir->data->joliet)
|
||||
{
|
||||
char *oldname;
|
||||
char *oldname, *semicolon;
|
||||
|
||||
oldname = filename;
|
||||
filename = grub_iso9660_convert_string
|
||||
((grub_uint16_t *) oldname, dirent.namelen >> 1);
|
||||
|
||||
semicolon = grub_strrchr (filename, ';');
|
||||
if (semicolon)
|
||||
*semicolon = '\0';
|
||||
|
||||
if (filename_alloc)
|
||||
grub_free (oldname);
|
||||
|
||||
|
@ -744,7 +747,6 @@ grub_iso9660_open (struct grub_file *file, const char *name)
|
|||
goto fail;
|
||||
|
||||
data->first_sector = foundnode->blk;
|
||||
data->length = foundnode->size;
|
||||
|
||||
file->data = data;
|
||||
file->size = foundnode->size;
|
||||
|
|
1133
fs/nilfs2.c
Normal file
1133
fs/nilfs2.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -62,7 +62,7 @@
|
|||
|
||||
static grub_dl_t my_mod;
|
||||
|
||||
#define assert(boolean) real_assert (boolean, __FILE__, __LINE__)
|
||||
#define assert(boolean) real_assert (boolean, GRUB_FILE, __LINE__)
|
||||
static inline void
|
||||
real_assert (int boolean, const char *file, const int line)
|
||||
{
|
||||
|
@ -1189,7 +1189,8 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
(unsigned long long) (current_position - initial_position),
|
||||
(unsigned long) len);
|
||||
return current_position - initial_position;
|
||||
/*
|
||||
|
||||
#if 0
|
||||
switch (found.type)
|
||||
{
|
||||
case GRUB_REISERFS_DIRECT:
|
||||
|
@ -1232,7 +1233,8 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
return read_length;*/
|
||||
return read_length;
|
||||
#endif
|
||||
|
||||
fail:
|
||||
grub_free (indirect_block_ptr);
|
||||
|
|
31
fs/udf.c
31
fs/udf.c
|
@ -25,6 +25,7 @@
|
|||
#include <grub/dl.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/fshelp.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
#define GRUB_UDF_MAX_PDS 2
|
||||
#define GRUB_UDF_MAX_PMS 6
|
||||
|
@ -745,20 +746,42 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
|
|||
else
|
||||
{
|
||||
enum grub_fshelp_filetype type;
|
||||
char filename[dirent.file_ident_length + 1];
|
||||
grub_uint8_t raw[dirent.file_ident_length];
|
||||
grub_uint16_t utf16[dirent.file_ident_length - 1];
|
||||
grub_uint8_t filename[dirent.file_ident_length * 2];
|
||||
grub_size_t utf16len = 0;
|
||||
|
||||
type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
|
||||
(GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
|
||||
|
||||
if ((grub_udf_read_file (dir, 0, offset,
|
||||
dirent.file_ident_length, filename))
|
||||
dirent.file_ident_length,
|
||||
(char *) raw))
|
||||
!= dirent.file_ident_length)
|
||||
return 0;
|
||||
|
||||
filename[dirent.file_ident_length] = 0;
|
||||
if (hook (&filename[1], type, child))
|
||||
if (raw[0] == 8)
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = dirent.file_ident_length - 1;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = raw[i + 1];
|
||||
}
|
||||
if (raw[0] == 16)
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = (dirent.file_ident_length - 1) / 2;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
|
||||
}
|
||||
if (raw[0] == 8 || raw[0] == 16)
|
||||
{
|
||||
*grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0';
|
||||
|
||||
if (hook ((char *) filename, type, child))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Align to dword boundary. */
|
||||
offset = (offset + dirent.file_ident_length + 3) & (~3);
|
||||
|
|
72
genemuinit.sh
Normal file
72
genemuinit.sh
Normal file
|
@ -0,0 +1,72 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
|
||||
#
|
||||
# This gensymlist.sh is free software; the author
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
nm="$1"
|
||||
shift
|
||||
|
||||
cat <<EOF
|
||||
/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2005,2007 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_emu_init.h"
|
||||
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
void
|
||||
grub_init_all (void)
|
||||
{
|
||||
EOF
|
||||
|
||||
read mods
|
||||
for line in $mods; do
|
||||
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
|
||||
echo "grub_${line}_init ();" | sed 's,\.mod,,g;'
|
||||
fi
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
void
|
||||
grub_fini_all (void)
|
||||
{
|
||||
EOF
|
||||
|
||||
for line in $mods; do
|
||||
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
|
||||
echo "grub_${line}_fini ();" | sed 's,\.mod,,g;'
|
||||
fi
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
}
|
||||
EOF
|
52
genemuinitheader.sh
Normal file
52
genemuinitheader.sh
Normal file
|
@ -0,0 +1,52 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
||||
#
|
||||
# This gensymlist.sh is free software; the author
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
nm="$1"
|
||||
shift
|
||||
|
||||
cat <<EOF
|
||||
/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007 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/>.
|
||||
*/
|
||||
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
void grub_init_all (void);
|
||||
void grub_fini_all (void);
|
||||
EOF
|
||||
|
||||
read mods
|
||||
for line in $mods; do
|
||||
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
|
||||
echo "void grub_${line}_init (void);" | sed 's,\.mod,,g;'
|
||||
fi
|
||||
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
|
||||
echo "void grub_${line}_fini (void);" | sed 's,\.mod,,g;'
|
||||
fi
|
||||
done
|
|
@ -14,7 +14,7 @@
|
|||
### The configure script will replace these variables.
|
||||
|
||||
: ${srcdir=@srcdir@}
|
||||
: ${CC=@CC@}
|
||||
: ${CC=@TARGET_CC@}
|
||||
|
||||
u=
|
||||
grep "^#define HAVE_ASM_USCORE" config.h >/dev/null 2>&1 && u="_"
|
||||
|
|
56
genmk.rb
56
genmk.rb
|
@ -91,7 +91,7 @@ endif
|
|||
dir = File.dirname(src)
|
||||
|
||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||
-include #{dep}
|
||||
|
||||
"
|
||||
|
@ -143,27 +143,35 @@ mostlyclean-module-#{@name}.#{@rule_count}:
|
|||
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
|
||||
UNDSYMFILES += #{undsym}
|
||||
|
||||
ifeq ($(TARGET_NO_MODULES), yes)
|
||||
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
|
||||
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
||||
else
|
||||
ifneq ($(TARGET_APPLE_CC),1)
|
||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
|
||||
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
||||
else
|
||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
||||
-rm -f $@
|
||||
-rm -f $@.bin
|
||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
|
||||
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@
|
||||
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -ew2030 -ew2050 -nu -nd $@.bin $@
|
||||
-rm -f $@.bin
|
||||
endif
|
||||
endif
|
||||
|
||||
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str}
|
||||
|
||||
#{mod_obj}: #{mod_src}
|
||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
|
||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{mod_src}\\\" -c -o $@ $<
|
||||
|
||||
#{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
|
||||
|
@ -197,11 +205,11 @@ endif
|
|||
dir = File.dirname(src)
|
||||
|
||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||
-include #{dep}
|
||||
|
||||
clean-module-#{extra_target}.#{@rule_count}:
|
||||
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video}
|
||||
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video} #{terminal}
|
||||
|
||||
CLEAN_MODULE_TARGETS += clean-module-#{extra_target}.#{@rule_count}
|
||||
|
||||
|
@ -299,7 +307,7 @@ MOSTLYCLEAN_UTILITY_TARGETS += mostlyclean-utility-#{@name}.#{@rule_count}
|
|||
dir = File.dirname(src)
|
||||
|
||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -MD -c -o $@ $<
|
||||
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||
-include #{dep}
|
||||
|
||||
"
|
||||
|
@ -314,28 +322,32 @@ class Program
|
|||
end
|
||||
attr_reader :dir, :name
|
||||
|
||||
def print_tail()
|
||||
prefix = @name.to_var
|
||||
print "CLEANFILES += #{@name} $(#{prefix}_OBJECTS)
|
||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
|
||||
$(TARGET_CC) -Wl,-r,-d -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
|
||||
else
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
|
||||
$(TARGET_CC) -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
|
||||
endif
|
||||
|
||||
"
|
||||
end
|
||||
|
||||
def rule(sources)
|
||||
prefix = @name.to_var
|
||||
objs = sources.collect do |src|
|
||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
||||
prefix + '-' + src.to_obj
|
||||
end
|
||||
objs_str = objs.join(' ');
|
||||
deps = objs.collect {|obj| obj.suffix('d')}
|
||||
deps_str = deps.join(' ');
|
||||
|
||||
"CLEANFILES += #{@name} #{objs_str}
|
||||
MOSTLYCLEANFILES += #{deps_str}
|
||||
|
||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
$(STRIP) --strip-unneeded -K start -R .note -R .comment $@
|
||||
else
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
$(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@
|
||||
endif
|
||||
"MOSTLYCLEANFILES += #{deps_str}
|
||||
|
||||
" + objs.collect_with_index do |obj, i|
|
||||
src = sources[i]
|
||||
|
@ -346,10 +358,11 @@ endif
|
|||
dir = File.dirname(src)
|
||||
|
||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||
|
||||
-include #{dep}
|
||||
|
||||
#{prefix}_OBJECTS += #{obj}
|
||||
"
|
||||
end.join('')
|
||||
end
|
||||
|
@ -458,4 +471,5 @@ while l = gets
|
|||
|
||||
end
|
||||
utils.each {|util| util.print_tail()}
|
||||
programs.each {|program| program.print_tail()}
|
||||
|
||||
|
|
|
@ -32,13 +32,12 @@ FNR == 1 {
|
|||
else if ($1 != "__gnu_local_gp") {
|
||||
printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
|
||||
error++;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
# Output the result.
|
||||
END {
|
||||
if (error == 1)
|
||||
if (error >= 1)
|
||||
exit 1;
|
||||
|
||||
for (mod in modtab) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
### The configure script will replace these variables.
|
||||
|
||||
: ${srcdir=@srcdir@}
|
||||
: ${CC=@CC@}
|
||||
: ${CC=@TARGET_CC@}
|
||||
|
||||
|
||||
cat <<EOF
|
||||
|
@ -37,6 +37,7 @@ cat <<EOF
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
EOF
|
||||
|
||||
for i in $*; do
|
||||
|
|
48
gentrigtables.c
Normal file
48
gentrigtables.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Generate trigonometric function tables. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#include <grub/trig.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("#include <grub/types.h>\n");
|
||||
|
||||
#define TAB(op) \
|
||||
printf ("grub_int16_t grub_trig_" #op "tab[] =\n{"); \
|
||||
for (i = 0; i < GRUB_TRIG_ANGLE_MAX; i++) \
|
||||
{ \
|
||||
double x = i * 2 * M_PI / GRUB_TRIG_ANGLE_MAX; \
|
||||
if (i % 10 == 0) \
|
||||
printf ("\n "); \
|
||||
printf ("%d,", (int) (round (op (x) * GRUB_TRIG_FRACTION_SCALE))); \
|
||||
} \
|
||||
printf ("\n};\n")
|
||||
|
||||
TAB(sin);
|
||||
TAB(cos);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -279,13 +279,6 @@ grub_gettext_init_ext (const char *lang)
|
|||
|
||||
/* mo_file e.g.: /boot/grub/locale/ca.mo */
|
||||
|
||||
mo_file =
|
||||
grub_malloc (grub_strlen (locale_dir) + grub_strlen ("/") +
|
||||
grub_strlen (lang) + grub_strlen (".mo") + 1);
|
||||
|
||||
/* Warning: if changing some paths in the below line, change the grub_malloc
|
||||
contents below. */
|
||||
|
||||
mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, lang);
|
||||
if (!mo_file)
|
||||
return;
|
||||
|
|
144
gfxmenu/gfxmenu.c
Normal file
144
gfxmenu/gfxmenu.c
Normal file
|
@ -0,0 +1,144 @@
|
|||
/* gfxmenu.c - Graphical menu interface controller. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/gfxterm.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/menu_viewer.h>
|
||||
#include <grub/gfxmenu_model.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/time.h>
|
||||
|
||||
grub_gfxmenu_view_t cached_view;
|
||||
|
||||
static void
|
||||
grub_gfxmenu_viewer_fini (void *data __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
/* FIXME: Previously 't' changed to text menu is it necessary? */
|
||||
static grub_err_t
|
||||
grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
|
||||
{
|
||||
grub_gfxmenu_view_t view = NULL;
|
||||
const char *theme_path;
|
||||
struct grub_menu_viewer *instance;
|
||||
grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
theme_path = grub_env_get ("theme");
|
||||
if (! theme_path)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_gfxterm_fullscreen ();
|
||||
grub_error_pop ();
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no theme specified");
|
||||
}
|
||||
|
||||
instance = grub_zalloc (sizeof (*instance));
|
||||
if (!instance)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_gfxterm_fullscreen ();
|
||||
grub_error_pop ();
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
err = grub_video_get_info (&mode_info);
|
||||
if (err)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_gfxterm_fullscreen ();
|
||||
grub_error_pop ();
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!cached_view || grub_strcmp (cached_view->theme_path, theme_path) != 0
|
||||
|| cached_view->screen.width != mode_info.width
|
||||
|| cached_view->screen.height != mode_info.height)
|
||||
{
|
||||
grub_free (cached_view);
|
||||
/* Create the view. */
|
||||
cached_view = grub_gfxmenu_view_new (theme_path, mode_info.width,
|
||||
mode_info.height);
|
||||
}
|
||||
|
||||
if (! cached_view)
|
||||
{
|
||||
grub_free (instance);
|
||||
grub_error_push ();
|
||||
grub_gfxterm_fullscreen ();
|
||||
grub_error_pop ();
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
view = cached_view;
|
||||
|
||||
view->double_repaint = (mode_info.mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED)
|
||||
&& !(mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
|
||||
view->selected = entry;
|
||||
view->menu = menu;
|
||||
view->nested = nested;
|
||||
view->first_timeout = -1;
|
||||
|
||||
grub_gfxmenu_view_draw (view);
|
||||
|
||||
instance->data = view;
|
||||
instance->set_chosen_entry = grub_gfxmenu_set_chosen_entry;
|
||||
instance->fini = grub_gfxmenu_viewer_fini;
|
||||
instance->print_timeout = grub_gfxmenu_print_timeout;
|
||||
instance->clear_timeout = grub_gfxmenu_clear_timeout;
|
||||
|
||||
grub_menu_register_viewer (instance);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT (gfxmenu)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
if (grub_gfxmenu_try_hook && grub_strcmp (term->name, "gfxterm") == 0)
|
||||
{
|
||||
grub_gfxterm_fullscreen ();
|
||||
break;
|
||||
}
|
||||
|
||||
grub_gfxmenu_try_hook = grub_gfxmenu_try;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (gfxmenu)
|
||||
{
|
||||
grub_gfxmenu_view_destroy (cached_view);
|
||||
grub_gfxmenu_try_hook = NULL;
|
||||
}
|
412
gfxmenu/gui_box.c
Normal file
412
gfxmenu/gui_box.c
Normal file
|
@ -0,0 +1,412 @@
|
|||
/* gui_box.c - GUI container that stack components. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
|
||||
struct component_node
|
||||
{
|
||||
grub_gui_component_t component;
|
||||
struct component_node *next;
|
||||
struct component_node *prev;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_box *grub_gui_box_t;
|
||||
|
||||
typedef void (*layout_func_t) (grub_gui_box_t self, int modify_layout,
|
||||
unsigned *minimal_width,
|
||||
unsigned *minimal_height);
|
||||
|
||||
struct grub_gui_box
|
||||
{
|
||||
struct grub_gui_container container;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
|
||||
/* Doubly linked list of components with dummy head & tail nodes. */
|
||||
struct component_node chead;
|
||||
struct component_node ctail;
|
||||
|
||||
/* The layout function: differs for vertical and horizontal boxes. */
|
||||
layout_func_t layout_func;
|
||||
};
|
||||
|
||||
static void
|
||||
box_destroy (void *vself)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
struct component_node *cur;
|
||||
struct component_node *next;
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = next)
|
||||
{
|
||||
/* Copy the 'next' pointer, since we need it for the next iteration,
|
||||
and we're going to free the memory it is stored in. */
|
||||
next = cur->next;
|
||||
/* Destroy the child component. */
|
||||
cur->component->ops->destroy (cur->component);
|
||||
/* Free the linked list node. */
|
||||
grub_free (cur);
|
||||
}
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
box_get_id (void *vself)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
box_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return (grub_strcmp (type, "component") == 0
|
||||
|| grub_strcmp (type, "container") == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
layout_horizontally (grub_gui_box_t self, int modify_layout,
|
||||
unsigned *min_width, unsigned *min_height)
|
||||
{
|
||||
/* Start at the left (chead) and set the x coordinates as we go right. */
|
||||
/* All components have their width set to the box's width. */
|
||||
|
||||
struct component_node *cur;
|
||||
unsigned w = 0, mwfrac = 0, h = 0, x = 0;
|
||||
grub_fixed_signed_t wfrac = 0;
|
||||
int bogus_frac = 0;
|
||||
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
grub_gui_component_t c = cur->component;
|
||||
unsigned mw = 0, mh = 0;
|
||||
|
||||
if (c->ops->get_minimal_size)
|
||||
c->ops->get_minimal_size (c, &mw, &mh);
|
||||
|
||||
if (c->h > (signed) h)
|
||||
h = c->h;
|
||||
if (mh > h)
|
||||
h = mh;
|
||||
wfrac += c->wfrac;
|
||||
w += c->w;
|
||||
if (mw - c->w > 0)
|
||||
mwfrac += mw - c->w;
|
||||
}
|
||||
if (wfrac > GRUB_FIXED_1 || (w > 0 && wfrac == GRUB_FIXED_1))
|
||||
bogus_frac = 1;
|
||||
|
||||
if (min_width)
|
||||
{
|
||||
if (wfrac < GRUB_FIXED_1)
|
||||
*min_width = grub_fixed_sfs_divide (w, GRUB_FIXED_1 - wfrac);
|
||||
else
|
||||
*min_width = w;
|
||||
if (*min_width < w + mwfrac)
|
||||
*min_width = w + mwfrac;
|
||||
}
|
||||
if (min_height)
|
||||
*min_height = h;
|
||||
|
||||
if (!modify_layout)
|
||||
return;
|
||||
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
grub_video_rect_t r;
|
||||
grub_gui_component_t c = cur->component;
|
||||
unsigned mw = 0, mh = 0;
|
||||
|
||||
r.x = x;
|
||||
r.y = 0;
|
||||
r.height = h;
|
||||
|
||||
if (c->ops->get_minimal_size)
|
||||
c->ops->get_minimal_size (c, &mw, &mh);
|
||||
|
||||
r.width = c->w;
|
||||
if (!bogus_frac)
|
||||
r.width += grub_fixed_sfs_multiply (self->bounds.width, c->wfrac);
|
||||
|
||||
if (r.width < mw)
|
||||
r.width = mw;
|
||||
|
||||
c->ops->set_bounds (c, &r);
|
||||
|
||||
x += r.width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
layout_vertically (grub_gui_box_t self, int modify_layout,
|
||||
unsigned *min_width, unsigned *min_height)
|
||||
{
|
||||
/* Start at the top (chead) and set the y coordinates as we go rdown. */
|
||||
/* All components have their height set to the box's height. */
|
||||
|
||||
struct component_node *cur;
|
||||
unsigned h = 0, mhfrac = 0, w = 0, y = 0;
|
||||
grub_fixed_signed_t hfrac = 0;
|
||||
int bogus_frac = 0;
|
||||
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
grub_gui_component_t c = cur->component;
|
||||
unsigned mw = 0, mh = 0;
|
||||
|
||||
if (c->ops->get_minimal_size)
|
||||
c->ops->get_minimal_size (c, &mw, &mh);
|
||||
|
||||
if (c->w > (signed) w)
|
||||
w = c->w;
|
||||
if (mw > w)
|
||||
w = mw;
|
||||
hfrac += c->hfrac;
|
||||
h += c->h;
|
||||
if (mh - c->h > 0)
|
||||
mhfrac += mh - c->h;
|
||||
}
|
||||
if (hfrac > GRUB_FIXED_1 || (h > 0 && hfrac == GRUB_FIXED_1))
|
||||
bogus_frac = 1;
|
||||
|
||||
if (min_height)
|
||||
{
|
||||
if (hfrac < GRUB_FIXED_1)
|
||||
*min_height = grub_fixed_sfs_divide (h, GRUB_FIXED_1 - hfrac);
|
||||
else
|
||||
*min_height = h;
|
||||
if (*min_height < h + mhfrac)
|
||||
*min_height = h + mhfrac;
|
||||
}
|
||||
if (min_width)
|
||||
*min_width = w;
|
||||
|
||||
if (!modify_layout)
|
||||
return;
|
||||
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
grub_video_rect_t r;
|
||||
grub_gui_component_t c = cur->component;
|
||||
unsigned mw = 0, mh = 0;
|
||||
|
||||
r.x = 0;
|
||||
r.y = y;
|
||||
r.width = w;
|
||||
|
||||
if (c->ops->get_minimal_size)
|
||||
c->ops->get_minimal_size (c, &mw, &mh);
|
||||
|
||||
r.height = c->h;
|
||||
if (!bogus_frac)
|
||||
r.height += grub_fixed_sfs_multiply (self->bounds.height, c->hfrac);
|
||||
|
||||
if (r.height < mh)
|
||||
r.height = mh;
|
||||
|
||||
c->ops->set_bounds (c, &r);
|
||||
|
||||
y += r.height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
box_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
struct component_node *cur;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
grub_gui_component_t comp = cur->component;
|
||||
comp->ops->paint (comp, region);
|
||||
}
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
box_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
box_get_parent (void *vself)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
box_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
self->layout_func (self, 1, 0, 0); /* Relayout the children. */
|
||||
}
|
||||
|
||||
static void
|
||||
box_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
/* The box's preferred size is based on the preferred sizes
|
||||
of its children. */
|
||||
static void
|
||||
box_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
self->layout_func (self, 0, width, height); /* Just calculate the size. */
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
box_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
{
|
||||
self->id = grub_strdup (value);
|
||||
if (! self->id)
|
||||
return grub_errno;
|
||||
}
|
||||
else
|
||||
self->id = 0;
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
box_add (void *vself, grub_gui_component_t comp)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
struct component_node *node;
|
||||
node = grub_malloc (sizeof (*node));
|
||||
if (! node)
|
||||
return; /* Note: probably should handle the error. */
|
||||
node->component = comp;
|
||||
/* Insert the node before the tail. */
|
||||
node->prev = self->ctail.prev;
|
||||
node->prev->next = node;
|
||||
node->next = &self->ctail;
|
||||
node->next->prev = node;
|
||||
|
||||
comp->ops->set_parent (comp, (grub_gui_container_t) self);
|
||||
self->layout_func (self, 1, 0, 0); /* Relayout the children. */
|
||||
}
|
||||
|
||||
static void
|
||||
box_remove (void *vself, grub_gui_component_t comp)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
struct component_node *cur;
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
{
|
||||
if (cur->component == comp)
|
||||
{
|
||||
/* Unlink 'cur' from the list. */
|
||||
cur->prev->next = cur->next;
|
||||
cur->next->prev = cur->prev;
|
||||
/* Free the node's memory (but don't destroy the component). */
|
||||
grub_free (cur);
|
||||
/* Must not loop again, since 'cur' would be dereferenced! */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
box_iterate_children (void *vself,
|
||||
grub_gui_component_callback cb, void *userdata)
|
||||
{
|
||||
grub_gui_box_t self = vself;
|
||||
struct component_node *cur;
|
||||
for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
|
||||
cb (cur->component, userdata);
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops box_comp_ops =
|
||||
{
|
||||
.destroy = box_destroy,
|
||||
.get_id = box_get_id,
|
||||
.is_instance = box_is_instance,
|
||||
.paint = box_paint,
|
||||
.set_parent = box_set_parent,
|
||||
.get_parent = box_get_parent,
|
||||
.set_bounds = box_set_bounds,
|
||||
.get_bounds = box_get_bounds,
|
||||
.get_minimal_size = box_get_minimal_size,
|
||||
.set_property = box_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_container_ops box_ops =
|
||||
{
|
||||
.add = box_add,
|
||||
.remove = box_remove,
|
||||
.iterate_children = box_iterate_children
|
||||
};
|
||||
|
||||
/* Box constructor. Specify the appropriate layout function to create
|
||||
a horizontal or vertical stacking box. */
|
||||
static grub_gui_box_t
|
||||
box_new (layout_func_t layout_func)
|
||||
{
|
||||
grub_gui_box_t box;
|
||||
box = grub_zalloc (sizeof (*box));
|
||||
if (! box)
|
||||
return 0;
|
||||
box->container.ops = &box_ops;
|
||||
box->container.component.ops = &box_comp_ops;
|
||||
box->chead.next = &box->ctail;
|
||||
box->ctail.prev = &box->chead;
|
||||
box->layout_func = layout_func;
|
||||
return box;
|
||||
}
|
||||
|
||||
/* Create a new container that stacks its child components horizontally,
|
||||
from left to right. Each child get a width corresponding to its
|
||||
preferred width. The height of each child is set the maximum of the
|
||||
preferred heights of all children. */
|
||||
grub_gui_container_t
|
||||
grub_gui_hbox_new (void)
|
||||
{
|
||||
return (grub_gui_container_t) box_new (layout_horizontally);
|
||||
}
|
||||
|
||||
/* Create a new container that stacks its child components verticallyj,
|
||||
from top to bottom. Each child get a height corresponding to its
|
||||
preferred height. The width of each child is set the maximum of the
|
||||
preferred widths of all children. */
|
||||
grub_gui_container_t
|
||||
grub_gui_vbox_new (void)
|
||||
{
|
||||
return (grub_gui_container_t) box_new (layout_vertically);
|
||||
}
|
267
gfxmenu/gui_canvas.c
Normal file
267
gfxmenu/gui_canvas.c
Normal file
|
@ -0,0 +1,267 @@
|
|||
/* gui_canvas.c - GUI container allowing manually placed components. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
|
||||
/* TODO Add layering so that components can be properly overlaid. */
|
||||
|
||||
struct component_node
|
||||
{
|
||||
grub_gui_component_t component;
|
||||
struct component_node *next;
|
||||
};
|
||||
|
||||
struct grub_gui_canvas
|
||||
{
|
||||
struct grub_gui_container container;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
/* Component list (dummy head node). */
|
||||
struct component_node components;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_canvas *grub_gui_canvas_t;
|
||||
|
||||
static void
|
||||
canvas_destroy (void *vself)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
struct component_node *cur;
|
||||
struct component_node *next;
|
||||
for (cur = self->components.next; cur; cur = next)
|
||||
{
|
||||
/* Copy the 'next' pointer, since we need it for the next iteration,
|
||||
and we're going to free the memory it is stored in. */
|
||||
next = cur->next;
|
||||
/* Destroy the child component. */
|
||||
cur->component->ops->destroy (cur->component);
|
||||
/* Free the linked list node. */
|
||||
grub_free (cur);
|
||||
}
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
canvas_get_id (void *vself)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
canvas_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return (grub_strcmp (type, "component") == 0
|
||||
|| grub_strcmp (type, "container") == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
struct component_node *cur;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
for (cur = self->components.next; cur; cur = cur->next)
|
||||
{
|
||||
grub_video_rect_t r;
|
||||
grub_gui_component_t comp;
|
||||
signed x, y, w, h;
|
||||
|
||||
comp = cur->component;
|
||||
|
||||
w = grub_fixed_sfs_multiply (self->bounds.width, comp->wfrac) + comp->w;
|
||||
h = grub_fixed_sfs_multiply (self->bounds.height, comp->hfrac) + comp->h;
|
||||
x = grub_fixed_sfs_multiply (self->bounds.width, comp->xfrac) + comp->x;
|
||||
y = grub_fixed_sfs_multiply (self->bounds.height, comp->yfrac) + comp->y;
|
||||
|
||||
if (comp->ops->get_minimal_size)
|
||||
{
|
||||
unsigned mw;
|
||||
unsigned mh;
|
||||
comp->ops->get_minimal_size (comp, &mw, &mh);
|
||||
if (w < (signed) mw)
|
||||
w = mw;
|
||||
if (h < (signed) mh)
|
||||
h = mh;
|
||||
}
|
||||
|
||||
/* Sanity checks. */
|
||||
if (w <= 0)
|
||||
w = 32;
|
||||
if (h <= 0)
|
||||
h = 32;
|
||||
|
||||
if (x >= (signed) self->bounds.width)
|
||||
x = self->bounds.width - 32;
|
||||
if (y >= (signed) self->bounds.height)
|
||||
y = self->bounds.height - 32;
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
|
||||
if (x + w >= (signed) self->bounds.width)
|
||||
w = self->bounds.width - x;
|
||||
if (y + h >= (signed) self->bounds.height)
|
||||
h = self->bounds.height - y;
|
||||
|
||||
r.x = x;
|
||||
r.y = y;
|
||||
r.width = w;
|
||||
r.height = h;
|
||||
comp->ops->set_bounds (comp, &r);
|
||||
|
||||
/* Paint the child. */
|
||||
if (grub_video_have_common_points (region, &r))
|
||||
comp->ops->paint (comp, region);
|
||||
}
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
canvas_get_parent (void *vself)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
canvas_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
{
|
||||
self->id = grub_strdup (value);
|
||||
if (! self->id)
|
||||
return grub_errno;
|
||||
}
|
||||
else
|
||||
self->id = 0;
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_add (void *vself, grub_gui_component_t comp)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
struct component_node *node;
|
||||
node = grub_malloc (sizeof (*node));
|
||||
if (! node)
|
||||
return; /* Note: probably should handle the error. */
|
||||
node->component = comp;
|
||||
node->next = self->components.next;
|
||||
self->components.next = node;
|
||||
comp->ops->set_parent (comp, (grub_gui_container_t) self);
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_remove (void *vself, grub_gui_component_t comp)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
struct component_node *cur;
|
||||
struct component_node *prev;
|
||||
prev = &self->components;
|
||||
for (cur = self->components.next; cur; prev = cur, cur = cur->next)
|
||||
{
|
||||
if (cur->component == comp)
|
||||
{
|
||||
/* Unlink 'cur' from the list. */
|
||||
prev->next = cur->next;
|
||||
/* Free the node's memory (but don't destroy the component). */
|
||||
grub_free (cur);
|
||||
/* Must not loop again, since 'cur' would be dereferenced! */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
canvas_iterate_children (void *vself,
|
||||
grub_gui_component_callback cb, void *userdata)
|
||||
{
|
||||
grub_gui_canvas_t self = vself;
|
||||
struct component_node *cur;
|
||||
for (cur = self->components.next; cur; cur = cur->next)
|
||||
cb (cur->component, userdata);
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops canvas_comp_ops =
|
||||
{
|
||||
.destroy = canvas_destroy,
|
||||
.get_id = canvas_get_id,
|
||||
.is_instance = canvas_is_instance,
|
||||
.paint = canvas_paint,
|
||||
.set_parent = canvas_set_parent,
|
||||
.get_parent = canvas_get_parent,
|
||||
.set_bounds = canvas_set_bounds,
|
||||
.get_bounds = canvas_get_bounds,
|
||||
.set_property = canvas_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_container_ops canvas_ops =
|
||||
{
|
||||
.add = canvas_add,
|
||||
.remove = canvas_remove,
|
||||
.iterate_children = canvas_iterate_children
|
||||
};
|
||||
|
||||
grub_gui_container_t
|
||||
grub_gui_canvas_new (void)
|
||||
{
|
||||
grub_gui_canvas_t canvas;
|
||||
canvas = grub_zalloc (sizeof (*canvas));
|
||||
if (! canvas)
|
||||
return 0;
|
||||
canvas->container.ops = &canvas_ops;
|
||||
canvas->container.component.ops = &canvas_comp_ops;
|
||||
return (grub_gui_container_t) canvas;
|
||||
}
|
308
gfxmenu/gui_circular_progress.c
Normal file
308
gfxmenu/gui_circular_progress.c
Normal file
|
@ -0,0 +1,308 @@
|
|||
/* gui_circular_process.c - GUI circular progress indicator component. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/trig.h>
|
||||
|
||||
struct grub_gui_circular_progress
|
||||
{
|
||||
struct grub_gui_progress progress;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
int start;
|
||||
int end;
|
||||
int value;
|
||||
int num_ticks;
|
||||
int start_angle;
|
||||
int ticks_disappear;
|
||||
char *theme_dir;
|
||||
int need_to_load_pixmaps;
|
||||
char *center_file;
|
||||
char *tick_file;
|
||||
struct grub_video_bitmap *center_bitmap;
|
||||
struct grub_video_bitmap *tick_bitmap;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_circular_progress *circular_progress_t;
|
||||
|
||||
static void
|
||||
circprog_destroy (void *vself)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
circprog_get_id (void *vself)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
circprog_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return grub_strcmp (type, "component") == 0;
|
||||
}
|
||||
|
||||
static struct grub_video_bitmap *
|
||||
load_bitmap (const char *dir, const char *file)
|
||||
{
|
||||
struct grub_video_bitmap *bitmap;
|
||||
char *abspath;
|
||||
|
||||
/* Check arguments. */
|
||||
if (! dir || ! file)
|
||||
return 0;
|
||||
|
||||
/* Resolve to an absolute path. */
|
||||
abspath = grub_resolve_relative_path (dir, file);
|
||||
if (! abspath)
|
||||
return 0;
|
||||
|
||||
/* Load the image. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_video_bitmap_load (&bitmap, abspath);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
grub_free (abspath);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static int
|
||||
check_pixmaps (circular_progress_t self)
|
||||
{
|
||||
if (self->need_to_load_pixmaps)
|
||||
{
|
||||
if (self->center_bitmap)
|
||||
grub_video_bitmap_destroy (self->center_bitmap);
|
||||
self->center_bitmap = load_bitmap (self->theme_dir, self->center_file);
|
||||
self->tick_bitmap = load_bitmap (self->theme_dir, self->tick_file);
|
||||
self->need_to_load_pixmaps = 0;
|
||||
}
|
||||
|
||||
return (self->center_bitmap != 0 && self->tick_bitmap != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
circprog_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
|
||||
if (! self->visible)
|
||||
return;
|
||||
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
if (! check_pixmaps (self))
|
||||
return;
|
||||
|
||||
grub_video_rect_t vpsave;
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
|
||||
int width = self->bounds.width;
|
||||
int height = self->bounds.height;
|
||||
int center_width = grub_video_bitmap_get_width (self->center_bitmap);
|
||||
int center_height = grub_video_bitmap_get_height (self->center_bitmap);
|
||||
int tick_width = grub_video_bitmap_get_width (self->tick_bitmap);
|
||||
int tick_height = grub_video_bitmap_get_height (self->tick_bitmap);
|
||||
grub_video_blit_bitmap (self->center_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
(width - center_width) / 2,
|
||||
(height - center_height) / 2, 0, 0,
|
||||
center_width, center_height);
|
||||
|
||||
int radius = width / 2 - tick_width / 2 - 1;
|
||||
int nticks;
|
||||
int tick_begin;
|
||||
int tick_end;
|
||||
if (self->end == self->start)
|
||||
nticks = 0;
|
||||
else
|
||||
nticks = (self->num_ticks
|
||||
* (self->value - self->start)
|
||||
/ (self->end - self->start));
|
||||
/* Do ticks appear or disappear as the value approached the end? */
|
||||
if (self->ticks_disappear)
|
||||
{
|
||||
tick_begin = nticks;
|
||||
tick_end = self->num_ticks - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tick_begin = 0;
|
||||
tick_end = nticks - 1;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = tick_begin; i < tick_end; i++)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int angle;
|
||||
|
||||
/* Calculate the location of the tick. */
|
||||
angle = self->start_angle + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
|
||||
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
|
||||
/* Adjust (x,y) so the tick is centered. */
|
||||
x -= tick_width / 2;
|
||||
y -= tick_height / 2;
|
||||
|
||||
/* Draw the tick. */
|
||||
grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
x, y, 0, 0, tick_width, tick_height);
|
||||
}
|
||||
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
circprog_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
circprog_get_parent (void *vself)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
circprog_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
circprog_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
circprog_set_state (void *vself, int visible, int start,
|
||||
int current, int end)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
self->visible = visible;
|
||||
self->start = start;
|
||||
self->value = current;
|
||||
self->end = end;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
circprog_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
circular_progress_t self = vself;
|
||||
if (grub_strcmp (name, "num_ticks") == 0)
|
||||
{
|
||||
self->num_ticks = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "start_angle") == 0)
|
||||
{
|
||||
self->start_angle = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "ticks_disappear") == 0)
|
||||
{
|
||||
self->ticks_disappear = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "center_bitmap") == 0)
|
||||
{
|
||||
self->need_to_load_pixmaps = 1;
|
||||
grub_free (self->center_file);
|
||||
self->center_file = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "tick_bitmap") == 0)
|
||||
{
|
||||
self->need_to_load_pixmaps = 1;
|
||||
grub_free (self->tick_file);
|
||||
self->tick_file = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "theme_dir") == 0)
|
||||
{
|
||||
self->need_to_load_pixmaps = 1;
|
||||
grub_free (self->theme_dir);
|
||||
self->theme_dir = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||
== 0)
|
||||
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||
circprog_set_state);
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops circprog_ops =
|
||||
{
|
||||
.destroy = circprog_destroy,
|
||||
.get_id = circprog_get_id,
|
||||
.is_instance = circprog_is_instance,
|
||||
.paint = circprog_paint,
|
||||
.set_parent = circprog_set_parent,
|
||||
.get_parent = circprog_get_parent,
|
||||
.set_bounds = circprog_set_bounds,
|
||||
.get_bounds = circprog_get_bounds,
|
||||
.set_property = circprog_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_progress_ops circprog_prog_ops =
|
||||
{
|
||||
.set_state = circprog_set_state
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_circular_progress_new (void)
|
||||
{
|
||||
circular_progress_t self;
|
||||
self = grub_zalloc (sizeof (*self));
|
||||
if (! self)
|
||||
return 0;
|
||||
self->progress.ops = &circprog_prog_ops;
|
||||
self->progress.component.ops = &circprog_ops;
|
||||
self->visible = 1;
|
||||
self->num_ticks = 64;
|
||||
self->start_angle = -64;
|
||||
|
||||
return (grub_gui_component_t) self;
|
||||
}
|
269
gfxmenu/gui_image.c
Normal file
269
gfxmenu/gui_image.c
Normal file
|
@ -0,0 +1,269 @@
|
|||
/* gui_image.c - GUI component to display an image. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
|
||||
struct grub_gui_image
|
||||
{
|
||||
struct grub_gui_component component;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
char *theme_dir;
|
||||
struct grub_video_bitmap *raw_bitmap;
|
||||
struct grub_video_bitmap *bitmap;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_image *grub_gui_image_t;
|
||||
|
||||
static void
|
||||
image_destroy (void *vself)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
|
||||
/* Free the scaled bitmap, unless it's a reference to the raw bitmap. */
|
||||
if (self->bitmap && (self->bitmap != self->raw_bitmap))
|
||||
grub_video_bitmap_destroy (self->bitmap);
|
||||
if (self->raw_bitmap)
|
||||
grub_video_bitmap_destroy (self->raw_bitmap);
|
||||
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
image_get_id (void *vself)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
image_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return grub_strcmp (type, "component") == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
image_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
if (! self->bitmap)
|
||||
return;
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
grub_video_blit_bitmap (self->bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
0, 0, 0, 0,
|
||||
grub_video_bitmap_get_width (self->bitmap),
|
||||
grub_video_bitmap_get_height (self->bitmap));
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
image_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
image_get_parent (void *vself)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
rescale_image (grub_gui_image_t self)
|
||||
{
|
||||
if (! self->raw_bitmap)
|
||||
{
|
||||
if (self->bitmap)
|
||||
{
|
||||
grub_video_bitmap_destroy (self->bitmap);
|
||||
self->bitmap = 0;
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
unsigned width = self->bounds.width;
|
||||
unsigned height = self->bounds.height;
|
||||
|
||||
if (self->bitmap
|
||||
&& (grub_video_bitmap_get_width (self->bitmap) == width)
|
||||
&& (grub_video_bitmap_get_height (self->bitmap) == height))
|
||||
{
|
||||
/* Nothing to do; already the right size. */
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Free any old scaled bitmap,
|
||||
*unless* it's a reference to the raw bitmap. */
|
||||
if (self->bitmap && (self->bitmap != self->raw_bitmap))
|
||||
grub_video_bitmap_destroy (self->bitmap);
|
||||
|
||||
self->bitmap = 0;
|
||||
|
||||
/* Create a scaled bitmap, unless the requested size is the same
|
||||
as the raw size -- in that case a reference is made. */
|
||||
if (grub_video_bitmap_get_width (self->raw_bitmap) == width
|
||||
&& grub_video_bitmap_get_height (self->raw_bitmap) == height)
|
||||
{
|
||||
self->bitmap = self->raw_bitmap;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Don't scale to an invalid size. */
|
||||
if (width == 0 || height == 0)
|
||||
return grub_errno;
|
||||
|
||||
/* Create the scaled bitmap. */
|
||||
grub_video_bitmap_create_scaled (&self->bitmap,
|
||||
width,
|
||||
height,
|
||||
self->raw_bitmap,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_error (grub_errno, "failed to scale bitmap for image component");
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
image_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
rescale_image (self);
|
||||
}
|
||||
|
||||
static void
|
||||
image_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
/* FIXME: inform rendering system it's not forced minimum. */
|
||||
static void
|
||||
image_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
|
||||
if (self->raw_bitmap)
|
||||
{
|
||||
*width = grub_video_bitmap_get_width (self->raw_bitmap);
|
||||
*height = grub_video_bitmap_get_height (self->raw_bitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
load_image (grub_gui_image_t self, const char *path)
|
||||
{
|
||||
struct grub_video_bitmap *bitmap;
|
||||
if (grub_video_bitmap_load (&bitmap, path) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
if (self->bitmap && (self->bitmap != self->raw_bitmap))
|
||||
grub_video_bitmap_destroy (self->bitmap);
|
||||
if (self->raw_bitmap)
|
||||
grub_video_bitmap_destroy (self->raw_bitmap);
|
||||
|
||||
self->raw_bitmap = bitmap;
|
||||
return rescale_image (self);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
image_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gui_image_t self = vself;
|
||||
if (grub_strcmp (name, "theme_dir") == 0)
|
||||
{
|
||||
grub_free (self->theme_dir);
|
||||
self->theme_dir = grub_strdup (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "file") == 0)
|
||||
{
|
||||
char *absvalue;
|
||||
grub_err_t err;
|
||||
|
||||
/* Resolve to an absolute path. */
|
||||
if (! self->theme_dir)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unspecified theme_dir");
|
||||
absvalue = grub_resolve_relative_path (self->theme_dir, value);
|
||||
if (! absvalue)
|
||||
return grub_errno;
|
||||
|
||||
err = load_image (self, absvalue);
|
||||
grub_free (absvalue);
|
||||
|
||||
return err;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops image_ops =
|
||||
{
|
||||
.destroy = image_destroy,
|
||||
.get_id = image_get_id,
|
||||
.is_instance = image_is_instance,
|
||||
.paint = image_paint,
|
||||
.set_parent = image_set_parent,
|
||||
.get_parent = image_get_parent,
|
||||
.set_bounds = image_set_bounds,
|
||||
.get_bounds = image_get_bounds,
|
||||
.get_minimal_size = image_get_minimal_size,
|
||||
.set_property = image_set_property
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_image_new (void)
|
||||
{
|
||||
grub_gui_image_t image;
|
||||
image = grub_zalloc (sizeof (*image));
|
||||
if (! image)
|
||||
return 0;
|
||||
image->component.ops = &image_ops;
|
||||
return (grub_gui_component_t) image;
|
||||
}
|
||||
|
254
gfxmenu/gui_label.c
Normal file
254
gfxmenu/gui_label.c
Normal file
|
@ -0,0 +1,254 @@
|
|||
/* gui_label.c - GUI component to display a line of text. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
|
||||
static const char *align_options[] =
|
||||
{
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
0
|
||||
};
|
||||
|
||||
enum align_mode {
|
||||
align_left,
|
||||
align_center,
|
||||
align_right
|
||||
};
|
||||
|
||||
struct grub_gui_label
|
||||
{
|
||||
struct grub_gui_component comp;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
char *text;
|
||||
char *template;
|
||||
grub_font_t font;
|
||||
grub_gui_color_t color;
|
||||
int value;
|
||||
enum align_mode align;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_label *grub_gui_label_t;
|
||||
|
||||
static void
|
||||
label_destroy (void *vself)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self->text);
|
||||
grub_free (self->template);
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
label_get_id (void *vself)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
label_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return grub_strcmp (type, "component") == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
label_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
|
||||
if (! self->visible)
|
||||
return;
|
||||
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
/* Calculate the starting x coordinate. */
|
||||
int left_x;
|
||||
if (self->align == align_left)
|
||||
left_x = 0;
|
||||
else if (self->align == align_center)
|
||||
left_x = ((self->bounds.width
|
||||
- grub_font_get_string_width (self->font, self->text))
|
||||
) / 2;
|
||||
else if (self->align == align_right)
|
||||
left_x = (self->bounds.width
|
||||
- grub_font_get_string_width (self->font, self->text));
|
||||
else
|
||||
return; /* Invalid alignment. */
|
||||
|
||||
grub_video_rect_t vpsave;
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
grub_font_draw_string (self->text,
|
||||
self->font,
|
||||
grub_gui_map_color (self->color),
|
||||
left_x,
|
||||
grub_font_get_ascent (self->font));
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
label_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
label_get_parent (void *vself)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
label_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
label_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
*width = grub_font_get_string_width (self->font, self->text);
|
||||
*height = (grub_font_get_ascent (self->font)
|
||||
+ grub_font_get_descent (self->font));
|
||||
}
|
||||
|
||||
static void
|
||||
label_set_state (void *vself, int visible, int start __attribute__ ((unused)),
|
||||
int current, int end __attribute__ ((unused)))
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
self->value = -current;
|
||||
self->visible = visible;
|
||||
grub_free (self->text);
|
||||
self->text = grub_xasprintf (self->template ? : "%d", self->value);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
label_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gui_label_t self = vself;
|
||||
if (grub_strcmp (name, "text") == 0)
|
||||
{
|
||||
grub_free (self->text);
|
||||
grub_free (self->template);
|
||||
if (! value)
|
||||
{
|
||||
self->template = NULL;
|
||||
self->text = grub_strdup ("");
|
||||
}
|
||||
else
|
||||
{
|
||||
self->template = grub_strdup (value);
|
||||
self->text = grub_xasprintf (value, self->value);
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "font") == 0)
|
||||
{
|
||||
self->font = grub_font_get (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->color);
|
||||
}
|
||||
else if (grub_strcmp (name, "align") == 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; align_options[i]; i++)
|
||||
{
|
||||
if (grub_strcmp (align_options[i], value) == 0)
|
||||
{
|
||||
self->align = i; /* Set the alignment mode. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "visible") == 0)
|
||||
{
|
||||
self->visible = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||
== 0)
|
||||
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||
label_set_state);
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops label_ops =
|
||||
{
|
||||
.destroy = label_destroy,
|
||||
.get_id = label_get_id,
|
||||
.is_instance = label_is_instance,
|
||||
.paint = label_paint,
|
||||
.set_parent = label_set_parent,
|
||||
.get_parent = label_get_parent,
|
||||
.set_bounds = label_set_bounds,
|
||||
.get_bounds = label_get_bounds,
|
||||
.get_minimal_size = label_get_minimal_size,
|
||||
.set_property = label_set_property
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_label_new (void)
|
||||
{
|
||||
grub_gui_label_t label;
|
||||
label = grub_zalloc (sizeof (*label));
|
||||
if (! label)
|
||||
return 0;
|
||||
label->comp.ops = &label_ops;
|
||||
label->visible = 1;
|
||||
label->text = grub_strdup ("");
|
||||
label->font = grub_font_get ("Unknown Regular 16");
|
||||
label->color.red = 0;
|
||||
label->color.green = 0;
|
||||
label->color.blue = 0;
|
||||
label->color.alpha = 255;
|
||||
label->align = align_left;
|
||||
return (grub_gui_component_t) label;
|
||||
}
|
612
gfxmenu/gui_list.c
Normal file
612
gfxmenu/gui_list.c
Normal file
|
@ -0,0 +1,612 @@
|
|||
/* gui_list.c - GUI component to display a selectable list of items. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
|
||||
struct grub_gui_list_impl
|
||||
{
|
||||
struct grub_gui_list list;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
|
||||
int icon_width;
|
||||
int icon_height;
|
||||
int item_height;
|
||||
int item_padding;
|
||||
int item_icon_space;
|
||||
int item_spacing;
|
||||
grub_font_t item_font;
|
||||
grub_font_t selected_item_font;
|
||||
grub_gui_color_t item_color;
|
||||
int selected_item_color_set;
|
||||
grub_gui_color_t selected_item_color;
|
||||
|
||||
int draw_scrollbar;
|
||||
int need_to_recreate_scrollbar;
|
||||
char *scrollbar_frame_pattern;
|
||||
char *scrollbar_thumb_pattern;
|
||||
grub_gfxmenu_box_t scrollbar_frame;
|
||||
grub_gfxmenu_box_t scrollbar_thumb;
|
||||
int scrollbar_width;
|
||||
|
||||
int first_shown_index;
|
||||
|
||||
int need_to_recreate_boxes;
|
||||
char *theme_dir;
|
||||
char *menu_box_pattern;
|
||||
char *selected_item_box_pattern;
|
||||
grub_gfxmenu_box_t menu_box;
|
||||
grub_gfxmenu_box_t selected_item_box;
|
||||
|
||||
grub_gfxmenu_icon_manager_t icon_manager;
|
||||
|
||||
grub_gfxmenu_view_t view;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_list_impl *list_impl_t;
|
||||
|
||||
static void
|
||||
list_destroy (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
|
||||
grub_free (self->theme_dir);
|
||||
grub_free (self->menu_box_pattern);
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
if (self->menu_box)
|
||||
self->menu_box->destroy (self->menu_box);
|
||||
if (self->selected_item_box)
|
||||
self->selected_item_box->destroy (self->selected_item_box);
|
||||
if (self->icon_manager)
|
||||
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
|
||||
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static int
|
||||
get_num_shown_items (list_impl_t self)
|
||||
{
|
||||
int boxpad = self->item_padding;
|
||||
int item_vspace = self->item_spacing;
|
||||
int item_height = self->item_height;
|
||||
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
|
||||
return (self->bounds.height + item_vspace - 2 * boxpad
|
||||
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
||||
}
|
||||
|
||||
static int
|
||||
check_boxes (list_impl_t self)
|
||||
{
|
||||
if (self->need_to_recreate_boxes)
|
||||
{
|
||||
grub_gui_recreate_box (&self->menu_box,
|
||||
self->menu_box_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->selected_item_box,
|
||||
self->selected_item_box_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
self->need_to_recreate_boxes = 0;
|
||||
}
|
||||
|
||||
return (self->menu_box != 0 && self->selected_item_box != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
check_scrollbar (list_impl_t self)
|
||||
{
|
||||
if (self->need_to_recreate_scrollbar)
|
||||
{
|
||||
grub_gui_recreate_box (&self->scrollbar_frame,
|
||||
self->scrollbar_frame_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->scrollbar_thumb,
|
||||
self->scrollbar_thumb_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
self->need_to_recreate_scrollbar = 0;
|
||||
}
|
||||
|
||||
return (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
list_get_id (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
list_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return (grub_strcmp (type, "component") == 0
|
||||
|| grub_strcmp (type, "list") == 0);
|
||||
}
|
||||
|
||||
static struct grub_video_bitmap *
|
||||
get_item_icon (list_impl_t self, int item_index)
|
||||
{
|
||||
grub_menu_entry_t entry;
|
||||
entry = grub_menu_get_entry (self->view->menu, item_index);
|
||||
if (! entry)
|
||||
return 0;
|
||||
|
||||
return grub_gfxmenu_icon_manager_get_icon (self->icon_manager, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
make_selected_item_visible (list_impl_t self)
|
||||
{
|
||||
int selected_index = self->view->selected;
|
||||
if (selected_index < 0)
|
||||
return; /* No item is selected. */
|
||||
int num_shown_items = get_num_shown_items (self);
|
||||
int last_shown_index = self->first_shown_index + (num_shown_items - 1);
|
||||
if (selected_index < self->first_shown_index)
|
||||
self->first_shown_index = selected_index;
|
||||
else if (selected_index > last_shown_index)
|
||||
self->first_shown_index = selected_index - (num_shown_items - 1);
|
||||
}
|
||||
|
||||
/* Draw a scrollbar on the menu. */
|
||||
static void
|
||||
draw_scrollbar (list_impl_t self,
|
||||
int value, int extent, int min, int max,
|
||||
int rightx, int topy, int height)
|
||||
{
|
||||
grub_gfxmenu_box_t frame = self->scrollbar_frame;
|
||||
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
|
||||
int frame_vertical_pad = (frame->get_top_pad (frame)
|
||||
+ frame->get_bottom_pad (frame));
|
||||
int frame_horizontal_pad = (frame->get_left_pad (frame)
|
||||
+ frame->get_right_pad (frame));
|
||||
int tracktop = topy + frame->get_top_pad (frame);
|
||||
int tracklen = height - frame_vertical_pad;
|
||||
frame->set_content_size (frame, self->scrollbar_width, tracklen);
|
||||
int thumby = tracktop + tracklen * (value - min) / (max - min);
|
||||
int thumbheight = tracklen * extent / (max - min) + 1;
|
||||
thumb->set_content_size (thumb,
|
||||
self->scrollbar_width - frame_horizontal_pad,
|
||||
thumbheight - (thumb->get_top_pad (thumb)
|
||||
+ thumb->get_bottom_pad (thumb)));
|
||||
frame->draw (frame,
|
||||
rightx - (self->scrollbar_width + frame_horizontal_pad),
|
||||
topy);
|
||||
thumb->draw (thumb,
|
||||
rightx - (self->scrollbar_width - frame->get_right_pad (frame)),
|
||||
thumby);
|
||||
}
|
||||
|
||||
/* Draw the list of items. */
|
||||
static void
|
||||
draw_menu (list_impl_t self, int width, int drawing_scrollbar,
|
||||
int num_shown_items)
|
||||
{
|
||||
if (! self->menu_box || ! self->selected_item_box)
|
||||
return;
|
||||
|
||||
int boxpad = self->item_padding;
|
||||
int icon_text_space = self->item_icon_space;
|
||||
int item_vspace = self->item_spacing;
|
||||
|
||||
int ascent = grub_font_get_ascent (self->item_font);
|
||||
int descent = grub_font_get_descent (self->item_font);
|
||||
int item_height = self->item_height;
|
||||
|
||||
make_selected_item_visible (self);
|
||||
|
||||
int scrollbar_h_space = drawing_scrollbar ? self->scrollbar_width : 0;
|
||||
|
||||
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||
int sel_leftpad = selbox->get_left_pad (selbox);
|
||||
int item_top = boxpad;
|
||||
int item_left = boxpad + sel_leftpad;
|
||||
int menu_index;
|
||||
int visible_index;
|
||||
|
||||
for (visible_index = 0, menu_index = self->first_shown_index;
|
||||
visible_index < num_shown_items && menu_index < self->view->menu->size;
|
||||
visible_index++, menu_index++)
|
||||
{
|
||||
int is_selected = (menu_index == self->view->selected);
|
||||
|
||||
if (is_selected)
|
||||
{
|
||||
int sel_toppad = selbox->get_top_pad (selbox);
|
||||
selbox->set_content_size (selbox,
|
||||
(width - 2 * boxpad
|
||||
- scrollbar_h_space),
|
||||
item_height);
|
||||
selbox->draw (selbox,
|
||||
item_left - sel_leftpad,
|
||||
item_top - sel_toppad);
|
||||
}
|
||||
|
||||
struct grub_video_bitmap *icon;
|
||||
if ((icon = get_item_icon (self, menu_index)) != 0)
|
||||
grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND,
|
||||
item_left,
|
||||
item_top + (item_height - self->icon_height) / 2,
|
||||
0, 0, self->icon_width, self->icon_height);
|
||||
|
||||
const char *item_title =
|
||||
grub_menu_get_entry (self->view->menu, menu_index)->title;
|
||||
grub_font_t font =
|
||||
(is_selected && self->selected_item_font
|
||||
? self->selected_item_font
|
||||
: self->item_font);
|
||||
grub_gui_color_t text_color =
|
||||
((is_selected && self->selected_item_color_set)
|
||||
? self->selected_item_color
|
||||
: self->item_color);
|
||||
grub_font_draw_string (item_title,
|
||||
font,
|
||||
grub_gui_map_color (text_color),
|
||||
item_left + self->icon_width + icon_text_space,
|
||||
(item_top + (item_height - (ascent + descent))
|
||||
/ 2 + ascent));
|
||||
|
||||
item_top += item_height + item_vspace;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
list_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
if (! self->visible)
|
||||
return;
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
check_boxes (self);
|
||||
|
||||
if (! self->menu_box || ! self->selected_item_box)
|
||||
return;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
{
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_left_pad = box->get_left_pad (box);
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_right_pad = box->get_right_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
grub_video_rect_t vpsave2, content_rect;
|
||||
int num_shown_items = get_num_shown_items (self);
|
||||
int drawing_scrollbar = (self->draw_scrollbar
|
||||
&& (num_shown_items < self->view->menu->size)
|
||||
&& check_scrollbar (self));
|
||||
|
||||
content_rect.x = box_left_pad;
|
||||
content_rect.y = box_top_pad;
|
||||
content_rect.width = self->bounds.width - box_left_pad - box_right_pad;
|
||||
content_rect.height = self->bounds.height - box_top_pad - box_bottom_pad;
|
||||
|
||||
box->set_content_size (box, content_rect.width, content_rect.height);
|
||||
|
||||
box->draw (box, 0, 0);
|
||||
|
||||
grub_gui_set_viewport (&content_rect, &vpsave2);
|
||||
draw_menu (self, content_rect.width, drawing_scrollbar, num_shown_items);
|
||||
grub_gui_restore_viewport (&vpsave2);
|
||||
|
||||
if (drawing_scrollbar)
|
||||
draw_scrollbar (self,
|
||||
self->first_shown_index, num_shown_items,
|
||||
0, self->view->menu->size,
|
||||
self->bounds.width - box_right_pad
|
||||
+ self->scrollbar_width,
|
||||
box_top_pad + self->item_padding,
|
||||
self->bounds.height - box_top_pad - box_bottom_pad);
|
||||
}
|
||||
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
list_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
list_get_parent (void *vself)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
list_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
list_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
|
||||
if (check_boxes (self))
|
||||
{
|
||||
int boxpad = self->item_padding;
|
||||
int item_vspace = self->item_spacing;
|
||||
int item_height = self->item_height;
|
||||
int num_items = 3;
|
||||
|
||||
grub_gfxmenu_box_t box = self->menu_box;
|
||||
int box_left_pad = box->get_left_pad (box);
|
||||
int box_top_pad = box->get_top_pad (box);
|
||||
int box_right_pad = box->get_right_pad (box);
|
||||
int box_bottom_pad = box->get_bottom_pad (box);
|
||||
unsigned width_s;
|
||||
|
||||
*width = grub_font_get_string_width (self->item_font, "Typical OS");
|
||||
width_s = grub_font_get_string_width (self->selected_item_font,
|
||||
"Typical OS");
|
||||
if (*width < width_s)
|
||||
*width = width_s;
|
||||
|
||||
*width += 2 * boxpad + box_left_pad + box_right_pad;
|
||||
|
||||
/* Set the menu box height to fit the items. */
|
||||
*height = (item_height * num_items
|
||||
+ item_vspace * (num_items - 1)
|
||||
+ 2 * boxpad
|
||||
+ box_top_pad + box_bottom_pad);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
list_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
if (grub_strcmp (name, "item_font") == 0)
|
||||
{
|
||||
self->item_font = grub_font_get (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_font") == 0)
|
||||
{
|
||||
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||
self->selected_item_font = 0;
|
||||
else
|
||||
self->selected_item_font = grub_font_get (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->item_color);
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_color") == 0)
|
||||
{
|
||||
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||
{
|
||||
self->selected_item_color_set = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (grub_gui_parse_color (value, &self->selected_item_color)
|
||||
== GRUB_ERR_NONE)
|
||||
self->selected_item_color_set = 1;
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "icon_width") == 0)
|
||||
{
|
||||
self->icon_width = grub_strtol (value, 0, 10);
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
}
|
||||
else if (grub_strcmp (name, "icon_height") == 0)
|
||||
{
|
||||
self->icon_height = grub_strtol (value, 0, 10);
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_height") == 0)
|
||||
{
|
||||
self->item_height = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_padding") == 0)
|
||||
{
|
||||
self->item_padding = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_icon_space") == 0)
|
||||
{
|
||||
self->item_icon_space = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "item_spacing") == 0)
|
||||
{
|
||||
self->item_spacing = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "visible") == 0)
|
||||
{
|
||||
self->visible = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "menu_pixmap_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->menu_box_pattern);
|
||||
self->menu_box_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_frame") == 0)
|
||||
{
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
grub_free (self->scrollbar_frame_pattern);
|
||||
self->scrollbar_frame_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_thumb") == 0)
|
||||
{
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
grub_free (self->scrollbar_thumb_pattern);
|
||||
self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar_width") == 0)
|
||||
{
|
||||
self->scrollbar_width = grub_strtol (value, 0, 10);
|
||||
}
|
||||
else if (grub_strcmp (name, "scrollbar") == 0)
|
||||
{
|
||||
self->draw_scrollbar = grub_strcmp (value, "false") != 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "theme_dir") == 0)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->theme_dir);
|
||||
self->theme_dir = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Set necessary information that the gfxmenu view provides. */
|
||||
static void
|
||||
list_set_view_info (void *vself,
|
||||
grub_gfxmenu_view_t view)
|
||||
{
|
||||
list_impl_t self = vself;
|
||||
grub_gfxmenu_icon_manager_set_theme_path (self->icon_manager,
|
||||
view->theme_path);
|
||||
self->view = view;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops list_comp_ops =
|
||||
{
|
||||
.destroy = list_destroy,
|
||||
.get_id = list_get_id,
|
||||
.is_instance = list_is_instance,
|
||||
.paint = list_paint,
|
||||
.set_parent = list_set_parent,
|
||||
.get_parent = list_get_parent,
|
||||
.set_bounds = list_set_bounds,
|
||||
.get_bounds = list_get_bounds,
|
||||
.get_minimal_size = list_get_minimal_size,
|
||||
.set_property = list_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_list_ops list_ops =
|
||||
{
|
||||
.set_view_info = list_set_view_info
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_list_new (void)
|
||||
{
|
||||
list_impl_t self;
|
||||
grub_font_t default_font;
|
||||
grub_gui_color_t default_fg_color;
|
||||
grub_gui_color_t default_bg_color;
|
||||
|
||||
self = grub_zalloc (sizeof (*self));
|
||||
if (! self)
|
||||
return 0;
|
||||
|
||||
self->list.ops = &list_ops;
|
||||
self->list.component.ops = &list_comp_ops;
|
||||
|
||||
self->visible = 1;
|
||||
|
||||
default_font = grub_font_get ("Unknown Regular 16");
|
||||
default_fg_color = grub_gui_color_rgb (0, 0, 0);
|
||||
default_bg_color = grub_gui_color_rgb (255, 255, 255);
|
||||
|
||||
self->icon_width = 32;
|
||||
self->icon_height = 32;
|
||||
self->item_height = 42;
|
||||
self->item_padding = 14;
|
||||
self->item_icon_space = 4;
|
||||
self->item_spacing = 16;
|
||||
self->item_font = default_font;
|
||||
self->selected_item_font = 0; /* Default to using the item_font. */
|
||||
self->item_color = default_fg_color;
|
||||
self->selected_item_color_set = 0; /* Default to using the item_color. */
|
||||
self->selected_item_color = default_fg_color;
|
||||
|
||||
self->draw_scrollbar = 1;
|
||||
self->need_to_recreate_scrollbar = 1;
|
||||
self->scrollbar_frame = 0;
|
||||
self->scrollbar_thumb = 0;
|
||||
self->scrollbar_frame_pattern = 0;
|
||||
self->scrollbar_thumb_pattern = 0;
|
||||
self->scrollbar_width = 16;
|
||||
|
||||
self->first_shown_index = 0;
|
||||
|
||||
self->need_to_recreate_boxes = 0;
|
||||
self->theme_dir = 0;
|
||||
self->menu_box_pattern = 0;
|
||||
self->selected_item_box_pattern = 0;
|
||||
self->menu_box = grub_gfxmenu_create_box (0, 0);
|
||||
self->selected_item_box = grub_gfxmenu_create_box (0, 0);
|
||||
|
||||
self->icon_manager = grub_gfxmenu_icon_manager_new ();
|
||||
if (! self->icon_manager)
|
||||
{
|
||||
self->list.component.ops->destroy (self);
|
||||
return 0;
|
||||
}
|
||||
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||
self->icon_width,
|
||||
self->icon_height);
|
||||
return (grub_gui_component_t) self;
|
||||
}
|
391
gfxmenu/gui_progress_bar.c
Normal file
391
gfxmenu/gui_progress_bar.c
Normal file
|
@ -0,0 +1,391 @@
|
|||
/* gui_progress_bar.c - GUI progress bar component. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
struct grub_gui_progress_bar
|
||||
{
|
||||
struct grub_gui_progress progress;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
int start;
|
||||
int end;
|
||||
int value;
|
||||
int show_text;
|
||||
char *template;
|
||||
grub_font_t font;
|
||||
grub_gui_color_t text_color;
|
||||
grub_gui_color_t border_color;
|
||||
grub_gui_color_t bg_color;
|
||||
grub_gui_color_t fg_color;
|
||||
|
||||
char *theme_dir;
|
||||
int need_to_recreate_pixmaps;
|
||||
int pixmapbar_available;
|
||||
char *bar_pattern;
|
||||
char *highlight_pattern;
|
||||
grub_gfxmenu_box_t bar_box;
|
||||
grub_gfxmenu_box_t highlight_box;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_progress_bar *grub_gui_progress_bar_t;
|
||||
|
||||
static void
|
||||
progress_bar_destroy (void *vself)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
progress_bar_get_id (void *vself)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
return self->id;
|
||||
}
|
||||
|
||||
static int
|
||||
progress_bar_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||
{
|
||||
return grub_strcmp (type, "component") == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
check_pixmaps (grub_gui_progress_bar_t self)
|
||||
{
|
||||
if (!self->pixmapbar_available)
|
||||
return 0;
|
||||
if (self->need_to_recreate_pixmaps)
|
||||
{
|
||||
grub_gui_recreate_box (&self->bar_box,
|
||||
self->bar_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
grub_gui_recreate_box (&self->highlight_box,
|
||||
self->highlight_pattern,
|
||||
self->theme_dir);
|
||||
|
||||
self->need_to_recreate_pixmaps = 0;
|
||||
}
|
||||
|
||||
return (self->bar_box != 0 && self->highlight_box != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_filled_rect_bar (grub_gui_progress_bar_t self)
|
||||
{
|
||||
/* Set the progress bar's frame. */
|
||||
grub_video_rect_t f;
|
||||
f.x = 1;
|
||||
f.y = 1;
|
||||
f.width = self->bounds.width - 2;
|
||||
f.height = self->bounds.height - 2;
|
||||
|
||||
/* Border. */
|
||||
grub_video_fill_rect (grub_gui_map_color (self->border_color),
|
||||
f.x - 1, f.y - 1,
|
||||
f.width + 2, f.height + 2);
|
||||
|
||||
/* Bar background. */
|
||||
int barwidth = (f.width
|
||||
* (self->value - self->start)
|
||||
/ (self->end - self->start));
|
||||
grub_video_fill_rect (grub_gui_map_color (self->bg_color),
|
||||
f.x + barwidth, f.y,
|
||||
f.width - barwidth, f.height);
|
||||
|
||||
/* Bar foreground. */
|
||||
grub_video_fill_rect (grub_gui_map_color (self->fg_color),
|
||||
f.x, f.y,
|
||||
barwidth, f.height);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_pixmap_bar (grub_gui_progress_bar_t self)
|
||||
{
|
||||
grub_gfxmenu_box_t bar = self->bar_box;
|
||||
grub_gfxmenu_box_t hl = self->highlight_box;
|
||||
int w = self->bounds.width;
|
||||
int h = self->bounds.height;
|
||||
int bar_l_pad = bar->get_left_pad (bar);
|
||||
int bar_r_pad = bar->get_right_pad (bar);
|
||||
int bar_t_pad = bar->get_top_pad (bar);
|
||||
int bar_b_pad = bar->get_bottom_pad (bar);
|
||||
int bar_h_pad = bar_l_pad + bar_r_pad;
|
||||
int bar_v_pad = bar_t_pad + bar_b_pad;
|
||||
int tracklen = w - bar_h_pad;
|
||||
int trackheight = h - bar_v_pad;
|
||||
int barwidth;
|
||||
|
||||
bar->set_content_size (bar, tracklen, trackheight);
|
||||
|
||||
barwidth = (tracklen * (self->value - self->start)
|
||||
/ (self->end - self->start));
|
||||
|
||||
hl->set_content_size (hl, barwidth, h - bar_v_pad);
|
||||
|
||||
bar->draw (bar, 0, 0);
|
||||
hl->draw (hl, bar_l_pad, bar_t_pad);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_text (grub_gui_progress_bar_t self)
|
||||
{
|
||||
if (self->template)
|
||||
{
|
||||
grub_font_t font = self->font;
|
||||
grub_video_color_t text_color = grub_gui_map_color (self->text_color);
|
||||
int width = self->bounds.width;
|
||||
int height = self->bounds.height;
|
||||
char *text;
|
||||
text = grub_xasprintf (self->template,
|
||||
self->value > 0 ? self->value : -self->value);
|
||||
if (!text)
|
||||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return;
|
||||
}
|
||||
/* Center the text. */
|
||||
int text_width = grub_font_get_string_width (font, text);
|
||||
int x = (width - text_width) / 2;
|
||||
int y = ((height - grub_font_get_descent (font)) / 2
|
||||
+ grub_font_get_ascent (font) / 2);
|
||||
grub_font_draw_string (text, font, text_color, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_paint (void *vself, const grub_video_rect_t *region)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
grub_video_rect_t vpsave;
|
||||
|
||||
if (! self->visible)
|
||||
return;
|
||||
if (!grub_video_have_common_points (region, &self->bounds))
|
||||
return;
|
||||
|
||||
if (self->end == self->start)
|
||||
return;
|
||||
|
||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||
|
||||
if (check_pixmaps (self))
|
||||
draw_pixmap_bar (self);
|
||||
else
|
||||
draw_filled_rect_bar (self);
|
||||
|
||||
draw_text (self);
|
||||
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_set_parent (void *vself, grub_gui_container_t parent)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
self->parent = parent;
|
||||
}
|
||||
|
||||
static grub_gui_container_t
|
||||
progress_bar_get_parent (void *vself)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
return self->parent;
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
self->bounds = *bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
*bounds = self->bounds;
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_get_minimal_size (void *vself,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
unsigned text_width = 0, text_height = 0;
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
|
||||
if (self->template)
|
||||
{
|
||||
text_width = grub_font_get_string_width (self->font, self->template);
|
||||
text_width += grub_font_get_string_width (self->font, "XXXXXXXXXX");
|
||||
text_height = grub_font_get_descent (self->font)
|
||||
+ grub_font_get_ascent (self->font);
|
||||
}
|
||||
*width = 200;
|
||||
if (*width < text_width)
|
||||
*width = text_width;
|
||||
*height = 28;
|
||||
if (*height < text_height)
|
||||
*height = text_height;
|
||||
}
|
||||
|
||||
static void
|
||||
progress_bar_set_state (void *vself, int visible, int start,
|
||||
int current, int end)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
self->visible = visible;
|
||||
self->start = start;
|
||||
self->value = current;
|
||||
self->end = end;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
progress_bar_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
grub_gui_progress_bar_t self = vself;
|
||||
if (grub_strcmp (name, "text") == 0)
|
||||
{
|
||||
grub_free (self->template);
|
||||
if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_LONG@") == 0)
|
||||
value
|
||||
= _("The highlighted entry will be executed automatically in %ds.");
|
||||
else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_MIDDLE@") == 0)
|
||||
/* TRANSLATORS: 's' stands for seconds.
|
||||
It's a standalone timeout notification.
|
||||
Please use the short form in your language. */
|
||||
value = _("%ds remaining.");
|
||||
else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_SHORT@") == 0)
|
||||
/* TRANSLATORS: 's' stands for seconds.
|
||||
It's a standalone timeout notification.
|
||||
Please use the shortest form available in you language. */
|
||||
value = _("%ds");
|
||||
|
||||
self->template = grub_strdup (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "font") == 0)
|
||||
{
|
||||
self->font = grub_font_get (value);
|
||||
}
|
||||
else if (grub_strcmp (name, "text_color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->text_color);
|
||||
}
|
||||
else if (grub_strcmp (name, "border_color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->border_color);
|
||||
}
|
||||
else if (grub_strcmp (name, "bg_color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->bg_color);
|
||||
}
|
||||
else if (grub_strcmp (name, "fg_color") == 0)
|
||||
{
|
||||
grub_gui_parse_color (value, &self->fg_color);
|
||||
}
|
||||
else if (grub_strcmp (name, "bar_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_pixmaps = 1;
|
||||
self->pixmapbar_available = 1;
|
||||
grub_free (self->bar_pattern);
|
||||
self->bar_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "highlight_style") == 0)
|
||||
{
|
||||
self->need_to_recreate_pixmaps = 1;
|
||||
self->pixmapbar_available = 1;
|
||||
grub_free (self->highlight_pattern);
|
||||
self->highlight_pattern = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "theme_dir") == 0)
|
||||
{
|
||||
self->need_to_recreate_pixmaps = 1;
|
||||
grub_free (self->theme_dir);
|
||||
self->theme_dir = value ? grub_strdup (value) : 0;
|
||||
}
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
else
|
||||
self->id = 0;
|
||||
/* if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||
== 0)*/
|
||||
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||
progress_bar_set_state);
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static struct grub_gui_component_ops progress_bar_ops =
|
||||
{
|
||||
.destroy = progress_bar_destroy,
|
||||
.get_id = progress_bar_get_id,
|
||||
.is_instance = progress_bar_is_instance,
|
||||
.paint = progress_bar_paint,
|
||||
.set_parent = progress_bar_set_parent,
|
||||
.get_parent = progress_bar_get_parent,
|
||||
.set_bounds = progress_bar_set_bounds,
|
||||
.get_bounds = progress_bar_get_bounds,
|
||||
.get_minimal_size = progress_bar_get_minimal_size,
|
||||
.set_property = progress_bar_set_property
|
||||
};
|
||||
|
||||
static struct grub_gui_progress_ops progress_bar_pb_ops =
|
||||
{
|
||||
.set_state = progress_bar_set_state
|
||||
};
|
||||
|
||||
grub_gui_component_t
|
||||
grub_gui_progress_bar_new (void)
|
||||
{
|
||||
grub_gui_progress_bar_t self;
|
||||
self = grub_zalloc (sizeof (*self));
|
||||
if (! self)
|
||||
return 0;
|
||||
|
||||
self->progress.ops = &progress_bar_pb_ops;
|
||||
self->progress.component.ops = &progress_bar_ops;
|
||||
self->visible = 1;
|
||||
self->font = grub_font_get ("Unknown Regular 16");
|
||||
grub_gui_color_t black = { .red = 0, .green = 0, .blue = 0, .alpha = 255 };
|
||||
grub_gui_color_t gray = { .red = 128, .green = 128, .blue = 128, .alpha = 255 };
|
||||
grub_gui_color_t lightgray = { .red = 200, .green = 200, .blue = 200, .alpha = 255 };
|
||||
self->text_color = black;
|
||||
self->border_color = black;
|
||||
self->bg_color = gray;
|
||||
self->fg_color = lightgray;
|
||||
|
||||
return (grub_gui_component_t) self;
|
||||
}
|
327
gfxmenu/gui_string_util.c
Normal file
327
gfxmenu/gui_string_util.c
Normal file
|
@ -0,0 +1,327 @@
|
|||
/* gui_string_util.c - String utilities used by the GUI system. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 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/gui_string_util.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
/* Create a new NUL-terminated string on the heap as a substring of BUF.
|
||||
The range of buf included is the half-open interval [START,END).
|
||||
The index START is inclusive, END is exclusive. */
|
||||
char *
|
||||
grub_new_substring (const char *buf,
|
||||
grub_size_t start, grub_size_t end)
|
||||
{
|
||||
if (end < start)
|
||||
return 0;
|
||||
grub_size_t len = end - start;
|
||||
char *s = grub_malloc (len + 1);
|
||||
if (! s)
|
||||
return 0;
|
||||
grub_memcpy (s, buf + start, len);
|
||||
s[len] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Eliminate "." and ".." path elements from PATH. A new heap-allocated
|
||||
string is returned. */
|
||||
static char *
|
||||
canonicalize_path (const char *path)
|
||||
{
|
||||
int i;
|
||||
const char *p;
|
||||
char *newpath = 0;
|
||||
|
||||
/* Count the path components in path. */
|
||||
int components = 1;
|
||||
for (p = path; *p; p++)
|
||||
if (*p == '/')
|
||||
components++;
|
||||
|
||||
char **path_array = grub_malloc (components * sizeof (*path_array));
|
||||
if (! path_array)
|
||||
return 0;
|
||||
|
||||
/* Initialize array elements to NULL pointers; in case once of the
|
||||
allocations fails, the cleanup code can just call grub_free() for all
|
||||
pointers in the array. */
|
||||
for (i = 0; i < components; i++)
|
||||
path_array[i] = 0;
|
||||
|
||||
/* Parse the path into path_array. */
|
||||
p = path;
|
||||
for (i = 0; i < components && p; i++)
|
||||
{
|
||||
/* Find the end of the path element. */
|
||||
const char *end = grub_strchr (p, '/');
|
||||
if (!end)
|
||||
end = p + grub_strlen (p);
|
||||
|
||||
/* Copy the element. */
|
||||
path_array[i] = grub_new_substring (p, 0, end - p);
|
||||
if (! path_array[i])
|
||||
goto cleanup;
|
||||
|
||||
/* Advance p to point to the start of the next element, or NULL. */
|
||||
if (*end)
|
||||
p = end + 1;
|
||||
else
|
||||
p = 0;
|
||||
}
|
||||
|
||||
/* Eliminate '.' and '..' elements from the path array. */
|
||||
int newpath_length = 0;
|
||||
for (i = components - 1; i >= 0; --i)
|
||||
{
|
||||
if (! grub_strcmp (path_array[i], "."))
|
||||
{
|
||||
grub_free (path_array[i]);
|
||||
path_array[i] = 0;
|
||||
}
|
||||
else if (! grub_strcmp (path_array[i], "..")
|
||||
&& i > 0)
|
||||
{
|
||||
/* Delete the '..' and the prior path element. */
|
||||
grub_free (path_array[i]);
|
||||
path_array[i] = 0;
|
||||
--i;
|
||||
grub_free (path_array[i]);
|
||||
path_array[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newpath_length += grub_strlen (path_array[i]) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Construct a new path string. */
|
||||
newpath = grub_malloc (newpath_length + 1);
|
||||
if (! newpath)
|
||||
goto cleanup;
|
||||
|
||||
newpath[0] = '\0';
|
||||
char *newpath_end = newpath;
|
||||
int first = 1;
|
||||
for (i = 0; i < components; i++)
|
||||
{
|
||||
char *element = path_array[i];
|
||||
if (element)
|
||||
{
|
||||
/* For all components but the first, prefix with a slash. */
|
||||
if (! first)
|
||||
newpath_end = grub_stpcpy (newpath_end, "/");
|
||||
newpath_end = grub_stpcpy (newpath_end, element);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < components; i++)
|
||||
grub_free (path_array[i]);
|
||||
grub_free (path_array);
|
||||
|
||||
return newpath;
|
||||
}
|
||||
|
||||
/* Return a new heap-allocated string representing to absolute path
|
||||
to the file referred to by PATH. If PATH is an absolute path, then
|
||||
the returned path is a copy of PATH. If PATH is a relative path, then
|
||||
BASE is with PATH used to construct the absolute path. */
|
||||
char *
|
||||
grub_resolve_relative_path (const char *base, const char *path)
|
||||
{
|
||||
char *abspath;
|
||||
char *canonpath;
|
||||
char *p;
|
||||
grub_size_t l;
|
||||
|
||||
/* If PATH is an absolute path, then just use it as is. */
|
||||
if (path[0] == '/' || path[0] == '(')
|
||||
return canonicalize_path (path);
|
||||
|
||||
abspath = grub_malloc (grub_strlen (base) + grub_strlen (path) + 3);
|
||||
if (! abspath)
|
||||
return 0;
|
||||
|
||||
/* Concatenate BASE and PATH. */
|
||||
p = grub_stpcpy (abspath, base);
|
||||
l = grub_strlen (abspath);
|
||||
if (l == 0 || abspath[l-1] != '/')
|
||||
{
|
||||
*p = '/';
|
||||
p++;
|
||||
*p = 0;
|
||||
}
|
||||
grub_stpcpy (p, path);
|
||||
|
||||
canonpath = canonicalize_path (abspath);
|
||||
if (! canonpath)
|
||||
return abspath;
|
||||
|
||||
grub_free (abspath);
|
||||
return canonpath;
|
||||
}
|
||||
|
||||
/* Get the path of the directory where the file at FILE_PATH is located.
|
||||
FILE_PATH should refer to a file, not a directory. The returned path
|
||||
includes a trailing slash.
|
||||
This does not handle GRUB "(hd0,0)" paths properly yet since it only
|
||||
looks at slashes. */
|
||||
char *
|
||||
grub_get_dirname (const char *file_path)
|
||||
{
|
||||
int i;
|
||||
int last_slash;
|
||||
|
||||
last_slash = -1;
|
||||
for (i = grub_strlen (file_path) - 1; i >= 0; --i)
|
||||
{
|
||||
if (file_path[i] == '/')
|
||||
{
|
||||
last_slash = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (last_slash == -1)
|
||||
return grub_strdup ("/");
|
||||
|
||||
return grub_new_substring (file_path, 0, last_slash + 1);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
my_isxdigit (char c)
|
||||
{
|
||||
return ((c >= '0' && c <= '9')
|
||||
|| (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F'));
|
||||
}
|
||||
|
||||
static int
|
||||
parse_hex_color_component (const char *s, unsigned start, unsigned end)
|
||||
{
|
||||
unsigned len;
|
||||
char buf[3];
|
||||
|
||||
len = end - start;
|
||||
/* Check the limits so we don't overrun the buffer. */
|
||||
if (len < 1 || len > 2)
|
||||
return 0;
|
||||
|
||||
if (len == 1)
|
||||
{
|
||||
buf[0] = s[start]; /* Get the first and only hex digit. */
|
||||
buf[1] = buf[0]; /* Duplicate the hex digit. */
|
||||
}
|
||||
else if (len == 2)
|
||||
{
|
||||
buf[0] = s[start];
|
||||
buf[1] = s[start + 1];
|
||||
}
|
||||
|
||||
buf[2] = '\0';
|
||||
|
||||
return grub_strtoul (buf, 0, 16);
|
||||
}
|
||||
|
||||
/* Parse a color string of the form "r, g, b", "#RGB", "#RGBA",
|
||||
"#RRGGBB", or "#RRGGBBAA". */
|
||||
grub_err_t
|
||||
grub_gui_parse_color (const char *s, grub_gui_color_t *color)
|
||||
{
|
||||
grub_gui_color_t c;
|
||||
|
||||
/* Skip whitespace. */
|
||||
while (*s && grub_isspace (*s))
|
||||
s++;
|
||||
|
||||
if (*s == '#')
|
||||
{
|
||||
/* HTML-style. Number if hex digits:
|
||||
[6] #RRGGBB [3] #RGB
|
||||
[8] #RRGGBBAA [4] #RGBA */
|
||||
|
||||
s++; /* Skip the '#'. */
|
||||
/* Count the hexits to determine the format. */
|
||||
int hexits = 0;
|
||||
const char *end = s;
|
||||
while (my_isxdigit (*end))
|
||||
{
|
||||
end++;
|
||||
hexits++;
|
||||
}
|
||||
|
||||
/* Parse the color components based on the format. */
|
||||
if (hexits == 3 || hexits == 4)
|
||||
{
|
||||
c.red = parse_hex_color_component (s, 0, 1);
|
||||
c.green = parse_hex_color_component (s, 1, 2);
|
||||
c.blue = parse_hex_color_component (s, 2, 3);
|
||||
if (hexits == 4)
|
||||
c.alpha = parse_hex_color_component (s, 3, 4);
|
||||
else
|
||||
c.alpha = 255;
|
||||
}
|
||||
else if (hexits == 6 || hexits == 8)
|
||||
{
|
||||
c.red = parse_hex_color_component (s, 0, 2);
|
||||
c.green = parse_hex_color_component (s, 2, 4);
|
||||
c.blue = parse_hex_color_component (s, 4, 6);
|
||||
if (hexits == 8)
|
||||
c.alpha = parse_hex_color_component (s, 6, 8);
|
||||
else
|
||||
c.alpha = 255;
|
||||
}
|
||||
else
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid HTML-type color string `%s'", s);
|
||||
}
|
||||
else if (grub_isdigit (*s))
|
||||
{
|
||||
/* Comma separated decimal values. */
|
||||
c.red = grub_strtoul (s, 0, 0);
|
||||
if ((s = grub_strchr (s, ',')) == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"missing 1st comma separator in color `%s'", s);
|
||||
s++;
|
||||
c.green = grub_strtoul (s, 0, 0);
|
||||
if ((s = grub_strchr (s, ',')) == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"missing 2nd comma separator in color `%s'", s);
|
||||
s++;
|
||||
c.blue = grub_strtoul (s, 0, 0);
|
||||
if ((s = grub_strchr (s, ',')) == 0)
|
||||
c.alpha = 255;
|
||||
else
|
||||
{
|
||||
s++;
|
||||
c.alpha = grub_strtoul (s, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! grub_gui_get_named_color (s, &c))
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid named color `%s'", s);
|
||||
}
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
*color = c;
|
||||
return grub_errno;
|
||||
}
|
101
gfxmenu/gui_util.c
Normal file
101
gfxmenu/gui_util.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* gui_util.c - GUI utility functions. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
|
||||
|
||||
struct find_by_id_state
|
||||
{
|
||||
const char *match_id;
|
||||
grub_gui_component_callback match_callback;
|
||||
void *match_userdata;
|
||||
};
|
||||
|
||||
static void
|
||||
find_by_id_recursively (grub_gui_component_t component, void *userdata)
|
||||
{
|
||||
struct find_by_id_state *state;
|
||||
const char *id;
|
||||
|
||||
state = (struct find_by_id_state *) userdata;
|
||||
id = component->ops->get_id (component);
|
||||
if (id && grub_strcmp (id, state->match_id) == 0)
|
||||
state->match_callback (component, state->match_userdata);
|
||||
|
||||
if (component->ops->is_instance (component, "container"))
|
||||
{
|
||||
grub_gui_container_t container;
|
||||
container = (grub_gui_container_t) component;
|
||||
container->ops->iterate_children (container,
|
||||
find_by_id_recursively,
|
||||
state);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gui_find_by_id (grub_gui_component_t root,
|
||||
const char *id,
|
||||
grub_gui_component_callback cb,
|
||||
void *userdata)
|
||||
{
|
||||
struct find_by_id_state state;
|
||||
state.match_id = id;
|
||||
state.match_callback = cb;
|
||||
state.match_userdata = userdata;
|
||||
find_by_id_recursively (root, &state);
|
||||
}
|
||||
|
||||
|
||||
struct iterate_recursively_state
|
||||
{
|
||||
grub_gui_component_callback callback;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
static
|
||||
void iterate_recursively_cb (grub_gui_component_t component, void *userdata)
|
||||
{
|
||||
struct iterate_recursively_state *state;
|
||||
|
||||
state = (struct iterate_recursively_state *) userdata;
|
||||
state->callback (component, state->userdata);
|
||||
|
||||
if (component->ops->is_instance (component, "container"))
|
||||
{
|
||||
grub_gui_container_t container;
|
||||
container = (grub_gui_container_t) component;
|
||||
container->ops->iterate_children (container,
|
||||
iterate_recursively_cb,
|
||||
state);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gui_iterate_recursively (grub_gui_component_t root,
|
||||
grub_gui_component_callback cb,
|
||||
void *userdata)
|
||||
{
|
||||
struct iterate_recursively_state state;
|
||||
state.callback = cb;
|
||||
state.userdata = userdata;
|
||||
iterate_recursively_cb (root, &state);
|
||||
}
|
263
gfxmenu/icon_manager.c
Normal file
263
gfxmenu/icon_manager.c
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* icon_manager.c - gfxmenu icon manager. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 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/err.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/icon_manager.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
/* Currently hard coded to '.png' extension. */
|
||||
static const char icon_extension[] = ".png";
|
||||
|
||||
typedef struct icon_entry
|
||||
{
|
||||
char *class_name;
|
||||
struct grub_video_bitmap *bitmap;
|
||||
struct icon_entry *next;
|
||||
} *icon_entry_t;
|
||||
|
||||
struct grub_gfxmenu_icon_manager
|
||||
{
|
||||
char *theme_path;
|
||||
int icon_width;
|
||||
int icon_height;
|
||||
|
||||
/* Icon cache: linked list w/ dummy head node. */
|
||||
struct icon_entry cache;
|
||||
};
|
||||
|
||||
|
||||
/* Create a new icon manager and return a point to it. */
|
||||
grub_gfxmenu_icon_manager_t
|
||||
grub_gfxmenu_icon_manager_new (void)
|
||||
{
|
||||
grub_gfxmenu_icon_manager_t mgr;
|
||||
mgr = grub_malloc (sizeof (*mgr));
|
||||
if (! mgr)
|
||||
return 0;
|
||||
|
||||
mgr->theme_path = 0;
|
||||
mgr->icon_width = 0;
|
||||
mgr->icon_height = 0;
|
||||
|
||||
/* Initialize the dummy head node. */
|
||||
mgr->cache.class_name = 0;
|
||||
mgr->cache.bitmap = 0;
|
||||
mgr->cache.next = 0;
|
||||
|
||||
return mgr;
|
||||
}
|
||||
|
||||
/* Destroy the icon manager MGR, freeing all resources used by it.
|
||||
|
||||
Note: Any bitmaps returned by grub_gfxmenu_icon_manager_get_icon()
|
||||
are destroyed and must not be used by the caller after this function
|
||||
is called. */
|
||||
void
|
||||
grub_gfxmenu_icon_manager_destroy (grub_gfxmenu_icon_manager_t mgr)
|
||||
{
|
||||
grub_gfxmenu_icon_manager_clear_cache (mgr);
|
||||
grub_free (mgr->theme_path);
|
||||
grub_free (mgr);
|
||||
}
|
||||
|
||||
/* Clear the icon cache. */
|
||||
void
|
||||
grub_gfxmenu_icon_manager_clear_cache (grub_gfxmenu_icon_manager_t mgr)
|
||||
{
|
||||
icon_entry_t cur;
|
||||
icon_entry_t next;
|
||||
for (cur = mgr->cache.next; cur; cur = next)
|
||||
{
|
||||
next = cur->next;
|
||||
grub_free (cur->class_name);
|
||||
grub_video_bitmap_destroy (cur->bitmap);
|
||||
grub_free (cur);
|
||||
}
|
||||
mgr->cache.next = 0;
|
||||
}
|
||||
|
||||
/* Set the theme path. If the theme path is changed, the icon cache
|
||||
is cleared. */
|
||||
void
|
||||
grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
|
||||
const char *path)
|
||||
{
|
||||
/* Clear the cache if the theme path has changed. */
|
||||
if (((mgr->theme_path == 0) != (path == 0))
|
||||
|| (grub_strcmp (mgr->theme_path, path) != 0))
|
||||
grub_gfxmenu_icon_manager_clear_cache (mgr);
|
||||
|
||||
grub_free (mgr->theme_path);
|
||||
mgr->theme_path = path ? grub_strdup (path) : 0;
|
||||
}
|
||||
|
||||
/* Set the icon size. When icons are requested from the icon manager,
|
||||
they are scaled to this size before being returned. If the size is
|
||||
changed, the icon cache is cleared. */
|
||||
void
|
||||
grub_gfxmenu_icon_manager_set_icon_size (grub_gfxmenu_icon_manager_t mgr,
|
||||
int width, int height)
|
||||
{
|
||||
/* If the width or height is changed, we must clear the cache, since the
|
||||
scaled bitmaps are stored in the cache. */
|
||||
if (width != mgr->icon_width || height != mgr->icon_height)
|
||||
grub_gfxmenu_icon_manager_clear_cache (mgr);
|
||||
|
||||
mgr->icon_width = width;
|
||||
mgr->icon_height = height;
|
||||
}
|
||||
|
||||
/* Try to load an icon for the specified CLASS_NAME in the directory DIR.
|
||||
Returns 0 if the icon could not be loaded, or returns a pointer to a new
|
||||
bitmap if it was successful. */
|
||||
static struct grub_video_bitmap *
|
||||
try_loading_icon (grub_gfxmenu_icon_manager_t mgr,
|
||||
const char *dir, const char *class_name)
|
||||
{
|
||||
char *path;
|
||||
int l;
|
||||
|
||||
path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name)
|
||||
+ grub_strlen (icon_extension) + 3);
|
||||
if (! path)
|
||||
return 0;
|
||||
|
||||
grub_strcpy (path, dir);
|
||||
l = grub_strlen (path);
|
||||
if (path[l-1] != '/')
|
||||
{
|
||||
path[l] = '/';
|
||||
path[l+1] = 0;
|
||||
}
|
||||
grub_strcat (path, class_name);
|
||||
grub_strcat (path, icon_extension);
|
||||
|
||||
struct grub_video_bitmap *raw_bitmap;
|
||||
grub_video_bitmap_load (&raw_bitmap, path);
|
||||
grub_free (path);
|
||||
grub_errno = GRUB_ERR_NONE; /* Critical to clear the error!! */
|
||||
if (! raw_bitmap)
|
||||
return 0;
|
||||
|
||||
struct grub_video_bitmap *scaled_bitmap;
|
||||
grub_video_bitmap_create_scaled (&scaled_bitmap,
|
||||
mgr->icon_width, mgr->icon_height,
|
||||
raw_bitmap,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||
grub_video_bitmap_destroy (raw_bitmap);
|
||||
if (! scaled_bitmap)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_error (grub_errno, "failed to scale icon");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return scaled_bitmap;
|
||||
}
|
||||
|
||||
/* Get the icon for the specified class CLASS_NAME. If an icon for
|
||||
CLASS_NAME already exists in the cache, then a reference to the cached
|
||||
bitmap is returned. If it is not cached, then it is loaded and cached.
|
||||
If no icon could be could for CLASS_NAME, then 0 is returned. */
|
||||
static struct grub_video_bitmap *
|
||||
get_icon_by_class (grub_gfxmenu_icon_manager_t mgr, const char *class_name)
|
||||
{
|
||||
/* First check the icon cache. */
|
||||
icon_entry_t entry;
|
||||
for (entry = mgr->cache.next; entry; entry = entry->next)
|
||||
{
|
||||
if (grub_strcmp (entry->class_name, class_name) == 0)
|
||||
return entry->bitmap;
|
||||
}
|
||||
|
||||
if (! mgr->theme_path)
|
||||
return 0;
|
||||
|
||||
/* Otherwise, we search for an icon to load. */
|
||||
char *theme_dir = grub_get_dirname (mgr->theme_path);
|
||||
char *icons_dir;
|
||||
struct grub_video_bitmap *icon;
|
||||
icon = 0;
|
||||
/* First try the theme's own icons, from "grub/themes/NAME/icons/" */
|
||||
icons_dir = grub_resolve_relative_path (theme_dir, "icons/");
|
||||
if (icons_dir)
|
||||
{
|
||||
icon = try_loading_icon (mgr, icons_dir, class_name);
|
||||
grub_free (icons_dir);
|
||||
}
|
||||
|
||||
grub_free (theme_dir);
|
||||
if (! icon)
|
||||
{
|
||||
const char *icondir;
|
||||
|
||||
icondir = grub_env_get ("icondir");
|
||||
if (icondir)
|
||||
icon = try_loading_icon (mgr, icondir, class_name);
|
||||
}
|
||||
|
||||
/* No icon was found. */
|
||||
/* This should probably be noted in the cache, so that a search is not
|
||||
performed each time an icon for CLASS_NAME is requested. */
|
||||
if (! icon)
|
||||
return 0;
|
||||
|
||||
/* Insert a new cache entry for this icon. */
|
||||
entry = grub_malloc (sizeof (*entry));
|
||||
if (! entry)
|
||||
{
|
||||
grub_video_bitmap_destroy (icon);
|
||||
return 0;
|
||||
}
|
||||
entry->class_name = grub_strdup (class_name);
|
||||
entry->bitmap = icon;
|
||||
entry->next = mgr->cache.next;
|
||||
mgr->cache.next = entry; /* Link it into the cache. */
|
||||
return entry->bitmap;
|
||||
}
|
||||
|
||||
/* Get the best available icon for ENTRY. Beginning with the first class
|
||||
listed in the menu entry and proceeding forward, an icon for each class
|
||||
is searched for. The first icon found is returned. The returned icon
|
||||
is scaled to the size specified by
|
||||
grub_gfxmenu_icon_manager_set_icon_size().
|
||||
|
||||
Note: Bitmaps returned by this function are destroyed when the
|
||||
icon manager is destroyed.
|
||||
*/
|
||||
struct grub_video_bitmap *
|
||||
grub_gfxmenu_icon_manager_get_icon (grub_gfxmenu_icon_manager_t mgr,
|
||||
grub_menu_entry_t entry)
|
||||
{
|
||||
struct grub_menu_entry_class *c;
|
||||
struct grub_video_bitmap *icon;
|
||||
|
||||
/* Try each class in succession. */
|
||||
icon = 0;
|
||||
for (c = entry->classes->next; c && ! icon; c = c->next)
|
||||
icon = get_icon_by_class (mgr, c->name);
|
||||
return icon;
|
||||
}
|
0
gfxmenu/model.c
Normal file
0
gfxmenu/model.c
Normal file
209
gfxmenu/named_colors.c
Normal file
209
gfxmenu/named_colors.c
Normal file
|
@ -0,0 +1,209 @@
|
|||
/* named_colors.c - Named color values. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
struct named_color
|
||||
{
|
||||
const char *name;
|
||||
grub_gui_color_t color;
|
||||
};
|
||||
|
||||
/*
|
||||
Named color list generated from the list of SVG color keywords from
|
||||
<http://www.w3.org/TR/css3-color/#svg-color>,
|
||||
processed through the following Perl command:
|
||||
perl -ne 'chomp;split;print "{ \"$_[0]\", RGB_COLOR($_[2]) },\n"'
|
||||
*/
|
||||
|
||||
#define RGB_COLOR(r,g,b) {.red = r, .green = g, .blue = b, .alpha = 255}
|
||||
|
||||
static struct named_color named_colors[] =
|
||||
{
|
||||
{ "aliceblue", RGB_COLOR(240,248,255) },
|
||||
{ "antiquewhite", RGB_COLOR(250,235,215) },
|
||||
{ "aqua", RGB_COLOR(0,255,255) },
|
||||
{ "aquamarine", RGB_COLOR(127,255,212) },
|
||||
{ "azure", RGB_COLOR(240,255,255) },
|
||||
{ "beige", RGB_COLOR(245,245,220) },
|
||||
{ "bisque", RGB_COLOR(255,228,196) },
|
||||
{ "black", RGB_COLOR(0,0,0) },
|
||||
{ "blanchedalmond", RGB_COLOR(255,235,205) },
|
||||
{ "blue", RGB_COLOR(0,0,255) },
|
||||
{ "blueviolet", RGB_COLOR(138,43,226) },
|
||||
{ "brown", RGB_COLOR(165,42,42) },
|
||||
{ "burlywood", RGB_COLOR(222,184,135) },
|
||||
{ "cadetblue", RGB_COLOR(95,158,160) },
|
||||
{ "chartreuse", RGB_COLOR(127,255,0) },
|
||||
{ "chocolate", RGB_COLOR(210,105,30) },
|
||||
{ "coral", RGB_COLOR(255,127,80) },
|
||||
{ "cornflowerblue", RGB_COLOR(100,149,237) },
|
||||
{ "cornsilk", RGB_COLOR(255,248,220) },
|
||||
{ "crimson", RGB_COLOR(220,20,60) },
|
||||
{ "cyan", RGB_COLOR(0,255,255) },
|
||||
{ "darkblue", RGB_COLOR(0,0,139) },
|
||||
{ "darkcyan", RGB_COLOR(0,139,139) },
|
||||
{ "darkgoldenrod", RGB_COLOR(184,134,11) },
|
||||
{ "darkgray", RGB_COLOR(169,169,169) },
|
||||
{ "darkgreen", RGB_COLOR(0,100,0) },
|
||||
{ "darkgrey", RGB_COLOR(169,169,169) },
|
||||
{ "darkkhaki", RGB_COLOR(189,183,107) },
|
||||
{ "darkmagenta", RGB_COLOR(139,0,139) },
|
||||
{ "darkolivegreen", RGB_COLOR(85,107,47) },
|
||||
{ "darkorange", RGB_COLOR(255,140,0) },
|
||||
{ "darkorchid", RGB_COLOR(153,50,204) },
|
||||
{ "darkred", RGB_COLOR(139,0,0) },
|
||||
{ "darksalmon", RGB_COLOR(233,150,122) },
|
||||
{ "darkseagreen", RGB_COLOR(143,188,143) },
|
||||
{ "darkslateblue", RGB_COLOR(72,61,139) },
|
||||
{ "darkslategray", RGB_COLOR(47,79,79) },
|
||||
{ "darkslategrey", RGB_COLOR(47,79,79) },
|
||||
{ "darkturquoise", RGB_COLOR(0,206,209) },
|
||||
{ "darkviolet", RGB_COLOR(148,0,211) },
|
||||
{ "deeppink", RGB_COLOR(255,20,147) },
|
||||
{ "deepskyblue", RGB_COLOR(0,191,255) },
|
||||
{ "dimgray", RGB_COLOR(105,105,105) },
|
||||
{ "dimgrey", RGB_COLOR(105,105,105) },
|
||||
{ "dodgerblue", RGB_COLOR(30,144,255) },
|
||||
{ "firebrick", RGB_COLOR(178,34,34) },
|
||||
{ "floralwhite", RGB_COLOR(255,250,240) },
|
||||
{ "forestgreen", RGB_COLOR(34,139,34) },
|
||||
{ "fuchsia", RGB_COLOR(255,0,255) },
|
||||
{ "gainsboro", RGB_COLOR(220,220,220) },
|
||||
{ "ghostwhite", RGB_COLOR(248,248,255) },
|
||||
{ "gold", RGB_COLOR(255,215,0) },
|
||||
{ "goldenrod", RGB_COLOR(218,165,32) },
|
||||
{ "gray", RGB_COLOR(128,128,128) },
|
||||
{ "green", RGB_COLOR(0,128,0) },
|
||||
{ "greenyellow", RGB_COLOR(173,255,47) },
|
||||
{ "grey", RGB_COLOR(128,128,128) },
|
||||
{ "honeydew", RGB_COLOR(240,255,240) },
|
||||
{ "hotpink", RGB_COLOR(255,105,180) },
|
||||
{ "indianred", RGB_COLOR(205,92,92) },
|
||||
{ "indigo", RGB_COLOR(75,0,130) },
|
||||
{ "ivory", RGB_COLOR(255,255,240) },
|
||||
{ "khaki", RGB_COLOR(240,230,140) },
|
||||
{ "lavender", RGB_COLOR(230,230,250) },
|
||||
{ "lavenderblush", RGB_COLOR(255,240,245) },
|
||||
{ "lawngreen", RGB_COLOR(124,252,0) },
|
||||
{ "lemonchiffon", RGB_COLOR(255,250,205) },
|
||||
{ "lightblue", RGB_COLOR(173,216,230) },
|
||||
{ "lightcoral", RGB_COLOR(240,128,128) },
|
||||
{ "lightcyan", RGB_COLOR(224,255,255) },
|
||||
{ "lightgoldenrodyellow", RGB_COLOR(250,250,210) },
|
||||
{ "lightgray", RGB_COLOR(211,211,211) },
|
||||
{ "lightgreen", RGB_COLOR(144,238,144) },
|
||||
{ "lightgrey", RGB_COLOR(211,211,211) },
|
||||
{ "lightpink", RGB_COLOR(255,182,193) },
|
||||
{ "lightsalmon", RGB_COLOR(255,160,122) },
|
||||
{ "lightseagreen", RGB_COLOR(32,178,170) },
|
||||
{ "lightskyblue", RGB_COLOR(135,206,250) },
|
||||
{ "lightslategray", RGB_COLOR(119,136,153) },
|
||||
{ "lightslategrey", RGB_COLOR(119,136,153) },
|
||||
{ "lightsteelblue", RGB_COLOR(176,196,222) },
|
||||
{ "lightyellow", RGB_COLOR(255,255,224) },
|
||||
{ "lime", RGB_COLOR(0,255,0) },
|
||||
{ "limegreen", RGB_COLOR(50,205,50) },
|
||||
{ "linen", RGB_COLOR(250,240,230) },
|
||||
{ "magenta", RGB_COLOR(255,0,255) },
|
||||
{ "maroon", RGB_COLOR(128,0,0) },
|
||||
{ "mediumaquamarine", RGB_COLOR(102,205,170) },
|
||||
{ "mediumblue", RGB_COLOR(0,0,205) },
|
||||
{ "mediumorchid", RGB_COLOR(186,85,211) },
|
||||
{ "mediumpurple", RGB_COLOR(147,112,219) },
|
||||
{ "mediumseagreen", RGB_COLOR(60,179,113) },
|
||||
{ "mediumslateblue", RGB_COLOR(123,104,238) },
|
||||
{ "mediumspringgreen", RGB_COLOR(0,250,154) },
|
||||
{ "mediumturquoise", RGB_COLOR(72,209,204) },
|
||||
{ "mediumvioletred", RGB_COLOR(199,21,133) },
|
||||
{ "midnightblue", RGB_COLOR(25,25,112) },
|
||||
{ "mintcream", RGB_COLOR(245,255,250) },
|
||||
{ "mistyrose", RGB_COLOR(255,228,225) },
|
||||
{ "moccasin", RGB_COLOR(255,228,181) },
|
||||
{ "navajowhite", RGB_COLOR(255,222,173) },
|
||||
{ "navy", RGB_COLOR(0,0,128) },
|
||||
{ "oldlace", RGB_COLOR(253,245,230) },
|
||||
{ "olive", RGB_COLOR(128,128,0) },
|
||||
{ "olivedrab", RGB_COLOR(107,142,35) },
|
||||
{ "orange", RGB_COLOR(255,165,0) },
|
||||
{ "orangered", RGB_COLOR(255,69,0) },
|
||||
{ "orchid", RGB_COLOR(218,112,214) },
|
||||
{ "palegoldenrod", RGB_COLOR(238,232,170) },
|
||||
{ "palegreen", RGB_COLOR(152,251,152) },
|
||||
{ "paleturquoise", RGB_COLOR(175,238,238) },
|
||||
{ "palevioletred", RGB_COLOR(219,112,147) },
|
||||
{ "papayawhip", RGB_COLOR(255,239,213) },
|
||||
{ "peachpuff", RGB_COLOR(255,218,185) },
|
||||
{ "peru", RGB_COLOR(205,133,63) },
|
||||
{ "pink", RGB_COLOR(255,192,203) },
|
||||
{ "plum", RGB_COLOR(221,160,221) },
|
||||
{ "powderblue", RGB_COLOR(176,224,230) },
|
||||
{ "purple", RGB_COLOR(128,0,128) },
|
||||
{ "red", RGB_COLOR(255,0,0) },
|
||||
{ "rosybrown", RGB_COLOR(188,143,143) },
|
||||
{ "royalblue", RGB_COLOR(65,105,225) },
|
||||
{ "saddlebrown", RGB_COLOR(139,69,19) },
|
||||
{ "salmon", RGB_COLOR(250,128,114) },
|
||||
{ "sandybrown", RGB_COLOR(244,164,96) },
|
||||
{ "seagreen", RGB_COLOR(46,139,87) },
|
||||
{ "seashell", RGB_COLOR(255,245,238) },
|
||||
{ "sienna", RGB_COLOR(160,82,45) },
|
||||
{ "silver", RGB_COLOR(192,192,192) },
|
||||
{ "skyblue", RGB_COLOR(135,206,235) },
|
||||
{ "slateblue", RGB_COLOR(106,90,205) },
|
||||
{ "slategray", RGB_COLOR(112,128,144) },
|
||||
{ "slategrey", RGB_COLOR(112,128,144) },
|
||||
{ "snow", RGB_COLOR(255,250,250) },
|
||||
{ "springgreen", RGB_COLOR(0,255,127) },
|
||||
{ "steelblue", RGB_COLOR(70,130,180) },
|
||||
{ "tan", RGB_COLOR(210,180,140) },
|
||||
{ "teal", RGB_COLOR(0,128,128) },
|
||||
{ "thistle", RGB_COLOR(216,191,216) },
|
||||
{ "tomato", RGB_COLOR(255,99,71) },
|
||||
{ "turquoise", RGB_COLOR(64,224,208) },
|
||||
{ "violet", RGB_COLOR(238,130,238) },
|
||||
{ "wheat", RGB_COLOR(245,222,179) },
|
||||
{ "white", RGB_COLOR(255,255,255) },
|
||||
{ "whitesmoke", RGB_COLOR(245,245,245) },
|
||||
{ "yellow", RGB_COLOR(255,255,0) },
|
||||
{ "yellowgreen", RGB_COLOR(154,205,50) },
|
||||
{ 0, { 0, 0, 0, 0 } } /* Terminator. */
|
||||
};
|
||||
|
||||
/* Get the color named NAME. If the color was found, returns 1 and
|
||||
stores the color into *COLOR. If the color was not found, returns 0 and
|
||||
does not modify *COLOR. */
|
||||
int
|
||||
grub_gui_get_named_color (const char *name,
|
||||
grub_gui_color_t *color)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; named_colors[i].name; i++)
|
||||
{
|
||||
if (grub_strcmp (named_colors[i].name, name) == 0)
|
||||
{
|
||||
*color = named_colors[i].color;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
723
gfxmenu/theme_loader.c
Normal file
723
gfxmenu/theme_loader.c
Normal file
|
@ -0,0 +1,723 @@
|
|||
/* theme_loader.c - Theme file loader for gfxmenu. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gui.h>
|
||||
|
||||
/* Construct a new box widget using ABSPATTERN to find the pixmap files for
|
||||
it, storing the new box instance at *BOXPTR.
|
||||
PATTERN should be of the form: "(hd0,0)/somewhere/style*.png".
|
||||
The '*' then gets substituted with the various pixmap names that the
|
||||
box uses. */
|
||||
static grub_err_t
|
||||
recreate_box_absolute (grub_gfxmenu_box_t *boxptr, const char *abspattern)
|
||||
{
|
||||
char *prefix;
|
||||
char *suffix;
|
||||
char *star;
|
||||
grub_gfxmenu_box_t box;
|
||||
|
||||
star = grub_strchr (abspattern, '*');
|
||||
if (! star)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"missing `*' in box pixmap pattern `%s'", abspattern);
|
||||
|
||||
/* Prefix: Get the part before the '*'. */
|
||||
prefix = grub_malloc (star - abspattern + 1);
|
||||
if (! prefix)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (prefix, abspattern, star - abspattern);
|
||||
prefix[star - abspattern] = '\0';
|
||||
|
||||
/* Suffix: Everything after the '*' is the suffix. */
|
||||
suffix = star + 1;
|
||||
|
||||
box = grub_gfxmenu_create_box (prefix, suffix);
|
||||
grub_free (prefix);
|
||||
if (! box)
|
||||
return grub_errno;
|
||||
|
||||
if (*boxptr)
|
||||
(*boxptr)->destroy (*boxptr);
|
||||
*boxptr = box;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
/* Construct a new box widget using PATTERN to find the pixmap files for it,
|
||||
storing the new widget at *BOXPTR. PATTERN should be of the form:
|
||||
"somewhere/style*.png". The '*' then gets substituted with the various
|
||||
pixmap names that the widget uses.
|
||||
|
||||
Important! The value of *BOXPTR must be initialized! It must either
|
||||
(1) Be 0 (a NULL pointer), or
|
||||
(2) Be a pointer to a valid 'grub_gfxmenu_box_t' instance.
|
||||
In this case, the previous instance is destroyed. */
|
||||
grub_err_t
|
||||
grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||
const char *pattern, const char *theme_dir)
|
||||
{
|
||||
char *abspattern;
|
||||
|
||||
/* Check arguments. */
|
||||
if (! pattern)
|
||||
{
|
||||
/* If no pixmap pattern is given, then just create an empty box. */
|
||||
if (*boxptr)
|
||||
(*boxptr)->destroy (*boxptr);
|
||||
*boxptr = grub_gfxmenu_create_box (0, 0);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (! theme_dir)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"styled box missing theme directory");
|
||||
|
||||
/* Resolve to an absolute path. */
|
||||
abspattern = grub_resolve_relative_path (theme_dir, pattern);
|
||||
if (! abspattern)
|
||||
return grub_errno;
|
||||
|
||||
/* Create the box. */
|
||||
recreate_box_absolute (boxptr, abspattern);
|
||||
grub_free (abspattern);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Set the specified property NAME on the view to the given string VALUE.
|
||||
The caller is responsible for the lifetimes of NAME and VALUE. */
|
||||
static grub_err_t
|
||||
theme_set_string (grub_gfxmenu_view_t view,
|
||||
const char *name,
|
||||
const char *value,
|
||||
const char *theme_dir,
|
||||
const char *filename,
|
||||
int line_num,
|
||||
int col_num)
|
||||
{
|
||||
if (! grub_strcmp ("title-font", name))
|
||||
view->title_font = grub_font_get (value);
|
||||
else if (! grub_strcmp ("message-font", name))
|
||||
view->message_font = grub_font_get (value);
|
||||
else if (! grub_strcmp ("terminal-font", name))
|
||||
{
|
||||
grub_free (view->terminal_font_name);
|
||||
view->terminal_font_name = grub_strdup (value);
|
||||
if (! view->terminal_font_name)
|
||||
return grub_errno;
|
||||
}
|
||||
else if (! grub_strcmp ("title-color", name))
|
||||
grub_gui_parse_color (value, &view->title_color);
|
||||
else if (! grub_strcmp ("message-color", name))
|
||||
grub_gui_parse_color (value, &view->message_color);
|
||||
else if (! grub_strcmp ("message-bg-color", name))
|
||||
grub_gui_parse_color (value, &view->message_bg_color);
|
||||
else if (! grub_strcmp ("desktop-image", name))
|
||||
{
|
||||
struct grub_video_bitmap *raw_bitmap;
|
||||
struct grub_video_bitmap *scaled_bitmap;
|
||||
char *path;
|
||||
path = grub_resolve_relative_path (theme_dir, value);
|
||||
if (! path)
|
||||
return grub_errno;
|
||||
if (grub_video_bitmap_load (&raw_bitmap, path) != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_free (path);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_free(path);
|
||||
grub_video_bitmap_create_scaled (&scaled_bitmap,
|
||||
view->screen.width,
|
||||
view->screen.height,
|
||||
raw_bitmap,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||
grub_video_bitmap_destroy (raw_bitmap);
|
||||
if (! scaled_bitmap)
|
||||
{
|
||||
grub_error_push ();
|
||||
return grub_error (grub_errno, "error scaling desktop image");
|
||||
}
|
||||
|
||||
grub_video_bitmap_destroy (view->desktop_image);
|
||||
view->desktop_image = scaled_bitmap;
|
||||
}
|
||||
else if (! grub_strcmp ("desktop-color", name))
|
||||
grub_gui_parse_color (value, &view->desktop_color);
|
||||
else if (! grub_strcmp ("terminal-box", name))
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_gui_recreate_box (&view->terminal_box, value, theme_dir);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
}
|
||||
else if (! grub_strcmp ("title-text", name))
|
||||
{
|
||||
grub_free (view->title_text);
|
||||
view->title_text = grub_strdup (value);
|
||||
if (! view->title_text)
|
||||
return grub_errno;
|
||||
}
|
||||
else
|
||||
{
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"%s:%d:%d unknown property `%s'",
|
||||
filename, line_num, col_num, name);
|
||||
}
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
struct parsebuf
|
||||
{
|
||||
char *buf;
|
||||
int pos;
|
||||
int len;
|
||||
int line_num;
|
||||
int col_num;
|
||||
const char *filename;
|
||||
char *theme_dir;
|
||||
grub_gfxmenu_view_t view;
|
||||
};
|
||||
|
||||
static int
|
||||
has_more (struct parsebuf *p)
|
||||
{
|
||||
return p->pos < p->len;
|
||||
}
|
||||
|
||||
static int
|
||||
read_char (struct parsebuf *p)
|
||||
{
|
||||
if (has_more (p))
|
||||
{
|
||||
char c;
|
||||
c = p->buf[p->pos++];
|
||||
if (c == '\n')
|
||||
{
|
||||
p->line_num++;
|
||||
p->col_num = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->col_num++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
peek_char (struct parsebuf *p)
|
||||
{
|
||||
if (has_more (p))
|
||||
return p->buf[p->pos];
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_whitespace (char c)
|
||||
{
|
||||
return (c == ' '
|
||||
|| c == '\t'
|
||||
|| c == '\r'
|
||||
|| c == '\n'
|
||||
|| c == '\f');
|
||||
}
|
||||
|
||||
static void
|
||||
skip_whitespace (struct parsebuf *p)
|
||||
{
|
||||
while (has_more (p) && is_whitespace(peek_char (p)))
|
||||
read_char (p);
|
||||
}
|
||||
|
||||
static void
|
||||
advance_to_next_line (struct parsebuf *p)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Eat characters up to the newline. */
|
||||
do
|
||||
{
|
||||
c = read_char (p);
|
||||
}
|
||||
while (c != -1 && c != '\n');
|
||||
}
|
||||
|
||||
static int
|
||||
is_identifier_char (int c)
|
||||
{
|
||||
return (c != -1
|
||||
&& (grub_isalpha(c)
|
||||
|| grub_isdigit(c)
|
||||
|| c == '_'
|
||||
|| c == '-'));
|
||||
}
|
||||
|
||||
static char *
|
||||
read_identifier (struct parsebuf *p)
|
||||
{
|
||||
/* Index of the first character of the identifier in p->buf. */
|
||||
int start;
|
||||
/* Next index after the last character of the identifer in p->buf. */
|
||||
int end;
|
||||
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Capture the start of the identifier. */
|
||||
start = p->pos;
|
||||
|
||||
/* Scan for the end. */
|
||||
while (is_identifier_char (peek_char (p)))
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
|
||||
if (end - start < 1)
|
||||
return 0;
|
||||
|
||||
return grub_new_substring (p->buf, start, end);
|
||||
}
|
||||
|
||||
static char *
|
||||
read_expression (struct parsebuf *p)
|
||||
{
|
||||
int start;
|
||||
int end;
|
||||
|
||||
skip_whitespace (p);
|
||||
if (peek_char (p) == '"')
|
||||
{
|
||||
/* Read as a quoted string.
|
||||
The quotation marks are not included in the expression value. */
|
||||
/* Skip opening quotation mark. */
|
||||
read_char (p);
|
||||
start = p->pos;
|
||||
while (has_more (p) && peek_char (p) != '"')
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
/* Skip the terminating quotation mark. */
|
||||
read_char (p);
|
||||
}
|
||||
else if (peek_char (p) == '(')
|
||||
{
|
||||
/* Read as a parenthesized string -- for tuples/coordinates. */
|
||||
/* The parentheses are included in the expression value. */
|
||||
int c;
|
||||
|
||||
start = p->pos;
|
||||
do
|
||||
{
|
||||
c = read_char (p);
|
||||
}
|
||||
while (c != -1 && c != ')');
|
||||
end = p->pos;
|
||||
}
|
||||
else if (has_more (p))
|
||||
{
|
||||
/* Read as a single word -- for numeric values or words without
|
||||
whitespace. */
|
||||
start = p->pos;
|
||||
while (has_more (p) && ! is_whitespace (peek_char (p)))
|
||||
read_char (p);
|
||||
end = p->pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The end of the theme file has been reached. */
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d expression expected in theme file",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return grub_new_substring (p->buf, start, end);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
parse_proportional_spec (char *value, signed *abs, grub_fixed_signed_t *prop)
|
||||
{
|
||||
signed num;
|
||||
char *ptr;
|
||||
int sig = 0;
|
||||
*abs = 0;
|
||||
*prop = 0;
|
||||
ptr = value;
|
||||
while (*ptr)
|
||||
{
|
||||
sig = 0;
|
||||
|
||||
while (*ptr == '-' || *ptr == '+')
|
||||
{
|
||||
if (*ptr == '-')
|
||||
sig = !sig;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
num = grub_strtoul (ptr, &ptr, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
if (sig)
|
||||
num = -num;
|
||||
if (*ptr == '%')
|
||||
{
|
||||
*prop += grub_fixed_fsf_divide (grub_signed_to_fixed (num), 100);
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
*abs += num;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
/* Read a GUI object specification from the theme file.
|
||||
Any components created will be added to the GUI container PARENT. */
|
||||
static grub_err_t
|
||||
read_object (struct parsebuf *p, grub_gui_container_t parent)
|
||||
{
|
||||
grub_video_rect_t bounds;
|
||||
|
||||
char *name;
|
||||
name = read_identifier (p);
|
||||
if (! name)
|
||||
goto cleanup;
|
||||
|
||||
grub_gui_component_t component = 0;
|
||||
if (grub_strcmp (name, "label") == 0)
|
||||
{
|
||||
component = grub_gui_label_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "image") == 0)
|
||||
{
|
||||
component = grub_gui_image_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "vbox") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_vbox_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "hbox") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_hbox_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "canvas") == 0)
|
||||
{
|
||||
component = (grub_gui_component_t) grub_gui_canvas_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "progress_bar") == 0)
|
||||
{
|
||||
component = grub_gui_progress_bar_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "circular_progress") == 0)
|
||||
{
|
||||
component = grub_gui_circular_progress_new ();
|
||||
}
|
||||
else if (grub_strcmp (name, "boot_menu") == 0)
|
||||
{
|
||||
component = grub_gui_list_new ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unknown type. */
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d unknown object type `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (! component)
|
||||
goto cleanup;
|
||||
|
||||
/* Inform the component about the theme so it can find its resources. */
|
||||
component->ops->set_property (component, "theme_dir", p->theme_dir);
|
||||
component->ops->set_property (component, "theme_path", p->filename);
|
||||
|
||||
/* Add the component as a child of PARENT. */
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
bounds.width = -1;
|
||||
bounds.height = -1;
|
||||
component->ops->set_bounds (component, &bounds);
|
||||
parent->ops->add (parent, component);
|
||||
|
||||
skip_whitespace (p);
|
||||
if (read_char (p) != '{')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d expected `{' after object type name `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
while (has_more (p))
|
||||
{
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Check whether the end has been encountered. */
|
||||
if (peek_char (p) == '}')
|
||||
{
|
||||
/* Skip the closing brace. */
|
||||
read_char (p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (peek_char (p) == '#')
|
||||
{
|
||||
/* Skip comments. */
|
||||
advance_to_next_line (p);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (peek_char (p) == '+')
|
||||
{
|
||||
/* Skip the '+'. */
|
||||
read_char (p);
|
||||
|
||||
/* Check whether this component is a container. */
|
||||
if (component->ops->is_instance (component, "container"))
|
||||
{
|
||||
/* Read the sub-object recursively and add it as a child. */
|
||||
if (read_object (p, (grub_gui_container_t) component) != 0)
|
||||
goto cleanup;
|
||||
/* After reading the sub-object, resume parsing, expecting
|
||||
another property assignment or sub-object definition. */
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d attempted to add object to non-container",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
char *property;
|
||||
property = read_identifier (p);
|
||||
if (! property)
|
||||
{
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d identifier expected in theme file",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
skip_whitespace (p);
|
||||
if (read_char (p) != '=')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d expected `=' after property name `%s'",
|
||||
p->filename, p->line_num, p->col_num, property);
|
||||
grub_free (property);
|
||||
goto cleanup;
|
||||
}
|
||||
skip_whitespace (p);
|
||||
|
||||
char *value;
|
||||
value = read_expression (p);
|
||||
if (! value)
|
||||
{
|
||||
grub_free (property);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Handle the property value. */
|
||||
if (grub_strcmp (property, "left") == 0)
|
||||
parse_proportional_spec (value, &component->x, &component->xfrac);
|
||||
else if (grub_strcmp (property, "top") == 0)
|
||||
parse_proportional_spec (value, &component->y, &component->yfrac);
|
||||
else if (grub_strcmp (property, "width") == 0)
|
||||
parse_proportional_spec (value, &component->w, &component->wfrac);
|
||||
else if (grub_strcmp (property, "height") == 0)
|
||||
parse_proportional_spec (value, &component->h, &component->hfrac);
|
||||
else
|
||||
/* General property handling. */
|
||||
component->ops->set_property (component, property, value);
|
||||
|
||||
grub_free (value);
|
||||
grub_free (property);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
grub_free (name);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
read_property (struct parsebuf *p)
|
||||
{
|
||||
char *name;
|
||||
|
||||
/* Read the property name. */
|
||||
name = read_identifier (p);
|
||||
if (! name)
|
||||
{
|
||||
advance_to_next_line (p);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Skip whitespace before separator. */
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Read separator. */
|
||||
if (read_char (p) != ':')
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d missing separator after property name `%s'",
|
||||
p->filename, p->line_num, p->col_num, name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Skip whitespace after separator. */
|
||||
skip_whitespace (p);
|
||||
|
||||
/* Get the value based on its type. */
|
||||
if (peek_char (p) == '"')
|
||||
{
|
||||
/* String value (e.g., '"My string"'). */
|
||||
char *value = read_expression (p);
|
||||
if (! value)
|
||||
{
|
||||
grub_error (GRUB_ERR_IO, "%s:%d:%d missing property value",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto done;
|
||||
}
|
||||
/* If theme_set_string results in an error, grub_errno will be returned
|
||||
below. */
|
||||
theme_set_string (p->view, name, value, p->theme_dir,
|
||||
p->filename, p->line_num, p->col_num);
|
||||
grub_free (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_IO,
|
||||
"%s:%d:%d property value invalid; "
|
||||
"enclose literal values in quotes (\")",
|
||||
p->filename, p->line_num, p->col_num);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
grub_free (name);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t
|
||||
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||
{
|
||||
grub_file_t file;
|
||||
struct parsebuf p;
|
||||
|
||||
p.view = view;
|
||||
p.theme_dir = grub_get_dirname (theme_path);
|
||||
|
||||
file = grub_file_open (theme_path);
|
||||
if (! file)
|
||||
{
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
p.len = grub_file_size (file);
|
||||
p.buf = grub_malloc (p.len);
|
||||
p.pos = 0;
|
||||
p.line_num = 1;
|
||||
p.col_num = 1;
|
||||
p.filename = theme_path;
|
||||
if (! p.buf)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
if (grub_file_read (file, p.buf, p.len) != p.len)
|
||||
{
|
||||
grub_free (p.buf);
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
|
||||
view->canvas = grub_gui_canvas_new ();
|
||||
((grub_gui_component_t) view->canvas)
|
||||
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
||||
&view->screen);
|
||||
|
||||
while (has_more (&p))
|
||||
{
|
||||
/* Skip comments (lines beginning with #). */
|
||||
if (peek_char (&p) == '#')
|
||||
{
|
||||
advance_to_next_line (&p);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Find the first non-whitespace character. */
|
||||
skip_whitespace (&p);
|
||||
|
||||
/* Handle the content. */
|
||||
if (peek_char (&p) == '+')
|
||||
{
|
||||
/* Skip the '+'. */
|
||||
read_char (&p);
|
||||
read_object (&p, view->canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
read_property (&p);
|
||||
}
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Set the new theme path. */
|
||||
grub_free (view->theme_path);
|
||||
view->theme_path = grub_strdup (theme_path);
|
||||
goto cleanup;
|
||||
|
||||
fail:
|
||||
if (view->canvas)
|
||||
{
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
view->canvas = 0;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
grub_free (p.buf);
|
||||
grub_file_close (file);
|
||||
grub_free (p.theme_dir);
|
||||
return grub_errno;
|
||||
}
|
453
gfxmenu/view.c
Normal file
453
gfxmenu/view.c
Normal file
|
@ -0,0 +1,453 @@
|
|||
/* view.c - Graphical menu interface MVC view. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/gfxterm.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/menu_viewer.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/icon_manager.h>
|
||||
|
||||
static void
|
||||
init_terminal (grub_gfxmenu_view_t view);
|
||||
static grub_video_rect_t term_rect;
|
||||
static grub_gfxmenu_view_t term_view;
|
||||
|
||||
/* Create a new view object, loading the theme specified by THEME_PATH and
|
||||
associating MODEL with the view. */
|
||||
grub_gfxmenu_view_t
|
||||
grub_gfxmenu_view_new (const char *theme_path,
|
||||
int width, int height)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
grub_font_t default_font;
|
||||
grub_gui_color_t default_fg_color;
|
||||
grub_gui_color_t default_bg_color;
|
||||
|
||||
view = grub_malloc (sizeof (*view));
|
||||
if (! view)
|
||||
return 0;
|
||||
|
||||
view->screen.x = 0;
|
||||
view->screen.y = 0;
|
||||
view->screen.width = width;
|
||||
view->screen.height = height;
|
||||
|
||||
default_font = grub_font_get ("Unknown Regular 16");
|
||||
default_fg_color = grub_gui_color_rgb (0, 0, 0);
|
||||
default_bg_color = grub_gui_color_rgb (255, 255, 255);
|
||||
|
||||
view->canvas = 0;
|
||||
|
||||
view->title_font = default_font;
|
||||
view->message_font = default_font;
|
||||
view->terminal_font_name = grub_strdup ("Fixed 10");
|
||||
view->title_color = default_fg_color;
|
||||
view->message_color = default_bg_color;
|
||||
view->message_bg_color = default_fg_color;
|
||||
view->desktop_image = 0;
|
||||
view->desktop_color = default_bg_color;
|
||||
view->terminal_box = grub_gfxmenu_create_box (0, 0);
|
||||
view->title_text = grub_strdup ("GRUB Boot Menu");
|
||||
view->progress_message_text = 0;
|
||||
view->theme_path = 0;
|
||||
|
||||
/* Set the timeout bar's frame. */
|
||||
view->progress_message_frame.width = view->screen.width * 4 / 5;
|
||||
view->progress_message_frame.height = 50;
|
||||
view->progress_message_frame.x = view->screen.x
|
||||
+ (view->screen.width - view->progress_message_frame.width) / 2;
|
||||
view->progress_message_frame.y = view->screen.y
|
||||
+ view->screen.height - 90 - 20 - view->progress_message_frame.height;
|
||||
|
||||
if (grub_gfxmenu_view_load_theme (view, theme_path) != 0)
|
||||
{
|
||||
grub_gfxmenu_view_destroy (view);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
/* Destroy the view object. All used memory is freed. */
|
||||
void
|
||||
grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
grub_video_bitmap_destroy (view->desktop_image);
|
||||
if (view->terminal_box)
|
||||
view->terminal_box->destroy (view->terminal_box);
|
||||
grub_free (view->terminal_font_name);
|
||||
grub_free (view->title_text);
|
||||
grub_free (view->progress_message_text);
|
||||
grub_free (view->theme_path);
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->destroy (view->canvas);
|
||||
grub_free (view);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_background (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *bounds)
|
||||
{
|
||||
if (view->desktop_image)
|
||||
{
|
||||
struct grub_video_bitmap *img = view->desktop_image;
|
||||
grub_video_blit_bitmap (img, GRUB_VIDEO_BLIT_REPLACE,
|
||||
bounds->x, bounds->y,
|
||||
bounds->x - view->screen.x,
|
||||
bounds->y - view->screen.y,
|
||||
bounds->width, bounds->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_video_fill_rect (grub_gui_map_color (view->desktop_color),
|
||||
bounds->x, bounds->y,
|
||||
bounds->width, bounds->height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_title (grub_gfxmenu_view_t view)
|
||||
{
|
||||
if (! view->title_text)
|
||||
return;
|
||||
|
||||
/* Center the title. */
|
||||
int title_width = grub_font_get_string_width (view->title_font,
|
||||
view->title_text);
|
||||
int x = (view->screen.width - title_width) / 2;
|
||||
int y = 40 + grub_font_get_ascent (view->title_font);
|
||||
grub_font_draw_string (view->title_text,
|
||||
view->title_font,
|
||||
grub_gui_map_color (view->title_color),
|
||||
x, y);
|
||||
}
|
||||
|
||||
struct progress_value_data
|
||||
{
|
||||
int visible;
|
||||
int start;
|
||||
int end;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
|
||||
|
||||
static void
|
||||
update_timeouts (int visible, int start, int value, int end)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *cur;
|
||||
|
||||
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||
cur->set_state (cur->self, visible, start, value, end);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_timeouts (struct grub_gfxmenu_view *view)
|
||||
{
|
||||
struct grub_gfxmenu_timeout_notify *cur;
|
||||
|
||||
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||
{
|
||||
grub_video_rect_t bounds;
|
||||
cur->self->ops->get_bounds (cur->self, &bounds);
|
||||
grub_gfxmenu_view_redraw (view, &bounds);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_print_timeout (int timeout, void *data)
|
||||
{
|
||||
struct grub_gfxmenu_view *view = data;
|
||||
|
||||
if (view->first_timeout == -1)
|
||||
view->first_timeout = timeout;
|
||||
|
||||
update_timeouts (1, -(view->first_timeout + 1), -timeout, 0);
|
||||
redraw_timeouts (view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
redraw_timeouts (view);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_clear_timeout (void *data)
|
||||
{
|
||||
struct grub_gfxmenu_view *view = data;
|
||||
|
||||
update_timeouts (0, 1, 0, 0);
|
||||
redraw_timeouts (view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
redraw_timeouts (view);
|
||||
}
|
||||
|
||||
static void
|
||||
update_menu_visit (grub_gui_component_t component,
|
||||
void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
view = userdata;
|
||||
if (component->ops->is_instance (component, "list"))
|
||||
{
|
||||
grub_gui_list_t list = (grub_gui_list_t) component;
|
||||
list->ops->set_view_info (list, view);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update any boot menu components with the current menu model and
|
||||
theme path. */
|
||||
static void
|
||||
update_menu_components (grub_gfxmenu_view_t view)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
update_menu_visit, view);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_message (grub_gfxmenu_view_t view)
|
||||
{
|
||||
char *text = view->progress_message_text;
|
||||
grub_video_rect_t f = view->progress_message_frame;
|
||||
if (! text)
|
||||
return;
|
||||
|
||||
grub_font_t font = view->message_font;
|
||||
grub_video_color_t color = grub_gui_map_color (view->message_color);
|
||||
|
||||
/* Border. */
|
||||
grub_video_fill_rect (color,
|
||||
f.x-1, f.y-1, f.width+2, f.height+2);
|
||||
/* Fill. */
|
||||
grub_video_fill_rect (grub_gui_map_color (view->message_bg_color),
|
||||
f.x, f.y, f.width, f.height);
|
||||
|
||||
/* Center the text. */
|
||||
int text_width = grub_font_get_string_width (font, text);
|
||||
int x = f.x + (f.width - text_width) / 2;
|
||||
int y = (f.y + (f.height - grub_font_get_descent (font)) / 2
|
||||
+ grub_font_get_ascent (font) / 2);
|
||||
grub_font_draw_string (text, font, color, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *region)
|
||||
{
|
||||
if (grub_video_have_common_points (&term_rect, region))
|
||||
grub_gfxterm_schedule_repaint ();
|
||||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
|
||||
redraw_background (view, region);
|
||||
if (view->canvas)
|
||||
view->canvas->component.ops->paint (view->canvas, region);
|
||||
draw_title (view);
|
||||
if (grub_video_have_common_points (&view->progress_message_frame, region))
|
||||
draw_message (view);
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
|
||||
{
|
||||
init_terminal (view);
|
||||
|
||||
/* Clear the screen; there may be garbage left over in video memory. */
|
||||
grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
|
||||
view->screen.x, view->screen.y,
|
||||
view->screen.width, view->screen.height);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
|
||||
view->screen.x, view->screen.y,
|
||||
view->screen.width, view->screen.height);
|
||||
|
||||
update_menu_components (view);
|
||||
|
||||
grub_gfxmenu_view_redraw (view, &view->screen);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_gfxmenu_view_redraw (view, &view->screen);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_menu_visit (grub_gui_component_t component,
|
||||
void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view;
|
||||
view = userdata;
|
||||
if (component->ops->is_instance (component, "list"))
|
||||
{
|
||||
grub_gui_list_t list;
|
||||
grub_video_rect_t bounds;
|
||||
|
||||
list = (grub_gui_list_t) component;
|
||||
component->ops->get_bounds (component, &bounds);
|
||||
grub_gfxmenu_view_redraw (view, &bounds);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
|
||||
{
|
||||
update_menu_components (view);
|
||||
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
{
|
||||
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
|
||||
redraw_menu_visit, view);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data)
|
||||
{
|
||||
grub_gfxmenu_view_t view = data;
|
||||
|
||||
view->selected = entry;
|
||||
grub_gfxmenu_redraw_menu (view);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_gfxmenu_draw_terminal_box (void)
|
||||
{
|
||||
grub_gfxmenu_box_t term_box;
|
||||
|
||||
term_box = term_view->terminal_box;
|
||||
if (!term_box)
|
||||
return;
|
||||
|
||||
term_box->set_content_size (term_box, term_rect.width,
|
||||
term_rect.height);
|
||||
|
||||
term_box->draw (term_box,
|
||||
term_rect.x - term_box->get_left_pad (term_box),
|
||||
term_rect.y - term_box->get_top_pad (term_box));
|
||||
grub_video_swap_buffers ();
|
||||
if (term_view->double_repaint)
|
||||
term_box->draw (term_box,
|
||||
term_rect.x - term_box->get_left_pad (term_box),
|
||||
term_rect.y - term_box->get_top_pad (term_box));
|
||||
}
|
||||
|
||||
static void
|
||||
init_terminal (grub_gfxmenu_view_t view)
|
||||
{
|
||||
term_rect.width = view->screen.width * 7 / 10;
|
||||
term_rect.height = view->screen.height * 7 / 10;
|
||||
|
||||
term_rect.x = view->screen.x + view->screen.width * (10 - 7) / 10 / 2;
|
||||
term_rect.y = view->screen.y + view->screen.height * (10 - 7) / 10 / 2;
|
||||
|
||||
term_view = view;
|
||||
|
||||
/* Note: currently there is no API for changing the gfxterm font
|
||||
on the fly, so whatever font the initially loaded theme specifies
|
||||
will be permanent. */
|
||||
grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY, term_rect.x,
|
||||
term_rect.y,
|
||||
term_rect.width, term_rect.height,
|
||||
view->double_repaint, view->terminal_font_name, 3);
|
||||
grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box;
|
||||
}
|
||||
|
||||
/* FIXME: previously notifications were displayed in special case.
|
||||
Is it necessary?
|
||||
*/
|
||||
#if 0
|
||||
/* Sets MESSAGE as the progress message for the view.
|
||||
MESSAGE can be 0, in which case no message is displayed. */
|
||||
static void
|
||||
set_progress_message (grub_gfxmenu_view_t view, const char *message)
|
||||
{
|
||||
grub_free (view->progress_message_text);
|
||||
if (message)
|
||||
view->progress_message_text = grub_strdup (message);
|
||||
else
|
||||
view->progress_message_text = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
notify_booting (grub_menu_entry_t entry, void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
|
||||
|
||||
char *s = grub_malloc (100 + grub_strlen (entry->title));
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
grub_sprintf (s, "Booting '%s'", entry->title);
|
||||
set_progress_message (view, s);
|
||||
grub_free (s);
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_fallback (grub_menu_entry_t entry, void *userdata)
|
||||
{
|
||||
grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
|
||||
|
||||
char *s = grub_malloc (100 + grub_strlen (entry->title));
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
grub_sprintf (s, "Falling back to '%s'", entry->title);
|
||||
set_progress_message (view, s);
|
||||
grub_free (s);
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
grub_video_swap_buffers ();
|
||||
if (view->double_repaint)
|
||||
grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_execution_failure (void *userdata __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static struct grub_menu_execute_callback execute_callback =
|
||||
{
|
||||
.notify_booting = notify_booting,
|
||||
.notify_fallback = notify_fallback,
|
||||
.notify_failure = notify_execution_failure
|
||||
};
|
||||
|
||||
#endif
|
313
gfxmenu/widget-box.c
Normal file
313
gfxmenu/widget-box.c
Normal file
|
@ -0,0 +1,313 @@
|
|||
/* widget_box.c - Pixmap-stylized box widget. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 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/err.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
|
||||
enum box_pixmaps
|
||||
{
|
||||
BOX_PIXMAP_NW, BOX_PIXMAP_NE, BOX_PIXMAP_SE, BOX_PIXMAP_SW,
|
||||
BOX_PIXMAP_N, BOX_PIXMAP_E, BOX_PIXMAP_S, BOX_PIXMAP_W,
|
||||
BOX_PIXMAP_CENTER
|
||||
};
|
||||
|
||||
static const char *box_pixmap_names[] = {
|
||||
/* Corners: */
|
||||
"nw", "ne", "se", "sw",
|
||||
/* Sides: */
|
||||
"n", "e", "s", "w",
|
||||
/* Center: */
|
||||
"c"
|
||||
};
|
||||
|
||||
#define BOX_NUM_PIXMAPS (sizeof(box_pixmap_names)/sizeof(*box_pixmap_names))
|
||||
|
||||
static int
|
||||
get_height (struct grub_video_bitmap *bitmap)
|
||||
{
|
||||
if (bitmap)
|
||||
return grub_video_bitmap_get_height (bitmap);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_width (struct grub_video_bitmap *bitmap)
|
||||
{
|
||||
if (bitmap)
|
||||
return grub_video_bitmap_get_width (bitmap);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
blit (grub_gfxmenu_box_t self, int pixmap_index, int x, int y)
|
||||
{
|
||||
struct grub_video_bitmap *bitmap;
|
||||
bitmap = self->scaled_pixmaps[pixmap_index];
|
||||
if (! bitmap)
|
||||
return;
|
||||
grub_video_blit_bitmap (bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
x, y, 0, 0,
|
||||
grub_video_bitmap_get_width (bitmap),
|
||||
grub_video_bitmap_get_height (bitmap));
|
||||
}
|
||||
|
||||
static void
|
||||
draw (grub_gfxmenu_box_t self, int x, int y)
|
||||
{
|
||||
int height_n;
|
||||
int height_s;
|
||||
int height_e;
|
||||
int height_w;
|
||||
int width_n;
|
||||
int width_s;
|
||||
int width_e;
|
||||
int width_w;
|
||||
|
||||
height_n = get_height (self->scaled_pixmaps[BOX_PIXMAP_N]);
|
||||
height_s = get_height (self->scaled_pixmaps[BOX_PIXMAP_S]);
|
||||
height_e = get_height (self->scaled_pixmaps[BOX_PIXMAP_E]);
|
||||
height_w = get_height (self->scaled_pixmaps[BOX_PIXMAP_W]);
|
||||
width_n = get_width (self->scaled_pixmaps[BOX_PIXMAP_N]);
|
||||
width_s = get_width (self->scaled_pixmaps[BOX_PIXMAP_S]);
|
||||
width_e = get_width (self->scaled_pixmaps[BOX_PIXMAP_E]);
|
||||
width_w = get_width (self->scaled_pixmaps[BOX_PIXMAP_W]);
|
||||
|
||||
/* Draw sides. */
|
||||
blit (self, BOX_PIXMAP_N, x + width_w, y);
|
||||
blit (self, BOX_PIXMAP_S, x + width_w, y + height_n + self->content_height);
|
||||
blit (self, BOX_PIXMAP_E, x + width_w + self->content_width, y + height_n);
|
||||
blit (self, BOX_PIXMAP_W, x, y + height_n);
|
||||
|
||||
/* Draw corners. */
|
||||
blit (self, BOX_PIXMAP_NW, x, y);
|
||||
blit (self, BOX_PIXMAP_NE, x + width_w + self->content_width, y);
|
||||
blit (self, BOX_PIXMAP_SE,
|
||||
x + width_w + self->content_width,
|
||||
y + height_n + self->content_height);
|
||||
blit (self, BOX_PIXMAP_SW, x, y + height_n + self->content_height);
|
||||
|
||||
/* Draw center. */
|
||||
blit (self, BOX_PIXMAP_CENTER, x + width_w, y + height_n);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
scale_pixmap (grub_gfxmenu_box_t self, int i, int w, int h)
|
||||
{
|
||||
struct grub_video_bitmap **scaled = &self->scaled_pixmaps[i];
|
||||
struct grub_video_bitmap *raw = self->raw_pixmaps[i];
|
||||
|
||||
if (raw == 0)
|
||||
return grub_errno;
|
||||
|
||||
if (w == -1)
|
||||
w = grub_video_bitmap_get_width (raw);
|
||||
if (h == -1)
|
||||
h = grub_video_bitmap_get_height (raw);
|
||||
|
||||
if (*scaled == 0
|
||||
|| ((int) grub_video_bitmap_get_width (*scaled) != w)
|
||||
|| ((int) grub_video_bitmap_get_height (*scaled) != h))
|
||||
{
|
||||
if (*scaled)
|
||||
{
|
||||
grub_video_bitmap_destroy (*scaled);
|
||||
*scaled = 0;
|
||||
}
|
||||
|
||||
/* Don't try to create a bitmap with a zero dimension. */
|
||||
if (w != 0 && h != 0)
|
||||
grub_video_bitmap_create_scaled (scaled, w, h, raw,
|
||||
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_error (grub_errno,
|
||||
"failed to scale bitmap for styled box pixmap #%d", i);
|
||||
}
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
set_content_size (grub_gfxmenu_box_t self,
|
||||
int width, int height)
|
||||
{
|
||||
self->content_width = width;
|
||||
self->content_height = height;
|
||||
|
||||
/* Resize sides to match the width and height. */
|
||||
/* It is assumed that the corners width/height match the adjacent sides. */
|
||||
|
||||
/* Resize N and S sides to match width. */
|
||||
if (scale_pixmap(self, BOX_PIXMAP_N, width, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
if (scale_pixmap(self, BOX_PIXMAP_S, width, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
|
||||
/* Resize E and W sides to match height. */
|
||||
if (scale_pixmap(self, BOX_PIXMAP_E, -1, height) != GRUB_ERR_NONE)
|
||||
return;
|
||||
if (scale_pixmap(self, BOX_PIXMAP_W, -1, height) != GRUB_ERR_NONE)
|
||||
return;
|
||||
|
||||
/* Don't scale the corners--they are assumed to match the sides. */
|
||||
if (scale_pixmap(self, BOX_PIXMAP_NW, -1, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
if (scale_pixmap(self, BOX_PIXMAP_SW, -1, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
if (scale_pixmap(self, BOX_PIXMAP_NE, -1, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
if (scale_pixmap(self, BOX_PIXMAP_SE, -1, -1) != GRUB_ERR_NONE)
|
||||
return;
|
||||
|
||||
/* Scale the center area. */
|
||||
if (scale_pixmap(self, BOX_PIXMAP_CENTER, width, height) != GRUB_ERR_NONE)
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
get_left_pad (grub_gfxmenu_box_t self)
|
||||
{
|
||||
return get_width (self->raw_pixmaps[BOX_PIXMAP_W]);
|
||||
}
|
||||
|
||||
static int
|
||||
get_top_pad (grub_gfxmenu_box_t self)
|
||||
{
|
||||
return get_height (self->raw_pixmaps[BOX_PIXMAP_N]);
|
||||
}
|
||||
|
||||
static int
|
||||
get_right_pad (grub_gfxmenu_box_t self)
|
||||
{
|
||||
return get_width (self->raw_pixmaps[BOX_PIXMAP_E]);
|
||||
}
|
||||
|
||||
static int
|
||||
get_bottom_pad (grub_gfxmenu_box_t self)
|
||||
{
|
||||
return get_height (self->raw_pixmaps[BOX_PIXMAP_S]);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy (grub_gfxmenu_box_t self)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < BOX_NUM_PIXMAPS; i++)
|
||||
{
|
||||
if (self->raw_pixmaps[i])
|
||||
grub_video_bitmap_destroy(self->raw_pixmaps[i]);
|
||||
self->raw_pixmaps[i] = 0;
|
||||
|
||||
if (self->scaled_pixmaps[i])
|
||||
grub_video_bitmap_destroy(self->scaled_pixmaps[i]);
|
||||
self->scaled_pixmaps[i] = 0;
|
||||
}
|
||||
grub_free (self->raw_pixmaps);
|
||||
self->raw_pixmaps = 0;
|
||||
grub_free (self->scaled_pixmaps);
|
||||
self->scaled_pixmaps = 0;
|
||||
|
||||
/* Free self: must be the last step! */
|
||||
grub_free (self);
|
||||
}
|
||||
|
||||
|
||||
/* Create a new box. If PIXMAPS_PREFIX and PIXMAPS_SUFFIX are both non-null,
|
||||
then an attempt is made to load the north, south, east, west, northwest,
|
||||
northeast, southeast, southwest, and center pixmaps.
|
||||
If either PIXMAPS_PREFIX or PIXMAPS_SUFFIX is 0, then no pixmaps are
|
||||
loaded, and the box has zero-width borders and is drawn transparent. */
|
||||
grub_gfxmenu_box_t
|
||||
grub_gfxmenu_create_box (const char *pixmaps_prefix,
|
||||
const char *pixmaps_suffix)
|
||||
{
|
||||
unsigned i;
|
||||
grub_gfxmenu_box_t box;
|
||||
|
||||
box = (grub_gfxmenu_box_t) grub_malloc (sizeof (*box));
|
||||
if (! box)
|
||||
return 0;
|
||||
|
||||
box->content_width = 0;
|
||||
box->content_height = 0;
|
||||
box->raw_pixmaps =
|
||||
(struct grub_video_bitmap **)
|
||||
grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *));
|
||||
box->scaled_pixmaps =
|
||||
(struct grub_video_bitmap **)
|
||||
grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *));
|
||||
|
||||
/* Initialize all pixmap pointers to NULL so that proper destruction can
|
||||
be performed if an error is encountered partway through construction. */
|
||||
for (i = 0; i < BOX_NUM_PIXMAPS; i++)
|
||||
box->raw_pixmaps[i] = 0;
|
||||
for (i = 0; i < BOX_NUM_PIXMAPS; i++)
|
||||
box->scaled_pixmaps[i] = 0;
|
||||
|
||||
/* Load the pixmaps. */
|
||||
for (i = 0; i < BOX_NUM_PIXMAPS; i++)
|
||||
{
|
||||
if (pixmaps_prefix && pixmaps_suffix)
|
||||
{
|
||||
char *path;
|
||||
char *path_end;
|
||||
|
||||
path = grub_malloc (grub_strlen (pixmaps_prefix)
|
||||
+ grub_strlen (box_pixmap_names[i])
|
||||
+ grub_strlen (pixmaps_suffix)
|
||||
+ 1);
|
||||
if (! path)
|
||||
goto fail_and_destroy;
|
||||
|
||||
/* Construct the specific path for this pixmap. */
|
||||
path_end = grub_stpcpy (path, pixmaps_prefix);
|
||||
path_end = grub_stpcpy (path_end, box_pixmap_names[i]);
|
||||
path_end = grub_stpcpy (path_end, pixmaps_suffix);
|
||||
|
||||
grub_video_bitmap_load (&box->raw_pixmaps[i], path);
|
||||
grub_free (path);
|
||||
|
||||
/* Ignore missing pixmaps. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
box->draw = draw;
|
||||
box->set_content_size = set_content_size;
|
||||
box->get_left_pad = get_left_pad;
|
||||
box->get_top_pad = get_top_pad;
|
||||
box->get_right_pad = get_right_pad;
|
||||
box->get_bottom_pad = get_bottom_pad;
|
||||
box->destroy = destroy;
|
||||
return box;
|
||||
|
||||
fail_and_destroy:
|
||||
destroy (box);
|
||||
return 0;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
|
|
34
gnulib/argp-ba.c
Normal file
34
gnulib/argp-ba.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
|
||||
Copyright (C) 1996, 1997, 1999, 2009, 2010 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* If set by the user program, it should point to string that is the
|
||||
bug-reporting address for the program. It will be printed by argp_help if
|
||||
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
|
||||
messages), embedded in a sentence that says something like `Report bugs to
|
||||
ADDR.'. */
|
||||
const char *argp_program_bug_address
|
||||
/* This variable should be zero-initialized. On most systems, putting it into
|
||||
BSS is sufficient. Not so on MacOS X 10.3 and 10.4, see
|
||||
<http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
|
||||
<http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
|
||||
#if defined __ELF__
|
||||
/* On ELF systems, variables in BSS behave well. */
|
||||
#else
|
||||
= (const char *) 0
|
||||
#endif
|
||||
;
|
30
gnulib/argp-eexst.c
Normal file
30
gnulib/argp-eexst.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Default definition for ARGP_ERR_EXIT_STATUS
|
||||
Copyright (C) 1997, 2009, 2010 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sysexits.h>
|
||||
|
||||
#include "argp.h"
|
||||
|
||||
/* The exit status that argp will use when exiting due to a parsing error.
|
||||
If not defined or set by the user program, this defaults to EX_USAGE from
|
||||
<sysexits.h>. */
|
||||
error_t argp_err_exit_status = EX_USAGE;
|
435
gnulib/argp-fmtstream.c
Normal file
435
gnulib/argp-fmtstream.c
Normal file
|
@ -0,0 +1,435 @@
|
|||
/* Word-wrapping and line-truncating streams
|
||||
Copyright (C) 1997-1999, 2001-2003, 2005, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This package emulates glibc `line_wrap_stream' semantics for systems that
|
||||
don't have that. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "argp-fmtstream.h"
|
||||
#include "argp-namefrob.h"
|
||||
|
||||
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
|
||||
#ifndef isblank
|
||||
#define isblank(ch) ((ch)==' ' || (ch)=='\t')
|
||||
#endif
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
# include <wchar.h>
|
||||
# include <libio/libioP.h>
|
||||
# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
|
||||
#endif
|
||||
|
||||
#define INIT_BUF_SIZE 200
|
||||
#define PRINTF_SIZE_GUESS 150
|
||||
|
||||
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||
Returns NULL if there was an error. */
|
||||
argp_fmtstream_t
|
||||
__argp_make_fmtstream (FILE *stream,
|
||||
size_t lmargin, size_t rmargin, ssize_t wmargin)
|
||||
{
|
||||
argp_fmtstream_t fs;
|
||||
|
||||
fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
|
||||
if (fs != NULL)
|
||||
{
|
||||
fs->stream = stream;
|
||||
|
||||
fs->lmargin = lmargin;
|
||||
fs->rmargin = rmargin;
|
||||
fs->wmargin = wmargin;
|
||||
fs->point_col = 0;
|
||||
fs->point_offs = 0;
|
||||
|
||||
fs->buf = (char *) malloc (INIT_BUF_SIZE);
|
||||
if (! fs->buf)
|
||||
{
|
||||
free (fs);
|
||||
fs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs->p = fs->buf;
|
||||
fs->end = fs->buf + INIT_BUF_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return fs;
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Flush FS to its stream, and free it (but don't close the stream). */
|
||||
void
|
||||
__argp_fmtstream_free (argp_fmtstream_t fs)
|
||||
{
|
||||
__argp_fmtstream_update (fs);
|
||||
if (fs->p > fs->buf)
|
||||
{
|
||||
#ifdef USE_IN_LIBIO
|
||||
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||
#else
|
||||
fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||
#endif
|
||||
}
|
||||
free (fs->buf);
|
||||
free (fs);
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
|
||||
end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
|
||||
void
|
||||
__argp_fmtstream_update (argp_fmtstream_t fs)
|
||||
{
|
||||
char *buf, *nl;
|
||||
size_t len;
|
||||
|
||||
/* Scan the buffer for newlines. */
|
||||
buf = fs->buf + fs->point_offs;
|
||||
while (buf < fs->p)
|
||||
{
|
||||
size_t r;
|
||||
|
||||
if (fs->point_col == 0 && fs->lmargin != 0)
|
||||
{
|
||||
/* We are starting a new line. Print spaces to the left margin. */
|
||||
const size_t pad = fs->lmargin;
|
||||
if (fs->p + pad < fs->end)
|
||||
{
|
||||
/* We can fit in them in the buffer by moving the
|
||||
buffer text up and filling in the beginning. */
|
||||
memmove (buf + pad, buf, fs->p - buf);
|
||||
fs->p += pad; /* Compensate for bigger buffer. */
|
||||
memset (buf, ' ', pad); /* Fill in the spaces. */
|
||||
buf += pad; /* Don't bother searching them. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No buffer space for spaces. Must flush. */
|
||||
size_t i;
|
||||
for (i = 0; i < pad; i++)
|
||||
{
|
||||
#ifdef USE_IN_LIBIO
|
||||
if (_IO_fwide (fs->stream, 0) > 0)
|
||||
putwc_unlocked (L' ', fs->stream);
|
||||
else
|
||||
#endif
|
||||
putc_unlocked (' ', fs->stream);
|
||||
}
|
||||
}
|
||||
fs->point_col = pad;
|
||||
}
|
||||
|
||||
len = fs->p - buf;
|
||||
nl = memchr (buf, '\n', len);
|
||||
|
||||
if (fs->point_col < 0)
|
||||
fs->point_col = 0;
|
||||
|
||||
if (!nl)
|
||||
{
|
||||
/* The buffer ends in a partial line. */
|
||||
|
||||
if (fs->point_col + len < fs->rmargin)
|
||||
{
|
||||
/* The remaining buffer text is a partial line and fits
|
||||
within the maximum line width. Advance point for the
|
||||
characters to be written and stop scanning. */
|
||||
fs->point_col += len;
|
||||
break;
|
||||
}
|
||||
else
|
||||
/* Set the end-of-line pointer for the code below to
|
||||
the end of the buffer. */
|
||||
nl = fs->p;
|
||||
}
|
||||
else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
|
||||
{
|
||||
/* The buffer contains a full line that fits within the maximum
|
||||
line width. Reset point and scan the next line. */
|
||||
fs->point_col = 0;
|
||||
buf = nl + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This line is too long. */
|
||||
r = fs->rmargin - 1;
|
||||
|
||||
if (fs->wmargin < 0)
|
||||
{
|
||||
/* Truncate the line by overwriting the excess with the
|
||||
newline and anything after it in the buffer. */
|
||||
if (nl < fs->p)
|
||||
{
|
||||
memmove (buf + (r - fs->point_col), nl, fs->p - nl);
|
||||
fs->p -= buf + (r - fs->point_col) - nl;
|
||||
/* Reset point for the next line and start scanning it. */
|
||||
fs->point_col = 0;
|
||||
buf += r + 1; /* Skip full line plus \n. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The buffer ends with a partial line that is beyond the
|
||||
maximum line width. Advance point for the characters
|
||||
written, and discard those past the max from the buffer. */
|
||||
fs->point_col += len;
|
||||
fs->p -= fs->point_col - r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do word wrap. Go to the column just past the maximum line
|
||||
width and scan back for the beginning of the word there.
|
||||
Then insert a line break. */
|
||||
|
||||
char *p, *nextline;
|
||||
int i;
|
||||
|
||||
p = buf + (r + 1 - fs->point_col);
|
||||
while (p >= buf && !isblank ((unsigned char) *p))
|
||||
--p;
|
||||
nextline = p + 1; /* This will begin the next line. */
|
||||
|
||||
if (nextline > buf)
|
||||
{
|
||||
/* Swallow separating blanks. */
|
||||
if (p >= buf)
|
||||
do
|
||||
--p;
|
||||
while (p >= buf && isblank ((unsigned char) *p));
|
||||
nl = p + 1; /* The newline will replace the first blank. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A single word that is greater than the maximum line width.
|
||||
Oh well. Put it on an overlong line by itself. */
|
||||
p = buf + (r + 1 - fs->point_col);
|
||||
/* Find the end of the long word. */
|
||||
if (p < nl)
|
||||
do
|
||||
++p;
|
||||
while (p < nl && !isblank ((unsigned char) *p));
|
||||
if (p == nl)
|
||||
{
|
||||
/* It already ends a line. No fussing required. */
|
||||
fs->point_col = 0;
|
||||
buf = nl + 1;
|
||||
continue;
|
||||
}
|
||||
/* We will move the newline to replace the first blank. */
|
||||
nl = p;
|
||||
/* Swallow separating blanks. */
|
||||
do
|
||||
++p;
|
||||
while (isblank ((unsigned char) *p));
|
||||
/* The next line will start here. */
|
||||
nextline = p;
|
||||
}
|
||||
|
||||
/* Note: There are a bunch of tests below for
|
||||
NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
|
||||
at the end of the buffer, and NEXTLINE is in fact empty (and so
|
||||
we need not be careful to maintain its contents). */
|
||||
|
||||
if ((nextline == buf + len + 1
|
||||
? fs->end - nl < fs->wmargin + 1
|
||||
: nextline - (nl + 1) < fs->wmargin)
|
||||
&& fs->p > nextline)
|
||||
{
|
||||
/* The margin needs more blanks than we removed. */
|
||||
if (fs->end - fs->p > fs->wmargin + 1)
|
||||
/* Make some space for them. */
|
||||
{
|
||||
size_t mv = fs->p - nextline;
|
||||
memmove (nl + 1 + fs->wmargin, nextline, mv);
|
||||
nextline = nl + 1 + fs->wmargin;
|
||||
len = nextline + mv - buf;
|
||||
*nl++ = '\n';
|
||||
}
|
||||
else
|
||||
/* Output the first line so we can use the space. */
|
||||
{
|
||||
#ifdef _LIBC
|
||||
__fxprintf (fs->stream, "%.*s\n",
|
||||
(int) (nl - fs->buf), fs->buf);
|
||||
#else
|
||||
if (nl > fs->buf)
|
||||
fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
|
||||
putc_unlocked ('\n', fs->stream);
|
||||
#endif
|
||||
|
||||
len += buf - fs->buf;
|
||||
nl = buf = fs->buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* We can fit the newline and blanks in before
|
||||
the next word. */
|
||||
*nl++ = '\n';
|
||||
|
||||
if (nextline - nl >= fs->wmargin
|
||||
|| (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
|
||||
/* Add blanks up to the wrap margin column. */
|
||||
for (i = 0; i < fs->wmargin; ++i)
|
||||
*nl++ = ' ';
|
||||
else
|
||||
for (i = 0; i < fs->wmargin; ++i)
|
||||
#ifdef USE_IN_LIBIO
|
||||
if (_IO_fwide (fs->stream, 0) > 0)
|
||||
putwc_unlocked (L' ', fs->stream);
|
||||
else
|
||||
#endif
|
||||
putc_unlocked (' ', fs->stream);
|
||||
|
||||
/* Copy the tail of the original buffer into the current buffer
|
||||
position. */
|
||||
if (nl < nextline)
|
||||
memmove (nl, nextline, buf + len - nextline);
|
||||
len -= nextline - buf;
|
||||
|
||||
/* Continue the scan on the remaining lines in the buffer. */
|
||||
buf = nl;
|
||||
|
||||
/* Restore bufp to include all the remaining text. */
|
||||
fs->p = nl + len;
|
||||
|
||||
/* Reset the counter of what has been output this line. If wmargin
|
||||
is 0, we want to avoid the lmargin getting added, so we set
|
||||
point_col to a magic value of -1 in that case. */
|
||||
fs->point_col = fs->wmargin ? fs->wmargin : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember that we've scanned as far as the end of the buffer. */
|
||||
fs->point_offs = fs->p - fs->buf;
|
||||
}
|
||||
|
||||
/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
|
||||
growing the buffer, or by flushing it. True is returned iff we succeed. */
|
||||
int
|
||||
__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
|
||||
{
|
||||
if ((size_t) (fs->end - fs->p) < amount)
|
||||
{
|
||||
ssize_t wrote;
|
||||
|
||||
/* Flush FS's buffer. */
|
||||
__argp_fmtstream_update (fs);
|
||||
|
||||
#ifdef _LIBC
|
||||
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||
wrote = fs->p - fs->buf;
|
||||
#else
|
||||
wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||
#endif
|
||||
if (wrote == fs->p - fs->buf)
|
||||
{
|
||||
fs->p = fs->buf;
|
||||
fs->point_offs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs->p -= wrote;
|
||||
fs->point_offs -= wrote;
|
||||
memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((size_t) (fs->end - fs->buf) < amount)
|
||||
/* Gotta grow the buffer. */
|
||||
{
|
||||
size_t old_size = fs->end - fs->buf;
|
||||
size_t new_size = old_size + amount;
|
||||
char *new_buf;
|
||||
|
||||
if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
|
||||
{
|
||||
__set_errno (ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs->buf = new_buf;
|
||||
fs->end = new_buf + new_size;
|
||||
fs->p = fs->buf;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
|
||||
{
|
||||
int out;
|
||||
size_t avail;
|
||||
size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
|
||||
|
||||
do
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (! __argp_fmtstream_ensure (fs, size_guess))
|
||||
return -1;
|
||||
|
||||
va_start (args, fmt);
|
||||
avail = fs->end - fs->p;
|
||||
out = __vsnprintf (fs->p, avail, fmt, args);
|
||||
va_end (args);
|
||||
if ((size_t) out >= avail)
|
||||
size_guess = out + 1;
|
||||
}
|
||||
while ((size_t) out >= avail);
|
||||
|
||||
fs->p += out;
|
||||
|
||||
return out;
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
354
gnulib/argp-fmtstream.h
Normal file
354
gnulib/argp-fmtstream.h
Normal file
|
@ -0,0 +1,354 @@
|
|||
/* Word-wrapping and line-truncating streams.
|
||||
Copyright (C) 1997, 2006-2010 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This package emulates glibc `line_wrap_stream' semantics for systems that
|
||||
don't have that. If the system does have it, it is just a wrapper for
|
||||
that. This header file is only used internally while compiling argp, and
|
||||
shouldn't be installed. */
|
||||
|
||||
#ifndef _ARGP_FMTSTREAM_H
|
||||
#define _ARGP_FMTSTREAM_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __attribute__
|
||||
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||
The __-protected variants of the attributes 'format' and 'printf' are
|
||||
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||
We enable __attribute__ only if these are supported too, because
|
||||
gnulib and libintl do '#define printf __printf__' when they override
|
||||
the 'printf' function. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
|
||||
|| (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
|
||||
/* line_wrap_stream is available, so use that. */
|
||||
#define ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
#endif
|
||||
|
||||
#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
/* Just be a simple wrapper for line_wrap_stream; the semantics are
|
||||
*slightly* different, as line_wrap_stream doesn't actually make a new
|
||||
object, it just modifies the given stream (reversibly) to do
|
||||
line-wrapping. Since we control who uses this code, it doesn't matter. */
|
||||
|
||||
#include <linewrap.h>
|
||||
|
||||
typedef FILE *argp_fmtstream_t;
|
||||
|
||||
#define argp_make_fmtstream line_wrap_stream
|
||||
#define __argp_make_fmtstream line_wrap_stream
|
||||
#define argp_fmtstream_free line_unwrap_stream
|
||||
#define __argp_fmtstream_free line_unwrap_stream
|
||||
|
||||
#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||
#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||
#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||
#define argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||
#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||
#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||
#define __argp_fmtstream_printf fprintf
|
||||
#define argp_fmtstream_printf fprintf
|
||||
|
||||
#define __argp_fmtstream_lmargin line_wrap_lmargin
|
||||
#define argp_fmtstream_lmargin line_wrap_lmargin
|
||||
#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||
#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||
#define __argp_fmtstream_rmargin line_wrap_rmargin
|
||||
#define argp_fmtstream_rmargin line_wrap_rmargin
|
||||
#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||
#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||
#define __argp_fmtstream_wmargin line_wrap_wmargin
|
||||
#define argp_fmtstream_wmargin line_wrap_wmargin
|
||||
#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||
#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||
#define __argp_fmtstream_point line_wrap_point
|
||||
#define argp_fmtstream_point line_wrap_point
|
||||
|
||||
#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||
/* Guess we have to define our own version. */
|
||||
|
||||
struct argp_fmtstream
|
||||
{
|
||||
FILE *stream; /* The stream we're outputting to. */
|
||||
|
||||
size_t lmargin, rmargin; /* Left and right margins. */
|
||||
ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
|
||||
|
||||
/* Point in buffer to which we've processed for wrapping, but not output. */
|
||||
size_t point_offs;
|
||||
/* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
|
||||
ssize_t point_col;
|
||||
|
||||
char *buf; /* Output buffer. */
|
||||
char *p; /* Current end of text in BUF. */
|
||||
char *end; /* Absolute end of BUF. */
|
||||
};
|
||||
|
||||
typedef struct argp_fmtstream *argp_fmtstream_t;
|
||||
|
||||
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||
Returns NULL if there was an error. */
|
||||
extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
|
||||
size_t __lmargin,
|
||||
size_t __rmargin,
|
||||
ssize_t __wmargin);
|
||||
extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
|
||||
size_t __lmargin,
|
||||
size_t __rmargin,
|
||||
ssize_t __wmargin);
|
||||
|
||||
/* Flush __FS to its stream, and free it (but don't close the stream). */
|
||||
extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||
extern void argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||
|
||||
extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||
const char *__fmt, ...)
|
||||
__attribute__ ((__format__ (printf, 2, 3)));
|
||||
extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||
const char *__fmt, ...)
|
||||
__attribute__ ((__format__ (printf, 2, 3)));
|
||||
|
||||
#if _LIBC || !defined __OPTIMIZE__
|
||||
extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||
extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||
|
||||
extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||
extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||
|
||||
extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||
const char *__str, size_t __len);
|
||||
extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||
const char *__str, size_t __len);
|
||||
#endif
|
||||
|
||||
/* Access macros for various bits of state. */
|
||||
#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
|
||||
#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
|
||||
#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
|
||||
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
|
||||
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
|
||||
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
|
||||
|
||||
#if _LIBC || !defined __OPTIMIZE__
|
||||
/* Set __FS's left margin to LMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||
size_t __lmargin);
|
||||
extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||
size_t __lmargin);
|
||||
|
||||
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||
size_t __rmargin);
|
||||
extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||
size_t __rmargin);
|
||||
|
||||
/* Set __FS's wrap margin to __WMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||
size_t __wmargin);
|
||||
extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||
size_t __wmargin);
|
||||
|
||||
/* Return the column number of the current output point in __FS. */
|
||||
extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||
extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||
#endif
|
||||
|
||||
/* Internal routines. */
|
||||
extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||
extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||
extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||
extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
/* Inline versions of above routines. */
|
||||
|
||||
#if !_LIBC
|
||||
#define __argp_fmtstream_putc argp_fmtstream_putc
|
||||
#define __argp_fmtstream_puts argp_fmtstream_puts
|
||||
#define __argp_fmtstream_write argp_fmtstream_write
|
||||
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
|
||||
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
|
||||
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
|
||||
#define __argp_fmtstream_point argp_fmtstream_point
|
||||
#define __argp_fmtstream_update _argp_fmtstream_update
|
||||
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
|
||||
#endif
|
||||
|
||||
#ifndef ARGP_FS_EI
|
||||
# ifdef __GNUC__
|
||||
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
|
||||
inline semantics, unless -fgnu89-inline is used. It defines a macro
|
||||
__GNUC_STDC_INLINE__ to indicate this situation or a macro
|
||||
__GNUC_GNU_INLINE__ to indicate the opposite situation.
|
||||
|
||||
GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
|
||||
semantics but warns, unless -fgnu89-inline is used:
|
||||
warning: C99 inline functions are not supported; using GNU89
|
||||
warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
|
||||
It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
|
||||
|
||||
Whereas Apple GCC 4.0.1 build 5479 without -std=c99 or -std=gnu99
|
||||
implements the GNU C inline semantics and defines the macro
|
||||
__GNUC_GNU_INLINE__, but it does not warn and does not support
|
||||
__attribute__ ((__gnu_inline__)).
|
||||
|
||||
All in all, these are the possible combinations. For every compiler,
|
||||
we need to choose ARGP_FS_EI so that the corresponding table cell
|
||||
contains an "ok".
|
||||
|
||||
\ ARGP_FS_EI inline extern extern
|
||||
\ inline inline
|
||||
CC \ __attribute__
|
||||
((gnu_inline))
|
||||
|
||||
gcc 4.3.0 error ok ok
|
||||
gcc 4.3.0 -std=gnu99 -fgnu89-inline error ok ok
|
||||
gcc 4.3.0 -std=gnu99 ok error ok
|
||||
|
||||
gcc 4.2.2 error ok ok
|
||||
gcc 4.2.2 -std=gnu99 -fgnu89-inline error ok ok
|
||||
gcc 4.2.2 -std=gnu99 error warning ok
|
||||
|
||||
gcc 4.1.2 error ok warning
|
||||
gcc 4.1.2 -std=gnu99 error ok warning
|
||||
|
||||
Apple gcc 4.0.1 error ok warning
|
||||
Apple gcc 4.0.1 -std=gnu99 ok error warning
|
||||
*/
|
||||
# if defined __GNUC_STDC_INLINE__
|
||||
# define ARGP_FS_EI inline
|
||||
# elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
|
||||
# define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__))
|
||||
# else
|
||||
# define ARGP_FS_EI extern inline
|
||||
# endif
|
||||
# else
|
||||
/* With other compilers, assume the ISO C99 meaning of 'inline', if
|
||||
the compiler supports 'inline' at all. */
|
||||
# define ARGP_FS_EI inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||
const char *__str, size_t __len)
|
||||
{
|
||||
if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
|
||||
{
|
||||
memcpy (__fs->p, __str, __len);
|
||||
__fs->p += __len;
|
||||
return __len;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARGP_FS_EI int
|
||||
__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str)
|
||||
{
|
||||
size_t __len = strlen (__str);
|
||||
if (__len)
|
||||
{
|
||||
size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
|
||||
return __wrote == __len ? 0 : -1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARGP_FS_EI int
|
||||
__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
|
||||
{
|
||||
if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
|
||||
return *__fs->p++ = __ch;
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Set __FS's left margin to __LMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->lmargin;
|
||||
__fs->lmargin = __lmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->rmargin;
|
||||
__fs->rmargin = __rmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Set FS's wrap margin to __WMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->wmargin;
|
||||
__fs->wmargin = __wmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Return the column number of the current output point in __FS. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_point (argp_fmtstream_t __fs)
|
||||
{
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
return __fs->point_col >= 0 ? __fs->point_col : 0;
|
||||
}
|
||||
|
||||
#if !_LIBC
|
||||
#undef __argp_fmtstream_putc
|
||||
#undef __argp_fmtstream_puts
|
||||
#undef __argp_fmtstream_write
|
||||
#undef __argp_fmtstream_set_lmargin
|
||||
#undef __argp_fmtstream_set_rmargin
|
||||
#undef __argp_fmtstream_set_wmargin
|
||||
#undef __argp_fmtstream_point
|
||||
#undef __argp_fmtstream_update
|
||||
#undef __argp_fmtstream_ensure
|
||||
#endif
|
||||
|
||||
#endif /* __OPTIMIZE__ */
|
||||
|
||||
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||
|
||||
#endif /* argp-fmtstream.h */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue