merge mainline into gdb

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-18 21:00:13 +01:00
commit 515e8007fc
465 changed files with 26882 additions and 11400 deletions

View file

@ -52,7 +52,6 @@ grub_register_command_prio (const char *name,
void
grub_unregister_command (grub_command_t cmd)
{
grub_prio_list_remove (GRUB_AS_PRIO_LIST_P (&grub_command_list),
GRUB_AS_PRIO_LIST (cmd));
grub_prio_list_remove (GRUB_AS_PRIO_LIST (cmd));
grub_free (cmd);
}

View file

@ -68,7 +68,7 @@ grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
{
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no environment variable specified");
N_("one argument expected"));
grub_env_unset (argv[0]);
return 0;
@ -83,7 +83,7 @@ grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
grub_dl_t mod;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified");
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
p = grub_strchr (argv[0], '/');
if (! p)
@ -133,6 +133,8 @@ grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
char *path;
device_name = grub_file_get_device_name (argv[0]);
if (grub_errno)
goto fail;
dev = grub_device_open (device_name);
if (! dev)
goto fail;

View file

@ -25,6 +25,7 @@
#include <grub/misc.h>
#include <grub/env.h>
#include <grub/partition.h>
#include <grub/i18n.h>
grub_net_t (*grub_net_open) (const char *name) = NULL;
@ -39,7 +40,7 @@ grub_device_open (const char *name)
name = grub_env_get ("root");
if (name == NULL || *name == '\0')
{
grub_error (GRUB_ERR_BAD_DEVICE, "no device is set");
grub_error (GRUB_ERR_BAD_DEVICE, N_("variable `%s' isn't set"), "root");
goto fail;
}
}

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/time.h>
#include <grub/file.h>
#include <grub/i18n.h>
#define GRUB_CACHE_TIMEOUT 2
@ -177,7 +178,7 @@ grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
static grub_disk_dev_t grub_disk_dev_list;
grub_disk_dev_t grub_disk_dev_list;
void
grub_disk_dev_register (grub_disk_dev_t dev)
@ -199,20 +200,6 @@ grub_disk_dev_unregister (grub_disk_dev_t dev)
}
}
int
grub_disk_dev_iterate (int (*hook) (const char *name))
{
grub_disk_dev_t p;
grub_disk_pull_t pull;
for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
for (p = grub_disk_dev_list; p; p = p->next)
if (p->iterate && (p->iterate) (hook, pull))
return 1;
return 0;
}
/* Return the location of the first ',', if any, which is not
escaped by a '\'. */
static const char *
@ -277,7 +264,8 @@ grub_disk_open (const char *name)
if (! dev)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such disk");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
name);
goto fail;
}
if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
@ -296,7 +284,7 @@ grub_disk_open (const char *name)
disk->partition = grub_partition_probe (disk, p + 1);
if (! disk->partition)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such partition");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("no such partition"));
goto fail;
}
}
@ -374,7 +362,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
if (*sector >= len
|| len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of partition");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of partition"));
*sector += start;
}
@ -385,7 +374,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
>> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors
<< (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)) - *sector))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of disk `%s'"), disk->name);
return GRUB_ERR_NONE;
}
@ -607,12 +597,13 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
while (l)
{
(disk->read_hook) (s, o,
((l > GRUB_DISK_SECTOR_SIZE)
? GRUB_DISK_SECTOR_SIZE
: l));
grub_size_t cl;
cl = GRUB_DISK_SECTOR_SIZE - o;
if (cl > l)
cl = l;
(disk->read_hook) (s, o, cl);
s++;
l -= GRUB_DISK_SECTOR_SIZE - o;
l -= cl;
o = 0;
}
}

View file

@ -31,6 +31,7 @@
#include <grub/file.h>
#include <grub/env.h>
#include <grub/cache.h>
#include <grub/i18n.h>
/* Platforms where modules are in a readonly area of memory. */
#if defined(GRUB_MACHINE_QEMU)
@ -43,6 +44,8 @@
#pragma GCC diagnostic ignored "-Wcast-align"
grub_dl_t grub_dl_head = 0;
static grub_err_t
@ -208,20 +211,24 @@ static grub_err_t
grub_dl_check_header (void *ehdr, grub_size_t size)
{
Elf_Ehdr *e = ehdr;
grub_err_t err;
/* Check the header size. */
if (size < sizeof (Elf_Ehdr))
return grub_error (GRUB_ERR_BAD_OS, "ELF header smaller than expected");
/* Check the magic numbers. */
if (grub_arch_dl_check_header (ehdr)
|| e->e_ident[EI_MAG0] != ELFMAG0
if (e->e_ident[EI_MAG0] != ELFMAG0
|| e->e_ident[EI_MAG1] != ELFMAG1
|| e->e_ident[EI_MAG2] != ELFMAG2
|| e->e_ident[EI_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch independent ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch independent ELF magic"));
err = grub_arch_dl_check_header (ehdr);
if (err)
return err;
return GRUB_ERR_NONE;
}
@ -243,7 +250,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
i < e->e_shnum;
i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
{
tsize += ALIGN_UP (s->sh_size, s->sh_addralign);
tsize = ALIGN_UP (tsize, s->sh_addralign) + s->sh_size;
if (talign < s->sh_addralign)
talign = s->sh_addralign;
}
@ -345,7 +352,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symbol table");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
#ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size);
@ -378,7 +385,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
grub_symbol_t nsym = grub_dl_resolve_symbol (name);
if (! nsym)
return grub_error (GRUB_ERR_BAD_MODULE,
"symbol not found: `%s'", name);
N_("symbol `%s' not found"), name);
sym->st_value = (Elf_Addr) nsym->addr;
if (nsym->isfunc)
sym->st_info = ELF_ST_INFO (bind, STT_FUNC);
@ -596,7 +603,7 @@ grub_dl_load_core (void *addr, grub_size_t size)
if (e->e_type != ET_REL)
{
grub_error (GRUB_ERR_BAD_MODULE, "invalid ELF file type");
grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
return 0;
}
@ -704,11 +711,12 @@ grub_dl_load (const char *name)
return mod;
if (! grub_dl_dir) {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
return 0;
}
filename = grub_xasprintf ("%s/%s.mod", grub_dl_dir, name);
filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s.mod",
grub_dl_dir, name);
if (! filename)
return 0;
@ -729,7 +737,6 @@ int
grub_dl_unload (grub_dl_t mod)
{
grub_dl_dep_t dep, depn;
grub_dl_segment_t seg, segn;
if (mod->ref_count > 0)
return 0;
@ -749,13 +756,7 @@ grub_dl_unload (grub_dl_t mod)
grub_free (dep);
}
for (seg = mod->segment; seg; seg = segn)
{
segn = seg->next;
grub_free (seg->addr);
grub_free (seg);
}
grub_free (mod->base);
grub_free (mod->name);
#ifdef GRUB_MODULES_MACHINE_READONLY
grub_free (mod->symtab);

