merge mainline into gfxmenu

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-25 21:32:46 +01:00
commit 9f293ab0df
198 changed files with 5911 additions and 2701 deletions

View file

@ -109,6 +109,8 @@ grub_device_iterate (int (*hook) (const char *name))
(void) grub_partition_iterate (dev->disk, iterate_partition);
grub_device_close (dev);
grub_errno = GRUB_ERR_NONE;
p = ents;
while (p != NULL)
{

View file

@ -18,6 +18,7 @@
*/
#include <grub/misc.h>
#include <grub/charset.h>
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/efi/console_control.h>
@ -188,6 +189,25 @@ grub_efi_exit_boot_services (grub_efi_uintn_t map_key)
return status == GRUB_EFI_SUCCESS;
}
grub_err_t
grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
grub_efi_uintn_t descriptor_size,
grub_efi_uint32_t descriptor_version,
grub_efi_memory_descriptor_t *virtual_map)
{
grub_efi_runtime_services_t *r;
grub_efi_status_t status;
r = grub_efi_system_table->runtime_services;
status = efi_call_4 (r->set_virtual_address_map, memory_map_size,
descriptor_size, descriptor_version, virtual_map);
if (status == GRUB_EFI_SUCCESS)
return GRUB_ERR_NONE;
return grub_error (GRUB_ERR_IO, "set_virtual_address_map failed");
}
grub_uint32_t
grub_get_rtc (void)
{

View file

@ -181,7 +181,9 @@ grub_elf32_size (grub_elf_t elf)
/* Run through the program headers to calculate the total memory size we
* should claim. */
auto int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf, Elf32_Phdr *phdr, void *_arg);
int NESTED_FUNC_ATTR calcsize (grub_elf_t UNUSED _elf, Elf32_Phdr *phdr, void UNUSED *_arg)
int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf __attribute__ ((unused)),
Elf32_Phdr *phdr,
void *_arg __attribute__ ((unused)))
{
/* Only consider loadable segments. */
if (phdr->p_type != PT_LOAD)
@ -360,7 +362,9 @@ grub_elf64_size (grub_elf_t elf)
/* Run through the program headers to calculate the total memory size we
* should claim. */
auto int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf, Elf64_Phdr *phdr, void *_arg);
int NESTED_FUNC_ATTR calcsize (grub_elf_t UNUSED _elf, Elf64_Phdr *phdr, void UNUSED *_arg)
int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf __attribute__ ((unused)),
Elf64_Phdr *phdr,
void *_arg __attribute__ ((unused)))
{
/* Only consider loadable segments. */
if (phdr->p_type != PT_LOAD)

View file

@ -101,6 +101,7 @@ grub_env_context_open (int export)
grub_env_context_close ();
return grub_errno;
}
grub_env_export (var->name);
grub_register_variable_hook (var->name, var->read_hook, var->write_hook);
}
}
@ -170,8 +171,16 @@ grub_env_export (const char *name)
struct grub_env_var *var;
var = grub_env_find (name);
if (var)
var->type = GRUB_ENV_VAR_GLOBAL;
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->type = GRUB_ENV_VAR_GLOBAL;
return GRUB_ERR_NONE;
}

View file

@ -17,7 +17,6 @@
*/
#include <grub/cpu/io.h>
#include <grub/cpu/halt.h>
#include <grub/machine/init.h>
#include <grub/misc.h>

View file

@ -146,6 +146,9 @@ multiboot_entry:
/* obtain the boot device */
movl 12(%ebx), %edx
movl $GRUB_MEMORY_MACHINE_PROT_STACK, %ebp
movl %ebp, %esp
/* relocate the code */
movl $(GRUB_KERNEL_MACHINE_RAW_SIZE + 0x200), %ecx
addl EXT_C(grub_compressed_size) - _start + 0x100000 + 0x200, %ecx
@ -484,21 +487,6 @@ FUNCTION(grub_exit)
jmp cold_reboot
.code32
/*
* grub_reboot()
*
* Reboot the system. At the moment, rely on BIOS.
*/
FUNCTION(grub_reboot)
call prot_to_real
.code16
cold_reboot:
/* cold boot */
movw $0x0472, %di
movw %ax, (%di)
ljmp $0xFFFF, $0x0000
.code32
/*
* grub_halt(int no_apm)
*

View file

@ -81,7 +81,7 @@ codestart:
movl $END_SYMBOL, %ecx
subl %edi, %ecx
#endif
/* clean out */
xorl %eax, %eax
cld
@ -95,3 +95,5 @@ codestart:
/* This should never happen. */
jmp EXT_C(grub_stop)
#include "../realmode.S"

View file

