merge with mainline

This commit is contained in:
BVK Chaitanya 2010-05-25 17:11:24 +05:30
commit a6b1d2075e
20 changed files with 274 additions and 64 deletions

View file

@ -1,3 +1,74 @@
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
* commands/usbtest.c (grub_usb_get_string): Properly support UTF-16.
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
cmostest support.
* commands/i386/cmostest.c: New file.
* conf/i386-coreboot.rmk (pkglib_MODULES): Add cmostest.mod.
(cmostest_mod_SOURCES): New variable.
(cmostest_mod_CFLAGS): Likewise.
(cmostest_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk: Likewise.
* docs/grub.texi (Vendor power-on keys): New section.
* util/grub-mkconfig.in: export GRUB_DEFAULT_BUTTON,
GRUB_HIDDEN_TIMEOUT_BUTTON, GRUB_TIMEOUT_BUTTON
and GRUB_BUTTON_CMOS_ADDRESS.
* util/grub.d/00_header.in: Handle powering-on by separate button.
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
* gfxmenu/gui_list.c (draw_menu): Don't add scrollbar width to padding.
Removed drawing_scrollbar argument. All users updated
Fixes #29792.
Reported by Jo Shields
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
* gfxmenu/view.c (grub_gfxmenu_draw_terminal_box): Apply only to current
buffer since gfxterm handles double repaint.
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
* gfxmenu/gfxmenu.c (grub_gfxmenu_try): Change viewport on both buffers.
* term/gfxterm.c (real_scroll): Likewise.
2010-05-21 Vladimir Serbinenko <phcoder@gmail.com>
* kern/i386/pc/mmap.c (grub_machine_mmap_iterate): Zero-fill entry
before calling BIOS.
2010-05-21 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/i18n.h: Always enable grub_gettext.
2010-05-21 Vladimir Serbinenko <phcoder@gmail.com>
* kern/i386/pc/init.c (make_install_device): Fix a leftover usage of old
partition naming style.
2010-05-21 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mkconfig.in: Fix handling of -o so that it works when
not the first option.
2010-05-20 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mkrelpath.c (usage): Remove excess apostrophe.
2010-05-20 Colin Watson <cjwatson@ubuntu.com>
* util/misc.c: Move inclusion of <limits.h> to ...
* kern/emu/misc.c: ... here. Needed for canonicalize_file_name.
2010-05-20 Grégoire Sutre <gregoire.sutre@gmail.com>
* kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev) [__NetBSD__]:
Fix merge error in NetBSD code.
(find_partition_start) [__NetBSD__]: Likewise.
2010-05-19 BVK Chaitanya <bvk.groups@gmail.com>
Fix grub-mkrescue usage unit testing.

59
commands/i386/cmostest.c Normal file
View file

@ -0,0 +1,59 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/misc.h>
#include <grub/cmos.h>
static grub_err_t
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
int byte, bit;
char *rest;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
byte = grub_strtoul (argv[0], &rest, 0);
if (*rest != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required.");
bit = grub_strtoul (rest + 1, 0, 0);
if (grub_cmos_read (byte) & (1 << bit))
return GRUB_ERR_NONE;
return grub_error (GRUB_ERR_TEST_FAILURE, "false");
}
static grub_command_t cmd;
GRUB_MOD_INIT(cmostest)
{
cmd = grub_register_command ("cmostest", grub_cmd_cmostest,
"cmostest BYTE:BIT",
"Test bit at BYTE:BIT in CMOS.");
}
GRUB_MOD_FINI(cmostest)
{
grub_unregister_command (cmd);
}

View file

@ -83,15 +83,24 @@ grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
0x06, (3 << 8) | index,
langid, descstr.length, (char *) descstrp);
*string = grub_malloc (descstr.length / 2);
if (descstrp->length == 0)
{
grub_free (descstrp);
*string = grub_strdup ("");
if (! *string)
return GRUB_USB_ERR_INTERNAL;
return GRUB_USB_ERR_NONE;
}
*string = grub_malloc (descstr.length * 2 + 1);
if (! *string)
{
grub_free (descstrp);
return GRUB_USB_ERR_INTERNAL;
}
grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, descstrp->length / 2 - 1);
(*string)[descstr.length / 2 - 1] = '\0';
*grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
descstrp->length / 2 - 1) = 0;
grub_free (descstrp);
return GRUB_USB_ERR_NONE;

