merge mainline into newreloc

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-01-30 16:46:16 +01:00
commit 6e308bd942
72 changed files with 1538 additions and 533 deletions

360
ChangeLog
View file

@ -1,3 +1,361 @@
2010-01-28 Christian Schmitt <chris@ilovelinux.de>
* util/ieee1275/grub-install.in: Fix nvsetenv arguments.
2010-01-28 BVK Chaitanya <bvk.groups@gmail.com>
* include/grub/script_sh.h (sourcecode): Add const qualifier.
* util/grub-script-check.c (getline): Fix empty lines case.
2010-01-28 Robert Millan <rmh.grub@aybabtu.com>
* Makefile.in (check): Exit with fail status when one of the tests
fails.
* tests/example_functional_test.c (example_test): Fix reversed assert.
* tests/example_unit_test.c (example_test): Likewise.
2010-01-28 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/10_linux.in: This script does not use any of the
contents of gettext.sh, only the external command `gettext', so stop
sourcing it. (Moreover, gettext.sh isn't necessarily installed in
the same prefix as GRUB.)
* util/grub.d/10_kfreebsd.in: Likewise.
2010-01-27 Vladimir Serbinenko <phcoder@gmail.com>
* normal/cmdline.c (grub_cmdline_get): Fix completion in the middle
of the line.
2010-01-27 Vladimir Serbinenko <phcoder@gmail.com>
* kern/disk.c (grub_disk_read): Fix offset computation when reading
last sectors.
2010-01-27 Vladimir Serbinenko <phcoder@gmail.com>
* commands/hashsum.c (hash_file): Avoid possible stack overflow by
having a 4KiB and not 32KiB buffer size.
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* util/hostfs.c: Include `<errno.h>'.
(grub_hostfs_read): Handle errors from fseeko() and fread().
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* kern/disk.c (grub_disk_read): Fix bug that would cause infinite
loop when using read hooks on files whose size isn't sector-aligned.
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
Remove unused parameter.
* fs/iso9660.c (struct grub_iso9660_data): Remove `length' parameter.
(grub_iso9660_open): Remove initialization of `data->length'.
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* util/grub-fstest.c (fstest): Rewrite allocation, fixing a few
memleak conditions.
2010-01-27 Carles Pina i Estany <carles@pina.cat>
* util/lvm.c: New macro LVM_DEV_MAPPER_STRING.
(grub_util_lvm_isvolume): Use LVM_DEV_MAPPER_STRING.
2010-01-26 Carles Pina i Estany <carles@pina.cat>
* util/bin2h.c (usage): Fix warning (space after backslash).
2010-01-26 Carles Pina i Estany <carles@pina.cat>
* font/font.c: Include `grub/fontformat.h.
Remove font file format constants.
(grub_font_load): Use the new macros.
* include/grub/fontformat.h: New file.
* util/grub-mkfont.c: Include `grub/fontformat.c'.
(write_font_pf2): Use the new macros.
2010-01-26 Robert Millan <rmh.grub@aybabtu.com>
* util/bin2h.c (usage): Make --help actually explain what `grub-bin2h'
does.
2010-01-26 Robert Millan <rmh.grub@aybabtu.com>
* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_PXE_DL): New macro.
* boot/i386/pc/pxeboot.S: Include `<grub/machine/boot.h>'.
(_start): Macroify `0x7F'.
* kern/i386/pc/init.c: Include `<grub/machine/boot.h>'.
(make_install_device): Use "(pxe)" as fallback prefix when booting
via PXE.
2010-01-26 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Reset LIBS after check for libgcc symbols.
2010-01-25 Colin Watson <cjwatson@ubuntu.com>
* util/hostdisk.c (open_device): Add trailing newline to debug
message.
2010-01-25 Grégoire Sutre <gregoire.sutre@gmail.com>
* configure.ac: Check for `limits.h'.
* util/misc.c: Include `<limits.h>' (for PATH_MAX).
2010-01-24 Robert Millan <rmh.grub@aybabtu.com>
* loader/mips/linux.c (grub_cmd_linux, grub_cmd_initrd): Don't
capitalize error strings.
2010-01-24 Samuel Thibault <samuel.thibault@ens-lyon.org>
* util/grub.d/10_hurd.in: Add a recovery mode.
2010-01-23 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Check for libgcc symbols with -nostdlib.
2010-01-23 BVK Chaitanya <bvk.groups@gmail.com>
* acinclude.m4: Quote underquoted AC_DEFUN parameters.
2010-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_setcolorstate): Allocate on
stack since heap may be unavailable at that point.
(grub_ofconsole_gotoxy): Likewise.
2010-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Check for _restgpr_14_x.
* include/grub/powerpc/libgcc.h [HAVE__RESTGPR_14_X]: Add _restgpr_*_x
and _savegpr_* prototypes.
2010-01-22 Robert Millan <rmh.grub@aybabtu.com>
Use generic grub_reboot() for i386-efi.
* kern/efi/efi.c [__i386__] (grub_reboot): Remove.
* kern/i386/efi/startup.S: Include `"../realmode.S"'.
* kern/i386/realmode.S: Include `<grub/i386/pc/memory.h>'.
2010-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* kern/ieee1275/init.c (grub_machine_set_prefix): Don't check for
presence of "prefix" variable as it breaks when normal.mod is
embedded.
2010-01-21 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_dimensions): Allocate on
stack since heap is unavailable at that point.
2010-01-21 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/i386/bsd.h (FREEBSD_N_BIOS_GEOM): Removed.
(grub_freebsd_bootinfo): Rewritten.
* loader/i386/bsd.c (grub_freebsd_boot): Use new grub_freebsd_bootinfo.
2010-01-21 Vladimir Serbinenko <phcoder@gmail.com>
* util/misc.c (make_system_path_relative_to_its_root): Fix typo.
2010-01-21 Robert Millan <rmh.grub@aybabtu.com>
* po/POTFILES: Remove mkisofs-related files. They have their own TLP
domain now.
2010-01-20 Felix Zielcke <fzielcke@z-51.de>
* util/misc.c (make_system_path_relative_to_its_root): Change the work
around for handling "/" to the correct fix. Fix a memory leak. Use
xstrdup instead of strdup.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* conf/mips.rmk (kernel_img_HEADERS): Add env_private.h
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Optimise glyph lookup by Basic Multilingual Plane lookup array.
* font/font.c (struct grub_font): New member 'bmp_idx'.
(font_init): Initialise 'bmp_idx'.
(load_font_index): Fill 'bmp_idx'.
(find_glyph): Make inline. Use bmp_idx for BMP characters.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* video/fb/video_fb.c (grub_video_fb_scroll): Optimise by avoiding
unnecessary calls.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Move context handling out of the kernel.
* conf/any-emu.rmk (grub_emu_SOURCES): Add normal/context.c.
* conf/common.rmk (normal_mod_SOURCES): Add normal/context.c.
* conf/i386-coreboot.rmk (kernel_img_HEADERS): Add env_private.h.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/env.h: Include grub/menu.h.
(grub_env_var_type): Removed.
(grub_env_var): Replaced field 'type' with 'global'.
(grub_env_find): New prototype.
(grub_env_context_open): Remove EXPORT_FUNC.
(grub_env_context_close): Likewise.
(grub_env_export): Likewise.
(grub_env_set_data_slot): Removed.
(grub_env_get_data_slot): Likewise.
(grub_env_unset_data_slot): Likewise.
(grub_env_unset_menu): New prototype.
(grub_env_set_menu): Likewise.
(grub_env_get_menu): Likewise.
* include/grub/env_private.h: New file.
* include/grub/normal.h (grub_context_init): New prototype.
(grub_context_fini): Likewise.
* kern/corecmd.c (grub_core_cmd_export): Moved from here ...
* normal/context.c (grub_cmd_export): ... to here.
* kern/env.c: Include env_private.h.
(HASHSZ): Moved to include/grub/env_private.h.
(grub_env_context): Likewise.
(grub_env_sorted_var): Likewise.
(current_context): Renamed from this ...
(grub_current_context): ...to this. 'static' removed. All users updated.
(grub_env_find): Removed 'static'.
(grub_env_context_open): Moved to normal/context.c.
(grub_env_context_close): Likewise.
(grub_env_export): Likewise.
(mangle_data_slot_name): Removed.
(grub_env_set_data_slot): Likewise.
(grub_env_get_data_slot): Likewise.
(grub_env_unset_data_slot): Likewise.
* kern/main.c (grub_set_root_dev): Don't export root.
It will be done later.
(grub_main): Don't export prefix.
It will be done later.
* normal/context.c: New file.
* normal/main.c (free_menu): Use grub_env_unset_menu.
(grub_normal_add_menu_entry): Use grub_env_get_menu.
(read_config_file): Use grub_env_get_menu and grub_env_set_menu.
(GRUB_MOD_INIT(normal)): Call grub_context_init.
(GRUB_MOD_FINI(normal)): Call grub_context_fini.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
setpci support.
* commands/setpci.c: New file.
* conf/i386.rmk (pkglib_MODULES): Add setpci.mod.
(setpci_mod_SOURCES): New variable.
(setpci_mod_CFLAGS): Likewise.
(setpci_mod_LDFLAGS): Likewise.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Byte-addressable PCI configuration space.
* bus/pci.c (grub_pci_make_address): Use byte address instead of
dword address.
(grub_pci_iterate): Use macroses GRUB_PCI_REG_PCI_ID and
GRUB_PCI_REG_CACHELINE.
* bus/usb/ohci.c (grub_ohci_pci_iter): Use macroses
GRUB_PCI_REG_CLASS and GRUB_PCI_REG_ADDRESS_REG0.
* bus/usb/uhci.c (grub_ohci_pci_iter): Use macroses
GRUB_PCI_REG_CLASS and GRUB_PCI_REG_ADDRESS_REG4.
* commands/efi/fixvideo.c (scan_card): Use macros GRUB_PCI_REG_CLASS.
* commands/efi/loadbios.c (enable_rom_area): Pass byte-address to
grub_pci_make_address.
(lock_rom_area): Likewise.
* commands/lspci.c (grub_lspci_iter): Use macroses
GRUB_PCI_REG_CLASS and GRUB_PCI_REG_ADDRESSES. Handle byte-addressing
of grub_pci_make_address.
* disk/ata.c (grub_ata_pciinit): Likewise.
* include/grub/pci.h (GRUB_PCI_REG_PCI_ID): New macro.
(GRUB_PCI_REG_VENDOR): Likewise.
(GRUB_PCI_REG_DEVICE): Likewise.
(GRUB_PCI_REG_COMMAND): Likewise.
(GRUB_PCI_REG_STATUS): Likewise.
(GRUB_PCI_REG_REVISION): Likewise.
(GRUB_PCI_REG_CLASS): Likewise.
(GRUB_PCI_REG_CACHELINE): Likewise.
(GRUB_PCI_REG_LAT_TIMER): Likewise.
(GRUB_PCI_REG_HEADER_TYPE): Likewise.
(GRUB_PCI_REG_BIST): Likewise.
(GRUB_PCI_REG_ADDRESSES): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_ADDRESS_REG): Likewise.
(GRUB_PCI_REG_CIS_POINTER): Likewise.
(GRUB_PCI_REG_SUBVENDOR): Likewise.
(GRUB_PCI_REG_SUBSYSTEM): Likewise.
(GRUB_PCI_REG_ROM_ADDRESS): Likewise.
(GRUB_PCI_REG_CAP_POINTER): Likewise.
(GRUB_PCI_REG_IRQ_LINE): Likewise.
(GRUB_PCI_REG_IRQ_PIN): Likewise.
(GRUB_PCI_REG_MIN_GNT): Likewise.
(GRUB_PCI_REG_MAX_LAT): Likewise.
* loader/i386/efi/linux.c (find_framebuf): Use GRUB_PCI_REG_CLASS.
* loader/i386/efi/xnu.c (find_framebuf): Likewise.
* video/efi_uga.c (find_framebuf): Likewise.
* video/sm712.c (grub_video_sm712_setup): Likewise.
* util/pci.c (grub_pci_make_address): Use byte-addressed configuration
space.
2010-01-20 Robert Millan <rmh.grub@aybabtu.com>
* util/grub.d/10_linux.in (linux_entry): Set gfxpayload=keep when it
can be reliably determined to be supported.
2010-01-20 Robert Millan <rmh.grub@aybabtu.com>
* loader/i386/linux.c (grub_cmd_linux): If `vga=' was used, write down
that VESA is supported.
(grub_linux_boot): Use generic framebuffer unless VESA is known to be
supported.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* conf/common.rmk (font/font.c_DEPENDENCIES): Condition on FONT_SOURCE.
2010-01-20 Robert Millan <rmh.grub@aybabtu.com>
* util/misc.c (make_system_path_relative_to_its_root): Work around
special-casing of "/", as previous incarnation of this routine did.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Fix any-emu compilation.
* conf/any-emu.rmk (bin_UTILITIES): Add grub-bin2h.
* grub_bin2h_SOURCES: New variable.
2010-01-20 Robert Millan <rmh.grub@aybabtu.com>
* util/grub.d/00_header.in: Fix stupid mistake from last commit.
2010-01-20 Robert Millan <rmh.grub@aybabtu.com>
* util/grub.d/00_header.in: Fix handling of locale_dir.
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add /usr/share/fonts/unifont/unifont.pcf.gz
as possible unifont location (Gentoo).
Reported by: Alexander Brüning
2010-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Don't try to generate lists for kernel.img.
@ -23584,7 +23942,7 @@
* genmk.rb (PModule#rule): Make sure to get only symbol names
from the output of nm.
Reported by Robert Millan <zeratul2@wanadoo.es>.
Reported by Robert Millan <rmh.grub@aybabtu.com>.
2003-09-25 Yoshinori K. Okuji <okuji@enbug.org>

View file

@ -473,23 +473,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:

View file

@ -14,7 +14,7 @@ $2
dnl Check whether target compiler is working
AC_DEFUN(grub_PROG_TARGET_CC,
AC_DEFUN([grub_PROG_TARGET_CC],
[AC_MSG_CHECKING([whether target compiler is working])
AC_CACHE_VAL(grub_cv_prog_target_cc,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@ -36,7 +36,7 @@ dnl grub_ASM_USCORE checks if C symbols get an underscore after
dnl compiling to assembler.
dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
dnl Erich Boleyn and modified by Yoshinori K. Okuji.
AC_DEFUN(grub_ASM_USCORE,
AC_DEFUN([grub_ASM_USCORE],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if C symbols get an underscore after compilation])
AC_CACHE_VAL(grub_cv_asm_uscore,
@ -75,7 +75,7 @@ AC_MSG_RESULT([$grub_cv_asm_uscore])
dnl Some versions of `objcopy -O binary' vary their output depending
dnl on the link address.
AC_DEFUN(grub_PROG_OBJCOPY_ABSOLUTE,
AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE],
[AC_MSG_CHECKING([whether ${OBJCOPY} works for absolute addresses])
AC_CACHE_VAL(grub_cv_prog_objcopy_absolute,
[cat > conftest.c <<\EOF
@ -119,7 +119,7 @@ fi
dnl Supply --build-id=none to ld if building modules.
dnl This suppresses warnings from ld on some systems
AC_DEFUN(grub_PROG_LD_BUILD_ID_NONE,
AC_DEFUN([grub_PROG_LD_BUILD_ID_NONE],
[AC_MSG_CHECKING([whether linker accepts --build-id=none])
AC_CACHE_VAL(grub_cv_prog_ld_build_id_none,
[save_LDFLAGS="$LDFLAGS"
@ -150,7 +150,7 @@ dnl
dnl We only support the newer versions, because the old versions cause
dnl major pain, by requiring manual assembly to get 16-bit instructions into
dnl asm files.
AC_DEFUN(grub_I386_ASM_ADDR32,
AC_DEFUN([grub_I386_ASM_ADDR32],
[AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT])
AC_MSG_CHECKING([for .code16 addr32 assembler support])
@ -178,7 +178,7 @@ AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
dnl check if our compiler is apple cc
dnl because it requires numerous workarounds
AC_DEFUN(grub_apple_cc,
AC_DEFUN([grub_apple_cc],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether our compiler is apple cc])
AC_CACHE_VAL(grub_cv_apple_cc,
@ -193,7 +193,7 @@ AC_MSG_RESULT([$grub_cv_apple_cc])])
dnl check if our target compiler is apple cc
dnl because it requires numerous workarounds
AC_DEFUN(grub_apple_target_cc,
AC_DEFUN([grub_apple_target_cc],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([whether our target compiler is apple cc])
AC_CACHE_VAL(grub_cv_apple_target_cc,
@ -210,7 +210,7 @@ AC_MSG_RESULT([$grub_cv_apple_target_cc])])
dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines.
AC_DEFUN(grub_I386_ASM_PREFIX_REQUIREMENT,
AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl
[whether addr32 must be in the same line as the instruction])
@ -246,7 +246,7 @@ AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])])
dnl Older versions of GAS require that absolute indirect calls/jumps are
dnl not prefixed with `*', while later versions warn if not prefixed.
AC_DEFUN(grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK,
AC_DEFUN([grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl
[whether an absolute indirect call/jump must not be prefixed with an asterisk])
@ -276,7 +276,7 @@ AC_MSG_RESULT([$grub_cv_i386_asm_absolute_without_asterisk])])
dnl Check what symbol is defined as a bss start symbol.
dnl Written by Michael Hohmoth and Yoshinori K. Okuji.
AC_DEFUN(grub_CHECK_BSS_START_SYMBOL,
AC_DEFUN([grub_CHECK_BSS_START_SYMBOL],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if __bss_start is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol,
@ -320,7 +320,7 @@ fi
dnl Check what symbol is defined as an end symbol.
dnl Written by Yoshinori K. Okuji.
AC_DEFUN(grub_CHECK_END_SYMBOL,
AC_DEFUN([grub_CHECK_END_SYMBOL],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if end is defined by the compiler])
AC_CACHE_VAL(grub_cv_check_end_symbol,
@ -352,7 +352,7 @@ fi
])
dnl Check if the C compiler generates calls to `__enable_execute_stack()'.
AC_DEFUN(grub_CHECK_ENABLE_EXECUTE_STACK,[
AC_DEFUN([grub_CHECK_ENABLE_EXECUTE_STACK],[
AC_MSG_CHECKING([whether `$CC' generates calls to `__enable_execute_stack()'])
AC_LANG_CONFTEST([[
void f (int (*p) (void));
@ -379,7 +379,7 @@ rm -f conftest*
dnl Check if the C compiler supports `-fstack-protector'.
AC_DEFUN(grub_CHECK_STACK_PROTECTOR,[
AC_DEFUN([grub_CHECK_STACK_PROTECTOR],[
[# Smashing stack protector.
ssp_possible=yes]
AC_MSG_CHECKING([whether `$CC' accepts `-fstack-protector'])
@ -398,7 +398,7 @@ else
])
dnl Check if the C compiler supports `-mstack-arg-probe' (Cygwin).
AC_DEFUN(grub_CHECK_STACK_ARG_PROBE,[
AC_DEFUN([grub_CHECK_STACK_ARG_PROBE],[
[# Smashing stack arg probe.
sap_possible=yes]
AC_MSG_CHECKING([whether `$CC' accepts `-mstack-arg-probe'])
@ -414,7 +414,7 @@ else
])
dnl Check if ln can handle directories properly (mingw).
AC_DEFUN(grub_CHECK_LINK_DIR,[
AC_DEFUN([grub_CHECK_LINK_DIR],[
AC_MSG_CHECKING([whether ln can handle directories properly])
[mkdir testdir 2>/dev/null
case $srcdir in
@ -432,7 +432,7 @@ rm -rf testdir]
])
dnl Check if the C compiler supports `-fPIE'.
AC_DEFUN(grub_CHECK_PIE,[
AC_DEFUN([grub_CHECK_PIE],[
[# Position independent executable.
pie_possible=yes]
AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default])

View file

@ -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

View file

@ -24,7 +24,7 @@ grub_pci_address_t
grub_pci_make_address (grub_pci_device_t dev, int reg)
{
return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
| (dev.function << 8) | (reg << 2);
| (dev.function << 8) | reg;
}
void
@ -41,7 +41,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
{
for (dev.function = 0; dev.function < 8; dev.function++)
{
addr = grub_pci_make_address (dev, 0);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_PCI_ID);
id = grub_pci_read (addr);
/* Check if there is a device present. */
@ -54,7 +54,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
/* Probe only func = 0 if the device if not multifunction */
if (dev.function == 0)
{
addr = grub_pci_make_address (dev, 3);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CACHELINE);
hdr = grub_pci_read (addr);
if (!(hdr & 0x800000))
break;

View file

@ -126,7 +126,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
grub_uint32_t revision;
grub_uint32_t frame_interval;
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class_code = grub_pci_read (addr) >> 8;
interf = class_code & 0xFF;
@ -138,7 +138,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
return 0;
/* Determine IO base address. */
addr = grub_pci_make_address (dev, 4);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
base = grub_pci_read (addr);
#if 0

View file

@ -150,7 +150,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
struct grub_uhci *u;
int i;
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class_code = grub_pci_read (addr) >> 8;
interf = class_code & 0xFF;
@ -162,7 +162,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
return 0;
/* Determine IO base address. */
addr = grub_pci_make_address (dev, 8);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
base = grub_pci_read (addr);
/* Stop if there is no IO space base address defined. */
if (! (base & 1))

View file

@ -43,7 +43,7 @@ scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
{
grub_pci_address_t addr;
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
if (grub_pci_read_byte (addr + 3) == 0x3)
{
struct grub_video_patch *p = video_patches;

View file

@ -51,7 +51,8 @@ enable_rom_area (void)
return 0;
}
addr = grub_pci_make_address (dev, 36);
/* FIXME: should be macroified. */
addr = grub_pci_make_address (dev, 144);
grub_pci_write_byte (addr++, 0x30);
grub_pci_write_byte (addr++, 0x33);
grub_pci_write_byte (addr++, 0x33);
@ -77,7 +78,8 @@ lock_rom_area (void)
grub_pci_address_t addr;
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
addr = grub_pci_make_address (dev, 36);
/* FIXME: should be macroified. */
addr = grub_pci_make_address (dev, 144);
grub_pci_write_byte (addr++, 0x10);
grub_pci_write_byte (addr++, 0x11);
grub_pci_write_byte (addr++, 0x11);

View file

@ -57,7 +57,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);

View file

@ -135,7 +135,7 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
grub_printf ("%02x:%02x.%x %04x:%04x", grub_pci_get_bus (dev),
grub_pci_get_device (dev), grub_pci_get_function (dev),
pciid & 0xFFFF, pciid >> 16);
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
/* Lookup the class name, if there isn't a specific one,
@ -156,14 +156,14 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
if (iospace)
{
reg = 4;
while (reg < 10)
reg = GRUB_PCI_REG_ADDRESSES;
while (reg < GRUB_PCI_REG_CIS_POINTER)
{
grub_uint64_t space;
addr = grub_pci_make_address (dev, reg);
space = grub_pci_read (addr);
reg++;
reg += sizeof (grub_uint32_t);
if (space == 0)
continue;
@ -171,7 +171,9 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
switch (space & GRUB_PCI_ADDR_SPACE_MASK)
{
case GRUB_PCI_ADDR_SPACE_IO:
grub_printf ("\tIO space %d at 0x%llx\n", (reg - 1) - 4,
grub_printf ("\tIO space %d at 0x%llx\n",
(unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
/ sizeof (grub_uint32_t)) - 1,
(unsigned long long)
(space & GRUB_PCI_ADDR_IO_MASK));
break;
@ -181,9 +183,11 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
{
addr = grub_pci_make_address (dev, reg);
space |= ((grub_uint64_t) grub_pci_read (addr)) << 32;
reg++;
reg += sizeof (grub_uint32_t);
grub_printf ("\t64-bit memory space %d at 0x%016llx [%s]\n",
(reg - 2) - 4, (unsigned long long)
(unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
/ sizeof (grub_uint32_t)) - 2,
(unsigned long long)
(space & GRUB_PCI_ADDR_MEM_MASK),
space & GRUB_PCI_ADDR_MEM_PREFETCH
? "prefetchable" : "non-prefetchable");
@ -191,7 +195,9 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
}
else
grub_printf ("\t32-bit memory space %d at 0x%016llx [%s]\n",
(reg - 1) - 4, (unsigned long long)
(unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
/ sizeof (grub_uint32_t)) - 1,
(unsigned long long)
(space & GRUB_PCI_ADDR_MEM_MASK),
space & GRUB_PCI_ADDR_MEM_PREFETCH
? "prefetchable" : "non-prefetchable");

340
commands/setpci.c Normal file
View file

@ -0,0 +1,340 @@
/* lspci.c - List PCI devices. */
/*
* 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/pci.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/env.h>
#include <grub/mm.h>
struct pci_register
{
const char *name;
grub_uint16_t addr;
unsigned size;
};
struct pci_register pci_registers[] =
{
{"VENDOR_ID", GRUB_PCI_REG_VENDOR , 2},
{"DEVICE_ID", GRUB_PCI_REG_DEVICE , 2},
{"COMMAND", GRUB_PCI_REG_COMMAND , 2},
{"STATUS", GRUB_PCI_REG_STATUS , 2},
{"REVISION", GRUB_PCI_REG_REVISION , 1},
{"CLASS_PROG", GRUB_PCI_REG_CLASS + 1 , 1},
{"CLASS_DEVICE", GRUB_PCI_REG_CLASS + 2 , 2},
{"CACHE_LINE_SIZE", GRUB_PCI_REG_CACHELINE , 1},
{"LATENCY_TIMER", GRUB_PCI_REG_LAT_TIMER , 1},
{"HEADER_TYPE", GRUB_PCI_REG_HEADER_TYPE , 1},
{"BIST", GRUB_PCI_REG_BIST , 1},
{"BASE_ADDRESS_0", GRUB_PCI_REG_ADDRESS_REG0, 4},
{"BASE_ADDRESS_1", GRUB_PCI_REG_ADDRESS_REG1, 4},
{"BASE_ADDRESS_2", GRUB_PCI_REG_ADDRESS_REG2, 4},
{"BASE_ADDRESS_3", GRUB_PCI_REG_ADDRESS_REG3, 4},
{"BASE_ADDRESS_4", GRUB_PCI_REG_ADDRESS_REG4, 4},
{"BASE_ADDRESS_5", GRUB_PCI_REG_ADDRESS_REG5, 4},
{"CARDBUS_CIS", GRUB_PCI_REG_CIS_POINTER , 4},
{"SUBVENDOR_ID", GRUB_PCI_REG_SUBVENDOR , 2},
{"SUBSYSTEM_ID", GRUB_PCI_REG_SUBSYSTEM , 2},
{"ROM_ADDRESS", GRUB_PCI_REG_ROM_ADDRESS , 4},
{"CAP_POINTER", GRUB_PCI_REG_CAP_POINTER , 1},
{"INTERRUPT_LINE", GRUB_PCI_REG_IRQ_LINE , 1},
{"INTERRUPT_PIN", GRUB_PCI_REG_IRQ_PIN , 1},
{"MIN_GNT", GRUB_PCI_REG_MIN_GNT , 1},
{"MAX_LAT", GRUB_PCI_REG_MIN_GNT , 1},
};
static const struct grub_arg_option options[] =
{
{0, 'd', 0, "Select device by vendor and device IDs.",
"[vendor]:[device]", ARG_TYPE_STRING},
{0, 's', 0, "Select device by its position on the bus.",
"[bus]:[slot][.func]", ARG_TYPE_STRING},
{0, 'v', 0, "Save read value into variable VARNAME.",
"VARNAME", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
static grub_uint32_t pciid_check_mask, pciid_check_value;
static int bus, device, function;
static int check_bus, check_device, check_function;
static grub_uint32_t write_mask, regwrite;
static int regsize;
static grub_uint16_t regaddr;
static const char *varname;
static int NESTED_FUNC_ATTR
grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
{
grub_uint32_t regval = 0;
grub_pci_address_t addr;
if ((pciid & pciid_check_mask) != pciid_check_value)
return 0;
if (check_bus && grub_pci_get_bus (dev) != bus)
return 0;
if (check_device && grub_pci_get_device (dev) != device)
return 0;
if (check_function && grub_pci_get_function (dev) != device)
return 0;
addr = grub_pci_make_address (dev, regaddr);
switch (regsize)
{
case 1:
regval = grub_pci_read_byte (addr);
break;
case 2:
regval = grub_pci_read_word (addr);
break;
case 4:
regval = grub_pci_read (addr);
break;
}
if (varname)
{
char buf[sizeof ("XXXXXXXX")];
grub_snprintf (buf, sizeof (buf), "%x", regval);
grub_env_set (varname, buf);
return 1;
}
if (!write_mask)
{
grub_printf ("Register %x of %d:%d.%d is %x\n", regaddr,
grub_pci_get_bus (dev),
grub_pci_get_device (dev),
grub_pci_get_function (dev),
regval);
return 0;
}
regval = (regval & ~write_mask) | regwrite;
switch (regsize)
{
case 1:
grub_pci_write_byte (addr, regval);
break;
case 2:
grub_pci_write_word (addr, regval);
break;
case 4:
grub_pci_write (addr, regval);
break;
}
return 0;
}
static grub_err_t
grub_cmd_setpci (grub_extcmd_t cmd, int argc, char **argv)
{
const char *ptr;
unsigned i;
pciid_check_value = 0;
pciid_check_mask = 0;
if (cmd->state[0].set)
{
ptr = cmd->state[0].arg;
pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff);
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
grub_errno = GRUB_ERR_NONE;
ptr = cmd->state[0].arg;
}
else
pciid_check_mask |= 0xffff;
if (grub_errno)
return grub_errno;
if (*ptr != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Colon expected.");
ptr++;
pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff)
<< 16;
if (grub_errno == GRUB_ERR_BAD_NUMBER)
grub_errno = GRUB_ERR_NONE;
else
pciid_check_mask |= 0xffff0000;
}
pciid_check_value &= pciid_check_mask;
check_bus = check_device = check_function = 0;
if (cmd->state[1].set)
{
const char *optr;
ptr = cmd->state[1].arg;
optr = ptr;
bus = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
grub_errno = GRUB_ERR_NONE;
ptr = optr;
}
else
check_bus = 1;
if (grub_errno)
return grub_errno;
if (*ptr != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Colon expected.");
ptr++;
optr = ptr;
device = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
grub_errno = GRUB_ERR_NONE;
ptr = optr;
}
else
check_device = 1;
if (*ptr == '.')
{
ptr++;
function = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno)
return grub_errno;
check_function = 1;
}
}
if (cmd->state[2].set)
varname = cmd->state[2].arg;
else
varname = NULL;
write_mask = 0;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Command expected.");
if (argc > 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Only one command is supported.");
ptr = argv[0];
for (i = 0; i < ARRAY_SIZE (pci_registers); i++)
{
if (grub_strncmp (ptr, pci_registers[i].name,
grub_strlen (pci_registers[i].name)) == 0)
break;
}
if (i == ARRAY_SIZE (pci_registers))
{
regsize = 0;
regaddr = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown register");
}
else
{
regaddr = pci_registers[i].addr;
regsize = pci_registers[i].size;
ptr += grub_strlen (pci_registers[i].name);
}
if (grub_errno)
return grub_errno;
if (*ptr == '+')
{
ptr++;
regaddr += grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno)
return grub_errno;
}
if (grub_memcmp (ptr, ".L", sizeof (".L") - 1) == 0
|| grub_memcmp (ptr, ".l", sizeof (".l") - 1) == 0)
{
regsize = 4;
ptr += sizeof (".l") - 1;
}
else if (grub_memcmp (ptr, ".W", sizeof (".W") - 1) == 0
|| grub_memcmp (ptr, ".w", sizeof (".w") - 1) == 0)
{
regsize = 2;
ptr += sizeof (".w") - 1;
}
else if (grub_memcmp (ptr, ".B", sizeof (".B") - 1) == 0
|| grub_memcmp (ptr, ".b", sizeof (".b") - 1) == 0)
{
regsize = 1;
ptr += sizeof (".b") - 1;
}
if (!regsize)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Unknown register size.");
write_mask = 0;
if (*ptr == '=')
{
ptr++;
regwrite = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno)
return grub_errno;
write_mask = 0xffffffff;
if (*ptr == ':')
{
ptr++;
write_mask = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno)
return grub_errno;
write_mask = 0xffffffff;
}
regwrite &= write_mask;
}
if (write_mask && varname)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Option -v isn't valid for writes.");
grub_pci_iterate (grub_setpci_iter);
return GRUB_ERR_NONE;
}
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);
}
GRUB_MOD_FINI(setpci)
{
grub_unregister_extcmd (cmd);
}

View file

@ -30,7 +30,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.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 lib/charset.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 \
@ -98,3 +98,6 @@ endif
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

View file

@ -588,7 +588,7 @@ normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \
normal/auth.c normal/autofs.c normal/handler.c \
normal/color.c normal/completion.c normal/datetime.c normal/menu.c \
normal/menu_entry.c normal/menu_text.c \
normal/misc.c normal/crypto.c normal/term.c
normal/misc.c normal/crypto.c normal/term.c normal/context.c
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
@ -638,7 +638,9 @@ png_mod_CFLAGS = $(COMMON_CFLAGS)
png_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)

View file

@ -35,7 +35,8 @@ 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 \
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 list.h handler.h command.h i18n.h mm_private.h
machine/memory.h list.h handler.h command.h i18n.h \
env_private.h mm_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
@ -81,7 +82,8 @@ 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 \
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 list.h handler.h command.h i18n.h mm_private.h
machine/memory.h list.h handler.h command.h i18n.h \
env_private.h mm_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)

View file

@ -52,7 +52,8 @@ kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.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 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 mm_private.h
efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h \
i18n.h env_private.h mm_private.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)

View file

@ -33,7 +33,7 @@ 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 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/memory.h \
list.h handler.h command.h i18n.h mm_private.h
list.h handler.h command.h i18n.h env_private.h mm_private.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
@ -54,7 +54,7 @@ sbin_SCRIPTS = grub-install
grub_install_SOURCES = util/ieee1275/grub-install.in
# Modules.
pkglib_MODULES = halt.mod reboot.mod suspend.mod serial.mod \
pkglib_MODULES = halt.mod reboot.mod suspend.mod \
nand.mod memdisk.mod pci.mod lspci.mod datetime.mod \
date.mod datehook.mod lsmmap.mod mmap.mod
@ -85,11 +85,6 @@ 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 nand.mod.
nand_mod_SOURCES = disk/ieee1275/nand.c
nand_mod_CFLAGS = $(COMMON_CFLAGS)

View file

@ -64,7 +64,8 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.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 mm_private.h
machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h \
i18n.h env_private.h mm_private.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)

View file

@ -47,6 +47,12 @@ bsd_mod_CFLAGS = $(COMMON_CFLAGS)
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
# For setpci.mod
pkglib_MODULES += setpci.mod
setpci_mod_SOURCES = commands/setpci.c
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 \

View file

@ -17,7 +17,8 @@ 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 mm_private.h
command.h machine/memory.h cpu/libgcc.h cpu/cache.h i18n.h \
env_private.h mm_private.h
ifeq ($(platform), yeeloong)
kernel_img_HEADERS += pci.h

View file

@ -17,7 +17,7 @@ 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 partition.h \
msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \
command.h i18n.h mm_private.h
command.h i18n.h env_private.h mm_private.h
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)

View file

@ -31,7 +31,7 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.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 mm_private.h
sparc64/ieee1275/ieee1275.h mm_private.h env_private.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 \

View file

@ -52,7 +52,7 @@ 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 mm_private.h
handler.h command.h i18n.h env_private.h mm_private.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)

View file

@ -168,7 +168,7 @@ if test "x$YACC" = x; then
AC_MSG_ERROR([bison is not found])
fi
for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz ; do
for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
if test -e $file ; then
AC_SUBST([FONT_SOURCE], [$file])
break
@ -221,7 +221,7 @@ AC_HEADER_MAJOR
AC_HEADER_DIRENT
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)
AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
#
# Check for target programs.
@ -438,18 +438,26 @@ AC_SUBST(TARGET_ASFLAGS)
AC_SUBST(TARGET_CPPFLAGS)
AC_SUBST(TARGET_LDFLAGS)
# Check for libgcc symbols (must be performed before we add -nostdlib to LDFLAGS)
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2)
# Set them to their new values for the tests below.
CC="$TARGET_CC"
if test "x$TARGET_APPLE_CC" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wl,--defsym,abort=main -Wno-error"
fi
CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
LIBS=-lgcc
# Check for libgcc symbols
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
if test "x$TARGET_APPLE_CC" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib"
else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
fi
CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
LIBS=""
# Defined in aclocal.m4.
grub_PROG_TARGET_CC

View file

@ -404,7 +404,7 @@ grub_ata_pciinit (grub_pci_device_t dev,
int nports = 2;
/* Read class. */
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
/* AMD CS5536 Southbridge. */
@ -444,9 +444,12 @@ grub_ata_pciinit (grub_pci_device_t dev,
{
/* Read the BARs, which either contain a mmapped IO address
or the IO port address. */
addr = grub_pci_make_address (dev, 4 + 2 * i);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
+ sizeof (grub_uint64_t) * i);
bar1 = grub_pci_read (addr);
addr = grub_pci_make_address (dev, 5 + 2 * i);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
+ sizeof (grub_uint64_t) * i
+ sizeof (grub_uint32_t));
bar2 = grub_pci_read (addr);
/* Check if the BARs describe an IO region. */

View file

@ -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"
@ -63,6 +64,7 @@ struct grub_font
short leading;
grub_uint32_t num_chars;
struct char_index_entry *char_index;
grub_uint16_t *bmp_idx;
};
/* Definition of font registry. */
@ -88,19 +90,6 @@ 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[] =
{
@ -227,6 +216,7 @@ font_init (grub_font_t font)
font->descent = 0;
font->num_chars = 0;
font->char_index = 0;
font->bmp_idx = 0;
}
/* Open the next section in the file.
@ -320,6 +310,14 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
* sizeof (struct char_index_entry));
if (! font->char_index)
return 1;
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
if (! font->bmp_idx)
{
grub_free (font->char_index);
return 1;
}
grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t));
#if FONT_DEBUG >= 2
grub_printf("num_chars=%d)\n", font->num_chars);
@ -346,6 +344,9 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
return 1;
}
if (entry->code < 0x10000)
font->bmp_idx[entry->code] = i;
last_code = entry->code;
/* Read storage flags byte. */
@ -447,7 +448,8 @@ grub_font_load (const char *filename)
#if FONT_DEBUG >= 3
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");
@ -476,7 +478,7 @@ grub_font_load (const char *filename)
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]);
@ -516,18 +518,22 @@ grub_font_load (const char *filename)
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 (&section);
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 (&section, &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 (&section);
@ -540,32 +546,42 @@ 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 (&section, &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 (&section, &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 (&section, &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 (&section, &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;
@ -641,7 +657,7 @@ read_be_int16 (grub_file_t file, grub_int16_t * value)
/* Return a pointer to the character index entry for the glyph corresponding to
the codepoint CODE in the font FONT. If not found, return zero. */
static struct char_index_entry *
static inline struct char_index_entry *
find_glyph (const grub_font_t font, grub_uint32_t code)
{
struct char_index_entry *table;
@ -649,8 +665,17 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
grub_size_t hi;
grub_size_t mid;
/* Do a binary search in `char_index', which is ordered by code point. */
table = font->char_index;
/* Use BMP index if possible. */
if (code < 0x10000)
{
if (font->bmp_idx[code] == 0xffff)
return 0;
return &table[font->bmp_idx[code]];
}
/* Do a binary search in `char_index', which is ordered by code point. */
lo = 0;
hi = font->num_chars - 1;

View file

@ -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;
@ -744,7 +743,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;

View file

@ -22,6 +22,7 @@
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/menu.h>
struct grub_env_var;
@ -30,18 +31,6 @@ typedef char *(*grub_env_read_hook_t) (struct grub_env_var *var,
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
const char *val);
enum grub_env_var_type
{
/* The default variable type which is local in current context. */
GRUB_ENV_VAR_LOCAL,
/* The exported type, which is passed to new contexts. */
GRUB_ENV_VAR_GLOBAL,
/* The data slot type, which is used to store arbitrary data. */
GRUB_ENV_VAR_DATA
};
struct grub_env_var
{
char *name;
@ -50,23 +39,24 @@ struct grub_env_var
grub_env_write_hook_t write_hook;
struct grub_env_var *next;
struct grub_env_var **prevp;
enum grub_env_var_type type;
int global;
};
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(grub_env_unset) (const char *name);
void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var));
struct grub_env_var *EXPORT_FUNC(grub_env_find) (const char *name);
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook);
grub_err_t EXPORT_FUNC(grub_env_context_open) (int export);
grub_err_t EXPORT_FUNC(grub_env_context_close) (void);
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
grub_err_t EXPORT_FUNC(grub_env_set_data_slot) (const char *name,
const void *ptr);
void *EXPORT_FUNC(grub_env_get_data_slot) (const char *name);
void EXPORT_FUNC(grub_env_unset_data_slot) (const char *name);
grub_err_t grub_env_context_open (int export);
grub_err_t grub_env_context_close (void);
grub_err_t grub_env_export (const char *name);
void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);
void grub_env_set_menu (grub_menu_t nmenu);
#endif /* ! GRUB_ENV_HEADER */

View file

@ -0,0 +1,46 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,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/>.
*/
#ifndef GRUB_ENV_PRIVATE_HEADER
#define GRUB_ENV_PRIVATE_HEADER 1
#include <grub/env.h>
/* The size of the hash table. */
#define HASHSZ 13
/* A hashtable for quick lookup of variables. */
struct grub_env_context
{
/* A hash table for variables. */
struct grub_env_var *vars[HASHSZ];
/* One level deeper on the stack. */
struct grub_env_context *prev;
};
/* This is used for sorting only. */
struct grub_env_sorted_var
{
struct grub_env_var *var;
struct grub_env_sorted_var *next;
};
extern struct grub_env_context *EXPORT_VAR(grub_current_context);
#endif /* ! GRUB_ENV_PRIVATE_HEADER */

38
include/grub/fontformat.h Normal file
View file

@ -0,0 +1,38 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_FONT_FORMAT_HEADER
#define GRUB_FONT_FORMAT_HEADER 1
/* FONT_FORMAT_PFF2_MAGIC use only 4 relevants bytes and the \0. */
#define FONT_FORMAT_PFF2_MAGIC "PFF2"
#define FONT_FORMAT_SECTION_NAMES_FILE "FILE"
#define FONT_FORMAT_SECTION_NAMES_FONT_NAME "NAME"
#define FONT_FORMAT_SECTION_NAMES_POINT_SIZE "PTSZ"
#define FONT_FORMAT_SECTION_NAMES_WEIGHT "WEIG"
#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH "MAXW"
#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT "MAXH"
#define FONT_FORMAT_SECTION_NAMES_ASCENT "ASCE"
#define FONT_FORMAT_SECTION_NAMES_DESCENT "DESC"
#define FONT_FORMAT_SECTION_NAMES_CHAR_INDEX "CHIX"
#define FONT_FORMAT_SECTION_NAMES_DATA "DATA"
#define FONT_FORMAT_SECTION_NAMES_FAMILY "FAMI"
#define FONT_FORMAT_SECTION_NAMES_SLAN "SLAN"
#endif /* ! GRUB_FONT_FORMAT_HEADER */

View file

@ -45,33 +45,25 @@ enum bsd_kernel_types
#define FREEBSD_B_PARTSHIFT OPENBSD_B_PARTSHIFT
#define FREEBSD_B_TYPESHIFT OPENBSD_B_TYPESHIFT
#define FREEBSD_BOOTINFO_VERSION 1
#define FREEBSD_N_BIOS_GEOM 8
#define FREEBSD_MODTYPE_KERNEL "elf kernel"
#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel"
#define FREEBSD_MODTYPE_ELF_MODULE "elf module"
#define FREEBSD_MODTYPE_ELF_MODULE_OBJ "elf obj module"
#define FREEBSD_MODTYPE_RAW "raw"
#define FREEBSD_BOOTINFO_VERSION 1
struct grub_freebsd_bootinfo
{
grub_uint32_t bi_version;
grub_uint32_t bi_kernelname;
grub_uint32_t bi_nfs_diskless;
grub_uint32_t bi_n_bios_used;
grub_uint32_t bi_bios_geom[FREEBSD_N_BIOS_GEOM];
grub_uint32_t bi_size;
grub_uint8_t bi_memsizes_valid;
grub_uint8_t bi_bios_dev;
grub_uint8_t bi_pad[2];
grub_uint32_t bi_basemem;
grub_uint32_t bi_extmem;
grub_uint32_t bi_symtab;
grub_uint32_t bi_esymtab;
grub_uint32_t bi_kernend;
grub_uint32_t bi_envp;
grub_uint32_t bi_modulep;
grub_uint32_t version;
grub_uint8_t unused1[44];
grub_uint32_t length;
grub_uint8_t unused2;
grub_uint8_t boot_device;
grub_uint8_t unused3[18];
grub_uint32_t kern_end;
grub_uint32_t environment;
grub_uint32_t tags;
} __attribute__ ((packed));
struct freebsd_tag_header

View file

@ -66,6 +66,8 @@
/* The size of a block list used in the kernel startup code. */
#define GRUB_BOOT_MACHINE_LIST_SIZE 12
#define GRUB_BOOT_MACHINE_PXE_DL 0x7f
#ifndef ASM_FILE
/* This is the blocklist used in the diskboot image. */

View file

@ -101,6 +101,9 @@ void read_command_list (void);
/* Defined in `autofs.c'. */
void read_fs_list (void);
void grub_context_init (void);
void grub_context_fini (void);
void read_crypto_list (void);
void read_terminal_list (void);

View file

@ -35,6 +35,37 @@
#define GRUB_PCI_ADDR_MEM_MASK ~0xf
#define GRUB_PCI_ADDR_IO_MASK ~0x03
#define GRUB_PCI_REG_PCI_ID 0x00
#define GRUB_PCI_REG_VENDOR 0x00
#define GRUB_PCI_REG_DEVICE 0x02
#define GRUB_PCI_REG_COMMAND 0x04
#define GRUB_PCI_REG_STATUS 0x06
#define GRUB_PCI_REG_REVISION 0x08
#define GRUB_PCI_REG_CLASS 0x08
#define GRUB_PCI_REG_CACHELINE 0x0c
#define GRUB_PCI_REG_LAT_TIMER 0x0d
#define GRUB_PCI_REG_HEADER_TYPE 0x0e
#define GRUB_PCI_REG_BIST 0x0f
#define GRUB_PCI_REG_ADDRESSES 0x10
/* Beware that 64-bit address takes 2 registers. */
#define GRUB_PCI_REG_ADDRESS_REG0 0x10
#define GRUB_PCI_REG_ADDRESS_REG1 0x14
#define GRUB_PCI_REG_ADDRESS_REG2 0x18
#define GRUB_PCI_REG_ADDRESS_REG3 0x1c
#define GRUB_PCI_REG_ADDRESS_REG4 0x20
#define GRUB_PCI_REG_ADDRESS_REG5 0x24
#define GRUB_PCI_REG_CIS_POINTER 0x28
#define GRUB_PCI_REG_SUBVENDOR 0x2c
#define GRUB_PCI_REG_SUBSYSTEM 0x2e
#define GRUB_PCI_REG_ROM_ADDRESS 0x30
#define GRUB_PCI_REG_CAP_POINTER 0x34
#define GRUB_PCI_REG_IRQ_LINE 0x3c
#define GRUB_PCI_REG_IRQ_PIN 0x3d
#define GRUB_PCI_REG_MIN_GNT 0x3e
#define GRUB_PCI_REG_MAX_LAT 0x3f
typedef grub_uint32_t grub_pci_id_t;
#ifdef GRUB_UTIL

View file

@ -33,3 +33,42 @@ void EXPORT_FUNC (__trampoline_setup) (void);
#ifdef HAVE___UCMPDI2
void EXPORT_FUNC (__ucmpdi2) (void);
#endif
#ifdef HAVE__RESTGPR_14_X
void EXPORT_FUNC (_restgpr_14_x) (void);
void EXPORT_FUNC (_restgpr_15_x) (void);
void EXPORT_FUNC (_restgpr_16_x) (void);
void EXPORT_FUNC (_restgpr_17_x) (void);
void EXPORT_FUNC (_restgpr_18_x) (void);
void EXPORT_FUNC (_restgpr_19_x) (void);
void EXPORT_FUNC (_restgpr_20_x) (void);
void EXPORT_FUNC (_restgpr_21_x) (void);
void EXPORT_FUNC (_restgpr_22_x) (void);
void EXPORT_FUNC (_restgpr_23_x) (void);
void EXPORT_FUNC (_restgpr_24_x) (void);
void EXPORT_FUNC (_restgpr_25_x) (void);
void EXPORT_FUNC (_restgpr_26_x) (void);
void EXPORT_FUNC (_restgpr_27_x) (void);
void EXPORT_FUNC (_restgpr_28_x) (void);
void EXPORT_FUNC (_restgpr_29_x) (void);
void EXPORT_FUNC (_restgpr_30_x) (void);
void EXPORT_FUNC (_restgpr_31_x) (void);
void EXPORT_FUNC (_savegpr_14) (void);
void EXPORT_FUNC (_savegpr_15) (void);
void EXPORT_FUNC (_savegpr_16) (void);
void EXPORT_FUNC (_savegpr_17) (void);
void EXPORT_FUNC (_savegpr_18) (void);
void EXPORT_FUNC (_savegpr_19) (void);
void EXPORT_FUNC (_savegpr_20) (void);
void EXPORT_FUNC (_savegpr_21) (void);
void EXPORT_FUNC (_savegpr_22) (void);
void EXPORT_FUNC (_savegpr_23) (void);
void EXPORT_FUNC (_savegpr_24) (void);
void EXPORT_FUNC (_savegpr_25) (void);
void EXPORT_FUNC (_savegpr_26) (void);
void EXPORT_FUNC (_savegpr_27) (void);
void EXPORT_FUNC (_savegpr_28) (void);
void EXPORT_FUNC (_savegpr_29) (void);
void EXPORT_FUNC (_savegpr_30) (void);
void EXPORT_FUNC (_savegpr_31) (void);
#endif

View file

@ -112,7 +112,7 @@ struct grub_script_cmd_menuentry
struct grub_script_arglist *arglist;
/* The sourcecode the entry will be generated from. */
char *sourcecode;
const char *sourcecode;
/* Options. XXX: Not used yet. */
int options;

View file

@ -73,18 +73,6 @@ grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
return 0;
}
static grub_err_t
grub_core_cmd_export (struct grub_command *cmd __attribute__ ((unused)),
int argc, char **args)
{
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no environment variable specified");
grub_env_export (args[0]);
return 0;
}
/* insmod MODULE */
static grub_err_t
grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
@ -193,8 +181,6 @@ grub_register_core_commands (void)
"[ENVVAR=VALUE]", "Set an environment variable.");
grub_register_command ("unset", grub_core_cmd_unset,
"ENVVAR", "Remove an environment variable.");
grub_register_command ("export", grub_core_cmd_export,
"ENVVAR", "Export a variable.");
grub_register_command ("ls", grub_core_cmd_ls,
"[ARG]", "List devices or files.");
grub_register_command ("insmod", grub_core_cmd_insmod,

View file

@ -441,7 +441,7 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_errno = GRUB_ERR_NONE;
num = ((size + GRUB_DISK_SECTOR_SIZE - 1)
num = ((size + real_offset + pos + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
p = grub_realloc (tmp_buf, num << GRUB_DISK_SECTOR_BITS);
@ -458,18 +458,20 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
goto finish;
}
grub_memcpy (buf, tmp_buf + real_offset, size);
grub_memcpy (buf, tmp_buf + pos + real_offset, size);
/* Call the read hook, if any. */
if (disk->read_hook)
while (size)
{
grub_size_t to_read = (size > GRUB_DISK_SECTOR_SIZE) ? GRUB_DISK_SECTOR_SIZE : size;
(disk->read_hook) (sector, real_offset,
((size > GRUB_DISK_SECTOR_SIZE)
? GRUB_DISK_SECTOR_SIZE
: size));
to_read);
if (grub_errno != GRUB_ERR_NONE)
goto finish;
sector++;
size -= GRUB_DISK_SECTOR_SIZE - real_offset;
size -= to_read - real_offset;
real_offset = 0;
}

View file

@ -1,7 +1,7 @@
/* efi.c - generic EFI support */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -162,6 +162,8 @@ grub_exit (void)
for (;;) ;
}
/* On i386, a firmware-independant grub_reboot() is provided by realmode.S. */
#ifndef __i386__
void
grub_reboot (void)
{
@ -169,6 +171,7 @@ grub_reboot (void)
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL);
}
#endif
void
grub_halt (void)

View file

@ -18,34 +18,15 @@
*/
#include <grub/env.h>
#include <grub/env_private.h>
#include <grub/misc.h>
#include <grub/mm.h>
/* The size of the hash table. */
#define HASHSZ 13
/* A hashtable for quick lookup of variables. */
struct grub_env_context
{
/* A hash table for variables. */
struct grub_env_var *vars[HASHSZ];
/* One level deeper on the stack. */
struct grub_env_context *prev;
};
/* This is used for sorting only. */
struct grub_env_sorted_var
{
struct grub_env_var *var;
struct grub_env_sorted_var *next;
};
/* The initial context. */
static struct grub_env_context initial_context;
/* The current context. */
static struct grub_env_context *current_context = &initial_context;
struct grub_env_context *grub_current_context = &initial_context;
/* Return the hash representation of the string S. */
static unsigned int
@ -60,88 +41,20 @@ grub_env_hashval (const char *s)
return i % HASHSZ;
}
static struct grub_env_var *
struct grub_env_var *
grub_env_find (const char *name)
{
struct grub_env_var *var;
int idx = grub_env_hashval (name);
/* Look for the variable in the current context. */
for (var = current_context->vars[idx]; var; var = var->next)
for (var = grub_current_context->vars[idx]; var; var = var->next)
if (grub_strcmp (var->name, name) == 0)
return var;
return 0;
}
grub_err_t
grub_env_context_open (int export)
{
struct grub_env_context *context;
int i;
context = grub_zalloc (sizeof (*context));
if (! context)
return grub_errno;
context->prev = current_context;
current_context = context;
/* Copy exported variables. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *var;
for (var = context->prev->vars[i]; var; var = var->next)
{
if (export && var->type == GRUB_ENV_VAR_GLOBAL)
{
if (grub_env_set (var->name, var->value) != GRUB_ERR_NONE)
{
grub_env_context_close ();
return grub_errno;
}
grub_env_export (var->name);
grub_register_variable_hook (var->name, var->read_hook, var->write_hook);
}
}
}
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_context_close (void)
{
struct grub_env_context *context;
int i;
if (! current_context->prev)
grub_fatal ("cannot close the initial context");
/* Free the variables associated with this context. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *p, *q;
for (p = current_context->vars[i]; p; p = q)
{
q = p->next;
grub_free (p->name);
if (p->type != GRUB_ENV_VAR_DATA)
grub_free (p->value);
grub_free (p);
}
}
/* Restore the previous context. */
context = current_context->prev;
grub_free (current_context);
current_context = context;
return GRUB_ERR_NONE;
}
static void
grub_env_insert (struct grub_env_context *context,
struct grub_env_var *var)
@ -165,26 +78,6 @@ grub_env_remove (struct grub_env_var *var)
var->next->prevp = var->prevp;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->type = GRUB_ENV_VAR_GLOBAL;
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_set (const char *name, const char *val)
{
@ -216,9 +109,8 @@ grub_env_set (const char *name, const char *val)
if (! var)
return grub_errno;
/* This is not necessary, because GRUB_ENV_VAR_LOCAL == 0. But leave
this for readability. */
var->type = GRUB_ENV_VAR_LOCAL;
/* This is not necessary. But leave this for readability. */
var->global = 0;
var->name = grub_strdup (name);
if (! var->name)
@ -228,7 +120,7 @@ grub_env_set (const char *name, const char *val)
if (! var->value)
goto fail;
grub_env_insert (current_context, var);
grub_env_insert (grub_current_context, var);
return GRUB_ERR_NONE;
@ -273,7 +165,6 @@ grub_env_unset (const char *name)
grub_env_remove (var);
grub_free (var->name);
if (var->type != GRUB_ENV_VAR_DATA)
grub_free (var->value);
grub_free (var);
}
@ -290,14 +181,10 @@ grub_env_iterate (int (*func) (struct grub_env_var *var))
{
struct grub_env_var *var;
for (var = current_context->vars[i]; var; var = var->next)
for (var = grub_current_context->vars[i]; var; var = var->next)
{
struct grub_env_sorted_var *p, **q;
/* Ignore data slots. */
if (var->type == GRUB_ENV_VAR_DATA)
continue;
sorted_var = grub_malloc (sizeof (*sorted_var));
if (! sorted_var)
goto fail;
@ -353,77 +240,3 @@ grub_register_variable_hook (const char *name,
return GRUB_ERR_NONE;
}
static char *
mangle_data_slot_name (const char *name)
{
return grub_xasprintf ("\e%s", name);
}
grub_err_t
grub_env_set_data_slot (const char *name, const void *ptr)
{
char *mangled_name;
struct grub_env_var *var;
mangled_name = mangle_data_slot_name (name);
if (! mangled_name)
goto fail;
/* If the variable does already exist, just update the variable. */
var = grub_env_find (mangled_name);
if (var)
{
var->value = (char *) ptr;
return GRUB_ERR_NONE;
}
/* The variable does not exist, so create a new one. */
var = grub_zalloc (sizeof (*var));
if (! var)
goto fail;
var->type = GRUB_ENV_VAR_DATA;
var->name = mangled_name;
var->value = (char *) ptr;
grub_env_insert (current_context, var);
return GRUB_ERR_NONE;
fail:
grub_free (mangled_name);
return grub_errno;
}
void *
grub_env_get_data_slot (const char *name)
{
char *mangled_name;
void *ptr = 0;
mangled_name = mangle_data_slot_name (name);
if (! mangled_name)
goto fail;
ptr = grub_env_get (mangled_name);
grub_free (mangled_name);
fail:
return ptr;
}
void
grub_env_unset_data_slot (const char *name)
{
char *mangled_name;
mangled_name = mangle_data_slot_name (name);
if (! mangled_name)
return;
grub_env_unset (mangled_name);
grub_free (mangled_name);
}

View file

@ -1,7 +1,7 @@
/* startup.S - bootstrap GRUB itself */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,3 +62,5 @@ codestart:
movl %eax, EXT_C(grub_efi_system_table)
call EXT_C(grub_main)
ret
#include "../realmode.S"

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,6 +18,7 @@
#include <grub/kernel.h>
#include <grub/mm.h>
#include <grub/machine/boot.h>
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/machine/console.h>
@ -59,6 +60,13 @@ make_install_device (void)
{
/* No hardcoded root partition - make it from the boot drive and the
partition number encoded at the install time. */
if (grub_boot_drive == GRUB_BOOT_MACHINE_PXE_DL)
{
grub_strcpy (dev, "(pxe");
ptr += sizeof ("(pxe") - 1;
}
else
{
grub_snprintf (dev, sizeof (dev),
"(%cd%u", (grub_boot_drive & 0x80) ? 'h' : 'f',
grub_boot_drive & 0x7f);
@ -67,14 +75,13 @@ make_install_device (void)
if (grub_install_dos_part >= 0)
grub_snprintf (ptr, sizeof (dev) - (ptr - dev),
",%u", grub_install_dos_part + 1);
ptr += grub_strlen (ptr);
if (grub_install_bsd_part >= 0)
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ",%c",
grub_install_bsd_part + 'a');
ptr += grub_strlen (ptr);
}
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ")%s", grub_prefix);
grub_strcpy (grub_prefix, dev);

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,6 +16,7 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/i386/pc/memory.h>
/*
* Note: These functions defined in this file may be called from C.

View file

@ -75,10 +75,6 @@ grub_machine_set_prefix (void)
char *filename;
char *prefix;
if (grub_env_get ("prefix"))
/* We already set prefix in grub_machine_init(). */
return;
if (grub_prefix[0])
{
grub_env_set ("prefix", grub_prefix);

View file

@ -114,7 +114,6 @@ grub_set_root_dev (void)
const char *prefix;
grub_register_variable_hook ("root", 0, grub_env_write_root);
grub_env_export ("root");
prefix = grub_env_get ("prefix");
@ -167,7 +166,6 @@ grub_main (void)
/* It is better to set the root device as soon as possible,
for convenience. */
grub_machine_set_prefix ();
grub_env_export ("prefix");
grub_set_root_dev ();
grub_register_core_commands ();

View file

@ -577,14 +577,14 @@ grub_freebsd_boot (void)
}
grub_memset (&bi, 0, sizeof (bi));
bi.bi_version = FREEBSD_BOOTINFO_VERSION;
bi.bi_size = sizeof (bi);
bi.version = FREEBSD_BOOTINFO_VERSION;
bi.length = sizeof (bi);
grub_bsd_get_device (&biosdev, &unit, &slice, &part);
bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) +
(unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT));
bi.bi_bios_dev = biosdev;
bi.boot_device = biosdev;
p_size = 0;
grub_env_iterate (iterate_env_count);
@ -629,7 +629,7 @@ grub_freebsd_boot (void)
{
*(p++) = 0;
bi.bi_envp = p_target;
bi.environment = p_target;
}
if (is_elf_kernel)
@ -655,9 +655,9 @@ grub_freebsd_boot (void)
case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ENVP:
if (is_64bit)
*(grub_uint64_t *) p_tag = bi.bi_envp;
*(grub_uint64_t *) p_tag = bi.environment;
else
*(grub_uint32_t *) p_tag = bi.bi_envp;
*(grub_uint32_t *) p_tag = bi.environment;
break;
case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND:
@ -675,12 +675,12 @@ grub_freebsd_boot (void)
p_tag = ALIGN_VAR (p_tag - p) + p;
}
bi.bi_modulep = (p - p0) + p_target;
bi.tags = (p - p0) + p_target;
p = (ALIGN_PAGE ((p_tag - p0) + p_target) - p_target) + p0;
}
bi.bi_kernend = kern_end;
bi.kern_end = kern_end;
grub_video_set_mode ("text", 0, 0);
@ -713,7 +713,7 @@ grub_freebsd_boot (void)
state.rip = (((grub_uint64_t) entry_hi) << 32) | entry;
stack[0] = entry;
stack[1] = bi.bi_modulep;
stack[1] = bi.tags;
stack[2] = kern_end;
return grub_relocator64_boot (relocator, state, 0, 0x40000000);
}
@ -746,7 +746,7 @@ grub_freebsd_boot (void)
stack[4] = 0;
stack[5] = 0;
stack[6] = stack_target + 9 * sizeof (grub_uint32_t);
stack[7] = bi.bi_modulep;
stack[7] = bi.tags;
stack[8] = kern_end;
return grub_relocator32_boot (relocator, state);
}