@ -127,7 +127,7 @@ real_to_prot:
/* turn on protected mode */
movl %cr0, %eax
orl $GRUB_MEMORY_MACHINE_CR0_PE_ON, %eax
orl $GRUB_MEMORY_CPU_CR0_PE_ON, %eax
movl %eax, %cr0
/* jump to relocation, flush prefetch queue, and reload %cs */
@ -196,7 +196,7 @@ tmpcseg:
/* clear the PE bit of CR0 */
movl %cr0, %eax
andl $(~GRUB_MEMORY_MACHINE_CR0_PE_ON), %eax
andl $(~GRUB_MEMORY_CPU_CR0_PE_ON), %eax
movl %eax, %cr0
/* flush prefetch queue, reload %cs */
@ -215,10 +215,27 @@ realcseg:
movw %ax, %gs
movw %ax, %ss
#ifdef GRUB_MACHINE_PCBIOS
/* restore interrupts */
sti
#endif
/* return on new stack! */
DATA32 ret
.code32
/*
* grub_reboot()
*
* Reboot the system. At the moment, rely on BIOS.
*/
FUNCTION(grub_reboot)
call prot_to_real
.code16
cold_reboot:
/* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
movw $0x0472, %di
movw %ax, (%di)
ljmp $0xf000, $0xfff0
.code32

View file

@ -1,32 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/cpu/io.h>
#include <grub/cpu/at_keyboard.h>
#include <grub/cpu/reboot.h>
#include <grub/misc.h>
void
grub_reboot (void)
{
/* Use the keyboard controller to reboot. That's what keyboards were
designed for, isn't it? */
grub_outb (KEYBOARD_COMMAND_REBOOT, KEYBOARD_REG_STATUS);
grub_printf ("GRUB doesn't know how to reboot this machine yet!\n");
}

View file

@ -1,7 +1,7 @@
/* openfw.c -- Open firmware support functions. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 2003,2004,2005,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
@ -399,11 +399,14 @@ grub_ieee1275_encode_devname (const char *path)
return encoding;
}
/* On i386, a firmware-independant grub_reboot() is provided by realmode.S. */
#ifndef __i386__
void
grub_reboot (void)
{
grub_ieee1275_interpret ("reset-all", 0);
}
#endif
void
grub_halt (void)

View file

@ -126,6 +126,38 @@ grub_printf (const char *fmt, ...)
return ret;
}
int
grub_printf_ (const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = grub_vprintf (_(fmt), ap);
va_end (ap);
return ret;
}
int
grub_puts (const char *s)
{
while (*s)
{
grub_putchar (*s);
s++;
}
grub_putchar ('\n');
return 1; /* Cannot fail. */
}
int
grub_puts_ (const char *s)
{
return grub_puts (_(s));
}
#if defined (APPLE_CC) && ! defined (GRUB_UTIL)
int
grub_err_printf (const char *fmt, ...)
@ -843,68 +875,6 @@ grub_sprintf (char *str, const char *fmt, ...)
return ret;
}
/* Convert UTF-16 to UTF-8. */
grub_uint8_t *
grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
grub_size_t size)
{
grub_uint32_t code_high = 0;
while (size--)
{
grub_uint32_t code = *src++;
if (code_high)
{
if (code >= 0xDC00 && code <= 0xDFFF)
{
/* Surrogate pair. */
code = ((code_high - 0xD800) << 12) + (code - 0xDC00) + 0x10000;
*dest++ = (code >> 18) | 0xF0;
*dest++ = ((code >> 12) & 0x3F) | 0x80;
*dest++ = ((code >> 6) & 0x3F) | 0x80;
*dest++ = (code & 0x3F) | 0x80;
}
else
{
/* Error... */
*dest++ = '?';
}
code_high = 0;
}
else
{
if (code <= 0x007F)
*dest++ = code;
else if (code <= 0x07FF)
{
*dest++ = (code >> 6) | 0xC0;
*dest++ = (code & 0x3F) | 0x80;
}
else if (code >= 0xD800 && code <= 0xDBFF)
{
code_high = code;
continue;
}
else if (code >= 0xDC00 && code <= 0xDFFF)
{
/* Error... */
*dest++ = '?';
}
else
{
*dest++ = (code >> 12) | 0xE0;
*dest++ = ((code >> 6) & 0x3F) | 0x80;
*dest++ = (code & 0x3F) | 0x80;
}
}
}
return dest;
}
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
bytes (if SRCSIZE is -1, it is ignored) in length to a UCS-4 string.
Return the number of characters converted. DEST must be able to hold

View file

@ -142,7 +142,7 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
*(bp++) = *val;
}
*argc = 1;
*argc = 0;
do
{
if (! *rd)
@ -188,12 +188,16 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
state = newstate;
}
} while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state));
*(bp++) = '\0';
/* A special case for when the last character was part of a
variable. */
add_var (GRUB_PARSER_STATE_TEXT);
if (bp != buffer && *(bp - 1))
{
*(bp++) = '\0';
(*argc)++;
}
/* Reserve memory for the return values. */
args = grub_malloc (bp - buffer);
@ -219,8 +223,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
bp++;
}
(*argc)--;
return 0;
}

View file

@ -35,9 +35,12 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
if (grub_parser_split_cmdline (line, getline, &n, &args) || n < 0)
return grub_errno;
if (n == 0)
return GRUB_ERR_NONE;
/* In case of an assignment set the environment accordingly
instead of calling a function. */
if (n == 0 && grub_strchr (line, '='))
if (n == 1 && grub_strchr (line, '='))
{
char *val = grub_strchr (args[0], '=');
val[0] = 0;
@ -56,7 +59,7 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
cmd = grub_command_find (name);
if (cmd)
{
(cmd->func) (cmd, n, &args[1]);
(cmd->func) (cmd, n - 1, &args[1]);
}
else
{