View file

@ -68,5 +68,11 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For cmostest.mod
pkglib_MODULES += cmostest.mod
cmostest_mod_SOURCES = commands/i386/cmostest.c
cmostest_mod_CFLAGS = $(COMMON_CFLAGS)
cmostest_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/i386.mk
include $(srcdir)/conf/common.mk

View file

@ -244,6 +244,12 @@ hdparm_mod_SOURCES = commands/hdparm.c lib/hexdump.c
hdparm_mod_CFLAGS = $(COMMON_CFLAGS)
hdparm_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For cmostest.mod
pkglib_MODULES += cmostest.mod
cmostest_mod_SOURCES = commands/i386/cmostest.c
cmostest_mod_CFLAGS = $(COMMON_CFLAGS)
cmostest_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifeq ($(enable_efiemu), yes)
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)

View file

@ -155,6 +155,7 @@ esac
machine_CPPFLAGS="$machine_CPPFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
CPPFLAGS="$CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS"
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CPPFLAGS"
TARGET_CFLAGS="$TARGET_CFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS"
AC_SUBST(host_cpu)

View file

@ -80,6 +80,7 @@ This edition documents version @value{VERSION}.
* Configuration:: Writing your own configuration file
* Network:: Downloading OS images from a network
* Serial terminal:: Using GRUB via a serial line
* Vendor power-on keys:: Changing GRUB behaviour on vendor power-on keys
* Preset Menu:: Embedding a configuration file into GRUB
* Images:: GRUB image files
* Filesystem:: Filesystem syntax and semantics
@ -747,6 +748,23 @@ implements few VT100 escape sequences. If you specify this option then
GRUB provides you with an alternative menu interface, because the normal
menu requires several fancy features of your terminal.
@node Vendor power-on keys
@chapter Using GRUB with vendor power-on keys
Some laptop vendor provide an additional power-on button which boots another OS.
GRUB supports such buttons with GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON,
GRUB_HIDDEN_TIMEOUT_BUTTON and GRUB_BUTTON_CMOS_ADDRESS variables in
default/grub. GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON and
GRUB_HIDDEN_TIMEOUT_BUTTON are used instead of corresponding variables without
_BUTTON suffix when powered using special button.
GRUB_BUTTON_CMOS_ADDRESS is vendor specific and partially model-specific.
Values known to GRUB team are:
@table @key
@item Dell XPS M1530
85:3
@end table
To take full advantage of this function install GRUB into MBR.
@node Filesystem
@chapter Filesystem syntax and semantics

View file

@ -110,6 +110,13 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
view->nested = nested;
view->first_timeout = -1;
grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
if (view->double_repaint)
{
grub_video_swap_buffers ();
grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
}
grub_gfxmenu_view_draw (view);
instance->data = view;

View file

