merge mainline into yeeloongfw

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-05-23 14:50:11 +02:00
commit 2226d68df1
12 changed files with 211 additions and 40 deletions

View file

@ -1,3 +1,40 @@
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> 2010-05-21 Vladimir Serbinenko <phcoder@gmail.com>
* kern/i386/pc/mmap.c (grub_machine_mmap_iterate): Zero-fill entry * kern/i386/pc/mmap.c (grub_machine_mmap_iterate): Zero-fill entry

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, 0x06, (3 << 8) | index,
langid, descstr.length, (char *) descstrp); 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) if (! *string)
{ {
grub_free (descstrp); grub_free (descstrp);
return GRUB_USB_ERR_INTERNAL; return GRUB_USB_ERR_INTERNAL;
} }
grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, descstrp->length / 2 - 1); *grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
(*string)[descstr.length / 2 - 1] = '\0'; descstrp->length / 2 - 1) = 0;
grub_free (descstrp); grub_free (descstrp);
return GRUB_USB_ERR_NONE; 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_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS) 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/i386.mk
include $(srcdir)/conf/common.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_CFLAGS = $(COMMON_CFLAGS)
hdparm_mod_LDFLAGS = $(COMMON_LDFLAGS) 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) ifeq ($(enable_efiemu), yes)
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)

View file

@ -80,6 +80,7 @@ This edition documents version @value{VERSION}.
* Configuration:: Writing your own configuration file * Configuration:: Writing your own configuration file
* Network:: Downloading OS images from a network * Network:: Downloading OS images from a network
* Serial terminal:: Using GRUB via a serial line * 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 * Preset Menu:: Embedding a configuration file into GRUB
* Images:: GRUB image files * Images:: GRUB image files
* Filesystem:: Filesystem syntax and semantics * 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 GRUB provides you with an alternative menu interface, because the normal
menu requires several fancy features of your terminal. 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 @node Filesystem
@chapter Filesystem syntax and semantics @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->nested = nested;
view->first_timeout = -1; 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); grub_gfxmenu_view_draw (view);
instance->data = view; instance->data = view;

View file

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

View file

@ -707,12 +707,6 @@ real_scroll (void)
draw_cursor (0); draw_cursor (0);
grub_video_set_active_render_target (render_target); 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; i = window.double_repaint ? 2 : 1;
@ -720,6 +714,15 @@ real_scroll (void)
while (i--) 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. */ /* Clear new border area. */
grub_video_fill_rect (color, grub_video_fill_rect (color,
virtual_screen.offset_x, virtual_screen.offset_x,
@ -735,6 +738,10 @@ real_scroll (void)
grub_video_scroll (color, 0, -virtual_screen.normal_char_height grub_video_scroll (color, 0, -virtual_screen.normal_char_height
* virtual_screen.total_scroll); * 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) if (i)
grub_video_swap_buffers (); grub_video_swap_buffers ();
} }
@ -746,9 +753,6 @@ real_scroll (void)
grub_video_scroll (color, 0, -virtual_screen.normal_char_height grub_video_scroll (color, 0, -virtual_screen.normal_char_height
* virtual_screen.total_scroll); * 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); grub_video_set_active_render_target (render_target);
} }

View file

@ -246,6 +246,10 @@ export GRUB_DEFAULT \
GRUB_HIDDEN_TIMEOUT \ GRUB_HIDDEN_TIMEOUT \
GRUB_HIDDEN_TIMEOUT_QUIET \ GRUB_HIDDEN_TIMEOUT_QUIET \
GRUB_TIMEOUT \ GRUB_TIMEOUT \
GRUB_DEFAULT_BUTTON \
GRUB_HIDDEN_TIMEOUT_BUTTON \
GRUB_TIMEOUT_BUTTON \
GRUB_BUTTON_CMOS_ADDRESS \
GRUB_DISTRIBUTOR \ GRUB_DISTRIBUTOR \
GRUB_CMDLINE_LINUX \ GRUB_CMDLINE_LINUX \
GRUB_CMDLINE_LINUX_DEFAULT \ GRUB_CMDLINE_LINUX_DEFAULT \

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