View file

@ -203,6 +203,8 @@ grub_get_rtc (void)
return grub_rtc_get_time_ms ();
}
#pragma GCC diagnostic ignored "-Wcast-align"
/* Search the mods section from the PE32/PE32+ image. This code uses
a PE32 header, but should work with PE32+ as well. */
grub_addr_t
@ -246,6 +248,8 @@ grub_efi_modules_addr (void)
return (grub_addr_t) info;
}
#pragma GCC diagnostic error "-Wcast-align"
char *
grub_efi_get_filename (grub_efi_device_path_t *dp)
{

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -39,7 +40,7 @@ grub_elf_check_header (grub_elf_t elf)
|| e->e_ident[EI_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch independent ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch independent ELF magic"));
return GRUB_ERR_NONE;
}
@ -59,7 +60,7 @@ grub_elf_close (grub_elf_t elf)
}
grub_elf_t
grub_elf_file (grub_file_t file)
grub_elf_file (grub_file_t file, const char *filename)
{
grub_elf_t elf;
@ -75,8 +76,9 @@ grub_elf_file (grub_file_t file)
if (grub_file_read (elf->file, &elf->ehdr, sizeof (elf->ehdr))
!= sizeof (elf->ehdr))
{
grub_error_push ();
grub_error (GRUB_ERR_READ_ERROR, "cannot read ELF header");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
goto fail;
}
@ -101,7 +103,7 @@ grub_elf_open (const char *name)
if (! file)
return 0;
elf = grub_elf_file (file);
elf = grub_elf_file (file, name);
if (! elf)
grub_file_close (file);
@ -118,7 +120,7 @@ grub_elf_is_elf32 (grub_elf_t elf)
}
static grub_err_t
grub_elf32_load_phdrs (grub_elf_t elf)
grub_elf32_load_phdrs (grub_elf_t elf, const char *filename)
{
grub_ssize_t phdrs_size;
@ -135,8 +137,10 @@ grub_elf32_load_phdrs (grub_elf_t elf)
if ((grub_file_seek (elf->file, elf->ehdr.ehdr32.e_phoff) == (grub_off_t) -1)
|| (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{
grub_error_push ();
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
return GRUB_ERR_NONE;
@ -144,6 +148,7 @@ grub_elf32_load_phdrs (grub_elf_t elf)
grub_err_t
grub_elf32_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *),
void *hook_arg)
{
@ -151,7 +156,7 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
unsigned int i;
if (! elf->phdrs)
if (grub_elf32_load_phdrs (elf))
if (grub_elf32_load_phdrs (elf, filename))
return grub_errno;
phdrs = elf->phdrs;
@ -174,7 +179,8 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */
grub_size_t
grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
grub_elf32_size (grub_elf_t elf, const char *filename,
Elf32_Addr *base, grub_uint32_t *max_align)
{
Elf32_Addr segments_start = (Elf32_Addr) -1;
Elf32_Addr segments_end = 0;
@ -201,7 +207,7 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
return 0;
}
grub_elf32_phdr_iterate (elf, calcsize, 0);
grub_elf32_phdr_iterate (elf, filename, calcsize, 0);
if (base)
*base = 0;
@ -228,7 +234,8 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
/* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t
grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
grub_elf32_load (grub_elf_t _elf, const char *filename,
grub_elf32_load_hook_t _load_hook,
grub_addr_t *base, grub_size_t *size)
{
grub_addr_t load_base = (grub_addr_t) -1ULL;
@ -257,11 +264,7 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
(unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
return grub_errno;
if (phdr->p_filesz)
{
@ -270,11 +273,10 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
if (read != (grub_ssize_t) phdr->p_filesz)
{
/* XXX How can we free memory from `load_hook'? */
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"couldn't read segment from file: "
"wanted 0x%lx bytes; read 0x%lx bytes",
phdr->p_filesz, read);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
}
@ -287,7 +289,8 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
return 0;
}
err = grub_elf32_phdr_iterate (_elf, grub_elf32_load_segment, _load_hook);
err = grub_elf32_phdr_iterate (_elf, filename,
grub_elf32_load_segment, _load_hook);
if (base)
*base = load_base;
@ -307,7 +310,7 @@ grub_elf_is_elf64 (grub_elf_t elf)
}
static grub_err_t
grub_elf64_load_phdrs (grub_elf_t elf)
grub_elf64_load_phdrs (grub_elf_t elf, const char *filename)
{
grub_ssize_t phdrs_size;
@ -324,8 +327,10 @@ grub_elf64_load_phdrs (grub_elf_t elf)
if ((grub_file_seek (elf->file, elf->ehdr.ehdr64.e_phoff) == (grub_off_t) -1)
|| (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{
grub_error_push ();
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
return GRUB_ERR_NONE;
@ -333,6 +338,7 @@ grub_elf64_load_phdrs (grub_elf_t elf)
grub_err_t
grub_elf64_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *),
void *hook_arg)
{
@ -340,7 +346,7 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
unsigned int i;
if (! elf->phdrs)
if (grub_elf64_load_phdrs (elf))
if (grub_elf64_load_phdrs (elf, filename))
return grub_errno;
phdrs = elf->phdrs;
@ -363,7 +369,8 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */
grub_size_t
grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
grub_elf64_size (grub_elf_t elf, const char *filename,
Elf64_Addr *base, grub_uint64_t *max_align)
{
Elf64_Addr segments_start = (Elf64_Addr) -1;
Elf64_Addr segments_end = 0;
@ -390,7 +397,7 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
return 0;
}
grub_elf64_phdr_iterate (elf, calcsize, 0);
grub_elf64_phdr_iterate (elf, filename, calcsize, 0);
if (base)
*base = 0;
@ -417,7 +424,8 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
/* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t
grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
grub_elf64_load (grub_elf_t _elf, const char *filename,
grub_elf64_load_hook_t _load_hook,
grub_addr_t *base, grub_size_t *size)
{
grub_addr_t load_base = (grub_addr_t) -1ULL;
@ -447,11 +455,7 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
(unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
return grub_errno;
if (phdr->p_filesz)
{
@ -460,11 +464,10 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
if (read != (grub_ssize_t) phdr->p_filesz)
{
/* XXX How can we free memory from `load_hook'? */
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"couldn't read segment from file: "
"wanted 0x%lx bytes; read 0x%lx bytes",
phdr->p_filesz, read);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
}
@ -477,7 +480,8 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
return 0;
}
err = grub_elf64_phdr_iterate (_elf, grub_elf64_load_segment, _load_hook);
err = grub_elf64_phdr_iterate (_elf, filename,
grub_elf64_load_segment, _load_hook);
if (base)
*base = load_base;