View file

@ -939,6 +939,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
break;
}
/* We can't detect VESA, but user is implicitly telling us that it
is built-in because `vga=' parameter was used. */
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
linux_mode
= &linux_vesafb_modes[vid_mode - GRUB_LINUX_VID_MODE_VESA_START];

View file

@ -199,7 +199,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
{
grub_elf_close (elf);
return grub_error (GRUB_ERR_UNKNOWN_OS,
"This ELF file is not of the right type\n");
"this ELF file is not of the right type\n");
}
/* Release the previously used memory. */
@ -239,7 +239,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (grub_elf_is_elf64 (elf))
err = grub_linux_load64 (elf, &extra, size);
else
err = grub_error (GRUB_ERR_BAD_FILE_TYPE, "Unknown ELF class");
err = grub_error (GRUB_ERR_BAD_FILE_TYPE, "unknown ELF class");
grub_elf_close (elf);
@ -330,13 +330,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_err_t err;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "No initrd specified");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no initrd specified");
if (!loaded)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load Linux first.");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load Linux first.");
if (initrd_loaded)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Only one initrd can be loaded.");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "only one initrd can be loaded.");
file = grub_file_open (argv[0]);
if (! file)
@ -359,7 +359,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
if (grub_file_read (file, initrd_src, size) != size)
{
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file");
grub_file_close (file);
return grub_errno;

View file

@ -419,10 +419,13 @@ grub_cmdline_get (const char *prompt)
int restore;
char *insertu8;
char *bufu8;
grub_uint32_t c;
c = buf[lpos];
buf[lpos] = '\0';
bufu8 = grub_ucs4_to_utf8_alloc (buf, lpos);
buf[lpos] = c;
if (!bufu8)
{
grub_print_error ();
@ -461,10 +464,21 @@ grub_cmdline_get (const char *prompt)
(grub_uint8_t *) insertu8,
insertlen, 0);
if (t > 0)
{
if (insert[t-1] == ' ' && buf[lpos] == ' ')
{
insert[t-1] = 0;
if (t != 1)
cl_insert (insert);
lpos++;
cl_set_pos_all ();
}
else
{
insert[t] = 0;
cl_insert (insert);
}
}
grub_free (insertu8);
grub_free (insert);

182
normal/context.c Normal file
View file

@ -0,0 +1,182 @@
/* env.c - Environment variables */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,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/env.h>
#include <grub/env_private.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/command.h>
#include <grub/normal.h>
struct menu_pointer
{
grub_menu_t menu;
struct menu_pointer *prev;
};
struct menu_pointer initial_menu;
struct menu_pointer *current_menu = &initial_menu;
void
grub_env_unset_menu (void)
{
current_menu->menu = NULL;
}
grub_menu_t
grub_env_get_menu (void)
{
return current_menu->menu;
}
void
grub_env_set_menu (grub_menu_t nmenu)
{
current_menu->menu = nmenu;
}
grub_err_t
grub_env_context_open (int export)
{
struct grub_env_context *context;
int i;
struct menu_pointer *menu;
context = grub_zalloc (sizeof (*context));
if (! context)
return grub_errno;
menu = grub_zalloc (sizeof (*menu));
if (! menu)
return grub_errno;
context->prev = grub_current_context;
grub_current_context = context;
menu->prev = current_menu;
current_menu = menu;
/* Copy exported variables. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *var;
for (var = context->prev->vars[i]; var; var = var->next)
{
if (export && var->global)
{
if (grub_env_set (var->name, var->value) != GRUB_ERR_NONE)
{
grub_env_context_close ();
return grub_errno;
}
grub_env_export (var->name);
grub_register_variable_hook (var->name, var->read_hook, var->write_hook);
}
}
}
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_context_close (void)
{
struct grub_env_context *context;
int i;
struct menu_pointer *menu;
if (! grub_current_context->prev)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"cannot close the initial context");
/* Free the variables associated with this context. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *p, *q;
for (p = grub_current_context->vars[i]; p; p = q)
{
q = p->next;
grub_free (p->name);
grub_free (p->value);
grub_free (p);
}
}
/* Restore the previous context. */
context = grub_current_context->prev;
grub_free (grub_current_context);
grub_current_context = context;
menu = current_menu->prev;
grub_free (current_menu);
current_menu = menu;
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}
static grub_command_t export_cmd;
static grub_err_t
grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)),
int argc, char **args)
{
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no environment variable specified");
grub_env_export (args[0]);
return 0;
}
void
grub_context_init (void)
{
grub_env_export ("root");
grub_env_export ("prefix");
export_cmd = grub_register_command ("export", grub_cmd_export,
"export ENVVAR", "Export a variable.");
}
void
grub_context_fini (void)
{
grub_unregister_command (export_cmd);
}

