From 222671b22ea7a95e6bc812bd42d6d3ba78381a3d Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 4 Aug 2009 20:10:28 +0000 Subject: [PATCH 01/45] 2009-08-04 Felix Zielcke * commands/search.c: Fix help output to match actual code. --- ChangeLog | 4 ++++ commands/search.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 670d7258b..71ad4afca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-04 Felix Zielcke + + * commands/search.c: Fix help output to match actual code. + 2009-08-02 Vladimir Serbinenko * commands/hexdump.c (grub_cmd_hexdump): Use grub_disk_read instead diff --git a/commands/search.c b/commands/search.c index 4ac7429eb..d10b51abf 100644 --- a/commands/search.c +++ b/commands/search.c @@ -29,7 +29,7 @@ static const struct grub_arg_option options[] = { - {"file", 'f', 0, "search devices by a file (default)", 0, 0}, + {"file", 'f', 0, "search devices by a file", 0, 0}, {"label", 'l', 0, "search devices by a filesystem label", 0, 0}, {"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0}, {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING}, From ecb1a6d9e9fabb3f858a8127950e4f60da43b0a8 Mon Sep 17 00:00:00 2001 From: robertmh Date: Tue, 4 Aug 2009 21:23:11 +0000 Subject: [PATCH 02/45] Fix last ChangeLog entry. --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 71ad4afca..2437c7cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2009-08-04 Felix Zielcke - * commands/search.c: Fix help output to match actual code. + * commands/search.c (options): Fix help output to match actual code. 2009-08-02 Vladimir Serbinenko From f56a875639c8deacaa40b953602f489aa9ab0881 Mon Sep 17 00:00:00 2001 From: robertmh Date: Tue, 4 Aug 2009 21:28:19 +0000 Subject: [PATCH 03/45] 2009-08-04 Robert Millan Fix a bug resulting in black screen when loading Linux using a packed video mode. * kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette_width): New function. * include/grub/i386/pc/vbe.h (GRUB_VBE_CAPABILITY_DACWIDTH): New macro. (grub_vbe_bios_getset_dac_palette_width): New function. (grub_vbe_bios_get_dac_palette_width) (grub_vbe_bios_set_dac_palette_width): New macros (act as wrappers for grub_vbe_bios_getset_dac_palette_width()). * video/i386/pc/vbe.c (grub_vbe_probe): Use `GRUB_VBE_STATUS_OK' to check for return status. (grub_vbe_get_video_mode_info): When getting information for a packed mode (<= 8 bpp), obtain DAC palette width using grub_vbe_bios_getset_dac_palette_width(), and use that for initializing {red,green,blue}_mark_size. --- ChangeLog | 21 +++++++++++++++++ include/grub/i386/pc/vbe.h | 7 ++++++ kern/i386/pc/startup.S | 46 ++++++++++++++++++++++++++++++++++++++ video/i386/pc/vbe.c | 20 ++++++++++++++++- 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2437c7cac..44f14a0d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2009-08-04 Robert Millan + + Fix a bug resulting in black screen when loading Linux using a + packed video mode. + + * kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette_width): New + function. + + * include/grub/i386/pc/vbe.h (GRUB_VBE_CAPABILITY_DACWIDTH): New macro. + (grub_vbe_bios_getset_dac_palette_width): New function. + (grub_vbe_bios_get_dac_palette_width) + (grub_vbe_bios_set_dac_palette_width): New macros (act as wrappers for + grub_vbe_bios_getset_dac_palette_width()). + + * video/i386/pc/vbe.c (grub_vbe_probe): Use `GRUB_VBE_STATUS_OK' to + check for return status. + (grub_vbe_get_video_mode_info): When getting information for a packed + mode (<= 8 bpp), obtain DAC palette width using + grub_vbe_bios_getset_dac_palette_width(), and use that for initializing + {red,green,blue}_mark_size. + 2009-08-04 Felix Zielcke * commands/search.c (options): Fix help output to match actual code. diff --git a/include/grub/i386/pc/vbe.h b/include/grub/i386/pc/vbe.h index bd6ecd7e4..fad3c6c36 100644 --- a/include/grub/i386/pc/vbe.h +++ b/include/grub/i386/pc/vbe.h @@ -30,6 +30,8 @@ /* VBE status codes. */ #define GRUB_VBE_STATUS_OK 0x004f +#define GRUB_VBE_CAPABILITY_DACWIDTH (1 << 0) + /* Bits from the GRUB_VBE "mode_attributes" field in the mode info struct. */ #define GRUB_VBE_MODEATTR_SUPPORTED (1 << 0) #define GRUB_VBE_MODEATTR_RESERVED_1 (1 << 1) @@ -181,6 +183,11 @@ grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_controller_info) (struct grub_vb grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_get_mode_info) (grub_uint32_t mode, struct grub_vbe_mode_info_block *mode_info); +grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_getset_dac_palette_width) (int set, int *width); + +#define grub_vbe_bios_get_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(0, (width)) +#define grub_vbe_bios_set_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(1, (width)) + /* Call VESA BIOS 0x4f02 to set video mode, return status. */ grub_vbe_status_t EXPORT_FUNC(grub_vbe_bios_set_mode) (grub_uint32_t mode, struct grub_vbe_crtc_info_block *crtc_info); diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index be258fb08..1a896eda1 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -1732,6 +1732,52 @@ FUNCTION(grub_vbe_bios_get_mode) popl %ebp ret +/* + * grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size) + * + * Register allocations for parameters: + * %eax set + * %edx *dac_mask_size + */ +FUNCTION(grub_vbe_bios_getset_dac_palette_width) + pushl %ebp + pushl %ebx + + xorl %ebx, %ebx + + /* If we only want to fetch the value, set %bl to 1. */ + testl %eax, %eax + jne 1f + incb %bl +1: + + /* Put desired width in %bh. */ + movl (%edx), %eax + movb %al, %bh + + call prot_to_real + .code16 + + movw $0x4f08, %ax + int $0x10 + + movw %ax, %dx /* real_to_prot destroys %eax. */ + + DATA32 call real_to_prot + .code32 + + /* Move result back to *dac_mask_size. */ + movb %bh, %al + movl %eax, (%edx) + + /* Return value in %eax. */ + xorl %eax, %eax + movw %dx, %ax + + popl %ebx + popl %ebp + ret + /* * grub_vbe_status_t grub_vbe_bios_set_memory_window (grub_uint32_t window, * grub_uint32_t position); diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index ae0840234..1670a737d 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -116,7 +116,7 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block) /* Try to get controller info block. */ status = grub_vbe_bios_get_controller_info (vbe_ib); - if (status == 0x004F) + if (status == GRUB_VBE_STATUS_OK) { /* Copy it for later usage. */ grub_memcpy (&controller_info, vbe_ib, sizeof (controller_info)); @@ -300,6 +300,24 @@ grub_vbe_get_video_mode_info (grub_uint32_t mode, /* Make copy of mode info block. */ grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info)); + + /* Packed mode. Query DAC Palette width for color sizes. */ + if (mode_info->bits_per_pixel <= 8) + { + int width = 8; + status = 0; + + if (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH) + status = grub_vbe_bios_set_dac_palette_width (& width); + + if (status != GRUB_VBE_STATUS_OK) + /* 6 is default after mode reset. */ + width = 6; + + mode_info->red_mask_size = mode_info->green_mask_size + = mode_info->blue_mask_size = width; + mode_info->rsvd_mask_size = 0; + } } else /* Just clear mode info block if it isn't a VESA mode. */ From 6dcfcb3291f885d9c9229aac985d69f6c205131d Mon Sep 17 00:00:00 2001 From: fzielcke Date: Thu, 6 Aug 2009 07:05:48 +0000 Subject: [PATCH 04/45] 2009-08-06 Felix Zielcke * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Fix handling of multiple abstraction modules. --- ChangeLog | 5 +++++ util/grub-mkconfig_lib.in | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44f14a0d4..68134df3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-06 Felix Zielcke + + * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Fix + handling of multiple abstraction modules. + 2009-08-04 Robert Millan Fix a bug resulting in black screen when loading Linux using a diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 9afbd3b1f..d27b72ea1 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -136,9 +136,9 @@ prepare_grub_to_access_device () # Abstraction modules aren't auto-loaded. abstraction="`${grub_probe} --device ${device} --target=abstraction`" - if [ "x${abstraction}" = "x" ] ; then : ; else - echo "insmod ${abstraction}" - fi + for module in ${abstraction} ; do + echo "insmod ${module}" + done # If there's a filesystem UUID that GRUB is capable of identifying, use it; # otherwise set root as per value in device.map. From 4e2171f866615f25038a506a5986541b025a11f5 Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 11:55:36 +0000 Subject: [PATCH 05/45] 2009-08-07 Robert Millan * util/grub.d/10_freebsd.in: Use an absolute device path for `vfs.root.mountfrom'. Set `vfs.root.mountfrom.options=rw'. --- ChangeLog | 5 +++++ util/grub.d/10_freebsd.in | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68134df3e..2632d0509 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-07 Robert Millan + + * util/grub.d/10_freebsd.in: Use an absolute device path for + `vfs.root.mountfrom'. Set `vfs.root.mountfrom.options=rw'. + 2009-08-06 Felix Zielcke * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Fix diff --git a/util/grub.d/10_freebsd.in b/util/grub.d/10_freebsd.in index 2addf03a1..64d2cc4c0 100644 --- a/util/grub.d/10_freebsd.in +++ b/util/grub.d/10_freebsd.in @@ -50,8 +50,6 @@ if [ "x$kfreebsd" != "x" ] ; then devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` fi - root_device=`basename ${GRUB_DEVICE}` - # For "ufs" it's the same. Do we care about the others? kfreebsd_fs=${GRUB_FS} @@ -69,7 +67,8 @@ EOF EOF fi cat << EOF - set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${root_device} + set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE} + set FreeBSD.vfs.root.mountfrom.options=rw } EOF fi From 7a4894cc9991e1e50501bbd63eca14405c8b8b15 Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 12:02:54 +0000 Subject: [PATCH 06/45] Split in two commits. This one's the first. 2009-08-07 Robert Millan * util/grub.d/10_linux.in (test_numeric): Moved from here ... * util/grub-mkconfig_lib.in (version_test_numeric): ... to here. Update all users. * util/grub.d/10_linux.in (test_gt): Strip any basename prefix, not just "vmlinu[zx]". Moved from here ... * util/grub-mkconfig_lib.in (version_test_gt): ... to here. Update all users. * util/grub.d/10_linux.in (find_latest): Moved from here ... * util/grub-mkconfig_lib.in (version_find_latest): ... to here. Update all users. --- ChangeLog | 16 ++++++++++++++++ util/grub.d/10_linux.in | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2632d0509..78a212ff1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2009-08-07 Robert Millan + + * util/grub.d/10_linux.in (test_numeric): Moved from here ... + * util/grub-mkconfig_lib.in (version_test_numeric): ... to here. + Update all users. + + * util/grub.d/10_linux.in (test_gt): Strip any basename prefix, + not just "vmlinu[zx]". + Moved from here ... + * util/grub-mkconfig_lib.in (version_test_gt): ... to here. Update + all users. + + * util/grub.d/10_linux.in (find_latest): Moved from here ... + * util/grub-mkconfig_lib.in (version_find_latest): ... to here. Update + all users. + 2009-08-07 Robert Millan * util/grub.d/10_freebsd.in: Use an absolute device path for diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 3d130609a..637bf3e94 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -67,8 +67,8 @@ test_numeric () test_gt () { - local a=`echo $1 | sed -e "s/vmlinu[zx]-//g"` - local b=`echo $2 | sed -e "s/vmlinu[zx]-//g"` + local a=`echo $1 | sed -e "s/[^-]*-//g"` + local b=`echo $2 | sed -e "s/[^-]*-//g"` local cmp=gt if [ "x$b" = "x" ] ; then return 0 From 9d5bdd2cf697b4421e1cc203271a8cc7e0f0ea4d Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 12:05:06 +0000 Subject: [PATCH 07/45] Split in two commits. This one's the second. 2009-08-07 Robert Millan * util/grub.d/10_linux.in (test_numeric): Moved from here ... * util/grub-mkconfig_lib.in (version_test_numeric): ... to here. Update all users. * util/grub.d/10_linux.in (test_gt): Strip any basename prefix, not just "vmlinu[zx]". Moved from here ... * util/grub-mkconfig_lib.in (version_test_gt): ... to here. Update all users. * util/grub.d/10_linux.in (find_latest): Moved from here ... * util/grub-mkconfig_lib.in (version_find_latest): ... to here. Update all users. --- util/grub-mkconfig_lib.in | 51 +++++++++++++++++++++++++++++++++++++ util/grub.d/10_linux.in | 53 +-------------------------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index d27b72ea1..52dac00fe 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -176,3 +176,54 @@ grub_file_is_not_garbage () fi return 0 } + +version_test_numeric () +{ + local a=$1 + local cmp=$2 + local b=$3 + if [ "$a" = "$b" ] ; then + case $cmp in + ge|eq|le) return 0 ;; + gt|lt) return 1 ;; + esac + fi + if [ "$cmp" = "lt" ] ; then + c=$a + a=$b + b=$c + fi + if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then + return 0 + else + return 1 + fi +} + +version_test_gt () +{ + local a=`echo $1 | sed -e "s/[^-]*-//g"` + local b=`echo $2 | sed -e "s/[^-]*-//g"` + local cmp=gt + if [ "x$b" = "x" ] ; then + return 0 + fi + case $a:$b in + *.old:*.old) ;; + *.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;; + *:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;; + esac + version_test_numeric $a $cmp $b + return $? +} + +version_find_latest () +{ + local a="" + for i in $@ ; do + if version_test_gt "$i" "$a" ; then + a="$i" + fi + done + echo "$a" +} diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 637bf3e94..4df078e8f 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -42,57 +42,6 @@ else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi -test_numeric () -{ - local a=$1 - local cmp=$2 - local b=$3 - if [ "$a" = "$b" ] ; then - case $cmp in - ge|eq|le) return 0 ;; - gt|lt) return 1 ;; - esac - fi - if [ "$cmp" = "lt" ] ; then - c=$a - a=$b - b=$c - fi - if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then - return 0 - else - return 1 - fi -} - -test_gt () -{ - local a=`echo $1 | sed -e "s/[^-]*-//g"` - local b=`echo $2 | sed -e "s/[^-]*-//g"` - local cmp=gt - if [ "x$b" = "x" ] ; then - return 0 - fi - case $a:$b in - *.old:*.old) ;; - *.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;; - *:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;; - esac - test_numeric $a $cmp $b - return $? -} - -find_latest () -{ - local a="" - for i in $@ ; do - if test_gt "$i" "$a" ; then - a="$i" - fi - done - echo "$a" -} - linux_entry () { cat << EOF @@ -117,7 +66,7 @@ list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do done` while [ "x$list" != "x" ] ; do - linux=`find_latest $list` + linux=`version_find_latest $list` echo "Found linux image: $linux" >&2 basename=`basename $linux` dirname=`dirname $linux` From b969c52f6b500bdc643ff6698162b7ba1dd6a54f Mon Sep 17 00:00:00 2001 From: fzielcke Date: Fri, 7 Aug 2009 12:18:03 +0000 Subject: [PATCH 08/45] 2009-08-07 Felix Zielcke * util/grub-mkconfig_lib.in (font_path): Move the functionality of it to ... * util/grub-mkconfig.in: ... here. Prefer unicode.pf2 and unifont.pf2 over ascii.pf2. Export LANG=C in case ascii.pf2 gets used. --- ChangeLog | 7 +++++++ util/grub-mkconfig.in | 32 +++++++++++++++++++++----------- util/grub-mkconfig_lib.in | 17 ----------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78a212ff1..b149b540c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-07 Felix Zielcke + + * util/grub-mkconfig_lib.in (font_path): Move the functionality + of it to ... + * util/grub-mkconfig.in: ... here. Prefer unicode.pf2 and + unifont.pf2 over ascii.pf2. Export LANG=C in case ascii.pf2 gets used. + 2009-08-07 Robert Millan * util/grub.d/10_linux.in (test_numeric): Moved from here ... diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 75a07e698..98726f144 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -24,6 +24,8 @@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ package_version=@PACKAGE_VERSION@ +datadir=@datadir@ +pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"` grub_prefix=`echo /boot/grub | sed ${transform}` grub_cfg="" grub_mkconfig_dir=${sysconfdir}/grub.d @@ -151,22 +153,30 @@ esac # check for terminals that require fonts case ${GRUB_TERMINAL_OUTPUT} in gfxterm) - if path=`font_path` ; then - GRUB_FONT_PATH="${path}" - else - # fallback to the native terminal for this platform - unset GRUB_TERMINAL_OUTPUT + for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do + for basename in unicode unifont ascii; do + path="${dir}/${basename}.pf2" + if is_path_readable_by_grub ${path} > /dev/null ; then + GRUB_FONT_PATH=${path} + else + continue + fi + if [ "${basename}" = "ascii"] ; then + # make sure all our children behave in conformance with ascii.. + export LANG=C + fi + break 2 + done + done + if [ -z "${GRUB_FONT_PATH}" ] ; then + # fallback to the native terminal for this platform + unset GRUB_TERMINAL_OUTPUT + fi fi ;; -esac - -# does our terminal support utf-8 ? -case ${GRUB_TERMINAL_OUTPUT} in - gfxterm) ;; *) # make sure all our children behave in conformance with ascii.. export LANG=C - ;; esac # These are defined in this script, export them here so that user can diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 52dac00fe..99b3c9c6f 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -148,23 +148,6 @@ prepare_grub_to_access_device () fi } -font_path () -{ - for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do - # FIXME: We prefer ascii because loading complete fonts is too slow (and - # we don't yet provide the gettext magic that would make unicode useful). - for basename in ascii unicode unifont ; do - path="${dir}/${basename}.pf2" - if is_path_readable_by_grub ${path} > /dev/null ; then - echo "${path}" - return 0 - fi - done - done - - return 1 -} - grub_file_is_not_garbage () { if test -f "$1" ; then From 818e094a040e00beab7ea410294fd07a641b6281 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Fri, 7 Aug 2009 13:37:52 +0000 Subject: [PATCH 09/45] 2009-08-07 Felix Zielcke * fs/uuid.c (grub_jfs_superblock): New fields unused2 and uuid. (grub_jfs_uuid): New function. (grub_jfs_fs): Set uuid field to grub_jfs_uuid. --- ChangeLog | 6 ++++++ fs/jfs.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index b149b540c..9475494cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-07 Felix Zielcke + + * fs/uuid.c (grub_jfs_superblock): New fields unused2 and uuid. + (grub_jfs_uuid): New function. + (grub_jfs_fs): Set uuid field to grub_jfs_uuid. + 2009-08-07 Felix Zielcke * util/grub-mkconfig_lib.in (font_path): Move the functionality diff --git a/fs/jfs.c b/fs/jfs.c index ae7486a2f..7b361c065 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -51,6 +51,8 @@ struct grub_jfs_sblock grub_uint8_t unused[71]; grub_uint8_t volname[11]; + grub_uint8_t unused2[32]; + grub_uint8_t uuid[16]; }; struct grub_jfs_extent @@ -832,6 +834,38 @@ grub_jfs_close (grub_file_t file) return GRUB_ERR_NONE; } +static grub_err_t +grub_jfs_uuid (grub_device_t device, char **uuid) +{ + struct grub_jfs_data *data; + grub_disk_t disk = device->disk; + + grub_dl_ref (my_mod); + + data = grub_jfs_mount (disk); + if (data) + { + *uuid = grub_malloc (40 + sizeof ('\0')); + + grub_sprintf (*uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + data->sblock.uuid[0], data->sblock.uuid[1], + data->sblock.uuid[2], data->sblock.uuid[3], + data->sblock.uuid[4], data->sblock.uuid[5], + data->sblock.uuid[6], data->sblock.uuid[7], + data->sblock.uuid[8], data->sblock.uuid[9], + data->sblock.uuid[10], data->sblock.uuid[11], + data->sblock.uuid[12], data->sblock.uuid[13], + data->sblock.uuid[14], data->sblock.uuid[15]); + } + else + *uuid = NULL; + + grub_dl_unref (my_mod); + + grub_free (data); + + return grub_errno; +} static grub_err_t grub_jfs_label (grub_device_t device, char **label) @@ -856,6 +890,7 @@ static struct grub_fs grub_jfs_fs = .read = grub_jfs_read, .close = grub_jfs_close, .label = grub_jfs_label, + .uuid = grub_jfs_uuid, .next = 0 }; From 0ded14361d48d0ac21a9a3b8d1492a0ae6dbceac Mon Sep 17 00:00:00 2001 From: fzielcke Date: Fri, 7 Aug 2009 13:40:43 +0000 Subject: [PATCH 10/45] use \t instead of spaces to indent --- fs/jfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/jfs.c b/fs/jfs.c index 7b361c065..b38efed59 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -852,10 +852,10 @@ grub_jfs_uuid (grub_device_t device, char **uuid) data->sblock.uuid[2], data->sblock.uuid[3], data->sblock.uuid[4], data->sblock.uuid[5], data->sblock.uuid[6], data->sblock.uuid[7], - data->sblock.uuid[8], data->sblock.uuid[9], - data->sblock.uuid[10], data->sblock.uuid[11], - data->sblock.uuid[12], data->sblock.uuid[13], - data->sblock.uuid[14], data->sblock.uuid[15]); + data->sblock.uuid[8], data->sblock.uuid[9], + data->sblock.uuid[10], data->sblock.uuid[11], + data->sblock.uuid[12], data->sblock.uuid[13], + data->sblock.uuid[14], data->sblock.uuid[15]); } else *uuid = NULL; From 998b5aa9ae66590d661b95a91fe99edc92991f8b Mon Sep 17 00:00:00 2001 From: fzielcke Date: Fri, 7 Aug 2009 14:06:24 +0000 Subject: [PATCH 11/45] 2009-08-07 Felix Zielcke * util/grub-mkconfig.in: Remove a wrong `fi'. --- ChangeLog | 4 ++++ util/grub-mkconfig.in | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9475494cd..102ed46a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-07 Felix Zielcke + + * util/grub-mkconfig.in: Remove a wrong `fi'. + 2009-08-07 Felix Zielcke * fs/uuid.c (grub_jfs_superblock): New fields unused2 and uuid. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 98726f144..4ddb7beae 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -172,7 +172,6 @@ case ${GRUB_TERMINAL_OUTPUT} in # fallback to the native terminal for this platform unset GRUB_TERMINAL_OUTPUT fi - fi ;; *) # make sure all our children behave in conformance with ascii.. From 126d66289217abaefe05a13f1ebdec82ab36fef6 Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 16:51:13 +0000 Subject: [PATCH 12/45] 2009-08-07 Robert Millan * docs/grub.texi: Update CVS information to SVN. Replace outdated "GRUB 2 will include" phrase with "GRUB 2 includes". --- ChangeLog | 5 +++++ docs/grub.texi | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 102ed46a3..63b2d49b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-07 Robert Millan + + * docs/grub.texi: Update CVS information to SVN. + Replace outdated "GRUB 2 will include" phrase with "GRUB 2 includes". + 2009-08-07 Felix Zielcke * util/grub-mkconfig.in: Remove a wrong `fi'. diff --git a/docs/grub.texi b/docs/grub.texi index 11603930e..1abeb242c 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3854,13 +3854,8 @@ just do: @end group @end example -This will install the grub shell @file{grub} (@pxref{Invoking the grub -shell}), the Multiboot checker @file{mbchk} (@pxref{Invoking mbchk}), -and the GRUB images. This will also install the GRUB manual. - -Also, the latest version is available from the CVS. See -@uref{http://savannah.gnu.org/cvs/?group=grub} for more information. - +Also, the latest version is available from the SVN. See +@uref{http://savannah.gnu.org/svn/?group=grub} for more information. @node Reporting bugs @appendix Reporting bugs @@ -3932,7 +3927,7 @@ Once we get your report, we will try to fix the bugs. @node Future @appendix Where GRUB will go -We started the next generation of GRUB, GRUB 2. This will include +We started the next generation of GRUB, GRUB 2. GRUB 2 includes internationalization, dynamic module loading, real memory management, multiple architecture support, a scripting language, and many other nice feature. If you are interested in the development of GRUB 2, take From ed94253fbff5f37828b526845e658b408ea3d98c Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 17:14:16 +0000 Subject: [PATCH 13/45] 2009-08-07 Robert Millan * docs/version.texi: New file. Provides version information for grub.texi. --- ChangeLog | 5 +++++ docs/version.texi | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 docs/version.texi diff --git a/ChangeLog b/ChangeLog index 63b2d49b6..4767763e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-07 Robert Millan + + * docs/version.texi: New file. Provides version information for + grub.texi. + 2009-08-07 Robert Millan * docs/grub.texi: Update CVS information to SVN. diff --git a/docs/version.texi b/docs/version.texi new file mode 100644 index 000000000..5a03fa3c9 --- /dev/null +++ b/docs/version.texi @@ -0,0 +1,4 @@ +@set UPDATED 7 Ago 2009 +@set UPDATED-MONTH Ago 2009 +@set EDITION 1.97~snapshot +@set VERSION 1.97~snapshot From 892a3d98052232e30e004a7b870463acf7cc8b21 Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 7 Aug 2009 17:18:12 +0000 Subject: [PATCH 14/45] 2009-08-07 Robert Millan * docs/grub.texi: Major overhaul. Remove all sections that are specific to GRUB Legacy, or mostly composed of Legacy-specific information. --- ChangeLog | 6 + docs/grub.texi | 2576 +----------------------------------------------- 2 files changed, 16 insertions(+), 2566 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4767763e3..a47abd4a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-07 Robert Millan + + * docs/grub.texi: Major overhaul. Remove all sections that are + specific to GRUB Legacy, or mostly composed of Legacy-specific + information. + 2009-08-07 Robert Millan * docs/version.texi: New file. Provides version information for diff --git a/docs/grub.texi b/docs/grub.texi index 1abeb242c..e3f412565 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -34,14 +34,9 @@ Invariant Sections. @direntry * GRUB: (grub). The GRand Unified Bootloader * grub-install: (grub)Invoking grub-install. Install GRUB on your drive -* grub-md5-crypt: (grub)Invoking grub-md5-crypt. Encrypt a password - in MD5 format * grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo command from a terminfo name -* grub-set-default: (grub)Invoking grub-set-default. Set a default boot - entry -* mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel @end direntry @setchapternewpage odd @@ -86,7 +81,6 @@ This edition documents version @value{VERSION}. * Network:: Downloading OS images from a network * Serial terminal:: Using GRUB via a serial line * Preset Menu:: Embedding a configuration file into GRUB -* Security:: Improving the security * Images:: GRUB image files * Filesystem:: Filesystem syntax and semantics * Interface:: The menu and the command-line @@ -94,10 +88,7 @@ This edition documents version @value{VERSION}. * Troubleshooting:: Error messages produced by GRUB * Invoking the grub shell:: How to use the grub shell * Invoking grub-install:: How to use the GRUB installer -* Invoking grub-md5-crypt:: How to generate a cryptic password * Invoking grub-terminfo:: How to generate a terminfo command -* Invoking grub-set-default:: How to set a default boot entry -* Invoking mbchk:: How to use the Multiboot checker * Obtaining and Building GRUB:: How to obtain and build GRUB * Reporting bugs:: Where you should send a bug report * Future:: Some future plans on GRUB @@ -158,11 +149,6 @@ partition, and a file name (@pxref{Naming convention}) to GRUB, how to install GRUB on your drive (@pxref{Installation}), and how to boot your OSes (@pxref{Booting}), step by step. -Besides the GRUB boot loader itself, there is a @dfn{grub shell} -@command{grub} (@pxref{Invoking the grub shell}) which can be run when -you are in your operating system. It emulates the boot loader and can -be used for installing the boot loader. - @node History @section History of GRUB @@ -458,119 +444,17 @@ have an emergency boot disk ready, so that you can rescue your computer if, by any chance, your hard drive becomes unusable (unbootable). GRUB comes with boot images, which are normally put in the directory -@file{/usr/lib/grub/i386-pc}. If you do not use grub-install, then -you need to copy the files @file{stage1}, @file{stage2}, and -@file{*stage1_5} to the directory @file{/boot/grub}, and run the -@command{grub-set-default} (@pxref{Invoking grub-set-default}) if you -intend to use @samp{default saved} (@pxref{default}) in your -configuration file. Hereafter, the directory where GRUB images are +@file{/usr/lib/grub/i386-pc}. Hereafter, the directory where GRUB images are initially placed (normally @file{/usr/lib/grub/i386-pc}) will be called the @dfn{image directory}, and the directory where the boot loader needs to find them (usually @file{/boot/grub}) will be called the @dfn{boot directory}. @menu -* Creating a GRUB boot floppy:: -* Installing GRUB natively:: * Installing GRUB using grub-install:: -* Making a GRUB bootable CD-ROM:: @end menu -@node Creating a GRUB boot floppy -@section Creating a GRUB boot floppy - -To create a GRUB boot floppy, you need to take the files @file{stage1} -and @file{stage2} from the image directory, and write them to the first -and the second block of the floppy disk, respectively. - -@strong{Caution:} This procedure will destroy any data currently stored -on the floppy. - -On a UNIX-like operating system, that is done with the following -commands: - -@example -@group -# @kbd{cd /usr/lib/grub/i386-pc} -# @kbd{dd if=stage1 of=/dev/fd0 bs=512 count=1} -1+0 records in -1+0 records out -# @kbd{dd if=stage2 of=/dev/fd0 bs=512 seek=1} -153+1 records in -153+1 records out -# -@end group -@end example - -The device file name may be different. Consult the manual for your OS. - - -@node Installing GRUB natively -@section Installing GRUB natively - -@strong{Caution:} Installing GRUB's stage1 in this manner will erase the -normal boot-sector used by an OS. - -GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD -directly, so using it on a boot sector (the first sector of a -partition) should be okay. But generally, it would be a good idea to -back up the first sector of the partition on which you are installing -GRUB's stage1. This isn't as important if you are installing GRUB on -the first sector of a hard disk, since it's easy to reinitialize it -(e.g. by running @samp{FDISK /MBR} from DOS). - -If you decide to install GRUB in the native environment, which is -definitely desirable, you'll need to create a GRUB boot disk, and -reboot your computer with it. Otherwise, see @ref{Installing GRUB using -grub-install}. - -Once started, GRUB will show the command-line interface -(@pxref{Command-line interface}). First, set the GRUB's @dfn{root -device}@footnote{Note that GRUB's root device doesn't necessarily mean -your OS's root partition; if you need to specify a root partition for -your OS, add the argument into the command @command{kernel}.} to the -partition containing the boot directory, like this: - -@example -grub> @kbd{root (hd0,0)} -@end example - -If you are not sure which partition actually holds this directory, use the -command @command{find} (@pxref{find}), like this: - -@example -grub> @kbd{find /boot/grub/stage1} -@end example - -This will search for the file name @file{/boot/grub/stage1} and show the -devices which contain the file. - -Once you've set the root device correctly, run the command -@command{setup} (@pxref{setup}): - -@example -grub> @kbd{setup (hd0)} -@end example - -This command will install the GRUB boot loader on the Master Boot -Record (MBR) of the first drive. If you want to put GRUB into the boot -sector of a partition instead of putting it in the MBR, specify the -partition into which you want to install GRUB: - -@example -grub> @kbd{setup (hd0,0)} -@end example - -If you install GRUB into a partition or a drive other than the first -one, you must chain-load GRUB from another boot loader. Refer to the -manual for the boot loader to know how to chain-load GRUB. - -After using the setup command, you will boot into GRUB without the -GRUB floppy. See the chapter @ref{Booting} to find out how to boot -your operating systems from GRUB. - - @node Installing GRUB using grub-install @section Installing GRUB using grub-install @@ -722,7 +606,6 @@ magic. @menu * General boot methods:: How to boot OSes with GRUB generally * OS-specific notes:: Notes on some operating systems -* Making your system robust:: How to make your system robust @end menu @@ -753,71 +636,9 @@ For the sake of convenience, there is also support for Linux, FreeBSD, NetBSD and OpenBSD. If you want to boot other operating systems, you will have to chain-load them (@pxref{Chain-loading}). -Generally, GRUB can boot any Multiboot-compliant OS in the following -steps: +FIXME: this section is incomplete. @enumerate -@item -Set GRUB's root device to the drive where the OS images are stored with -the command @command{root} (@pxref{root}). - -@item -Load the kernel image with the command @command{kernel} (@pxref{kernel}). - -@item -If you need modules, load them with the command @command{module} -(@pxref{module}) or @command{modulenounzip} (@pxref{modulenounzip}). - -@item -Run the command @command{boot} (@pxref{boot}). -@end enumerate - -Linux, FreeBSD, NetBSD and OpenBSD can be booted in a similar -manner. You load a kernel image with the command @command{kernel} and -then run the command @command{boot}. If the kernel requires some -parameters, just append the parameters to @command{kernel}, after the -file name of the kernel. Also, please refer to @ref{OS-specific notes}, -for information on your OS-specific issues. - - -@node Chain-loading -@subsection Load another boot loader to boot unsupported operating systems - -If you want to boot an unsupported operating system (e.g. Windows 95), -chain-load a boot loader for the operating system. Normally, the boot -loader is embedded in the @dfn{boot sector} of the partition on which -the operating system is installed. - -@enumerate -@item -Set GRUB's root device to the partition by the command -@command{rootnoverify} (@pxref{rootnoverify}): - -@example -grub> @kbd{rootnoverify (hd0,0)} -@end example - -@item -Set the @dfn{active} flag in the partition using the command -@command{makeactive}@footnote{This is not necessary for most of the -modern operating systems.} (@pxref{makeactive}): - -@example -grub> @kbd{makeactive} -@end example - -@item -Load the boot loader with the command @command{chainloader} -(@pxref{chainloader}): - -@example -grub> @kbd{chainloader +1} -@end example - -@samp{+1} indicates that GRUB should read one sector from the start of -the partition. The complete description about this syntax can be found -in @ref{Block list syntax}. - @item Run the command @command{boot} (@pxref{boot}). @end enumerate @@ -835,12 +656,6 @@ Here, we describe some caveats on several operating systems. @menu * GNU/Hurd:: * GNU/Linux:: -* FreeBSD:: -* NetBSD:: -* OpenBSD:: -* DOS/Windows:: -* SCO UnixWare:: -* QNX:: @end menu @@ -851,22 +666,9 @@ Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is nothing special about it. But do not forget that you have to specify a root partition to the kernel. +FIXME: this section is incomplete. + @enumerate -@item -Set GRUB's root device to the same drive as GNU/Hurd's. Probably the -command @code{find /boot/gnumach} or similar can help you -(@pxref{find}). - -@item -Load the kernel and the module, like this: - -@example -@group -grub> @kbd{kernel /boot/gnumach root=hd0s1} -grub> @kbd{module /boot/serverboot} -@end group -@end example - @item Run the command @command{boot} (@pxref{boot}). @end enumerate @@ -878,35 +680,11 @@ Run the command @command{boot} (@pxref{boot}). It is relatively easy to boot GNU/Linux from GRUB, because it somewhat resembles to boot a Multiboot-compliant OS. +FIXME: this section is incomplete. + @enumerate @item -Set GRUB's root device to the same drive as GNU/Linux's. Probably the -command @code{find /vmlinuz} or similar can help you (@pxref{find}). - -@item -Load the kernel: - -@example -grub> @kbd{kernel /vmlinuz root=/dev/hda1} -@end example - -If you need to specify some kernel parameters, just append them to the -command. For example, to set @option{vga} to @samp{ext}, do this: - -@example -grub> @kbd{kernel /vmlinuz root=/dev/hda1 vga=ext} -@end example - -See the documentation in the Linux source tree for complete -information on the available options. - -@item -If you use an initrd, execute the command @command{initrd} -(@pxref{initrd}) after @command{kernel}: - -@example -grub> @kbd{initrd /initrd} -@end example +Set GRUB's root device to the same drive as GNU/Linux's. @item Finally, run the command @command{boot} (@pxref{boot}). @@ -919,617 +697,6 @@ the size, run the command @command{uppermem} @emph{before} loading the kernel. @xref{uppermem}, for more information. -@node FreeBSD -@subsection FreeBSD - -GRUB can load the kernel directly, either in ELF or a.out format. But -this is not recommended, since FreeBSD's bootstrap interface sometimes -changes heavily, so GRUB can't guarantee to pass kernel parameters -correctly. - -Thus, we'd recommend loading the very flexible loader -@file{/boot/loader} instead. See this example: - -@example -@group -grub> @kbd{root (hd0,a)} -grub> @kbd{kernel /boot/loader} -grub> @kbd{boot} -@end group -@end example - - -@node NetBSD -@subsection NetBSD - -GRUB can load NetBSD a.out and ELF directly, follow these steps: - -@enumerate -@item -Set GRUB's root device with @command{root} (@pxref{root}). - -@item -Load the kernel with @command{kernel} (@pxref{kernel}). You should -append the ugly option @option{--type=netbsd}, if you want to load an -ELF kernel, like this: - -@example -grub> @kbd{kernel --type=netbsd /netbsd-elf} -@end example - -@item -Run @command{boot} (@pxref{boot}). -@end enumerate - -For now, however, GRUB doesn't allow you to pass kernel parameters, so -it may be better to chain-load it instead. For more information, please -see @ref{Chain-loading}. - - -@node OpenBSD -@subsection OpenBSD - -The booting instruction is exactly the same as for NetBSD -(@pxref{NetBSD}). - - -@node DOS/Windows -@subsection DOS/Windows - -GRUB cannot boot DOS or Windows directly, so you must chain-load them -(@pxref{Chain-loading}). However, their boot loaders have some critical -deficiencies, so it may not work to just chain-load them. To overcome -the problems, GRUB provides you with two helper functions. - -If you have installed DOS (or Windows) on a non-first hard disk, you -have to use the disk swapping technique, because that OS cannot boot -from any disks but the first one. The workaround used in GRUB is the -command @command{map} (@pxref{map}), like this: - -@example -@group -grub> @kbd{map (hd0) (hd1)} -grub> @kbd{map (hd1) (hd0)} -@end group -@end example - -This performs a @dfn{virtual} swap between your first and second hard -drive. - -@strong{Caution:} This is effective only if DOS (or Windows) uses BIOS -to access the swapped disks. If that OS uses a special driver for the -disks, this probably won't work. - -Another problem arises if you installed more than one set of DOS/Windows -onto one disk, because they could be confused if there are more than one -primary partitions for DOS/Windows. Certainly you should avoid doing -this, but there is a solution if you do want to do so. Use the partition -hiding/unhiding technique. - -If GRUB @dfn{hide}s a DOS (or Windows) partition (@pxref{hide}), DOS (or -Windows) will ignore the partition. If GRUB @dfn{unhide}s a DOS (or -Windows) partition (@pxref{unhide}), DOS (or Windows) will detect the -partition. Thus, if you have installed DOS (or Windows) on the first -and the second partition of the first hard disk, and you want to boot -the copy on the first partition, do the following: - -@example -@group -grub> @kbd{unhide (hd0,0)} -grub> @kbd{hide (hd0,1)} -grub> @kbd{rootnoverify (hd0,0)} -grub> @kbd{chainloader +1} -grub> @kbd{makeactive} -grub> @kbd{boot} -@end group -@end example - - -@node SCO UnixWare -@subsection SCO UnixWare - -It is known that the signature in the boot loader for SCO UnixWare is -wrong, so you will have to specify the option @option{--force} to -@command{chainloader} (@pxref{chainloader}), like this: - -@example -@group -grub> @kbd{rootnoverify (hd1,0)} -grub> @kbd{chainloader --force +1} -grub> @kbd{makeactive} -grub> @kbd{boot} -@end group -@end example - - -@node QNX -@subsection QNX - -QNX seems to use a bigger boot loader, so you need to boot it up, like -this: - -@example -@group -grub> @kbd{rootnoverify (hd1,1)} -grub> @kbd{chainloader +4} -grub> @kbd{boot} -@end group -@end example - - -@node Making your system robust -@section How to make your system robust - -When you test a new kernel or a new OS, it is important to make sure -that your computer can boot even if the new system is unbootable. This -is crucial especially if you maintain servers or remote systems. To -accomplish this goal, you need to set up two things: - -@enumerate -@item -You must maintain a system which is always bootable. For instance, if -you test a new kernel, you need to keep a working kernel in a -different place. And, it would sometimes be very nice to even have a -complete copy of a working system in a different partition or disk. - -@item -You must direct GRUB to boot a working system when the new system -fails. This is possible with the @dfn{fallback} system in GRUB. -@end enumerate - -The former requirement is very specific to each OS, so this -documentation does not cover that topic. It is better to consult some -backup tools. - -So let's see the GRUB part. There are two possibilities: one of them -is quite simple but not very robust, and the other is a bit complex to -set up but probably the best solution to make sure that your system -can start as long as GRUB itself is bootable. - -@menu -* Booting once-only:: -* Booting fallback systems:: -@end menu - - -@node Booting once-only -@subsection Booting once-only - -You can teach GRUB to boot an entry only at next boot time. Suppose -that your have an old kernel @file{old_kernel} and a new kernel -@file{new_kernel}. You know that @file{old_kernel} can boot -your system correctly, and you want to test @file{new_kernel}. - -To ensure that your system will go back to the old kernel even if the -new kernel fails (e.g. it panics), you can specify that GRUB should -try the new kernel only once and boot the old kernel after that. - -First, modify your configuration file. Here is an example: - -@example -@group -default saved # This is important!!! -timeout 10 - -title the old kernel -root (hd0,0) -kernel /old_kernel -savedefault - -title the new kernel -root (hd0,0) -kernel /new_kernel -savedefault 0 # This is important!!! -@end group -@end example - -Note that this configuration file uses @samp{default saved} -(@pxref{default}) at the head and @samp{savedefault 0} -(@pxref{savedefault}) in the entry for the new kernel. This means -that GRUB boots a saved entry by default, and booting the entry for the -new kernel saves @samp{0} as the saved entry. - -With this configuration file, after all, GRUB always tries to boot the -old kernel after it booted the new one, because @samp{0} is the entry -of @code{the old kernel}. - -The next step is to tell GRUB to boot the new kernel at next boot -time. For this, execute @command{grub-set-default} (@pxref{Invoking -grub-set-default}): - -@example -# @kbd{grub-set-default 1} -@end example - -This command sets the saved entry to @samp{1}, that is, to the new -kernel. - -This method is useful, but still not very robust, because GRUB stops -booting, if there is any error in the boot entry, such that the new -kernel has an invalid executable format. Thus, it it even better to -use the @dfn{fallback} mechanism of GRUB. Look at next subsection for -this feature. - - -@node Booting fallback systems -@subsection Booting fallback systems - -GRUB supports a fallback mechanism of booting one or more other -entries if a default boot entry fails. You can specify multiple -fallback entries if you wish. - -Suppose that you have three systems, @samp{A}, @samp{B} and -@samp{C}. @samp{A} is a system which you want to boot by -default. @samp{B} is a backup system which is supposed to boot -safely. @samp{C} is another backup system which is used in case where -@samp{B} is broken. - -Then you may want GRUB to boot the first system which is bootable -among @samp{A}, @samp{B} and @samp{C}. A configuration file can be -written in this way: - -@example -@group -default saved # This is important!!! -timeout 10 -fallback 1 2 # This is important!!! - -title A -root (hd0,0) -kernel /kernel -savedefault fallback # This is important!!! - -title B -root (hd1,0) -kernel /kernel -savedefault fallback # This is important!!! - -title C -root (hd2,0) -kernel /kernel -savedefault -@end group -@end example - -Note that @samp{default saved} (@pxref{default}), @samp{fallback 1 2} -and @samp{savedefault fallback} are used. GRUB will boot a saved entry -by default and save a fallback entry as next boot entry with this -configuration. - -When GRUB tries to boot @samp{A}, GRUB saves @samp{1} as next boot -entry, because the command @command{fallback} specifies that @samp{1} -is the first fallback entry. The entry @samp{1} is @samp{B}, so GRUB -will try to boot @samp{B} at next boot time. - -Likewise, when GRUB tries to boot @samp{B}, GRUB saves @samp{2} as -next boot entry, because @command{fallback} specifies @samp{2} as next -fallback entry. This makes sure that GRUB will boot @samp{C} after -booting @samp{B}. - -It is noteworthy that GRUB uses fallback entries both when GRUB -itself fails in booting an entry and when @samp{A} or @samp{B} fails -in starting up your system. So this solution ensures that your system -is started even if GRUB cannot find your kernel or if your kernel -panics. - -However, you need to run @command{grub-set-default} (@pxref{Invoking -grub-set-default}) when @samp{A} starts correctly or you fix @samp{A} -after it crashes, since GRUB always sets next boot entry to a fallback -entry. You should run this command in a startup script such as -@file{rc.local} to boot @samp{A} by default: - -@example -# @kbd{grub-set-default 0} -@end example - -where @samp{0} is the number of the boot entry for the system -@samp{A}. - -If you want to see what is current default entry, you can look at the -file @file{/boot/grub/default} (or @file{/grub/default} in -some systems). Because this file is plain-text, you can just -@command{cat} this file. But it is strongly recommended @strong{not to -modify this file directly}, because GRUB may fail in saving a default -entry in this file, if you change this file in an unintended -manner. Therefore, you should use @command{grub-set-default} when you -need to change the default entry. - - -@node Configuration -@chapter Configuration - -You've probably noticed that you need to type several commands to boot your -OS. There's a solution to that - GRUB provides a menu interface -(@pxref{Menu interface}) from which you can select an item (using arrow -keys) that will do everything to boot an OS. - -To enable the menu, you need a configuration file, -@file{menu.lst} under the boot directory. We'll analyze an example -file. - -The file first contains some general settings, the menu interface -related options. You can put these commands (@pxref{Menu-specific -commands}) before any of the items (starting with @command{title} -(@pxref{title})). - -@example -@group -# -# Sample boot menu configuration file -# -@end group -@end example - -As you may have guessed, these lines are comments. Lines starting with a -hash character (@samp{#}), and blank lines, are ignored by GRUB. - -@example -@group -# By default, boot the first entry. -default 0 -@end group -@end example - -The first entry (here, counting starts with number zero, not one!) will -be the default choice. - -@example -@group -# Boot automatically after 30 secs. -timeout 30 -@end group -@end example - -As the comment says, GRUB will boot automatically in 30 seconds, unless -interrupted with a keypress. - -@example -@group -# Fallback to the second entry. -fallback 1 -@end group -@end example - -If, for any reason, the default entry doesn't work, fall back to the -second one (this is rarely used, for obvious reasons). - -Note that the complete descriptions of these commands, which are menu -interface specific, can be found in @ref{Menu-specific -commands}. Other descriptions can be found in @ref{Commands}. - -Now, on to the actual OS definitions. You will see that each entry -begins with a special command, @command{title} (@pxref{title}), and the -action is described after it. Note that there is no command -@command{boot} (@pxref{boot}) at the end of each item. That is because -GRUB automatically executes @command{boot} if it loads other commands -successfully. - -The argument for the command @command{title} is used to display a short -title/description of the entry in the menu. Since @command{title} -displays the argument as is, you can write basically anything there. - -@example -@group -# For booting GNU/Hurd -title GNU/Hurd -root (hd0,0) -kernel /boot/gnumach.gz root=hd0s1 -module /boot/serverboot.gz -@end group -@end example - -This boots GNU/Hurd from the first hard disk. - -@example -@group -# For booting GNU/Linux -title GNU/Linux -kernel (hd1,0)/vmlinuz root=/dev/hdb1 -@end group -@end example - -This boots GNU/Linux, but from the second hard disk. - -@example -@group -# For booting Mach (getting kernel from floppy) -title Utah Mach4 multiboot -root (hd0,2) -pause Insert the diskette now^G!! -kernel (fd0)/boot/kernel root=hd0s3 -module (fd0)/boot/bootstrap -@end group -@end example - -This boots Mach with a kernel on a floppy, but the root filesystem at -hd0s3. It also contains a @command{pause} line (@pxref{pause}), which -will cause GRUB to display a prompt and delay, before actually executing -the rest of the commands and booting. - -@example -@group -# For booting FreeBSD -title FreeBSD -root (hd0,2,a) -kernel /boot/loader -@end group -@end example - -This item will boot FreeBSD kernel loaded from the @samp{a} partition of -the third @sc{pc} slice of the first hard disk. - -@example -@group -# For booting OS/2 -title OS/2 -root (hd0,1) -makeactive -# chainload OS/2 bootloader from the first sector -chainloader +1 -# This is similar to "chainload", but loads a specific file -#chainloader /boot/chain.os2 -@end group -@end example - -This will boot OS/2, using a chain-loader (@pxref{Chain-loading}). - -@example -@group -# For booting Windows NT or Windows95 -title Windows NT / Windows 95 boot menu -root (hd0,0) -makeactive -chainloader +1 -# For loading DOS if Windows NT is installed -# chainload /bootsect.dos -@end group -@end example - -The same as the above, but for Windows. - -@example -@group -# For installing GRUB into the hard disk -title Install GRUB into the hard disk -root (hd0,0) -setup (hd0) -@end group -@end example - -This will just (re)install GRUB onto the hard disk. - -@example -# Change the colors. -title Change the colors -color light-green/brown blink-red/blue -@end example - -In the last entry, the command @command{color} is used (@pxref{color}), -to change the menu colors (try it!). This command is somewhat special, -because it can be used both in the command-line and in the menu. GRUB -has several such commands, see @ref{General commands}. - -We hope that you now understand how to use the basic features of -GRUB. To learn more about GRUB, see the following chapters. - - -@node Network -@chapter Downloading OS images from a network - -Although GRUB is a disk-based boot loader, it does provide network -support. To use the network support, you need to enable at least one -network driver in the GRUB build process. For more information please -see @file{netboot/README.netboot} in the source distribution. - -@menu -* General usage of network support:: -* Diskless:: -@end menu - - -@node General usage of network support -@section How to set up your network - -GRUB requires a file server and optionally a server that will assign an -IP address to the machine on which GRUB is running. For the former, only -TFTP is supported at the moment. The latter is either BOOTP, DHCP or a -RARP server@footnote{RARP is not advised, since it cannot serve much -information}. It is not necessary to run both the servers on one -computer. How to configure these servers is beyond the scope of this -document, so please refer to the manuals specific to those -protocols/servers. - -If you decided to use a server to assign an IP address, set up the -server and run @command{bootp} (@pxref{bootp}), @command{dhcp} -(@pxref{dhcp}) or @command{rarp} (@pxref{rarp}) for BOOTP, DHCP or RARP, -respectively. Each command will show an assigned IP address, a netmask, -an IP address for your TFTP server and a gateway. If any of the -addresses is wrong or it causes an error, probably the configuration of -your servers isn't set up properly. - -Otherwise, run @command{ifconfig}, like this: - -@example -grub> @kbd{ifconfig --address=192.168.110.23 --server=192.168.110.14} -@end example - -You can also use @command{ifconfig} in conjuction with @command{bootp}, -@command{dhcp} or @command{rarp} (e.g. to reassign the server address -manually). @xref{ifconfig}, for more details. - -Finally, download your OS images from your network. The network can be -accessed using the network drive @samp{(nd)}. Everything else is very -similar to the normal instructions (@pxref{Booting}). - -Here is an example: - -@example -@group -grub> @kbd{bootp} -Probing... [NE*000] -NE2000 base ... -Address: 192.168.110.23 Netmask: 255.255.255.0 -Server: 192.168.110.14 Gateway: 192.168.110.1 - -grub> @kbd{root (nd)} -grub> @kbd{kernel /tftproot/gnumach.gz root=sd0s1} -grub> @kbd{module /tftproot/serverboot.gz} -grub> @kbd{boot} -@end group -@end example - - -@node Diskless -@section Booting from a network - -It is sometimes very useful to boot from a network, especially when you -use a machine which has no local disk. In this case, you need to obtain -a kind of Net Boot @sc{rom}, such as a PXE @sc{rom} or a free software -package like Etherboot. Such a Boot @sc{rom} first boots the machine, -sets up the network card installed into the machine, and downloads a -second stage boot image from the network. Then, the second image will -try to boot an operating system actually from the network. - -GRUB provides two second stage images, @file{nbgrub} and -@file{pxegrub} (@pxref{Images}). These images are the same as the -normal Stage 2, except that they set up a network automatically, and try -to load a configuration file from the network, if specified. The usage -is very simple: If the machine has a PXE @sc{rom}, use -@file{pxegrub}. If the machine has an NBI loader such as Etherboot, use -@file{nbgrub}. There is no difference between them except their -formats. Since the way to load a second stage image you want to use -should be described in the manual on your Net Boot @sc{rom}, please -refer to the manual, for more information. - -However, there is one thing specific to GRUB. Namely, how to specify a -configuration file in a BOOTP/DHCP server. For now, GRUB uses the tag -@samp{150}, to get the name of a configuration file. The following is an -example with a BOOTP configuration: - -@example -@group -.allhost:hd=/tmp:bf=null:\ - :ds=145.71.35.1 145.71.32.1:\ - :sm=255.255.254.0:\ - :gw=145.71.35.1:\ - :sa=145.71.35.5: - -foo:ht=1:ha=63655d0334a7:ip=145.71.35.127:\ - :bf=/nbgrub:\ - :tc=.allhost:\ - :T150="(nd)/tftpboot/menu.lst.foo": -@end group -@end example - -Note that you should specify the drive name @code{(nd)} in the name of -the configuration file. This is because you might change the root drive -before downloading the configuration from the TFTP server when the -preset menu feature is used (@pxref{Preset Menu}). - -See the manual of your BOOTP/DHCP server for more information. The -exact syntax should differ a little from the example. - - @node Serial terminal @chapter Using GRUB via a serial line @@ -1581,214 +748,6 @@ GRUB provides you with an alternative menu interface, because the normal menu requires several fancy features of your terminal. -@node Preset Menu -@chapter Embedding a configuration file into GRUB - -GRUB supports a @dfn{preset menu} which is to be always loaded before -starting. The preset menu feature is useful, for example, when your -computer has no console but a serial cable. In this case, it is -critical to set up the serial terminal as soon as possible, since you -cannot see any message until the serial terminal begins to work. So it -is good to run the commands @command{serial} (@pxref{serial}) and -@command{terminal} (@pxref{terminal}) before anything else at the -start-up time. - -How the preset menu works is slightly complicated: - -@enumerate -@item -GRUB checks if the preset menu feature is used, and loads the preset -menu, if available. This includes running commands and reading boot -entries, like an ordinary configuration file. - -@item -GRUB checks if the configuration file is available. Note that this check -is performed @strong{regardless of the existence of the preset -menu}. The configuration file is loaded even if the preset menu was -loaded. - -@item -If the preset menu includes any boot entries, they are cleared when -the configuration file is loaded. It doesn't matter whether the -configuration file has any entries or no entry. The boot entries in the -preset menu are used only when GRUB fails in loading the configuration -file. -@end enumerate - -To enable the preset menu feature, you must rebuild GRUB specifying a -file to the configure script with the option -@option{--enable-preset-menu}. The file has the same semantics as -normal configuration files (@pxref{Configuration}). - -Another point you should take care is that the diskless support -(@pxref{Diskless}) diverts the preset menu. Diskless images embed a -preset menu to execute the command @command{bootp} (@pxref{bootp}) -automatically, unless you specify your own preset menu to the configure -script. This means that you must put commands to initialize a network in -the preset menu yourself, because diskless images don't set it up -implicitly, when you use the preset menu explicitly. - -Therefore, a typical preset menu used with diskless support would be -like this: - -@example -@group -# Set up the serial terminal, first of all. -serial --unit=0 --speed=19200 -terminal --timeout=0 serial - -# Initialize the network. -dhcp -@end group -@end example - - -@node Security -@chapter Protecting your computer from cracking - -You may be interested in how to prevent ordinary users from doing -whatever they like, if you share your computer with other people. So -this chapter describes how to improve the security of GRUB. - -One thing which could be a security hole is that the user can do too -many things with GRUB, because GRUB allows one to modify its configuration -and run arbitrary commands at run-time. For example, the user can even -read @file{/etc/passwd} in the command-line interface by the command -@command{cat} (@pxref{cat}). So it is necessary to disable all the -interactive operations. - -Thus, GRUB provides a @dfn{password} feature, so that only administrators -can start the interactive operations (i.e. editing menu entries and -entering the command-line interface). To use this feature, you need to -run the command @command{password} in your configuration file -(@pxref{password}), like this: - -@example -password --md5 PASSWORD -@end example - -If this is specified, GRUB disallows any interactive control, until you -press the key @key{p} and enter a correct password. The option -@option{--md5} tells GRUB that @samp{PASSWORD} is in MD5 format. If it -is omitted, GRUB assumes the @samp{PASSWORD} is in clear text. - -You can encrypt your password with the command @command{md5crypt} -(@pxref{md5crypt}). For example, run the grub shell (@pxref{Invoking the -grub shell}), and enter your password: - -@example -@group -grub> md5crypt -Password: ********** -Encrypted: $1$U$JK7xFegdxWH6VuppCUSIb. -@end group -@end example - -Then, cut and paste the encrypted password to your configuration file. - -Also, you can specify an optional argument to @command{password}. See -this example: - -@example -password PASSWORD /boot/grub/menu-admin.lst -@end example - -In this case, GRUB will load @file{/boot/grub/menu-admin.lst} as a -configuration file when you enter the valid password. - -Another thing which may be dangerous is that any user can choose any -menu entry. Usually, this wouldn't be problematic, but you might want to -permit only administrators to run some of your menu entries, such as an -entry for booting an insecure OS like DOS. - -GRUB provides the command @command{lock} (@pxref{lock}). This command -always fails until you enter the valid password, so you can use it, like -this: - -@example -@group -title Boot DOS -lock -rootnoverify (hd0,1) -makeactive -chainload +1 -@end group -@end example - -You should insert @command{lock} right after @command{title}, because -any user can execute commands in an entry until GRUB encounters -@command{lock}. - -You can also use the command @command{password} instead of -@command{lock}. In this case the boot process will ask for the password -and stop if it was entered incorrectly. Since the @command{password} -takes its own @var{PASSWORD} argument this is useful if you want -different passwords for different entries. - - -@node Images -@chapter GRUB image files - -GRUB consists of several images: two essential stages, optional stages -called @dfn{Stage 1.5}, one image for bootable CD-ROM, and two network -boot images. Here is a short overview of them. @xref{Internals}, for -more details. - -@table @file -@item stage1 -This is an essential image used for booting up GRUB. Usually, this is -embedded in an MBR or the boot sector of a partition. Because a PC boot -sector is 512 bytes, the size of this image is exactly 512 bytes. - -All @file{stage1} must do is to load Stage 2 or Stage 1.5 from a local -disk. Because of the size restriction, @file{stage1} encodes the -location of Stage 2 (or Stage 1.5) in a block list format, so it never -understand any filesystem structure. - -@item stage2 -This is the core image of GRUB. It does everything but booting up -itself. Usually, this is put in a filesystem, but that is not required. - -@item e2fs_stage1_5 -@itemx fat_stage1_5 -@itemx ffs_stage1_5 -@itemx jfs_stage1_5 -@itemx minix_stage1_5 -@itemx reiserfs_stage1_5 -@itemx vstafs_stage1_5 -@itemx xfs_stage1_5 - -These are called @dfn{Stage 1.5}, because they serve as a bridge -between @file{stage1} and @file{stage2}, that is to say, Stage 1.5 is -loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between -@file{stage1} and @file{*_stage1_5} is that the former doesn't -understand any filesystem while the latter understands one filesystem -(e.g. @file{e2fs_stage1_5} understands ext2fs). So you can move the -Stage 2 image to another location safely, even after GRUB has been -installed. - -While Stage 2 cannot generally be embedded in a fixed area as the size -is so large, Stage 1.5 can be installed into the area right after an MBR, -or the boot loader area of a ReiserFS or a FFS. - -@item stage2_eltorito -This is a boot image for CD-ROMs using the @dfn{no emulation mode} in -El Torito specification. This is identical to Stage 2, except that -this boots up without Stage 1 and sets up a special drive @samp{(cd)}. - -@item nbgrub -This is a network boot image for the Network Image Proposal used by some -network boot loaders, such as Etherboot. This is mostly the same as -Stage 2, but it also sets up a network and loads a configuration file -from the network. - -@item pxegrub -This is another network boot image for the Preboot Execution Environment -used by several Netboot ROMs. This is identical to @file{nbgrub}, except -for the format. -@end table - - @node Filesystem @chapter Filesystem syntax and semantics @@ -1907,8 +866,6 @@ the command-line interface. @menu * Command-line interface:: The flexible command-line interface * Menu interface:: The simple menu interface -* Menu entry editor:: Editing a menu entry -* Hidden menu interface:: The hidden menu interface @end menu @@ -2029,19 +986,6 @@ does not support @dfn{undo}, you can do almost the same thing by just returning to the main menu. -@node Hidden menu interface -@section The hidden menu interface - -When your terminal is dumb or you request GRUB to hide the menu -interface explicitly with the command @command{hiddenmenu} -(@pxref{hiddenmenu}), GRUB doesn't show the menu interface (@pxref{Menu -interface}) and automatically boots the default entry, unless -interrupted by pressing @key{ESC}. - -When you interrupt the timeout and your terminal is dumb, GRUB falls -back to the command-line interface (@pxref{Command-line interface}). - - @node Commands @chapter The list of available commands @@ -2094,64 +1038,12 @@ start, where they are ignored. These commands can only be used in the menu: @menu -* default:: Set the default entry -* fallback:: Set the fallback entry -* hiddenmenu:: Hide the menu interface -* timeout:: Set the timeout -* title:: Start a menu entry +* menuentry:: Start a menu entry @end menu -@node default -@subsection default - -@deffn Command default num -Set the default entry to the entry number @var{num}. Numbering starts -from 0, and the entry number 0 is the default if the command is not -used. - -You can specify @samp{saved} instead of a number. In this case, the -default entry is the entry saved with the command -@command{savedefault}. @xref{savedefault}, for more information. -@end deffn - - -@node fallback -@subsection fallback - -@deffn Command fallback num... -Go into unattended boot mode: if the default boot entry has any errors, -instead of waiting for the user to do something, immediately start -over using the @var{num} entry (same numbering as the @code{default} -command (@pxref{default})). This obviously won't help if the machine was -rebooted by a kernel that GRUB loaded. You can specify multiple -fallback entry numbers. -@end deffn - - -@node hiddenmenu -@subsection hiddenmenu - -@deffn Command hiddenmenu -Don't display the menu. If the command is used, no menu will be -displayed on the control terminal, and the default entry will be -booted after the timeout expired. The user can still request the -menu to be displayed by pressing @key{ESC} before the timeout -expires. See also @ref{Hidden menu interface}. -@end deffn - - -@node timeout -@subsection timeout - -@deffn Command timeout sec -Set a timeout, in @var{sec} seconds, before automatically booting the -default entry (normally the first entry defined). -@end deffn - - -@node title -@subsection title +@node menuentry +@subsection menuentry @deffn Command title name @dots{} Start a new boot entry, and set its name to the contents of the rest of @@ -2165,242 +1057,11 @@ the line, starting with the first non-space character. Commands usable anywhere in the menu and in the command-line. @menu -* bootp:: Initialize a network device via BOOTP -* color:: Color the menu interface -* device:: Specify a file as a drive -* dhcp:: Initialize a network device via DHCP -* hide:: Hide a partition -* ifconfig:: Configure a network device manually -* pager:: Change the state of the internal pager -* partnew:: Make a primary partition -* parttype:: Change the type of a partition -* password:: Set a password for the menu interface -* rarp:: Initialize a network device via RARP * serial:: Set up a serial device -* setkey:: Configure the key map -* terminal:: Choose a terminal * terminfo:: Define escape sequences for a terminal -* tftpserver:: Specify a TFTP server -* unhide:: Unhide a partition @end menu -@node bootp -@subsection bootp - -@deffn Command bootp [@option{--with-configfile}] -Initialize a network device via the @dfn{BOOTP} protocol. This command -is only available if GRUB is compiled with netboot support. See also -@ref{Network}. - -If you specify @option{--with-configfile} to this command, GRUB will -fetch and load a configuration file specified by your BOOTP server -with the vendor tag @samp{150}. -@end deffn - - -@node color -@subsection color - -@deffn Command color normal [highlight] -Change the menu colors. The color @var{normal} is used for most -lines in the menu (@pxref{Menu interface}), and the color -@var{highlight} is used to highlight the line where the cursor -points. If you omit @var{highlight}, then the inverted color of -@var{normal} is used for the highlighted line. The format of a color is -@code{@var{foreground}/@var{background}}. @var{foreground} and -@var{background} are symbolic color names. A symbolic color name must be -one of these: - -@itemize @bullet -@item -black - -@item -blue - -@item -green - -@item -cyan - -@item -red - -@item -magenta - -@item -brown - -@item -light-gray - -@strong{These below can be specified only for the foreground.} - -@item -dark-gray - -@item -light-blue - -@item -light-green - -@item -light-cyan - -@item -light-red - -@item -light-magenta - -@item -yellow - -@item -white -@end itemize - -But only the first eight names can be used for @var{background}. You can -prefix @code{blink-} to @var{foreground} if you want a blinking -foreground color. - -This command can be used in the configuration file and on the command -line, so you may write something like this in your configuration file: - -@example -@group -# Set default colors. -color light-gray/blue black/light-gray - -# Change the colors. -title OS-BS like -color magenta/blue black/magenta -@end group -@end example -@end deffn - - -@node device -@subsection device - -@deffn Command device drive file -In the grub shell, specify the file @var{file} as the actual drive for a -@sc{bios} drive @var{drive}. You can use this command to create a disk -image, and/or to fix the drives guessed by GRUB when GRUB fails to -determine them correctly, like this: - -@example -@group -grub> @kbd{device (fd0) /floppy-image} -grub> @kbd{device (hd0) /dev/sd0} -@end group -@end example - -This command can be used only in the grub shell (@pxref{Invoking the -grub shell}). -@end deffn - - -@node dhcp -@subsection dhcp - -@deffn Command dhcp [--with-configfile] -Initialize a network device via the @dfn{DHCP} protocol. Currently, -this command is just an alias for @command{bootp}, since the two -protocols are very similar. This command is only available if GRUB is -compiled with netboot support. See also @ref{Network}. - -If you specify @option{--with-configfile} to this command, GRUB will -fetch and load a configuration file specified by your DHCP server -with the vendor tag @samp{150}. -@end deffn - - -@node hide -@subsection hide - -@deffn Command hide partition -Hide the partition @var{partition} by setting the @dfn{hidden} bit in -its partition type code. This is useful only when booting DOS or Windows -and multiple primary FAT partitions exist in one disk. See also -@ref{DOS/Windows}. -@end deffn - - -@node ifconfig -@subsection ifconfig - -@deffn Command ifconfig [@option{--server=server}] [@option{--gateway=gateway}] [@option{--mask=mask}] [@option{--address=address}] -Configure the IP address, the netmask, the gateway, and the server -address of a network device manually. The values must be in dotted -decimal format, like @samp{192.168.11.178}. The order of the options is -not important. This command shows current network configuration, if no -option is specified. See also @ref{Network}. -@end deffn - - -@node pager -@subsection pager - -@deffn Command pager [flag] -Toggle or set the state of the internal pager. If @var{flag} is -@samp{on}, the internal pager is enabled. If @var{flag} is @samp{off}, -it is disabled. If no argument is given, the state is toggled. -@end deffn - - -@node partnew -@subsection partnew - -@deffn Command partnew part type from len -Create a new primary partition. @var{part} is a partition specification -in GRUB syntax (@pxref{Naming convention}); @var{type} is the partition -type and must be a number in the range @code{0-0xff}; @var{from} is -the starting address and @var{len} is the length, both in sector units. -@end deffn - - -@node parttype -@subsection parttype - -@deffn Command parttype part type -Change the type of an existing partition. @var{part} is a partition -specification in GRUB syntax (@pxref{Naming convention}); @var{type} -is the new partition type and must be a number in the range 0-0xff. -@end deffn - - -@node password -@subsection password - -@deffn Command password [@option{--md5}] passwd [new-config-file] -If used in the first section of a menu file, disable all interactive -editing control (menu entry editor and command-line) and entries -protected by the command @command{lock}. If the password @var{passwd} is -entered, it loads the @var{new-config-file} as a new config file and -restarts the GRUB Stage 2, if @var{new-config-file} is -specified. Otherwise, GRUB will just unlock the privileged instructions. -You can also use this command in the script section, in which case it -will ask for the password, before continuing. The option -@option{--md5} tells GRUB that @var{passwd} is encrypted with -@command{md5crypt} (@pxref{md5crypt}). -@end deffn - - -@node rarp -@subsection rarp - -@deffn Command rarp -Initialize a network device via the @dfn{RARP} protocol. This command -is only available if GRUB is compiled with netboot support. See also -@ref{Network}. -@end deffn - - @node serial @subsection serial @@ -2426,169 +1087,6 @@ support. See also @ref{Serial terminal}. @end deffn -@node setkey -@subsection setkey - -@deffn Command setkey [to_key from_key] -Change the keyboard map. The key @var{from_key} is mapped to the key -@var{to_key}. If no argument is specified, reset key mappings. Note that -this command @emph{does not} exchange the keys. If you want to exchange -the keys, run this command again with the arguments exchanged, like this: - -@example -grub> @kbd{setkey capslock control} -grub> @kbd{setkey control capslock} -@end example - -A key must be an alphabet letter, a digit, or one of these symbols: -@samp{escape}, @samp{exclam}, @samp{at}, @samp{numbersign}, -@samp{dollar}, @samp{percent}, @samp{caret}, @samp{ampersand}, -@samp{asterisk}, @samp{parenleft}, @samp{parenright}, @samp{minus}, -@samp{underscore}, @samp{equal}, @samp{plus}, @samp{backspace}, -@samp{tab}, @samp{bracketleft}, @samp{braceleft}, @samp{bracketright}, -@samp{braceright}, @samp{enter}, @samp{control}, @samp{semicolon}, -@samp{colon}, @samp{quote}, @samp{doublequote}, @samp{backquote}, -@samp{tilde}, @samp{shift}, @samp{backslash}, @samp{bar}, @samp{comma}, -@samp{less}, @samp{period}, @samp{greater}, @samp{slash}, -@samp{question}, @samp{alt}, @samp{space}, @samp{capslock}, @samp{FX} -(@samp{X} is a digit), and @samp{delete}. This table describes to which -character each of the symbols corresponds: - -@table @samp -@item exclam -@samp{!} - -@item at -@samp{@@} - -@item numbersign -@samp{#} - -@item dollar -@samp{$} - -@item percent -@samp{%} - -@item caret -@samp{^} - -@item ampersand -@samp{&} - -@item asterisk -@samp{*} - -@item parenleft -@samp{(} - -@item parenright -@samp{)} - -@item minus -@samp{-} - -@item underscore -@samp{_} - -@item equal -@samp{=} - -@item plus -@samp{+} - -@item bracketleft -@samp{[} - -@item braceleft -@samp{@{} - -@item bracketright -@samp{]} - -@item braceright -@samp{@}} - -@item semicolon -@samp{;} - -@item colon -@samp{:} - -@item quote -@samp{'} - -@item doublequote -@samp{"} - -@item backquote -@samp{`} - -@item tilde -@samp{~} - -@item backslash -@samp{\} - -@item bar -@samp{|} - -@item comma -@samp{,} - -@item less -@samp{<} - -@item period -@samp{.} - -@item greater -@samp{>} - -@item slash -@samp{/} - -@item question -@samp{?} - -@item space -@samp{ } -@end table -@end deffn - - -@node terminal -@subsection terminal - -@deffn Command terminal [@option{--dumb}] [@option{--no-echo}] [@option{--no-edit}] [@option{--timeout=secs}] [@option{--lines=lines}] [@option{--silent}] [@option{console}] [@option{serial}] [@option{hercules}] -Select a terminal for user interaction. The terminal is assumed to be -VT100-compatible unless @option{--dumb} is specified. If both -@option{console} and @option{serial} are specified, then GRUB will use -the one where a key is entered first or the first when the timeout -expires. If neither are specified, the current setting is -reported. This command is only available if GRUB is compiled with serial -support. See also @ref{Serial terminal}. - -This may not make sense for most users, but GRUB supports Hercules -console as well. Hercules console is usable like the ordinary console, -and the usage is quite similar to that for serial terminals: specify -@option{hercules} as the argument. - -The option @option{--lines} defines the number of lines in your -terminal, and it is used for the internal pager function. If you don't -specify this option, the number is assumed as 24. - -The option @option{--silent} suppresses the message to prompt you to -hit any key. This might be useful if your system has no terminal -device. - -The option @option{--no-echo} has GRUB not to echo back input -characters. This implies the option @option{--no-edit}. - -The option @option{--no-edit} disables the BASH-like editing feature. -@end deffn - - @node terminfo @subsection terminfo @@ -2604,31 +1102,6 @@ If no option is specified, the current settings are printed. @end deffn -@node tftpserver -@subsection tftpserver - -@deffn Command tftpserver ipaddr -@strong{Caution:} This command exists only for backward -compatibility. Use @command{ifconfig} (@pxref{ifconfig}) instead. - -Override a TFTP server address returned by a BOOTP/DHCP/RARP server. The -argument @var{ipaddr} must be in dotted decimal format, like -@samp{192.168.0.15}. This command is only available if GRUB is compiled -with netboot support. See also @ref{Network}. -@end deffn - - -@node unhide -@subsection unhide - -@deffn Command unhide partition -Unhide the partition @var{partition} by clearing the @dfn{hidden} bit in -its partition type code. This is useful only when booting DOS or Windows -and multiple primary partitions exist on one disk. See also -@ref{DOS/Windows}. -@end deffn - - @node Command-line and menu entry commands @section The list of command-line and menu entry commands @@ -2637,56 +1110,17 @@ you forget a command, you can run the command @command{help} (@pxref{help}). @menu -* blocklist:: Get the block list notation of a file * boot:: Start up your operating system * cat:: Show the contents of a file * chainloader:: Chain-load another boot loader * cmp:: Compare two files * configfile:: Load a configuration file -* debug:: Toggle the debug flag -* displayapm:: Display APM information -* displaymem:: Display memory configuration -* embed:: Embed Stage 1.5 -* find:: Find a file -* fstest:: Test a filesystem -* geometry:: Manipulate the geometry of a drive * halt:: Shut down your computer * help:: Show help messages -* impsprobe:: Probe SMP -* initrd:: Load an initrd -* install:: Install GRUB -* ioprobe:: Probe I/O ports used for a drive -* kernel:: Load a kernel -* lock:: Lock a menu entry -* makeactive:: Make a partition active -* map:: Map a drive to another -* md5crypt:: Encrypt a password in MD5 format -* module:: Load a module -* modulenounzip:: Load a module without decompression -* pause:: Wait for a key press -* quit:: Exit from the grub shell * reboot:: Reboot your computer -* read:: Read data from memory -* root:: Set GRUB's root device -* rootnoverify:: Set GRUB's root device without mounting -* savedefault:: Save current entry as the default entry -* setup:: Set up GRUB's installation automatically -* testload:: Load a file for testing a filesystem -* testvbe:: Test VESA BIOS EXTENSION -* uppermem:: Set the upper memory size -* vbeprobe:: Probe VESA BIOS EXTENSION @end menu -@node blocklist -@subsection blocklist - -@deffn Command blocklist file -Print the block list notation of the file @var{file}. @xref{Block list -syntax}. -@end deffn - - @node boot @subsection boot @@ -2753,93 +1187,6 @@ Load @var{file} as a configuration file. @end deffn -@node debug -@subsection debug - -@deffn Command debug -Toggle debug mode (by default it is off). When debug mode is on, some -extra messages are printed to show disk activity. This global debug flag -is mainly useful for GRUB developers when testing new code. -@end deffn - - -@node displayapm -@subsection displayapm - -@deffn Command displayapm -Display APM BIOS information. -@end deffn - - -@node displaymem -@subsection displaymem - -@deffn Command displaymem -Display what GRUB thinks the system address space map of the machine is, -including all regions of physical @sc{ram} installed. GRUB's -@dfn{upper/lower memory} display uses the standard BIOS interface for -the available memory in the first megabyte, or @dfn{lower memory}, and a -synthesized number from various BIOS interfaces of the memory starting -at 1MB and going up to the first chipset hole for @dfn{upper memory} -(the standard PC @dfn{upper memory} interface is limited to reporting a -maximum of 64MB). -@end deffn - - -@node embed -@subsection embed - -@deffn Command embed stage1_5 device -Embed the Stage 1.5 @var{stage1_5} in the sectors after the MBR if -@var{device} is a drive, or in the @dfn{boot loader} area if @var{device} -is a FFS partition or a ReiserFS partition.@footnote{The latter feature -has not been implemented yet.} Print the number of sectors which -@var{stage1_5} occupies, if successful. - -Usually, you don't need to run this command directly. @xref{setup}. -@end deffn - - -@node find -@subsection find - -@deffn Command find filename -Search for the file name @var{filename} in all mountable partitions -and print the list of the devices which contain the file. The file -name @var{filename} should be an absolute file name like -@code{/boot/grub/stage1}. -@end deffn - - -@node fstest -@subsection fstest - -@deffn Command fstest -Toggle filesystem test mode. -Filesystem test mode, when turned on, prints out data corresponding to -all the device reads and what values are being sent to the low-level -routines. The format is @samp{<@var{partition-offset-sector}, -@var{byte-offset}, @var{byte-length}>} for high-level reads inside a -partition, and @samp{[@var{disk-offset-sector}]} for low-level sector -requests from the disk. -Filesystem test mode is turned off by any use of the @command{install} -(@pxref{install}) or @command{testload} (@pxref{testload}) commands. -@end deffn - - -@node geometry -@subsection geometry - -@deffn Command geometry drive [cylinder head sector [total_sector]] -Print the information for the drive @var{drive}. In the grub shell, you -can set the geometry of the drive arbitrarily. The number of -cylinders, the number of heads, the number of sectors and the number of -total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR, -respectively. If you omit TOTAL_SECTOR, then it will be calculated -based on the C/H/S values automatically. -@end deffn - - @node halt @subsection halt @@ -2865,220 +1212,6 @@ about each of the commands which match those @var{patterns}. @end deffn -@node impsprobe -@subsection impsprobe - -@deffn Command impsprobe -Probe the Intel Multiprocessor Specification 1.1 or 1.4 configuration -table and boot the various CPUs which are found into a tight loop. This -command can be used only in the Stage 2, but not in the grub shell. -@end deffn - - -@node initrd -@subsection initrd - -@deffn Command initrd file @dots{} -Load an initial ramdisk for a Linux format boot image and set the -appropriate parameters in the Linux setup area in memory. See also -@ref{GNU/Linux}. -@end deffn - - -@node install -@subsection install - -@deffn Command install [@option{--force-lba}] [@option{--stage2=os_stage2_file}] stage1_file [@option{d}] dest_dev stage2_file [addr] [@option{p}] [config_file] [real_config_file] -This command is fairly complex, and you should not use this command -unless you are familiar with GRUB. Use @command{setup} (@pxref{setup}) -instead. - -In short, it will perform a full install presuming the Stage 2 or Stage -1.5@footnote{They're loaded the same way, so we will refer to the Stage -1.5 as a Stage 2 from now on.} is in its final install location. - -In slightly more detail, it will load @var{stage1_file}, validate that -it is a GRUB Stage 1 of the right version number, install in it a -blocklist for loading @var{stage2_file} as a Stage 2. If the option -@option{d} is present, the Stage 1 will always look for the actual -disk @var{stage2_file} was installed on, rather than using the booting -drive. The Stage 2 will be loaded at address @var{addr}, which must be -@samp{0x8000} for a true Stage 2, and @samp{0x2000} for a Stage 1.5. If -@var{addr} is not present, GRUB will determine the address -automatically. It then writes the completed Stage 1 to the first block -of the device @var{dest_dev}. If the options @option{p} or -@var{config_file} are present, then it reads the first block of stage2, -modifies it with the values of the partition @var{stage2_file} was found -on (for @option{p}) or places the string @var{config_file} into the area -telling the stage2 where to look for a configuration file at boot -time. Likewise, if @var{real_config_file} is present and -@var{stage2_file} is a Stage 1.5, then the Stage 2 @var{config_file} is -patched with the configuration file name @var{real_config_file}. This -command preserves the DOS BPB (and for hard disks, the partition table) -of the sector the Stage 1 is to be installed into. - -@strong{Caution:} Several buggy BIOSes don't pass a booting drive -properly when booting from a hard disk drive. Therefore, you will -unfortunately have to specify the option @option{d}, whether your -Stage2 resides at the booting drive or not, if you have such a -BIOS. We know these are defective in this way: - -@table @asis -@item -Fujitsu LifeBook 400 BIOS version 31J0103A - -@item -HP Vectra XU 6/200 BIOS version GG.06.11 -@end table - -@strong{Caution2:} A number of BIOSes don't return a correct LBA support -bitmap even if they do have the support. So GRUB provides a solution to -ignore the wrong bitmap, that is, the option @option{--force-lba}. Don't -use this option if you know that your BIOS doesn't have LBA support. - -@strong{Caution3:} You must specify the option @option{--stage2} in the -grub shell, if you cannot unmount the filesystem where your stage2 file -resides. The argument should be the file name in your operating system. -@end deffn - - -@node ioprobe -@subsection ioprobe - -@deffn Command ioprobe drive -Probe I/O ports used for the drive @var{drive}. This command will list -the I/O ports on the screen. For technical information, -@xref{Internals}. -@end deffn - - -@node kernel -@subsection kernel - -@deffn Command kernel [@option{--type=type}] [@option{--no-mem-option}] file @dots{} -Attempt to load the primary boot image (Multiboot a.out or @sc{elf}, -Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from -@var{file}. The rest of the line is passed verbatim as the @dfn{kernel -command-line}. Any modules must be reloaded after using this command. - -This command also accepts the option @option{--type} so that you can -specify the kernel type of @var{file} explicitly. The argument -@var{type} must be one of these: @samp{netbsd}, @samp{freebsd}, -@samp{openbsd}, @samp{linux}, @samp{biglinux}, and -@samp{multiboot}. However, you need to specify it only if you want to -load a NetBSD @sc{elf} kernel, because GRUB can automatically determine -a kernel type in the other cases, quite safely. - -The option @option{--no-mem-option} is effective only for Linux. If the -option is specified, GRUB doesn't pass the option @option{mem=} to the -kernel. This option is implied for Linux kernels 2.4.18 and newer. -@end deffn - - -@node lock -@subsection lock - -@deffn Command lock -Prevent normal users from executing arbitrary menu entries. You must use -the command @command{password} if you really want this command to be -useful (@pxref{password}). - -This command is used in a menu, as shown in this example: - -@example -@group -title This entry is too dangerous to be executed by normal users -lock -root (hd0,a) -kernel /no-security-os -@end group -@end example - -See also @ref{Security}. -@end deffn - - -@node makeactive -@subsection makeactive - -@deffn Command makeactive -Set the active partition on the root disk to GRUB's root device. -This command is limited to @emph{primary} PC partitions on a hard disk. -@end deffn - - -@node map -@subsection map - -@deffn Command map to_drive from_drive -Map the drive @var{from_drive} to the drive @var{to_drive}. This is -necessary when you chain-load some operating systems, such as DOS, if -such an OS resides at a non-first drive. Here is an example: - -@example -@group -grub> @kbd{map (hd0) (hd1)} -grub> @kbd{map (hd1) (hd0)} -@end group -@end example - -The example exchanges the order between the first hard disk and the -second hard disk. See also @ref{DOS/Windows}. -@end deffn - - -@node md5crypt -@subsection md5crypt - -@deffn Command md5crypt -Prompt to enter a password, and encrypt it in MD5 format. The encrypted -password can be used with the command @command{password} -(@pxref{password}). See also @ref{Security}. -@end deffn - - -@node module -@subsection module - -@deffn Command module file @dots{} -Load a boot module @var{file} for a Multiboot format boot image (no -interpretation of the file contents are made, so the user of this -command must know what the kernel in question expects). The rest of the -line is passed as the @dfn{module command-line}, like the -@command{kernel} command. You must load a Multiboot kernel image before -loading any module. See also @ref{modulenounzip}. -@end deffn - - -@node modulenounzip -@subsection modulenounzip - -@deffn Command modulenounzip file @dots{} -The same as @command{module} (@pxref{module}), except that automatic -decompression is disabled. -@end deffn - - -@node pause -@subsection pause - -@deffn Command pause message @dots{} -Print the @var{message}, then wait until a key is pressed. Note that -placing @key{^G} (ASCII code 7) in the message will cause the speaker to -emit the standard beep sound, which is useful when prompting the user to -change floppies. -@end deffn - - -@node quit -@subsection quit - -@deffn Command quit -Exit from the grub shell @command{grub} (@pxref{Invoking the grub -shell}). This command can be used only in the grub shell. -@end deffn - - @node reboot @subsection reboot @@ -3087,551 +1220,6 @@ Reboot the computer. @end deffn -@node read -@subsection read - -@deffn Command read addr -Read a 32-bit value from memory at address @var{addr} and display it in -hex format. -@end deffn - - -@node root -@subsection root - -@deffn Command root device [hdbias] -Set the current @dfn{root device} to the device @var{device}, then -attempt to mount it to get the partition size (for passing the partition -descriptor in @code{ES:ESI}, used by some chain-loaded boot loaders), the -BSD drive-type (for booting BSD kernels using their native boot format), -and correctly determine the PC partition where a BSD sub-partition is -located. The optional @var{hdbias} parameter is a number to tell a BSD -kernel how many BIOS drive numbers are on controllers before the current -one. For example, if there is an IDE disk and a SCSI disk, and your -FreeBSD root partition is on the SCSI disk, then use a @samp{1} for -@var{hdbias}. - -See also @ref{rootnoverify}. -@end deffn - - -@node rootnoverify -@subsection rootnoverify - -@deffn Command rootnoverify device [hdbias] -Similar to @command{root} (@pxref{root}), but don't attempt to mount the -partition. This is useful for when an OS is outside of the area of the -disk that GRUB can read, but setting the correct root device is still -desired. Note that the items mentioned in @command{root} above which -derived from attempting the mount will @emph{not} work correctly. -@end deffn - - -@node savedefault -@subsection savedefault - -@deffn Command savedefault num -Save the current menu entry or @var{num} if specified as a default -entry. Here is an example: - -@example -@group -default saved -timeout 10 - -title GNU/Linux -root (hd0,0) -kernel /boot/vmlinuz root=/dev/sda1 vga=ext -initrd /boot/initrd -savedefault - -title FreeBSD -root (hd0,a) -kernel /boot/loader -savedefault -@end group -@end example - -With this configuration, GRUB will choose the entry booted previously as -the default entry. - -You can specify @samp{fallback} instead of a number. Then, next -fallback entry is saved. Next fallback entry is chosen from fallback -entries. Normally, this will be the first entry in fallback ones. - -See also @ref{default} and @ref{Invoking grub-set-default}. -@end deffn - - -@node setup -@subsection setup - -@deffn Command setup [@option{--force-lba}] [@option{--stage2=os_stage2_file}] [@option{--prefix=dir}] install_device [image_device] -Set up the installation of GRUB automatically. This command uses the -more flexible command @command{install} (@pxref{install}) in the backend -and installs GRUB into the device @var{install_device}. If -@var{image_device} is specified, then find the GRUB images -(@pxref{Images}) in the device @var{image_device}, otherwise use the -current @dfn{root device}, which can be set by the command -@command{root}. If @var{install_device} is a hard disk, then embed a -Stage 1.5 in the disk if possible. - -The option @option{--prefix} specifies the directory under which GRUB -images are put. If it is not specified, GRUB automatically searches them -in @file{/boot/grub} and @file{/grub}. - -The options @option{--force-lba} and @option{--stage2} are just passed -to @command{install} if specified. @xref{install}, for more -information. -@end deffn - - -@node testload -@subsection testload - -@deffn Command testload file -Read the entire contents of @var{file} in several different ways and -compare them, to test the filesystem code. The output is somewhat -cryptic, but if no errors are reported and the final @samp{i=@var{X}, -filepos=@var{Y}} reading has @var{X} and @var{Y} equal, then it is -definitely consistent, and very likely works correctly subject to a -consistent offset error. If this test succeeds, then a good next step is -to try loading a kernel. -@end deffn - - -@node testvbe -@subsection testvbe - -@deffn Command testvbe mode -Test the VESA BIOS EXTENSION mode @var{mode}. This command will switch -your video card to the graphics mode, and show an endless animation. Hit -any key to return. See also @ref{vbeprobe}. -@end deffn - - -@node uppermem -@subsection uppermem - -@deffn Command uppermem kbytes -Force GRUB to assume that only @var{kbytes} kilobytes of upper memory -are installed. Any system address range maps are discarded. - -@strong{Caution:} This should be used with great caution, and should -only be necessary on some old machines. GRUB's BIOS probe can pick up -all @sc{ram} on all new machines the author has ever heard of. It can -also be used for debugging purposes to lie to an OS. -@end deffn - - -@node vbeprobe -@subsection vbeprobe - -@deffn Command vbeprobe [mode] -Probe VESA BIOS EXTENSION information. If the mode @var{mode} is -specified, show only the information about @var{mode}. Otherwise, this -command lists up available VBE modes on the screen. See also -@ref{testvbe}. -@end deffn - - -@node Troubleshooting -@chapter Error messages reported by GRUB - -This chapter describes error messages reported by GRUB when you -encounter trouble. @xref{Invoking the grub shell}, if your problem is -specific to the grub shell. - -@menu -* Stage1 errors:: Errors reported by the Stage 1 -* Stage1.5 errors:: Errors reported by the Stage 1.5 -* Stage2 errors:: Errors reported by the Stage 2 -@end menu - - -@node Stage1 errors -@section Errors reported by the Stage 1 - -The general way that the Stage 1 handles errors is to print an error -string and then halt. Pressing @kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will -reboot. - -The following is a comprehensive list of error messages for the Stage 1: - -@table @asis -@item Hard Disk Error -The stage2 or stage1.5 is being read from a hard disk, and the attempt -to determine the size and geometry of the hard disk failed. - -@item Floppy Error -The stage2 or stage1.5 is being read from a floppy disk, and the attempt -to determine the size and geometry of the floppy disk failed. It's listed -as a separate error since the probe sequence is different than for hard -disks. - -@item Read Error -A disk read error happened while trying to read the stage2 or stage1.5. - -@item Geom Error -The location of the stage2 or stage1.5 is not in the portion of the disk -supported directly by the BIOS read calls. This could occur because the -BIOS translated geometry has been changed by the user or the disk is -moved to another machine or controller after installation, or GRUB was -not installed using itself (if it was, the Stage 2 version of this error -would have been seen during that process and it would not have completed -the install). -@end table - - -@node Stage1.5 errors -@section Errors reported by the Stage 1.5 - -The general way that the Stage 1.5 handles errors is to print an error -number in the form @code{Error @var{num}} and then halt. Pressing -@kbd{@key{CTRL}-@key{ALT}-@key{DEL}} will reboot. - -The error numbers correspond to the errors reported by Stage -2. @xref{Stage2 errors}. - - -@node Stage2 errors -@section Errors reported by the Stage 2 - -The general way that the Stage 2 handles errors is to abort the -operation in question, print an error string, then (if possible) either -continue based on the fact that an error occurred or wait for the user to -deal with the error. - -The following is a comprehensive list of error messages for the Stage 2 -(error numbers for the Stage 1.5 are listed before the colon in each -description): - -@table @asis -@item 1 : Filename must be either an absolute filename or blocklist -This error is returned if a file name is requested which doesn't fit the -syntax/rules listed in the @ref{Filesystem}. - -@item 2 : Bad file or directory type -This error is returned if a file requested is not a regular file, but -something like a symbolic link, directory, or FIFO. - -@item 3 : Bad or corrupt data while decompressing file -This error is returned if the run-length decompression code gets an -internal error. This is usually from a corrupt file. - -@item 4 : Bad or incompatible header in compressed file -This error is returned if the file header for a supposedly compressed -file is bad. - -@item 5 : Partition table invalid or corrupt -This error is returned if the sanity checks on the integrity of the -partition table fail. This is a bad sign. - -@item 6 : Mismatched or corrupt version of stage1/stage2 -This error is returned if the install command points to incompatible -or corrupt versions of the stage1 or stage2. It can't detect corruption -in general, but this is a sanity check on the version numbers, which -should be correct. - -@item 7 : Loading below 1MB is not supported -This error is returned if the lowest address in a kernel is below the -1MB boundary. The Linux zImage format is a special case and can be -handled since it has a fixed loading address and maximum size. - -@item 8 : Kernel must be loaded before booting -This error is returned if GRUB is told to execute the boot sequence -without having a kernel to start. - -@item 9 : Unknown boot failure -This error is returned if the boot attempt did not succeed for reasons -which are unknown. - -@item 10 : Unsupported Multiboot features requested -This error is returned when the Multiboot features word in the Multiboot -header requires a feature that is not recognized. The point of this is -that the kernel requires special handling which GRUB is probably -unable to provide. - -@item 11 : Unrecognized device string -This error is returned if a device string was expected, and the string -encountered didn't fit the syntax/rules listed in the @ref{Filesystem}. - -@item 12 : Invalid device requested -This error is returned if a device string is recognizable but does not -fall under the other device errors. - -@item 13 : Invalid or unsupported executable format -This error is returned if the kernel image being loaded is not -recognized as Multiboot or one of the supported native formats (Linux -zImage or bzImage, FreeBSD, or NetBSD). - -@item 14 : Filesystem compatibility error, cannot read whole file -Some of the filesystem reading code in GRUB has limits on the length of -the files it can read. This error is returned when the user runs into -such a limit. - -@item 15 : File not found -This error is returned if the specified file name cannot be found, but -everything else (like the disk/partition info) is OK. - -@item 16 : Inconsistent filesystem structure -This error is returned by the filesystem code to denote an internal -error caused by the sanity checks of the filesystem structure on disk -not matching what it expects. This is usually caused by a corrupt -filesystem or bugs in the code handling it in GRUB. - -@item 17 : Cannot mount selected partition -This error is returned if the partition requested exists, but the -filesystem type cannot be recognized by GRUB. - -@item 18 : Selected cylinder exceeds maximum supported by BIOS -This error is returned when a read is attempted at a linear block -address beyond the end of the BIOS translated area. This generally -happens if your disk is larger than the BIOS can handle (512MB for -(E)IDE disks on older machines or larger than 8GB in general). - -@item 19 : Linux kernel must be loaded before initrd -This error is returned if the initrd command is used before loading a -Linux kernel. - -@item 20 : Multiboot kernel must be loaded before modules -This error is returned if the module load command is used before loading -a Multiboot kernel. It only makes sense in this case anyway, as GRUB has -no idea how to communicate the presence of such modules to a -non-Multiboot-aware kernel. - -@item 21 : Selected disk does not exist -This error is returned if the device part of a device- or full file name -refers to a disk or BIOS device that is not present or not recognized by -the BIOS in the system. - -@item 22 : No such partition -This error is returned if a partition is requested in the device part of -a device- or full file name which isn't on the selected disk. - -@item 23 : Error while parsing number -This error is returned if GRUB was expecting to read a number and -encountered bad data. - -@item 24 : Attempt to access block outside partition -This error is returned if a linear block address is outside of the disk -partition. This generally happens because of a corrupt filesystem on the -disk or a bug in the code handling it in GRUB (it's a great debugging -tool). - -@item 25 : Disk read error -This error is returned if there is a disk read error when trying to -probe or read data from a particular disk. - -@item 26 : Too many symbolic links -This error is returned if the link count is beyond the maximum -(currently 5), possibly the symbolic links are looped. - -@item 27 : Unrecognized command -This error is returned if an unrecognized command is entered on the -command-line or in a boot sequence section of a configuration file and -that entry is selected. - -@item 28 : Selected item cannot fit into memory -This error is returned if a kernel, module, or raw file load command is -either trying to load its data such that it won't fit into memory or it -is simply too big. - -@item 29 : Disk write error -This error is returned if there is a disk write error when trying to -write to a particular disk. This would generally only occur during an -install of set active partition command. - -@item 30 : Invalid argument -This error is returned if an argument specified to a command is invalid. - -@item 31 : File is not sector aligned -This error may occur only when you access a ReiserFS partition by -block-lists (e.g. the command @command{install}). In this case, you -should mount the partition with the @samp{-o notail} option. - -@item 32 : Must be authenticated -This error is returned if you try to run a locked entry. You should -enter a correct password before running such an entry. - -@item 33 : Serial device not configured -This error is returned if you try to change your terminal to a serial -one before initializing any serial device. - -@item 34 : No spare sectors on the disk -This error is returned if a disk doesn't have enough spare space. This -happens when you try to embed Stage 1.5 into the unused sectors after -the MBR, but the first partition starts right after the MBR or they are -used by EZ-BIOS. -@end table - - -@node Invoking the grub shell -@chapter Invoking the grub shell - -This chapter documents the grub shell @command{grub}. Note that the grub -shell is an emulator; it doesn't run under the native environment, so it -sometimes does something wrong. Therefore, you shouldn't trust it too -much. If there is anything wrong with it, don't hesitate to try the -native GRUB environment, especially when it guesses a wrong map between -BIOS drives and OS devices. - -@menu -* Basic usage:: How to use the grub shell -* Installation under UNIX:: How to install GRUB via @command{grub} -* Device map:: The map between BIOS drives and OS devices -@end menu - - -@node Basic usage -@section Introduction into the grub shell - -You can use the command @command{grub} for installing GRUB under your -operating systems and for a testbed when you add a new feature into GRUB -or when fixing a bug. @command{grub} is almost the same as the Stage 2, -and, in fact, it shares the source code with the Stage 2 and you can use -the same commands (@pxref{Commands}) in @command{grub}. It is emulated by -replacing BIOS calls with UNIX system calls and libc functions. - -The command @command{grub} accepts the following options: - -@table @option -@item --help -Print a summary of the command-line options and exit. - -@item --version -Print the version number of GRUB and exit. - -@item --verbose -Print some verbose messages for debugging purpose. - -@item --device-map=@var{file} -Use the device map file @var{file}. The format is described in -@ref{Device map}. - -@item --no-floppy -Do not probe any floppy drive. This option has no effect if the option -@option{--device-map} is specified (@pxref{Device map}). - -@item --probe-second-floppy -Probe the second floppy drive. If this option is not specified, the grub -shell does not probe it, as that sometimes takes a long time. If you -specify the device map file (@pxref{Device map}), the grub shell just -ignores this option. - -@item --config-file=@var{file} -Read the configuration file @var{file} instead of -@file{/boot/grub/menu.lst}. The format is the same as the normal GRUB -syntax. See @ref{Filesystem}, for more information. - -@item --boot-drive=@var{drive} -Set the stage2 @var{boot_drive} to @var{drive}. This argument should be -an integer (decimal, octal or hexadecimal). - -@item --install-partition=@var{par} -Set the stage2 @var{install_partition} to @var{par}. This argument -should be an integer (decimal, octal or hexadecimal). - -@item --no-config-file -Do not use the configuration file even if it can be read. - -@item --no-curses -Do not use the screen handling interface by the curses even if it is -available. - -@item --batch -This option has the same meaning as @samp{--no-config-file --no-curses}. - -@item --read-only -Disable writing to any disk. - -@item --hold -Wait until a debugger will attach. This option is useful when you want -to debug the startup code. -@end table - - -@node Installation under UNIX -@section How to install GRUB via @command{grub} - -The installation procedure is the same as under the @dfn{native} Stage -2. @xref{Installation}, for more information. The command -@command{grub}-specific information is described here. - -What you should be careful about is @dfn{buffer cache}. @command{grub} -makes use of raw devices instead of filesystems that your operating -systems serve, so there exists a potential problem that some cache -inconsistency may corrupt your filesystems. What we recommend is: - -@itemize @bullet -@item -If you can unmount drives to which GRUB may write any amount of data, -unmount them before running @command{grub}. - -@item -If a drive cannot be unmounted but can be mounted with the read-only -flag, mount it in read-only mode. That should be secure. - -@item -If a drive must be mounted with the read-write flag, make sure that no -activity is being done on it while the command @command{grub} is -running. - -@item -Reboot your operating system as soon as possible. This is probably not -required if you follow the rules above, but reboot is the most secure -way. -@end itemize - -In addition, enter the command @command{quit} when you finish the -installation. That is @emph{very important} because @command{quit} makes -the buffer cache consistent. Do not push @key{C-c}. - -If you want to install GRUB non-interactively, specify @samp{--batch} -option in the command-line. This is a simple example: - -@example -@group -#!/bin/sh - -# Use /usr/sbin/grub if you are on an older system. -/sbin/grub --batch </dev/null 2>/dev/null -root (hd0,0) -setup (hd0) -quit -EOT -@end group -@end example - - -@node Device map -@section The map between BIOS drives and OS devices - -When you specify the option @option{--device-map} (@pxref{Basic usage}), -the grub shell creates the @dfn{device map file} automatically unless it -already exists. The file name @file{/boot/grub/device.map} is preferred. - -If the device map file exists, the grub shell reads it to map BIOS -drives to OS devices. This file consists of lines like this: - -@example -@var{device} @var{file} -@end example - -@var{device} is a drive specified in the GRUB syntax (@pxref{Device -syntax}), and @var{file} is an OS file, which is normally a device -file. - -The reason why the grub shell gives you the device map file is that it -cannot guess the map between BIOS drives and OS devices correctly in -some environments. For example, if you exchange the boot sequence -between IDE and SCSI in your BIOS, it gets the order wrong. - -Thus, edit the file if the grub shell makes a mistake. You can put any -comments in the file if needed, as the grub shell assumes that a line is -just a comment if the first character is @samp{#}. - - @node Invoking grub-install @chapter Invoking grub-install @@ -3655,11 +1243,6 @@ Print a summary of the command-line options and exit. @item --version Print the version number of GRUB and exit. -@item --force-lba -Force GRUB to use LBA mode even for a buggy BIOS. Use this option only -if your BIOS doesn't work properly in LBA mode even though it supports -LBA mode. - @item --root-directory=@var{dir} Install GRUB images under the directory @var{dir} instead of the root directory. This option is useful when you want to install GRUB into a @@ -3671,14 +1254,6 @@ you have a separate @dfn{boot} partition which is mounted on @kbd{grub-install --root-directory=/boot hd0} @end example -@item --grub-shell=@var{file} -Use @var{file} as the grub shell. You can append arbitrary options to -@var{file} after the file name, like this: - -@example -@kbd{grub-install --grub-shell="grub --read-only" /dev/fd0} -@end example - @item --recheck Recheck the device map, even if @file{/boot/grub/device.map} already exists. You should use this option whenever you add/remove a disk @@ -3686,137 +1261,6 @@ into/from your computer. @end table -@node Invoking grub-md5-crypt -@chapter Invoking grub-md5-crypt - -The program @command{grub-md5-crypt} encrypts a password in MD5 format. -This is just a frontend of the grub shell (@pxref{Invoking the grub -shell}). Passwords encrypted by this program can be used with the -command @command{password} (@pxref{password}). - -@command{grub-md5-crypt} accepts the following options: - -@table @option -@item --help -Print a summary of the command-line options and exit. - -@item --version -Print the version information and exit. - -@item --grub-shell=@var{file} -Use @var{file} as the grub shell. -@end table - - -@node Invoking grub-terminfo -@chapter Invoking grub-terminfo - -The program @command{grub-terminfo} generates a terminfo command from -a terminfo name (@pxref{terminfo}). The result can be used in the -configuration file, to define escape sequences. Because GRUB assumes -that your terminal is vt100-compatible by default, this would be -useful only if your terminal is uncommon (such as vt52). - -@command{grub-terminfo} accepts the following options: - -@table @option -@item --help -Print a summary of the command-line options and exit. - -@item --version -Print the version information and exit. -@end table - -You must specify one argument to this command. For example: - -@example -@kbd{grub-terminfo vt52} -@end example - - -@node Invoking grub-set-default -@chapter Invoking grub-set-default - -The program @command{grub-set-default} sets the default boot entry for -GRUB. This automatically creates a file named @file{default} under -your GRUB directory (i.e. @file{/boot/grub}), if it is not -present. This file is used to determine the default boot entry when -GRUB boots up your system when you use @samp{default saved} in your -configuration file (@pxref{default}), and to save next default boot -entry when you use @samp{savedefault} in a boot entry -(@pxref{savedefault}). - -@command{grub-set-default} accepts the following options: - -@table @option -@item --help -Print a summary of the command-line options and exit. - -@item --version -Print the version information and exit. - -@item --root-directory=@var{dir} -Use the directory @var{dir} instead of the root directory -(i.e. @file{/}) to define the location of the default file. This -is useful when you mount a disk which is used for another system. -@end table - -You must specify a single argument to @command{grub-set-default}. This -argument is normally the number of a default boot entry. For example, -if you have this configuration file: - -@example -@group -default saved -timeout 10 - -title GNU/Hurd -root (hd0,0) -... - -title GNU/Linux -root (hd0,1) -... -@end group -@end example - -and if you want to set the next default boot entry to GNU/Linux, you -may execute this command: - -@example -@kbd{grub-set-default 1} -@end example - -Because the entry for GNU/Linux is @samp{1}. Note that entries are -counted from zero. So, if you want to specify GNU/Hurd here, then you -should specify @samp{0}. - -This feature is very useful if you want to test a new kernel or to -make your system quite robust. @xref{Making your system robust}, for -more hints about how to set up a robust system. - - -@node Invoking mbchk -@chapter Invoking mbchk - -The program @command{mbchk} checks for the format of a Multiboot -kernel. We recommend using this program before booting your own kernel -by GRUB. - -@command{mbchk} accepts the following options: - -@table @option -@item --help -Print a summary of the command-line options and exit. - -@item --version -Print the version number of GRUB and exit. - -@item --quiet -Suppress all normal output. -@end table - - @node Obtaining and Building GRUB @appendix How to obtain and build GRUB From 29a6b9e8fadf353862ea4a579e5753fa2ddfc0b3 Mon Sep 17 00:00:00 2001 From: proski Date: Sat, 8 Aug 2009 04:28:12 +0000 Subject: [PATCH 15/45] 2009-08-08 Pavel Roskin * util/grub-mkconfig.in: Define datarootdir, datadir may depend on it. Add missing space before closing bracket. Fix misleading formatting. --- ChangeLog | 6 ++++++ util/grub-mkconfig.in | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a47abd4a3..1c8a14664 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-08 Pavel Roskin + + * util/grub-mkconfig.in: Define datarootdir, datadir may depend + on it. Add missing space before closing bracket. Fix + misleading formatting. + 2009-08-07 Robert Millan * docs/grub.texi: Major overhaul. Remove all sections that are diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 4ddb7beae..7756b492a 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -24,6 +24,7 @@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ package_version=@PACKAGE_VERSION@ +datarootdir=@datarootdir@ datadir=@datadir@ pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"` grub_prefix=`echo /boot/grub | sed ${transform}` @@ -161,17 +162,17 @@ case ${GRUB_TERMINAL_OUTPUT} in else continue fi - if [ "${basename}" = "ascii"] ; then + if [ "${basename}" = "ascii" ] ; then # make sure all our children behave in conformance with ascii.. export LANG=C fi break 2 done done - if [ -z "${GRUB_FONT_PATH}" ] ; then - # fallback to the native terminal for this platform - unset GRUB_TERMINAL_OUTPUT - fi + if [ -z "${GRUB_FONT_PATH}" ] ; then + # fallback to the native terminal for this platform + unset GRUB_TERMINAL_OUTPUT + fi ;; *) # make sure all our children behave in conformance with ascii.. From 2f5cb8278a707c3b047aace9c8c778a4c7c231e7 Mon Sep 17 00:00:00 2001 From: proski Date: Sat, 8 Aug 2009 05:37:49 +0000 Subject: [PATCH 16/45] 2009-08-08 Pavel Roskin * util/grub-mkconfig_lib.in (version_test_numeric): Don't use the "g" modifier in sed when the intention is to strip something once. This fixes comparison of kernels with multiple dashes. --- ChangeLog | 4 ++++ util/grub-mkconfig_lib.in | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c8a14664..3b252ee6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-08-08 Pavel Roskin + * util/grub-mkconfig_lib.in (version_test_numeric): Don't use + the "g" modifier in sed when the intention is to strip something + once. This fixes comparison of kernels with multiple dashes. + * util/grub-mkconfig.in: Define datarootdir, datadir may depend on it. Add missing space before closing bracket. Fix misleading formatting. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 99b3c9c6f..3585a68ef 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -185,16 +185,16 @@ version_test_numeric () version_test_gt () { - local a=`echo $1 | sed -e "s/[^-]*-//g"` - local b=`echo $2 | sed -e "s/[^-]*-//g"` + local a=`echo $1 | sed -e "s/[^-]*-//"` + local b=`echo $2 | sed -e "s/[^-]*-//"` local cmp=gt if [ "x$b" = "x" ] ; then return 0 fi case $a:$b in *.old:*.old) ;; - *.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;; - *:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;; + *.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;; + *:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;; esac version_test_numeric $a $cmp $b return $? From b5f16cc4cf838fa4c1b0b01ab045fdb5eef9df4e Mon Sep 17 00:00:00 2001 From: proski Date: Sat, 8 Aug 2009 05:58:23 +0000 Subject: [PATCH 17/45] 2009-08-08 Pavel Roskin * include/grub/powerpc/libgcc.h: Export __ashrdi3() if available, xfs.mod needs it now. --- ChangeLog | 3 +++ include/grub/powerpc/libgcc.h | 1 + 2 files changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3b252ee6b..202e76b80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-08-08 Pavel Roskin + * include/grub/powerpc/libgcc.h: Export __ashrdi3() if + available, xfs.mod needs it now. + * util/grub-mkconfig_lib.in (version_test_numeric): Don't use the "g" modifier in sed when the intention is to strip something once. This fixes comparison of kernels with multiple dashes. diff --git a/include/grub/powerpc/libgcc.h b/include/grub/powerpc/libgcc.h index bed937767..ea4b073a0 100644 --- a/include/grub/powerpc/libgcc.h +++ b/include/grub/powerpc/libgcc.h @@ -18,6 +18,7 @@ void EXPORT_FUNC (memset) (void) __attribute__ ((weak)); void EXPORT_FUNC (__ashldi3) (void) __attribute__ ((weak)); +void EXPORT_FUNC (__ashrdi3) (void) __attribute__ ((weak)); void EXPORT_FUNC (__lshrdi3) (void) __attribute__ ((weak)); void EXPORT_FUNC (__trampoline_setup) (void) __attribute__ ((weak)); void EXPORT_FUNC (__ucmpdi2) (void) __attribute__ ((weak)); From a78c8d240bbb261b3c93732835e59d54557f470d Mon Sep 17 00:00:00 2001 From: fzielcke Date: Sat, 8 Aug 2009 06:41:54 +0000 Subject: [PATCH 18/45] 2009-08-08 Felix Zielcke * util/grub-mkconfig.in: Allow the user to specify the used font with GRUB_FONT. --- ChangeLog | 5 +++++ util/grub-mkconfig.in | 33 +++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 202e76b80..cd782a218 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-08 Felix Zielcke + + * util/grub-mkconfig.in: Allow the user to specify the used font + with GRUB_FONT. + 2009-08-08 Pavel Roskin * include/grub/powerpc/libgcc.h: Export __ashrdi3() if diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 7756b492a..f20c9de69 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -154,21 +154,30 @@ esac # check for terminals that require fonts case ${GRUB_TERMINAL_OUTPUT} in gfxterm) - for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do - for basename in unicode unifont ascii; do - path="${dir}/${basename}.pf2" - if is_path_readable_by_grub ${path} > /dev/null ; then - GRUB_FONT_PATH=${path} + if [ -n "$GRUB_FONT" ] ; then + if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then + GRUB_FONT_PATH=${GRUB_FONT} else - continue + echo "No such font or not readable by grub: ${GRUB_FONT}" >&2 + exit 1 fi - if [ "${basename}" = "ascii" ] ; then - # make sure all our children behave in conformance with ascii.. - export LANG=C - fi - break 2 + else + for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do + for basename in unicode unifont ascii; do + path="${dir}/${basename}.pf2" + if is_path_readable_by_grub ${path} > /dev/null ; then + GRUB_FONT_PATH=${path} + else + continue + fi + if [ "${basename}" = "ascii" ] ; then + # make sure all our children behave in conformance with ascii.. + export LANG=C + fi + break 2 + done done - done + fi if [ -z "${GRUB_FONT_PATH}" ] ; then # fallback to the native terminal for this platform unset GRUB_TERMINAL_OUTPUT From 1ebbe064d1ed74dabf28fa4e1db92d939608a9e7 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Sat, 8 Aug 2009 17:59:19 +0000 Subject: [PATCH 19/45] 2009-08-08 Felix Zielcke * util/grub.d/00_header.in: Fix a comment. * util/grub.d/10_linux.in: Likewise. * util/grub.d/10_windows.in: Likewise. * util/grub.d/10_hurd.in: Likewise. --- ChangeLog | 7 +++++++ util/grub.d/00_header.in | 2 +- util/grub.d/10_hurd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/10_windows.in | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd782a218..cf9d5db83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-08 Felix Zielcke + + * util/grub.d/00_header.in: Fix a comment. + * util/grub.d/10_linux.in: Likewise. + * util/grub.d/10_windows.in: Likewise. + * util/grub.d/10_hurd.in: Likewise. + 2009-08-08 Felix Zielcke * util/grub-mkconfig.in: Allow the user to specify the used font diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index d8fa4165d..a273213f3 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -1,6 +1,6 @@ #! /bin/sh -e -# update-grub helper script. +# grub-mkconfig helper script. # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index e72198da6..ec78a3532 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -1,6 +1,6 @@ #! /bin/sh -e -# update-grub helper script. +# grub-mkconfig helper script. # Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 4df078e8f..381a0c3d5 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -1,6 +1,6 @@ #! /bin/sh -e -# update-grub helper script. +# grub-mkconfig helper script. # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 8877b15d5..055258e29 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -1,6 +1,6 @@ #! /bin/sh -e -# update-grub helper script. +# grub-mkconfig helper script. # Copyright (C) 2008 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify From d1e1d52774dd005d8f1670283ecd86719db10e05 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 8 Aug 2009 18:53:49 +0000 Subject: [PATCH 20/45] 2009-08-08 Robert Millan * fs/jfs.c: Update copyright year. --- ChangeLog | 4 ++++ fs/jfs.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cf9d5db83..f0b1781f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-08 Robert Millan + + * fs/jfs.c: Update copyright year. + 2009-08-08 Felix Zielcke * util/grub.d/00_header.in: Fix a comment. diff --git a/fs/jfs.c b/fs/jfs.c index b38efed59..51ca91ad0 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -1,7 +1,7 @@ /* jfs.c - JFS. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2004,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 From f5d35e7a4bb92ad1c76c24b10944480b3e44b364 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 8 Aug 2009 19:24:58 +0000 Subject: [PATCH 21/45] 2009-08-08 Robert Millan * util/grub-dumpdevtree: Moved from here ... * util/i386/efi/grub-dumpdevtree: ... to here. (hexify): New function. Converts a string to its hex version. Generate hex versions of "efi" and "device-properties" by calling hexify() on the ASCII strings rather than by hardcoding numbers. --- ChangeLog | 8 ++++++++ util/grub-dumpdevtree | 3 --- util/i386/efi/grub-dumpdevtree | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) delete mode 100644 util/grub-dumpdevtree create mode 100644 util/i386/efi/grub-dumpdevtree diff --git a/ChangeLog b/ChangeLog index f0b1781f6..6ffa0d779 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-08-08 Robert Millan + + * util/grub-dumpdevtree: Moved from here ... + * util/i386/efi/grub-dumpdevtree: ... to here. + (hexify): New function. Converts a string to its hex version. + Generate hex versions of "efi" and "device-properties" by calling + hexify() on the ASCII strings rather than by hardcoding numbers. + 2009-08-08 Robert Millan * fs/jfs.c: Update copyright year. diff --git a/util/grub-dumpdevtree b/util/grub-dumpdevtree deleted file mode 100644 index ca1a6a907..000000000 --- a/util/grub-dumpdevtree +++ /dev/null @@ -1,3 +0,0 @@ -echo "656669{ 6465766963652d70726f70657274696573:" -ioreg -lw0 -p IODeviceTree -n efi -r -x |grep device-properties | sed 's/.*.*//;' -echo ";}" diff --git a/util/i386/efi/grub-dumpdevtree b/util/i386/efi/grub-dumpdevtree new file mode 100644 index 000000000..bc13e3c35 --- /dev/null +++ b/util/i386/efi/grub-dumpdevtree @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +hexify() +{ + echo -n "$@" | od -A n -t x1 - | sed -e 's/ //g' | tr '\n' '\0' +} + +echo "`hexify efi`{ `hexify device-properties`:" +ioreg -lw0 -p IODeviceTree -n efi -r -x |grep device-properties | sed 's/.*.*//;' +echo ";}" From 81623db67750b0e476c2d4809307bfb7839d351a Mon Sep 17 00:00:00 2001 From: robertmh Date: Mon, 10 Aug 2009 15:42:39 +0000 Subject: [PATCH 22/45] 2009-08-10 Robert Millan * include/grub/i386/bsd.h (KERNEL_TYPE_NONE, KERNEL_TYPE_FREEBSD) (KERNEL_TYPE_OPENBSD, KERNEL_TYPE_NETBSD): Convert to ... (bsd_kernel_types): ... this enum. * loader/i386/bsd.c (grub_cmd_freebsd_loadenv, grub_cmd_freebsd_module) (grub_cmd_freebsd_module_elf): Abort with "You need to load the kernel first." when `kernel_type' is set to KERNEL_TYPE_NONE. (grub_bsd_load_aout, grub_bsd_load, grub_cmd_freebsd_loadenv) (grub_cmd_freebsd_module, grub_cmd_freebsd_module_elf) (GRUB_MOD_INIT (bsd)): Fix capitalization in a few error messages. --- ChangeLog | 15 +++++++++++++ include/grub/i386/bsd.h | 13 ++++++----- loader/i386/bsd.c | 48 +++++++++++++++++++++++++---------------- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ffa0d779..675cc6d7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-08-10 Robert Millan + + * include/grub/i386/bsd.h (KERNEL_TYPE_NONE, KERNEL_TYPE_FREEBSD) + (KERNEL_TYPE_OPENBSD, KERNEL_TYPE_NETBSD): Convert to ... + (bsd_kernel_types): ... this enum. + + * loader/i386/bsd.c (grub_cmd_freebsd_loadenv, grub_cmd_freebsd_module) + (grub_cmd_freebsd_module_elf): Abort with "You need to load the + kernel first." when `kernel_type' is set to KERNEL_TYPE_NONE. + + (grub_bsd_load_aout, grub_bsd_load, grub_cmd_freebsd_loadenv) + (grub_cmd_freebsd_module, grub_cmd_freebsd_module_elf) + (GRUB_MOD_INIT (bsd)): Fix capitalization in a few error + messages. + 2009-08-08 Robert Millan * util/grub-dumpdevtree: Moved from here ... diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index 3130697af..117ed5c68 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * 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 @@ -21,10 +21,13 @@ #include -#define KERNEL_TYPE_NONE 0 -#define KERNEL_TYPE_FREEBSD 1 -#define KERNEL_TYPE_OPENBSD 2 -#define KERNEL_TYPE_NETBSD 3 +enum bsd_kernel_types + { + KERNEL_TYPE_NONE, + KERNEL_TYPE_FREEBSD, + KERNEL_TYPE_OPENBSD, + KERNEL_TYPE_NETBSD, + }; #define GRUB_BSD_TEMP_BUFFER 0x68000 diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 468e6d0cf..5badb7932 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -47,7 +47,7 @@ #define MOD_BUF_ALLOC_UNIT 4096 -static int kernel_type; +static int kernel_type = KERNEL_TYPE_NONE; static grub_dl_t my_mod; static grub_addr_t entry, entry_hi, kern_start, kern_end; static grub_uint32_t bootflags; @@ -614,10 +614,10 @@ grub_bsd_load_aout (grub_file_t file) return grub_errno; if (grub_file_read (file, &ah, sizeof (ah)) != sizeof (ah)) - return grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header"); + return grub_error (GRUB_ERR_READ_ERROR, "Cannot read the a.out header"); if (grub_aout_get_type (&ah) != AOUT_TYPE_AOUT32) - return grub_error (GRUB_ERR_BAD_OS, "invalid a.out header"); + return grub_error (GRUB_ERR_BAD_OS, "Invalid a.out header"); entry = ah.aout32.a_entry & 0xFFFFFF; @@ -635,7 +635,7 @@ grub_bsd_load_aout (grub_file_t file) } if (load_addr < 0x100000) - return grub_error (GRUB_ERR_BAD_OS, "load address below 1M"); + return grub_error (GRUB_ERR_BAD_OS, "Load address below 1M"); kern_start = load_addr; kern_end = load_addr + ah.aout32.a_text + ah.aout32.a_data; @@ -738,7 +738,7 @@ grub_bsd_load_elf (grub_elf_t elf) return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); } else - return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); + return grub_error (GRUB_ERR_BAD_OS, "Invalid elf"); } static grub_err_t @@ -753,7 +753,7 @@ grub_bsd_load (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "No kernel specified"); goto fail; } @@ -914,13 +914,17 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)), char *buf = 0, *curr, *next; int len; + if (kernel_type == KERNEL_TYPE_NONE) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "You need to load the kernel first."); + if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only freebsd support environment"); + "Only FreeBSD support environment"); if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "no filename"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "No filename"); goto fail; } @@ -1004,13 +1008,17 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), char **modargv; char *type; + if (kernel_type == KERNEL_TYPE_NONE) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "You need to load the kernel first."); + if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only freebsd support module"); + "Only FreeBSD support module"); if (!is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only elf kernel support module"); + "Only ELF kernel support module"); /* List the current modules if no parameter. */ if (!argc) @@ -1066,13 +1074,17 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), grub_file_t file = 0; grub_err_t err; + if (kernel_type == KERNEL_TYPE_NONE) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "You need to load the kernel first."); + if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only freebsd support module"); + "Only FreeBSD support module"); if (! is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only elf kernel support module"); + "Only ELF kernel support module"); /* List the current modules if no parameter. */ if (! argc) @@ -1108,22 +1120,22 @@ GRUB_MOD_INIT (bsd) { cmd_freebsd = grub_register_command ("freebsd", grub_cmd_freebsd, - 0, "load freebsd kernel"); + 0, "load kernel of FreeBSD"); cmd_openbsd = grub_register_command ("openbsd", grub_cmd_openbsd, - 0, "load openbsd kernel"); + 0, "load kernel of OpenBSD"); cmd_netbsd = grub_register_command ("netbsd", grub_cmd_netbsd, - 0, "load netbsd kernel"); + 0, "load kernel of NetBSD"); cmd_freebsd_loadenv = grub_register_command ("freebsd_loadenv", grub_cmd_freebsd_loadenv, - 0, "load freebsd env"); + 0, "load FreeBSD env"); cmd_freebsd_module = grub_register_command ("freebsd_module", grub_cmd_freebsd_module, - 0, "load freebsd module"); + 0, "load FreeBSD kernel module"); cmd_freebsd_module_elf = grub_register_command ("freebsd_module_elf", grub_cmd_freebsd_module_elf, - 0, "load freebsd ELF module"); + 0, "load FreeBSD kernel module (ELF)"); my_mod = mod; } From 1f9e557e393128d47c69679fd797c034ae000c55 Mon Sep 17 00:00:00 2001 From: proski Date: Thu, 13 Aug 2009 05:34:39 +0000 Subject: [PATCH 23/45] 2009-08-13 Pavel Roskin * boot/i386/pc/boot.S: Remove all code dependent on APPLE_CC. Use local labels starting with "L_" so that Apple assembler knows they are local. --- ChangeLog | 6 +++ boot/i386/pc/boot.S | 110 +++++++++++++------------------------------- 2 files changed, 38 insertions(+), 78 deletions(-) diff --git a/ChangeLog b/ChangeLog index 675cc6d7f..9e84e542a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-13 Pavel Roskin + + * boot/i386/pc/boot.S: Remove all code dependent on APPLE_CC. + Use local labels starting with "L_" so that Apple assembler + knows they are local. + 2009-08-10 Robert Millan * include/grub/i386/bsd.h (KERNEL_TYPE_NONE, KERNEL_TYPE_FREEBSD) diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S index 1fb5f7416..8a8f6c7cf 100644 --- a/boot/i386/pc/boot.S +++ b/boot/i386/pc/boot.S @@ -30,11 +30,7 @@ #define ABS(x) (x-_start+0x7c00) /* Print message string */ -#ifdef APPLE_CC -#define MSG(x) x ## _abs = ABS(x); movw $x ## _abs, %si; call message -#else -#define MSG(x) movw $ABS(x), %si; call message -#endif +#define MSG(x) movw $ABS(x), %si; call L_message .file "boot.S" @@ -56,7 +52,7 @@ start: * parameter block. */ - jmp after_BPB + jmp L_after_BPB nop /* do I care about this ??? */ /* @@ -104,7 +100,7 @@ boot_drive: .byte 0xff /* the disk to load kernel from */ /* 0xff means use the boot drive */ -after_BPB: +L_after_BPB: /* general setup */ cli /* we're not safe here! */ @@ -129,12 +125,7 @@ boot_drive_check: * ljmp to the next instruction because some bogus BIOSes * jump to 07C0:0000 instead of 0000:7C00. */ -#ifdef APPLE_CC - real_start_abs = ABS(real_start) - ljmp $0, $(real_start_abs) -#else ljmp $0, $ABS(real_start) -#endif real_start: @@ -151,12 +142,7 @@ real_start: /* * Check if we have a forced disk reference here */ -#ifdef APPLE_CC - boot_drive_abs = ABS (boot_drive) - movb boot_drive_abs, %al -#else movb ABS(boot_drive), %al -#endif cmpb $0xff, %al je 1f movb %al, %dl @@ -168,16 +154,11 @@ real_start: MSG(notification_string) /* set %si to the disk address packet */ -#ifdef APPLE_CC - disk_address_packet_abs = ABS (disk_address_packet) - movw $disk_address_packet_abs, %si -#else movw $ABS(disk_address_packet), %si -#endif /* do not probe LBA if the drive is a floppy */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl - jz chs_mode + jz L_chs_mode /* check if LBA is supported */ movb $0x41, %ah @@ -192,12 +173,12 @@ real_start: pushw %dx /* use CHS if fails */ - jc chs_mode + jc L_chs_mode cmpw $0xaa55, %bx - jne chs_mode + jne L_chs_mode andw $1, %cx - jz chs_mode + jz L_chs_mode lba_mode: xorw %ax, %ax @@ -214,18 +195,10 @@ lba_mode: movw $0x0010, (%si) /* the absolute address */ -#ifdef APPLE_CC - kernel_sector_abs = ABS (kernel_sector) - movl (kernel_sector_abs), %ebx - movl %ebx, 8(%si) - movl (kernel_sector_abs + 4), %ebx - movl %ebx, 12(%si) -#else movl ABS(kernel_sector), %ebx movl %ebx, 8(%si) movl ABS(kernel_sector + 4), %ebx movl %ebx, 12(%si) -#endif /* the segment of buffer address */ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si) @@ -243,30 +216,30 @@ lba_mode: int $0x13 /* LBA read is not supported, so fallback to CHS. */ - jc chs_mode + jc L_chs_mode movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx - jmp copy_buffer + jmp L_copy_buffer -chs_mode: +L_chs_mode: /* * Determine the hard disk geometry from the BIOS! * We do this first, so that LS-120 IDE floppies work correctly. */ movb $8, %ah int $0x13 - jnc final_init + jnc L_final_init /* * The call failed, so maybe use the floppy probe instead. */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl - jz floppy_probe + jz L_floppy_probe /* Nope, we definitely have a hard disk, and we're screwed. */ - jmp hd_probe_error + jmp L_hd_probe_error -final_init: +L_final_init: /* set the mode to zero */ movzbl %dh, %eax movb %ah, -1(%si) @@ -292,22 +265,13 @@ final_init: setup_sectors: /* load logical sector start (top half) */ -#ifdef APPLE_CC - kernel_sector_abs = ABS (kernel_sector) - movl (kernel_sector_abs + 4), %eax -#else movl ABS(kernel_sector + 4), %eax -#endif orl %eax, %eax - jnz geometry_error + jnz L_geometry_error /* load logical sector start (bottom half) */ -#ifdef APPLE_CC - movl (kernel_sector_abs), %eax -#else movl ABS(kernel_sector), %eax -#endif /* zero %edx */ xorl %edx, %edx @@ -323,7 +287,7 @@ setup_sectors: /* do we need too many cylinders? */ cmpw 8(%si), %ax - jge geometry_error + jge L_geometry_error /* normalize sector start (1-based) */ incb %cl @@ -365,11 +329,11 @@ setup_sectors: movw $0x0201, %ax /* function 2 */ int $0x13 - jc read_error + jc L_read_error movw %es, %bx -copy_buffer: +L_copy_buffer: /* * We need to save %cx and %si because the startup code in * kernel uses them without initializing them. @@ -392,42 +356,37 @@ copy_buffer: popa /* boot kernel */ -#ifdef APPLE_CC - kernel_address_abs = ABS (kernel_address) - jmp *(kernel_address_abs) -#else jmp *(kernel_address) -#endif /* END OF MAIN LOOP */ /* * BIOS Geometry translation error (past the end of the disk geometry!). */ -geometry_error: +L_geometry_error: MSG(geometry_error_string) - jmp general_error + jmp L_general_error /* * Disk probe failure. */ -hd_probe_error: +L_hd_probe_error: MSG(hd_probe_error_string) - jmp general_error + jmp L_general_error /* * Read error on the disk. */ -read_error: +L_read_error: MSG(read_error_string) -general_error: +L_general_error: MSG(general_error_string) /* go here when you need to stop the machine hard after an error condition */ /* tell the BIOS a boot failure, which may result in no effect */ int $0x18 -stop: jmp stop +L_stop: jmp L_stop notification_string: .asciz "GRUB " geometry_error_string: .asciz "Geom" @@ -450,7 +409,7 @@ general_error_string: .asciz " Error\r\n" movw $0x0001, %bx movb $0xe, %ah int $0x10 /* display a byte */ -message: +L_message: lodsb cmpb $0, %al jne 1b /* if not end of string, jmp to display */ @@ -478,19 +437,14 @@ part_start: probe_values: .byte 36, 18, 15, 9, 0 -floppy_probe: +L_floppy_probe: /* * Perform floppy probe. */ -#ifdef APPLE_CC - probe_values_abs = ABS (probe_values) - movw $(probe_values_abs-1), %si -#else movw $ABS(probe_values-1), %si -#endif -probe_loop: +L_probe_loop: /* reset floppy controller INT 13h AH=0 */ xorw %ax, %ax int $0x13 @@ -506,7 +460,7 @@ probe_loop: * Floppy disk probe failure. */ MSG(fd_probe_error_string) - jmp general_error + jmp L_general_error /* "Floppy" */ fd_probe_error_string: .asciz "Floppy" @@ -519,14 +473,14 @@ fd_probe_error_string: .asciz "Floppy" movb $0, %dh int $0x13 - /* if error, jump to "probe_loop" */ - jc probe_loop + /* if error, jump to "L_probe_loop" */ + jc L_probe_loop /* %cl is already the correct value! */ movb $1, %dh movb $79, %ch - jmp final_init + jmp L_final_init . = _start + GRUB_BOOT_MACHINE_PART_END From 9ca628433162d4328a76806156ce35cb05f8971a Mon Sep 17 00:00:00 2001 From: proski Date: Thu, 13 Aug 2009 05:43:14 +0000 Subject: [PATCH 24/45] 2009-08-13 Pavel Roskin * boot/i386/pc/boot.S: Remove ABS macro, it's not required by any modern compilers we support. --- ChangeLog | 3 +++ boot/i386/pc/boot.S | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e84e542a..d07648549 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-08-13 Pavel Roskin + * boot/i386/pc/boot.S: Remove ABS macro, it's not required by + any modern compilers we support. + * boot/i386/pc/boot.S: Remove all code dependent on APPLE_CC. Use local labels starting with "L_" so that Apple assembler knows they are local. diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S index 8a8f6c7cf..77319a71f 100644 --- a/boot/i386/pc/boot.S +++ b/boot/i386/pc/boot.S @@ -24,13 +24,8 @@ * defines for the code go here */ - /* Absolute addresses - This makes the assembler generate the address without support - from the linker. (ELF can't relocate 16-bit addresses!) */ -#define ABS(x) (x-_start+0x7c00) - /* Print message string */ -#define MSG(x) movw $ABS(x), %si; call L_message +#define MSG(x) movw $x, %si; call L_message .file "boot.S" @@ -125,7 +120,7 @@ boot_drive_check: * ljmp to the next instruction because some bogus BIOSes * jump to 07C0:0000 instead of 0000:7C00. */ - ljmp $0, $ABS(real_start) + ljmp $0, $real_start real_start: @@ -142,7 +137,7 @@ real_start: /* * Check if we have a forced disk reference here */ - movb ABS(boot_drive), %al + movb boot_drive, %al cmpb $0xff, %al je 1f movb %al, %dl @@ -154,7 +149,7 @@ real_start: MSG(notification_string) /* set %si to the disk address packet */ - movw $ABS(disk_address_packet), %si + movw $disk_address_packet, %si /* do not probe LBA if the drive is a floppy */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl @@ -195,9 +190,9 @@ lba_mode: movw $0x0010, (%si) /* the absolute address */ - movl ABS(kernel_sector), %ebx + movl kernel_sector, %ebx movl %ebx, 8(%si) - movl ABS(kernel_sector + 4), %ebx + movl kernel_sector + 4, %ebx movl %ebx, 12(%si) /* the segment of buffer address */ @@ -265,13 +260,13 @@ L_final_init: setup_sectors: /* load logical sector start (top half) */ - movl ABS(kernel_sector + 4), %eax + movl kernel_sector + 4, %eax orl %eax, %eax jnz L_geometry_error /* load logical sector start (bottom half) */ - movl ABS(kernel_sector), %eax + movl kernel_sector, %eax /* zero %edx */ xorl %edx, %edx @@ -442,7 +437,7 @@ L_floppy_probe: * Perform floppy probe. */ - movw $ABS(probe_values-1), %si + movw $probe_values - 1, %si L_probe_loop: /* reset floppy controller INT 13h AH=0 */ From be3c9ca7cb874adb88c364836ae4f9cab83c0e6c Mon Sep 17 00:00:00 2001 From: proski Date: Thu, 13 Aug 2009 06:09:39 +0000 Subject: [PATCH 25/45] 2009-08-13 Yves Blusseau * include/grub/symbol.h: Add the LOCAL macro. * boot/i386/pc/boot.S: Use the LOCAL macro for all labels starting with "L_". --- ChangeLog | 6 ++++ boot/i386/pc/boot.S | 66 ++++++++++++++++++++++--------------------- include/grub/symbol.h | 3 ++ 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index d07648549..4aeacf68a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-13 Yves Blusseau + + * include/grub/symbol.h: Add the LOCAL macro. + * boot/i386/pc/boot.S: Use the LOCAL macro for all labels + starting with "L_". + 2009-08-13 Pavel Roskin * boot/i386/pc/boot.S: Remove ABS macro, it's not required by diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S index 77319a71f..865326ee2 100644 --- a/boot/i386/pc/boot.S +++ b/boot/i386/pc/boot.S @@ -17,6 +17,7 @@ * along with GRUB. If not, see . */ +#include #include #include @@ -25,7 +26,7 @@ */ /* Print message string */ -#define MSG(x) movw $x, %si; call L_message +#define MSG(x) movw $x, %si; call LOCAL(message) .file "boot.S" @@ -47,7 +48,7 @@ start: * parameter block. */ - jmp L_after_BPB + jmp LOCAL(after_BPB) nop /* do I care about this ??? */ /* @@ -95,7 +96,7 @@ boot_drive: .byte 0xff /* the disk to load kernel from */ /* 0xff means use the boot drive */ -L_after_BPB: +LOCAL(after_BPB): /* general setup */ cli /* we're not safe here! */ @@ -153,7 +154,7 @@ real_start: /* do not probe LBA if the drive is a floppy */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl - jz L_chs_mode + jz LOCAL(chs_mode) /* check if LBA is supported */ movb $0x41, %ah @@ -168,12 +169,12 @@ real_start: pushw %dx /* use CHS if fails */ - jc L_chs_mode + jc LOCAL(chs_mode) cmpw $0xaa55, %bx - jne L_chs_mode + jne LOCAL(chs_mode) andw $1, %cx - jz L_chs_mode + jz LOCAL(chs_mode) lba_mode: xorw %ax, %ax @@ -211,30 +212,30 @@ lba_mode: int $0x13 /* LBA read is not supported, so fallback to CHS. */ - jc L_chs_mode + jc LOCAL(chs_mode) movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx - jmp L_copy_buffer + jmp LOCAL(copy_buffer) -L_chs_mode: +LOCAL(chs_mode): /* * Determine the hard disk geometry from the BIOS! * We do this first, so that LS-120 IDE floppies work correctly. */ movb $8, %ah int $0x13 - jnc L_final_init + jnc LOCAL(final_init) /* * The call failed, so maybe use the floppy probe instead. */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl - jz L_floppy_probe + jz LOCAL(floppy_probe) /* Nope, we definitely have a hard disk, and we're screwed. */ - jmp L_hd_probe_error + jmp LOCAL(hd_probe_error) -L_final_init: +LOCAL(final_init): /* set the mode to zero */ movzbl %dh, %eax movb %ah, -1(%si) @@ -263,7 +264,7 @@ setup_sectors: movl kernel_sector + 4, %eax orl %eax, %eax - jnz L_geometry_error + jnz LOCAL(geometry_error) /* load logical sector start (bottom half) */ movl kernel_sector, %eax @@ -282,7 +283,7 @@ setup_sectors: /* do we need too many cylinders? */ cmpw 8(%si), %ax - jge L_geometry_error + jge LOCAL(geometry_error) /* normalize sector start (1-based) */ incb %cl @@ -324,11 +325,11 @@ setup_sectors: movw $0x0201, %ax /* function 2 */ int $0x13 - jc L_read_error + jc LOCAL(read_error) movw %es, %bx -L_copy_buffer: +LOCAL(copy_buffer): /* * We need to save %cx and %si because the startup code in * kernel uses them without initializing them. @@ -358,30 +359,31 @@ L_copy_buffer: /* * BIOS Geometry translation error (past the end of the disk geometry!). */ -L_geometry_error: +LOCAL(geometry_error): MSG(geometry_error_string) - jmp L_general_error + jmp LOCAL(general_error) /* * Disk probe failure. */ -L_hd_probe_error: +LOCAL(hd_probe_error): MSG(hd_probe_error_string) - jmp L_general_error + jmp LOCAL(general_error) /* * Read error on the disk. */ -L_read_error: +LOCAL(read_error): MSG(read_error_string) -L_general_error: +LOCAL(general_error): MSG(general_error_string) /* go here when you need to stop the machine hard after an error condition */ /* tell the BIOS a boot failure, which may result in no effect */ int $0x18 -L_stop: jmp L_stop +LOCAL(stop): + jmp LOCAL(stop) notification_string: .asciz "GRUB " geometry_error_string: .asciz "Geom" @@ -404,7 +406,7 @@ general_error_string: .asciz " Error\r\n" movw $0x0001, %bx movb $0xe, %ah int $0x10 /* display a byte */ -L_message: +LOCAL(message): lodsb cmpb $0, %al jne 1b /* if not end of string, jmp to display */ @@ -432,14 +434,14 @@ part_start: probe_values: .byte 36, 18, 15, 9, 0 -L_floppy_probe: +LOCAL(floppy_probe): /* * Perform floppy probe. */ movw $probe_values - 1, %si -L_probe_loop: +LOCAL(probe_loop): /* reset floppy controller INT 13h AH=0 */ xorw %ax, %ax int $0x13 @@ -455,7 +457,7 @@ L_probe_loop: * Floppy disk probe failure. */ MSG(fd_probe_error_string) - jmp L_general_error + jmp LOCAL(general_error) /* "Floppy" */ fd_probe_error_string: .asciz "Floppy" @@ -468,14 +470,14 @@ fd_probe_error_string: .asciz "Floppy" movb $0, %dh int $0x13 - /* if error, jump to "L_probe_loop" */ - jc L_probe_loop + /* if error, jump to "LOCAL(probe_loop)" */ + jc LOCAL(probe_loop) /* %cl is already the correct value! */ movb $1, %dh movb $79, %ch - jmp L_final_init + jmp LOCAL(final_init) . = _start + GRUB_BOOT_MACHINE_PART_END diff --git a/include/grub/symbol.h b/include/grub/symbol.h index 68d9f00e9..6bf512d12 100644 --- a/include/grub/symbol.h +++ b/include/grub/symbol.h @@ -21,6 +21,9 @@ #include +/* Apple assembler requires local labels to start with a capital L */ +#define LOCAL(sym) L_ ## sym + /* Add an underscore to a C symbol in assembler code if needed. */ #ifdef HAVE_ASM_USCORE # define EXT_C(sym) _ ## sym From 9a10df160ee55b6f664b3ef2d74c4bb1defe660d Mon Sep 17 00:00:00 2001 From: robertmh Date: Thu, 13 Aug 2009 20:08:23 +0000 Subject: [PATCH 26/45] 2009-08-13 Colin Watson * util/grub-mkconfig.in: Export GRUB_HIDDEN_TIMEOUT. * util/grub.d/00_header.in: Enter interruptible sleep if GRUB_HIDDEN_TIMEOUT is set. --- ChangeLog | 6 ++++++ util/grub-mkconfig.in | 22 ++++++++++++++++++++-- util/grub.d/00_header.in | 18 +++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4aeacf68a..ab51146e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-13 Colin Watson + + * util/grub-mkconfig.in: Export GRUB_HIDDEN_TIMEOUT. + * util/grub.d/00_header.in: Enter interruptible sleep if + GRUB_HIDDEN_TIMEOUT is set. + 2009-08-13 Yves Blusseau * include/grub/symbol.h: Add the LOCAL macro. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index f20c9de69..5865b89ce 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -190,10 +190,28 @@ esac # These are defined in this script, export them here so that user can # override them. -export GRUB_DEVICE GRUB_DEVICE_UUID GRUB_DEVICE_BOOT GRUB_DEVICE_BOOT_UUID GRUB_FS GRUB_FONT_PATH GRUB_PRELOAD_MODULES +export GRUB_DEVICE \ + GRUB_DEVICE_UUID \ + GRUB_DEVICE_BOOT \ + GRUB_DEVICE_BOOT_UUID \ + GRUB_FS \ + GRUB_FONT_PATH \ + GRUB_PRELOAD_MODULES # These are optional, user-defined variables. -export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR GRUB_CMDLINE_LINUX GRUB_CMDLINE_LINUX_DEFAULT GRUB_TERMINAL_INPUT GRUB_TERMINAL_OUTPUT GRUB_SERIAL_COMMAND GRUB_DISABLE_LINUX_UUID GRUB_DISABLE_LINUX_RECOVERY GRUB_GFXMODE +export GRUB_DEFAULT \ + GRUB_HIDDEN_TIMEOUT \ + GRUB_HIDDEN_TIMEOUT_QUIET \ + GRUB_TIMEOUT \ + GRUB_DISTRIBUTOR \ + GRUB_CMDLINE_LINUX \ + GRUB_CMDLINE_LINUX_DEFAULT \ + GRUB_TERMINAL_INPUT \ + GRUB_TERMINAL_OUTPUT \ + GRUB_SERIAL_COMMAND \ + GRUB_DISABLE_LINUX_UUID \ + GRUB_DISABLE_LINUX_RECOVERY \ + GRUB_GFXMODE if test "x${grub_cfg}" != "x"; then rm -f ${grub_cfg}.new diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index a273213f3..98c7c004b 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -37,7 +37,6 @@ if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi cat << EOF set default=${GRUB_DEFAULT} -set timeout=${GRUB_TIMEOUT} EOF case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in @@ -112,3 +111,20 @@ fi EOF ;; esac + +if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then + if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then + verbose= + else + verbose=" --verbose" + fi + cat << EOF +if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then + set timeout=${GRUB_TIMEOUT} +fi +EOF +else + cat << EOF +set timeout=${GRUB_TIMEOUT} +EOF +fi From d404ee564609f542e2607eebdfdf3873dcfb1966 Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 14 Aug 2009 04:12:22 +0000 Subject: [PATCH 27/45] 2009-08-14 Pavel Roskin * boot/i386/pc/cdboot.S: Use LOCAL for local labels. Eliminate ABS and APPLE_CC. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/lnxboot.S: Likewise. Hardcode the number of code sectors allow compilation on MacOSX. * conf/i386-pc.rmk: Enable unconditional compilation of lnxboot.img. --- ChangeLog | 10 ++++ boot/i386/pc/cdboot.S | 33 ++++-------- boot/i386/pc/diskboot.S | 64 +++++++++------------- boot/i386/pc/lnxboot.S | 114 ++++++---------------------------------- conf/i386-pc.rmk | 6 +-- 5 files changed, 63 insertions(+), 164 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab51146e8..a05df9c59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-08-14 Pavel Roskin + + * boot/i386/pc/cdboot.S: Use LOCAL for local labels. Eliminate + ABS and APPLE_CC. + * boot/i386/pc/diskboot.S: Likewise. + * boot/i386/pc/lnxboot.S: Likewise. Hardcode the number of code + sectors allow compilation on MacOSX. + * conf/i386-pc.rmk: Enable unconditional compilation of + lnxboot.img. + 2009-08-13 Colin Watson * util/grub-mkconfig.in: Export GRUB_HIDDEN_TIMEOUT. diff --git a/boot/i386/pc/cdboot.S b/boot/i386/pc/cdboot.S index efa65f511..ccc9d64de 100644 --- a/boot/i386/pc/cdboot.S +++ b/boot/i386/pc/cdboot.S @@ -17,6 +17,7 @@ * along with GRUB. If not, see . */ +#include #include #include #include @@ -38,9 +39,9 @@ start: _start: - call next + call LOCAL(next) -next: +LOCAL(next): jmp 1f . = start + 8 @@ -67,24 +68,17 @@ bi_reserved: movw %ax, %ds movw %ax, %es -#ifdef APPLE_CC - err_noboot_msg_abs = 0x7C00 + err_noboot_msg - start - movw $err_noboot_msg_abs, %si - bi_length_dif = bi_length - next - movl %cs:bi_length_dif(%bx), %ecx -#else movw $(0x7C00 + err_noboot_msg - start), %si - movl %cs: bi_length - next(%bx), %ecx -#endif + movl %cs: bi_length - LOCAL(next)(%bx), %ecx orl %ecx, %ecx - jz fail + jz LOCAL(fail) addl $((1 << CDSEC_SHIFT) - 1), %ecx shrl $CDSEC_SHIFT, %ecx - movl %cs: bi_file - next(%bx), %esi + movl %cs: bi_file - LOCAL(next)(%bx), %esi - call read_cdrom + call LOCAL(read_cdrom) ljmp $(DATA_ADDR >> 4), $0 @@ -93,7 +87,7 @@ bi_reserved: * esi: start sector * ecx: number of sectors */ -read_cdrom: +LOCAL(read_cdrom): xorl %eax, %eax /* Number of blocks to read. */ @@ -134,7 +128,7 @@ read_cdrom: 2: shrw $1, %di /* Reduce transfer size. */ - jz cdrom_fail + jz LOCAL(cdrom_fail) movw %di, 0x10(%si) movw %di, 2(%si) movb $0x42, %ah @@ -155,15 +149,10 @@ read_cdrom: addw $0x12, %sp ret -cdrom_fail: -#ifdef APPLE_CC - err_cdfail_msg_abs = 0x7C00 + err_cdfail_msg - start - movw $(err_cdfail_msg_abs), %si -#else +LOCAL(cdrom_fail): movw $(0x7C00 + err_cdfail_msg - start), %si -#endif -fail: +LOCAL(fail): movb $0x0e, %ah xorw %bx, %bx 1: diff --git a/boot/i386/pc/diskboot.S b/boot/i386/pc/diskboot.S index 1e817df27..e5e4a4ef3 100644 --- a/boot/i386/pc/diskboot.S +++ b/boot/i386/pc/diskboot.S @@ -16,23 +16,14 @@ * along with GRUB. If not, see . */ +#include #include /* * defines for the code go here */ - /* Absolute addresses - This makes the assembler generate the address without support - from the linker. (ELF can't relocate 16-bit addresses!) */ -#define ABS(x) (x-_start+GRUB_BOOT_MACHINE_KERNEL_ADDR) - - /* Print message string */ -#ifdef APPLE_CC -#define MSG(x) x ## _abs = ABS(x); mov $x ## _abs, %esi; call message -#else -#define MSG(x) movw $ABS(x), %si; call message -#endif +#define MSG(x) movw $x, %si; call LOCAL(message) .file "diskboot.S" @@ -65,33 +56,27 @@ _start: popw %si /* this sets up for the first run through "bootloop" */ -#ifdef APPLE_CC - firstlist_off_abs = ABS (firstlist - GRUB_BOOT_MACHINE_LIST_SIZE) - movl $firstlist_off_abs, %edi -#else - movw $ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE), %di -#endif + movw $(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE), %di /* save the sector number of the second sector in %ebp */ movl (%di), %ebp /* this is the loop for reading the rest of the kernel in */ -bootloop: +LOCAL(bootloop): /* check the number of sectors to read */ cmpw $0, 8(%di) /* if zero, go to the start function */ - je bootit + je LOCAL(bootit) -setup_sectors: +LOCAL(setup_sectors): /* check if we use LBA or CHS */ cmpb $0, -1(%si) - /* jump to chs_mode if zero */ - je chs_mode + /* use CHS if zero, LBA otherwise */ + je LOCAL(chs_mode) -lba_mode: /* load logical sector start */ movl (%di), %ebx movl 4(%di), %ecx @@ -150,16 +135,16 @@ lba_mode: movb $0x42, %ah int $0x13 - jc read_error + jc LOCAL(read_error) movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx - jmp copy_buffer + jmp LOCAL(copy_buffer) -chs_mode: +LOCAL(chs_mode): /* load logical sector start (top half) */ movl 4(%di), %eax orl %eax, %eax - jnz geometry_error + jnz LOCAL(geometry_error) /* load logical sector start (bottom half) */ movl (%di), %eax @@ -184,7 +169,7 @@ chs_mode: /* do we need too many cylinders? */ cmpw 8(%si), %ax - jge geometry_error + jge LOCAL(geometry_error) /* determine the maximum sector length of this read */ movw (%si), %ax /* get number of sectors per track/head */ @@ -254,12 +239,12 @@ chs_mode: movb $0x2, %ah /* function 2 */ int $0x13 - jc read_error + jc LOCAL(read_error) /* save source segment */ movw %es, %bx -copy_buffer: +LOCAL(copy_buffer): /* load addresses for copy from disk buffer to destination */ movw 10(%di), %es /* load destination segment */ @@ -299,17 +284,17 @@ copy_buffer: /* check if finished with this dataset */ cmpw $0, 8(%di) - jne setup_sectors + jne LOCAL(setup_sectors) /* update position to load from */ subw $GRUB_BOOT_MACHINE_LIST_SIZE, %di /* jump to bootloop */ - jmp bootloop + jmp LOCAL(bootloop) /* END OF MAIN LOOP */ -bootit: +LOCAL(bootit): /* print a newline */ MSG(notification_done) popw %dx /* this makes sure %dl is our "boot" drive */ @@ -319,21 +304,21 @@ bootit: /* * BIOS Geometry translation error (past the end of the disk geometry!). */ -geometry_error: +LOCAL(geometry_error): MSG(geometry_error_string) - jmp general_error + jmp LOCAL(general_error) /* * Read error on the disk. */ -read_error: +LOCAL(read_error): MSG(read_error_string) -general_error: +LOCAL(general_error): MSG(general_error_string) /* go here when you need to stop the machine hard after an error condition */ -stop: jmp stop +LOCAL(stop): jmp LOCAL(stop) notification_string: .asciz "loading" @@ -361,12 +346,11 @@ general_error_string: .asciz " Error" int $0x10 /* display a byte */ incw %si -message: +LOCAL(message): movb (%si), %al cmpb $0, %al jne 1b /* if not end of string, jmp to display */ ret -lastlist: /* * This area is an empty space between the main body of code below which diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index 14bd0415e..c51741d42 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -25,14 +26,8 @@ .file "lnxboot.S" -#ifdef APPLE_CC -#error Building lnxboot.img with Apple's as results in an unusable image -#endif - #define CODE_ADDR 0x6000 -#ifndef APPLE_CC -#define CODE_LENG (code_end - start) -#endif +#define CODE_SECTORS 1 #define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200) #define BLCK_LENG 0x4000 @@ -45,17 +40,12 @@ data_start: xorl %ebp, %ebp - jmp linux_next + jmp LOCAL(linux_next) . = data_start + 0x1F1 setup_sects: -/* Apple's cc can't fill this value. */ -#ifdef APPLE_CC - .byte 0 -#else - .byte (CODE_LENG >> 9) -#endif + .byte CODE_SECTORS root_flags: .word 0 syssize: @@ -74,7 +64,7 @@ boot_flag: start: _start: - jmp linux_init + jmp LOCAL(linux_init) .ascii "HdrS" /* Header signature. */ .word 0x0203 /* Header version number. */ @@ -132,40 +122,22 @@ reg_edx: data_leng: .long 0 -linux_init: - -#ifdef APPLE_CC - reg_edx_rel = reg_edx - start - code32_start_rel = code32_start - start - movw %cs:(reg_edx_rel), %dx - movl %cs:(code32_start_rel), %ebp -#else +LOCAL(linux_init): movw %cs:(reg_edx - start), %dx movl %cs:(code32_start - start), %ebp -#endif -linux_next: +LOCAL(linux_next): - call normalize + call LOCAL(normalize) -normalize: +LOCAL(normalize): popw %bx -#ifdef APPLE_CC - normalize_rel = normalize - start - subw $(normalize_rel), %bx -#else - subw $(normalize - start), %bx -#endif + subw $(LOCAL(normalize) - start), %bx shrw $4, %bx movw %cs, %ax addw %bx, %ax pushw %ax -#ifdef APPLE_CC - real_code_rel = real_code - start - pushw $(real_code_rel) -#else pushw $(real_code - start) -#endif lret /* Jump to real_code. */ real_code: @@ -191,13 +163,7 @@ real_code: rep movsl - -#ifdef APPLE_CC - real_code_2_rel = real_code_2 - start - ljmp $(CODE_ADDR >> 4), $(real_code_2_rel) -#else ljmp $(CODE_ADDR >> 4), $(real_code_2 - start) -#endif real_code_2: @@ -216,21 +182,14 @@ real_code_2: addl %ecx, %esi movl $DATA_ADDR, %edi - call move_memory + call LOCAL(move_memory) /* Check for multiboot signature. */ cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END) jz 1f -#ifdef APPLE_CC - ramdisk_image_rel = ramdisk_image - start - ramdisk_size_rel = ramdisk_size - start - movl (ramdisk_image_rel), %esi - movl (ramdisk_size_rel), %ecx -#else movl (ramdisk_image - start), %esi movl (ramdisk_size - start), %ecx -#endif movl $(DATA_ADDR - 0x200), %edi jmp 2f @@ -240,17 +199,11 @@ real_code_2: addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx 2: - call move_memory + call LOCAL(move_memory) movsbl %dh, %eax movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) - -#ifdef APPLE_CC - reg_edx_rel = reg_edx - start - movsbl (reg_edx_rel + 2), %eax -#else movsbl (reg_edx + 2 - start), %eax -#endif movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) movb $0xFF, %dh @@ -264,7 +217,7 @@ real_code_2: * ecx: number of bytes */ -move_memory: +LOCAL(move_memory): incl %ecx andb $0xFE, %cl pushw %dx @@ -279,28 +232,6 @@ move_memory: pushl %ecx movl %esi, %eax -#ifdef APPLE_CC - gdt_src1_rel = gdt_src1 - start - gdt_src2_rel = gdt_src2 - start - gdt_dst1_rel = gdt_dst1 - start - gdt_dst2_rel = gdt_dst2 - start - gdt_rel = gdt - start - - movw %si, (gdt_src1_rel) - shrl $16, %eax - movb %al, (gdt_src1_rel + 2) - movb %ah, (gdt_src2_rel) - - movl %edi, %eax - movw %di, (gdt_dst1_rel) - shrl $16, %eax - movb %al, (gdt_dst1_rel + 2) - movb %ah, (gdt_dst2_rel) - - movw $(gdt_rel), %si - movb $0x87, %ah - shrw $1, %cx -#else movw %si, (gdt_src1 - start) shrl $16, %eax movb %al, (gdt_src1 + 2 - start) @@ -315,7 +246,6 @@ move_memory: movw $(gdt - start), %si movb $0x87, %ah shrw $1, %cx -#endif int $0x15 @@ -325,13 +255,8 @@ move_memory: popl %esi jnc 2f -#ifdef APPLE_CC - err_int15_msg_rel = err_int15_msg - start - movw $(err_int15_msg_rel), %si -#else movw $(err_int15_msg - start), %si -#endif - jmp fail + jmp LOCAL(fail) 2: @@ -349,7 +274,7 @@ move_memory: * si: message */ -fail: +LOCAL(fail): movb $0x0e, %ah xorw %bx, %bx 1: @@ -362,11 +287,4 @@ fail: err_int15_msg: .ascii "move memory fails\0" - /* Unsupported feature in Apple's cc. */ -#ifndef APPLE_CC - . = (. & (~0x1FF)) + 0x1FF -#endif - - .byte 0 - -code_end: + . = _start + CODE_SECTORS * 512 diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 798aee231..b61ecaba5 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -10,7 +10,8 @@ COMMON_LDFLAGS = -m32 -nostdlib script/sh/lexer.c_DEPENDENCIES = grub_script.tab.h # Images. -pkglib_IMAGES = boot.img diskboot.img kernel.img pxeboot.img cdboot.img +pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \ + pxeboot.img # For boot.img. boot_img_SOURCES = boot/i386/pc/boot.S @@ -31,9 +32,6 @@ diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)8000 diskboot_img_FORMAT = binary # For lnxboot.img. -ifeq ($(TARGET_APPLE_CC), 0) -pkglib_IMAGES += lnxboot.img -endif lnxboot_img_SOURCES = boot/i386/pc/lnxboot.S lnxboot_img_ASFLAGS = $(COMMON_ASFLAGS) lnxboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)6000 From d3539132cdea9ba20d29cf99b8759232ae6a29f0 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 12:41:58 +0000 Subject: [PATCH 28/45] 2009-08-14 Vladimir Serbinenko Framebuffer split. * commands/i386/pc/vbetest.c (grub_cmd_vbetest): Restore video subsystem at the end. * conf/common.rmk (pkglib_MODULES): Add video_fb.mod. (video_fb_mod_SOURCES): New variable. (video_fb_mod_CFLAGS): Likewise. (video_fb_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (vbe_mod_SOURCES): Remove video/i386/pc/vbeblit.c, video/i386/pc/vbefill.c and video/i386/pc/vbeutil.c. * video/i386/pc/vbeblit.c: Moved from here ... * video/fb/fbblit.c: ..here. Replaced 'vbe' with 'fb'. * video/i386/pc/vbefill.c: Moved from here ... * video/fb/fbfill.c: ..here. Replaced 'vbe' with 'fb'. * video/i386/pc/vbeutil.c: Moved from here ... * video/fb/fbutil.c: ..here. Replaced 'vbe' with 'fb'. * include/grub/i386/pc/vbeblit.h: Moved from here ... * include/grub/fbblit.h: ... here. Replaced 'vbe' with 'fb'. * include/grub/i386/pc/vbefill.h: Moved from here ... * include/grub/fbfill.h: ... here. Replaced 'vbe' with 'fb'. * include/grub/i386/pc/vbeutil.h: Moved from here ... * include/grub/fbutil.h: ... here. Replaced 'vbe' with 'fb'. * include/grub/i386/pc/vbe.h: Moved framebuffer part ... * include/grub/video_fb.h: ... here. Replaced 'vbe' with 'fb'. * include/grub/video.h (GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER): Removed. (GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER): Likewise. (grub_video_adapter): Added 'get_info_and_fini'. (grub_video_get_info_and_fini): New prototype. (grub_video_set_mode): make modestring const char *. * loader/i386/linux.c (grub_linux_setup_video): Use grub_video_get_info_and_fini. (grub_linux_boot): Move modesetting just before booting. * loader/i386/pc/xnu.c (grub_xnu_set_video): Use grub_video_get_info_and_fini. * video/i386/pc/vbe.c: Moved framebuffer part ... * video/fb/video_fb.c: ... here. Replaced 'vbe' with 'fb'. * video/i386/pc/vbe.c (grub_vbe_set_video_mode): Use grub_video_fbstd_colors and grub_video_fb_set_palette. (grub_video_vbe_init): Clear 'framebuffer' variable and use grub_video_fb_init. (grub_video_vbe_fini): Use grub_video_fb_fini. (grub_video_vbe_setup): Use framebuffer.render_target instead of render_target and use grub_video_fb_set_active_render_target and grub_video_fb_set_palette. (grub_video_vbe_set_palette): Use grub_video_fb_set_palette. (grub_video_vbe_set_viewport): Use grub_video_fb_set_viewport. (grub_video_vbe_adapter): Use framebuffer. * video/video.c (grub_video_get_info_and_fini): New function. (grub_video_set_mode): Make modestring const char *. (GRUB_MOD_INIT(video_video)): Don't set variables to 0 since these values are already initialised. --- ChangeLog | 54 + commands/i386/pc/vbetest.c | 2 + conf/common.rmk | 7 +- conf/i386-pc.rmk | 3 +- include/grub/fbblit.h | 134 ++ include/grub/fbfill.h | 75 ++ include/grub/{i386/pc/vbeutil.h => fbutil.h} | 8 +- include/grub/i386/pc/vbe.h | 54 +- include/grub/i386/pc/vbeblit.h | 134 -- include/grub/i386/pc/vbefill.h | 52 - include/grub/video.h | 19 +- include/grub/video_fb.h | 121 ++ loader/i386/linux.c | 83 +- loader/i386/pc/xnu.c | 13 +- video/{i386/pc/vbeblit.c => fb/fbblit.c} | 194 +-- video/{i386/pc/vbefill.c => fb/fbfill.c} | 46 +- video/{i386/pc/vbeutil.c => fb/fbutil.c} | 8 +- video/fb/video_fb.c | 1156 +++++++++++++++++ video/i386/pc/vbe.c | 1213 ++---------------- video/video.c | 22 +- 20 files changed, 1840 insertions(+), 1558 deletions(-) create mode 100644 include/grub/fbblit.h create mode 100644 include/grub/fbfill.h rename include/grub/{i386/pc/vbeutil.h => fbutil.h} (83%) delete mode 100644 include/grub/i386/pc/vbeblit.h delete mode 100644 include/grub/i386/pc/vbefill.h create mode 100644 include/grub/video_fb.h rename video/{i386/pc/vbeblit.c => fb/fbblit.c} (78%) rename video/{i386/pc/vbefill.c => fb/fbfill.c} (76%) rename video/{i386/pc/vbeutil.c => fb/fbutil.c} (95%) create mode 100644 video/fb/video_fb.c diff --git a/ChangeLog b/ChangeLog index a05df9c59..9ea7886d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,57 @@ +2009-08-14 Vladimir Serbinenko + + Framebuffer split. + + * commands/i386/pc/vbetest.c (grub_cmd_vbetest): Restore video + subsystem at the end. + * conf/common.rmk (pkglib_MODULES): Add video_fb.mod. + (video_fb_mod_SOURCES): New variable. + (video_fb_mod_CFLAGS): Likewise. + (video_fb_mod_LDFLAGS): Likewise. + * conf/i386-pc.rmk (vbe_mod_SOURCES): Remove video/i386/pc/vbeblit.c, + video/i386/pc/vbefill.c and video/i386/pc/vbeutil.c. + * video/i386/pc/vbeblit.c: Moved from here ... + * video/fb/fbblit.c: ..here. Replaced 'vbe' with 'fb'. + * video/i386/pc/vbefill.c: Moved from here ... + * video/fb/fbfill.c: ..here. Replaced 'vbe' with 'fb'. + * video/i386/pc/vbeutil.c: Moved from here ... + * video/fb/fbutil.c: ..here. Replaced 'vbe' with 'fb'. + * include/grub/i386/pc/vbeblit.h: Moved from here ... + * include/grub/fbblit.h: ... here. Replaced 'vbe' with 'fb'. + * include/grub/i386/pc/vbefill.h: Moved from here ... + * include/grub/fbfill.h: ... here. Replaced 'vbe' with 'fb'. + * include/grub/i386/pc/vbeutil.h: Moved from here ... + * include/grub/fbutil.h: ... here. Replaced 'vbe' with 'fb'. + * include/grub/i386/pc/vbe.h: Moved framebuffer part ... + * include/grub/video_fb.h: ... here. Replaced 'vbe' with 'fb'. + * include/grub/video.h (GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER): Removed. + (GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER): Likewise. + (grub_video_adapter): Added 'get_info_and_fini'. + (grub_video_get_info_and_fini): New prototype. + (grub_video_set_mode): make modestring const char *. + * loader/i386/linux.c (grub_linux_setup_video): Use + grub_video_get_info_and_fini. + (grub_linux_boot): Move modesetting just before booting. + * loader/i386/pc/xnu.c (grub_xnu_set_video): Use + grub_video_get_info_and_fini. + * video/i386/pc/vbe.c: Moved framebuffer part ... + * video/fb/video_fb.c: ... here. Replaced 'vbe' with 'fb'. + * video/i386/pc/vbe.c (grub_vbe_set_video_mode): Use + grub_video_fbstd_colors and grub_video_fb_set_palette. + (grub_video_vbe_init): Clear 'framebuffer' variable and use + grub_video_fb_init. + (grub_video_vbe_fini): Use grub_video_fb_fini. + (grub_video_vbe_setup): Use framebuffer.render_target instead of + render_target and use grub_video_fb_set_active_render_target and + grub_video_fb_set_palette. + (grub_video_vbe_set_palette): Use grub_video_fb_set_palette. + (grub_video_vbe_set_viewport): Use grub_video_fb_set_viewport. + (grub_video_vbe_adapter): Use framebuffer. + * video/video.c (grub_video_get_info_and_fini): New function. + (grub_video_set_mode): Make modestring const char *. + (GRUB_MOD_INIT(video_video)): Don't set variables to 0 since these + values are already initialised. + 2009-08-14 Pavel Roskin * boot/i386/pc/cdboot.S: Use LOCAL for local labels. Eliminate diff --git a/commands/i386/pc/vbetest.c b/commands/i386/pc/vbetest.c index 3cbc3014c..314320d07 100644 --- a/commands/i386/pc/vbetest.c +++ b/commands/i386/pc/vbetest.c @@ -155,6 +155,8 @@ grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)), grub_getkey (); + grub_video_restore (); + /* Restore old video mode. */ grub_vbe_set_video_mode (old_mode, 0); diff --git a/conf/common.rmk b/conf/common.rmk index 032517ffb..5e9330237 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -535,13 +535,18 @@ lua_mod_LDFLAGS = $(COMMON_LDFLAGS) # Common Video Subsystem specific modules. pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \ - png.mod font.mod gfxterm.mod + png.mod font.mod gfxterm.mod video_fb.mod # For video.mod. video_mod_SOURCES = video/video.c video_mod_CFLAGS = $(COMMON_CFLAGS) video_mod_LDFLAGS = $(COMMON_LDFLAGS) +video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \ + video/fb/fbfill.c video/fb/fbutil.c +video_fb_mod_CFLAGS = $(COMMON_CFLAGS) +video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For videotest.mod. videotest_mod_SOURCES = commands/videotest.c videotest_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index b61ecaba5..debb40364 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -271,8 +271,7 @@ multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) # For vbe.mod. -vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \ - video/i386/pc/vbefill.c video/i386/pc/vbeutil.c +vbe_mod_SOURCES = video/i386/pc/vbe.c vbe_mod_CFLAGS = $(COMMON_CFLAGS) vbe_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/include/grub/fbblit.h b/include/grub/fbblit.h new file mode 100644 index 000000000..664f508c5 --- /dev/null +++ b/include/grub/fbblit.h @@ -0,0 +1,134 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_FBBLIT_HEADER +#define GRUB_FBBLIT_HEADER 1 + +/* NOTE: This header is private header for fb driver and should not be used + in other parts of the code. */ + +struct grub_video_fbblit_info; + +void +grub_video_fbblit_replace (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +#endif /* ! GRUB_FBBLIT_HEADER */ diff --git a/include/grub/fbfill.h b/include/grub/fbfill.h new file mode 100644 index 000000000..08cd7b887 --- /dev/null +++ b/include/grub/fbfill.h @@ -0,0 +1,75 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_FBFILL_HEADER +#define GRUB_FBFILL_HEADER 1 + +/* NOTE: This header is private header for fb driver and should not be used + in other parts of the code. */ + +struct grub_video_fbblit_info; + +struct grub_video_fbrender_target +{ + /* Copy of the screen's mode info structure, except that width, height and + mode_type has been re-adjusted to requested render target settings. */ + struct grub_video_mode_info mode_info; + + struct + { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + } viewport; + + /* Indicates whether the data has been allocated by us and must be freed + when render target is destroyed. */ + int is_allocated; + + /* Pointer to data. Can either be in video card memory or in local host's + memory. */ + void *data; +}; + +void +grub_video_fbfill (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height); + +void +grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height); + +void +grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height); + +void +grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height); + +void +grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height); + +#endif /* ! GRUB_FBFILL_HEADER */ diff --git a/include/grub/i386/pc/vbeutil.h b/include/grub/fbutil.h similarity index 83% rename from include/grub/i386/pc/vbeutil.h rename to include/grub/fbutil.h index 9b5be2163..76e1e573c 100644 --- a/include/grub/i386/pc/vbeutil.h +++ b/include/grub/fbutil.h @@ -25,19 +25,19 @@ #include #include -struct grub_video_i386_vbeblit_info +struct grub_video_fbblit_info { struct grub_video_mode_info *mode_info; void *data; }; -grub_uint8_t *get_data_ptr (struct grub_video_i386_vbeblit_info *source, +grub_uint8_t *get_data_ptr (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y); -grub_video_color_t get_pixel (struct grub_video_i386_vbeblit_info *source, +grub_video_color_t get_pixel (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y); -void set_pixel (struct grub_video_i386_vbeblit_info *source, +void set_pixel (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y, grub_video_color_t color); #endif /* ! GRUB_VBEUTIL_MACHINE_HEADER */ diff --git a/include/grub/i386/pc/vbe.h b/include/grub/i386/pc/vbe.h index fad3c6c36..32427679b 100644 --- a/include/grub/i386/pc/vbe.h +++ b/include/grub/i386/pc/vbe.h @@ -19,10 +19,7 @@ #ifndef GRUB_VBE_MACHINE_HEADER #define GRUB_VBE_MACHINE_HEADER 1 -#include -#include -#include -#include +#include /* Default video mode to be used. */ #define GRUB_VBE_DEFAULT_VIDEO_MODE 0x101 @@ -231,54 +228,5 @@ grub_err_t grub_vbe_get_video_mode (grub_uint32_t *mode); grub_err_t grub_vbe_get_video_mode_info (grub_uint32_t mode, struct grub_vbe_mode_info_block *mode_info); -/* VBE module internal prototypes (should not be used from elsewhere). */ -struct grub_video_i386_vbeblit_info; - -struct grub_video_render_target -{ - /* Copy of the screen's mode info structure, except that width, height and - mode_type has been re-adjusted to requested render target settings. */ - struct grub_video_mode_info mode_info; - - struct - { - unsigned int x; - unsigned int y; - unsigned int width; - unsigned int height; - } viewport; - - /* Indicates whether the data has been allocated by us and must be freed - when render target is destroyed. */ - int is_allocated; - - /* Pointer to data. Can either be in video card memory or in local host's - memory. */ - void *data; -}; - -grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source, - grub_uint32_t x, grub_uint32_t y); - -grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green, - grub_uint8_t blue); - -grub_video_color_t grub_video_vbe_map_rgba (grub_uint8_t red, - grub_uint8_t green, - grub_uint8_t blue, - grub_uint8_t alpha); - -grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color, - grub_uint8_t *red, - grub_uint8_t *green, - grub_uint8_t *blue, - grub_uint8_t *alpha); - -void grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info *source, - grub_video_color_t color, - grub_uint8_t *red, - grub_uint8_t *green, - grub_uint8_t *blue, - grub_uint8_t *alpha); #endif /* ! GRUB_VBE_MACHINE_HEADER */ diff --git a/include/grub/i386/pc/vbeblit.h b/include/grub/i386/pc/vbeblit.h deleted file mode 100644 index 5a2aa7af0..000000000 --- a/include/grub/i386/pc/vbeblit.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_VBEBLIT_MACHINE_HEADER -#define GRUB_VBEBLIT_MACHINE_HEADER 1 - -/* NOTE: This header is private header for vbe driver and should not be used - in other parts of the code. */ - -struct grub_video_i386_vbeblit_info; - -void -grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_directN (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_BGR888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -void -grub_video_i386_vbeblit_blend_index_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y); - -#endif /* ! GRUB_VBEBLIT_MACHINE_HEADER */ diff --git a/include/grub/i386/pc/vbefill.h b/include/grub/i386/pc/vbefill.h deleted file mode 100644 index efc6378d4..000000000 --- a/include/grub/i386/pc/vbefill.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_VBEFILL_MACHINE_HEADER -#define GRUB_VBEFILL_MACHINE_HEADER 1 - -/* NOTE: This header is private header for vbe driver and should not be used - in other parts of the code. */ - -struct grub_video_i386_vbeblit_info; - -void -grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height); - -void -grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height); - -void -grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height); - -void -grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height); - -void -grub_video_i386_vbefill_direct8 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height); - -#endif /* ! GRUB_VBEFILL_MACHINE_HEADER */ diff --git a/include/grub/video.h b/include/grub/video.h index c98731ddf..4145db465 100644 --- a/include/grub/video.h +++ b/include/grub/video.h @@ -48,10 +48,8 @@ struct grub_video_bitmap; #define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK 0x0000ff00 #define GRUB_VIDEO_MODE_TYPE_DEPTH_POS 8 -/* Defined predefined render targets. */ -#define GRUB_VIDEO_RENDER_TARGET_DISPLAY ((struct grub_video_render_target *) 0) -#define GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER ((struct grub_video_render_target *) 0) -#define GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER ((struct grub_video_render_target *) 1) +#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \ + ((struct grub_video_render_target *) 0) /* Defined blitting formats. */ enum grub_video_blit_format @@ -177,6 +175,9 @@ struct grub_video_adapter grub_err_t (*get_info) (struct grub_video_mode_info *mode_info); + grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info, + void **framebuffer); + grub_err_t (*set_palette) (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data); @@ -241,6 +242,14 @@ grub_err_t grub_video_restore (void); grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info); +/* Framebuffer address may change as a part of normal operation + (e.g. double buffering). That's why you need to stop video subsystem to be + sure that framebuffer address doesn't change. To ensure this abstraction + grub_video_get_info_and_fini is the only function supplying framebuffer + address. */ +grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, + void **framebuffer); + enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info); grub_err_t grub_video_set_palette (unsigned int start, unsigned int count, @@ -297,7 +306,7 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_target grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target); -grub_err_t grub_video_set_mode (char *modestring, +grub_err_t grub_video_set_mode (const char *modestring, int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p, struct grub_video_mode_info *mode_info)); diff --git a/include/grub/video_fb.h b/include/grub/video_fb.h new file mode 100644 index 000000000..03ef38509 --- /dev/null +++ b/include/grub/video_fb.h @@ -0,0 +1,121 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_VIDEO_FB_HEADER +#define GRUB_VIDEO_FB_HEADER 1 + +#include +#include +#include +#include + +/* FB module internal prototype (should not be used from elsewhere). */ + +struct grub_video_fbblit_info; + +struct grub_video_fbrender_target; + +#define GRUB_VIDEO_FBSTD_NUMCOLORS 16 +extern struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS]; + +grub_uint8_t * grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, + grub_uint32_t x, grub_uint32_t y); + +grub_err_t +grub_video_fb_init (void); + +grub_err_t +grub_video_fb_fini (void); + +grub_err_t +grub_video_fb_get_info (struct grub_video_mode_info *mode_info); + +grub_err_t +grub_video_fb_get_palette (unsigned int start, unsigned int count, + struct grub_video_palette_data *palette_data); +grub_err_t +grub_video_fb_set_palette (unsigned int start, unsigned int count, + struct grub_video_palette_data *palette_data); +grub_err_t +grub_video_fb_set_viewport (unsigned int x, unsigned int y, + unsigned int width, unsigned int height); +grub_err_t +grub_video_fb_get_viewport (unsigned int *x, unsigned int *y, + unsigned int *width, unsigned int *height); + +grub_video_color_t +grub_video_fb_map_color (grub_uint32_t color_name); + +grub_video_color_t +grub_video_fb_map_rgb (grub_uint8_t red, grub_uint8_t green, + grub_uint8_t blue); + +grub_video_color_t +grub_video_fb_map_rgba (grub_uint8_t red, grub_uint8_t green, + grub_uint8_t blue, grub_uint8_t alpha); + +grub_err_t +grub_video_fb_unmap_color (grub_video_color_t color, + grub_uint8_t *red, grub_uint8_t *green, + grub_uint8_t *blue, grub_uint8_t *alpha); + +void +grub_video_fb_unmap_color_int (struct grub_video_fbblit_info * source, + grub_video_color_t color, + grub_uint8_t *red, grub_uint8_t *green, + grub_uint8_t *blue, grub_uint8_t *alpha); + +grub_err_t +grub_video_fb_fill_rect (grub_video_color_t color, int x, int y, + unsigned int width, unsigned int height); + +grub_err_t +grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, + enum grub_video_blit_operators oper, int x, int y, + int offset_x, int offset_y, + unsigned int width, unsigned int height); + +grub_err_t +grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source, + enum grub_video_blit_operators oper, + int x, int y, int offset_x, int offset_y, + unsigned int width, unsigned int height); + +grub_err_t +grub_video_fb_scroll (grub_video_color_t color, int dx, int dy); + +grub_err_t +grub_video_fb_create_render_target (struct grub_video_fbrender_target **result, + unsigned int width, unsigned int height, + unsigned int mode_type __attribute__ ((unused))); + +grub_err_t +grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result, + const struct grub_video_mode_info *mode_info, + void *ptr); + +grub_err_t +grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target); + +grub_err_t +grub_video_fb_get_active_render_target (struct grub_video_fbrender_target **target); + +grub_err_t +grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *target); + +#endif /* ! GRUB_VIDEO_FB_HEADER */ diff --git a/loader/i386/linux.c b/loader/i386/linux.c index d76e7fbd0..238e4cd8f 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -31,9 +31,7 @@ #include #include #include -/* FIXME: the definition of `struct grub_video_render_target' is - VBE-specific. */ -#include +#include #include #define GRUB_LINUX_CL_OFFSET 0x1000 @@ -403,14 +401,11 @@ static int grub_linux_setup_video (struct linux_kernel_params *params) { struct grub_video_mode_info mode_info; - struct grub_video_render_target *render_target; + void *framebuffer; int ret; - ret = grub_video_get_info (&mode_info); - if (ret) - return 1; + ret = grub_video_get_info_and_fini (&mode_info, &framebuffer); - ret = grub_video_get_active_render_target (&render_target); if (ret) return 1; @@ -419,7 +414,7 @@ grub_linux_setup_video (struct linux_kernel_params *params) params->lfb_depth = mode_info.bpp; params->lfb_line_len = mode_info.pitch; - params->lfb_base = (grub_size_t) render_target->data; + params->lfb_base = (grub_size_t) framebuffer; params->lfb_size = (params->lfb_line_len * params->lfb_height + 65535) >> 16; params->red_mask_size = mode_info.red_mask_size; @@ -449,41 +444,6 @@ grub_linux_boot (void) params = real_mode_mem; - modevar = grub_env_get ("gfxpayload"); - - /* Now all graphical modes are acceptable. - May change in future if we have modes without framebuffer. */ - if (modevar && *modevar != 0) - { - tmp = grub_malloc (grub_strlen (modevar) - + sizeof (DEFAULT_VIDEO_MODE) + 1); - if (! tmp) - return grub_errno; - grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar); - err = grub_video_set_mode (tmp, 0); - grub_free (tmp); - } -#ifndef GRUB_ASSUME_LINUX_HAS_FB_SUPPORT - else - err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0); -#endif - - if (err) - { - grub_print_error (); - grub_printf ("Booting however\n"); - grub_errno = GRUB_ERR_NONE; - } - - if (! grub_linux_setup_video (params)) - params->have_vga = GRUB_VIDEO_TYPE_VLFB; - else - { - params->have_vga = GRUB_VIDEO_TYPE_TEXT; - params->video_width = 80; - params->video_height = 25; - } - grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", (unsigned) params->code32_start, (unsigned long) &(idt_desc.limit), @@ -534,6 +494,41 @@ grub_linux_boot (void) grub_mmap_iterate (hook); params->mmap_size = e820_num; + modevar = grub_env_get ("gfxpayload"); + + /* Now all graphical modes are acceptable. + May change in future if we have modes without framebuffer. */ + if (modevar && *modevar != 0) + { + tmp = grub_malloc (grub_strlen (modevar) + + sizeof (DEFAULT_VIDEO_MODE) + 1); + if (! tmp) + return grub_errno; + grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar); + err = grub_video_set_mode (tmp, 0); + grub_free (tmp); + } +#ifndef GRUB_ASSUME_LINUX_HAS_FB_SUPPORT + else + err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0); +#endif + + if (err) + { + grub_print_error (); + grub_printf ("Booting however\n"); + grub_errno = GRUB_ERR_NONE; + } + + if (! grub_linux_setup_video (params)) + params->have_vga = GRUB_VIDEO_TYPE_VLFB; + else + { + params->have_vga = GRUB_VIDEO_TYPE_TEXT; + params->video_width = 80; + params->video_height = 25; + } + /* Initialize these last, because terminal position could be affected by printfs above. */ if (params->have_vga == GRUB_VIDEO_TYPE_TEXT) { diff --git a/loader/i386/pc/xnu.c b/loader/i386/pc/xnu.c index 037a7134f..69a9405c6 100644 --- a/loader/i386/pc/xnu.c +++ b/loader/i386/pc/xnu.c @@ -21,8 +21,7 @@ #include #include #include -#include -#include +#include #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -43,10 +42,10 @@ grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *params) { struct grub_video_mode_info mode_info; - struct grub_video_render_target *render_target; int ret; int x,y; char *tmp, *modevar; + void *framebuffer; grub_err_t err; modevar = grub_env_get ("gfxpayload"); @@ -67,11 +66,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params) if (err) return err; - ret = grub_video_get_info (&mode_info); - if (ret) - return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters"); - - ret = grub_video_get_active_render_target (&render_target); + ret = grub_video_get_info_and_fini (&mode_info, &framebuffer); if (ret) return grub_error (GRUB_ERR_IO, "couldn't retrieve video parameters"); @@ -102,7 +97,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params) params->lfb_depth = mode_info.bpp; params->lfb_line_len = mode_info.pitch; - params->lfb_base = PTR_TO_UINT32 (render_target->data); + params->lfb_base = PTR_TO_UINT32 (framebuffer); params->lfb_mode = grub_xnu_bitmap ? GRUB_XNU_VIDEO_SPLASH : GRUB_XNU_VIDEO_TEXT_IN_VIDEO; diff --git a/video/i386/pc/vbeblit.c b/video/fb/fbblit.c similarity index 78% rename from video/i386/pc/vbeblit.c rename to video/fb/fbblit.c index 4121bfe6c..138eba8c1 100644 --- a/video/i386/pc/vbeblit.c +++ b/video/fb/fbblit.c @@ -27,19 +27,19 @@ - Every function in this code assumes that bounds checking has been done in previous phase and they are opted out in here. */ -#include -#include -#include +#include +#include +#include #include #include #include /* Generic replacing blitter (slow). Works for every supported format. */ void -grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y) { int i; int j; @@ -56,11 +56,11 @@ grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst, { src_color = get_pixel (src, i + offset_x, j + offset_y); - grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green, - &src_blue, &src_alpha); + grub_video_fb_unmap_color_int (src, src_color, &src_red, &src_green, + &src_blue, &src_alpha); - dst_color = grub_video_vbe_map_rgba (src_red, src_green, - src_blue, src_alpha); + dst_color = grub_video_fb_map_rgba (src_red, src_green, + src_blue, src_alpha); set_pixel (dst, x + i, y + j, dst_color); } @@ -69,10 +69,10 @@ grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst, /* Block copy replacing blitter. Works with modes multiple of 8 bits. */ void -grub_video_i386_vbeblit_replace_directN (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y) { int j; grub_uint32_t *srcptr; @@ -92,11 +92,11 @@ grub_video_i386_vbeblit_replace_directN (struct grub_video_i386_vbeblit_info *ds /* Optimized replacing blitter for RGBX8888 to BGRX8888. */ void -grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { int i; int j; @@ -135,11 +135,11 @@ grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (struct grub_video_i386_vbebli /* Optimized replacing blitter for RGB888 to BGRX8888. */ void -grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { int i; int j; @@ -179,11 +179,11 @@ grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (struct grub_video_i386_vbeblit_ /* Optimized replacing blitter for RGBX8888 to BGR888. */ void -grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t *srcptr; grub_uint8_t *dstptr; @@ -227,11 +227,11 @@ grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (struct grub_video_i386_vbeblit_ /* Optimized replacing blitter for RGB888 to BGR888. */ void -grub_video_i386_vbeblit_replace_BGR888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { int i; int j; @@ -268,11 +268,11 @@ grub_video_i386_vbeblit_replace_BGR888_RGB888 (struct grub_video_i386_vbeblit_in /* Optimized replacing blitter for RGB888 to RGBX8888. */ void -grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -304,11 +304,11 @@ grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (struct grub_video_i386_vbeblit_ /* Optimized replacing blitter for RGBX8888 to RGB888. */ void -grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -341,11 +341,11 @@ grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (struct grub_video_i386_vbeblit_ /* Optimized replacing blitter for RGBX8888 to indexed color. */ void -grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -369,7 +369,7 @@ grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_i sg = (color >> 8) & 0xFF; sb = (color >> 16) & 0xFF; - color = grub_video_vbe_map_rgb(sr, sg, sb); + color = grub_video_fb_map_rgb(sr, sg, sb); *dstptr++ = color & 0xFF; } } @@ -377,11 +377,11 @@ grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_i /* Optimized replacing blitter for RGB888 to indexed color. */ void -grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -403,7 +403,7 @@ grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_inf sg = *srcptr++; sb = *srcptr++; - color = grub_video_vbe_map_rgb(sr, sg, sb); + color = grub_video_fb_map_rgb(sr, sg, sb); *dstptr++ = color & 0xFF; } @@ -412,10 +412,10 @@ grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_inf /* Generic blending blitter. Works for every supported format. */ void -grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, int width, int height, + int offset_x, int offset_y) { int i; int j; @@ -436,24 +436,24 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst, grub_video_color_t dst_color; src_color = get_pixel (src, i + offset_x, j + offset_y); - grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green, - &src_blue, &src_alpha); + grub_video_fb_unmap_color_int (src, src_color, &src_red, &src_green, + &src_blue, &src_alpha); if (src_alpha == 0) continue; if (src_alpha == 255) { - dst_color = grub_video_vbe_map_rgba (src_red, src_green, - src_blue, src_alpha); + dst_color = grub_video_fb_map_rgba (src_red, src_green, + src_blue, src_alpha); set_pixel (dst, x + i, y + j, dst_color); continue; } dst_color = get_pixel (dst, x + i, y + j); - grub_video_vbe_unmap_color_int (dst, dst_color, &dst_red, - &dst_green, &dst_blue, &dst_alpha); + grub_video_fb_unmap_color_int (dst, dst_color, &dst_red, + &dst_green, &dst_blue, &dst_alpha); dst_red = (((src_red * src_alpha) + (dst_red * (255 - src_alpha))) / 255); @@ -463,8 +463,8 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst, + (dst_blue * (255 - src_alpha))) / 255); dst_alpha = src_alpha; - dst_color = grub_video_vbe_map_rgba (dst_red, dst_green, dst_blue, - dst_alpha); + dst_color = grub_video_fb_map_rgba (dst_red, dst_green, dst_blue, + dst_alpha); set_pixel (dst, x + i, y + j, dst_color); } @@ -473,11 +473,11 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst, /* Optimized blending blitter for RGBA8888 to BGRA8888. */ void -grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t *srcptr; grub_uint32_t *dstptr; @@ -554,11 +554,11 @@ grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (struct grub_video_i386_vbeblit_ /* Optimized blending blitter for RGBA8888 to BGR888. */ void -grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t *srcptr; grub_uint8_t *dstptr; @@ -635,11 +635,11 @@ grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (struct grub_video_i386_vbeblit_in /* Optimized blending blitter for RGBA888 to RGBA8888. */ void -grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -700,11 +700,11 @@ grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (struct grub_video_i386_vbeblit_ /* Optimized blending blitter for RGBA8888 to RGB888. */ void -grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -766,11 +766,11 @@ grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (struct grub_video_i386_vbeblit_in /* Optimized blending blitter for RGBA8888 to indexed color. */ void -grub_video_i386_vbeblit_blend_index_RGBA8888 (struct grub_video_i386_vbeblit_info *dst, - struct grub_video_i386_vbeblit_info *src, - int x, int y, - int width, int height, - int offset_x, int offset_y) +grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) { grub_uint32_t color; int i; @@ -809,18 +809,18 @@ grub_video_i386_vbeblit_blend_index_RGBA8888 (struct grub_video_i386_vbeblit_inf if (a == 255) { - color = grub_video_vbe_map_rgb(sr, sg, sb); + color = grub_video_fb_map_rgb(sr, sg, sb); *dstptr++ = color & 0xFF; continue; } - grub_video_vbe_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da); + grub_video_fb_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da); dr = (dr * (255 - a) + sr * a) / 255; dg = (dg * (255 - a) + sg * a) / 255; db = (db * (255 - a) + sb * a) / 255; - color = grub_video_vbe_map_rgb(dr, dg, db); + color = grub_video_fb_map_rgb(dr, dg, db); *dstptr++ = color & 0xFF; } diff --git a/video/i386/pc/vbefill.c b/video/fb/fbfill.c similarity index 76% rename from video/i386/pc/vbefill.c rename to video/fb/fbfill.c index 3a98a715a..a4ca7c2a1 100644 --- a/video/i386/pc/vbefill.c +++ b/video/fb/fbfill.c @@ -27,32 +27,32 @@ - Every function in this code assumes that bounds checking has been done in previous phase and they are opted out in here. */ -#include -#include -#include +#include +#include +#include #include #include /* Generic filler that works for every supported mode. */ void -grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height) +grub_video_fbfill (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height) { int i; int j; for (j = 0; j < height; j++) for (i = 0; i < width; i++) - set_pixel (dst, x+i, y+j, color); + set_pixel (dst, x + i, y + j, color); } /* Optimized filler for direct color 32 bit modes. It is assumed that color is already mapped to destination format. */ void -grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height) +grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height) { int i; int j; @@ -64,7 +64,7 @@ grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst, rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; /* Get the start address. */ - dstptr = (grub_uint32_t *) grub_video_vbe_get_video_ptr (dst, x, y); + dstptr = (grub_uint32_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -79,9 +79,9 @@ grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst, /* Optimized filler for direct color 24 bit modes. It is assumed that color is already mapped to destination format. */ void -grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height) +grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height) { int i; int j; @@ -96,7 +96,7 @@ grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst, rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; /* Get the start address. */ - dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -115,9 +115,9 @@ grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst, /* Optimized filler for direct color 16 bit modes. It is assumed that color is already mapped to destination format. */ void -grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height) +grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height) { int i; int j; @@ -131,7 +131,7 @@ grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst, rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; /* Get the start address. */ - dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -149,9 +149,9 @@ grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst, /* Optimized filler for index color. It is assumed that color is already mapped to destination format. */ void -grub_video_i386_vbefill_direct8 (struct grub_video_i386_vbeblit_info *dst, - grub_video_color_t color, int x, int y, - int width, int height) +grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst, + grub_video_color_t color, int x, int y, + int width, int height) { int i; int j; @@ -164,7 +164,7 @@ grub_video_i386_vbefill_direct8 (struct grub_video_i386_vbeblit_info *dst, rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; /* Get the start address. */ - dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { diff --git a/video/i386/pc/vbeutil.c b/video/fb/fbutil.c similarity index 95% rename from video/i386/pc/vbeutil.c rename to video/fb/fbutil.c index 1040dc934..09cbb12f9 100644 --- a/video/i386/pc/vbeutil.c +++ b/video/fb/fbutil.c @@ -16,12 +16,12 @@ * along with GRUB. If not, see . */ -#include +#include #include #include grub_uint8_t * -get_data_ptr (struct grub_video_i386_vbeblit_info *source, +get_data_ptr (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y) { grub_uint8_t *ptr = 0; @@ -64,7 +64,7 @@ get_data_ptr (struct grub_video_i386_vbeblit_info *source, } grub_video_color_t -get_pixel (struct grub_video_i386_vbeblit_info *source, +get_pixel (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y) { grub_video_color_t color = 0; @@ -111,7 +111,7 @@ get_pixel (struct grub_video_i386_vbeblit_info *source, } void -set_pixel (struct grub_video_i386_vbeblit_info *source, +set_pixel (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y, grub_video_color_t color) { switch (source->mode_info->bpp) diff --git a/video/fb/video_fb.c b/video/fb/video_fb.c new file mode 100644 index 000000000..fc943735a --- /dev/null +++ b/video/fb/video_fb.c @@ -0,0 +1,1156 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static struct grub_video_fbrender_target *render_target; +struct grub_video_palette_data *palette; +static unsigned int palette_size; + +/* Specify "standard" VGA palette, some video cards may + need this and this will also be used when using RGB modes. */ +struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS] = + { + // {R, G, B, A} + {0x00, 0x00, 0x00, 0xFF}, // 0 = black + {0x00, 0x00, 0xA8, 0xFF}, // 1 = blue + {0x00, 0xA8, 0x00, 0xFF}, // 2 = green + {0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan + {0xA8, 0x00, 0x00, 0xFF}, // 4 = red + {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta + {0xA8, 0x54, 0x00, 0xFF}, // 6 = brown + {0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray + + {0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray + {0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue + {0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green + {0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan + {0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red + {0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta + {0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow + {0xFE, 0xFE, 0xFE, 0xFF} // 15 = white + }; + +grub_err_t +grub_video_fb_init (void) +{ + grub_free (palette); + render_target = 0; + palette = 0; + palette_size = 0; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_fini (void) +{ + grub_free (palette); + render_target = 0; + palette = 0; + palette_size = 0; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_get_info (struct grub_video_mode_info *mode_info) +{ + /* Copy mode info from active render target. */ + grub_memcpy (mode_info, &render_target->mode_info, + sizeof (struct grub_video_mode_info)); + + return GRUB_ERR_NONE; +} + + +grub_uint8_t * +grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, + grub_uint32_t x, grub_uint32_t y) +{ + grub_uint8_t *ptr = 0; + + switch (source->mode_info->bpp) + { + case 32: + ptr = (grub_uint8_t *)source->data + + y * source->mode_info->pitch + + x * 4; + break; + + case 24: + ptr = (grub_uint8_t *)source->data + + y * source->mode_info->pitch + + x * 3; + break; + + case 16: + case 15: + ptr = (grub_uint8_t *)source->data + + y * source->mode_info->pitch + + x * 2; + break; + + case 8: + ptr = (grub_uint8_t *)source->data + + y * source->mode_info->pitch + + x; + break; + } + + return ptr; +} + +grub_err_t +grub_video_fb_get_palette (unsigned int start, unsigned int count, + struct grub_video_palette_data *palette_data) +{ + unsigned int i; + + /* Assume that we know everything from index color palette. */ + for (i = 0; (i < count) && ((i + start) < palette_size); i++) + palette_data[i] = palette[start + i]; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_set_palette (unsigned int start, unsigned int count, + struct grub_video_palette_data *palette_data) +{ + unsigned i; + if (start + count > palette_size) + { + palette_size = start + count; + palette = grub_realloc (palette, sizeof (palette[0]) * palette_size); + if (!palette) + { + grub_video_fb_fini (); + return grub_errno; + } + } + for (i = 0; (i < count) && ((i + start) < palette_size); i++) + palette[start + i] = palette_data[i]; + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_set_viewport (unsigned int x, unsigned int y, + unsigned int width, unsigned int height) +{ + /* Make sure viewport is withing screen dimensions. If viewport was set + to be out of the region, mark its size as zero. */ + if (x > render_target->mode_info.width) + { + x = 0; + width = 0; + } + + if (y > render_target->mode_info.height) + { + y = 0; + height = 0; + } + + if (x + width > render_target->mode_info.width) + width = render_target->mode_info.width - x; + + if (y + height > render_target->mode_info.height) + height = render_target->mode_info.height - y; + + render_target->viewport.x = x; + render_target->viewport.y = y; + render_target->viewport.width = width; + render_target->viewport.height = height; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_get_viewport (unsigned int *x, unsigned int *y, + unsigned int *width, unsigned int *height) +{ + if (x) *x = render_target->viewport.x; + if (y) *y = render_target->viewport.y; + if (width) *width = render_target->viewport.width; + if (height) *height = render_target->viewport.height; + + return GRUB_ERR_NONE; +} + +/* Maps color name to target optimized color format. */ +grub_video_color_t +grub_video_fb_map_color (grub_uint32_t color_name) +{ + /* TODO: implement color theme mapping code. */ + + if (color_name < palette_size) + { + if ((render_target->mode_info.mode_type + & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) + return color_name; + else + { + grub_video_color_t color; + + color = grub_video_fb_map_rgb (palette[color_name].r, + palette[color_name].g, + palette[color_name].b); + + return color; + } + } + + return 0; +} + +/* Maps RGB to target optimized color format. */ +grub_video_color_t +grub_video_fb_map_rgb (grub_uint8_t red, grub_uint8_t green, + grub_uint8_t blue) +{ + if ((render_target->mode_info.mode_type + & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) + { + int minindex = 0; + int delta = 0; + int tmp; + int val; + unsigned i; + + /* Find best matching color. */ + for (i = 0; i < palette_size; i++) + { + val = palette[i].r - red; + tmp = val * val; + val = palette[i].g - green; + tmp += val * val; + val = palette[i].b - blue; + tmp += val * val; + + if (i == 0) + delta = tmp; + + if (tmp < delta) + { + delta = tmp; + minindex = i; + if (tmp == 0) + break; + } + } + + return minindex; + } + else if ((render_target->mode_info.mode_type + & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) + { + if (red == render_target->mode_info.fg_red + && green == render_target->mode_info.fg_green + && blue == render_target->mode_info.fg_blue) + return 1; + else + return 0; + } + else + { + grub_uint32_t value; + grub_uint8_t alpha = 255; /* Opaque color. */ + + red >>= 8 - render_target->mode_info.red_mask_size; + green >>= 8 - render_target->mode_info.green_mask_size; + blue >>= 8 - render_target->mode_info.blue_mask_size; + alpha >>= 8 - render_target->mode_info.reserved_mask_size; + + value = red << render_target->mode_info.red_field_pos; + value |= green << render_target->mode_info.green_field_pos; + value |= blue << render_target->mode_info.blue_field_pos; + value |= alpha << render_target->mode_info.reserved_field_pos; + + return value; + } + +} + +/* Maps RGBA to target optimized color format. */ +grub_video_color_t +grub_video_fb_map_rgba (grub_uint8_t red, grub_uint8_t green, + grub_uint8_t blue, grub_uint8_t alpha) +{ + if ((render_target->mode_info.mode_type + & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) + /* No alpha available in index color modes, just use + same value as in only RGB modes. */ + return grub_video_fb_map_rgb (red, green, blue); + else if ((render_target->mode_info.mode_type + & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) + { + if (red == render_target->mode_info.fg_red + && green == render_target->mode_info.fg_green + && blue == render_target->mode_info.fg_blue + && alpha == render_target->mode_info.fg_alpha) + return 1; + else + return 0; + } + else + { + grub_uint32_t value; + + red >>= 8 - render_target->mode_info.red_mask_size; + green >>= 8 - render_target->mode_info.green_mask_size; + blue >>= 8 - render_target->mode_info.blue_mask_size; + alpha >>= 8 - render_target->mode_info.reserved_mask_size; + + value = red << render_target->mode_info.red_field_pos; + value |= green << render_target->mode_info.green_field_pos; + value |= blue << render_target->mode_info.blue_field_pos; + value |= alpha << render_target->mode_info.reserved_field_pos; + + return value; + } +} + +/* Splits target optimized format to components. */ +grub_err_t +grub_video_fb_unmap_color (grub_video_color_t color, + grub_uint8_t *red, grub_uint8_t *green, + grub_uint8_t *blue, grub_uint8_t *alpha) +{ + struct grub_video_fbblit_info target_info; + + target_info.mode_info = &render_target->mode_info; + target_info.data = render_target->data; + + grub_video_fb_unmap_color_int (&target_info, color, red, green, blue, alpha); + + return GRUB_ERR_NONE; +} + +/* Splits color in source format to components. */ +void +grub_video_fb_unmap_color_int (struct grub_video_fbblit_info * source, + grub_video_color_t color, + grub_uint8_t *red, grub_uint8_t *green, + grub_uint8_t *blue, grub_uint8_t *alpha) +{ + struct grub_video_mode_info *mode_info; + mode_info = source->mode_info; + + if ((mode_info->mode_type + & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) + { + /* If we have an out-of-bounds color, return transparent black. */ + if (color > 255) + { + *red = 0; + *green = 0; + *blue = 0; + *alpha = 0; + return; + } + + *red = palette[color].r; + *green = palette[color].g; + *blue = palette[color].b; + *alpha = palette[color].a; + return; + } + else if ((mode_info->mode_type + & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) + { + if (color & 1) + { + *red = mode_info->fg_red; + *green = mode_info->fg_green; + *blue = mode_info->fg_blue; + *alpha = mode_info->fg_alpha; + } + else + { + *red = mode_info->bg_red; + *green = mode_info->bg_green; + *blue = mode_info->bg_blue; + *alpha = mode_info->bg_alpha; + } + } + else + { + grub_uint32_t tmp; + + /* Get red component. */ + tmp = color >> mode_info->red_field_pos; + tmp &= (1 << mode_info->red_mask_size) - 1; + tmp <<= 8 - mode_info->red_mask_size; + tmp |= (1 << (8 - mode_info->red_mask_size)) - 1; + *red = tmp & 0xFF; + + /* Get green component. */ + tmp = color >> mode_info->green_field_pos; + tmp &= (1 << mode_info->green_mask_size) - 1; + tmp <<= 8 - mode_info->green_mask_size; + tmp |= (1 << (8 - mode_info->green_mask_size)) - 1; + *green = tmp & 0xFF; + + /* Get blue component. */ + tmp = color >> mode_info->blue_field_pos; + tmp &= (1 << mode_info->blue_mask_size) - 1; + tmp <<= 8 - mode_info->blue_mask_size; + tmp |= (1 << (8 - mode_info->blue_mask_size)) - 1; + *blue = tmp & 0xFF; + + /* Get alpha component. */ + if (source->mode_info->reserved_mask_size > 0) + { + tmp = color >> mode_info->reserved_field_pos; + tmp &= (1 << mode_info->reserved_mask_size) - 1; + tmp <<= 8 - mode_info->reserved_mask_size; + tmp |= (1 << (8 - mode_info->reserved_mask_size)) - 1; + } + else + /* If there is no alpha component, assume it opaque. */ + tmp = 255; + + *alpha = tmp & 0xFF; + } +} + +grub_err_t +grub_video_fb_fill_rect (grub_video_color_t color, int x, int y, + unsigned int width, unsigned int height) +{ + struct grub_video_fbblit_info target; + + /* Make sure there is something to do. */ + if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) + return GRUB_ERR_NONE; + if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) + return GRUB_ERR_NONE; + + /* Do not allow drawing out of viewport. */ + if (x < 0) + { + width += x; + x = 0; + } + if (y < 0) + { + height += y; + y = 0; + } + + if ((x + width) > render_target->viewport.width) + width = render_target->viewport.width - x; + if ((y + height) > render_target->viewport.height) + height = render_target->viewport.height - y; + + /* Add viewport offset. */ + x += render_target->viewport.x; + y += render_target->viewport.y; + + /* Use fbblit_info to encapsulate rendering. */ + target.mode_info = &render_target->mode_info; + target.data = render_target->data; + + /* Try to figure out more optimized version. Note that color is already + mapped to target format so we can make assumptions based on that. */ + if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbfill_direct32 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbfill_direct32 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbfill_direct24 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_565) + { + grub_video_fbfill_direct16 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_565) + { + grub_video_fbfill_direct16 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbfill_direct8 (&target, color, x, y, + width, height); + return GRUB_ERR_NONE; + } + + /* No optimized version found, use default (slow) filler. */ + grub_video_fbfill (&target, color, x, y, width, height); + + return GRUB_ERR_NONE; +} + +/* NOTE: This function assumes that given coordinates are within bounds of + handled data. */ +static void +common_blitter (struct grub_video_fbblit_info *target, + struct grub_video_fbblit_info *source, + enum grub_video_blit_operators oper, int x, int y, + unsigned int width, unsigned int height, + int offset_x, int offset_y) +{ + if (oper == GRUB_VIDEO_BLIT_REPLACE) + { + /* Try to figure out more optimized version for replace operator. */ + if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbblit_replace_directN (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbblit_replace_BGRX8888_RGBX8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) + { + grub_video_fbblit_replace_BGR888_RGBX8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbblit_replace_RGB888_RGBX8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbblit_replace_index_RGBX8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbblit_replace_BGRX8888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbblit_replace_RGBX8888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) + { + grub_video_fbblit_replace_BGR888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbblit_replace_directN (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbblit_replace_index_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbblit_replace_directN (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbblit_replace_directN (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + + /* No optimized replace operator found, use default (slow) blitter. */ + grub_video_fbblit_replace (target, source, x, y, width, height, + offset_x, offset_y); + } + else + { + /* Try to figure out more optimized blend operator. */ + if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbblit_blend_BGRA8888_RGBA8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbblit_blend_RGBA8888_RGBA8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) + { + grub_video_fbblit_blend_BGR888_RGBA8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbblit_blend_RGB888_RGBA8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbblit_blend_index_RGBA8888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + /* Note: There is really no alpha information here, so blend is + changed to replace. */ + + if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) + { + grub_video_fbblit_replace_BGRX8888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbblit_replace_RGBX8888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) + { + grub_video_fbblit_replace_BGR888_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbblit_replace_directN (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) + { + grub_video_fbblit_replace_index_RGB888 (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } + + /* No optimized blend operation found, use default (slow) blitter. */ + grub_video_fbblit_blend (target, source, x, y, width, height, + offset_x, offset_y); + } +} + +grub_err_t +grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, + enum grub_video_blit_operators oper, int x, int y, + int offset_x, int offset_y, + unsigned int width, unsigned int height) +{ + struct grub_video_fbblit_info source; + struct grub_video_fbblit_info target; + + /* Make sure there is something to do. */ + if ((width == 0) || (height == 0)) + return GRUB_ERR_NONE; + if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) + return GRUB_ERR_NONE; + if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) + return GRUB_ERR_NONE; + if ((x + (int)bitmap->mode_info.width) < 0) + return GRUB_ERR_NONE; + if ((y + (int)bitmap->mode_info.height) < 0) + return GRUB_ERR_NONE; + if ((offset_x >= (int)bitmap->mode_info.width) + || (offset_x + (int)width < 0)) + return GRUB_ERR_NONE; + if ((offset_y >= (int)bitmap->mode_info.height) + || (offset_y + (int)height < 0)) + return GRUB_ERR_NONE; + + /* If we have negative coordinates, optimize drawing to minimum. */ + if (offset_x < 0) + { + width += offset_x; + x -= offset_x; + offset_x = 0; + } + + if (offset_y < 0) + { + height += offset_y; + y -= offset_y; + offset_y = 0; + } + + if (x < 0) + { + width += x; + offset_x -= x; + x = 0; + } + + if (y < 0) + { + height += y; + offset_y -= y; + y = 0; + } + + /* Do not allow drawing out of viewport. */ + if ((x + width) > render_target->viewport.width) + width = render_target->viewport.width - x; + if ((y + height) > render_target->viewport.height) + height = render_target->viewport.height - y; + + if ((offset_x + width) > bitmap->mode_info.width) + width = bitmap->mode_info.width - offset_x; + if ((offset_y + height) > bitmap->mode_info.height) + height = bitmap->mode_info.height - offset_y; + + /* Limit drawing to source render target dimensions. */ + if (width > bitmap->mode_info.width) + width = bitmap->mode_info.width; + + if (height > bitmap->mode_info.height) + height = bitmap->mode_info.height; + + /* Add viewport offset. */ + x += render_target->viewport.x; + y += render_target->viewport.y; + + /* Use fbblit_info to encapsulate rendering. */ + source.mode_info = &bitmap->mode_info; + source.data = bitmap->data; + target.mode_info = &render_target->mode_info; + target.data = render_target->data; + + /* Do actual blitting. */ + common_blitter (&target, &source, oper, x, y, width, height, + offset_x, offset_y); + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source, + enum grub_video_blit_operators oper, + int x, int y, int offset_x, int offset_y, + unsigned int width, unsigned int height) +{ + struct grub_video_fbblit_info source_info; + struct grub_video_fbblit_info target_info; + + /* Make sure there is something to do. */ + if ((width == 0) || (height == 0)) + return GRUB_ERR_NONE; + if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) + return GRUB_ERR_NONE; + if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) + return GRUB_ERR_NONE; + if ((x + (int)source->mode_info.width) < 0) + return GRUB_ERR_NONE; + if ((y + (int)source->mode_info.height) < 0) + return GRUB_ERR_NONE; + if ((offset_x >= (int)source->mode_info.width) + || (offset_x + (int)width < 0)) + return GRUB_ERR_NONE; + if ((offset_y >= (int)source->mode_info.height) + || (offset_y + (int)height < 0)) + return GRUB_ERR_NONE; + + /* If we have negative coordinates, optimize drawing to minimum. */ + if (offset_x < 0) + { + width += offset_x; + x -= offset_x; + offset_x = 0; + } + + if (offset_y < 0) + { + height += offset_y; + y -= offset_y; + offset_y = 0; + } + + if (x < 0) + { + width += x; + offset_x -= x; + x = 0; + } + + if (y < 0) + { + height += y; + offset_y -= y; + y = 0; + } + + /* Do not allow drawing out of viewport. */ + if ((x + width) > render_target->viewport.width) + width = render_target->viewport.width - x; + if ((y + height) > render_target->viewport.height) + height = render_target->viewport.height - y; + + if ((offset_x + width) > source->mode_info.width) + width = source->mode_info.width - offset_x; + if ((offset_y + height) > source->mode_info.height) + height = source->mode_info.height - offset_y; + + /* Limit drawing to source render target dimensions. */ + if (width > source->mode_info.width) + width = source->mode_info.width; + + if (height > source->mode_info.height) + height = source->mode_info.height; + + /* Add viewport offset. */ + x += render_target->viewport.x; + y += render_target->viewport.y; + + /* Use fbblit_info to encapsulate rendering. */ + source_info.mode_info = &source->mode_info; + source_info.data = source->data; + target_info.mode_info = &render_target->mode_info; + target_info.data = render_target->data; + + /* Do actual blitting. */ + common_blitter (&target_info, &source_info, oper, x, y, width, height, + offset_x, offset_y); + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_scroll (grub_video_color_t color, int dx, int dy) +{ + int width; + int height; + int src_x; + int src_y; + int dst_x; + int dst_y; + + /* 1. Check if we have something to do. */ + if ((dx == 0) && (dy == 0)) + return GRUB_ERR_NONE; + + width = render_target->viewport.width - grub_abs (dx); + height = render_target->viewport.height - grub_abs (dy); + + if (dx < 0) + { + src_x = render_target->viewport.x - dx; + dst_x = render_target->viewport.x; + } + else + { + src_x = render_target->viewport.x; + dst_x = render_target->viewport.x + dx; + } + + if (dy < 0) + { + src_y = render_target->viewport.y - dy; + dst_y = render_target->viewport.y; + } + else + { + src_y = render_target->viewport.y; + dst_y = render_target->viewport.y + dy; + } + + /* 2. Check if there is need to copy data. */ + if ((grub_abs (dx) < render_target->viewport.width) + && (grub_abs (dy) < render_target->viewport.height)) + { + /* 3. Move data in render target. */ + struct grub_video_fbblit_info target; + grub_uint8_t *src; + grub_uint8_t *dst; + int j; + + 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); + } + else + /* 3b. Move data downwards. */ + for (j = (height - 1); j >= 0; 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); + } + } + + /* 4. Fill empty space with specified color. In this implementation + there might be colliding areas but at the moment there is no need + to optimize this. */ + + /* 4a. Fill top & bottom parts. */ + if (dy > 0) + grub_video_fb_fill_rect (color, 0, 0, render_target->viewport.width, dy); + else if (dy < 0) + { + if (render_target->viewport.height < grub_abs (dy)) + dy = -render_target->viewport.height; + + grub_video_fb_fill_rect (color, 0, render_target->viewport.height + dy, + render_target->viewport.width, -dy); + } + + /* 4b. Fill left & right parts. */ + if (dx > 0) + grub_video_fb_fill_rect (color, 0, 0, + dx, render_target->viewport.height); + else if (dx < 0) + { + if (render_target->viewport.width < grub_abs (dx)) + dx = -render_target->viewport.width; + + grub_video_fb_fill_rect (color, render_target->viewport.width + dx, 0, + -dx, render_target->viewport.height); + } + + return GRUB_ERR_NONE; +} + + +grub_err_t +grub_video_fb_create_render_target (struct grub_video_fbrender_target **result, + unsigned int width, unsigned int height, + unsigned int mode_type __attribute__ ((unused))) +{ + struct grub_video_fbrender_target *target; + unsigned int size; + + /* Validate arguments. */ + if ((! result) + || (width == 0) + || (height == 0)) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "invalid argument given."); + + /* Allocate memory for render target. */ + target = grub_malloc (sizeof (struct grub_video_fbrender_target)); + if (! target) + return grub_errno; + + /* TODO: Implement other types too. + Currently only 32bit render targets are supported. */ + + /* Mark render target as allocated. */ + target->is_allocated = 1; + + /* Maximize viewport. */ + target->viewport.x = 0; + target->viewport.y = 0; + target->viewport.width = width; + target->viewport.height = height; + + /* Setup render target format. */ + target->mode_info.width = width; + target->mode_info.height = height; + target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB + | GRUB_VIDEO_MODE_TYPE_ALPHA; + target->mode_info.bpp = 32; + target->mode_info.bytes_per_pixel = 4; + target->mode_info.pitch = target->mode_info.bytes_per_pixel * width; + target->mode_info.number_of_colors = palette_size; /* Emulated palette. */ + target->mode_info.red_mask_size = 8; + target->mode_info.red_field_pos = 0; + target->mode_info.green_mask_size = 8; + target->mode_info.green_field_pos = 8; + target->mode_info.blue_mask_size = 8; + target->mode_info.blue_field_pos = 16; + target->mode_info.reserved_mask_size = 8; + target->mode_info.reserved_field_pos = 24; + + target->mode_info.blit_format = grub_video_get_blit_format (&target->mode_info); + + /* Calculate size needed for the data. */ + size = (width * target->mode_info.bytes_per_pixel) * height; + + target->data = grub_malloc (size); + if (! target->data) + { + grub_free (target); + return grub_errno; + } + + /* Clear render target with black and maximum transparency. */ + grub_memset (target->data, 0, size); + + /* TODO: Add render target to render target list. */ + + /* Save result to caller. */ + *result = target; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result, + const struct grub_video_mode_info *mode_info, + void *ptr) +{ + struct grub_video_fbrender_target *target; + unsigned y; + + /* Allocate memory for render target. */ + target = grub_malloc (sizeof (struct grub_video_fbrender_target)); + if (! target) + return grub_errno; + + /* Mark framebuffer memory as non allocated. */ + target->is_allocated = 0; + target->data = ptr; + + grub_memcpy (&(target->mode_info), mode_info, sizeof (target->mode_info)); + + /* Reset viewport to match new mode. */ + target->viewport.x = 0; + target->viewport.y = 0; + target->viewport.width = mode_info->width; + target->viewport.height = mode_info->height; + + /* Clear render target with black and maximum transparency. */ + for (y = 0; y < mode_info->height; y++) + grub_memset (target->data + mode_info->pitch * y, 0, + mode_info->bytes_per_pixel * mode_info->width); + + /* Save result to caller. */ + *result = target; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target) +{ + /* If there is no target, then just return without error. */ + if (! target) + return GRUB_ERR_NONE; + + /* TODO: Delist render target from render target list. */ + + /* If this is software render target, free it's memory. */ + if (target->is_allocated) + grub_free (target->data); + + /* Free render target. */ + grub_free (target); + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *target) +{ + if (! target->data) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "invalid render target given."); + + render_target = target; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_video_fb_get_active_render_target (struct grub_video_fbrender_target **target) +{ + *target = render_target; + + return GRUB_ERR_NONE; +} diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index 1670a737d..0244b9016 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -16,43 +16,17 @@ * along with GRUB. If not, see . */ +#define grub_video_render_target grub_video_fbrender_target + #include #include #include #include -#include -#include -#include #include #include #include #include #include -#include - -/* Specify "standard" VGA palette, some video cards may - need this and this will also be used when using RGB modes. */ -static struct grub_vbe_palette_data vga_colors[16] = - { - // {B, G, R, A} - {0x00, 0x00, 0x00, 0x00}, // 0 = black - {0xA8, 0x00, 0x00, 0x00}, // 1 = blue - {0x00, 0xA8, 0x00, 0x00}, // 2 = green - {0xA8, 0xA8, 0x00, 0x00}, // 3 = cyan - {0x00, 0x00, 0xA8, 0x00}, // 4 = red - {0xA8, 0x00, 0xA8, 0x00}, // 5 = magenta - {0x00, 0x54, 0xA8, 0x00}, // 6 = brown - {0xA8, 0xA8, 0xA8, 0x00}, // 7 = light gray - - {0x54, 0x54, 0x54, 0x00}, // 8 = dark gray - {0xFE, 0x54, 0x54, 0x00}, // 9 = bright blue - {0x54, 0xFE, 0x54, 0x00}, // 10 = bright green - {0xFE, 0xFE, 0x54, 0x00}, // 11 = bright cyan - {0x54, 0x54, 0xFE, 0x00}, // 12 = bright red - {0xFE, 0x54, 0xFE, 0x00}, // 13 = bright magenta - {0x54, 0xFE, 0xFE, 0x00}, // 14 = yellow - {0xFE, 0xFE, 0xFE, 0x00} // 15 = white - }; static int vbe_detected = -1; @@ -61,17 +35,16 @@ static struct grub_vbe_mode_info_block active_mode_info; static struct { - struct grub_video_render_target render_target; + struct grub_video_mode_info mode_info; + struct grub_video_render_target *render_target; unsigned int bytes_per_scan_line; unsigned int bytes_per_pixel; grub_uint32_t active_mode; grub_uint8_t *ptr; int index_color_mode; - struct grub_video_palette_data palette[256]; } framebuffer; -static struct grub_video_render_target *render_target; static grub_uint32_t initial_mode; static grub_uint32_t mode_in_use = 0x55aa; static grub_uint16_t *mode_list; @@ -142,6 +115,7 @@ grub_vbe_set_video_mode (grub_uint32_t mode, { grub_vbe_status_t status; grub_uint32_t old_mode; + grub_err_t err; /* Make sure that VBE is supported. */ grub_vbe_probe (0); @@ -239,15 +213,26 @@ grub_vbe_set_video_mode (grub_uint32_t mode, { struct grub_vbe_palette_data *palette = (struct grub_vbe_palette_data *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; + unsigned i; /* Make sure that the BIOS can reach the palette. */ - grub_memcpy (palette, vga_colors, sizeof (vga_colors)); - status = grub_vbe_bios_set_palette_data (sizeof (vga_colors) - / sizeof (struct grub_vbe_palette_data), - 0, - palette); + for (i = 0; i < GRUB_VIDEO_FBSTD_NUMCOLORS; i++) + { + palette[i].red = grub_video_fbstd_colors[i].r; + palette[i].green = grub_video_fbstd_colors[i].g; + palette[i].blue = grub_video_fbstd_colors[i].b; + palette[i].alignment = 0; + } + + status = grub_vbe_bios_set_palette_data (GRUB_VIDEO_FBSTD_NUMCOLORS, + 0, palette); /* Just ignore the status. */ + err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS, + grub_video_fbstd_colors); + if (err) + return err; + } } @@ -326,43 +311,6 @@ grub_vbe_get_video_mode_info (grub_uint32_t mode, return GRUB_ERR_NONE; } -grub_uint8_t * -grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source, - grub_uint32_t x, grub_uint32_t y) -{ - grub_uint8_t *ptr = 0; - - switch (source->mode_info->bpp) - { - case 32: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 4; - break; - - case 24: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 3; - break; - - case 16: - case 15: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 2; - break; - - case 8: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x; - break; - } - - return ptr; -} - static grub_err_t grub_video_vbe_init (void) { @@ -398,16 +346,15 @@ grub_video_vbe_init (void) { /* Free allocated resources. */ grub_free (mode_list); - mode_list = 0; + mode_list = NULL; return grub_errno; } - /* Reset frame buffer and render target variables. */ + /* Reset frame buffer. */ grub_memset (&framebuffer, 0, sizeof(framebuffer)); - render_target = &framebuffer.render_target; - return GRUB_ERR_NONE; + return grub_video_fb_init (); } static grub_err_t @@ -423,12 +370,11 @@ grub_video_vbe_fini (void) /* TODO: Free any resources allocated by driver. */ grub_free (mode_list); - mode_list = 0; + mode_list = NULL; /* TODO: destroy render targets. */ - /* Return success to caller. */ - return GRUB_ERR_NONE; + return grub_video_fb_fini (); } static grub_err_t @@ -440,7 +386,6 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, struct grub_vbe_mode_info_block best_mode_info; grub_uint32_t best_mode = 0; int depth; - unsigned int i; /* Decode depth from mode_type. If it is zero, then autodetect. */ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK) @@ -520,6 +465,7 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, /* Try to initialize best mode found. */ if (best_mode != 0) { + grub_err_t err; /* If this fails, then we have mode selection heuristics problem, or adapter failure. */ grub_vbe_set_video_mode (best_mode, &active_mode_info); @@ -530,78 +476,54 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, in order to fasten later operations. */ mode_in_use = best_mode; - /* Reset render target to framebuffer one. */ - render_target = &framebuffer.render_target; - - /* Fill mode info details in framebuffer's render target. */ - render_target->mode_info.width = active_mode_info.x_resolution; - render_target->mode_info.height = active_mode_info.y_resolution; + /* Fill mode info details. */ + framebuffer.mode_info.width = active_mode_info.x_resolution; + framebuffer.mode_info.height = active_mode_info.y_resolution; if (framebuffer.index_color_mode) - render_target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; + framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; else - render_target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB; + framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB; - render_target->mode_info.bpp = active_mode_info.bits_per_pixel; - render_target->mode_info.bytes_per_pixel = framebuffer.bytes_per_pixel; - render_target->mode_info.pitch = framebuffer.bytes_per_scan_line; - render_target->mode_info.number_of_colors = 256; /* TODO: fix me. */ - render_target->mode_info.red_mask_size = active_mode_info.red_mask_size; - render_target->mode_info.red_field_pos = active_mode_info.red_field_position; - render_target->mode_info.green_mask_size = active_mode_info.green_mask_size; - render_target->mode_info.green_field_pos = active_mode_info.green_field_position; - render_target->mode_info.blue_mask_size = active_mode_info.blue_mask_size; - render_target->mode_info.blue_field_pos = active_mode_info.blue_field_position; - render_target->mode_info.reserved_mask_size = active_mode_info.rsvd_mask_size; - render_target->mode_info.reserved_field_pos = active_mode_info.rsvd_field_position; + framebuffer.mode_info.bpp = active_mode_info.bits_per_pixel; + framebuffer.mode_info.bytes_per_pixel = framebuffer.bytes_per_pixel; + framebuffer.mode_info.pitch = framebuffer.bytes_per_scan_line; + framebuffer.mode_info.number_of_colors = 256; /* TODO: fix me. */ + framebuffer.mode_info.red_mask_size = active_mode_info.red_mask_size; + framebuffer.mode_info.red_field_pos = active_mode_info.red_field_position; + framebuffer.mode_info.green_mask_size = active_mode_info.green_mask_size; + framebuffer.mode_info.green_field_pos = active_mode_info.green_field_position; + framebuffer.mode_info.blue_mask_size = active_mode_info.blue_mask_size; + framebuffer.mode_info.blue_field_pos = active_mode_info.blue_field_position; + framebuffer.mode_info.reserved_mask_size = active_mode_info.rsvd_mask_size; + framebuffer.mode_info.reserved_field_pos = active_mode_info.rsvd_field_position; - render_target->mode_info.blit_format = grub_video_get_blit_format (&render_target->mode_info); + framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info); - /* Reset viewport to match new mode. */ - render_target->viewport.x = 0; - render_target->viewport.y = 0; - render_target->viewport.width = active_mode_info.x_resolution; - render_target->viewport.height = active_mode_info.y_resolution; + err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target, &framebuffer.mode_info, framebuffer.ptr); - /* Set framebuffer pointer and mark it as non allocated. */ - render_target->is_allocated = 0; - render_target->data = framebuffer.ptr; + if (err) + return err; + + err = grub_video_fb_set_active_render_target (framebuffer.render_target); + + if (err) + return err; /* Copy default palette to initialize emulated palette. */ - for (i = 0; - i < (sizeof (vga_colors) - / sizeof (struct grub_vbe_palette_data)); - i++) - { - framebuffer.palette[i].r = vga_colors[i].red; - framebuffer.palette[i].g = vga_colors[i].green; - framebuffer.palette[i].b = vga_colors[i].blue; - framebuffer.palette[i].a = 0xFF; - } - - return GRUB_ERR_NONE; + err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS, + grub_video_fbstd_colors); + return err; } /* Couldn't found matching mode. */ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found."); } -static grub_err_t -grub_video_vbe_get_info (struct grub_video_mode_info *mode_info) -{ - /* Copy mode info from active render target. */ - grub_memcpy (mode_info, &render_target->mode_info, - sizeof (struct grub_video_mode_info)); - - return GRUB_ERR_NONE; -} - static grub_err_t grub_video_vbe_set_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data) { - unsigned int i; - if (framebuffer.index_color_mode) { /* TODO: Implement setting indexed color mode palette to hardware. */ @@ -613,874 +535,8 @@ grub_video_vbe_set_palette (unsigned int start, unsigned int count, } /* Then set color to emulated palette. */ - for (i = 0; (i < count) && ((i + start) < 256); i++) - framebuffer.palette[start + i] = palette_data[i]; - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_get_palette (unsigned int start, unsigned int count, - struct grub_video_palette_data *palette_data) -{ - unsigned int i; - - /* Assume that we know everything from index color palette. */ - for (i = 0; (i < count) && ((i + start) < 256); i++) - palette_data[i] = framebuffer.palette[start + i]; - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_set_viewport (unsigned int x, unsigned int y, - unsigned int width, unsigned int height) -{ - /* Make sure viewport is withing screen dimensions. If viewport was set - to be out of the region, mark its size as zero. */ - if (x > active_mode_info.x_resolution) - { - x = 0; - width = 0; - } - - if (y > active_mode_info.y_resolution) - { - y = 0; - height = 0; - } - - if (x + width > active_mode_info.x_resolution) - width = active_mode_info.x_resolution - x; - - if (y + height > active_mode_info.y_resolution) - height = active_mode_info.y_resolution - y; - - render_target->viewport.x = x; - render_target->viewport.y = y; - render_target->viewport.width = width; - render_target->viewport.height = height; - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_get_viewport (unsigned int *x, unsigned int *y, - unsigned int *width, unsigned int *height) -{ - if (x) *x = render_target->viewport.x; - if (y) *y = render_target->viewport.y; - if (width) *width = render_target->viewport.width; - if (height) *height = render_target->viewport.height; - - return GRUB_ERR_NONE; -} - -/* Maps color name to target optimized color format. */ -static grub_video_color_t -grub_video_vbe_map_color (grub_uint32_t color_name) -{ - /* TODO: implement color theme mapping code. */ - - if (color_name < 256) - { - if ((render_target->mode_info.mode_type - & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) - return color_name; - else - { - grub_video_color_t color; - - color = grub_video_vbe_map_rgb (framebuffer.palette[color_name].r, - framebuffer.palette[color_name].g, - framebuffer.palette[color_name].b); - - return color; - } - } - - return 0; -} - -/* Maps RGB to target optimized color format. */ -grub_video_color_t -grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green, - grub_uint8_t blue) -{ - if ((render_target->mode_info.mode_type - & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) - { - int minindex = 0; - int delta = 0; - int tmp; - int val; - int i; - - /* Find best matching color. */ - for (i = 0; i < 256; i++) - { - val = framebuffer.palette[i].r - red; - tmp = val * val; - val = framebuffer.palette[i].g - green; - tmp += val * val; - val = framebuffer.palette[i].b - blue; - tmp += val * val; - - if (i == 0) - delta = tmp; - - if (tmp < delta) - { - delta = tmp; - minindex = i; - if (tmp == 0) - break; - } - } - - return minindex; - } - else if ((render_target->mode_info.mode_type - & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) - { - if (red == render_target->mode_info.fg_red - && green == render_target->mode_info.fg_green - && blue == render_target->mode_info.fg_blue) - return 1; - else - return 0; - } - else - { - grub_uint32_t value; - grub_uint8_t alpha = 255; /* Opaque color. */ - - red >>= 8 - render_target->mode_info.red_mask_size; - green >>= 8 - render_target->mode_info.green_mask_size; - blue >>= 8 - render_target->mode_info.blue_mask_size; - alpha >>= 8 - render_target->mode_info.reserved_mask_size; - - value = red << render_target->mode_info.red_field_pos; - value |= green << render_target->mode_info.green_field_pos; - value |= blue << render_target->mode_info.blue_field_pos; - value |= alpha << render_target->mode_info.reserved_field_pos; - - return value; - } - -} - -/* Maps RGBA to target optimized color format. */ -grub_video_color_t -grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green, - grub_uint8_t blue, grub_uint8_t alpha) -{ - if ((render_target->mode_info.mode_type - & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) - /* No alpha available in index color modes, just use - same value as in only RGB modes. */ - return grub_video_vbe_map_rgb (red, green, blue); - else if ((render_target->mode_info.mode_type - & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) - { - if (red == render_target->mode_info.fg_red - && green == render_target->mode_info.fg_green - && blue == render_target->mode_info.fg_blue - && alpha == render_target->mode_info.fg_alpha) - return 1; - else - return 0; - } - else - { - grub_uint32_t value; - - red >>= 8 - render_target->mode_info.red_mask_size; - green >>= 8 - render_target->mode_info.green_mask_size; - blue >>= 8 - render_target->mode_info.blue_mask_size; - alpha >>= 8 - render_target->mode_info.reserved_mask_size; - - value = red << render_target->mode_info.red_field_pos; - value |= green << render_target->mode_info.green_field_pos; - value |= blue << render_target->mode_info.blue_field_pos; - value |= alpha << render_target->mode_info.reserved_field_pos; - - return value; - } -} - -/* Splits target optimized format to components. */ -grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color, - grub_uint8_t *red, grub_uint8_t *green, - grub_uint8_t *blue, grub_uint8_t *alpha) -{ - struct grub_video_i386_vbeblit_info target_info; - - target_info.mode_info = &render_target->mode_info; - target_info.data = render_target->data; - - grub_video_vbe_unmap_color_int (&target_info, color, red, green, blue, alpha); - - return GRUB_ERR_NONE; -} - -/* Splits color in source format to components. */ -void -grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info * source, - grub_video_color_t color, - grub_uint8_t *red, grub_uint8_t *green, - grub_uint8_t *blue, grub_uint8_t *alpha) -{ - struct grub_video_mode_info *mode_info; - mode_info = source->mode_info; - - if ((mode_info->mode_type - & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) - { - /* If we have an out-of-bounds color, return transparent black. */ - if (color > 255) - { - *red = 0; - *green = 0; - *blue = 0; - *alpha = 0; - return; - } - - *red = framebuffer.palette[color].r; - *green = framebuffer.palette[color].g; - *blue = framebuffer.palette[color].b; - *alpha = framebuffer.palette[color].a; - return; - } - else if ((mode_info->mode_type - & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0) - { - if (color & 1) - { - *red = mode_info->fg_red; - *green = mode_info->fg_green; - *blue = mode_info->fg_blue; - *alpha = mode_info->fg_alpha; - } - else - { - *red = mode_info->bg_red; - *green = mode_info->bg_green; - *blue = mode_info->bg_blue; - *alpha = mode_info->bg_alpha; - } - } - else - { - grub_uint32_t tmp; - - /* Get red component. */ - tmp = color >> mode_info->red_field_pos; - tmp &= (1 << mode_info->red_mask_size) - 1; - tmp <<= 8 - mode_info->red_mask_size; - tmp |= (1 << (8 - mode_info->red_mask_size)) - 1; - *red = tmp & 0xFF; - - /* Get green component. */ - tmp = color >> mode_info->green_field_pos; - tmp &= (1 << mode_info->green_mask_size) - 1; - tmp <<= 8 - mode_info->green_mask_size; - tmp |= (1 << (8 - mode_info->green_mask_size)) - 1; - *green = tmp & 0xFF; - - /* Get blue component. */ - tmp = color >> mode_info->blue_field_pos; - tmp &= (1 << mode_info->blue_mask_size) - 1; - tmp <<= 8 - mode_info->blue_mask_size; - tmp |= (1 << (8 - mode_info->blue_mask_size)) - 1; - *blue = tmp & 0xFF; - - /* Get alpha component. */ - if (source->mode_info->reserved_mask_size > 0) - { - tmp = color >> mode_info->reserved_field_pos; - tmp &= (1 << mode_info->reserved_mask_size) - 1; - tmp <<= 8 - mode_info->reserved_mask_size; - tmp |= (1 << (8 - mode_info->reserved_mask_size)) - 1; - } - else - /* If there is no alpha component, assume it opaque. */ - tmp = 255; - - *alpha = tmp & 0xFF; - } -} - -static grub_err_t -grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y, - unsigned int width, unsigned int height) -{ - struct grub_video_i386_vbeblit_info target; - - /* Make sure there is something to do. */ - if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) - return GRUB_ERR_NONE; - if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) - return GRUB_ERR_NONE; - - /* Do not allow drawing out of viewport. */ - if (x < 0) - { - width += x; - x = 0; - } - if (y < 0) - { - height += y; - y = 0; - } - - if ((x + width) > render_target->viewport.width) - width = render_target->viewport.width - x; - if ((y + height) > render_target->viewport.height) - height = render_target->viewport.height - y; - - /* Add viewport offset. */ - x += render_target->viewport.x; - y += render_target->viewport.y; - - /* Use vbeblit_info to encapsulate rendering. */ - target.mode_info = &render_target->mode_info; - target.data = render_target->data; - - /* Try to figure out more optimized version. Note that color is already - mapped to target format so we can make assumptions based on that. */ - if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbefill_direct32 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - grub_video_i386_vbefill_direct32 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - grub_video_i386_vbefill_direct24 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_565) - { - grub_video_i386_vbefill_direct16 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_565) - { - grub_video_i386_vbefill_direct16 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbefill_direct8 (&target, color, x, y, - width, height); - return GRUB_ERR_NONE; - } - - /* No optimized version found, use default (slow) filler. */ - grub_video_i386_vbefill (&target, color, x, y, width, height); - - return GRUB_ERR_NONE; -} - -/* NOTE: This function assumes that given coordinates are within bounds of - handled data. */ -static void -common_blitter (struct grub_video_i386_vbeblit_info *target, - struct grub_video_i386_vbeblit_info *source, - enum grub_video_blit_operators oper, int x, int y, - unsigned int width, unsigned int height, - int offset_x, int offset_y) -{ - if (oper == GRUB_VIDEO_BLIT_REPLACE) - { - /* Try to figure out more optimized version for replace operator. */ - if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - grub_video_i386_vbeblit_replace_directN (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) - { - grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbeblit_replace_index_RGBX8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) - { - grub_video_i386_vbeblit_replace_BGR888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - grub_video_i386_vbeblit_replace_directN (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbeblit_replace_index_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbeblit_replace_directN (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbeblit_replace_directN (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - - /* No optimized replace operator found, use default (slow) blitter. */ - grub_video_i386_vbeblit_replace (target, source, x, y, width, height, - offset_x, offset_y); - } - else - { - /* Try to figure out more optimized blend operator. */ - if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) - { - grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbeblit_blend_index_RGBA8888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - /* Note: There is really no alpha information here, so blend is - changed to replace. */ - - if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888) - { - grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) - { - grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888) - { - grub_video_i386_vbeblit_replace_BGR888_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888) - { - grub_video_i386_vbeblit_replace_directN (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR) - { - grub_video_i386_vbeblit_replace_index_RGB888 (target, source, - x, y, width, height, - offset_x, offset_y); - return; - } - } - - /* No optimized blend operation found, use default (slow) blitter. */ - grub_video_i386_vbeblit_blend (target, source, x, y, width, height, - offset_x, offset_y); - } -} - -static grub_err_t -grub_video_vbe_blit_bitmap (struct grub_video_bitmap *bitmap, - enum grub_video_blit_operators oper, int x, int y, - int offset_x, int offset_y, - unsigned int width, unsigned int height) -{ - struct grub_video_i386_vbeblit_info source; - struct grub_video_i386_vbeblit_info target; - - /* Make sure there is something to do. */ - if ((width == 0) || (height == 0)) - return GRUB_ERR_NONE; - if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) - return GRUB_ERR_NONE; - if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) - return GRUB_ERR_NONE; - if ((x + (int)bitmap->mode_info.width) < 0) - return GRUB_ERR_NONE; - if ((y + (int)bitmap->mode_info.height) < 0) - return GRUB_ERR_NONE; - if ((offset_x >= (int)bitmap->mode_info.width) - || (offset_x + (int)width < 0)) - return GRUB_ERR_NONE; - if ((offset_y >= (int)bitmap->mode_info.height) - || (offset_y + (int)height < 0)) - return GRUB_ERR_NONE; - - /* If we have negative coordinates, optimize drawing to minimum. */ - if (offset_x < 0) - { - width += offset_x; - x -= offset_x; - offset_x = 0; - } - - if (offset_y < 0) - { - height += offset_y; - y -= offset_y; - offset_y = 0; - } - - if (x < 0) - { - width += x; - offset_x -= x; - x = 0; - } - - if (y < 0) - { - height += y; - offset_y -= y; - y = 0; - } - - /* Do not allow drawing out of viewport. */ - if ((x + width) > render_target->viewport.width) - width = render_target->viewport.width - x; - if ((y + height) > render_target->viewport.height) - height = render_target->viewport.height - y; - - if ((offset_x + width) > bitmap->mode_info.width) - width = bitmap->mode_info.width - offset_x; - if ((offset_y + height) > bitmap->mode_info.height) - height = bitmap->mode_info.height - offset_y; - - /* Limit drawing to source render target dimensions. */ - if (width > bitmap->mode_info.width) - width = bitmap->mode_info.width; - - if (height > bitmap->mode_info.height) - height = bitmap->mode_info.height; - - /* Add viewport offset. */ - x += render_target->viewport.x; - y += render_target->viewport.y; - - /* Use vbeblit_info to encapsulate rendering. */ - source.mode_info = &bitmap->mode_info; - source.data = bitmap->data; - target.mode_info = &render_target->mode_info; - target.data = render_target->data; - - /* Do actual blitting. */ - common_blitter (&target, &source, oper, x, y, width, height, - offset_x, offset_y); - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_blit_render_target (struct grub_video_render_target *source, - enum grub_video_blit_operators oper, - int x, int y, int offset_x, int offset_y, - unsigned int width, unsigned int height) -{ - struct grub_video_i386_vbeblit_info source_info; - struct grub_video_i386_vbeblit_info target_info; - - /* Make sure there is something to do. */ - if ((width == 0) || (height == 0)) - return GRUB_ERR_NONE; - if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0)) - return GRUB_ERR_NONE; - if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0)) - return GRUB_ERR_NONE; - if ((x + (int)source->mode_info.width) < 0) - return GRUB_ERR_NONE; - if ((y + (int)source->mode_info.height) < 0) - return GRUB_ERR_NONE; - if ((offset_x >= (int)source->mode_info.width) - || (offset_x + (int)width < 0)) - return GRUB_ERR_NONE; - if ((offset_y >= (int)source->mode_info.height) - || (offset_y + (int)height < 0)) - return GRUB_ERR_NONE; - - /* If we have negative coordinates, optimize drawing to minimum. */ - if (offset_x < 0) - { - width += offset_x; - x -= offset_x; - offset_x = 0; - } - - if (offset_y < 0) - { - height += offset_y; - y -= offset_y; - offset_y = 0; - } - - if (x < 0) - { - width += x; - offset_x -= x; - x = 0; - } - - if (y < 0) - { - height += y; - offset_y -= y; - y = 0; - } - - /* Do not allow drawing out of viewport. */ - if ((x + width) > render_target->viewport.width) - width = render_target->viewport.width - x; - if ((y + height) > render_target->viewport.height) - height = render_target->viewport.height - y; - - if ((offset_x + width) > source->mode_info.width) - width = source->mode_info.width - offset_x; - if ((offset_y + height) > source->mode_info.height) - height = source->mode_info.height - offset_y; - - /* Limit drawing to source render target dimensions. */ - if (width > source->mode_info.width) - width = source->mode_info.width; - - if (height > source->mode_info.height) - height = source->mode_info.height; - - /* Add viewport offset. */ - x += render_target->viewport.x; - y += render_target->viewport.y; - - /* Use vbeblit_info to encapsulate rendering. */ - source_info.mode_info = &source->mode_info; - source_info.data = source->data; - target_info.mode_info = &render_target->mode_info; - target_info.data = render_target->data; - - /* Do actual blitting. */ - common_blitter (&target_info, &source_info, oper, x, y, width, height, - offset_x, offset_y); - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_scroll (grub_video_color_t color, int dx, int dy) -{ - int width; - int height; - int src_x; - int src_y; - int dst_x; - int dst_y; - - /* 1. Check if we have something to do. */ - if ((dx == 0) && (dy == 0)) - return GRUB_ERR_NONE; - - width = render_target->viewport.width - grub_abs (dx); - height = render_target->viewport.height - grub_abs (dy); - - if (dx < 0) - { - src_x = render_target->viewport.x - dx; - dst_x = render_target->viewport.x; - } - else - { - src_x = render_target->viewport.x; - dst_x = render_target->viewport.x + dx; - } - - if (dy < 0) - { - src_y = render_target->viewport.y - dy; - dst_y = render_target->viewport.y; - } - else - { - src_y = render_target->viewport.y; - dst_y = render_target->viewport.y + dy; - } - - /* 2. Check if there is need to copy data. */ - if ((grub_abs (dx) < render_target->viewport.width) - && (grub_abs (dy) < render_target->viewport.height)) - { - /* 3. Move data in render target. */ - struct grub_video_i386_vbeblit_info target; - grub_uint8_t *src; - grub_uint8_t *dst; - int j; - - 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_vbe_get_video_ptr (&target, dst_x, dst_y + j); - src = grub_video_vbe_get_video_ptr (&target, src_x, src_y + j); - grub_memmove (dst, src, - width * target.mode_info->bytes_per_pixel); - } - else - /* 3b. Move data downwards. */ - for (j = (height - 1); j >= 0; j--) - { - dst = grub_video_vbe_get_video_ptr (&target, dst_x, dst_y + j); - src = grub_video_vbe_get_video_ptr (&target, src_x, src_y + j); - grub_memmove (dst, src, - width * target.mode_info->bytes_per_pixel); - } - } - - /* 4. Fill empty space with specified color. In this implementation - there might be colliding areas but at the moment there is no need - to optimize this. */ - - /* 4a. Fill top & bottom parts. */ - if (dy > 0) - grub_video_vbe_fill_rect (color, 0, 0, render_target->viewport.width, dy); - else if (dy < 0) - { - if (render_target->viewport.height < grub_abs (dy)) - dy = -render_target->viewport.height; - - grub_video_vbe_fill_rect (color, 0, render_target->viewport.height + dy, - render_target->viewport.width, -dy); - } - - /* 4b. Fill left & right parts. */ - if (dx > 0) - grub_video_vbe_fill_rect (color, 0, 0, - dx, render_target->viewport.height); - else if (dx < 0) - { - if (render_target->viewport.width < grub_abs (dx)) - dx = -render_target->viewport.width; - - grub_video_vbe_fill_rect (color, render_target->viewport.width + dx, 0, - -dx, render_target->viewport.height); - } - - return GRUB_ERR_NONE; + return grub_video_fb_set_palette (start, count, palette_data); } static grub_err_t @@ -1490,129 +546,31 @@ grub_video_vbe_swap_buffers (void) return GRUB_ERR_NONE; } -static grub_err_t -grub_video_vbe_create_render_target (struct grub_video_render_target **result, - unsigned int width, unsigned int height, - unsigned int mode_type __attribute__ ((unused))) -{ - struct grub_video_render_target *target; - unsigned int size; - - /* Validate arguments. */ - if ((! result) - || (width == 0) - || (height == 0)) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid argument given."); - - /* Allocate memory for render target. */ - target = grub_malloc (sizeof (struct grub_video_render_target)); - if (! target) - return grub_errno; - - /* TODO: Implement other types too. - Currently only 32bit render targets are supported. */ - - /* Mark render target as allocated. */ - target->is_allocated = 1; - - /* Maximize viewport. */ - target->viewport.x = 0; - target->viewport.y = 0; - target->viewport.width = width; - target->viewport.height = height; - - /* Setup render target format. */ - target->mode_info.width = width; - target->mode_info.height = height; - target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB - | GRUB_VIDEO_MODE_TYPE_ALPHA; - target->mode_info.bpp = 32; - target->mode_info.bytes_per_pixel = 4; - target->mode_info.pitch = target->mode_info.bytes_per_pixel * width; - target->mode_info.number_of_colors = 256; /* Emulated palette. */ - target->mode_info.red_mask_size = 8; - target->mode_info.red_field_pos = 0; - target->mode_info.green_mask_size = 8; - target->mode_info.green_field_pos = 8; - target->mode_info.blue_mask_size = 8; - target->mode_info.blue_field_pos = 16; - target->mode_info.reserved_mask_size = 8; - target->mode_info.reserved_field_pos = 24; - - target->mode_info.blit_format = grub_video_get_blit_format (&target->mode_info); - - /* Calculate size needed for the data. */ - size = (width * target->mode_info.bytes_per_pixel) * height; - - target->data = grub_malloc (size); - if (! target->data) - { - grub_free (target); - return grub_errno; - } - - /* Clear render target with black and maximum transparency. */ - grub_memset (target->data, 0, size); - - /* TODO: Add render target to render target list. */ - - /* Save result to caller. */ - *result = target; - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_video_vbe_delete_render_target (struct grub_video_render_target *target) -{ - /* If there is no target, then just return without error. */ - if (! target) - return GRUB_ERR_NONE; - - /* TODO: Delist render target from render target list. */ - - /* If this is software render target, free it's memory. */ - if (target->is_allocated) - grub_free (target->data); - - /* Free render target. */ - grub_free (target); - - return GRUB_ERR_NONE; -} - static grub_err_t grub_video_vbe_set_active_render_target (struct grub_video_render_target *target) { - if (target == GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER) - { - render_target = &framebuffer.render_target; + if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY) + target = framebuffer.render_target; - return GRUB_ERR_NONE; - } - - if (target == GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "double buffering not implemented yet."); - - if (! target->data) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid render target given."); - - render_target = target; - - return GRUB_ERR_NONE; + return grub_video_fb_set_active_render_target (target); } static grub_err_t -grub_video_vbe_get_active_render_target (struct grub_video_render_target **target) +grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info, + void **framebuf) { - *target = render_target; + grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info)); + *framebuf = (char *) framebuffer.ptr; + + grub_free (mode_list); + mode_list = NULL; + + grub_video_fb_fini (); return GRUB_ERR_NONE; } + static struct grub_video_adapter grub_video_vbe_adapter = { .name = "VESA BIOS Extension Video Driver", @@ -1620,24 +578,25 @@ static struct grub_video_adapter grub_video_vbe_adapter = .init = grub_video_vbe_init, .fini = grub_video_vbe_fini, .setup = grub_video_vbe_setup, - .get_info = grub_video_vbe_get_info, + .get_info = grub_video_fb_get_info, + .get_info_and_fini = grub_video_vbe_get_info_and_fini, .set_palette = grub_video_vbe_set_palette, - .get_palette = grub_video_vbe_get_palette, - .set_viewport = grub_video_vbe_set_viewport, - .get_viewport = grub_video_vbe_get_viewport, - .map_color = grub_video_vbe_map_color, - .map_rgb = grub_video_vbe_map_rgb, - .map_rgba = grub_video_vbe_map_rgba, - .unmap_color = grub_video_vbe_unmap_color, - .fill_rect = grub_video_vbe_fill_rect, - .blit_bitmap = grub_video_vbe_blit_bitmap, - .blit_render_target = grub_video_vbe_blit_render_target, - .scroll = grub_video_vbe_scroll, + .get_palette = grub_video_fb_get_palette, + .set_viewport = grub_video_fb_set_viewport, + .get_viewport = grub_video_fb_get_viewport, + .map_color = grub_video_fb_map_color, + .map_rgb = grub_video_fb_map_rgb, + .map_rgba = grub_video_fb_map_rgba, + .unmap_color = grub_video_fb_unmap_color, + .fill_rect = grub_video_fb_fill_rect, + .blit_bitmap = grub_video_fb_blit_bitmap, + .blit_render_target = grub_video_fb_blit_render_target, + .scroll = grub_video_fb_scroll, .swap_buffers = grub_video_vbe_swap_buffers, - .create_render_target = grub_video_vbe_create_render_target, - .delete_render_target = grub_video_vbe_delete_render_target, + .create_render_target = grub_video_fb_create_render_target, + .delete_render_target = grub_video_fb_delete_render_target, .set_active_render_target = grub_video_vbe_set_active_render_target, - .get_active_render_target = grub_video_vbe_get_active_render_target, + .get_active_render_target = grub_video_fb_get_active_render_target, .next = 0 }; diff --git a/video/video.c b/video/video.c index c22947b63..36ebfd1b8 100644 --- a/video/video.c +++ b/video/video.c @@ -93,6 +93,24 @@ grub_video_get_info (struct grub_video_mode_info *mode_info) return grub_video_adapter_active->get_info (mode_info); } +/* Get information about active video mode. */ +grub_err_t +grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, + void **framebuffer) +{ + grub_err_t err; + + if (! grub_video_adapter_active) + return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + + err = grub_video_adapter_active->get_info_and_fini (mode_info, framebuffer); + if (err) + return err; + + grub_video_adapter_active = 0; + return GRUB_ERR_NONE; +} + /* Determine optimized blitting formation for specified video mode info. */ enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info) @@ -380,7 +398,7 @@ grub_video_get_active_render_target (struct grub_video_render_target **target) } grub_err_t -grub_video_set_mode (char *modestring, +grub_video_set_mode (const char *modestring, int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p, struct grub_video_mode_info *mode_info)) { @@ -695,8 +713,6 @@ grub_video_set_mode (char *modestring, /* Initialize Video API module. */ GRUB_MOD_INIT(video_video) { - grub_video_adapter_active = 0; - grub_video_adapter_list = 0; } /* Finalize Video API module. */ From c0d8b5d42a94ac8cb6884ae40997a80bbb427eb3 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 13:31:09 +0000 Subject: [PATCH 29/45] 2009-08-14 Vladimir Serbinenko Split ufs.mod into ufs1.mod and ufs2.mod. * conf/common.rmk (grub_probe_SOURCES): Add fs/ufs2.c. (grub_fstest_SOURCES): Likewise. (pkglib_MODULES): Remove ufs.mod. Add ufs1.mod and ufs2.mod. (ufs_mod_SOURCES): Remove. (ufs_mod_CFLAGS): Likewise. (ufs_mod_LDFLAGS): Likewise. (ufs1_mod_SOURCES): New variable. (ufs1_mod_CFLAGS): Likewise. (ufs1_mod_LDFLAGS): Likewise. (ufs2_mod_SOURCES): New variable. (ufs2_mod_CFLAGS): Likewise. (ufs2_mod_LDFLAGS): Likewise. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add fs/ufs2.c. * conf/i386-efi.rmk (util/i386/efi/grub-mkimage.c_DEPENDENCIES): Likewise. (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. (grub_setup_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64.rmk (grub_emu_SOURCES): Likewise. (grub_setup_SOURCES): Likewise. * conf/x86_64-efi.rmk (util/i386/efi/grub-mkimage.c_DEPENDENCIES): Likewise. * fs/ufs2.c: New file. * fs/ufs.c: Separate UFS1 from UFS2 by using preprocessor. --- ChangeLog | 31 +++++ conf/common.rmk | 19 ++- conf/i386-coreboot.rmk | 2 +- conf/i386-efi.rmk | 4 +- conf/i386-ieee1275.rmk | 2 +- conf/i386-pc.rmk | 4 +- conf/powerpc-ieee1275.rmk | 2 +- conf/sparc64-ieee1275.rmk | 4 +- conf/x86_64-efi.rmk | 4 +- fs/ufs.c | 276 +++++++++++++++++++------------------- fs/ufs2.c | 3 + 11 files changed, 192 insertions(+), 159 deletions(-) create mode 100644 fs/ufs2.c diff --git a/ChangeLog b/ChangeLog index 9ea7886d6..a4ec76db9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2009-08-14 Vladimir Serbinenko + + Split ufs.mod into ufs1.mod and ufs2.mod. + + * conf/common.rmk (grub_probe_SOURCES): Add fs/ufs2.c. + (grub_fstest_SOURCES): Likewise. + (pkglib_MODULES): Remove ufs.mod. Add ufs1.mod and ufs2.mod. + (ufs_mod_SOURCES): Remove. + (ufs_mod_CFLAGS): Likewise. + (ufs_mod_LDFLAGS): Likewise. + (ufs1_mod_SOURCES): New variable. + (ufs1_mod_CFLAGS): Likewise. + (ufs1_mod_LDFLAGS): Likewise. + (ufs1_mod_SOURCES): New variable. + (ufs1_mod_CFLAGS): Likewise. + (ufs1_mod_LDFLAGS): Likewise. + * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add fs/ufs2.c. + * conf/i386-efi.rmk (util/i386/efi/grub-mkimage.c_DEPENDENCIES): + Likewise. + (grub_emu_SOURCES): Likewise. + * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. + (grub_setup_SOURCES): Likewise. + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/sparc64.rmk (grub_emu_SOURCES): Likewise. + (grub_setup_SOURCES): Likewise. + * conf/x86_64-efi.rmk (util/i386/efi/grub-mkimage.c_DEPENDENCIES): + Likewise. + * fs/ufs2.c: New file. + * fs/ufs.c: Separate UFS1 from UFS2 by using preprocessor. + 2009-08-14 Vladimir Serbinenko Framebuffer split. diff --git a/conf/common.rmk b/conf/common.rmk index 5e9330237..b0d3785d1 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -17,7 +17,7 @@ grub_probe_SOURCES = util/grub-probe.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ partmap/pc.c partmap/apple.c partmap/sun.c partmap/gpt.c\ kern/fs.c kern/env.c fs/fshelp.c \ @@ -38,7 +38,7 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ kern/partition.c partmap/pc.c partmap/apple.c partmap/sun.c \ partmap/gpt.c \ @@ -174,7 +174,7 @@ sbin_SCRIPTS += grub-dumpbios CLEANFILES += grub-dumpbios # Filing systems. -pkglib_MODULES += fshelp.mod fat.mod ufs.mod ext2.mod ntfs.mod \ +pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \ udf.mod afs.mod befs.mod @@ -189,10 +189,15 @@ fat_mod_SOURCES = fs/fat.c fat_mod_CFLAGS = $(COMMON_CFLAGS) fat_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For ufs.mod. -ufs_mod_SOURCES = fs/ufs.c -ufs_mod_CFLAGS = $(COMMON_CFLAGS) -ufs_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For ufs1.mod. +ufs1_mod_SOURCES = fs/ufs.c +ufs1_mod_CFLAGS = $(COMMON_CFLAGS) +ufs1_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For ufs2.mod. +ufs2_mod_SOURCES = fs/ufs2.c +ufs2_mod_CFLAGS = $(COMMON_CFLAGS) +ufs2_mod_LDFLAGS = $(COMMON_LDFLAGS) # For ext2.mod. ext2_mod_SOURCES = fs/ext2.c diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 7ba573795..ce2576b95 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -116,7 +116,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ fs/fshelp.c \ io/gzio.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 9177b9d44..6e3cbcf6d 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -24,7 +24,7 @@ util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile # util/misc.c util/getroot.c kern/device.c kern/disk.c \ # kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ # fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ -# fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ +# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ # kern/fs.c kern/env.c fs/fshelp.c # For grub-mkdevicemap. @@ -44,7 +44,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 032197906..65d1c6bde 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -71,7 +71,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ fs/fshelp.c \ io/gzio.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index debb40364..0ef5e4730 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -102,7 +102,7 @@ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ partmap/pc.c partmap/gpt.c \ \ @@ -146,7 +146,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index af29d23ad..c30f61a48 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -51,7 +51,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index aabccee5f..b26496d20 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -78,7 +78,7 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ partmap/amiga.c partmap/apple.c partmap/pc.c \ partmap/sun.c partmap/acorn.c \ @@ -108,7 +108,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 21da0e1cf..71a90ce18 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -23,7 +23,7 @@ grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \ # util/misc.c util/getroot.c kern/device.c kern/disk.c \ # kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ # fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ -# fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ +# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ # kern/fs.c kern/env.c fs/fshelp.c # For grub-mkdevicemap. @@ -42,7 +42,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/xfs.c fs/afs.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/fs/ufs.c b/fs/ufs.c index 336507c6d..75398617d 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -25,9 +25,12 @@ #include #include - +#ifdef MODE_UFS2 +#define GRUB_UFS_MAGIC 0x19540119 +#else #define GRUB_UFS_MAGIC 0x11954 -#define GRUB_UFS2_MAGIC 0x19540119 +#endif + #define GRUB_UFS_INODE 2 #define GRUB_UFS_FILETYPE_DIR 4 #define GRUB_UFS_FILETYPE_LNK 10 @@ -44,20 +47,29 @@ #define GRUB_UFS_VOLNAME_LEN 32 /* Calculate in which group the inode can be found. */ -#define inode_group(inode,sblock) () - #define UFS_BLKSZ(sblock) (grub_le_to_cpu32 (sblock->bsize)) -#define INODE(data,field) (data->ufs_type == UFS1 ? \ - data->inode. field : data->inode2. field) -#define INODE_ENDIAN(data,field,bits1,bits2) (data->ufs_type == UFS1 ? \ - grub_le_to_cpu##bits1 (data->inode.field) : \ - grub_le_to_cpu##bits2 (data->inode2.field)) +#define INODE(data,field) data->inode. field +#ifdef MODE_UFS2 +#define INODE_ENDIAN(data,field,bits1,bits2) grub_le_to_cpu##bits2 (data->inode.field) +#else +#define INODE_ENDIAN(data,field,bits1,bits2) grub_le_to_cpu##bits1 (data->inode.field) +#endif + #define INODE_SIZE(data) INODE_ENDIAN (data,size,32,64) #define INODE_NBLOCKS(data) INODE_ENDIAN (data,nblocks,32,64) #define INODE_MODE(data) INODE_ENDIAN (data,mode,16,16) -#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 4 : 8) +#ifdef MODE_UFS2 +#define INODE_BLKSZ 8 +#else +#define INODE_BLKSZ 4 +#endif +#ifdef MODE_UFS2 +#define UFS_INODE_PER_BLOCK 2 +#else +#define UFS_INODE_PER_BLOCK 4 +#endif #define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \ (data,blocks.dir_blocks[blk],32,64) #define INODE_INDIRBLOCKS(data,blk) INODE_ENDIAN \ @@ -111,35 +123,9 @@ struct grub_ufs_sblock grub_uint32_t magic; }; +#ifdef MODE_UFS2 /* UFS inode. */ struct grub_ufs_inode -{ - grub_uint16_t mode; - grub_uint16_t nlinks; - grub_uint16_t uid; - grub_uint16_t gid; - grub_int64_t size; - grub_uint64_t atime; - grub_uint64_t mtime; - grub_uint64_t ctime; - union - { - struct - { - grub_uint32_t dir_blocks[GRUB_UFS_DIRBLKS]; - grub_uint32_t indir_blocks[GRUB_UFS_INDIRBLKS]; - } blocks; - grub_uint8_t symlink[(GRUB_UFS_DIRBLKS + GRUB_UFS_INDIRBLKS) * 4]; - }; - grub_uint32_t flags; - grub_uint32_t nblocks; - grub_uint32_t gen; - grub_uint32_t unused; - grub_uint8_t pad[12]; -} __attribute__ ((packed)); - -/* UFS inode. */ -struct grub_ufs2_inode { grub_uint16_t mode; grub_uint16_t nlinks; @@ -173,6 +159,34 @@ struct grub_ufs2_inode grub_uint8_t unused[24]; } __attribute__ ((packed)); +#else +/* UFS inode. */ +struct grub_ufs_inode +{ + grub_uint16_t mode; + grub_uint16_t nlinks; + grub_uint16_t uid; + grub_uint16_t gid; + grub_int64_t size; + grub_uint64_t atime; + grub_uint64_t mtime; + grub_uint64_t ctime; + union + { + struct + { + grub_uint32_t dir_blocks[GRUB_UFS_DIRBLKS]; + grub_uint32_t indir_blocks[GRUB_UFS_INDIRBLKS]; + } blocks; + grub_uint8_t symlink[(GRUB_UFS_DIRBLKS + GRUB_UFS_INDIRBLKS) * 4]; + }; + grub_uint32_t flags; + grub_uint32_t nblocks; + grub_uint32_t gen; + grub_uint32_t unused; + grub_uint8_t pad[12]; +} __attribute__ ((packed)); +#endif /* Directory entry. */ struct grub_ufs_dirent @@ -195,17 +209,7 @@ struct grub_ufs_data { struct grub_ufs_sblock sblock; grub_disk_t disk; - union - { - struct grub_ufs_inode inode; - struct grub_ufs2_inode inode2; - }; - enum - { - UFS1, - UFS2, - UNKNOWN - } ufs_type; + struct grub_ufs_inode inode; int ino; int linknest; }; @@ -217,7 +221,7 @@ static grub_err_t grub_ufs_find_file (struct grub_ufs_data *data, const char *path); -static int +static grub_disk_addr_t grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk) { struct grub_ufs_sblock *sblock = &data->sblock; @@ -232,32 +236,38 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk) blk -= GRUB_UFS_DIRBLKS; - indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ (data); + indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ; /* Single indirect block. */ if (blk < indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; +#ifdef MODE_UFS2 + grub_uint64_t indir[UFS_BLKSZ (sblock) / sizeof (grub_uint64_t)]; +#else + grub_uint32_t indir[UFS_BLKSZ (sblock) / sizeof (grub_uint32_t)]; +#endif grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0) << log2_blksz, 0, sizeof (indir), indir); - return (data->ufs_type == UFS1) ? indir[blk] : indir[blk << 1]; + return indir[blk]; } blk -= indirsz; /* Double indirect block. */ if (blk < indirsz * indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; +#ifdef MODE_UFS2 + grub_uint64_t indir[UFS_BLKSZ (sblock) / sizeof (grub_uint64_t)]; +#else + grub_uint32_t indir[UFS_BLKSZ (sblock) / sizeof (grub_uint32_t)]; +#endif grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz, 0, sizeof (indir), indir); grub_disk_read (data->disk, - ((data->ufs_type == UFS1) ? - indir[blk / indirsz] : indir [(blk / indirsz) << 1]) + (indir [blk / indirsz]) << log2_blksz, 0, sizeof (indir), indir); - return (data->ufs_type == UFS1) ? - indir[blk % indirsz] : indir[(blk % indirsz) << 1]; + return indir[blk % indirsz]; } @@ -334,7 +344,6 @@ grub_ufs_read_file (struct grub_ufs_data *data, return len; } - /* Read inode INO from the mounted filesystem described by DATA. This inode is used by default now. */ static grub_err_t @@ -351,38 +360,20 @@ grub_ufs_read_inode (struct grub_ufs_data *data, int ino, char *inode) /* The first block of the group. */ int grpblk = group * (grub_le_to_cpu32 (sblock->frags_per_group)); - if (data->ufs_type == UFS1) + if (!inode) { - if (!inode) - { - inode = (char *) &data->inode; - data->ino = ino; - } - - grub_disk_read (data->disk, - (((grub_le_to_cpu32 (sblock->inoblk_offs) + grpblk) - << grub_le_to_cpu32 (data->sblock.log2_blksz))) - + grpino / 4, - (grpino % 4) * sizeof (struct grub_ufs_inode), - sizeof (struct grub_ufs_inode), - inode); + inode = (char *) &data->inode; + data->ino = ino; } - else - { - if (!inode) - { - inode = (char *) &data->inode2; - data->ino = ino; - } - grub_disk_read (data->disk, - (((grub_le_to_cpu32 (sblock->inoblk_offs) + grpblk) - << grub_le_to_cpu32 (data->sblock.log2_blksz))) - + grpino / 2, - (grpino % 2) * sizeof (struct grub_ufs2_inode), - sizeof (struct grub_ufs2_inode), - inode); - } + grub_disk_read (data->disk, + ((grub_le_to_cpu32 (sblock->inoblk_offs) + grpblk) + << grub_le_to_cpu32 (data->sblock.log2_blksz)) + + grpino / UFS_INODE_PER_BLOCK, + (grpino % UFS_INODE_PER_BLOCK) + * sizeof (struct grub_ufs_inode), + sizeof (struct grub_ufs_inode), + inode); return grub_errno; } @@ -466,9 +457,11 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path) (char *) &dirent) < 0) return grub_errno; - namelen = (data->ufs_type == UFS2) - ? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen); - +#ifdef MODE_UFS2 + namelen = dirent.namelen_bsd; +#else + namelen = grub_le_to_cpu16 (dirent.namelen); +#endif { char filename[namelen + 1]; @@ -530,8 +523,7 @@ grub_ufs_mount (grub_disk_t disk) if (!data) return 0; - /* Find a UFS1 or UFS2 sblock. */ - data->ufs_type = UNKNOWN; + /* Find a UFS sblock. */ while (*sblklist != -1) { grub_disk_read (disk, *sblklist, 0, sizeof (struct grub_ufs_sblock), @@ -541,31 +533,25 @@ grub_ufs_mount (grub_disk_t disk) if (grub_le_to_cpu32 (data->sblock.magic) == GRUB_UFS_MAGIC) { - data->ufs_type = UFS1; - break; - } - else if (grub_le_to_cpu32 (data->sblock.magic) == GRUB_UFS2_MAGIC) - { - data->ufs_type = UFS2; - break; + data->disk = disk; + data->linknest = 0; + return data; } sblklist++; } - if (data->ufs_type == UNKNOWN) - { - grub_error (GRUB_ERR_BAD_FS, "not an ufs filesystem"); - goto fail; - } - - data->disk = disk; - data->linknest = 0; - return data; fail: - grub_free (data); - if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not a ufs filesystem"); + if (grub_errno == GRUB_ERR_NONE || grub_errno == GRUB_ERR_OUT_OF_RANGE) + { +#ifdef MODE_UFS2 + grub_error (GRUB_ERR_BAD_FS, "not an ufs2 filesystem"); +#else + grub_error (GRUB_ERR_BAD_FS, "not an ufs1 filesystem"); +#endif + } + + grub_free (data); return 0; } @@ -615,12 +601,17 @@ grub_ufs_dir (grub_device_t device, const char *path, (char *) &dirent) < 0) break; - namelen = (data->ufs_type == UFS2) - ? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen); +#ifdef MODE_UFS2 + namelen = dirent.namelen_bsd; +#else + namelen = grub_le_to_cpu16 (dirent.namelen); +#endif { char filename[namelen + 1]; struct grub_dirhook_info info; + struct grub_ufs_inode inode; + grub_memset (&info, 0, sizeof (info)); if (grub_ufs_read_file (data, 0, pos + sizeof (dirent), @@ -628,24 +619,12 @@ grub_ufs_dir (grub_device_t device, const char *path, break; filename[namelen] = '\0'; - if (data->ufs_type == UFS1) - { - struct grub_ufs_inode inode; - grub_ufs_read_inode (data, dirent.ino, (char *) &inode); - info.dir = ((grub_le_to_cpu16 (inode.mode) & GRUB_UFS_ATTR_TYPE) - == GRUB_UFS_ATTR_DIR); - info.mtime = grub_le_to_cpu64 (inode.mtime); - info.mtimeset = 1; - } - else - { - struct grub_ufs2_inode inode; - grub_ufs_read_inode (data, dirent.ino, (char *) &inode); - info.dir = ((grub_le_to_cpu16 (inode.mode) & GRUB_UFS_ATTR_TYPE) - == GRUB_UFS_ATTR_DIR); - info.mtime = grub_le_to_cpu64 (inode.mtime); - info.mtimeset = 1; - } + grub_ufs_read_inode (data, dirent.ino, (char *) &inode); + + info.dir = ((grub_le_to_cpu16 (inode.mode) & GRUB_UFS_ATTR_TYPE) + == GRUB_UFS_ATTR_DIR); + info.mtime = grub_le_to_cpu64 (inode.mtime); + info.mtimeset = 1; if (hook (filename, &info)) break; @@ -716,6 +695,7 @@ grub_ufs_close (grub_file_t file) } +#ifdef MODE_UFS2 static grub_err_t grub_ufs_label (grub_device_t device, char **label) { @@ -727,10 +707,7 @@ grub_ufs_label (grub_device_t device, char **label) data = grub_ufs_mount (device->disk); if (data) - { - if (data->ufs_type == UFS2) - *label = grub_strdup ((char *) data->sblock.volume_name); - } + *label = grub_strdup ((char *) data->sblock.volume_name); grub_dl_unref (my_mod); @@ -738,6 +715,7 @@ grub_ufs_label (grub_device_t device, char **label) return grub_errno; } +#endif static grub_err_t grub_ufs_uuid (grub_device_t device, char **uuid) @@ -748,7 +726,7 @@ grub_ufs_uuid (grub_device_t device, char **uuid) grub_dl_ref (my_mod); data = grub_ufs_mount (disk); - if (data) + if (data && (data->sblock.uuidhi != 0 || data->sblock.uuidlow != 0)) { *uuid = grub_malloc (16 + sizeof ('\0')); grub_sprintf (*uuid, "%08x%08x", @@ -777,10 +755,12 @@ grub_ufs_mtime (grub_device_t device, grub_int32_t *tm) data = grub_ufs_mount (device->disk); if (!data) *tm = 0; - else if (data->ufs_type == UFS1) - *tm = grub_le_to_cpu32 (data->sblock.mtime); else +#ifdef MODE_UFS2 *tm = grub_le_to_cpu64 (data->sblock.mtime2); +#else + *tm = grub_le_to_cpu32 (data->sblock.mtime); +#endif grub_dl_unref (my_mod); @@ -793,24 +773,38 @@ grub_ufs_mtime (grub_device_t device, grub_int32_t *tm) static struct grub_fs grub_ufs_fs = { - .name = "ufs", +#ifdef MODE_UFS2 + .name = "ufs2", +#else + .name = "ufs1", +#endif .dir = grub_ufs_dir, .open = grub_ufs_open, .read = grub_ufs_read, .close = grub_ufs_close, +#ifdef MODE_UFS2 .label = grub_ufs_label, +#endif .uuid = grub_ufs_uuid, .mtime = grub_ufs_mtime, .next = 0 }; -GRUB_MOD_INIT(ufs) +#ifdef MODE_UFS2 +GRUB_MOD_INIT(ufs2) +#else +GRUB_MOD_INIT(ufs1) +#endif { grub_fs_register (&grub_ufs_fs); my_mod = mod; } -GRUB_MOD_FINI(ufs) +#ifdef MODE_UFS2 +GRUB_MOD_FINI(ufs2) +#else +GRUB_MOD_FINI(ufs1) +#endif { grub_fs_unregister (&grub_ufs_fs); } diff --git a/fs/ufs2.c b/fs/ufs2.c new file mode 100644 index 000000000..7f4eb95de --- /dev/null +++ b/fs/ufs2.c @@ -0,0 +1,3 @@ +/* ufs2.c - Unix File System 2 */ +#define MODE_UFS2 1 +#include "ufs.c" From 25fbd77a9d1ca9942932d94e9c32f5c7046c387e Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 13:32:09 +0000 Subject: [PATCH 30/45] changelog fix --- ChangeLog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4ec76db9..0cae2ec9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,9 +11,9 @@ (ufs1_mod_SOURCES): New variable. (ufs1_mod_CFLAGS): Likewise. (ufs1_mod_LDFLAGS): Likewise. - (ufs1_mod_SOURCES): New variable. - (ufs1_mod_CFLAGS): Likewise. - (ufs1_mod_LDFLAGS): Likewise. + (ufs2_mod_SOURCES): New variable. + (ufs2_mod_CFLAGS): Likewise. + (ufs2_mod_LDFLAGS): Likewise. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add fs/ufs2.c. * conf/i386-efi.rmk (util/i386/efi/grub-mkimage.c_DEPENDENCIES): Likewise. From c60cee8ee16c512ad73370e611a9d226c140c939 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 13:42:03 +0000 Subject: [PATCH 31/45] 2009-08-14 Vladimir Serbinenko Handle group offset on UFS1. * fs/ufs.c (grub_ufs_sblock): New field 'cylg_mask'. (grub_ufs_read_inode) [!MODE_UFS2]: handle cylg_offset and cylg_mask. --- ChangeLog | 7 +++++++ fs/ufs.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0cae2ec9d..c808913a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-14 Vladimir Serbinenko + + Handle group offset on UFS1. + + * fs/ufs.c (grub_ufs_sblock): New field 'cylg_mask'. + (grub_ufs_read_inode) [!MODE_UFS2]: handle cylg_offset and cylg_mask. + 2009-08-14 Vladimir Serbinenko Split ufs.mod into ufs1.mod and ufs2.mod. diff --git a/fs/ufs.c b/fs/ufs.c index 75398617d..797a45d13 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -88,7 +88,7 @@ struct grub_ufs_sblock /* The start of the cylinder group. */ grub_uint32_t cylg_offset; - grub_uint8_t unused3[4]; + grub_uint32_t cylg_mask; grub_uint32_t mtime; grub_uint8_t unused4[12]; @@ -360,6 +360,11 @@ grub_ufs_read_inode (struct grub_ufs_data *data, int ino, char *inode) /* The first block of the group. */ int grpblk = group * (grub_le_to_cpu32 (sblock->frags_per_group)); +#ifndef MODE_UFS2 + grpblk += grub_le_to_cpu32 (sblock->cylg_offset) + * (group & (~grub_le_to_cpu32 (sblock->cylg_mask))); +#endif + if (!inode) { inode = (char *) &data->inode; From c166d79e62a381ac7b947c7ed8a093407c34a276 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 15:15:33 +0000 Subject: [PATCH 32/45] 2009-08-14 Vladimir Serbinenko * loader/i386/multiboot.c (grub_multiboot_unload): Don't free mbi and mbi->cmdline but free playground. --- ChangeLog | 5 +++++ loader/i386/multiboot.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c808913a9..8b76b58ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-14 Vladimir Serbinenko + + * loader/i386/multiboot.c (grub_multiboot_unload): Don't free mbi and + mbi->cmdline but free playground. + 2009-08-14 Vladimir Serbinenko Handle group offset on UFS1. diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 87ffcae8d..642530641 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -53,7 +53,7 @@ extern grub_dl_t my_mod; static struct grub_multiboot_info *mbi, *mbi_dest; static grub_addr_t entry; -static char *playground; +static char *playground = 0; static grub_size_t code_size; static grub_err_t @@ -68,7 +68,7 @@ grub_multiboot_boot (void) static grub_err_t grub_multiboot_unload (void) { - if (mbi) + if (playground) { unsigned int i; for (i = 0; i < mbi->mods_count; i++) @@ -79,11 +79,11 @@ grub_multiboot_unload (void) ((struct grub_mod_list *) mbi->mods_addr)[i].cmdline); } grub_free ((void *) mbi->mods_addr); - grub_free ((void *) mbi->cmdline); - grub_free (mbi); + grub_free (playground); } - mbi = 0; + mbi = NULL; + playground = NULL; grub_dl_unref (my_mod); return GRUB_ERR_NONE; From e1f39873bcd4542cef76d39b1bf194dca10fc8dd Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 14 Aug 2009 15:19:24 +0000 Subject: [PATCH 33/45] 2009-08-14 Vladimir Serbinenko * loader/i386/multiboot.c (grub_multiboot): Don't pass filename to payload. (grub_module): Likewise. --- ChangeLog | 6 ++++++ loader/i386/multiboot.c | 42 +++++++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b76b58ea..83b575538 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-14 Vladimir Serbinenko + + * loader/i386/multiboot.c (grub_multiboot): Don't pass filename to + payload. + (grub_module): Likewise. + 2009-08-14 Vladimir Serbinenko * loader/i386/multiboot.c (grub_multiboot_unload): Don't free mbi and diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 642530641..8c3139b57 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -201,6 +201,8 @@ grub_multiboot (int argc, char *argv[]) grub_ssize_t len, cmdline_length, boot_loader_name_length; grub_uint32_t mmap_length; int i; + int cmdline_argc; + char **cmdline_argv; grub_loader_unset (); @@ -257,8 +259,15 @@ grub_multiboot (int argc, char *argv[]) mmap_length = grub_get_multiboot_mmap_len (); /* Figure out cmdline length. */ - for (i = 0, cmdline_length = 0; i < argc; i++) - cmdline_length += grub_strlen (argv[i]) + 1; + /* Skip filename. */ + cmdline_argc = argc - 1; + cmdline_argv = argv + 1; + + for (i = 0, cmdline_length = 0; i < cmdline_argc; i++) + cmdline_length += grub_strlen (cmdline_argv[i]) + 1; + + if (cmdline_length == 0) + cmdline_length = 1; boot_loader_name_length = sizeof(PACKAGE_STRING); @@ -351,14 +360,16 @@ grub_multiboot (int argc, char *argv[]) if (! cmdline) goto fail; - for (i = 0; i < argc; i++) + for (i = 0; i < cmdline_argc; i++) { - p = grub_stpcpy (p, argv[i]); + p = grub_stpcpy (p, cmdline_argv[i]); *(p++) = ' '; } /* Remove the space after the last word. */ - *(--p) = '\0'; + if (p != cmdline) + p--; + *p = 0; mbi->flags |= MULTIBOOT_INFO_CMDLINE; mbi->cmdline = (grub_uint32_t) cmdline_addr (grub_multiboot_payload_dest); @@ -393,6 +404,8 @@ grub_module (int argc, char *argv[]) grub_ssize_t size, len = 0; char *module = 0, *cmdline = 0, *p; int i; + int cmdline_argc; + char **cmdline_argv; if (argc == 0) { @@ -422,21 +435,30 @@ grub_module (int argc, char *argv[]) goto fail; } - for (i = 0; i < argc; i++) - len += grub_strlen (argv[i]) + 1; + /* Skip module name. */ + cmdline_argc = argc - 1; + cmdline_argv = argv + 1; + + for (i = 0; i < cmdline_argc; i++) + len += grub_strlen (cmdline_argv[i]) + 1; + + if (len == 0) + len = 1; cmdline = p = grub_malloc (len); if (! cmdline) goto fail; - for (i = 0; i < argc; i++) + for (i = 0; i < cmdline_argc; i++) { - p = grub_stpcpy (p, argv[i]); + p = grub_stpcpy (p, cmdline_argv[i]); *(p++) = ' '; } /* Remove the space after the last word. */ - *(--p) = '\0'; + if (p != cmdline) + p--; + *p = '\0'; if (mbi->flags & MULTIBOOT_INFO_MODS) { From 7cef4f7534e49e693dc044bc4031ffd15cc9cfde Mon Sep 17 00:00:00 2001 From: phcoder Date: Sat, 15 Aug 2009 14:45:08 +0000 Subject: [PATCH 34/45] 2009-08-15 Vladimir Serbinenko * fs/affs.c (grub_affs_read_symlink): Change leftover grub_printf into grub_dprintf. * fs/fat.c (grub_fat_read_data): Likewise. --- ChangeLog | 6 ++++++ fs/affs.c | 2 +- fs/fat.c | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83b575538..3d34abf21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-15 Vladimir Serbinenko + + * fs/affs.c (grub_affs_read_symlink): Change leftover grub_printf into + grub_dprintf. + * fs/fat.c (grub_fat_read_data): Likewise. + 2009-08-14 Vladimir Serbinenko * loader/i386/multiboot.c (grub_multiboot): Don't pass filename to diff --git a/fs/affs.c b/fs/affs.c index 286b99f9a..cfe7d579b 100644 --- a/fs/affs.c +++ b/fs/affs.c @@ -273,7 +273,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node) grub_free (symlink); return 0; } - grub_printf ("Symlink: `%s'\n", symlink); + grub_dprintf ("affs", "Symlink: `%s'\n", symlink); return symlink; } diff --git a/fs/fat.c b/fs/fat.c index cc733362f..024e8c684 100644 --- a/fs/fat.c +++ b/fs/fat.c @@ -423,8 +423,8 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, } #if 0 - grub_printf ("%s:%d: fat_size=%d, next_cluster=%u\n", - __FILE__, __LINE__, data->fat_size, next_cluster); + grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n", + data->fat_size, next_cluster); #endif /* Check the end. */ From 08aa61f0e21719e48d15ee3aa00350a6f5391c83 Mon Sep 17 00:00:00 2001 From: robertmh Date: Mon, 17 Aug 2009 12:44:28 +0000 Subject: [PATCH 35/45] 2009-08-17 Robert Millan * loader/i386/linux.c (GRUB_ASSUME_LINUX_HAS_FB_SUPPORT) (DEFAULT_VIDEO_MODE): Remove macros. (grub_linux_boot): Remove assumption that Linux has FB support, and use "text" as default video mode. --- ChangeLog | 7 +++++++ loader/i386/linux.c | 18 +++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d34abf21..7374c3903 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-17 Robert Millan + + * loader/i386/linux.c (GRUB_ASSUME_LINUX_HAS_FB_SUPPORT) + (DEFAULT_VIDEO_MODE): Remove macros. + (grub_linux_boot): Remove assumption that Linux has FB support, + and use "text" as default video mode. + 2009-08-15 Vladimir Serbinenko * fs/affs.c (grub_affs_read_symlink): Change leftover grub_printf into diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 238e4cd8f..4144384db 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -37,16 +37,6 @@ #define GRUB_LINUX_CL_OFFSET 0x1000 #define GRUB_LINUX_CL_END_OFFSET 0x2000 -/* This macro is useful for distributors, who can be certain they built FB support - into Linux, and therefore can benefit from seamless mode transition between - GRUB and Linux (saving boot time and visual glitches). Official GRUB, OTOH, - needs to be conservative. */ -#ifdef GRUB_ASSUME_LINUX_HAS_FB_SUPPORT -#define DEFAULT_VIDEO_MODE "keep,1024x768,800x600,640x480" -#else -#define DEFAULT_VIDEO_MODE "text" -#endif - static grub_dl_t my_mod; static grub_size_t linux_mem_size; @@ -501,17 +491,15 @@ grub_linux_boot (void) if (modevar && *modevar != 0) { tmp = grub_malloc (grub_strlen (modevar) - + sizeof (DEFAULT_VIDEO_MODE) + 1); + + sizeof (";text")); if (! tmp) return grub_errno; - grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar); + grub_sprintf (tmp, "%s;text", modevar); err = grub_video_set_mode (tmp, 0); grub_free (tmp); } -#ifndef GRUB_ASSUME_LINUX_HAS_FB_SUPPORT else - err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0); -#endif + err = grub_video_set_mode ("text", 0); if (err) { From cc8c6fafe9cf0cf40064428a14539b3e21c452e3 Mon Sep 17 00:00:00 2001 From: robertmh Date: Mon, 17 Aug 2009 12:46:58 +0000 Subject: [PATCH 36/45] 2009-08-17 Robert Millan * fs/fat.c (grub_fat_read_data): Remove `#if 0' braces around the grub_dprintf() that was just added. --- ChangeLog | 5 +++++ fs/fat.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7374c3903..c0f4c9fdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-17 Robert Millan + + * fs/fat.c (grub_fat_read_data): Remove `#if 0' braces around the + grub_dprintf() that was just added. + 2009-08-17 Robert Millan * loader/i386/linux.c (GRUB_ASSUME_LINUX_HAS_FB_SUPPORT) diff --git a/fs/fat.c b/fs/fat.c index 024e8c684..8440e43fa 100644 --- a/fs/fat.c +++ b/fs/fat.c @@ -422,10 +422,8 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, break; } -#if 0 grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n", data->fat_size, next_cluster); -#endif /* Check the end. */ if (next_cluster >= data->cluster_eof_mark) From 6025fcd7f914a2c44782e65fd17c322a4396474b Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 17 Aug 2009 13:34:24 +0000 Subject: [PATCH 37/45] 2009-08-17 Michal Suchanek Remove duplicate grub_video_fb_get_video_ptr. * include/grub/fbutil.h (get_data_ptr): Rename to ... (grub_video_fb_get_video_ptr): ... this. * include/grub/video_fb.h (grub_video_fb_get_video_ptr): Removed. * video/fb/fbutil.c: Add comment about addressing. (get_data_ptr): Rename to ... (grub_video_fb_get_video_ptr): ... this. All users updated. * video/fb/video_fb.c (grub_video_fb_get_video_ptr): Remove. --- ChangeLog | 12 +++++++++ include/grub/fbutil.h | 2 +- include/grub/video_fb.h | 3 --- video/fb/fbblit.c | 56 ++++++++++++++++++++--------------------- video/fb/fbutil.c | 29 ++++++++++++++------- video/fb/video_fb.c | 38 ---------------------------- 6 files changed, 61 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0f4c9fdf..13e21c890 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-08-17 Michal Suchanek + + Remove duplicate grub_video_fb_get_video_ptr. + + * include/grub/fbutil.h (get_data_ptr): Rename to ... + (grub_video_fb_get_video_ptr): ... this. + * include/grub/video_fb.h (grub_video_fb_get_video_ptr): Removed. + * video/fb/fbutil.c: Add comment about addressing. + (get_data_ptr): Rename to ... + (grub_video_fb_get_video_ptr): ... this. All users updated. + * video/fb/video_fb.c (grub_video_fb_get_video_ptr): Remove. + 2009-08-17 Robert Millan * fs/fat.c (grub_fat_read_data): Remove `#if 0' braces around the diff --git a/include/grub/fbutil.h b/include/grub/fbutil.h index 76e1e573c..cf7ecc0d8 100644 --- a/include/grub/fbutil.h +++ b/include/grub/fbutil.h @@ -31,7 +31,7 @@ struct grub_video_fbblit_info void *data; }; -grub_uint8_t *get_data_ptr (struct grub_video_fbblit_info *source, +grub_uint8_t *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y); grub_video_color_t get_pixel (struct grub_video_fbblit_info *source, diff --git a/include/grub/video_fb.h b/include/grub/video_fb.h index 03ef38509..17debd69f 100644 --- a/include/grub/video_fb.h +++ b/include/grub/video_fb.h @@ -33,9 +33,6 @@ struct grub_video_fbrender_target; #define GRUB_VIDEO_FBSTD_NUMCOLORS 16 extern struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS]; -grub_uint8_t * grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, - grub_uint32_t x, grub_uint32_t y); - grub_err_t grub_video_fb_init (void); diff --git a/video/fb/fbblit.c b/video/fb/fbblit.c index 138eba8c1..5b613bc79 100644 --- a/video/fb/fbblit.c +++ b/video/fb/fbblit.c @@ -83,8 +83,8 @@ grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (dst, x, y + j); grub_memmove (dstptr, srcptr, width * bpp); } @@ -110,8 +110,8 @@ grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -153,8 +153,8 @@ grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -197,8 +197,8 @@ grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint32_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -245,8 +245,8 @@ grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -285,8 +285,8 @@ grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -321,8 +321,8 @@ grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -358,8 +358,8 @@ grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -394,8 +394,8 @@ grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -491,8 +491,8 @@ grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint32_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint32_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint32_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -572,8 +572,8 @@ grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst, srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width; dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; - srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y); - dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y); + srcptr = (grub_uint32_t *) grub_video_fb_get_video_ptr (src, offset_x, offset_y); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); for (j = 0; j < height; j++) { @@ -656,8 +656,8 @@ grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -721,8 +721,8 @@ grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { @@ -788,8 +788,8 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, for (j = 0; j < height; j++) { - srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y); - dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j); + srcptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (src, offset_x, j + offset_y); + dstptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (dst, x, y + j); for (i = 0; i < width; i++) { diff --git a/video/fb/fbutil.c b/video/fb/fbutil.c index 09cbb12f9..1fa48ec59 100644 --- a/video/fb/fbutil.c +++ b/video/fb/fbutil.c @@ -16,12 +16,23 @@ * along with GRUB. If not, see . */ +/* SPECIAL NOTES! + + Please note following when reading the code below: + + - In this driver we assume that every memory can be accessed by same memory + bus. If there are different address spaces do not use this code as a base + code for other archs. + + - Every function in this code assumes that bounds checking has been done in + previous phase and they are opted out in here. */ + #include #include #include grub_uint8_t * -get_data_ptr (struct grub_video_fbblit_info *source, +grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, unsigned int x, unsigned int y) { grub_uint8_t *ptr = 0; @@ -72,24 +83,24 @@ get_pixel (struct grub_video_fbblit_info *source, switch (source->mode_info->bpp) { case 32: - color = *(grub_uint32_t *)get_data_ptr (source, x, y); + color = *(grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y); break; case 24: { grub_uint8_t *ptr; - ptr = get_data_ptr (source, x, y); + ptr = grub_video_fb_get_video_ptr (source, x, y); color = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16); } break; case 16: case 15: - color = *(grub_uint16_t *)get_data_ptr (source, x, y); + color = *(grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y); break; case 8: - color = *(grub_uint8_t *)get_data_ptr (source, x, y); + color = *(grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y); break; case 1: @@ -120,7 +131,7 @@ set_pixel (struct grub_video_fbblit_info *source, { grub_uint32_t *ptr; - ptr = (grub_uint32_t *)get_data_ptr (source, x, y); + ptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y); *ptr = color; } @@ -131,7 +142,7 @@ set_pixel (struct grub_video_fbblit_info *source, grub_uint8_t *ptr; grub_uint8_t *colorptr = (grub_uint8_t *)&color; - ptr = get_data_ptr (source, x, y); + ptr = grub_video_fb_get_video_ptr (source, x, y); ptr[0] = colorptr[0]; ptr[1] = colorptr[1]; @@ -144,7 +155,7 @@ set_pixel (struct grub_video_fbblit_info *source, { grub_uint16_t *ptr; - ptr = (grub_uint16_t *)get_data_ptr (source, x, y); + ptr = (grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y); *ptr = (grub_uint16_t) (color & 0xFFFF); } @@ -154,7 +165,7 @@ set_pixel (struct grub_video_fbblit_info *source, { grub_uint8_t *ptr; - ptr = (grub_uint8_t *)get_data_ptr (source, x, y); + ptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y); *ptr = (grub_uint8_t) (color & 0xFF); } diff --git a/video/fb/video_fb.c b/video/fb/video_fb.c index fc943735a..a35dd7a4e 100644 --- a/video/fb/video_fb.c +++ b/video/fb/video_fb.c @@ -83,44 +83,6 @@ grub_video_fb_get_info (struct grub_video_mode_info *mode_info) return GRUB_ERR_NONE; } - -grub_uint8_t * -grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, - grub_uint32_t x, grub_uint32_t y) -{ - grub_uint8_t *ptr = 0; - - switch (source->mode_info->bpp) - { - case 32: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 4; - break; - - case 24: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 3; - break; - - case 16: - case 15: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 2; - break; - - case 8: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x; - break; - } - - return ptr; -} - grub_err_t grub_video_fb_get_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data) From 2f467aa9ad488933ccdbd434a9f9b1b09272c452 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 17 Aug 2009 13:37:22 +0000 Subject: [PATCH 38/45] 2009-08-17 Michal Suchanek Rename variables for clarity. * video/i386/pc/vbe.c (active_mode_info): Renamed to ... (active_vbe_mode_info): ... this. All users updated. (framebuffer): Rename 'active_mode' to 'active_vbe_mode'. All users updated. (initial_mode): Rename to ... (initial_vbe_mode): ... this. All users updated. (mode_in_use): Rename to .. (vbe_mode_in_use): ... this. All users updated. (mode_list): Rename to .. (vbe_mode_list): ... this. All users updated. (grub_vbe_set_video_mode): Rename 'mode' to 'vbe_mode', 'mode_info' to 'vbe_mode_info' and 'old_mode' to 'old_vbe_mode'. (grub_video_vbe_init): Rename 'rm_mode_list' to 'rm_vbe_mode_list' and 'mode_list_size' to 'vbe_mode_list_size'. (grub_video_vbe_setup): Rename 'mode_info' to 'vbe_mode_info', 'best_mode_info' to 'best_vbe_mode_info' and 'best_mode' to 'best_vbe_mode' --- ChangeLog | 22 +++++++ video/i386/pc/vbe.c | 156 ++++++++++++++++++++++---------------------- 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/ChangeLog b/ChangeLog index 13e21c890..95cd3d0c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2009-08-17 Michal Suchanek + + Rename variables for clarity. + + * video/i386/pc/vbe.c (active_mode_info): Renamed to ... + (active_vbe_mode_info): ... this. All users updated. + (framebuffer): Rename 'active_mode' to 'active_vbe_mode'. + All users updated. + (initial_mode): Rename to ... + (initial_vbe_mode): ... this. All users updated. + (mode_in_use): Rename to .. + (vbe_mode_in_use): ... this. All users updated. + (mode_list): Rename to .. + (vbe_mode_list): ... this. All users updated. + (grub_vbe_set_video_mode): Rename 'mode' to 'vbe_mode', 'mode_info' to + 'vbe_mode_info' and 'old_mode' to 'old_vbe_mode'. + (grub_video_vbe_init): Rename 'rm_mode_list' to 'rm_vbe_mode_list' and + 'mode_list_size' to 'vbe_mode_list_size'. + (grub_video_vbe_setup): Rename 'mode_info' to 'vbe_mode_info', + 'best_mode_info' to 'best_vbe_mode_info' and + 'best_mode' to 'best_vbe_mode' + 2009-08-17 Michal Suchanek Remove duplicate grub_video_fb_get_video_ptr. diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index 0244b9016..34885d62e 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -31,7 +31,7 @@ static int vbe_detected = -1; static struct grub_vbe_info_block controller_info; -static struct grub_vbe_mode_info_block active_mode_info; +static struct grub_vbe_mode_info_block active_vbe_mode_info; static struct { @@ -40,14 +40,14 @@ static struct unsigned int bytes_per_scan_line; unsigned int bytes_per_pixel; - grub_uint32_t active_mode; + grub_uint32_t active_vbe_mode; grub_uint8_t *ptr; int index_color_mode; } framebuffer; -static grub_uint32_t initial_mode; -static grub_uint32_t mode_in_use = 0x55aa; -static grub_uint16_t *mode_list; +static grub_uint32_t initial_vbe_mode; +static grub_uint32_t vbe_mode_in_use = 0x55aa; +static grub_uint16_t *vbe_mode_list; static void * real2pm (grub_vbe_farptr_t ptr) @@ -110,11 +110,11 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block) } grub_err_t -grub_vbe_set_video_mode (grub_uint32_t mode, - struct grub_vbe_mode_info_block *mode_info) +grub_vbe_set_video_mode (grub_uint32_t vbe_mode, + struct grub_vbe_mode_info_block *vbe_mode_info) { grub_vbe_status_t status; - grub_uint32_t old_mode; + grub_uint32_t old_vbe_mode; grub_err_t err; /* Make sure that VBE is supported. */ @@ -123,18 +123,18 @@ grub_vbe_set_video_mode (grub_uint32_t mode, return grub_errno; /* Try to get mode info. */ - grub_vbe_get_video_mode_info (mode, &active_mode_info); + grub_vbe_get_video_mode_info (vbe_mode, &active_vbe_mode_info); if (grub_errno != GRUB_ERR_NONE) return grub_errno; /* For all VESA BIOS modes, force linear frame buffer. */ - if (mode >= 0x100) + if (vbe_mode >= 0x100) { /* We only want linear frame buffer modes. */ - mode |= 1 << 14; + vbe_mode |= 1 << 14; /* Determine frame buffer pixel format. */ - switch (active_mode_info.memory_model) + switch (active_vbe_mode_info.memory_model) { case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL: framebuffer.index_color_mode = 1; @@ -147,24 +147,24 @@ grub_vbe_set_video_mode (grub_uint32_t mode, default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported pixel format 0x%x", - active_mode_info.memory_model); + active_vbe_mode_info.memory_model); } } /* Get current mode. */ - grub_vbe_get_video_mode (&old_mode); + grub_vbe_get_video_mode (&old_vbe_mode); if (grub_errno != GRUB_ERR_NONE) return grub_errno; /* Try to set video mode. */ - status = grub_vbe_bios_set_mode (mode, 0); + status = grub_vbe_bios_set_mode (vbe_mode, 0); if (status != GRUB_VBE_STATUS_OK) - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", mode); + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", vbe_mode); /* Save information for later usage. */ - framebuffer.active_mode = mode; + framebuffer.active_vbe_mode = vbe_mode; - if (mode < 0x100) + if (vbe_mode < 0x100) { /* If this is not a VESA mode, guess address. */ framebuffer.ptr = (grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR; @@ -172,16 +172,16 @@ grub_vbe_set_video_mode (grub_uint32_t mode, } else { - framebuffer.ptr = (grub_uint8_t *) active_mode_info.phys_base_addr; + framebuffer.ptr = (grub_uint8_t *) active_vbe_mode_info.phys_base_addr; if (controller_info.version >= 0x300) - framebuffer.bytes_per_scan_line = active_mode_info.lin_bytes_per_scan_line; + framebuffer.bytes_per_scan_line = active_vbe_mode_info.lin_bytes_per_scan_line; else - framebuffer.bytes_per_scan_line = active_mode_info.bytes_per_scan_line; + framebuffer.bytes_per_scan_line = active_vbe_mode_info.bytes_per_scan_line; } /* Check whether mode is text mode or graphics mode. */ - if (active_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT) + if (active_vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT) { /* Text mode. */ @@ -193,7 +193,7 @@ grub_vbe_set_video_mode (grub_uint32_t mode, /* Graphics mode. */ /* Calculate bytes_per_pixel value. */ - switch(active_mode_info.bits_per_pixel) + switch(active_vbe_mode_info.bits_per_pixel) { case 32: framebuffer.bytes_per_pixel = 4; break; case 24: framebuffer.bytes_per_pixel = 3; break; @@ -201,10 +201,10 @@ grub_vbe_set_video_mode (grub_uint32_t mode, case 15: framebuffer.bytes_per_pixel = 2; break; case 8: framebuffer.bytes_per_pixel = 1; break; default: - grub_vbe_bios_set_mode (old_mode, 0); + grub_vbe_bios_set_mode (old_vbe_mode, 0); return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", - mode); + vbe_mode); break; } @@ -237,8 +237,8 @@ grub_vbe_set_video_mode (grub_uint32_t mode, } /* Copy mode info for caller. */ - if (mode_info) - grub_memcpy (mode_info, &active_mode_info, sizeof (*mode_info)); + if (vbe_mode_info) + grub_memcpy (vbe_mode_info, &active_vbe_mode_info, sizeof (*vbe_mode_info)); return GRUB_ERR_NONE; } @@ -314,9 +314,9 @@ grub_vbe_get_video_mode_info (grub_uint32_t mode, static grub_err_t grub_video_vbe_init (void) { - grub_uint16_t *rm_mode_list; + grub_uint16_t *rm_vbe_mode_list; grub_uint16_t *p; - grub_size_t mode_list_size; + grub_size_t vbe_mode_list_size; struct grub_vbe_info_block info_block; /* Check if there is adapter present. @@ -330,23 +330,23 @@ grub_video_vbe_init (void) return grub_errno; /* Copy modelist to local memory. */ - p = rm_mode_list = real2pm (info_block.video_mode_ptr); + p = rm_vbe_mode_list = real2pm (info_block.video_mode_ptr); while(*p++ != 0xFFFF) ; - mode_list_size = (grub_addr_t) p - (grub_addr_t) rm_mode_list; - mode_list = grub_malloc (mode_list_size); - if (! mode_list) + vbe_mode_list_size = (grub_addr_t) p - (grub_addr_t) rm_vbe_mode_list; + vbe_mode_list = grub_malloc (vbe_mode_list_size); + if (! vbe_mode_list) return grub_errno; - grub_memcpy (mode_list, rm_mode_list, mode_list_size); + grub_memcpy (vbe_mode_list, rm_vbe_mode_list, vbe_mode_list_size); /* Adapter could be found, figure out initial video mode. */ - grub_vbe_get_video_mode (&initial_mode); + grub_vbe_get_video_mode (&initial_vbe_mode); if (grub_errno != GRUB_ERR_NONE) { /* Free allocated resources. */ - grub_free (mode_list); - mode_list = NULL; + grub_free (vbe_mode_list); + vbe_mode_list = NULL; return grub_errno; } @@ -363,14 +363,14 @@ grub_video_vbe_fini (void) grub_vbe_status_t status; /* Restore old video mode. */ - status = grub_vbe_bios_set_mode (initial_mode, 0); + status = grub_vbe_bios_set_mode (initial_vbe_mode, 0); if (status != GRUB_VBE_STATUS_OK) /* TODO: Decide, is this something we want to do. */ return grub_errno; /* TODO: Free any resources allocated by driver. */ - grub_free (mode_list); - mode_list = NULL; + grub_free (vbe_mode_list); + vbe_mode_list = NULL; /* TODO: destroy render targets. */ @@ -382,9 +382,9 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, unsigned int mode_type) { grub_uint16_t *p; - struct grub_vbe_mode_info_block mode_info; - struct grub_vbe_mode_info_block best_mode_info; - grub_uint32_t best_mode = 0; + struct grub_vbe_mode_info_block vbe_mode_info; + struct grub_vbe_mode_info_block best_vbe_mode_info; + grub_uint32_t best_vbe_mode = 0; int depth; /* Decode depth from mode_type. If it is zero, then autodetect. */ @@ -392,11 +392,11 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS; /* Walk thru mode list and try to find matching mode. */ - for (p = mode_list; *p != 0xFFFF; p++) + for (p = vbe_mode_list; *p != 0xFFFF; p++) { - grub_uint32_t mode = *p; + grub_uint32_t vbe_mode = *p; - grub_vbe_get_video_mode_info (mode, &mode_info); + grub_vbe_get_video_mode_info (vbe_mode, &vbe_mode_info); if (grub_errno != GRUB_ERR_NONE) { /* Could not retrieve mode info, retreat. */ @@ -404,33 +404,33 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, break; } - if ((mode_info.mode_attributes & 0x001) == 0) + if ((vbe_mode_info.mode_attributes & 0x001) == 0) /* If not available, skip it. */ continue; - if ((mode_info.mode_attributes & 0x002) == 0) + if ((vbe_mode_info.mode_attributes & 0x002) == 0) /* Not enough information. */ continue; - if ((mode_info.mode_attributes & 0x008) == 0) + if ((vbe_mode_info.mode_attributes & 0x008) == 0) /* Monochrome is unusable. */ continue; - if ((mode_info.mode_attributes & 0x080) == 0) + if ((vbe_mode_info.mode_attributes & 0x080) == 0) /* We support only linear frame buffer modes. */ continue; - if ((mode_info.mode_attributes & 0x010) == 0) + if ((vbe_mode_info.mode_attributes & 0x010) == 0) /* We allow only graphical modes. */ continue; - if ((mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL) - && (mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)) + if ((vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL) + && (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)) /* Not compatible memory model. */ continue; - if ((mode_info.x_resolution != width) - || (mode_info.y_resolution != height)) + if ((vbe_mode_info.x_resolution != width) + || (vbe_mode_info.y_resolution != height)) /* Non matching resolution. */ continue; @@ -438,65 +438,65 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, if ((mode_type & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0) { if (((mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0) - && (mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)) + && (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)) /* Requested only index color modes. */ continue; if (((mode_type & GRUB_VIDEO_MODE_TYPE_RGB) != 0) - && (mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)) + && (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)) /* Requested only RGB modes. */ continue; } /* If there is a request for specific depth, ignore others. */ - if ((depth != 0) && (mode_info.bits_per_pixel != depth)) + if ((depth != 0) && (vbe_mode_info.bits_per_pixel != depth)) continue; /* Select mode with most number of bits per pixel. */ - if (best_mode != 0) - if (mode_info.bits_per_pixel < best_mode_info.bits_per_pixel) + if (best_vbe_mode != 0) + if (vbe_mode_info.bits_per_pixel < best_vbe_mode_info.bits_per_pixel) continue; /* Save so far best mode information for later use. */ - best_mode = mode; - grub_memcpy (&best_mode_info, &mode_info, sizeof (mode_info)); + best_vbe_mode = vbe_mode; + grub_memcpy (&best_vbe_mode_info, &vbe_mode_info, sizeof (vbe_mode_info)); } /* Try to initialize best mode found. */ - if (best_mode != 0) + if (best_vbe_mode != 0) { grub_err_t err; /* If this fails, then we have mode selection heuristics problem, or adapter failure. */ - grub_vbe_set_video_mode (best_mode, &active_mode_info); + grub_vbe_set_video_mode (best_vbe_mode, &active_vbe_mode_info); if (grub_errno != GRUB_ERR_NONE) return grub_errno; /* Now we are happily in requested video mode. Cache some info in order to fasten later operations. */ - mode_in_use = best_mode; + vbe_mode_in_use = best_vbe_mode; /* Fill mode info details. */ - framebuffer.mode_info.width = active_mode_info.x_resolution; - framebuffer.mode_info.height = active_mode_info.y_resolution; + framebuffer.mode_info.width = active_vbe_mode_info.x_resolution; + framebuffer.mode_info.height = active_vbe_mode_info.y_resolution; if (framebuffer.index_color_mode) framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; else framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB; - framebuffer.mode_info.bpp = active_mode_info.bits_per_pixel; + framebuffer.mode_info.bpp = active_vbe_mode_info.bits_per_pixel; framebuffer.mode_info.bytes_per_pixel = framebuffer.bytes_per_pixel; framebuffer.mode_info.pitch = framebuffer.bytes_per_scan_line; framebuffer.mode_info.number_of_colors = 256; /* TODO: fix me. */ - framebuffer.mode_info.red_mask_size = active_mode_info.red_mask_size; - framebuffer.mode_info.red_field_pos = active_mode_info.red_field_position; - framebuffer.mode_info.green_mask_size = active_mode_info.green_mask_size; - framebuffer.mode_info.green_field_pos = active_mode_info.green_field_position; - framebuffer.mode_info.blue_mask_size = active_mode_info.blue_mask_size; - framebuffer.mode_info.blue_field_pos = active_mode_info.blue_field_position; - framebuffer.mode_info.reserved_mask_size = active_mode_info.rsvd_mask_size; - framebuffer.mode_info.reserved_field_pos = active_mode_info.rsvd_field_position; + framebuffer.mode_info.red_mask_size = active_vbe_mode_info.red_mask_size; + framebuffer.mode_info.red_field_pos = active_vbe_mode_info.red_field_position; + framebuffer.mode_info.green_mask_size = active_vbe_mode_info.green_mask_size; + framebuffer.mode_info.green_field_pos = active_vbe_mode_info.green_field_position; + framebuffer.mode_info.blue_mask_size = active_vbe_mode_info.blue_mask_size; + framebuffer.mode_info.blue_field_pos = active_vbe_mode_info.blue_field_position; + framebuffer.mode_info.reserved_mask_size = active_vbe_mode_info.rsvd_mask_size; + framebuffer.mode_info.reserved_field_pos = active_vbe_mode_info.rsvd_field_position; framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info); @@ -562,8 +562,8 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info, grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info)); *framebuf = (char *) framebuffer.ptr; - grub_free (mode_list); - mode_list = NULL; + grub_free (vbe_mode_list); + vbe_mode_list = NULL; grub_video_fb_fini (); From 19f1b335c38eec9faa292c92b123130a55643e49 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 17 Aug 2009 13:44:07 +0000 Subject: [PATCH 39/45] 2009-08-17 Michal Suchanek VBE cleanup. * video/i386/pc/vbe.c (vbe_mode_in_use): Removed (duplicate). (grub_vbe_set_video_mode): Save active mode info only after setting the mode. (grub_video_vbe_setup): Call 'grub_vbe_set_video_mode' with NULL as second argument. --- ChangeLog | 10 ++++++++++ video/i386/pc/vbe.c | 30 ++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95cd3d0c9..b76fe3858 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-08-17 Michal Suchanek + + VBE cleanup. + + * video/i386/pc/vbe.c (vbe_mode_in_use): Removed (duplicate). + (grub_vbe_set_video_mode): Save active mode info + only after setting the mode. + (grub_video_vbe_setup): Call 'grub_vbe_set_video_mode' with NULL as + second argument. + 2009-08-17 Michal Suchanek Rename variables for clarity. diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index 34885d62e..b41e22fa2 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -46,7 +46,6 @@ static struct } framebuffer; static grub_uint32_t initial_vbe_mode; -static grub_uint32_t vbe_mode_in_use = 0x55aa; static grub_uint16_t *vbe_mode_list; static void * @@ -111,10 +110,11 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block) grub_err_t grub_vbe_set_video_mode (grub_uint32_t vbe_mode, - struct grub_vbe_mode_info_block *vbe_mode_info) + struct grub_vbe_mode_info_block *vbe_mode_info) { grub_vbe_status_t status; grub_uint32_t old_vbe_mode; + struct grub_vbe_mode_info_block new_vbe_mode_info; grub_err_t err; /* Make sure that VBE is supported. */ @@ -123,7 +123,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, return grub_errno; /* Try to get mode info. */ - grub_vbe_get_video_mode_info (vbe_mode, &active_vbe_mode_info); + grub_vbe_get_video_mode_info (vbe_mode, &new_vbe_mode_info); if (grub_errno != GRUB_ERR_NONE) return grub_errno; @@ -134,7 +134,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, vbe_mode |= 1 << 14; /* Determine frame buffer pixel format. */ - switch (active_vbe_mode_info.memory_model) + switch (new_vbe_mode_info.memory_model) { case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL: framebuffer.index_color_mode = 1; @@ -147,7 +147,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported pixel format 0x%x", - active_vbe_mode_info.memory_model); + new_vbe_mode_info.memory_model); } } @@ -163,6 +163,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, /* Save information for later usage. */ framebuffer.active_vbe_mode = vbe_mode; + grub_memcpy (&active_vbe_mode_info, &new_vbe_mode_info, sizeof (active_vbe_mode_info)); if (vbe_mode < 0x100) { @@ -172,16 +173,16 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, } else { - framebuffer.ptr = (grub_uint8_t *) active_vbe_mode_info.phys_base_addr; + framebuffer.ptr = (grub_uint8_t *) new_vbe_mode_info.phys_base_addr; if (controller_info.version >= 0x300) - framebuffer.bytes_per_scan_line = active_vbe_mode_info.lin_bytes_per_scan_line; + framebuffer.bytes_per_scan_line = new_vbe_mode_info.lin_bytes_per_scan_line; else - framebuffer.bytes_per_scan_line = active_vbe_mode_info.bytes_per_scan_line; + framebuffer.bytes_per_scan_line = new_vbe_mode_info.bytes_per_scan_line; } /* Check whether mode is text mode or graphics mode. */ - if (active_vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT) + if (new_vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT) { /* Text mode. */ @@ -193,7 +194,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, /* Graphics mode. */ /* Calculate bytes_per_pixel value. */ - switch(active_vbe_mode_info.bits_per_pixel) + switch(new_vbe_mode_info.bits_per_pixel) { case 32: framebuffer.bytes_per_pixel = 4; break; case 24: framebuffer.bytes_per_pixel = 3; break; @@ -238,7 +239,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode, /* Copy mode info for caller. */ if (vbe_mode_info) - grub_memcpy (vbe_mode_info, &active_vbe_mode_info, sizeof (*vbe_mode_info)); + grub_memcpy (vbe_mode_info, &new_vbe_mode_info, sizeof (*vbe_mode_info)); return GRUB_ERR_NONE; } @@ -468,14 +469,11 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, grub_err_t err; /* If this fails, then we have mode selection heuristics problem, or adapter failure. */ - grub_vbe_set_video_mode (best_vbe_mode, &active_vbe_mode_info); + /* grub_vbe_set_video_mode already sets active_vbe_mode_info. */ + grub_vbe_set_video_mode (best_vbe_mode, NULL); if (grub_errno != GRUB_ERR_NONE) return grub_errno; - /* Now we are happily in requested video mode. Cache some info - in order to fasten later operations. */ - vbe_mode_in_use = best_vbe_mode; - /* Fill mode info details. */ framebuffer.mode_info.width = active_vbe_mode_info.x_resolution; framebuffer.mode_info.height = active_vbe_mode_info.y_resolution; From b7da6babe8eed764a1f6ac7c2bc2c04b1292875c Mon Sep 17 00:00:00 2001 From: proski Date: Tue, 18 Aug 2009 17:26:35 +0000 Subject: [PATCH 40/45] 2009-08-18 Pavel Roskin * include/grub/fbfill.h (struct grub_video_fbrender_target): Use grub_uint8_t pointer for data. * include/grub/fbutil.h (struct grub_video_fbblit_info): Likewise. * video/fb/fbutil.c: Remove unnecessary casts. --- ChangeLog | 8 ++++++++ include/grub/fbfill.h | 2 +- include/grub/fbutil.h | 2 +- video/fb/fbutil.c | 22 ++++++---------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b76fe3858..e132a24f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-08-18 Pavel Roskin + + * include/grub/fbfill.h (struct grub_video_fbrender_target): Use + grub_uint8_t pointer for data. + * include/grub/fbutil.h (struct grub_video_fbblit_info): + Likewise. + * video/fb/fbutil.c: Remove unnecessary casts. + 2009-08-17 Michal Suchanek VBE cleanup. diff --git a/include/grub/fbfill.h b/include/grub/fbfill.h index 08cd7b887..c85fa12dd 100644 --- a/include/grub/fbfill.h +++ b/include/grub/fbfill.h @@ -44,7 +44,7 @@ struct grub_video_fbrender_target /* Pointer to data. Can either be in video card memory or in local host's memory. */ - void *data; + grub_uint8_t *data; }; void diff --git a/include/grub/fbutil.h b/include/grub/fbutil.h index cf7ecc0d8..065ccf9e3 100644 --- a/include/grub/fbutil.h +++ b/include/grub/fbutil.h @@ -28,7 +28,7 @@ struct grub_video_fbblit_info { struct grub_video_mode_info *mode_info; - void *data; + grub_uint8_t *data; }; grub_uint8_t *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, diff --git a/video/fb/fbutil.c b/video/fb/fbutil.c index 1fa48ec59..511beaafc 100644 --- a/video/fb/fbutil.c +++ b/video/fb/fbutil.c @@ -40,28 +40,20 @@ grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, switch (source->mode_info->bpp) { case 32: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 4; + ptr = source->data + y * source->mode_info->pitch + x * 4; break; case 24: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 3; + ptr = source->data + y * source->mode_info->pitch + x * 3; break; case 16: case 15: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x * 2; + ptr = source->data + y * source->mode_info->pitch + x * 2; break; case 8: - ptr = (grub_uint8_t *)source->data - + y * source->mode_info->pitch - + x; + ptr = source->data + y * source->mode_info->pitch + x; break; case 1: @@ -107,8 +99,7 @@ get_pixel (struct grub_video_fbblit_info *source, if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) { int bit_index = y * source->mode_info->width + x; - grub_uint8_t *ptr = (grub_uint8_t *)source->data - + bit_index / 8; + grub_uint8_t *ptr = source->data + bit_index / 8; int bit_pos = 7 - bit_index % 8; color = (*ptr >> bit_pos) & 0x01; } @@ -175,8 +166,7 @@ set_pixel (struct grub_video_fbblit_info *source, if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) { int bit_index = y * source->mode_info->width + x; - grub_uint8_t *ptr = (grub_uint8_t *)source->data - + bit_index / 8; + grub_uint8_t *ptr = source->data + bit_index / 8; int bit_pos = 7 - bit_index % 8; *ptr = (*ptr & ~(1 << bit_pos)) | ((color & 0x01) << bit_pos); } From 9aced5446db4ee17a3730c1c89e35a7776ac2d4d Mon Sep 17 00:00:00 2001 From: proski Date: Tue, 18 Aug 2009 17:57:07 +0000 Subject: [PATCH 41/45] 2009-08-18 Felix Zielcke * util/grub-mkconfig.in: Don't use gfxterm by default if not explicitly specified by the user. --- ChangeLog | 5 +++++ util/grub-mkconfig.in | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e132a24f3..0b929cf74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-18 Felix Zielcke + + * util/grub-mkconfig.in: Don't use gfxterm by default if not + explicitly specified by the user. + 2009-08-18 Pavel Roskin * include/grub/fbfill.h (struct grub_video_fbrender_target): Use diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 5865b89ce..93f96525e 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -141,13 +141,7 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then fi case x${GRUB_TERMINAL_OUTPUT} in - x) - # If this platform supports gfxterm, try to use it. - if test -e ${grub_prefix}/gfxterm.mod ; then - GRUB_TERMINAL_OUTPUT=gfxterm - fi - ;; - xconsole | xserial | xofconsole | xgfxterm) ;; + x | xconsole | xserial | xofconsole | xgfxterm) ;; *) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;; esac From e53cea1182fdaa72e0688bdb074a70e74111d01b Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 18 Aug 2009 19:50:31 +0000 Subject: [PATCH 42/45] 2009-08-18 Felix Zielcke * util/powerpc/ieee1275/grub-mkrescue.in (grub_mkimage): Use grub-mkelfimage. --- ChangeLog | 5 +++++ util/powerpc/ieee1275/grub-mkrescue.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0b929cf74..47d64975a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-18 Felix Zielcke + + * util/powerpc/ieee1275/grub-mkrescue.in (grub_mkimage): Use + grub-mkelfimage. + 2009-08-18 Felix Zielcke * util/grub-mkconfig.in: Don't use gfxterm by default if not diff --git a/util/powerpc/ieee1275/grub-mkrescue.in b/util/powerpc/ieee1275/grub-mkrescue.in index 30bdabed5..63bc7d88b 100644 --- a/util/powerpc/ieee1275/grub-mkrescue.in +++ b/util/powerpc/ieee1275/grub-mkrescue.in @@ -30,7 +30,7 @@ target_cpu=@target_cpu@ platform=@platform@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` -grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` +grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` # Usage: usage # Print the usage. From 7a9094e5bc2a98a97786f61e51b1258e264d8a0c Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 21 Aug 2009 21:40:58 +0000 Subject: [PATCH 43/45] 2009-08-21 Pavel Roskin * Makefile.in (install-local): Remove all files in $(DESTDIR)$(pkglibdir) before installing new files there. --- ChangeLog | 5 +++++ Makefile.in | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 47d64975a..bcb720151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-21 Pavel Roskin + + * Makefile.in (install-local): Remove all files in + $(DESTDIR)$(pkglibdir) before installing new files there. + 2009-08-18 Felix Zielcke * util/powerpc/ieee1275/grub-mkrescue.in (grub_mkimage): Use diff --git a/Makefile.in b/Makefile.in index 25acce7b1..3d97c3985 100644 --- a/Makefile.in +++ b/Makefile.in @@ -212,6 +212,7 @@ install: install-local install-local: all $(SHELL) $(mkinstalldirs) $(DESTDIR)$(pkglibdir) + rm -f $(DESTDIR)$(pkglibdir)/* @list='$(PKGLIB)'; \ for file in $$list; do \ if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \ From 5496c37ebe22262cc7f65fc7dc16f7b8ab446b8d Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 21 Aug 2009 21:42:58 +0000 Subject: [PATCH 44/45] 2009-08-21 Pavel Roskin * Makefile.in (install-local): When checking if a file is in the build directory, use "test -e" to detect symlinks. --- ChangeLog | 3 +++ Makefile.in | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bcb720151..e245d2da8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-08-21 Pavel Roskin + * Makefile.in (install-local): When checking if a file is in the + build directory, use "test -e" to detect symlinks. + * Makefile.in (install-local): Remove all files in $(DESTDIR)$(pkglibdir) before installing new files there. diff --git a/Makefile.in b/Makefile.in index 3d97c3985..8e2cdc6c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -222,7 +222,7 @@ install-local: all $(SHELL) $(mkinstalldirs) $(DESTDIR)$(includedir) @list='$(include_DATA)'; \ for file in $$list; do \ - if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \ + if test -e "$$file"; then dir=; else dir="$(srcdir)/"; fi; \ dest="`echo $$file | sed 's,include/,,'`"; \ destdir="`echo $$dest | sed 's,[^/]*$$,,g'`"; \ $(SHELL) $(mkinstalldirs) $(DESTDIR)$(includedir)/$$destdir; \ From 11d1c7696692d7a6d98c2237dd03204c38baffd1 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sat, 22 Aug 2009 17:47:16 +0000 Subject: [PATCH 45/45] 2009-08-22 Vladimir Serbinenko * commands/xnu_uuid.c (transform): Use grub_memcpy instead of memcpy. --- ChangeLog | 4 ++++ commands/xnu_uuid.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e245d2da8..b72d07e88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-22 Vladimir Serbinenko + + * commands/xnu_uuid.c (transform): Use grub_memcpy instead of memcpy. + 2009-08-21 Pavel Roskin * Makefile.in (install-local): When checking if a file is in the diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index e8e12b072..d5c272d03 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -100,7 +100,7 @@ transform ( MD5_CONTEXT *ctx, const unsigned char *data ) correct_words[i] = grub_le_to_cpu32 (p[i]); } #else - memcpy (correct_words, data, 64); + grub_memcpy (correct_words, data, 64); #endif #define OP(a, b, c, d, s, T) \