View file

@ -1,293 +0,0 @@
/* console.c -- Ncurses console for GRUB. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,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 <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <config-util.h>
/* For compatibility. */
#ifndef A_NORMAL
# define A_NORMAL 0
#endif /* ! A_NORMAL */
#ifndef A_STANDOUT
# define A_STANDOUT 0
#endif /* ! A_STANDOUT */
#include <grub/emu/console.h>
#include <grub/term.h>
#include <grub/types.h>
#if defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_CURSES_H)
# include <curses.h>
#else
#error What the hell?
#endif
static int grub_console_attr = A_NORMAL;
grub_uint8_t grub_console_cur_color = 7;
static const grub_uint8_t grub_console_standard_color = 0x7;
#define NUM_COLORS 8
static grub_uint8_t color_map[NUM_COLORS] =
{
COLOR_BLACK,
COLOR_BLUE,
COLOR_GREEN,
COLOR_CYAN,
COLOR_RED,
COLOR_MAGENTA,
COLOR_YELLOW,
COLOR_WHITE
};
static int use_color;
static void
grub_ncurses_putchar (struct grub_term_output *term __attribute__ ((unused)),
const struct grub_unicode_glyph *c)
{
addch (c->base | grub_console_attr);
}
static void
grub_ncurses_setcolorstate (struct grub_term_output *term,
grub_term_color_state state)
{
switch (state)
{
case GRUB_TERM_COLOR_STANDARD:
grub_console_cur_color = grub_console_standard_color;
grub_console_attr = A_NORMAL;
break;
case GRUB_TERM_COLOR_NORMAL:
grub_console_cur_color = term->normal_color;
grub_console_attr = A_NORMAL;
break;
case GRUB_TERM_COLOR_HIGHLIGHT:
grub_console_cur_color = term->highlight_color;
grub_console_attr = A_STANDOUT;
break;
default:
break;
}
if (use_color)
{
grub_uint8_t fg, bg;
fg = (grub_console_cur_color & 7);
bg = (grub_console_cur_color >> 4) & 7;
grub_console_attr = (grub_console_cur_color & 8) ? A_BOLD : A_NORMAL;
color_set ((bg << 3) + fg, 0);
}
}
static int
grub_ncurses_getkey (struct grub_term_input *term __attribute__ ((unused)))
{
int c;
wtimeout (stdscr, 100);
c = getch ();
switch (c)
{
case ERR:
return -1;
case KEY_LEFT:
c = GRUB_TERM_KEY_LEFT;
break;
case KEY_RIGHT:
c = GRUB_TERM_KEY_RIGHT;
break;
case KEY_UP:
c = GRUB_TERM_KEY_UP;
break;
case KEY_DOWN:
c = GRUB_TERM_KEY_DOWN;
break;
case KEY_IC:
c = 24;
break;
case KEY_DC:
c = GRUB_TERM_KEY_DC;
break;
case KEY_BACKSPACE:
/* XXX: For some reason ncurses on xterm does not return
KEY_BACKSPACE. */
case 127:
c = '\b';
break;
case KEY_HOME:
c = GRUB_TERM_KEY_HOME;
break;
case KEY_END:
c = GRUB_TERM_KEY_END;
break;
case KEY_NPAGE:
c = GRUB_TERM_KEY_NPAGE;
break;
case KEY_PPAGE:
c = GRUB_TERM_KEY_PPAGE;
break;
}
return c;
}
static grub_uint16_t
grub_ncurses_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
int x;
int y;
getyx (stdscr, y, x);
return (x << 8) | y;
}
static grub_uint16_t
grub_ncurses_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
int x;
int y;
getmaxyx (stdscr, y, x);
return (x << 8) | y;
}
static void
grub_ncurses_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
grub_uint8_t x, grub_uint8_t y)
{
move (y, x);
}
static void
grub_ncurses_cls (struct grub_term_output *term __attribute__ ((unused)))
{
clear ();
refresh ();
}
static void
grub_ncurses_setcursor (struct grub_term_output *term __attribute__ ((unused)),
int on)
{
curs_set (on ? 1 : 0);
}
static void
grub_ncurses_refresh (struct grub_term_output *term __attribute__ ((unused)))
{
refresh ();
}
static grub_err_t
grub_ncurses_init (struct grub_term_output *term __attribute__ ((unused)))
{
initscr ();
raw ();
noecho ();
scrollok (stdscr, TRUE);
nonl ();
intrflush (stdscr, FALSE);
keypad (stdscr, TRUE);
if (has_colors ())
{
start_color ();
if ((COLORS >= NUM_COLORS) && (COLOR_PAIRS >= NUM_COLORS * NUM_COLORS))
{
int i, j, n;
n = 0;
for (i = 0; i < NUM_COLORS; i++)
for (j = 0; j < NUM_COLORS; j++)
init_pair(n++, color_map[j], color_map[i]);
use_color = 1;
}
}
return 0;
}
static grub_err_t
grub_ncurses_fini (struct grub_term_output *term __attribute__ ((unused)))
{
endwin ();
return 0;
}
static struct grub_term_input grub_ncurses_term_input =
{
.name = "console",
.getkey = grub_ncurses_getkey,
};
static struct grub_term_output grub_ncurses_term_output =
{
.name = "console",
.init = grub_ncurses_init,
.fini = grub_ncurses_fini,
.putchar = grub_ncurses_putchar,
.getxy = grub_ncurses_getxy,
.getwh = grub_ncurses_getwh,
.gotoxy = grub_ncurses_gotoxy,
.cls = grub_ncurses_cls,
.setcolorstate = grub_ncurses_setcolorstate,
.setcursor = grub_ncurses_setcursor,
.refresh = grub_ncurses_refresh,
.flags = GRUB_TERM_CODE_TYPE_ASCII
};
void
grub_console_init (void)
{
grub_term_register_output ("console", &grub_ncurses_term_output);
grub_term_register_input ("console", &grub_ncurses_term_input);
}
void
grub_console_fini (void)
{
grub_ncurses_fini (&grub_ncurses_term_output);
}