@ -210,8 +210,7 @@ draw_scrollbar (list_impl_t self,
/* Draw the list of items. */
static void
draw_menu (list_impl_t self, int width, int drawing_scrollbar,
int num_shown_items)
draw_menu (list_impl_t self, int width, int num_shown_items)
{
if (! self->menu_box || ! self->selected_item_box)
return;
@ -226,8 +225,6 @@ draw_menu (list_impl_t self, int width, int drawing_scrollbar,
make_selected_item_visible (self);
int scrollbar_h_space = drawing_scrollbar ? self->scrollbar_width : 0;
grub_gfxmenu_box_t selbox = self->selected_item_box;
int sel_leftpad = selbox->get_left_pad (selbox);
int item_top = boxpad;
@ -244,12 +241,8 @@ draw_menu (list_impl_t self, int width, int drawing_scrollbar,
if (is_selected)
{
int sel_toppad = selbox->get_top_pad (selbox);
selbox->set_content_size (selbox,
(width - 2 * boxpad
- scrollbar_h_space),
item_height);
selbox->draw (selbox,
item_left - sel_leftpad,
selbox->set_content_size (selbox, (width - 2 * boxpad), item_height);
selbox->draw (selbox, item_left - sel_leftpad,
item_top - sel_toppad);
}
@ -320,7 +313,7 @@ list_paint (void *vself, const grub_video_rect_t *region)
box->draw (box, 0, 0);
grub_gui_set_viewport (&content_rect, &vpsave2);
draw_menu (self, content_rect.width, drawing_scrollbar, num_shown_items);
draw_menu (self, content_rect.width, num_shown_items);
grub_gui_restore_viewport (&vpsave2);
if (drawing_scrollbar)

View file

@ -354,11 +354,6 @@ grub_gfxmenu_draw_terminal_box (void)
term_box->set_content_size (term_box, term_rect.width,
term_rect.height);
term_box->draw (term_box,
term_rect.x - term_box->get_left_pad (term_box),
term_rect.y - term_box->get_top_pad (term_box));
grub_video_swap_buffers ();
if (term_view->double_repaint)
term_box->draw (term_box,
term_rect.x - term_box->get_left_pad (term_box),
term_rect.y - term_box->get_top_pad (term_box));

View file

@ -22,10 +22,10 @@
#include <config.h>
#include <grub/symbol.h>
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
/* NLS can be disabled through the configure --disable-nls option. */
#if (defined(ENABLE_NLS) && ENABLE_NLS)
#if (defined(ENABLE_NLS) && ENABLE_NLS) || !defined (GRUB_UTIL)
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
# ifdef GRUB_UTIL
@ -41,19 +41,11 @@ extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# ifdef GRUB_UTIL
static inline const char * __attribute__ ((always_inline))
gettext (const char *str)
{
return str;
}
# else
static inline const char * __attribute__ ((always_inline))
grub_gettext (const char *str)
{
return str;
}
# endif /* GRUB_UTIL */
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */

View file

@ -412,7 +412,8 @@ devmapper_fail:
fd = open (dev, O_RDONLY);
if (fd == -1)
{
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' while attempting to get disk geometry", dev);
grub_error (GRUB_ERR_BAD_DEVICE,
"cannot open `%s' while attempting to get disk geometry", dev);
return 0;
}
@ -434,9 +435,6 @@ devmapper_fail:
# if !defined(__NetBSD__)
return hdg.start;
# else /* defined(__NetBSD__) */
/* Since dev and convert_system_partition_to_system_disk (dev) are
* different, we know that dev is of the form /dev/r[wsc]d[0-9]+[a-z]
* and in particular it cannot be a floppy device. */
index = dev[strlen(dev) - 1] - 'a';
if (index >= label.d_npartitions)
@ -1433,7 +1431,6 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
/* Since os_dev and convert_system_partition_to_system_disk (os_dev) are
* different, we know that os_dev is of the form /dev/r[wsc]d[0-9]+[a-z]
* and in particular it cannot be a floppy device. */
index = os_dev[strlen(os_dev) - 1] - 'a';
# endif /* !defined(__NetBSD__) */
start = find_partition_start (os_dev);

View file

@ -9,6 +9,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <grub/mm.h>
#include <grub/err.h>

View file

@ -75,8 +75,8 @@ make_install_device (void)
ptr += grub_strlen (ptr);
if (grub_install_bsd_part >= 0)
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ",%c",
grub_install_bsd_part + 'a');
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ",%u",
grub_install_bsd_part + 1);
ptr += grub_strlen (ptr);
}

View file

@ -20,6 +20,7 @@
#include <grub/machine/memory.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/misc.h>
grub_err_t
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
@ -28,6 +29,8 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
struct grub_machine_mmap_entry *entry
= (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
grub_memset (entry, 0, sizeof (entry));
/* Check if grub_get_mmap_entry works. */
cont = grub_get_mmap_entry (entry, 0);
@ -43,6 +46,8 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
if (! cont)
break;
grub_memset (entry, 0, sizeof (entry));
cont = grub_get_mmap_entry (entry, cont);
}
while (entry->size);

View file

@ -707,12 +707,6 @@ real_scroll (void)
draw_cursor (0);
grub_video_set_active_render_target (render_target);
/* Save viewport and set it to our window. */
grub_video_get_viewport ((unsigned *) &saved_view.x,
(unsigned *) &saved_view.y,
(unsigned *) &saved_view.width,
(unsigned *) &saved_view.height);
grub_video_set_viewport (window.x, window.y, window.width, window.height);
i = window.double_repaint ? 2 : 1;
@ -720,6 +714,15 @@ real_scroll (void)
while (i--)
{
/* Save viewport and set it to our window. */
grub_video_get_viewport ((unsigned *) &saved_view.x,
(unsigned *) &saved_view.y,
(unsigned *) &saved_view.width,
(unsigned *) &saved_view.height);
grub_video_set_viewport (window.x, window.y, window.width,
window.height);
/* Clear new border area. */
grub_video_fill_rect (color,
virtual_screen.offset_x,
@ -735,6 +738,10 @@ real_scroll (void)
grub_video_scroll (color, 0, -virtual_screen.normal_char_height
* virtual_screen.total_scroll);
/* Restore saved viewport. */
grub_video_set_viewport (saved_view.x, saved_view.y,
saved_view.width, saved_view.height);
if (i)
grub_video_swap_buffers ();
}
@ -746,9 +753,6 @@ real_scroll (void)
grub_video_scroll (color, 0, -virtual_screen.normal_char_height
* virtual_screen.total_scroll);
/* Restore saved viewport. */
grub_video_set_viewport (saved_view.x, saved_view.y,
saved_view.width, saved_view.height);
grub_video_set_active_render_target (render_target);
}

View file

@ -50,7 +50,13 @@ EOF
}
# Check the arguments.
next_grub_cfg=false
for option in "$@"; do
if $next_grub_cfg; then
grub_cfg=$option
next_grub_cfg=false
continue
fi
case "$option" in
-h | --help)
usage
@ -59,8 +65,7 @@ for option in "$@"; do
echo "$0 (GNU GRUB ${package_version})"
exit 0 ;;
-o)
shift
grub_cfg=$1
next_grub_cfg=:
;;
--output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'`
@ -72,6 +77,11 @@ for option in "$@"; do
;;
esac
done
if $next_grub_cfg; then
echo "Missing argument to \`-o'" 1>&2
usage
exit 1
fi
. ${libdir}/grub/grub-mkconfig_lib
@ -236,6 +246,10 @@ export GRUB_DEFAULT \
GRUB_HIDDEN_TIMEOUT \
GRUB_HIDDEN_TIMEOUT_QUIET \
GRUB_TIMEOUT \
GRUB_DEFAULT_BUTTON \
GRUB_HIDDEN_TIMEOUT_BUTTON \
GRUB_TIMEOUT_BUTTON \
GRUB_BUTTON_CMOS_ADDRESS \
GRUB_DISTRIBUTOR \
GRUB_CMDLINE_LINUX \
GRUB_CMDLINE_LINUX_DEFAULT \