View file

@ -137,7 +137,7 @@ free_menu (grub_menu_t menu)
}
grub_free (menu);
grub_env_unset_data_slot ("menu");
grub_env_unset_menu ();
}
static void
@ -178,7 +178,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
return grub_errno;
classes_tail = classes_head;
menu = grub_env_get_data_slot ("menu");
menu = grub_env_get_menu ();
if (! menu)
return grub_error (GRUB_ERR_MENU, "no menu context");
@ -361,14 +361,14 @@ read_config_file (const char *config)
grub_menu_t newmenu;
newmenu = grub_env_get_data_slot ("menu");
newmenu = grub_env_get_menu ();
if (! newmenu)
{
newmenu = grub_zalloc (sizeof (*newmenu));
if (! newmenu)
return 0;
grub_env_set_data_slot ("menu", newmenu);
grub_env_set_menu (newmenu);
}
/* Try to open the config file. */
@ -642,6 +642,8 @@ grub_env_write_pager (struct grub_env_var *var __attribute__ ((unused)),
GRUB_MOD_INIT(normal)
{
grub_context_init ();
/* Normal mode shouldn't be unloaded. */
if (mod)
grub_dl_ref (mod);
@ -667,6 +669,8 @@ GRUB_MOD_INIT(normal)
GRUB_MOD_FINI(normal)
{
grub_context_fini ();
grub_set_history (0);
grub_register_variable_hook ("pager", 0, 0);
grub_fs_autoload_hook = 0;

View file

@ -79,12 +79,3 @@ term/serial.c
util/grub-mkrawimage.c
util/i386/pc/grub-setup.c
util/mkisofs/eltorito.c
util/mkisofs/joliet.c
util/mkisofs/mkisofs.c
util/mkisofs/mkisofs.h
util/mkisofs/multi.c
util/mkisofs/rock.c
util/mkisofs/tree.c
util/mkisofs/write.c

View file

@ -109,7 +109,7 @@ grub_ofconsole_getcharwidth (grub_uint32_t c __attribute__((unused)))
static void
grub_ofconsole_setcolorstate (grub_term_color_state state)
{
char *setcol;
char setcol[256];
int fg;
int bg;
@ -128,10 +128,8 @@ grub_ofconsole_setcolorstate (grub_term_color_state state)
return;
}
setcol = grub_xasprintf ("\e[3%dm\e[4%dm", fg, bg);
if (setcol)
grub_snprintf (setcol, sizeof (setcol), "\e[3%dm\e[4%dm", fg, bg);
grub_ofconsole_writeesc (setcol);
grub_free (setcol);
}
static void
@ -245,37 +243,28 @@ static void
grub_ofconsole_dimensions (void)
{
grub_ieee1275_ihandle_t options;
char *val;
grub_ssize_t lval;
if (! grub_ieee1275_finddevice ("/options", &options)
&& options != (grub_ieee1275_ihandle_t) -1)
{
if (! grub_ieee1275_get_property_length (options, "screen-#columns",
&lval) && lval != -1)
{
val = grub_malloc (lval);
if (val)
&lval)
&& lval >= 0 && lval < 1024)
{
char val[lval];
if (! grub_ieee1275_get_property (options, "screen-#columns",
val, lval, 0))
grub_ofconsole_width = (grub_uint8_t) grub_strtoul (val, 0, 10);
grub_free (val);
}
}
if (! grub_ieee1275_get_property_length (options, "screen-#rows",
&lval) && lval != -1)
{
val = grub_malloc (lval);
if (val)
if (! grub_ieee1275_get_property_length (options, "screen-#rows", &lval)
&& lval >= 0 && lval < 1024)
{
char val[lval];
if (! grub_ieee1275_get_property (options, "screen-#rows",
val, lval, 0))
grub_ofconsole_height = (grub_uint8_t) grub_strtoul (val, 0, 10);
grub_free (val);
}
}
}
@ -297,14 +286,12 @@ grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
{
char *s;
char s[256];
grub_curr_x = x;
grub_curr_y = y;
s = grub_xasprintf ("\e[%d;%dH", y + 1, x + 1);
if (s)
grub_snprintf (s, sizeof (s), "\e[%d;%dH", y + 1, x + 1);
grub_ofconsole_writeesc (s);
grub_free (s);
}
else
{

View file

@ -28,7 +28,7 @@ example_test (void)
/* Check if 1st argument is true and report with custom error message. */
grub_test_assert (2 == 2, "2 equal 2 expected");
grub_test_assert (2 == 3, "2 is not equal to %d", 3);
grub_test_assert (2 != 3, "2 matches %d", 3);
}
/* Register example_test method as a functional test. */

View file

@ -31,7 +31,7 @@ example_test (void)
/* Check if 1st argument is true and report with custom error message. */
grub_test_assert (2 == 2, "2 equal 2 expected");
grub_test_assert (2 == 3, "2 is not equal to %d", 3);
grub_test_assert (2 != 3, "2 matches %d", 3);
}
/* Register example_test method as a unit test. */