View file

@ -50,7 +50,7 @@ grub_emu_init (void)
grub_no_autoload = 1;
}
#ifdef __ia64__
#if defined (__ia64__) || defined (__powerpc__)
void grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
grub_size_t *tramp, grub_size_t *got)
{
@ -69,12 +69,4 @@ grub_arch_dl_init_linker (void)
void
grub_emu_post_init (void)
{
grub_lvm_fini ();
grub_mdraid09_fini ();
grub_mdraid1x_fini ();
grub_raid_fini ();
grub_raid_init ();
grub_mdraid09_init ();
grub_mdraid1x_init ();
grub_lvm_init ();
}

File diff suppressed because it is too large Load diff

View file

@ -21,8 +21,10 @@
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <dirent.h>
#include <stdio.h>
@ -54,6 +56,12 @@ is_dir (const char *path, const char *name)
return S_ISDIR (st.st_mode);
}
struct grub_hostfs_data
{
char *filename;
FILE *f;
};
static grub_err_t
grub_hostfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
@ -68,7 +76,8 @@ grub_hostfs_dir (grub_device_t device, const char *path,
dir = opendir (path);
if (! dir)
return grub_error (GRUB_ERR_BAD_FILENAME,
"can't open the hostfs directory `%s'", path);
N_("can't open `%s': %s"), path,
strerror (errno));
while (1)
{
@ -95,12 +104,30 @@ static grub_err_t
grub_hostfs_open (struct grub_file *file, const char *name)
{
FILE *f;
struct grub_hostfs_data *data;
f = fopen (name, "rb");
if (! f)
return grub_error (GRUB_ERR_BAD_FILENAME,
"can't open `%s'", name);
file->data = f;
N_("can't open `%s': %s"), name,
strerror (errno));
data = grub_malloc (sizeof (*data));
if (!data)
{
fclose (f);
return grub_errno;
}
data->filename = grub_strdup (name);
if (!data->filename)
{
grub_free (data);
fclose (f);
return grub_errno;
}
data->f = f;
file->data = data;
#ifdef __MINGW32__
file->size = grub_util_get_disk_size (name);
@ -116,18 +143,20 @@ grub_hostfs_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
{
FILE *f;
struct grub_hostfs_data *data;
f = (FILE *) file->data;
if (fseeko (f, file->offset, SEEK_SET) != 0)
data = file->data;
if (fseeko (data->f, file->offset, SEEK_SET) != 0)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "fseeko: %s", strerror (errno));
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("cannot seek `%s': %s"),
data->filename, strerror (errno));
return -1;
}
unsigned int s = fread (buf, 1, len, f);
unsigned int s = fread (buf, 1, len, data->f);
if (s != len)
grub_error (GRUB_ERR_FILE_READ_ERROR, "fread: %s", strerror (errno));
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("cannot read `%s': %s"),
data->filename, strerror (errno));
return (signed) s;
}
@ -135,10 +164,12 @@ grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_hostfs_close (grub_file_t file)
{
FILE *f;
struct grub_hostfs_data *data;
f = (FILE *) file->data;
fclose (f);
data = file->data;
fclose (data->f);
grub_free (data->filename);
grub_free (data);
return GRUB_ERR_NONE;
}

