From e2a101ab76764f80afc62141f56520cfdeed65e8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 22 Dec 2009 17:18:48 +0100 Subject: [PATCH 01/12] I/O rw support --- commands/iorw.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++ conf/i386.rmk | 6 ++ 2 files changed, 152 insertions(+) create mode 100644 commands/iorw.c diff --git a/commands/iorw.c b/commands/iorw.c new file mode 100644 index 000000000..5e685a264 --- /dev/null +++ b/commands/iorw.c @@ -0,0 +1,146 @@ +/* memrw.c - command to read / write physical memory */ +/* + * 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 . + */ + +#include +#include +#include +#include +#include + +static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword; +static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword; + +static const struct grub_arg_option options[] = + { + {0, 'v', 0, "Save read value into variable VARNAME.", + "VARNAME", ARG_TYPE_STRING}, + {0, 0, 0, 0, 0, 0} + }; + + +static grub_err_t +grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv) +{ + grub_target_addr_t addr; + grub_uint32_t value = 0; + char buf[sizeof ("XXXXXXXX")]; + + if (argc != 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); + + addr = grub_strtoul (argv[0], 0, 0); + switch (cmd->cmd->name[sizeof ("grub_in") - 1]) + { + case 'l': + value = grub_inl (addr); + break; + + case 'w': + value = grub_inw (addr); + break; + + case 'b': + value = grub_inb (addr); + break; + } + + if (cmd->state[0].set) + { + grub_sprintf (buf, "%x", value); + grub_env_set (cmd->state[0].arg, buf); + } + else + grub_printf ("0x%x\n", value); + + return 0; +} + +static grub_err_t +grub_cmd_write (grub_command_t cmd, int argc, char **argv) +{ + grub_target_addr_t addr; + grub_uint32_t value; + grub_uint32_t mask = 0xffffffff; + + if (argc != 2 && argc != 3) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); + + addr = grub_strtoul (argv[0], 0, 0); + value = grub_strtoul (argv[1], 0, 0); + if (argc == 3) + mask = grub_strtoul (argv[2], 0, 0); + value &= mask; + switch (cmd->name[sizeof ("grub_out") - 1]) + { + case 'l': + if (mask != 0xffffffff) + grub_outl ((grub_inl (addr) & ~mask) | value, addr); + else + grub_outl (value, addr); + break; + + case 'w': + if ((mask & 0xffff) != 0xffff) + grub_outw ((grub_inw (addr) & ~mask) | value, addr); + else + grub_outw (value, addr); + break; + + case 'b': + if ((mask & 0xff) != 0xff) + grub_outb ((grub_inb (addr) & ~mask) | value, addr); + else + grub_outb (value, addr); + break; + } + + return 0; +} + +GRUB_MOD_INIT(memrw) +{ + cmd_read_byte = + grub_register_extcmd ("grub_inb", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "grub_inb PORT", "Read byte from PORT.", options); + cmd_read_word = + grub_register_extcmd ("grub_inw", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "grub_inw PORT", "Read word from PORT.", options); + cmd_read_dword = + grub_register_extcmd ("grub_inl", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "grub_inl PORT", "Read dword from PORT.", options); + cmd_write_byte = + grub_register_command ("grub_outb", grub_cmd_write, + "grub_outb PORT VALUE [MASK]", "Write byte VALUE to PORT."); + cmd_write_word = + grub_register_command ("grub_outw", grub_cmd_write, + "grub_outw PORT VALUE [MASK]", "Write word VALUE to PORT."); + cmd_write_dword = + grub_register_command ("grub_outl", grub_cmd_write, + "grub_outl ADDR VALUE [MASK]", "Write dword VALUE to PORT."); +} + +GRUB_MOD_FINI(memrw) +{ + grub_unregister_extcmd (cmd_read_byte); + grub_unregister_extcmd (cmd_read_word); + grub_unregister_extcmd (cmd_read_dword); + grub_unregister_command (cmd_write_byte); + grub_unregister_command (cmd_write_word); + grub_unregister_command (cmd_write_dword); +} diff --git a/conf/i386.rmk b/conf/i386.rmk index c3f036d0f..45d2c0818 100644 --- a/conf/i386.rmk +++ b/conf/i386.rmk @@ -25,3 +25,9 @@ pkglib_MODULES += ata.mod ata_mod_SOURCES = disk/ata.c ata_mod_CFLAGS = $(COMMON_CFLAGS) ata_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For iorw.mod. +pkglib_MODULES += iorw.mod +iorw_mod_SOURCES = commands/iorw.c +iorw_mod_CFLAGS = $(COMMON_CFLAGS) +iorw_mod_LDFLAGS = $(COMMON_LDFLAGS) From 6392d412a0cf04ea8db9f3d91dfc3b97d22ec853 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 16:53:39 +0100 Subject: [PATCH 02/12] Changelog --- ChangeLog.io | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ChangeLog.io diff --git a/ChangeLog.io b/ChangeLog.io new file mode 100644 index 000000000..59af361c8 --- /dev/null +++ b/ChangeLog.io @@ -0,0 +1,7 @@ +2009-12-27 Vladimir Serbinenko + + * commands/iorw.c: New file. + * conf/i386.rmk (pkglib_MODULES): Add iorw.mod. + (iorw_mod_SOURCES): New variable. + (iorw_mod_CFLAGS): Likewise. + (iorw_mod_LDFLAGS): Likewise. From 16c8e9fd6618ab15d9d6743f68c1021961870775 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Dec 2009 23:01:12 +0100 Subject: [PATCH 03/12] Reimport hotkey support --- ChangeLog.hotkey | 9 +++++++++ include/grub/menu.h | 2 ++ normal/main.c | 39 +++++++++++++++++++++++++++++++++++++++ normal/menu.c | 15 ++++++++++++--- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 ChangeLog.hotkey diff --git a/ChangeLog.hotkey b/ChangeLog.hotkey new file mode 100644 index 000000000..1117b975c --- /dev/null +++ b/ChangeLog.hotkey @@ -0,0 +1,9 @@ +2009-08-24 Vladimir Serbinenko + + Hotkey support + + * include/grub/menu.h (grub_menu_entry): New field 'hotkey'. + * normal/main.c (hotkey_aliases): New variable. + (grub_normal_add_menu_entry): Parse "--hotkey". + * normal/menu_text.c (run_menu): Handle hotkeys. + diff --git a/include/grub/menu.h b/include/grub/menu.h index 78f461b92..e5e5fb110 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -47,6 +47,8 @@ struct grub_menu_entry /* The sourcecode of the menu entry, used by the editor. */ const char *sourcecode; + int hotkey; + /* The next element. */ struct grub_menu_entry *next; }; diff --git a/normal/main.c b/normal/main.c index 6d7a558f3..fd1088a10 100644 --- a/normal/main.c +++ b/normal/main.c @@ -155,6 +155,17 @@ free_menu_entry_classes (struct grub_menu_entry_class *head) } } +static struct +{ + char *name; + int key; +} hotkey_aliases[] = + { + {"backspace", '\b'}, + {"tab", '\t'}, + {"delete", GRUB_TERM_DC} + }; + /* Add a menu entry to the current menu context (as given by the environment variable data slot `menu'). As the configuration file is read, the script parser calls this when a menu entry is to be created. */ @@ -171,6 +182,7 @@ grub_normal_add_menu_entry (int argc, const char **args, struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */ struct grub_menu_entry_class *classes_tail; char *users = NULL; + int hotkey = 0; /* Allocate dummy head node for class list. */ classes_head = grub_zalloc (sizeof (struct grub_menu_entry_class)); @@ -237,6 +249,32 @@ grub_normal_add_menu_entry (int argc, const char **args, continue; } + else if (grub_strcmp(arg, "hotkey") == 0) + { + unsigned j; + + i++; + if (args[i][1] == 0) + { + hotkey = args[i][0]; + continue; + } + + for (j = 0; j < ARRAY_SIZE (hotkey_aliases); j++) + if (grub_strcmp (args[i], hotkey_aliases[j].name) == 0) + { + hotkey = hotkey_aliases[j].key; + break; + } + + if (j < ARRAY_SIZE (hotkey_aliases)) + continue; + + failed = 1; + grub_error (GRUB_ERR_MENU, + "Invalid hotkey: '%s'.", args[i]); + break; + } else { /* Handle invalid argument. */ @@ -293,6 +331,7 @@ grub_normal_add_menu_entry (int argc, const char **args, } (*last)->title = menutitle; + (*last)->hotkey = hotkey; (*last)->classes = classes_head; if (users) (*last)->restricted = 1; diff --git a/normal/menu.c b/normal/menu.c index 850350edd..19e83831d 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -232,9 +232,6 @@ menu_fini (void) viewers = NULL; } -/* FIXME: allow text menu in parallel with gfxmenu. */ -grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu, - int nested) = NULL; static void menu_init (int entry, grub_menu_t menu, int nested) { @@ -479,6 +476,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) goto refresh; default: + { + grub_menu_entry_t entry; + int i; + for (i = 0, entry = menu->entry_list; i < menu->size; + i++, entry = entry->next) + if (entry->hotkey == c) + { + menu_fini (); + *auto_boot = 0; + return i; + } + } break; } } From 1159bdce4a53adba09be544cfe87a02bfe0dea21 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 14 Mar 2010 23:56:13 +0100 Subject: [PATCH 04/12] * kern/mm.c (grub_real_malloc): Satisfy alignment requirement when extra == 0. --- ChangeLog.memalign_fix | 4 ++++ kern/mm.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ChangeLog.memalign_fix diff --git a/ChangeLog.memalign_fix b/ChangeLog.memalign_fix new file mode 100644 index 000000000..3dac2e51c --- /dev/null +++ b/ChangeLog.memalign_fix @@ -0,0 +1,4 @@ +2010-03-14 Vladimir Serbinenko + + * kern/mm.c (grub_real_malloc): Satisfy alignment requirement when + extra == 0. \ No newline at end of file diff --git a/kern/mm.c b/kern/mm.c index ef97b018e..9720a8b9d 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -223,7 +223,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) q->next = p->next; p->magic = GRUB_MM_ALLOC_MAGIC; } - else if (extra == 0 || p->size == n + extra) + else if (align == 1 || p->size == n + extra) { /* There might be alignment requirement, when taking it into account memory block fits in. @@ -240,11 +240,25 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) | alloc, size=n | | +---------------+ v */ + p->size -= n; p += p->size; p->size = n; p->magic = GRUB_MM_ALLOC_MAGIC; } + else if (extra == 0) + { + grub_mm_header_t r; + + p->magic = GRUB_MM_ALLOC_MAGIC; + p->size = n; + + r = p + extra + n; + r->magic = GRUB_MM_FREE_MAGIC; + r->size = p->size - extra - n; + r->next = p->next; + q->next = r; + } else { /* There is alignment requirement and there is room in memory From d8b5cd40114891a5c672a16db5a9209b575b9f26 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 1 May 2010 20:28:07 +0200 Subject: [PATCH 05/12] * commands/hashsum.c (GRUB_MOD_INIT): Remove duplication of command name and add N_. * commands/i386/pc/drivemap.c (GRUB_MOD_INIT): Likewise. * commands/iorw.c (GRUB_MOD_INIT): Likewise. * commands/password_pbkdf2.c (GRUB_MOD_INIT): Likewise. * commands/regexp.c (GRUB_MOD_INIT): Likewise. * commands/setpci.c (GRUB_MOD_INIT): Likewise. * commands/terminal.c (GRUB_MOD_INIT): Likewise. * efiemu/main.c (GRUB_MOD_INIT): Likewise. * font/font_cmd.c (GRUB_MOD_INIT): Likewise. * kern/corecmd.c (GRUB_MOD_INIT): Likewise. * mmap/mmap.c (GRUB_MOD_INIT): Likewise. * normal/context.c (GRUB_MOD_INIT): Likewise. * normal/main.c (GRUB_MOD_INIT): Likewise. * term/gfxterm.c (GRUB_MOD_INIT): Likewise. * term/serial.c (GRUB_MOD_INIT): Likewise. * term/terminfo.c (GRUB_MOD_INIT): Likewise. --- ChangeLog | 20 ++++++++++++++++++++ commands/hashsum.c | 25 +++++++++++++------------ commands/i386/pc/drivemap.c | 9 ++++----- commands/iorw.c | 22 +++++++++++++--------- commands/password_pbkdf2.c | 5 +++-- commands/regexp.c | 5 +++-- commands/setpci.c | 7 ++++--- commands/terminal.c | 12 ++++++------ efiemu/main.c | 9 +++++---- font/font_cmd.c | 7 ++++--- kern/corecmd.c | 11 +++++++---- mmap/mmap.c | 5 +++-- normal/context.c | 3 ++- normal/main.c | 4 ++-- term/gfxterm.c | 5 +++-- term/serial.c | 4 ++-- term/terminfo.c | 3 ++- 17 files changed, 96 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67910495b..ea576b9d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2010-05-01 Vladimir Serbinenko + + * commands/hashsum.c (GRUB_MOD_INIT): Remove duplication of command + name and add N_. + * commands/i386/pc/drivemap.c (GRUB_MOD_INIT): Likewise. + * commands/iorw.c (GRUB_MOD_INIT): Likewise. + * commands/password_pbkdf2.c (GRUB_MOD_INIT): Likewise. + * commands/regexp.c (GRUB_MOD_INIT): Likewise. + * commands/setpci.c (GRUB_MOD_INIT): Likewise. + * commands/terminal.c (GRUB_MOD_INIT): Likewise. + * efiemu/main.c (GRUB_MOD_INIT): Likewise. + * font/font_cmd.c (GRUB_MOD_INIT): Likewise. + * kern/corecmd.c (GRUB_MOD_INIT): Likewise. + * mmap/mmap.c (GRUB_MOD_INIT): Likewise. + * normal/context.c (GRUB_MOD_INIT): Likewise. + * normal/main.c (GRUB_MOD_INIT): Likewise. + * term/gfxterm.c (GRUB_MOD_INIT): Likewise. + * term/serial.c (GRUB_MOD_INIT): Likewise. + * term/terminfo.c (GRUB_MOD_INIT): Likewise. + 2010-05-01 Vladimir Serbinenko * kern/mm.c (grub_real_malloc): Satisfy alignment requirement when diff --git a/commands/hashsum.c b/commands/hashsum.c index 951479fa7..d5f551dbb 100644 --- a/commands/hashsum.c +++ b/commands/hashsum.c @@ -24,13 +24,14 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"hash", 'h', 0, "Specify hash to use.", "HASH", ARG_TYPE_STRING}, - {"check", 'c', 0, "Check hash list file.", "FILE", ARG_TYPE_STRING}, - {"prefix", 'p', 0, "Base directory for hash list.", "DIRECTORY", + {"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING}, + {"check", 'c', 0, N_("Check hash list file."), N_("FILE"), ARG_TYPE_STRING}, + {"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"), ARG_TYPE_STRING}, - {"keep-going", 'k', 0, "Don't stop after first error.", 0, 0}, + {"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -249,21 +250,21 @@ GRUB_MOD_INIT(hashsum) options); cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, GRUB_COMMAND_FLAG_BOTH, - "md5sum [-c FILE [-p PREFIX]] " - "[FILE1 [FILE2 ...]]", - "Compute or check hash checksum.", + N_("[-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]"), + N_("Compute or check hash checksum."), options); cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, GRUB_COMMAND_FLAG_BOTH, - "sha256sum [-c FILE [-p PREFIX]] " - "[FILE1 [FILE2 ...]]", + N_("[-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]"), "Compute or check hash checksum.", options); cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, GRUB_COMMAND_FLAG_BOTH, - "sha512sum [-c FILE [-p PREFIX]] " - "[FILE1 [FILE2 ...]]", - "Compute or check hash checksum.", + N_("[-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]"), + N_("Compute or check hash checksum."), options); } diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index 3baacba49..4afc43358 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -402,11 +402,10 @@ GRUB_MOD_INIT (drivemap) grub_get_root_biosnumber_saved = grub_get_root_biosnumber; grub_get_root_biosnumber = grub_get_root_biosnumber_drivemap; cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap, - GRUB_COMMAND_FLAG_BOTH, - "drivemap" - N_("-l | -r | [-s] grubdev osdisk."), - N_("Manage the BIOS drive mappings."), - options); + GRUB_COMMAND_FLAG_BOTH, + N_("-l | -r | [-s] grubdev osdisk."), + N_("Manage the BIOS drive mappings."), + options); drivemap_hook = grub_loader_register_preboot_hook (&install_int13_handler, &uninstall_int13_handler, diff --git a/commands/iorw.c b/commands/iorw.c index c356d0e36..474c8712e 100644 --- a/commands/iorw.c +++ b/commands/iorw.c @@ -22,14 +22,15 @@ #include #include #include +#include static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword; static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword; static const struct grub_arg_option options[] = { - {0, 'v', 0, "Save read value into variable VARNAME.", - "VARNAME", ARG_TYPE_STRING}, + {0, 'v', 0, N_("Save read value into variable VARNAME."), + N_("VARNAME"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -62,7 +63,7 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv) if (cmd->state[0].set) { - grub_sprintf (buf, "%x", value); + grub_snprintf (buf, sizeof (buf), "%x", value); grub_env_set (cmd->state[0].arg, buf); } else @@ -117,22 +118,25 @@ GRUB_MOD_INIT(memrw) { cmd_read_byte = grub_register_extcmd ("inb", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "PORT", "Read byte from PORT.", options); + N_("PORT"), N_("Read byte from PORT."), options); cmd_read_word = grub_register_extcmd ("inw", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "PORT", "Read word from PORT.", options); + N_("PORT"), N_("Read word from PORT."), options); cmd_read_dword = grub_register_extcmd ("inl", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "PORT", "Read dword from PORT.", options); + N_("PORT"), N_("Read dword from PORT."), options); cmd_write_byte = grub_register_command ("outb", grub_cmd_write, - "PORT VALUE [MASK]", "Write byte VALUE to PORT."); + N_("PORT VALUE [MASK]"), + N_("Write byte VALUE to PORT.")); cmd_write_word = grub_register_command ("outw", grub_cmd_write, - "PORT VALUE [MASK]", "Write word VALUE to PORT."); + N_("PORT VALUE [MASK]"), + N_("Write word VALUE to PORT.")); cmd_write_dword = grub_register_command ("outl", grub_cmd_write, - "ADDR VALUE [MASK]", "Write dword VALUE to PORT."); + N_("ADDR VALUE [MASK]"), + N_("Write dword VALUE to PORT.")); } GRUB_MOD_FINI(memrw) diff --git a/commands/password_pbkdf2.c b/commands/password_pbkdf2.c index 51c8ea794..6886987da 100644 --- a/commands/password_pbkdf2.c +++ b/commands/password_pbkdf2.c @@ -24,6 +24,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -186,8 +187,8 @@ GRUB_MOD_INIT(password_pbkdf2) { my_mod = mod; cmd = grub_register_command ("password_pbkdf2", grub_cmd_password, - "password_pbkdf2 USER PBKDF2_PASSWORD", - "Set user password (PBKDF2). "); + N_("USER PBKDF2_PASSWORD"), + N_("Set user password (PBKDF2). ")); } GRUB_MOD_FINI(password_pbkdf2) diff --git a/commands/regexp.c b/commands/regexp.c index 910bb9082..e8e8243b5 100644 --- a/commands/regexp.c +++ b/commands/regexp.c @@ -21,6 +21,7 @@ #include #include #include +#include #include static grub_err_t @@ -69,8 +70,8 @@ static grub_command_t cmd; GRUB_MOD_INIT(regexp) { cmd = grub_register_command ("regexp", grub_cmd_regexp, - "REGEXP STRING", - "Test if REGEXP matches STRING."); + N_("REGEXP STRING"), + N_("Test if REGEXP matches STRING.")); } GRUB_MOD_FINI(regexp) diff --git a/commands/setpci.c b/commands/setpci.c index f780547a2..fbc7c214e 100644 --- a/commands/setpci.c +++ b/commands/setpci.c @@ -23,6 +23,7 @@ #include #include #include +#include struct pci_register { @@ -329,9 +330,9 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(setpci) { cmd = grub_register_extcmd ("setpci", grub_cmd_setpci, GRUB_COMMAND_FLAG_BOTH, - "setpci [-s POSITION] [-d DEVICE] [-v VAR] " - "[REGISTER][=VALUE[:MASK]]", - "Manipulate PCI devices.", options); + N_("[-s POSITION] [-d DEVICE] [-v VAR] " + "[REGISTER][=VALUE[:MASK]]"), + N_("Manipulate PCI devices."), options); } GRUB_MOD_FINI(setpci) diff --git a/commands/terminal.c b/commands/terminal.c index c8c1ffe09..1129c39bd 100644 --- a/commands/terminal.c +++ b/commands/terminal.c @@ -229,14 +229,14 @@ GRUB_MOD_INIT(terminal) { cmd_terminal_input = grub_register_command ("terminal_input", grub_cmd_terminal_input, - "[--append|--remove] " - "[TERMINAL1] [TERMINAL2] ...", - "List or select an input terminal."); + N_("[--append|--remove] " + "[TERMINAL1] [TERMINAL2] ..."), + N_("List or select an input terminal.")); cmd_terminal_output = grub_register_command ("terminal_output", grub_cmd_terminal_output, - "[--append|--remove] " - "[TERMINAL1] [TERMINAL2] ...", - "List or select an output terminal."); + N_("[--append|--remove] " + "[TERMINAL1] [TERMINAL2] ..."), + N_("List or select an output terminal.")); } GRUB_MOD_FINI(terminal) diff --git a/efiemu/main.c b/efiemu/main.c index 8a8a508fa..b197a8b2c 100644 --- a/efiemu/main.c +++ b/efiemu/main.c @@ -31,6 +31,7 @@ #include #include #include +#include /* System table. Two version depending on mode */ grub_efi_system_table32_t *grub_efiemu_system_table32 = 0; @@ -327,15 +328,15 @@ GRUB_MOD_INIT(efiemu) { cmd_loadcore = grub_register_command ("efiemu_loadcore", grub_cmd_efiemu_load, - "FILE", - "Load and initialize EFI emulator."); + N_("FILE"), + N_("Load and initialize EFI emulator.")); cmd_prepare = grub_register_command ("efiemu_prepare", grub_cmd_efiemu_prepare, 0, - "Finalize loading of EFI emulator."); + N_("Finalize loading of EFI emulator.")); cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload, 0, - "Unload EFI emulator."); + N_("Unload EFI emulator.")); } GRUB_MOD_FINI(efiemu) diff --git a/font/font_cmd.c b/font/font_cmd.c index 5515b2cdc..8b00dd8b9 100644 --- a/font/font_cmd.c +++ b/font/font_cmd.c @@ -21,6 +21,7 @@ #include #include #include +#include static grub_err_t loadfont_command (grub_command_t cmd __attribute__ ((unused)), @@ -62,11 +63,11 @@ GRUB_MOD_INIT(font) cmd_loadfont = grub_register_command ("loadfont", loadfont_command, - "FILE...", - "Specify one or more font files to load."); + N_("FILE..."), + N_("Specify one or more font files to load.")); cmd_lsfonts = grub_register_command ("lsfonts", lsfonts_command, - 0, "List the loaded fonts."); + 0, N_("List the loaded fonts.")); } GRUB_MOD_FINI(font) diff --git a/kern/corecmd.c b/kern/corecmd.c index 8b8df63cb..9af706e94 100644 --- a/kern/corecmd.c +++ b/kern/corecmd.c @@ -26,6 +26,7 @@ #include #include #include +#include /* set ENVVAR=VALUE */ static grub_err_t @@ -178,11 +179,13 @@ void grub_register_core_commands (void) { grub_register_command ("set", grub_core_cmd_set, - "[ENVVAR=VALUE]", "Set an environment variable."); + N_("[ENVVAR=VALUE]"), + N_("Set an environment variable.")); grub_register_command ("unset", grub_core_cmd_unset, - "ENVVAR", "Remove an environment variable."); + N_("ENVVAR"), + N_("Remove an environment variable.")); grub_register_command ("ls", grub_core_cmd_ls, - "[ARG]", "List devices or files."); + N_("[ARG]"), N_("List devices or files.")); grub_register_command ("insmod", grub_core_cmd_insmod, - "MODULE", "Insert a module."); + N_("MODULE"), N_("Insert a module.")); } diff --git a/mmap/mmap.c b/mmap/mmap.c index c22be0a56..a1afc8b06 100644 --- a/mmap/mmap.c +++ b/mmap/mmap.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE @@ -414,8 +415,8 @@ static grub_command_t cmd; GRUB_MOD_INIT(mmap) { cmd = grub_register_command ("badram", grub_cmd_badram, - "ADDR1,MASK1[,ADDR2,MASK2[,...]]", - "Declare memory regions as badram."); + N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"), + N_("Declare memory regions as badram.")); } GRUB_MOD_FINI(mmap) diff --git a/normal/context.c b/normal/context.c index 08a841699..27adf287a 100644 --- a/normal/context.c +++ b/normal/context.c @@ -23,6 +23,7 @@ #include #include #include +#include struct menu_pointer { @@ -172,7 +173,7 @@ grub_context_init (void) grub_env_export ("prefix"); export_cmd = grub_register_command ("export", grub_cmd_export, - "export ENVVAR", "Export a variable."); + N_("ENVVAR"), N_("Export a variable.")); } void diff --git a/normal/main.c b/normal/main.c index 8e49b540b..4ed17e82c 100644 --- a/normal/main.c +++ b/normal/main.c @@ -705,9 +705,9 @@ GRUB_MOD_INIT(normal) /* Register a command "normal" for the rescue mode. */ grub_register_command ("normal", grub_cmd_normal, - 0, "Enter normal mode."); + 0, N_("Enter normal mode.")); grub_register_command ("normal_exit", grub_cmd_normal_exit, - 0, "Exit from normal mode."); + 0, N_("Exit from normal mode.")); /* Reload terminal colors when these variables are written to. */ grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal); diff --git a/term/gfxterm.c b/term/gfxterm.c index a1409980b..ecfe4ff3b 100644 --- a/term/gfxterm.c +++ b/term/gfxterm.c @@ -29,6 +29,7 @@ #include #include #include +#include #define DEFAULT_VIDEO_MODE "auto" #define DEFAULT_BORDER_WIDTH 10 @@ -1187,8 +1188,8 @@ GRUB_MOD_INIT(gfxterm) grub_register_extcmd ("background_image", grub_gfxterm_background_image_cmd, GRUB_COMMAND_FLAG_BOTH, - "[-m (stretch|normal)] FILE", - "Load background image for active terminal.", + N_("[-m (stretch|normal)] FILE"), + N_("Load background image for active terminal."), background_image_cmd_options); } diff --git a/term/serial.c b/term/serial.c index 05497ce40..2347bb3ee 100644 --- a/term/serial.c +++ b/term/serial.c @@ -616,8 +616,8 @@ GRUB_MOD_INIT(serial) { cmd = grub_register_extcmd ("serial", grub_cmd_serial, GRUB_COMMAND_FLAG_BOTH, - "serial [OPTIONS...]", - "Configure serial port.", options); + N_("[OPTIONS...]"), + N_("Configure serial port."), options); /* Set default settings. */ serial_settings.port = serial_hw_get_port (0); diff --git a/term/terminfo.c b/term/terminfo.c index 9a5979b1c..7402d23db 100644 --- a/term/terminfo.c +++ b/term/terminfo.c @@ -31,6 +31,7 @@ #include #include #include +#include struct terminfo { @@ -178,7 +179,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(terminfo) { cmd = grub_register_command ("terminfo", grub_cmd_terminfo, - "[TERM]", "Set terminfo type."); + N_("[TERM]"), N_("Set terminfo type.")); grub_terminfo_set_current ("vt100"); } From f5f3ff9326a27431640bba6e2f8632468029becd Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 1 May 2010 21:31:45 +0200 Subject: [PATCH 06/12] * commands/help.c (grub_cmd_help): Fix a typo. Reported by: Seth Goldberg --- ChangeLog | 5 +++++ commands/help.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ea576b9d2..9ecc94faf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-01 Vladimir Serbinenko + + * commands/help.c (grub_cmd_help): Fix a typo. + Reported by: Seth Goldberg + 2010-05-01 Vladimir Serbinenko * commands/hashsum.c (GRUB_MOD_INIT): Remove duplication of command diff --git a/commands/help.c b/commands/help.c index 1181c3bfb..c2aad03b2 100644 --- a/commands/help.c +++ b/commands/help.c @@ -100,7 +100,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) grub_arg_show_help ((grub_extcmd_t) cmd->data); else - grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary), + grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary), _(cmd->description)); } } From 3558c6e93cb8dda8deb63cc9be884d9c6d34b331 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 1 May 2010 21:32:23 +0200 Subject: [PATCH 07/12] * kern/main.c (grub_load_config): Fix copy-pasted comment. Reported by: Seth Goldberg --- ChangeLog | 5 +++++ kern/main.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9ecc94faf..62252fcfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-01 Vladimir Serbinenko + + * kern/main.c (grub_load_config): Fix copy-pasted comment. + Reported by: Seth Goldberg + 2010-05-01 Vladimir Serbinenko * commands/help.c (grub_cmd_help): Fix a typo. diff --git a/kern/main.c b/kern/main.c index 2f2c951ab..1fdf4ab07 100644 --- a/kern/main.c +++ b/kern/main.c @@ -102,7 +102,7 @@ grub_load_config (void) auto int hook (struct grub_module_header *); int hook (struct grub_module_header *header) { - /* Not an ELF module, skip. */ + /* Not an embedded config, skip. */ if (header->type != OBJ_TYPE_CONFIG) return 0; From d1b61374edb1f77f245317b7ec66909dc8b1a3a3 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Sat, 1 May 2010 21:39:32 +0200 Subject: [PATCH 08/12] * util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root): Remove broken Cygwin path conversion. * util/misc.c: [__CYGWIN__] Add include and define. [__CYGWIN__] (get_win32_path): Copy function from getroot.c, modify for Cygwin 1.7. (make_system_path_relative_to_its_root): Simplify loop, replace early return by break. [__CYGWIN__] Add conversion to win32 path. Include "/" case in trailing slash removal. --- ChangeLog | 12 ++++++++ util/grub-mkconfig_lib.in | 18 ++---------- util/misc.c | 61 ++++++++++++++++++++++++++++----------- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62252fcfc..dadecec86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-05-01 Christian Franke + + * util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root): + Remove broken Cygwin path conversion. + * util/misc.c: [__CYGWIN__] Add include and define. + [__CYGWIN__] (get_win32_path): Copy function from getroot.c, modify + for Cygwin 1.7. + (make_system_path_relative_to_its_root): Simplify loop, replace early + return by break. + [__CYGWIN__] Add conversion to win32 path. + Include "/" case in trailing slash removal. + 2010-05-01 Vladimir Serbinenko * kern/main.c (grub_load_config): Fix copy-pasted comment. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 831bef846..f4674b257 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -1,5 +1,5 @@ # Helper library for grub-mkconfig -# Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 2007,2008,2009,2010 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 @@ -44,21 +44,7 @@ grub_warn () make_system_path_relative_to_its_root () { - path="`${grub_mkrelpath} $1`" - - case "`uname 2>/dev/null`" in - CYGWIN*) - # Cygwin: Check if regular or emulated mount. - if [ -z "$dir" ] || [ "`stat -c %D "$dir/.."`" != 620000 ] ; then - # Reached some mount point not below /cygdrive. - # GRUB does not know Cygwin's emulated mounts, - # convert to Win32 path and remove drive letter. - path=`cygpath -m "$path" | sed -n 's,^[A-Za-z]:,,p'` - test ! -z "$path" || return 1 - fi ;; - esac - - echo "$path" + ${grub_mkrelpath} $1 } is_path_readable_by_grub () diff --git a/util/misc.c b/util/misc.c index 17fa6d5e4..f9d860d9a 100644 --- a/util/misc.c +++ b/util/misc.c @@ -53,6 +53,11 @@ # include #endif +#ifdef __CYGWIN__ +# include +# define DEV_CYGDRIVE_MAJOR 98 +#endif + #ifdef __MINGW32__ #include #include @@ -456,6 +461,27 @@ canonicalize_file_name (const char *path) return ret; } +#ifdef __CYGWIN__ +/* Convert POSIX path to Win32 path, + remove drive letter, replace backslashes. */ +static char * +get_win32_path (const char *path) +{ + char winpath[PATH_MAX]; + if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath))) + grub_util_error ("cygwin_conv_path() failed"); + + int len = strlen (winpath); + int offs = (len > 2 && winpath[1] == ':' ? 2 : 0); + + int i; + for (i = offs; i < len; i++) + if (winpath[i] == '\\') + winpath[i] = '/'; + return xstrdup (winpath + offs); +} +#endif + /* This function never prints trailing slashes (so that its output can be appended a slash unconditionally). */ char * @@ -521,30 +547,31 @@ make_system_path_relative_to_its_root (const char *path) /* offset == 1 means root directory. */ if (offset == 1) { - free (buf); - len = strlen (buf2); - while (buf2[len - 1] == '/' && len > 1) - { - buf2[len - 1] = '\0'; - len--; - } - if (len > 1) - return buf2; - else - { - /* This means path given is just a backslash. As above - we have to return an empty string. */ - free (buf2); - return xstrdup (""); - } + /* Include leading slash. */ + offset = 0; + break; } } free (buf); buf3 = xstrdup (buf2 + offset); free (buf2); +#ifdef __CYGWIN__ + if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16)) + { + /* Reached some mount point not below /cygdrive. + GRUB does not know Cygwin's emulated mounts, + convert to Win32 path. */ + grub_util_info ("Cygwin path = %s\n", buf3); + char * temp = get_win32_path (buf3); + free (buf3); + buf3 = temp; + } +#endif + + /* Remove trailing slashes, return empty string if root directory. */ len = strlen (buf3); - while (buf3[len - 1] == '/' && len > 1) + while (len > 0 && buf3[len - 1] == '/') { buf3[len - 1] = '\0'; len--; From 2589383147fc5b1dbca19428e5ab2dba9ae9c3ac Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 May 2010 12:53:32 +0200 Subject: [PATCH 09/12] * kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0. --- ChangeLog | 4 ++++ kern/mm.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dadecec86..96cfb2ebf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-05-01 Vladimir Serbinenko + + * kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0. + 2010-05-01 Christian Franke * util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root): diff --git a/kern/mm.c b/kern/mm.c index a903991d6..d79f5ce29 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -251,13 +251,20 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) grub_mm_header_t r; p->magic = GRUB_MM_ALLOC_MAGIC; - p->size = n; r = p + extra + n; r->magic = GRUB_MM_FREE_MAGIC; r->size = p->size - extra - n; r->next = p->next; q->next = r; + + if (q == p) + { + q = r; + r->next = r; + } + + p->size = n; } else { From 9b058d5291fbc0407ac07f8ece0a546317a7e3d4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 May 2010 13:07:31 +0200 Subject: [PATCH 10/12] * kern/mm.c (grub_mm_init_region): Check for region size after aligning pointers. --- ChangeLog | 5 +++++ kern/mm.c | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96cfb2ebf..f06602d53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-01 Vladimir Serbinenko + + * kern/mm.c (grub_mm_init_region): Check for region size after aligning + pointers. + 2010-05-01 Vladimir Serbinenko * kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0. diff --git a/kern/mm.c b/kern/mm.c index d79f5ce29..28802945c 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -148,15 +148,14 @@ grub_mm_init_region (void *addr, grub_size_t size) grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size); #endif - /* If this region is too small, ignore it. */ - if (size < GRUB_MM_ALIGN * 2) - return; - /* Allocate a region from the head. */ - r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1) - & (~(GRUB_MM_ALIGN - 1))); + r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); size -= (char *) r - (char *) addr + sizeof (*r); + /* If this region is too small, ignore it. */ + if (size < GRUB_MM_ALIGN) + return; + h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN); h->next = h; h->magic = GRUB_MM_FREE_MAGIC; From 7dd5a111ba41d1e5332898ba71f834f77292156c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 May 2010 13:12:55 +0200 Subject: [PATCH 11/12] * kern/mm.c (grub_real_malloc): Put magic and size assignment in common part. --- ChangeLog | 5 +++++ kern/mm.c | 12 +++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f06602d53..c52e885ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-01 Vladimir Serbinenko + + * kern/mm.c (grub_real_malloc): Put magic and size assignment in common + part. + 2010-05-01 Vladimir Serbinenko * kern/mm.c (grub_mm_init_region): Check for region size after aligning diff --git a/kern/mm.c b/kern/mm.c index 28802945c..47324a662 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -220,7 +220,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) +---------------+ v */ q->next = p->next; - p->magic = GRUB_MM_ALLOC_MAGIC; } else if (align == 1 || p->size == n + extra) { @@ -242,14 +241,10 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) p->size -= n; p += p->size; - p->size = n; - p->magic = GRUB_MM_ALLOC_MAGIC; } else if (extra == 0) { grub_mm_header_t r; - - p->magic = GRUB_MM_ALLOC_MAGIC; r = p + extra + n; r->magic = GRUB_MM_FREE_MAGIC; @@ -262,8 +257,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) q = r; r->next = r; } - - p->size = n; } else { @@ -296,10 +289,11 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) p->size = extra; p->next = r; p += extra; - p->size = n; - p->magic = GRUB_MM_ALLOC_MAGIC; } + p->magic = GRUB_MM_ALLOC_MAGIC; + p->size = n; + /* Mark find as a start marker for next allocation to fasten it. This will have side effect of fragmenting memory as small pieces before this will be un-used. */ From 265d68cd1034e6e6ca6296dcf1c7a29244567d9d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 May 2010 13:17:12 +0200 Subject: [PATCH 12/12] * commands/parttool.c (grub_cmd_parttool): Fix #if !GRUB_NO_MODULES condition. --- ChangeLog | 11 ++++++++--- commands/parttool.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c52e885ee..2a6d5e12a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,19 @@ -2010-05-01 Vladimir Serbinenko +2010-05-03 Vladimir Serbinenko + + * commands/parttool.c (grub_cmd_parttool): Fix #if !GRUB_NO_MODULES + condition. + +2010-05-03 Vladimir Serbinenko * kern/mm.c (grub_real_malloc): Put magic and size assignment in common part. -2010-05-01 Vladimir Serbinenko +2010-05-03 Vladimir Serbinenko * kern/mm.c (grub_mm_init_region): Check for region size after aligning pointers. -2010-05-01 Vladimir Serbinenko +2010-05-03 Vladimir Serbinenko * kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0. diff --git a/commands/parttool.c b/commands/parttool.c index 0850c5e1d..528cf43d7 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } /* Load modules. */ -#if GRUB_NO_MODULES +#if !GRUB_NO_MODULES { const char *prefix; prefix = grub_env_get ("prefix");