View file

@ -41,7 +41,7 @@ usage (int status)
printf ("\
Usage: %s [OPTIONS] PATH\n\
\n\
Make a system path relative to it's root.\n\
Make a system path relative to its root.\n\
\n\
Options:\n\
-h, --help display this message and exit\n\

View file

@ -38,11 +38,29 @@ if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
cat << EOF
if [ -s \$prefix/grubenv ]; then
load_env
fi
EOF
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
set default="${GRUB_DEFAULT_BUTTON}"
else
set default="${GRUB_DEFAULT}"
fi
EOF
else
cat <<EOF
set default="${GRUB_DEFAULT}"
EOF
fi
cat <<EOF
if [ \${prev_saved_entry} ]; then
set saved_entry=\${prev_saved_entry}
save_env saved_entry
@ -186,21 +204,36 @@ insmod gettext
EOF
fi
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
make_timeout ()
{
if [ "x${1}" != "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}
if sleep$verbose --interruptible ${1} ; then
set timeout=${2}
fi
EOF
else
else
cat << EOF
set timeout=${GRUB_TIMEOUT}
set timeout=${2}
EOF
fi
}
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
EOF
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"
echo else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
echo fi
else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
fi
# Play an initial tune

View file

@ -30,9 +30,6 @@
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <grub/kernel.h>
#include <grub/dl.h>