View file

@ -127,7 +127,7 @@ void grub_emu_init (void);
int
main (int argc, char *argv[])
{
char *dev_map = DEFAULT_DEVICE_MAP;
const char *dev_map = DEFAULT_DEVICE_MAP;
volatile int hold = 0;
int opt;

View file

@ -117,7 +117,7 @@ xmalloc (grub_size_t size)
p = malloc (size);
if (! p)
grub_util_error (_("out of memory"));
grub_util_error ("%s", _("out of memory"));
return p;
}
@ -127,7 +127,7 @@ xrealloc (void *ptr, grub_size_t size)
{
ptr = realloc (ptr, size);
if (! ptr)
grub_util_error (_("out of memory"));
grub_util_error ("%s", _("out of memory"));
return ptr;
}
@ -185,7 +185,7 @@ xasprintf (const char *fmt, ...)
if (vasprintf (&result, fmt, ap) < 0)
{
if (errno == ENOMEM)
grub_util_error (_("out of memory"));
grub_util_error ("%s", _("out of memory"));
return NULL;
}

View file

@ -23,6 +23,7 @@
#include <grub/mm.h>
#include <stdlib.h>
#include <string.h>
#include <grub/i18n.h>
void *
grub_malloc (grub_size_t size)
@ -30,7 +31,7 @@ grub_malloc (grub_size_t size)
void *ret;
ret = malloc (size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return ret;
}
@ -58,7 +59,7 @@ grub_realloc (void *ptr, grub_size_t size)
void *ret;
ret = realloc (ptr, size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return ret;
}
@ -77,11 +78,11 @@ grub_memalign (grub_size_t align, grub_size_t size)
#else
(void) align;
(void) size;
grub_util_error (_("grub_memalign is not supported"));
grub_util_error (_("grub_memalign is not supported on your system"));
#endif
if (!p)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return p;
}

View file

@ -22,18 +22,13 @@
#include <stdarg.h>
#include <grub/i18n.h>
#define GRUB_MAX_ERRMSG 256
#define GRUB_ERROR_STACK_SIZE 10
grub_err_t grub_errno;
char grub_errmsg[GRUB_MAX_ERRMSG];
int grub_err_printed_errors;
static struct
{
grub_err_t errno;
char errmsg[GRUB_MAX_ERRMSG];
} grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
static int grub_error_stack_pos;
static int grub_error_stack_assert;
@ -71,7 +66,7 @@ grub_error_push (void)
if (grub_error_stack_pos < GRUB_ERROR_STACK_SIZE)
{
/* Copy active error message to stack. */
grub_error_stack_items[grub_error_stack_pos].errno = grub_errno;
grub_error_stack_items[grub_error_stack_pos].grub_errno = grub_errno;
grub_memcpy (grub_error_stack_items[grub_error_stack_pos].errmsg,
grub_errmsg,
sizeof (grub_errmsg));
@ -99,7 +94,7 @@ grub_error_pop (void)
/* Pop error message from error stack to current active error. */
grub_error_stack_pos--;
grub_errno = grub_error_stack_items[grub_error_stack_pos].errno;
grub_errno = grub_error_stack_items[grub_error_stack_pos].grub_errno;
grub_memcpy (grub_errmsg,
grub_error_stack_items[grub_error_stack_pos].errmsg,
sizeof (grub_errmsg));

View file

@ -24,6 +24,7 @@
#include <grub/mm.h>
#include <grub/fs.h>
#include <grub/device.h>
#include <grub/i18n.h>
void (*EXPORT_VAR (grub_grubnet_fini)) (void);
@ -41,7 +42,7 @@ grub_file_get_device_name (const char *name)
if (! p)
{
grub_error (GRUB_ERR_BAD_FILENAME, "missing `)'");
grub_error (GRUB_ERR_BAD_FILENAME, N_("missing `%c' symbol"), ')');
return 0;
}
@ -138,7 +139,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
if (file->offset > file->size)
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to read past the end of file");
N_("attempt to read past the end of file"));
return -1;
}
@ -178,7 +179,7 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
if (offset > file->size)
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to seek outside of the file");
N_("attempt to seek outside of the file"));
return -1;
}