View file

@ -40,6 +40,8 @@ usage (int status)
else
printf ("\
Usage: %s [OPTIONS] SYMBOL-NAME\n\
\n\
Convert a binary file to a C header.\n\
\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\

View file

@ -280,27 +280,29 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
{
char *host_file;
char *loop_name;
char *argv[3] = { "-p" };
char *argv[3];
int i;
argv[0] = "-p";
for (i = 0; i < num_disks; i++)
{
loop_name = grub_xasprintf ("loop%d", i);
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!loop_name || !host_file)
{
grub_free (loop_name);
grub_free (host_file);
if (!loop_name)
grub_util_error (grub_errmsg);
host_file = grub_xasprintf ("(host)%s", images[i]);
if (!host_file)
grub_util_error (grub_errmsg);
return;
}
argv[1] = loop_name;
argv[2] = host_file;
if (execute_command ("loopback", 3, argv))
grub_util_error ("loopback command fails");
grub_free (loop_name);
grub_free (host_file);
}
grub_lvm_fini ();
@ -336,19 +338,16 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
for (i = 0; i < num_disks; i++)
{
grub_free (loop_name);
loop_name = grub_xasprintf ("loop%d", i);
if (!loop_name)
{
grub_free (host_file);
grub_util_error (grub_errmsg);
return;
}
argv[1] = loop_name;
execute_command ("loopback", 2, argv);
}
grub_free (loop_name);
grub_free (host_file);
}
}
static struct option options[] = {

View file

@ -20,6 +20,7 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <grub/fontformat.h>
#include <stdio.h>
#include <stdlib.h>
@ -392,9 +393,10 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
offset = 0;
leng = grub_cpu_to_be32 (4);
grub_util_write_image ("FILE", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_FILE,
sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1, file);
grub_util_write_image ((char *) &leng, 4, file);
grub_util_write_image ("PFF2", 4, file);
grub_util_write_image (FONT_FORMAT_PFF2_MAGIC, 4, file);
offset += 12;
if (! font_info->name)
@ -416,20 +418,25 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
font_name = xasprintf ("%s %s %d", font_info->name, &style_name[1],
font_info->size);
write_string_section ("NAME", font_name, &offset, file);
write_string_section ("FAMI", font_info->name, &offset, file);
write_string_section ("WEIG",
write_string_section (FONT_FORMAT_SECTION_NAMES_FONT_NAME,
font_name, &offset, file);
write_string_section (FONT_FORMAT_SECTION_NAMES_FAMILY,
font_info->name, &offset, file);
write_string_section (FONT_FORMAT_SECTION_NAMES_WEIGHT,
(font_info->style & FT_STYLE_FLAG_BOLD) ?
"bold" : "normal",
&offset, file);
write_string_section ("SLAN",
write_string_section (FONT_FORMAT_SECTION_NAMES_SLAN,
(font_info->style & FT_STYLE_FLAG_ITALIC) ?
"italic" : "normal",
&offset, file);
write_be16_section ("PTSZ", font_info->size, &offset, file);
write_be16_section ("MAXW", font_info->max_width, &offset, file);
write_be16_section ("MAXH", font_info->max_height, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
font_info->size, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
font_info->max_width, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
font_info->max_height, &offset, file);
if (! font_info->desc)
{
@ -447,8 +454,10 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
font_info->asce = font_info->max_y;
}
write_be16_section ("ASCE", font_info->asce, &offset, file);
write_be16_section ("DESC", font_info->desc, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_ASCENT,
font_info->asce, &offset, file);
write_be16_section (FONT_FORMAT_SECTION_NAMES_DESCENT,
font_info->desc, &offset, file);
if (font_verbosity > 0)
{
@ -479,7 +488,9 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
printf ("Number of glyph: %d\n", num);
leng = grub_cpu_to_be32 (num * 9);
grub_util_write_image ("CHIX", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1,
file);
grub_util_write_image ((char *) &leng, 4, file);
offset += 8 + num * 9 + 8;
@ -495,7 +506,8 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
}
leng = 0xffffffff;
grub_util_write_image ("DATA", 4, file);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_DATA,
sizeof(FONT_FORMAT_SECTION_NAMES_DATA) - 1, file);
grub_util_write_image ((char *) &leng, 4, file);
for (cur = font_info->glyph; cur; cur = cur->next)

View file

@ -82,16 +82,8 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd __attribute__ ((unused)))
}
grub_err_t
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
struct grub_script_cmd_menuentry *menu;
menu = (struct grub_script_cmd_menuentry *)cmd;
if (menu->sourcecode)
{
grub_free (menu->sourcecode);
menu->sourcecode = 0;
}
return 0;
}
@ -146,6 +138,7 @@ main (int argc, char *argv[])
auto grub_err_t get_config_line (char **line, int cont);
grub_err_t get_config_line (char **line, int cont __attribute__ ((unused)))
{
int i;
char *cmdline = 0;
size_t len = 0;
ssize_t read;
@ -164,6 +157,17 @@ main (int argc, char *argv[])
if (verbose)
grub_printf("%s", cmdline);
for (i = 0; cmdline[i] != '\0'; i++)
{
/* Replace tabs and carriage returns with spaces. */
if (cmdline[i] == '\t' || cmdline[i] == '\r')
cmdline[i] = ' ';
/* Replace '\n' with '\0'. */
if (cmdline[i] == '\n')
cmdline[i] = '\0';
}
*line = grub_strdup (cmdline);
free (cmdline);

View file

@ -1,7 +1,7 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -122,8 +122,9 @@ esac
# Gettext variables and module
if [ "x${LANG}" != "xC" ] ; then
prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
cat << EOF
set locale_dir=${locale_dir}
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
set lang=${grub_lang}
insmod gettext
EOF

View file

@ -89,3 +89,25 @@ cat << EOF
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF
cat << EOF
menuentry "${OS} (recovery mode)" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
echo $(gettext "Loading GNU Mach ...")
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
cat << EOF
echo $(gettext "Loading the Hurd ...")
module /hurd/${hurd_fs}.static ${hurd_fs} \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF

View file

@ -22,7 +22,6 @@ bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@

View file

@ -22,7 +22,6 @@ bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
@ -60,6 +59,15 @@ linux_entry ()
fi
printf "menuentry \"${title}\" {\n" "${os}" "${version}"
save_default_entry | sed -e "s/^/\t/"
# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null ; then
cat << EOF
set gfxpayload=keep
EOF
fi
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi

View file

@ -340,7 +340,7 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
is_partition = linux_find_partition (dev, disk->partition->start);
/* Open the partition. */
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()", dev);
grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
fd = open (dev, flags);
if (fd < 0)
{

View file

@ -1,7 +1,7 @@
/* hostfs.c - Dummy filesystem to provide access to the hosts filesystem */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
* Copyright (C) 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
@ -26,6 +26,7 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
/* dirent.d_type is a BSD extension, not part of POSIX */
@ -118,10 +119,17 @@ grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
FILE *f;
f = (FILE *) file->data;
fseeko (f, file->offset, SEEK_SET);
int s = fread (buf, 1, len, f);
if (fseeko (f, file->offset, SEEK_SET) != 0)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "fseeko: %s", strerror (errno));
return -1;
}
return s;
unsigned int s = fread (buf, 1, len, f);
if (s != len)
grub_error (GRUB_ERR_FILE_READ_ERROR, "fread: %s", strerror (errno));
return (signed) s;
}
static grub_err_t