View file

@ -26,6 +26,7 @@
#include <grub/types.h>
#include <grub/mm.h>
#include <grub/term.h>
#include <grub/i18n.h>
grub_fs_t grub_fs_list = 0;
@ -97,7 +98,7 @@ grub_fs_probe (grub_device_t device)
else if (device->net && device->net->fs)
return device->net->fs;
grub_error (GRUB_ERR_UNKNOWN_FS, "unknown filesystem");
grub_error (GRUB_ERR_UNKNOWN_FS, N_("unknown filesystem"));
return 0;
}
@ -145,7 +146,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
if (grub_errno != GRUB_ERR_NONE || *p != '+')
{
grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name);
N_("invalid file name `%s'"), name);
goto fail;
}
}
@ -157,7 +158,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
|| (*p && *p != ',' && ! grub_isspace (*p)))
{
grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name);
N_("invalid file name `%s'"), name);
goto fail;
}

View file

@ -42,6 +42,8 @@ extern grub_uint8_t _start[];
extern grub_uint8_t _end[];
extern grub_uint8_t _edata[];
#pragma GCC diagnostic warning "-Wsuggest-attribute=noreturn"
grub_uint32_t
grub_get_rtc (void)
{

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_386)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -100,6 +101,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset);
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
}

View file

@ -34,7 +34,7 @@ static struct multiboot_info kern_multiboot_info;
static grub_uint8_t mmap_entries[sizeof (struct multiboot_mmap_entry) * 32];
void
grub_machine_mmap_init ()
grub_machine_mmap_init (void)
{
if (! startup_multiboot_info)
grub_fatal ("Unable to find Multiboot Information (is CONFIG_MULTIBOOT disabled in coreboot?)");

View file

@ -39,7 +39,7 @@ extern char _end[];
static grub_uint64_t mem_size, above_4g;
void
grub_machine_mmap_init ()
grub_machine_mmap_init (void)
{
grub_uint8_t high, low, b, c, d;
grub_cmos_read (QEMU_CMOS_MEMSIZE_HIGH, &high);

View file

@ -46,7 +46,7 @@
* This is the area for all of the special variables.
*/
.p2align 2 /* force 4-byte alignment */
.p2align 5 /* force 4-byte alignment */
protstack:
.long GRUB_MEMORY_MACHINE_PROT_STACK
@ -79,7 +79,7 @@ protstack:
* description.
*/
.p2align 2 /* force 4-byte alignment */
.p2align 5 /* force 4-byte alignment */
gdt:
.word 0, 0
.byte 0, 0, 0, 0
@ -113,6 +113,7 @@ gdt:
.byte 0, 0x92, 0, 0
.p2align 5
/* this is the GDT descriptor */
gdtdesc:
.word 0x27 /* limit */

View file

@ -22,6 +22,7 @@
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -33,11 +34,13 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_IA_64)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
#define MASK20 ((1 << 20) - 1)
#define MASK19 ((1 << 19) - 1)
@ -181,7 +184,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -265,7 +268,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (0x%x) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -23,6 +23,8 @@
#include <grub/err.h>
#include <grub/mm.h>
#pragma GCC diagnostic ignored "-Wcast-align"
void
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)

View file

@ -27,7 +27,7 @@
int
grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep)
grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
{
struct find_device_args
{
@ -232,7 +232,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
}
int
grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer,
grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
grub_size_t len, grub_ssize_t *actualp)
{
struct write_args

View file

@ -192,11 +192,11 @@ grub_claim_heap (void)
if (len)
{
grub_err_t err;
/* Claim and use it. */
if (grub_claimmap (addr, len) < 0)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"failed to claim heap at 0x%llx, len 0x%llx",
addr, len);
err = grub_claimmap (addr, len);
if (err)
return err;
grub_mm_init_region ((void *) (grub_addr_t) addr, len);
}

View file

@ -34,7 +34,7 @@ enum grub_ieee1275_parse_type
/* Walk children of 'devpath', calling hook for each. */
int
grub_children_iterate (char *devpath,
grub_children_iterate (const char *devpath,
int (*hook) (struct grub_ieee1275_devalias *alias))
{
grub_ieee1275_phandle_t dev;
@ -164,7 +164,7 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
strings, so we will add a NULL byte at the end explicitly. */
pathlen += 1;
devpath = grub_malloc (pathlen);
devpath = grub_malloc (pathlen + 1);
if (! devpath)
{
grub_free (devtype);
@ -173,12 +173,15 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
}
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
&actual))
&actual) || actual < 0)
{
grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname);
goto nextprop;
}
devpath [actual] = '\0';
if (actual > pathlen)
actual = pathlen;
devpath[actual] = '\0';
devpath[pathlen] = '\0';
if (grub_ieee1275_finddevice (devpath, &dev))
{
@ -252,7 +255,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
return args.catch_result;
}
int
grub_err_t
grub_claimmap (grub_addr_t addr, grub_size_t size)
{
if (grub_ieee1275_claim (addr, size, 0, 0))
@ -261,13 +264,13 @@ grub_claimmap (grub_addr_t addr, grub_size_t size)
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
&& grub_ieee1275_map (addr, addr, size, 0x00))
{
grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
(long long) addr, (long long) size);
grub_error (GRUB_ERR_OUT_OF_MEMORY, "map failed: address 0x%llx, size 0x%llx\n",
(long long) addr, (long long) size);
grub_ieee1275_release (addr, size);
return -1;
return grub_errno;
}
return 0;
return GRUB_ERR_NONE;
}
/* Get the device arguments of the Open Firmware node name `path'. */
@ -294,7 +297,8 @@ grub_ieee1275_get_devname (const char *path)
int match_alias (struct grub_ieee1275_devalias *curalias)
{
/* briQ firmware can change capitalization in /chosen/bootpath. */
if (! grub_strncasecmp (curalias->path, path, pathlen))
if (grub_strncasecmp (curalias->path, path, pathlen) == 0
&& curalias->path[pathlen] == 0)
{
newpath = grub_strdup (curalias->name);
return 1;
@ -446,10 +450,10 @@ grub_ieee1275_encode_devname (const char *path)
/* GRUB partition 1 is OF partition 0. */
partno++;
encoding = grub_xasprintf ("%s,%d", device, partno);
encoding = grub_xasprintf ("ieee1275/%s,%d", device, partno);
}
else
encoding = grub_strdup (device);
encoding = grub_xasprintf ("ieee1275/%s", device);
grub_free (partition);
grub_free (device);

View file

@ -21,26 +21,6 @@
#include <grub/misc.h>
#include <grub/mm.h>
void
grub_list_push (grub_list_t *head, grub_list_t item)
{
item->next = *head;
*head = item;
}
void
grub_list_remove (grub_list_t *head, grub_list_t item)
{
grub_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
if (q == item)
{
*p = q->next;
break;
}
}
void *
grub_named_list_find (grub_named_list_t head, const char *name)
{
@ -81,6 +61,9 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
*p = nitem;
nitem->next = q;
if (q)
q->prev = &nitem->next;
nitem->prev = p;
if (! inactive)
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;

View file

@ -190,7 +190,7 @@ grub_load_normal_mode (void)
}
/* The main routine. */
void
void __attribute__ ((noreturn))
grub_main (void)
{
/* First of all, initialize the machine. */

View file

@ -125,7 +125,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
}
}
extern grub_uint32_t grub_total_modules_size;
extern grub_uint32_t grub_total_modules_size __attribute__ ((section(".text")));
grub_addr_t grub_modbase;
void

View file

@ -23,6 +23,7 @@
#include <grub/err.h>
#include <grub/cpu/types.h>
#include <grub/mm.h>
#include <grub/i18n.h>
/* Dummy __gnu_local_gp. Resolved by linker. */
static char __gnu_local_gp_dummy;
@ -43,11 +44,13 @@ grub_arch_dl_check_header (void *ehdr)
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_MIPS)
#endif
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
@ -69,7 +72,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -233,7 +236,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
grub_free (gp);
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown relocation type %d\n",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
break;

View file

@ -18,9 +18,6 @@ extern void grub_video_init (void);
extern void grub_bitmap_init (void);
extern void grub_font_init (void);
extern void grub_gfxterm_init (void);
extern void grub_at_keyboard_init (void);
extern void grub_serial_init (void);
extern void grub_terminfo_init (void);
extern void grub_keylayouts_init (void);
extern void grub_boot_init (void);
extern void grub_vga_text_init (void);

View file

@ -370,11 +370,13 @@ grub_strtoul (const char *str, char **end, int base)
unsigned long long num;
num = grub_strtoull (str, end, base);
#if GRUB_CPU_SIZEOF_LONG != 8
if (num > ~0UL)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "overflow is detected");
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
return ~0UL;
}
#endif
return (unsigned long) num;
}
@ -425,7 +427,8 @@ grub_strtoull (const char *str, char **end, int base)
/* NUM * BASE + DIGIT > ~0ULL */
if (num > grub_divmod64 (~0ULL - digit, base, 0))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "overflow is detected");
grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("overflow is detected"));
return ~0ULL;
}
@ -435,7 +438,8 @@ grub_strtoull (const char *str, char **end, int base)
if (! found)
{
grub_error (GRUB_ERR_BAD_NUMBER, "unrecognized number");
grub_error (GRUB_ERR_BAD_NUMBER,
N_("unrecognized number"));
return 0;
}
@ -749,6 +753,12 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
while (*fmt && grub_isdigit (*fmt))
fmt++;
if (*fmt && *fmt =='.')
fmt++;
while (*fmt && grub_isdigit (*fmt))
fmt++;
p = fmt;
if (*fmt && *fmt == '$')

View file