View file

@ -46,8 +46,8 @@ install_device=
debug=no
update_nvram=yes
ofpathname=/usr/sbin/ofpathname
nvsetenv=/sbin/nvsetenv
ofpathname=`which ofpathname`
nvsetenv=`which nvsetenv`
# Usage: usage
# Print the usage.
@ -216,11 +216,11 @@ if test $update_nvram = yes; then
}
# Point boot-device at the new grub install
boot_device="boot-device $ofpath:$partno,\\grub"
"$nvsetenv" "$boot_device" || {
boot_device="$ofpath:$partno,\\grub"
"$nvsetenv" boot-device "$boot_device" || {
echo "$nvsetenv failed."
echo "You will have to set boot-device manually. At the Open Firmware prompt, type:"
echo " setenv $boot_device"
echo " setenv boot-device $boot_device"
exit 1
}
fi

View file

@ -26,6 +26,8 @@
#include <string.h>
#include <sys/stat.h>
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
int
grub_util_lvm_isvolume (char *name)
{
@ -33,10 +35,10 @@ grub_util_lvm_isvolume (char *name)
struct stat st;
int err;
devname = xmalloc (strlen (name) + 13);
devname = xmalloc (strlen (name) + sizeof (LVM_DEV_MAPPER_STRING));
strcpy (devname, "/dev/mapper/");
strcpy (devname+12, name);
strcpy (devname, LVM_DEV_MAPPER_STRING);
strcpy (devname + sizeof(LVM_DEV_MAPPER_STRING) - 1, name);
err = stat (devname, &st);
free (devname);

View file

@ -30,6 +30,9 @@
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <grub/kernel.h>
#include <grub/misc.h>
@ -513,13 +516,13 @@ make_system_path_relative_to_its_root (const char *path)
grub_util_error ("failed to get canonical path of %s", path);
len = strlen (p) + 1;
buf = strdup (p);
buf = xstrdup (p);
free (p);
if (stat (buf, &st) < 0)
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
buf2 = strdup (buf);
buf2 = xstrdup (buf);
num = st.st_dev;
/* This loop sets offset to the number of chars of the root
@ -541,12 +544,16 @@ make_system_path_relative_to_its_root (const char *path)
/* buf is another filesystem; we found it. */
if (st.st_dev != num)
{
/* offset == 0 means path given is the mount point. */
/* offset == 0 means path given is the mount point.
This works around special-casing of "/" in Un*x. This function never
prints trailing slashes (so that its output can be appended a slash
unconditionally). Each slash in is considered a preceding slash, and
therefore the root directory is an empty string. */
if (offset == 0)
{
free (buf);
free (buf2);
return strdup ("/");
return xstrdup ("");
}
else
break;
@ -563,11 +570,19 @@ make_system_path_relative_to_its_root (const char *path)
buf2[len - 1] = '\0';
len--;
}
if (len > 1)
return buf2;
else
{
/* This means path given is just a backslash. As above
we have to return an empty string. */
free (buf2);
return xstrdup ("");
}
}
}
free (buf);
buf3 = strdup (buf2 + offset);
buf3 = xstrdup (buf2 + offset);
free (buf2);
len = strlen (buf3);

View file

@ -26,7 +26,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
{
grub_pci_address_t ret;
ret.dev = dev;
ret.pos = reg << 2;
ret.pos = reg;
return ret;
}

View file

@ -92,7 +92,7 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
{
grub_pci_address_t addr;
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
if (grub_pci_read (addr) >> 24 == 0x3)
{
int i;

View file

@ -974,31 +974,82 @@ grub_video_fb_scroll (grub_video_color_t color, int dx, int dy)
{
/* 3. Move data in render target. */
struct grub_video_fbblit_info target;
grub_uint8_t *src;
grub_uint8_t *dst;
int j;
int i, j;
int linedelta, linelen;
target.mode_info = &render_target->mode_info;
target.data = render_target->data;
/* Check vertical direction of the move. */
if (dy <= 0)
/* 3a. Move data upwards. */
for (j = 0; j < height; j++)
{
dst = grub_video_fb_get_video_ptr (&target, dst_x, dst_y + j);
src = grub_video_fb_get_video_ptr (&target, src_x, src_y + j);
grub_memmove (dst, src,
width * target.mode_info->bytes_per_pixel);
linedelta = target.mode_info->pitch
- width * target.mode_info->bytes_per_pixel;
linelen = width * target.mode_info->bytes_per_pixel;
#define DO_SCROLL \
/* Check vertical direction of the move. */ \
if (dy < 0 || (dy == 0 && dx < 0)) \
{ \
dst = (void *) grub_video_fb_get_video_ptr (&target, \
dst_x, dst_y); \
src = (void *) grub_video_fb_get_video_ptr (&target, \
src_x, src_y); \
/* 3a. Move data upwards. */ \
for (j = 0; j < height; j++) \
{ \
for (i = 0; i < linelen; i++) \
*(dst++) = *(src++); \
dst += linedelta; \
src += linedelta; \
} \
} \
else \
{ \
/* 3b. Move data downwards. */ \
dst = (void *) grub_video_fb_get_video_ptr (&target, \
dst_x + width - 1, \
dst_y + height - 1); \
src = (void *) grub_video_fb_get_video_ptr (&target, \
src_x + width - 1, \
src_y + height - 1); \
for (j = 0; j < height; j++) \
{ \
for (i = 0; i < linelen; i++) \
*(dst--) = *(src--); \
dst -= linedelta; \
src -= linedelta; \
} \
}
else
/* 3b. Move data downwards. */
for (j = (height - 1); j >= 0; j--)
/* If everything is aligned on 32-bit use 32-bit copy. */
if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x, src_y)
% sizeof (grub_uint32_t) == 0
&& (grub_addr_t) grub_video_fb_get_video_ptr (&target, dst_x, dst_y)
% sizeof (grub_uint32_t) == 0
&& linelen % sizeof (grub_uint32_t) == 0
&& linedelta % sizeof (grub_uint32_t) == 0)
{
dst = grub_video_fb_get_video_ptr (&target, dst_x, dst_y + j);
src = grub_video_fb_get_video_ptr (&target, src_x, src_y + j);
grub_memmove (dst, src,
width * target.mode_info->bytes_per_pixel);
grub_uint32_t *src, *dst;
linelen /= sizeof (grub_uint32_t);
linedelta /= sizeof (grub_uint32_t);
DO_SCROLL
}
/* If everything is aligned on 16-bit use 16-bit copy. */
else if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x, src_y)
% sizeof (grub_uint16_t) == 0
&& (grub_addr_t) grub_video_fb_get_video_ptr (&target,
dst_x, dst_y)
% sizeof (grub_uint16_t) == 0
&& linelen % sizeof (grub_uint16_t) == 0
&& linedelta % sizeof (grub_uint16_t) == 0)
{
grub_uint16_t *src, *dst;
linelen /= sizeof (grub_uint16_t);
linedelta /= sizeof (grub_uint16_t);
DO_SCROLL
}
/* If not aligned at all use 8-bit copy. */
else
{
grub_uint8_t *src, *dst;
DO_SCROLL
}
}

View file

@ -74,7 +74,7 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
grub_pci_address_t addr;
grub_uint32_t class;
addr = grub_pci_make_address (dev, 2);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x0712126f)
@ -82,7 +82,7 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
found = 1;
addr = grub_pci_make_address (dev, 4);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr);
framebuffer.dev = dev;