@ -65,6 +65,7 @@
#include <grub/types.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/i18n.h>
#include <grub/mm_private.h>
#ifdef MM_DEBUG
@ -324,7 +325,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
}
fail:
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return 0;
}

View file

@ -223,32 +223,34 @@ grub_partition_iterate (struct grub_disk *disk,
char *
grub_partition_get_name (const grub_partition_t partition)
{
char *out = 0;
int curlen = 0;
char *out = 0, *ptr;
grub_size_t needlen = 0;
grub_partition_t part;
if (!partition)
return grub_strdup ("");
for (part = partition; part; part = part->parent)
/* Even on 64-bit machines this buffer is enough to hold
longest number. */
needlen += grub_strlen (part->partmap->name) + 1 + 27;
out = grub_malloc (needlen + 1);
if (!out)
return NULL;
ptr = out + needlen;
*ptr = 0;
for (part = partition; part; part = part->parent)
{
/* Even on 64-bit machines this buffer is enough to hold
longest number. */
char buf[grub_strlen (part->partmap->name) + 25];
int strl;
grub_snprintf (buf, sizeof (buf), "%s%d", part->partmap->name,
part->number + 1);
strl = grub_strlen (buf);
if (curlen)
{
out = grub_realloc (out, curlen + strl + 2);
grub_memcpy (out + strl + 1, out, curlen);
out[curlen + 1 + strl] = 0;
grub_memcpy (out, buf, strl);
out[strl] = ',';
curlen = curlen + 1 + strl;
}
else
{
curlen = strl;
out = grub_strdup (buf);
}
char buf[27];
grub_size_t len;
grub_snprintf (buf, sizeof (buf), "%d", part->number + 1);
len = grub_strlen (buf);
ptr -= len;
grub_memcpy (ptr, buf, len);
len = grub_strlen (part->partmap->name);
ptr -= len;
grub_memcpy (ptr, part->partmap->name, len);
*--ptr = ',';
}
grub_memmove (out, ptr + 1, out + needlen - ptr);
return out;
}

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_PPC)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -43,7 +44,6 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
*tramp = 0;
@ -59,8 +59,6 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
if (i == e->e_shnum)
return;
entsize = s->sh_entsize;
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
@ -115,7 +113,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -198,7 +196,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -23,6 +23,7 @@
#include <grub/parser.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/i18n.h>
grub_err_t
grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
@ -63,7 +64,7 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
}
else
{
grub_printf ("Unknown command `%s'\n", name);
grub_printf_ (N_("Unknown command `%s'.\n"), name);
if (grub_command_find ("help"))
grub_printf ("Try `help' for usage\n");
}

View file

@ -74,7 +74,7 @@ grub_rescue_read_line (char **line, int cont)
return 0;
}
void
void __attribute__ ((noreturn))
grub_rescue_run (void)
{
grub_printf ("Entering rescue mode...\n");

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,11 +33,12 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_SPARCV9)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
/* Relocate symbols. */
grub_err_t
@ -55,7 +57,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -111,10 +113,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
(((grub_int32_t) ((value - (Elf_Addr) addr) >> 2)) &
0x3FFFFFFF);
break;
case R_SPARC_HH22: /* 9 V-imm22 */
*addr = (*addr & 0xFFC00000) | ((value >> 42) & 0x3FFFFF);
break;
case R_SPARC_HM10: /* 12 T-simm13 */
*addr = (*addr & 0xFFFFFC00) | ((value >> 32) & 0x3FF);
break;
case R_SPARC_HI22: /* 9 V-imm22 */
if (((grub_int32_t) value) & 0xFF00000000)
return grub_error (GRUB_ERR_BAD_MODULE,
"high address out of 22 bits range");
*addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
break;
case R_SPARC_LO10: /* 12 T-simm13 */
@ -131,7 +136,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -79,16 +79,11 @@ grub_xputs_dumb (const char *str)
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
static int pending_key = GRUB_TERM_NO_KEY;
int
grub_checkkey (void)
grub_getkey_noblock (void)
{
grub_term_input_t term;
if (pending_key != GRUB_TERM_NO_KEY)
return pending_key;
if (grub_term_poll_usb)
grub_term_poll_usb ();
@ -97,12 +92,12 @@ grub_checkkey (void)
FOR_ACTIVE_TERM_INPUTS(term)
{
pending_key = term->getkey (term);
if (pending_key != GRUB_TERM_NO_KEY)
return pending_key;
int key = term->getkey (term);
if (key != GRUB_TERM_NO_KEY)
return key;
}
return -1;
return GRUB_TERM_NO_KEY;
}
int
@ -112,18 +107,15 @@ grub_getkey (void)
grub_refresh ();
grub_checkkey ();
while (pending_key == GRUB_TERM_NO_KEY)
while (1)
{
ret = grub_getkey_noblock ();
if (ret != GRUB_TERM_NO_KEY)
return ret;
grub_cpu_idle ();
grub_checkkey ();
}
ret = pending_key;
pending_key = GRUB_TERM_NO_KEY;
return ret;
}
void
grub_refresh (void)
{

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_X86_64)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -108,9 +109,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*addr32 += rel->r_addend + sym->st_value;
break;
default:
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -25,7 +25,7 @@
* different call conversion, so we need to do some conversion.
*
* gcc:
* %rdi, %esi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ...
* %rdi, %rsi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ...
*
* efi:
* %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ...