merge from trunk

This commit is contained in:
Colin Watson 2010-01-05 10:53:03 +00:00
commit bc11fee9f5
260 changed files with 7022 additions and 3839 deletions

1130
ChangeLog

File diff suppressed because it is too large Load diff

View file

@ -109,11 +109,13 @@ endif
AWK = @AWK@
LIBCURSES = @LIBCURSES@
LIBUSB = @LIBUSB@
LIBPCIACCESS = @LIBPCIACCESS@
YACC = @YACC@
FONT_SOURCE = @FONT_SOURCE@
# Options.
enable_grub_emu_usb = @enable_grub_emu_usb@
enable_grub_emu_pci = @enable_grub_emu_pci@
enable_grub_fstest = @enable_grub_fstest@
enable_grub_pe2elf = @enable_grub_pe2elf@
enable_grub_mkfont = @enable_grub_mkfont@
@ -139,7 +141,9 @@ CLEANFILES =
MOSTLYCLEANFILES =
DISTCLEANFILES = config.status config.cache config.log config.h \
Makefile stamp-h include/grub/cpu include/grub/machine \
gensymlist.sh genkernsyms.sh build_env.mk
gensymlist.sh genkernsyms.sh build_env.mk \
docs/grub.info docs/version.texi docs/stamp-vti
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \
$(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS)
@ -165,7 +169,7 @@ endif
### General targets.
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
cat $(DEFSYMFILES) /dev/null \
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
@ -186,6 +190,9 @@ handler.lst: $(HANDLERFILES)
parttool.lst: $(PARTTOOLFILES)
cat $^ /dev/null | sort | uniq > $@
video.lst: $(VIDEOFILES)
cat $^ /dev/null | sort | uniq > $@
ifneq (true, $(MAKEINFO))
info_INFOS += docs/grub.info
endif
@ -477,8 +484,8 @@ genkernsyms.sh: genkernsyms.sh.in config.status
$(SHELL) ./config.status
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
cd $(srcdir) && $(XGETTEXT) --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_
cd $(srcdir) && $(XGETTEXT) --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
$(MSGMERGE) -U $@ $^

6
NEWS
View file

@ -1,7 +1,11 @@
New in 1.97 - :
New in 1.98:
* Add grub-probe support for GNU/Hurd.
* Add support for gettext.
New in 1.97:
* Add support for loading XNU (MacOS X kernel).
* ACPI override support.

1
THANKS
View file

@ -8,6 +8,7 @@ generally assist in the GRUB 2 maintainership process:
Andrey Shuvikov <mr_hyro@yahoo.com>
Bibo Mao <bibo.mao@intel.com>
David Miller <davem@davemloft.net>
Guillem Jover <guillem@hadrons.org>
Harley D. Eades III <hde@foobar-qux.org>
Hitoshi Ozeki <h-ozeki@ck2.so-net.ne.jp>

View file

@ -185,7 +185,7 @@ real_code_2:
call LOCAL(move_memory)
/* Check for multiboot signature. */
cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END)
cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END)
jz 1f
movl (ramdisk_image - start), %esi

View file

@ -21,41 +21,40 @@
#include <grub/pci.h>
grub_pci_address_t
grub_pci_make_address (int bus, int device, int function, int reg)
grub_pci_make_address (grub_pci_device_t dev, int reg)
{
return (1 << 31) | (bus << 16) | (device << 11) | (function << 8) | (reg << 2);
return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
| (dev.function << 8) | (reg << 2);
}
void
grub_pci_iterate (grub_pci_iteratefunc_t hook)
{
int bus;
int dev;
int func;
grub_pci_device_t dev;
grub_pci_address_t addr;
grub_pci_id_t id;
grub_uint32_t hdr;
for (bus = 0; bus < 256; bus++)
for (dev.bus = 0; dev.bus < 256; dev.bus++)
{
for (dev = 0; dev < 32; dev++)
for (dev.device = 0; dev.device < 32; dev.device++)
{
for (func = 0; func < 8; func++)
for (dev.function = 0; dev.function < 8; dev.function++)
{
addr = grub_pci_make_address (bus, dev, func, 0);
addr = grub_pci_make_address (dev, 0);
id = grub_pci_read (addr);
/* Check if there is a device present. */
if (id >> 16 == 0xFFFF)
continue;
if (hook (bus, dev, func, id))
if (hook (dev, id))
return;
/* Probe only func = 0 if the device if not multifunction */
if (func == 0)
if (dev.function == 0)
{
addr = grub_pci_make_address (bus, dev, func, 3);
addr = grub_pci_make_address (dev, 3);
hdr = grub_pci_read (addr);
if (!(hdr & 0x800000))
break;

View file

@ -113,7 +113,7 @@ grub_ohci_writereg32 (struct grub_ohci *o,
/* Iterate over all PCI devices. Determine if a device is an OHCI
controller. If this is the case, initialize it. */
static int NESTED_FUNC_ATTR
grub_ohci_pci_iter (int bus, int device, int func,
grub_ohci_pci_iter (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__((unused)))
{
grub_uint32_t class_code;
@ -126,7 +126,7 @@ grub_ohci_pci_iter (int bus, int device, int func,
grub_uint32_t revision;
grub_uint32_t frame_interval;
addr = grub_pci_make_address (bus, device, func, 2);
addr = grub_pci_make_address (dev, 2);
class_code = grub_pci_read (addr) >> 8;
interf = class_code & 0xFF;
@ -138,7 +138,7 @@ grub_ohci_pci_iter (int bus, int device, int func,
return 0;
/* Determine IO base address. */
addr = grub_pci_make_address (bus, device, func, 4);
addr = grub_pci_make_address (dev, 4);
base = grub_pci_read (addr);
#if 0

View file

@ -23,7 +23,6 @@
#include <grub/usb.h>
#include <grub/usbtrans.h>
#include <grub/pci.h>
#include <grub/cpu/pci.h>
#include <grub/i386/io.h>
#include <grub/time.h>
@ -138,7 +137,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
/* Iterate over all PCI devices. Determine if a device is an UHCI
controller. If this is the case, initialize it. */
static int NESTED_FUNC_ATTR
grub_uhci_pci_iter (int bus, int device, int func,
grub_uhci_pci_iter (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__((unused)))
{
grub_uint32_t class_code;
@ -151,7 +150,7 @@ grub_uhci_pci_iter (int bus, int device, int func,
struct grub_uhci *u;
int i;
addr = grub_pci_make_address (bus, device, func, 2);
addr = grub_pci_make_address (dev, 2);
class_code = grub_pci_read (addr) >> 8;
interf = class_code & 0xFF;
@ -163,7 +162,7 @@ grub_uhci_pci_iter (int bus, int device, int func,
return 0;
/* Determine IO base address. */
addr = grub_pci_make_address (bus, device, func, 8);
addr = grub_pci_make_address (dev, 8);
base = grub_pci_read (addr);
/* Stop if there is no IO space base address defined. */
if (! (base & 1))
@ -435,6 +434,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
grub_uhci_td_t td_prev = NULL;
grub_usb_err_t err = GRUB_USB_ERR_NONE;
int i;
grub_uint64_t endtime;
/* Allocate a queue head for the transfer queue. */
qh = grub_alloc_qh (u, GRUB_USB_TRANSACTION_TYPE_CONTROL);
@ -483,6 +483,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
/* Wait until either the transaction completed or an error
occurred. */
endtime = grub_get_time_ms () + 1000;
for (;;)
{
grub_uhci_td_t errtd;
@ -534,6 +535,13 @@ grub_uhci_transfer (grub_usb_controller_t dev,
updated. */
grub_dprintf ("uhci", "transaction fallthrough\n");
}
if (grub_get_time_ms () > endtime)
{
err = GRUB_USB_ERR_STALL;
grub_dprintf ("uhci", "transaction timed out\n");
goto fail;
}
grub_cpu_idle ();
}
grub_dprintf ("uhci", "transaction complete\n");
@ -573,6 +581,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
struct grub_uhci *u = (struct grub_uhci *) dev->data;
int reg;
unsigned int status;
grub_uint64_t endtime;
grub_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
@ -595,6 +604,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
status = grub_uhci_readreg16 (u, reg);
grub_uhci_writereg16 (u, reg, status & ~(1 << 9));
grub_dprintf ("uhci", "reset completed\n");
grub_millisleep (10);
/* Enable the port. */
grub_uhci_writereg16 (u, reg, enable << 2);
@ -602,7 +612,10 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
grub_dprintf ("uhci", "waiting for the port to be enabled\n");
while (! (grub_uhci_readreg16 (u, reg) & (1 << 2)));
endtime = grub_get_time_ms () + 1000;
while (! (grub_uhci_readreg16 (u, reg) & (1 << 2)))
if (grub_get_time_ms () > endtime)
return grub_error (GRUB_ERR_IO, "UHCI Timed out");
status = grub_uhci_readreg16 (u, reg);
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);

View file

@ -155,42 +155,6 @@ grub_usb_get_endpdescriptor (grub_usb_device_t usbdev, int addr)
return NULL;
}
grub_usb_err_t
grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
char **string)
{
struct grub_usb_desc_str descstr;
struct grub_usb_desc_str *descstrp;
grub_usb_err_t err;
/* Only get the length. */
err = grub_usb_control_msg (dev, 1 << 7,
0x06, (3 << 8) | index,
langid, 1, (char *) &descstr);
if (err)
return err;
descstrp = grub_malloc (descstr.length);
if (! descstrp)
return GRUB_USB_ERR_INTERNAL;
err = grub_usb_control_msg (dev, 1 << 7,
0x06, (3 << 8) | index,
langid, descstr.length, (char *) descstrp);
*string = grub_malloc (descstr.length / 2);
if (! *string)
{
grub_free (descstrp);
return GRUB_USB_ERR_INTERNAL;
}
grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, descstrp->length / 2 - 1);
(*string)[descstr.length / 2 - 1] = '\0';
grub_free (descstrp);
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_device_initialize (grub_usb_device_t dev)
{

View file

@ -48,9 +48,9 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller, grub_usb_speed_t speed)
if (! grub_usb_devs[i])
break;
}
if (grub_usb_devs[i])
if (i == 128)
{
grub_error (GRUB_ERR_IO, "Can't assign address to USB device");
grub_error (GRUB_ERR_IO, "can't assign address to USB device");
return NULL;
}
@ -60,6 +60,7 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller, grub_usb_speed_t speed)
| GRUB_USB_REQTYPE_TARGET_DEV),
GRUB_USB_REQ_SET_ADDRESS,
i, 0, 0, NULL);
dev->addr = i;
dev->initialized = 1;
grub_usb_devs[i] = dev;

View file

@ -36,23 +36,23 @@
static const struct grub_arg_option options[] = {
{"exclude", 'x', 0,
"Don't load host tables specified by comma-separated list",
"Don't load host tables specified by comma-separated list.",
0, ARG_TYPE_STRING},
{"load-only", 'n', 0,
"Load only tables specified by comma-separated list", 0, ARG_TYPE_STRING},
{"v1", '1', 0, "Expose v1 tables", 0, ARG_TYPE_NONE},
{"v2", '2', 0, "Expose v2 and v3 tables", 0, ARG_TYPE_NONE},
{"oemid", 'o', 0, "Set OEMID of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
"Load only tables specified by comma-separated list.", 0, ARG_TYPE_STRING},
{"v1", '1', 0, "Expose v1 tables.", 0, ARG_TYPE_NONE},
{"v2", '2', 0, "Expose v2 and v3 tables.", 0, ARG_TYPE_NONE},
{"oemid", 'o', 0, "Set OEMID of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING},
{"oemtable", 't', 0,
"Set OEMTABLE ID of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
"Set OEMTABLE ID of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING},
{"oemtablerev", 'r', 0,
"Set OEMTABLE revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
"Set OEMTABLE revision of RSDP, XSDT and RSDT.", 0, ARG_TYPE_INT},
{"oemtablecreator", 'c', 0,
"Set creator field of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
"Set creator field of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING},
{"oemtablecreatorrev", 'd', 0,
"Set creator revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
{"no-ebda", 'e', 0, "Don't update EBDA. May fix failures or hangs on some"
" BIOSes but makes it ineffective with OS not receiving RSDP from GRUB",
"Set creator revision of RSDP, XSDT and RSDT.", 0, ARG_TYPE_INT},
{"no-ebda", 'e', 0, "Don't update EBDA. May fix failures or hangs on some."
" BIOSes but makes it ineffective with OS not receiving RSDP from GRUB.",
0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
@ -277,7 +277,7 @@ grub_acpi_create_ebda (void)
{
grub_mmap_unregister (mmapregion);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't find suitable spot in EBDA");
"couldn't find suitable spot in EBDA");
}
/* Remove any other RSDT. */
@ -551,7 +551,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
grub_free (exclude);
grub_free (load_only);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate table");
"couldn't allocate table");
}
grub_memcpy (table_dsdt, dsdt, dsdt->length);
}
@ -578,7 +578,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
grub_free (exclude);
grub_free (load_only);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate table structure");
"couldn't allocate table structure");
}
table->size = curtable->length;
table->addr = grub_malloc (table->size);
@ -587,7 +587,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
{
free_tables ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate table");
"couldn't allocate table");
}
table->next = acpi_tables;
acpi_tables = table;
@ -674,7 +674,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
{
free_tables ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate table structure");
"couldn't allocate table structure");
}
table->size = size;
@ -709,7 +709,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
{
free_tables ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate space for ACPI tables");
"couldn't allocate space for ACPI tables");
}
setup_common_tables ();
@ -759,11 +759,11 @@ GRUB_MOD_INIT(acpi)
{
cmd = grub_register_extcmd ("acpi", grub_cmd_acpi,
GRUB_COMMAND_FLAG_BOTH,
"acpi [-1|-2] [--exclude=table1,table2|"
"[-1|-2] [--exclude=table1,table2|"
"--load-only=table1,table2] filename1 "
" [filename2] [...]",
"Load host acpi tables and tables "
"specified by arguments",
"specified by arguments.",
options);
}

View file

@ -87,7 +87,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
if (! file->device->disk)
return grub_error (GRUB_ERR_BAD_DEVICE,
"this command is available only for disk devices.");
"this command is available only for disk devices");
if (file->device->disk->partition)
part_start = grub_partition_get_start (file->device->disk->partition);
@ -110,7 +110,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(blocklist)
{
cmd = grub_register_command ("blocklist", grub_cmd_blocklist,
"blocklist FILE", "Print a block list.");
"FILE", "Print a block list.");
}
GRUB_MOD_FINI(blocklist)

View file

@ -186,7 +186,7 @@ GRUB_MOD_INIT(boot)
{
cmd_boot =
grub_register_command ("boot", grub_cmd_boot,
0, "boot an operating system");
0, "Boot an operating system.");
}
GRUB_MOD_FINI(boot)

View file

@ -78,7 +78,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(cat)
{
cmd = grub_register_command_p1 ("cat", grub_cmd_cat,
"cat FILE", "Show the contents of a file.");
"FILE", "Show the contents of a file.");
}
GRUB_MOD_FINI(cat)

View file

@ -40,7 +40,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required");
grub_printf ("Compare `%s' and `%s':\n", args[0],
grub_printf ("Compare file `%s' with `%s':\n", args[0],
args[1]);
file1 = grub_gzfile_open (args[0], 1);
@ -49,7 +49,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
goto cleanup;
if (grub_file_size (file1) != grub_file_size (file2))
grub_printf ("Differ in size: %llu [%s], %llu [%s]\n",
grub_printf ("Files differ in size: %llu [%s], %llu [%s]\n",
(unsigned long long) grub_file_size (file1), args[0],
(unsigned long long) grub_file_size (file2), args[1]);
else
@ -76,7 +76,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
{
if (buf1[i] != buf2[i])
{
grub_printf ("Differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n",
grub_printf ("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n",
(unsigned long long) (i + pos), buf1[i], args[0],
buf2[i], args[1]);
goto cleanup;
@ -109,7 +109,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(cmp)
{
cmd = grub_register_command ("cmp", grub_cmd_cmp,
"cmp FILE1 FILE2", "Compare two files.");
"FILE1 FILE2", "Compare two files.");
}
GRUB_MOD_FINI(cmp)

View file

@ -53,15 +53,15 @@ GRUB_MOD_INIT(configfile)
{
cmd_configfile =
grub_register_command ("configfile", grub_cmd_source,
"configfile FILE", "Load another config file.");
"FILE", "Load another config file.");
cmd_source =
grub_register_command ("source", grub_cmd_source,
"source FILE",
"FILE",
"Load another config file without changing context."
);
cmd_dot =
grub_register_command (".", grub_cmd_source,
". FILE",
"FILE",
"Load another config file without changing context."
);
}

View file

@ -57,7 +57,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(crc)
{
cmd = grub_register_command ("crc", grub_cmd_crc,
"crc FILE",
"FILE",
"Calculate the crc32 checksum of a file.");
}

View file

@ -135,7 +135,7 @@ GRUB_MOD_INIT(date)
{
cmd =
grub_register_command ("date", grub_cmd_date,
"date [[year-]month-day] [hour:minute[:second]]",
"[[year-]month-day] [hour:minute[:second]]",
"Command to display/set current datetime.");
}

View file

@ -23,8 +23,8 @@
static const struct grub_arg_option options[] =
{
{0, 'n', 0, "do not output the trailing newline", 0, 0},
{0, 'e', 0, "enable interpretation of backslash escapes", 0, 0},
{0, 'n', 0, "Do not output the trailing newline.", 0, 0},
{0, 'e', 0, "Enable interpretation of backslash escapes.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -113,7 +113,7 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(echo)
{
cmd = grub_register_extcmd ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
"echo [-e|-n] STRING", "Display a line of text.",
"[-e|-n] STRING", "Display a line of text.",
options);
}

View file

@ -38,11 +38,11 @@ static struct grub_video_patch
};
static int NESTED_FUNC_ATTR
scan_card (int bus, int dev, int func, grub_pci_id_t pciid)
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
{
grub_pci_address_t addr;
addr = grub_pci_make_address (bus, dev, func, 2);
addr = grub_pci_make_address (dev, 2);
if (grub_pci_read_byte (addr + 3) == 0x3)
{
struct grub_video_patch *p = video_patches;

View file

@ -41,15 +41,16 @@ enable_rom_area (void)
{
grub_pci_address_t addr;
grub_uint32_t *rom_ptr;
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
rom_ptr = (grub_uint32_t *) VBIOS_ADDR;
if (*rom_ptr != BLANK_MEM)
{
grub_printf ("ROM image present.\n");
grub_printf ("ROM image is present.\n");
return 0;
}
addr = grub_pci_make_address (0, 0, 0, 36);
addr = grub_pci_make_address (dev, 36);
grub_pci_write_byte (addr++, 0x30);
grub_pci_write_byte (addr++, 0x33);
grub_pci_write_byte (addr++, 0x33);
@ -62,7 +63,7 @@ enable_rom_area (void)
*rom_ptr = 0;
if (*rom_ptr != 0)
{
grub_printf ("Can\'t enable rom area.\n");
grub_printf ("Can\'t enable ROM area.\n");
return 0;
}
@ -73,8 +74,9 @@ static void
lock_rom_area (void)
{
grub_pci_address_t addr;
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
addr = grub_pci_make_address (0, 0, 0, 36);
addr = grub_pci_make_address (dev, 36);
grub_pci_write_byte (addr++, 0x10);
grub_pci_write_byte (addr++, 0x11);
grub_pci_write_byte (addr++, 0x11);
@ -158,7 +160,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
int size;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "No rom image specified");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no ROM image specified");
if (argc > 1)
{
@ -167,7 +169,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
if (file->size != 4)
grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid int10 dump size");
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid int10 dump size");
else
grub_file_read (file, (void *) 0x40, 4);
@ -182,7 +184,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
size = file->size;
if ((size < 0x10000) || (size > 0x40000))
grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid bios dump size");
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid bios dump size");
else if (enable_rom_area ())
{
grub_file_read (file, (void *) VBIOS_ADDR, size);
@ -199,10 +201,10 @@ static grub_command_t cmd_fakebios, cmd_loadbios;
GRUB_MOD_INIT(loadbios)
{
cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios,
0, "fake bios.");
0, "Fake bios.");
cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios,
"loadbios BIOS_DUMP [INT10_DUMP]",
"BIOS_DUMP [INT10_DUMP]",
"Load bios dump.");
}

View file

@ -240,13 +240,13 @@ GRUB_MOD_INIT(gptsync)
{
(void) mod; /* To stop warning. */
cmd = grub_register_command ("gptsync", grub_cmd_gptsync,
"gptsync DEVICE [PARTITION[+/-[TYPE]]] ...",
"DEVICE [PARTITION[+/-[TYPE]]] ...",
"Fill hybrid MBR of GPT drive DEVICE. "
"specified partitions will be a part "
"of hybrid mbr. Up to 3 partitions are "
"allowed. TYPE is an MBR type. "
"+ means that partition is active. "
"Only one partition can be active");
"Only one partition can be active.");
}
GRUB_MOD_FINI(gptsync)

View file

@ -35,8 +35,8 @@ static grub_command_t cmd;
GRUB_MOD_INIT(halt)
{
cmd = grub_register_command ("halt", grub_cmd_halt,
0, "halts the computer. This command does not"
" work on all firmware.");
0, "Halts the computer. This command does not"
" work on all firmware implementations.");
}
GRUB_MOD_FINI(halt)

View file

@ -95,16 +95,16 @@ GRUB_MOD_INIT(handler)
{
cmd_handler =
grub_register_command ("handler", grub_cmd_handler,
"handler [class [handler]]",
"List or select a handler");
"[class [handler]]",
"List or select a handler.");
cmd_terminal_input =
grub_register_command ("terminal_input", grub_cmd_handler,
"terminal_input [handler]",
"List or select a handler");
"[handler]",
"List or select an input terminal.");
cmd_terminal_output =
grub_register_command ("terminal_output", grub_cmd_handler,
"terminal_output [handler]",
"List or select a handler");
"[handler]",
"List or select an output terminal.");
}
GRUB_MOD_FINI(handler)

View file

@ -26,27 +26,27 @@
#include <grub/extcmd.h>
static const struct grub_arg_option options[] = {
{"apm", 'B', 0, "set Advanced Power Management\n"
"(1=low, ..., 254=high, 255=off)",
{"apm", 'B', 0, "Set Advanced Power Management\n"
"(1=low, ..., 254=high, 255=off).",
0, ARG_TYPE_INT},
{"power", 'C', 0, "check power mode", 0, ARG_TYPE_NONE},
{"security-freeze", 'F', 0, "freeze ATA security settings until reset",
{"power", 'C', 0, "Check power mode.", 0, ARG_TYPE_NONE},
{"security-freeze", 'F', 0, "Freeze ATA security settings until reset.",
0, ARG_TYPE_NONE},
{"health", 'H', 0, "check SMART health status", 0, ARG_TYPE_NONE},
{"aam", 'M', 0, "set Automatic Acoustic Management\n"
"(0=off, 128=quiet, ..., 254=fast)",
{"health", 'H', 0, "Check SMART health status.", 0, ARG_TYPE_NONE},
{"aam", 'M', 0, "Set Automatic Acoustic Management\n"
"(0=off, 128=quiet, ..., 254=fast).",
0, ARG_TYPE_INT},
{"standby-timeout", 'S', 0, "set standby timeout\n"
"(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...)",
{"standby-timeout", 'S', 0, "Set standby timeout\n"
"(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...).",
0, ARG_TYPE_INT},
{"standby", 'y', 0, "set drive to standby mode", 0, ARG_TYPE_NONE},
{"sleep", 'Y', 0, "set drive to sleep mode", 0, ARG_TYPE_NONE},
{"identify", 'i', 0, "print drive identity and settings",
{"standby", 'y', 0, "Set drive to standby mode.", 0, ARG_TYPE_NONE},
{"sleep", 'Y', 0, "Set drive to sleep mode.", 0, ARG_TYPE_NONE},
{"identify", 'i', 0, "Print drive identity and settings.",
0, ARG_TYPE_NONE},
{"dumpid", 'I', 0, "dump contents of ATA IDENTIFY sector",
{"dumpid", 'I', 0, "Dump contents of ATA IDENTIFY sector.",
0, ARG_TYPE_NONE},
{"smart", -1, 0, "disable/enable SMART (0/1)", 0, ARG_TYPE_INT},
{"quiet", 'q', 0, "do not print messages", 0, ARG_TYPE_NONE},
{"smart", -1, 0, "Disable/enable SMART (0/1).", 0, ARG_TYPE_INT},
{"quiet", 'q', 0, "Do not print messages.", 0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
@ -410,7 +410,7 @@ GRUB_MOD_INIT(hdparm)
{
cmd = grub_register_extcmd ("hdparm", grub_cmd_hdparm,
GRUB_COMMAND_FLAG_BOTH,
"hdparm [OPTIONS] DISK",
"[OPTIONS] DISK",
"Get/set ATA disk parameters.", options);
}

View file

@ -21,6 +21,7 @@
#include <grub/misc.h>
#include <grub/term.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
static grub_err_t
grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@ -38,13 +39,14 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
(cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
{
char description[GRUB_TERM_WIDTH / 2];
int desclen = grub_strlen (cmd->summary);
const char* summary_translated = _(cmd->summary);
int desclen = grub_strlen (summary_translated);
/* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
with the description followed by spaces. */
grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
grub_memcpy (description, cmd->summary,
grub_memcpy (description, summary_translated,
(desclen < GRUB_TERM_WIDTH / 2 - 1
? desclen : GRUB_TERM_WIDTH / 2 - 1));
@ -65,8 +67,8 @@ 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 ("Usage: %s\n%s\b", cmd->summary,
cmd->description);
grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary),
_(cmd->description));
}
}
return 0;
@ -94,8 +96,8 @@ GRUB_MOD_INIT(help)
{
cmd = grub_register_extcmd ("help", grub_cmd_help,
GRUB_COMMAND_FLAG_CMDLINE,
"help [PATTERN ...]",
"Show a help message.", 0);
N_("[PATTERN ...]"),
N_("Show a help message."), 0);
}
GRUB_MOD_FINI(help)

View file

@ -26,9 +26,9 @@
#include <grub/extcmd.h>
static const struct grub_arg_option options[] = {
{"skip", 's', 0, "skip offset bytes from the beginning of file.", 0,
{"skip", 's', 0, "Skip offset bytes from the beginning of file.", 0,
ARG_TYPE_INT},
{"length", 'n', 0, "read only length bytes", 0, ARG_TYPE_INT},
{"length", 'n', 0, "Read only LENGTH bytes.", 0, ARG_TYPE_INT},
{0, 0, 0, 0, 0, 0}
};
@ -38,18 +38,18 @@ grub_cmd_hexdump (grub_extcmd_t cmd, int argc, char **args)
struct grub_arg_list *state = cmd->state;
char buf[GRUB_DISK_SECTOR_SIZE * 4];
grub_ssize_t size, length;
grub_addr_t skip;
grub_disk_addr_t skip;
int namelen;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
namelen = grub_strlen (args[0]);
skip = (state[0].set) ? grub_strtoul (state[0].arg, 0, 0) : 0;
skip = (state[0].set) ? grub_strtoull (state[0].arg, 0, 0) : 0;
length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 256;
if (!grub_strcmp (args[0], "(mem)"))
hexdump (skip, (char *) skip, length);
hexdump (skip, (char *) (grub_addr_t) skip, length);
else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
{
grub_disk_t disk;
@ -121,7 +121,7 @@ GRUB_MOD_INIT (hexdump)
{
cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump,
GRUB_COMMAND_FLAG_BOTH,
"hexdump [OPTIONS] FILE_OR_DEVICE",
"[OPTIONS] FILE_OR_DEVICE",
"Dump the contents of a file or memory.",
options);
}

View file

@ -33,7 +33,7 @@
static const struct grub_arg_option options[] =
{
{"long-mode", 'l', 0, "check for long mode flag (default)", 0, 0},
{"long-mode", 'l', 0, "Check for long mode flag (default).", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -88,7 +88,7 @@ done:
#endif
cmd = grub_register_extcmd ("cpuid", grub_cmd_cpuid, GRUB_COMMAND_FLAG_BOTH,
"cpuid [-l]", "Check for CPU features", options);
"[-l]", "Check for CPU features.", options);
}
GRUB_MOD_FINI(cpuid)

View file

@ -33,9 +33,9 @@ static grub_uint32_t *const int13slot = UINT_TO_PTR (4 * 0x13);
/* Remember to update enum opt_idxs accordingly. */
static const struct grub_arg_option options[] = {
{"list", 'l', 0, "show the current mappings", 0, 0},
{"reset", 'r', 0, "reset all mappings to the default values", 0, 0},
{"swap", 's', 0, "perform both direct and reverse mappings", 0, 0},
{"list", 'l', 0, "Show the current mappings.", 0, 0},
{"reset", 'r', 0, "Reset all mappings to the default values.", 0, 0},
{"swap", 's', 0, "Perform both direct and reverse mappings.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -308,7 +308,7 @@ install_int13_handler (int noret __attribute__ ((unused)))
GRUB_MACHINE_MEMORY_RESERVED,
GRUB_MMAP_MALLOC_LOW);
if (! handler_base)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Could not reserve "
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve "
"memory for the int13h handler");
/* Copy int13h handler bundle to reserved area. */
@ -404,7 +404,7 @@ GRUB_MOD_INIT (drivemap)
GRUB_COMMAND_FLAG_BOTH,
"drivemap"
" -l | -r | [-s] grubdev osdisk",
"Manage the BIOS drive mappings",
"Manage the BIOS drive mappings.",
options);
drivemap_hook =
grub_loader_register_preboot_hook (&install_int13_handler,

View file

@ -23,7 +23,7 @@
static const struct grub_arg_option options[] =
{
{"no-apm", 'n', 0, "do not use APM to halt the computer", 0, 0},
{"no-apm", 'n', 0, "Do not use APM to halt the computer.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -46,8 +46,8 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(halt)
{
cmd = grub_register_extcmd ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
"halt [-n]",
"Halt the system, if possible using APM",
"[-n]",
"Halt the system, if possible using APM.",
options);
}

View file

@ -27,6 +27,7 @@
#include <grub/machine/time.h>
#include <grub/cpu/io.h>
#include <grub/command.h>
#include <grub/i18n.h>
#define BASE_TEMPO 120
@ -207,7 +208,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(play)
{
cmd = grub_register_command ("play", grub_cmd_play,
"play FILE", "Play a tune");
N_("FILE"), N_("Play a tune."));
}
GRUB_MOD_FINI(play)

View file

@ -1,7 +1,7 @@
/* pxe.c - command to control the pxe driver */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
* Copyright (C) 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
@ -21,79 +21,31 @@
#include <grub/err.h>
#include <grub/misc.h>
#include <grub/machine/pxe.h>
#include <grub/extcmd.h>
static const struct grub_arg_option options[] =
{
{"info", 'i', 0, "show PXE information.", 0, 0},
{"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT},
{"unload", 'u', 0, "unload PXE stack.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
static void
print_ip (grub_uint32_t ip)
{
int i;
for (i = 0; i < 3; i++)
{
grub_printf ("%d.", ip & 0xFF);
ip >>= 8;
}
grub_printf ("%d", ip);
}
#include <grub/command.h>
static grub_err_t
grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
grub_cmd_pxe_unload (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
struct grub_arg_list *state = cmd->state;
if (! grub_pxe_pxenv)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no pxe environment");
if (state[1].set)
{
int size;
size = grub_strtoul (state[1].arg, 0, 0);
if (size < GRUB_PXE_MIN_BLKSIZE)
size = GRUB_PXE_MIN_BLKSIZE;
else if (size > GRUB_PXE_MAX_BLKSIZE)
size = GRUB_PXE_MAX_BLKSIZE;
grub_pxe_blksize = size;
}
if (state[0].set)
{
grub_printf ("blksize : %d\n", grub_pxe_blksize);
grub_printf ("client ip : ");
print_ip (grub_pxe_your_ip);
grub_printf ("\nserver ip : ");
print_ip (grub_pxe_server_ip);
grub_printf ("\ngateway ip : ");
print_ip (grub_pxe_gateway_ip);
grub_printf ("\n");
}
if (state[2].set)
grub_pxe_unload ();
return 0;
}
static grub_extcmd_t cmd;
static grub_command_t cmd;
GRUB_MOD_INIT(pxecmd)
{
cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
"pxe [-i|-b|-u]",
"Command to control the PXE device.", options);
cmd = grub_register_command ("pxe_unload", grub_cmd_pxe_unload,
0,
"Unload PXE environment.");
}
GRUB_MOD_FINI(pxecmd)
{
grub_unregister_extcmd (cmd);
grub_unregister_command (cmd);
}

View file

@ -168,7 +168,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(vbetest)
{
cmd = grub_register_command ("vbetest", grub_cmd_vbetest,
0, "Test VESA BIOS Extension 2.0+ support");
0, "Test VESA BIOS Extension 2.0+ support.");
}
GRUB_MOD_FINI(vbetest)

View file

@ -39,7 +39,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(ieee1275_suspend)
{
cmd = grub_register_command ("suspend", grub_cmd_suspend,
0, "Return to Open Firmware prompt");
0, "Return to Open Firmware prompt.");
}
GRUB_MOD_FINI(ieee1275_suspend)

View file

@ -24,9 +24,9 @@
static const struct grub_arg_option options[] =
{
{"shift", 's', 0, "check Shift key", 0, 0},
{"ctrl", 'c', 0, "check Control key", 0, 0},
{"alt", 'a', 0, "check Alt key", 0, 0},
{"shift", 's', 0, "Check Shift key.", 0, 0},
{"ctrl", 'c', 0, "Check Control key.", 0, 0},
{"alt", 'a', 0, "Check Alt key.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -70,8 +70,8 @@ GRUB_MOD_INIT(keystatus)
{
cmd = grub_register_extcmd ("keystatus", grub_cmd_keystatus,
GRUB_COMMAND_FLAG_BOTH,
"keystatus [--shift] [--ctrl] [--alt]",
"Check key modifier status",
"[--shift] [--ctrl] [--alt]",
"Check key modifier status.",
options);
}

View file

@ -29,7 +29,7 @@
static const struct grub_arg_option options[] =
{
{"file", 'f', 0, "specify filename", 0, ARG_TYPE_PATHNAME},
{"file", 'f', 0, "Specify filename.", 0, ARG_TYPE_PATHNAME},
{0, 0, 0, 0, 0, 0}
};
@ -328,7 +328,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
}
if (! argc)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "No variable is specified");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified");
file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
if (! file)
@ -396,7 +396,7 @@ GRUB_MOD_INIT(loadenv)
cmd_save =
grub_register_extcmd ("save_env", grub_cmd_save_env,
GRUB_COMMAND_FLAG_BOTH,
"save_env [-f FILE] variable_name [...]",
"[-f FILE] variable_name [...]",
"Save variables to environment block file.",
options);
}

View file

@ -33,9 +33,9 @@
static const struct grub_arg_option options[] =
{
{"long", 'l', 0, "show a long list with more detailed information", 0, 0},
{"human-readable", 'h', 0, "print sizes in a human readable format", 0, 0},
{"all", 'a', 0, "list all files", 0, 0},
{"long", 'l', 0, "Show a long list with more detailed information.", 0, 0},
{"human-readable", 'h', 0, "Print sizes in a human readable format.", 0, 0},
{"all", 'a', 0, "List all files.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -260,7 +260,7 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(ls)
{
cmd = grub_register_extcmd ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
"ls [-l|-h|-a] [FILE]",
"[-l|-h|-a] [FILE]",
"List devices and files.", options);
}

View file

@ -20,7 +20,7 @@
#include <grub/pci.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/extcmd.h>
struct grub_pci_classname
{
@ -84,6 +84,7 @@ static const struct grub_pci_classname grub_pci_classes[] =
{ 11, 0x30, "MIPS Processor" },
{ 11, 0x40, "Co-Processor" },
{ 11, 0x80, "Unknown Processor" },
{ 12, 3, "USB Controller" },
{ 12, 0x80, "Serial Bus Controller" },
{ 13, 0x80, "Wireless Controller" },
{ 14, 0, "I2O" },
@ -114,16 +115,26 @@ grub_pci_get_class (int class, int subclass)
return 0;
}
static const struct grub_arg_option options[] =
{
{"iospace", 'i', 0, "show I/O spaces", 0, 0},
{0, 0, 0, 0, 0, 0}
};
static int iospace;
static int NESTED_FUNC_ATTR
grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
{
grub_uint32_t class;
const char *sclass;
grub_pci_address_t addr;
int reg;
grub_printf ("%02x:%02x.%x %04x:%04x", bus, dev, func, pciid & 0xFFFF,
pciid >> 16);
addr = grub_pci_make_address (bus, dev, func, 2);
grub_printf ("%02x:%02x.%x %04x:%04x", grub_pci_get_bus (dev),
grub_pci_get_device (dev), grub_pci_get_function (dev),
pciid & 0xFFFF, pciid >> 16);
addr = grub_pci_make_address (dev, 2);
class = grub_pci_read (addr);
/* Lookup the class name, if there isn't a specific one,
@ -142,27 +153,75 @@ grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
grub_printf ("\n");
if (iospace)
{
reg = 4;
while (reg < 10)
{
grub_uint64_t space;
addr = grub_pci_make_address (dev, reg);
space = grub_pci_read (addr);
reg++;
if (space == 0)
continue;
switch (space & GRUB_PCI_ADDR_SPACE_MASK)
{
case GRUB_PCI_ADDR_SPACE_IO:
grub_printf ("\tIO space %d at 0x%llx\n", (reg - 1) - 4,
(unsigned long long)
(space & GRUB_PCI_ADDR_IO_MASK));
break;
case GRUB_PCI_ADDR_SPACE_MEMORY:
if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK)
== GRUB_PCI_ADDR_MEM_TYPE_64)
{
addr = grub_pci_make_address (dev, reg);
space |= ((grub_uint64_t) grub_pci_read (addr)) << 32;
reg++;
grub_printf ("\t64-bit memory space %d at 0x%016llx [%s]\n",
(reg - 2) - 4, (unsigned long long)
(space & GRUB_PCI_ADDR_MEM_MASK),
space & GRUB_PCI_ADDR_MEM_PREFETCH
? "prefetchable" : "non-prefetchable");
}
else
grub_printf ("\t32-bit memory space %d at 0x%016llx [%s]\n",
(reg - 1) - 4, (unsigned long long)
(space & GRUB_PCI_ADDR_MEM_MASK),
space & GRUB_PCI_ADDR_MEM_PREFETCH
? "prefetchable" : "non-prefetchable");
break;
}
}
}
return 0;
}
static grub_err_t
grub_cmd_lspci (grub_command_t cmd __attribute__ ((unused)),
grub_cmd_lspci (grub_extcmd_t cmd,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
iospace = cmd->state[0].set;
grub_pci_iterate (grub_lspci_iter);
return GRUB_ERR_NONE;
}
static grub_command_t cmd;
static grub_extcmd_t cmd;
GRUB_MOD_INIT(pci)
GRUB_MOD_INIT(lspci)
{
cmd = grub_register_command ("lspci", grub_cmd_lspci,
0, "List PCI devices");
cmd = grub_register_extcmd ("lspci", grub_cmd_lspci, GRUB_COMMAND_FLAG_BOTH,
"[-i]", "List PCI devices.", options);
}
GRUB_MOD_FINI(pci)
GRUB_MOD_FINI(lspci)
{
grub_unregister_command (cmd);
grub_unregister_extcmd (cmd);
}

View file

@ -19,28 +19,52 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/extcmd.h>
#include <grub/env.h>
static grub_command_t cmd_read_byte, cmd_read_word, cmd_read_dword;
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_command_t cmd, int argc, char **argv)
grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
{
grub_target_addr_t addr;
grub_uint32_t value;
grub_uint32_t value = 0;
char buf[sizeof ("XXXXXXXX")];
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments");
addr = grub_strtoul (argv[0], 0, 0);
if (cmd->name[5] == 'd')
value = *((grub_uint32_t *) addr);
else if (cmd->name[5] == 'w')
value = *((grub_uint16_t *) addr);
else
value = *((grub_uint8_t *) addr);
switch (cmd->cmd->name[sizeof ("read_") - 1])
{
case 'd':
value = *((volatile grub_uint32_t *) addr);
break;
case 'w':
value = *((volatile grub_uint16_t *) addr);
break;
case 'b':
value = *((volatile grub_uint8_t *) 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;
@ -51,18 +75,42 @@ 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)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
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 (cmd->name[6] == 'd')
*((grub_uint32_t *) addr) = value;
else if (cmd->name[6] == 'w')
*((grub_uint16_t *) addr) = (grub_uint16_t) value;
if (argc == 3)
mask = grub_strtoul (argv[2], 0, 0);
value &= mask;
switch (cmd->name[sizeof ("write_") - 1])
{
case 'd':
if (mask != 0xffffffff)
*((volatile grub_uint32_t *) addr)
= (*((volatile grub_uint32_t *) addr) & ~mask) | value;
else
*((grub_uint8_t *) addr) = (grub_uint8_t) value;
*((volatile grub_uint32_t *) addr) = value;
break;
case 'w':
if ((mask & 0xffff) != 0xffff)
*((volatile grub_uint16_t *) addr)
= (*((volatile grub_uint16_t *) addr) & ~mask) | value;
else
*((volatile grub_uint16_t *) addr) = value;
break;
case 'b':
if ((mask & 0xff) != 0xff)
*((volatile grub_uint8_t *) addr)
= (*((volatile grub_uint8_t *) addr) & ~mask) | value;
else
*((volatile grub_uint8_t *) addr) = value;
break;
}
return 0;
}
@ -70,30 +118,30 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv)
GRUB_MOD_INIT(memrw)
{
cmd_read_byte =
grub_register_command ("read_byte", grub_cmd_read,
"read_byte ADDR", "read byte.");
grub_register_extcmd ("read_byte", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
"ADDR", "Read byte from ADDR.", options);
cmd_read_word =
grub_register_command ("read_word", grub_cmd_read,
"read_word ADDR", "read word.");
grub_register_extcmd ("read_word", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
"ADDR", "Read word from ADDR.", options);
cmd_read_dword =
grub_register_command ("read_dword", grub_cmd_read,
"read_dword ADDR", "read dword.");
grub_register_extcmd ("read_dword", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
"ADDR", "Read dword from ADDR.", options);
cmd_write_byte =
grub_register_command ("write_byte", grub_cmd_write,
"write_byte ADDR VALUE", "write byte.");
"ADDR VALUE [MASK]", "Write byte VALUE to ADDR.");
cmd_write_word =
grub_register_command ("write_word", grub_cmd_write,
"write_word ADDR VALUE", "write word.");
"ADDR VALUE [MASK]", "Write word VALUE to ADDR.");
cmd_write_dword =
grub_register_command ("write_dword", grub_cmd_write,
"write_dword ADDR VALUE", "write dword.");
"ADDR VALUE [MASK]", "Write dword VALUE to ADDR.");
}
GRUB_MOD_FINI(memrw)
{
grub_unregister_command (cmd_read_byte);
grub_unregister_command (cmd_read_word);
grub_unregister_command (cmd_read_dword);
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);

View file

@ -354,28 +354,28 @@ GRUB_MOD_INIT(minicmd)
{
cmd_cat =
grub_register_command ("cat", grub_mini_cmd_cat,
"cat FILE", "show the contents of a file");
"FILE", "Show the contents of a file.");
cmd_help =
grub_register_command ("help", grub_mini_cmd_help,
0, "show this message");
0, "Show this message.");
cmd_root =
grub_register_command ("root", grub_mini_cmd_root,
"root [DEVICE]", "set the root device");
"[DEVICE]", "Set the root device.");
cmd_dump =
grub_register_command ("dump", grub_mini_cmd_dump,
"dump ADDR", "dump memory");
"ADDR", "Dump memory.");
cmd_rmmod =
grub_register_command ("rmmod", grub_mini_cmd_rmmod,
"rmmod MODULE", "remove a module");
"MODULE", "Remove a module.");
cmd_lsmod =
grub_register_command ("lsmod", grub_mini_cmd_lsmod,
0, "show loaded modules");
0, "Show loaded modules.");
cmd_exit =
grub_register_command ("exit", grub_mini_cmd_exit,
0, "exit from GRUB");
0, "Exit from GRUB.");
cmd_clear =
grub_register_command ("clear", grub_mini_cmd_clear,
0, "clear the screen");
0, "Clear the screen.");
}
GRUB_MOD_FINI(minicmd)

View file

@ -34,9 +34,9 @@ static struct grub_parttool *parts = 0;
static int curhandle = 0;
static grub_dl_t mymod;
static char helpmsg[] =
"perform COMMANDS on partition.\n"
"Perform COMMANDS on partition.\n"
"Use \"parttool PARTITION help\" for the list "
"of available commands";
"of available commands.";
int
grub_parttool_register(const char *part_name,
@ -322,7 +322,7 @@ GRUB_MOD_INIT(parttool)
{
mymod = mod;
cmd = grub_register_command ("parttool", grub_cmd_parttool,
"parttool PARTITION COMMANDS",
"PARTITION COMMANDS",
helpmsg);
}

View file

@ -53,7 +53,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
char *pass;
if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected.");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments expected");
pass = grub_strdup (args[1]);
if (!pass)
@ -75,7 +75,7 @@ GRUB_MOD_INIT(password)
{
my_mod = mod;
cmd = grub_register_command ("password", grub_cmd_password,
"password USER PASSWORD",
"USER PASSWORD",
"Set user password (plaintext). "
"Unrecommended and insecure.");
}

View file

@ -34,12 +34,12 @@
static const struct grub_arg_option options[] =
{
{"set", 's', GRUB_ARG_OPTION_OPTIONAL,
"set a variable to return value", "VAR", ARG_TYPE_STRING},
{"driver", 'd', 0, "determine driver", 0, 0},
{"partmap", 'p', 0, "determine partition map type", 0, 0},
{"fs", 'f', 0, "determine filesystem type", 0, 0},
{"fs-uuid", 'u', 0, "determine filesystem UUID", 0, 0},
{"label", 'l', 0, "determine filesystem label", 0, 0},
"Set a variable to return value.", "VAR", ARG_TYPE_STRING},
{"driver", 'd', 0, "Determine driver.", 0, 0},
{"partmap", 'p', 0, "Determine partition map type.", 0, 0},
{"fs", 'f', 0, "Determine filesystem type.", 0, 0},
{"fs-uuid", 'u', 0, "Determine filesystem UUID.", 0, 0},
{"label", 'l', 0, "Determine filesystem label.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -150,7 +150,7 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT (probe)
{
cmd = grub_register_extcmd ("probe", grub_cmd_probe, GRUB_COMMAND_FLAG_BOTH,
"probe [DEVICE]",
"[DEVICE]",
"Retrieve device info.", options);
}

View file

@ -62,7 +62,7 @@ grub_getline (void)
}
static grub_err_t
grub_cmd_read (grub_command_t cmd UNUSED, int argc, char **args)
grub_cmd_read (grub_command_t cmd __attribute__ ((unused)), int argc, char **args)
{
char *line = grub_getline ();
if (! line)
@ -79,8 +79,8 @@ static grub_command_t cmd;
GRUB_MOD_INIT(read)
{
cmd = grub_register_command ("read", grub_cmd_read,
"read [ENVVAR]",
"Set variable with user input");
"[ENVVAR]",
"Set variable with user input.");
}
GRUB_MOD_FINI(read)

View file

@ -35,7 +35,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(reboot)
{
cmd = grub_register_command ("reboot", grub_cmd_reboot,
0, "Reboot the computer");
0, "Reboot the computer.");
}
GRUB_MOD_FINI(reboot)

View file

@ -25,29 +25,12 @@
#include <grub/device.h>
#include <grub/file.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/command.h>
#include <grub/search.h>
#include <grub/i18n.h>
static const struct grub_arg_option options[] =
{
{"file", 'f', 0, "search devices by a file", 0, 0},
{"label", 'l', 0, "search devices by a filesystem label", 0, 0},
{"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0},
{"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING},
{"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0},
{0, 0, 0, 0, 0, 0}
};
enum options
{
SEARCH_FILE,
SEARCH_LABEL,
SEARCH_FS_UUID,
SEARCH_SET,
SEARCH_NO_FLOPPY,
};
static void
search_fs (const char *key, const char *var, int no_floppy, enum options type)
void
FUNC_NAME (const char *key, const char *var, int no_floppy)
{
int count = 0;
char *buf = NULL;
@ -63,7 +46,7 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type)
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
return 0;
if (type == SEARCH_FILE)
#ifdef DO_SEARCH_FILE
{
grub_size_t len;
char *p;
@ -84,27 +67,29 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type)
grub_file_close (file);
}
}
else
#else
{
/* type is SEARCH_FS_UUID or SEARCH_LABEL */
/* SEARCH_FS_UUID or SEARCH_LABEL */
grub_device_t dev;
grub_fs_t fs;
int (*compare_fn) (const char *, const char *);
char *quid;
dev = grub_device_open (name);
if (dev)
{
fs = grub_fs_probe (dev);
compare_fn =
(type == SEARCH_FS_UUID) ? grub_strcasecmp : grub_strcmp;
if (fs && ((type == SEARCH_FS_UUID) ? fs->uuid : fs->label))
#ifdef DO_SEARCH_FS_UUID
#define compare_fn grub_strcasecmp
#define read_fn uuid
#else
#define compare_fn grub_strcmp
#define read_fn label
#endif
if (fs && fs->read_fn)
{
if (type == SEARCH_FS_UUID)
fs->uuid (dev, &quid);
else
fs->label (dev, &quid);
fs->read_fn (dev, &quid);
if (grub_errno == GRUB_ERR_NONE && quid)
{
@ -118,6 +103,7 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type)
grub_device_close (dev);
}
}
#endif
if (found)
{
@ -156,45 +142,42 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type)
}
static grub_err_t
grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
char **args)
{
struct grub_arg_list *state = cmd->state;
const char *var = 0;
if (argc == 0)
return grub_error (GRUB_ERR_INVALID_COMMAND, "no argument specified");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
if (state[SEARCH_SET].set)
var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
if (state[SEARCH_LABEL].set)
search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_LABEL);
else if (state[SEARCH_FS_UUID].set)
search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FS_UUID);
else if (state[SEARCH_FILE].set)
search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FILE);
else
return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0);
return grub_errno;
}
static grub_extcmd_t cmd;
static grub_command_t cmd;
GRUB_MOD_INIT(search)
#ifdef DO_SEARCH_FILE
GRUB_MOD_INIT(search_file)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_INIT(search_fs_uuid)
#else
GRUB_MOD_INIT(search_fs_label)
#endif
{
cmd =
grub_register_extcmd ("search", grub_cmd_search,
GRUB_COMMAND_FLAG_BOTH,
"search [-f|-l|-u|-s|-n] NAME",
"Search devices by file, filesystem label or filesystem UUID."
" If --set is specified, the first device found is"
" set to a variable. If no variable name is"
" specified, \"root\" is used.",
options);
grub_register_command (COMMAND_NAME, grub_cmd_do_search,
"NAME [VARIABLE]",
"Search devices by " SEARCH_TARGET "."
" If VARIABLE is specified, "
"the first device found is set to a variable.");
}
GRUB_MOD_FINI(search)
#ifdef DO_SEARCH_FILE
GRUB_MOD_FINI(search_file)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_FINI(search_fs_uuid)
#else
GRUB_MOD_FINI(search_fs_label)
#endif
{
grub_unregister_extcmd (cmd);
grub_unregister_command (cmd);
}

5
commands/search_file.c Normal file
View file

@ -0,0 +1,5 @@
#define DO_SEARCH_FILE 1
#define FUNC_NAME grub_search_fs_file
#define COMMAND_NAME "search.file"
#define SEARCH_TARGET "file"
#include "search.c"

5
commands/search_label.c Normal file
View file

@ -0,0 +1,5 @@
#define DO_SEARCH_FS_LABEL 1
#define FUNC_NAME grub_search_label
#define COMMAND_NAME "search.fs_label"
#define SEARCH_TARGET "filesystem label"
#include "search.c"

5
commands/search_uuid.c Normal file
View file

@ -0,0 +1,5 @@
#define DO_SEARCH_FS_UUID 1
#define FUNC_NAME grub_search_fs_uuid
#define COMMAND_NAME "search.fs_uuid"
#define SEARCH_TARGET "filesystem UUID"
#include "search.c"

95
commands/search_wrap.c Normal file
View file

@ -0,0 +1,95 @@
/* search.c - search devices based on a file or a filesystem label */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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
* 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/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/search.h>
#include <grub/i18n.h>
static const struct grub_arg_option options[] =
{
{"file", 'f', 0, N_("Search devices by a file."), 0, 0},
{"label", 'l', 0, N_("Search devices by a filesystem label."),
0, 0},
{"fs-uuid", 'u', 0, N_("Search devices by a filesystem UUID."),
0, 0},
{"set", 's', GRUB_ARG_OPTION_OPTIONAL,
N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING},
{"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
enum options
{
SEARCH_FILE,
SEARCH_LABEL,
SEARCH_FS_UUID,
SEARCH_SET,
SEARCH_NO_FLOPPY,
};
static grub_err_t
grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
const char *var = 0;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
if (state[SEARCH_SET].set)
var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
if (state[SEARCH_LABEL].set)
grub_search_label (args[0], var, state[SEARCH_NO_FLOPPY].set);
else if (state[SEARCH_FS_UUID].set)
grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set);
else if (state[SEARCH_FILE].set)
grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set);
else
return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
return grub_errno;
}
static grub_extcmd_t cmd;
GRUB_MOD_INIT(search)
{
cmd =
grub_register_extcmd ("search", grub_cmd_search,
GRUB_COMMAND_FLAG_BOTH,
N_("search [-f|-l|-u|-s|-n] NAME"),
N_("Search devices by file, filesystem label"
" or filesystem UUID."
" If --set is specified, the first device found is"
" set to a variable. If no variable name is"
" specified, \"root\" is used."),
options);
}
GRUB_MOD_FINI(search)
{
grub_unregister_extcmd (cmd);
}

View file

@ -27,8 +27,8 @@
static const struct grub_arg_option options[] =
{
{"verbose", 'v', 0, "verbose countdown", 0, 0},
{"interruptible", 'i', 0, "interruptible with ESC", 0, 0},
{"verbose", 'v', 0, "Verbose countdown.", 0, 0},
{"interruptible", 'i', 0, "Interruptible with ESC.", 0, 0},
{0, 0, 0, 0, 0, 0}
};
@ -105,8 +105,8 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(sleep)
{
cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH,
"sleep NUMBER_OF_SECONDS",
"Wait for a specified number of seconds",
"NUMBER_OF_SECONDS",
"Wait for a specified number of seconds.",
options);
}

View file

@ -420,9 +420,9 @@ static grub_command_t cmd_1, cmd_2;
GRUB_MOD_INIT(test)
{
cmd_1 = grub_register_command ("[", grub_cmd_test,
"[ EXPRESSION ]", "Evaluate an expression");
"EXPRESSION ]", "Evaluate an expression.");
cmd_2 = grub_register_command ("test", grub_cmd_test,
"test EXPRESSION", "Evaluate an expression");
"EXPRESSION", "Evaluate an expression.");
}
GRUB_MOD_FINI(test)

View file

@ -43,10 +43,10 @@ GRUB_MOD_INIT(true)
{
cmd_true =
grub_register_command ("true", grub_cmd_true,
0, "do nothing, successfully");
0, "Do nothing, successfully.");
cmd_false =
grub_register_command ("false", grub_cmd_false,
0, "do nothing, unsuccessfully");
0, "Do nothing, unsuccessfully.");
}
GRUB_MOD_FINI(true)

View file

@ -19,6 +19,7 @@
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/charset.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
@ -59,19 +60,61 @@ static const char *usb_devspeed[] =
"High"
};
static grub_usb_err_t
grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
char **string)
{
struct grub_usb_desc_str descstr;
struct grub_usb_desc_str *descstrp;
grub_usb_err_t err;
/* Only get the length. */
err = grub_usb_control_msg (dev, 1 << 7,
0x06, (3 << 8) | index,
langid, 1, (char *) &descstr);
if (err)
return err;
descstrp = grub_malloc (descstr.length);
if (! descstrp)
return GRUB_USB_ERR_INTERNAL;
err = grub_usb_control_msg (dev, 1 << 7,
0x06, (3 << 8) | index,
langid, descstr.length, (char *) descstrp);
*string = grub_malloc (descstr.length / 2);
if (! *string)
{
grub_free (descstrp);
return GRUB_USB_ERR_INTERNAL;
}
grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, descstrp->length / 2 - 1);
(*string)[descstr.length / 2 - 1] = '\0';
grub_free (descstrp);
return GRUB_USB_ERR_NONE;
}
static void
usb_print_str (const char *description, grub_usb_device_t dev, int idx)
{
char *name;
grub_usb_err_t err;
/* XXX: LANGID */
if (! idx)
return;
grub_usb_get_string (dev, idx, 0x0409, &name);
err = grub_usb_get_string (dev, idx, 0x0409, &name);
if (err)
grub_printf ("Error %d retrieving %s\n", err, description);
else
{
grub_printf ("%s: `%s'\n", description, name);
grub_free (name);
}
}
static int
usb_iterate (grub_usb_device_t dev)
@ -152,7 +195,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(usbtest)
{
cmd = grub_register_command ("usb", grub_cmd_usbtest,
0, "Test USB support");
0, "Test USB support.");
}
GRUB_MOD_FINI(usbtest)

View file

@ -71,7 +71,7 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
sanssmall = grub_font_get ("Helvetica 8");
fixed = grub_font_get ("Fixed 20");
if (! sansbig || ! sans || ! sanssmall || ! fixed)
return grub_error (GRUB_ERR_BAD_FONT, "No font loaded.");
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
glyph = grub_font_get_glyph (fixed, '*');
grub_font_draw_glyph (glyph, color, 200 ,0);
@ -178,7 +178,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(videotest)
{
cmd = grub_register_command ("videotest", grub_cmd_videotest,
0, "Test video subsystem");
0, "Test video subsystem.");
}
GRUB_MOD_FINI(videotest)

View file

@ -377,7 +377,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT (xnu_uuid)
{
cmd = grub_register_command ("xnu_uuid", grub_cmd_xnu_uuid,
"xnu_uuid GRUBUUID [VARNAME]",
"GRUBUUID [VARNAME]",
"Transform 64-bit UUID to format "
"suitable for xnu.");
}

View file

@ -8,7 +8,9 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/echo.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
commands/search.c commands/blocklist.c commands/hexdump.c \
commands/search_wrap.c commands/search_file.c \
commands/search_label.c commands/search_uuid.c \
commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
@ -59,6 +61,11 @@ grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
endif
ifeq ($(enable_grub_emu_pci), yes)
grub_emu_SOURCES += util/pci.c commands/lspci.c
grub_emu_LDFLAGS += $(LIBPCIACCESS)
endif
grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
DISTCLEANFILES += grub_emu_init.lst

View file

@ -3,7 +3,13 @@
sbin_UTILITIES += grub-mkdevicemap
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
util/deviceiter.c \
util/devicemap.c util/misc.c
util/misc.c
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
else
grub_mkdevicemap_SOURCES += util/devicemap.c
endif
# For grub-mkelfimage.
bin_UTILITIES += grub-mkelfimage
@ -389,7 +395,7 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Commands.
pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \
fs_file.mod fs_uuid.mod configfile.mod echo.mod \
configfile.mod echo.mod \
terminfo.mod test.mod blocklist.mod hexdump.mod \
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
msdospart.mod memrw.mod normal.mod sh.mod \
@ -462,10 +468,27 @@ help_mod_CFLAGS = $(COMMON_CFLAGS)
help_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For search.mod.
search_mod_SOURCES = commands/search.c
search_mod_SOURCES = commands/search_wrap.c
search_mod_CFLAGS = $(COMMON_CFLAGS)
search_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += search_fs_file.mod search_fs_uuid.mod search_label.mod
# For search.mod.
search_fs_file_mod_SOURCES = commands/search_file.c
search_fs_file_mod_CFLAGS = $(COMMON_CFLAGS)
search_fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For search.mod.
search_label_mod_SOURCES = commands/search_label.c
search_label_mod_CFLAGS = $(COMMON_CFLAGS)
search_label_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For search.mod.
search_fs_uuid_mod_SOURCES = commands/search_uuid.c
search_fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
search_fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For test.mod.
test_mod_SOURCES = commands/test.c
test_mod_CFLAGS = $(COMMON_CFLAGS)
@ -476,16 +499,6 @@ loopback_mod_SOURCES = disk/loopback.c
loopback_mod_CFLAGS = $(COMMON_CFLAGS)
loopback_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For fs_file.mod
fs_file_mod_SOURCES = disk/fs_file.c
fs_file_mod_CFLAGS = $(COMMON_CFLAGS)
fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For fs_uuid.mod
fs_uuid_mod_SOURCES = disk/fs_uuid.c
fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For configfile.mod
configfile_mod_SOURCES = commands/configfile.c
configfile_mod_CFLAGS = $(COMMON_CFLAGS)
@ -646,3 +659,8 @@ pkglib_MODULES += setjmp.mod
setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S
setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS)
setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += charset.mod
charset_mod_SOURCES = lib/charset.c
charset_mod_CFLAGS = $(COMMON_CFLAGS)
charset_mod_LDFLAGS = $(COMMON_LDFLAGS)

View file

@ -155,7 +155,7 @@ efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)

View file

@ -184,7 +184,7 @@ linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)

View file

@ -15,6 +15,12 @@ vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c
vga_text_mod_CFLAGS = $(COMMON_CFLAGS)
vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += relocator.mod
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += ata.mod
ata_mod_SOURCES = disk/ata.c
ata_mod_CFLAGS = $(COMMON_CFLAGS)

View file

@ -93,7 +93,7 @@ grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \
sbin_SCRIPTS = grub-install
# For grub-install.
grub_install_SOURCES = util/sparc64/ieee1275/grub-install.in
grub_install_SOURCES = util/grub-install.in
# Modules.
pkglib_MODULES = halt.mod \

View file

@ -161,9 +161,15 @@ efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
pkglib_MODULES += relocator.mod
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk

View file

@ -44,6 +44,11 @@ AC_CANONICAL_TARGET
# Program name transformations
AC_ARG_PROGRAM
# Optimization flag. Allow user to override.
if test "x$TARGET_CFLAGS" = x; then
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
fi
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
sparc) target_cpu=sparc64 ;;
@ -242,24 +247,10 @@ CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
LIBS=""
if test "x$TARGET_CFLAGS" = x; then
# debug flags.
TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
-Wundef -Wstrict-prototypes -g"
# optimization flags.
AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [
CFLAGS=-Os
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_Os=yes],
[grub_cv_cc_Os=no])
])
if test "x$grub_cv_cc_Os" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
else
TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
fi
# Force no alignment to save space on i386.
if test "x$target_cpu" = xi386; then
AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
@ -296,7 +287,6 @@ if test "x$TARGET_CFLAGS" = x; then
if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
fi
fi
grub_apple_target_cc
if test x$grub_cv_apple_target_cc = xyes ; then
@ -526,6 +516,10 @@ AC_ARG_ENABLE([grub-emu-usb],
[AS_HELP_STRING([--enable-grub-emu-usb],
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
AC_ARG_ENABLE([grub-emu-pci],
[AS_HELP_STRING([--enable-grub-emu-pci],
[build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
if test "$platform" = emu; then
missing_ncurses=
[# Check for curses libraries.]
@ -547,6 +541,11 @@ fi
if test x"$enable_grub_emu_usb" = xno ; then
grub_emu_usb_excuse="explicitly disabled"
fi
if test x"$enable_grub_emu_pci" = xyes ; then
grub_emu_usb_excuse="conflicts with PCI support"
fi
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for libusb libraries.]
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
@ -566,7 +565,35 @@ enable_grub_emu_usb=yes
else
enable_grub_emu_usb=no
fi
if test x"$enable_grub_emu_pci" != xyes ; then
grub_emu_pci_excuse="not enabled"
fi
if test x"$enable_grub_emu_usb" = xyes ; then
grub_emu_pci_excuse="conflicts with USB support"
fi
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for libpci libraries.]
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
[grub_emu_pci_excuse=["need libpciaccess library"]])
AC_SUBST([LIBPCIACCESS])
[fi]
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for headers.]
AC_CHECK_HEADERS([pci/pci.h], [],
[grub_emu_pci_excuse=["need libpciaccess headers"]])
[fi]
if test x"$grub_emu_pci_excuse" = x ; then
enable_grub_emu_pci=yes
else
enable_grub_emu_pci=no
fi
AC_SUBST([enable_grub_emu_usb])
AC_SUBST([enable_grub_emu_pci])
fi
AC_ARG_ENABLE([grub-fstest],
@ -641,6 +668,11 @@ echo USB support for grub-emu: Yes
else
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
fi
if [ x"$grub_emu_pci_excuse" = x ]; then
echo PCI support for grub-emu: Yes
else
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
fi
fi
if [ x"$enable_mm_debug" = xyes ]; then
echo With memory debugging: Yes

View file

@ -388,7 +388,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
}
static int NESTED_FUNC_ATTR
grub_ata_pciinit (int bus, int device, int func,
grub_ata_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__((unused)))
{
static int compat_use[2] = { 0 };
@ -402,7 +402,7 @@ grub_ata_pciinit (int bus, int device, int func,
static int controller = 0;
/* Read class. */
addr = grub_pci_make_address (bus, device, func, 2);
addr = grub_pci_make_address (dev, 2);
class = grub_pci_read (addr);
/* Check if this class ID matches that of a PCI IDE Controller. */
@ -429,9 +429,9 @@ grub_ata_pciinit (int bus, int device, int func,
{
/* Read the BARs, which either contain a mmapped IO address
or the IO port address. */
addr = grub_pci_make_address (bus, device, func, 4 + 2 * i);
addr = grub_pci_make_address (dev, 4 + 2 * i);
bar1 = grub_pci_read (addr);
addr = grub_pci_make_address (bus, device, func, 5 + 2 * i);
addr = grub_pci_make_address (dev, 5 + 2 * i);
bar2 = grub_pci_read (addr);
/* Check if the BARs describe an IO region. */
@ -444,7 +444,8 @@ grub_ata_pciinit (int bus, int device, int func,
grub_dprintf ("ata",
"PCI dev (%d,%d,%d) compat=%d rega=0x%x regb=0x%x\n",
bus, device, func, compat, rega, regb);
grub_pci_get_bus (dev), grub_pci_get_device (dev),
grub_pci_get_function (dev), compat, rega, regb);
if (rega && regb)
{
@ -674,7 +675,7 @@ grub_ata_open (const char *name, grub_disk_t disk)
}
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
if (dev->atapi)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk");
@ -774,7 +775,7 @@ grub_atapi_read (struct grub_scsi *scsi,
/* Count of last transfer may be uneven. */
if (! (0 < cnt && cnt <= size - nread && (! (cnt & 1) || cnt == size - nread)))
return grub_error (GRUB_ERR_READ_ERROR, "Invalid ATAPI transfer count");
return grub_error (GRUB_ERR_READ_ERROR, "invalid ATAPI transfer count");
/* Read the data. */
grub_ata_pio_read (dev, buf + nread, cnt);
@ -820,7 +821,7 @@ grub_atapi_open (const char *name, struct grub_scsi *scsi)
grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name);
if (! devfnd)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such ATAPI device");
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device");
scsi->data = devfnd;

View file

@ -30,7 +30,7 @@ grub_ata_pass_through (grub_disk_t disk,
{
if (disk->dev->id != GRUB_DISK_DEVICE_ATA_ID)
return grub_error (GRUB_ERR_BAD_DEVICE,
"Device not accessed via ata.mod");
"device not accessed via ata.mod");
struct grub_ata_device *dev = (struct grub_ata_device *) disk->data;

View file

@ -107,7 +107,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
if (sb.version != NV_VERSION)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown version: %d.%d", sb.version);
"unknown version: %d.%d", sb.version);
switch (sb.array.raid_level)
{
@ -129,7 +129,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported RAID level: %d", sb.array.raid_level);
"unsupported RAID level: %d", sb.array.raid_level);
}
array->number = 0;

View file

@ -1,136 +0,0 @@
/* fs_file.c - Access partition by a file it contains. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/file.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/partition.h>
static grub_device_t
search_fs_file (const char *key, unsigned long *count)
{
char *filename = NULL;
grub_device_t ret = NULL;
*count = 0;
auto int iterate_device (const char *name);
int iterate_device (const char *name)
{
int len;
grub_file_t file;
(*count)++;
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
filename = grub_realloc (filename, len);
if (! filename)
return 1;
grub_sprintf (filename, "(%s)%s", name, key);
file = grub_file_open (filename);
if (file)
{
grub_file_close (file);
ret = grub_device_open (name);
return 1;
}
grub_errno = GRUB_ERR_NONE;
return 0;
}
grub_device_iterate (iterate_device);
grub_free (filename);
return ret;
}
static grub_err_t
grub_fs_file_open (const char *name, grub_disk_t disk)
{
grub_device_t dev;
if (grub_strncmp (name, "FILE=", sizeof ("FILE=") - 1))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a FILE virtual volume");
dev = search_fs_file (name + sizeof ("FILE=") - 1, &disk->id);
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file found");
disk->total_sectors = dev->disk->total_sectors;
disk->has_partitions = 0;
if (dev->disk->partition)
{
disk->partition = grub_malloc (sizeof (*disk->partition));
if (disk->partition)
grub_memcpy (disk->partition, dev->disk->partition,
sizeof (*disk->partition));
}
else
disk->partition = NULL;
disk->data = dev;
return GRUB_ERR_NONE;
}
static void
grub_fs_file_close (grub_disk_t disk)
{
grub_device_t parent = disk->data;
grub_device_close (parent);
}
static grub_err_t
grub_fs_file_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_device_t parent = disk->data;
return parent->disk->dev->read (parent->disk, sector, size, buf);
}
static grub_err_t
grub_fs_file_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
grub_device_t parent = disk->data;
return parent->disk->dev->write (parent->disk, sector, size, buf);
}
static struct grub_disk_dev grub_fs_file_dev = {
.name = "fs_file",
.id = GRUB_DISK_DEVICE_FILE_ID,
.open = grub_fs_file_open,
.close = grub_fs_file_close,
.read = grub_fs_file_read,
.write = grub_fs_file_write,
.next = 0
};
GRUB_MOD_INIT (fs_file)
{
grub_disk_dev_register (&grub_fs_file_dev);
}
GRUB_MOD_FINI (fs_file)
{
grub_disk_dev_unregister (&grub_fs_file_dev);
}

View file

@ -1,149 +0,0 @@
/* fs_uuid.c - Access disks by their filesystem UUID. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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 <grub/disk.h>
#include <grub/dl.h>
#include <grub/kernel.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/types.h>
#include <grub/fs.h>
#include <grub/partition.h>
static grub_device_t
search_fs_uuid (const char *key, unsigned long *count)
{
*count = 0;
grub_device_t ret = NULL;
auto int iterate_device (const char *name);
int iterate_device (const char *name)
{
grub_device_t dev;
dev = grub_device_open (name);
if (dev)
{
grub_fs_t fs;
fs = grub_fs_probe (dev);
if (fs && fs->uuid)
{
char *uuid;
(fs->uuid) (dev, &uuid);
if (grub_errno == GRUB_ERR_NONE && uuid)
{
(*count)++;
if (grub_strcasecmp (uuid, key) == 0)
{
ret = dev;
grub_free (uuid);
return 1;
}
grub_free (uuid);
}
}
grub_device_close (dev);
}
grub_errno = GRUB_ERR_NONE;
return 0;
}
grub_device_iterate (iterate_device);
return ret;
}
static grub_err_t
grub_fs_uuid_open (const char *name, grub_disk_t disk)
{
grub_device_t dev;
if (grub_strncmp (name, "UUID=", sizeof ("UUID=")-1))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a UUID virtual volume");
dev = search_fs_uuid (name + sizeof ("UUID=") - 1, &disk->id);
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching UUID found");
disk->total_sectors = dev->disk->total_sectors;
disk->has_partitions = 0;
if (dev->disk->partition)
{
disk->partition = grub_malloc (sizeof (*disk->partition));
if (disk->partition)
grub_memcpy (disk->partition, dev->disk->partition,
sizeof (*disk->partition));
}
else
disk->partition = NULL;
disk->data = dev;
return GRUB_ERR_NONE;
}
static void
grub_fs_uuid_close (grub_disk_t disk __attribute((unused)))
{
grub_device_t parent = disk->data;
grub_device_close (parent);
}
static grub_err_t
grub_fs_uuid_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_device_t parent = disk->data;
return parent->disk->dev->read (parent->disk, sector, size, buf);
}
static grub_err_t
grub_fs_uuid_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
grub_device_t parent = disk->data;
return parent->disk->dev->write (parent->disk, sector, size, buf);
}
static struct grub_disk_dev grub_fs_uuid_dev =
{
.name = "fs_uuid",
.id = GRUB_DISK_DEVICE_UUID_ID,
.open = grub_fs_uuid_open,
.close = grub_fs_uuid_close,
.read = grub_fs_uuid_read,
.write = grub_fs_uuid_write,
.next = 0
};
GRUB_MOD_INIT(fs_uuid)
{
grub_disk_dev_register (&grub_fs_uuid_dev);
}
GRUB_MOD_FINI(fs_uuid)
{
grub_disk_dev_unregister (&grub_fs_uuid_dev);
}

View file

@ -169,7 +169,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
else
{
grub_free (data);
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
return grub_error (GRUB_ERR_BAD_DEVICE, "%s cannot get C/H/S values", disk->name);
}
}
@ -252,7 +252,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
1024 /* cylinders */ *
256 /* heads */ *
63 /* spt */)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
soff = ((grub_uint32_t) sector) % data->sectors + 1;
head = ((grub_uint32_t) sector) / data->sectors;
@ -260,7 +260,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
coff = head / data->heads;
if (coff >= data->cylinders)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name);
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
coff, hoff, soff, size, segment))
@ -268,9 +268,9 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
switch (cmd)
{
case GRUB_BIOSDISK_READ:
return grub_error (GRUB_ERR_READ_ERROR, "biosdisk read error");
return grub_error (GRUB_ERR_READ_ERROR, "%s read error", disk->name);
case GRUB_BIOSDISK_WRITE:
return grub_error (GRUB_ERR_WRITE_ERROR, "biosdisk write error");
return grub_error (GRUB_ERR_WRITE_ERROR, "%s write error", disk->name);
}
}
}

View file

@ -67,7 +67,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
} args;
if (! grub_strstr (name, "nand"))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Not a nand device");
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a NAND device");
data = grub_malloc (sizeof (*data));
if (! data)
@ -76,7 +76,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
grub_ieee1275_open (name, &dev_ihandle);
if (! dev_ihandle)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
goto fail;
}
@ -89,7 +89,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get block size");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size");
goto fail;
}
@ -102,7 +102,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get disk size");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size");
goto fail;
}
@ -172,7 +172,7 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
args.result = 1;
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
return grub_error (GRUB_ERR_READ_ERROR, "Read error");
return grub_error (GRUB_ERR_READ_ERROR, "read error");
ofs = 0;
size -= len;

View file

@ -175,7 +175,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
grub_ieee1275_open (op->devpath, &dev_ihandle);
if (! dev_ihandle)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
goto fail;
}
@ -184,20 +184,20 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
if (grub_ieee1275_finddevice (op->devpath, &dev))
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties");
goto fail;
}
if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop),
&actual))
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read the device type");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read the device type");
goto fail;
}
if (grub_strcmp (prop, "block"))
{
grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device");
grub_error (GRUB_ERR_BAD_DEVICE, "not a block device");
goto fail;
}
@ -244,12 +244,12 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
(int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
if (status < 0)
return grub_error (GRUB_ERR_READ_ERROR,
"Seek error, can't seek block %llu",
"seek error, can't seek block %llu",
(long long) sector);
grub_ieee1275_read ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
buf, size * 512UL, &actual);
if (actual != actual)
return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
return grub_error (GRUB_ERR_READ_ERROR, "read error on block: %llu",
(long long) sector);
return 0;

View file

@ -56,7 +56,7 @@ delete_loopback (const char *name)
break;
if (! dev)
return grub_error (GRUB_ERR_BAD_DEVICE, "Device not found");
return grub_error (GRUB_ERR_BAD_DEVICE, "device not found");
/* Remove the device from the list. */
*prev = dev->next;
@ -167,7 +167,7 @@ grub_loopback_open (const char *name, grub_disk_t disk)
break;
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
file = grub_file_open (dev->filename);
if (! file)

View file

@ -95,7 +95,7 @@ grub_lvm_open (const char *name, grub_disk_t disk)
}
if (! lv)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown LVM device %s", name);
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown LVM device %s", name);
disk->has_partitions = 0;
disk->id = lv->number;
@ -188,7 +188,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
size << GRUB_DISK_SECTOR_BITS, buf);
else
err = grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Physical volume %s not found", pv->name);
"physical volume %s not found", pv->name);
return err;
}
@ -263,7 +263,7 @@ grub_lvm_scan_device (const char *name)
if (dlocn->offset)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"We don't support multiple LVM data areas");
"we don't support multiple LVM data areas");
goto fail;
}
@ -290,7 +290,7 @@ grub_lvm_scan_device (const char *name)
|| (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION))
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown LVM metadata header");
"unknown LVM metadata header");
goto fail2;
}

View file

@ -181,7 +181,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
/* FIXME: Also support version 1.0. */
if (sb.major_version != 0 || sb.minor_version != 90)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported RAID version: %d.%d",
"unsupported RAID version: %d.%d",
sb.major_version, sb.minor_version);
/* FIXME: Check the checksum. */
@ -193,7 +193,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
sb.level != 5 && sb.level != 6 && sb.level != 10)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported RAID level: %d", sb.level);
"unsupported RAID level: %d", sb.level);
array->number = sb.md_minor;
array->level = sb.level;

View file

@ -123,7 +123,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
}
if (!array)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown RAID device %s",
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s",
name);
disk->has_partitions = 1;
@ -265,7 +265,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
}
else
err = grub_error (GRUB_ERR_READ_ERROR,
"disk missing.");
"disk missing");
k++;
if (k == array->total_devs)

View file

@ -157,7 +157,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
if (! array->device[q])
{
grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore");
grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore");
goto quit;
}
@ -176,7 +176,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
if ((! array->device[p]) || (! array->device[q]))
{
grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore");
grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore");
goto quit;
}

View file

@ -337,14 +337,14 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS;
if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0))
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported SCSI block size");
"unsupported SCSI block size");
grub_uint32_t sector_mod = 0;
sector = grub_divmod64 (sector, spb, &sector_mod);
if (! (sector_mod == 0 && size % spb == 0))
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unaligned SCSI read not supported");
"unaligned SCSI read not supported");
size /= spb;
}

View file

@ -39,6 +39,7 @@ grub_efi_system_table64_t *grub_efiemu_system_table64 = 0;
static struct grub_efiemu_prepare_hook *efiemu_prepare_hooks = 0;
/* Linked list of configuration tables */
static struct grub_efiemu_configuration_table *efiemu_config_tables = 0;
static int prepared = 0;
/* Free all allocated space */
grub_err_t
@ -70,6 +71,8 @@ grub_efiemu_unload (void)
}
efiemu_prepare_hooks = 0;
prepared = 0;
return GRUB_ERR_NONE;
}
@ -211,7 +214,7 @@ grub_efiemu_load_file (const char *filename)
{
grub_file_close (file);
grub_efiemu_unload ();
return grub_error (grub_errno, "Couldn't init memory management");
return grub_error (grub_errno, "couldn't init memory management");
}
grub_dprintf ("efiemu", "mm initialized\n");
@ -277,14 +280,19 @@ grub_efiemu_prepare (void)
{
grub_err_t err;
if (prepared)
return GRUB_ERR_NONE;
grub_dprintf ("efiemu", "Preparing %d-bit efiemu\n",
8 * grub_efiemu_sizeof_uintn_t ());
err = grub_efiemu_autocore ();
/* Create NVRAM if not yet done. */
/* Create NVRAM. */
grub_efiemu_pnvram ();
prepared = 1;
if (grub_efiemu_sizeof_uintn_t () == 4)
return grub_efiemu_prepare32 (efiemu_prepare_hooks, efiemu_config_tables);
else
@ -316,23 +324,19 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
static grub_command_t cmd_loadcore, cmd_prepare, cmd_unload;
void
grub_efiemu_pnvram_cmd_register (void);
GRUB_MOD_INIT(efiemu)
{
cmd_loadcore = grub_register_command ("efiemu_loadcore",
grub_cmd_efiemu_load,
"efiemu_loadcore FILE",
"Load and initialize EFI emulator");
"FILE",
"Load and initialize EFI emulator.");
cmd_prepare = grub_register_command ("efiemu_prepare",
grub_cmd_efiemu_prepare,
"efiemu_prepare",
"Finalize loading of EFI emulator");
0,
"Finalize loading of EFI emulator.");
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
"efiemu_unload",
"Unload EFI emulator");
grub_efiemu_pnvram_cmd_register ();
0,
"Unload EFI emulator.");
}
GRUB_MOD_FINI(efiemu)
@ -340,5 +344,4 @@ GRUB_MOD_FINI(efiemu)
grub_unregister_command (cmd_loadcore);
grub_unregister_command (cmd_prepare);
grub_unregister_command (cmd_unload);
grub_efiemu_pnvram_cmd_unregister ();
}

View file

@ -67,7 +67,7 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
* sizeof (grub_efi_memory_descriptor_t));
if (!efiemu_mmap)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Not enough space for memory map");
"not enough space for memory map");
}
/* Fill slot*/
@ -622,7 +622,7 @@ grub_efiemu_mm_do_alloc (void)
if (!efiemu_mmap)
{
grub_efiemu_unload ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Couldn't initialize mmap");
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't initialize mmap");
}
if ((err = efiemu_alloc_requests ()))

View file

@ -22,6 +22,7 @@
#include <grub/normal.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/charset.h>
#include <grub/efiemu/efiemu.h>
#include <grub/efiemu/runtime.h>
#include <grub/extcmd.h>
@ -34,62 +35,184 @@ static int timezone_handle = 0;
static int accuracy_handle = 0;
static int daylight_handle = 0;
/* Temporary place */
static grub_uint8_t *nvram;
static grub_size_t nvramsize;
static grub_uint32_t high_monotonic_count;
static grub_int16_t timezone;
static grub_uint8_t daylight;
static grub_uint32_t accuracy;
static const struct grub_arg_option options[] = {
{"size", 's', 0, "number of bytes to reserve for pseudo NVRAM", 0,
ARG_TYPE_INT},
{"high-monotonic-count", 'm', 0,
"Initial value of high monotonic count", 0, ARG_TYPE_INT},
{"timezone", 't', 0,
"Timezone, offset in minutes from GMT", 0, ARG_TYPE_INT},
{"accuracy", 'a', 0,
"Accuracy of clock, in 1e-12 units", 0, ARG_TYPE_INT},
{"daylight", 'd', 0,
"Daylight value, as per EFI specifications", 0, ARG_TYPE_INT},
{0, 0, 0, 0, 0, 0}
};
/* Parse signed value */
static int
grub_strtosl (char *arg, char **end, int base)
grub_strtosl (const char *arg, char **end, int base)
{
if (arg[0] == '-')
return -grub_strtoul (arg + 1, end, base);
return grub_strtoul (arg, end, base);
}
static inline int
hextoval (char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'z')
return c - 'a' + 10;
if (c >= 'A' && c <= 'Z')
return c - 'A' + 10;
return 0;
}
static inline grub_err_t
unescape (char *in, char *out, char *outmax, int *len)
{
char *ptr, *dptr;
dptr = out;
for (ptr = in; *ptr && dptr < outmax; )
if (*ptr == '%' && ptr[1] && ptr[2])
{
*dptr = (hextoval (ptr[1]) << 4) | (hextoval (ptr[2]));
ptr += 3;
dptr++;
}
else
{
*dptr = *ptr;
ptr++;
dptr++;
}
if (dptr == outmax)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"too many NVRAM variables for reserved variable space."
" Try increasing EfiEmu.pnvram.size");
*len = dptr - out;
return 0;
}
/* Export stuff for efiemu */
static grub_err_t
nvram_set (void * data __attribute__ ((unused)))
{
const char *env;
/* Take definitive pointers */
grub_uint8_t *nvram_def = grub_efiemu_mm_obtain_request (nvram_handle);
char *nvram = grub_efiemu_mm_obtain_request (nvram_handle);
grub_uint32_t *nvramsize_def
= grub_efiemu_mm_obtain_request (nvramsize_handle);
grub_uint32_t *high_monotonic_count_def
grub_uint32_t *high_monotonic_count
= grub_efiemu_mm_obtain_request (high_monotonic_count_handle);
grub_int16_t *timezone_def
grub_int16_t *timezone
= grub_efiemu_mm_obtain_request (timezone_handle);
grub_uint8_t *daylight_def
grub_uint8_t *daylight
= grub_efiemu_mm_obtain_request (daylight_handle);
grub_uint32_t *accuracy_def
grub_uint32_t *accuracy
= grub_efiemu_mm_obtain_request (accuracy_handle);
char *nvramptr;
auto int iterate_env (struct grub_env_var *var);
int iterate_env (struct grub_env_var *var)
{
char *guid, *attr, *name, *varname;
struct efi_variable *efivar;
int len = 0;
int i;
grub_uint64_t guidcomp;
if (grub_memcmp (var->name, "EfiEmu.pnvram.",
sizeof ("EfiEmu.pnvram.") - 1) != 0)
return 0;
guid = var->name + sizeof ("EfiEmu.pnvram.") - 1;
attr = grub_strchr (guid, '.');
if (!attr)
return 0;
attr++;
name = grub_strchr (attr, '.');
if (!name)
return 0;
name++;
efivar = (struct efi_variable *) nvramptr;
if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY,
"too many NVRAM variables for reserved variable space."
" Try increasing EfiEmu.pnvram.size");
return 1;
}
nvramptr += sizeof (struct efi_variable);
efivar->guid.data1 = grub_cpu_to_le32 (grub_strtoul (guid, &guid, 16));
if (*guid != '-')
return 0;
guid++;
efivar->guid.data2 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
if (*guid != '-')
return 0;
guid++;
efivar->guid.data3 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
if (*guid != '-')
return 0;
guid++;
guidcomp = grub_strtoull (guid, 0, 16);
for (i = 0; i < 8; i++)
efivar->guid.data4[i] = (guidcomp >> (56 - 8 * i)) & 0xff;
efivar->attributes = grub_strtoull (attr, 0, 16);
varname = grub_malloc (grub_strlen (name) + 1);
if (! varname)
return 1;
if (unescape (name, varname, varname + grub_strlen (name) + 1, &len))
return 1;
len = grub_utf8_to_utf16 ((grub_uint16_t *) nvramptr,
(nvramsize - (nvramptr - nvram)) / 2,
(grub_uint8_t *) varname, len, NULL);
if (len < 0)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "broken UTF-8 in variable name");
return 1;
}
nvramptr += 2 * len;
*((grub_uint16_t *) nvramptr) = 0;
nvramptr += 2;
efivar->namelen = 2 * len + 2;
if (unescape (var->value, nvramptr, nvram + nvramsize, &len))
{
efivar->namelen = 0;
return 1;
}
nvramptr += len;
efivar->size = len;
return 0;
}
/* Copy to definitive loaction */
grub_dprintf ("efiemu", "preparing pnvram\n");
grub_memcpy (nvram_def, nvram, nvramsize);
env = grub_env_get ("EfiEmu.pnvram.high_monotonic_count");
*high_monotonic_count = env ? grub_strtoul (env, 0, 0) : 1;
env = grub_env_get ("EfiEmu.pnvram.timezone");
*timezone = env ? grub_strtosl (env, 0, 0) : GRUB_EFI_UNSPECIFIED_TIMEZONE;
env = grub_env_get ("EfiEmu.pnvram.accuracy");
*accuracy = env ? grub_strtoul (env, 0, 0) : 50000000;
env = grub_env_get ("EfiEmu.pnvram.daylight");
*daylight = env ? grub_strtoul (env, 0, 0) : 0;
nvramptr = nvram;
grub_memset (nvram, 0, nvramsize);
grub_env_iterate (iterate_env);
if (grub_errno)
return grub_errno;
*nvramsize_def = nvramsize;
*high_monotonic_count_def = high_monotonic_count;
*timezone_def = timezone;
*daylight_def = daylight;
*accuracy_def = accuracy;
/* Register symbols */
grub_efiemu_register_symbol ("efiemu_variables", nvram_handle, 0);
@ -113,197 +236,27 @@ nvram_unload (void * data __attribute__ ((unused)))
grub_efiemu_mm_return_request (timezone_handle);
grub_efiemu_mm_return_request (accuracy_handle);
grub_efiemu_mm_return_request (daylight_handle);
grub_free (nvram);
nvram = 0;
}
/* Load the variables file It's in format
guid1:attr1:name1:data1;
guid2:attr2:name2:data2;
...
Where all fields are in hex
*/
static grub_err_t
read_pnvram (char *filename)
{
char *buf, *ptr, *ptr2;
grub_file_t file;
grub_size_t size;
grub_uint8_t *nvramptr = nvram;
struct efi_variable *efivar;
grub_size_t guidlen, datalen;
unsigned i, j;
file = grub_file_open (filename);
if (!file)
return grub_error (GRUB_ERR_BAD_OS, "couldn't read pnvram");
size = grub_file_size (file);
buf = grub_malloc (size + 1);
if (!buf)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't read pnvram");
if (grub_file_read (file, buf, size) != (grub_ssize_t) size)
return grub_error (GRUB_ERR_BAD_OS, "couldn't read pnvram");
buf[size] = 0;
grub_file_close (file);
for (ptr = buf; *ptr; )
{
if (grub_isspace (*ptr))
{
ptr++;
continue;
}
efivar = (struct efi_variable *) nvramptr;
if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"file is too large for reserved variable space");
nvramptr += sizeof (struct efi_variable);
/* look ahow long guid field is*/
guidlen = 0;
for (ptr2 = ptr; (grub_isspace (*ptr2)
|| (*ptr2 >= '0' && *ptr2 <= '9')
|| (*ptr2 >= 'a' && *ptr2 <= 'f')
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
ptr2++)
if (!grub_isspace (*ptr2))
guidlen++;
guidlen /= 2;
/* Read guid */
if (guidlen != sizeof (efivar->guid))
{
grub_free (buf);
return grub_error (GRUB_ERR_BAD_OS, "can't parse %s", filename);
}
for (i = 0; i < 2 * sizeof (efivar->guid); i++)
{
int hex = 0;
while (grub_isspace (*ptr))
ptr++;
if (*ptr >= '0' && *ptr <= '9')
hex = *ptr - '0';
if (*ptr >= 'a' && *ptr <= 'f')
hex = *ptr - 'a' + 10;
if (*ptr >= 'A' && *ptr <= 'F')
hex = *ptr - 'A' + 10;
if (i%2 == 0)
((grub_uint8_t *)&(efivar->guid))[i/2] = hex << 4;
else
((grub_uint8_t *)&(efivar->guid))[i/2] |= hex;
ptr++;
}
while (grub_isspace (*ptr))
ptr++;
if (*ptr != ':')
{
grub_dprintf ("efiemu", "Not colon\n");
grub_free (buf);
return grub_error (GRUB_ERR_BAD_OS, "can't parse %s", filename);
}
ptr++;
while (grub_isspace (*ptr))
ptr++;
/* Attributes can be just parsed by existing functions */
efivar->attributes = grub_strtoul (ptr, &ptr, 16);
while (grub_isspace (*ptr))
ptr++;
if (*ptr != ':')
{
grub_dprintf ("efiemu", "Not colon\n");
grub_free (buf);
return grub_error (GRUB_ERR_BAD_OS, "can't parse %s", filename);
}
ptr++;
while (grub_isspace (*ptr))
ptr++;
/* Read name and value */
for (j = 0; j < 2; j++)
{
/* Look the length */
datalen = 0;
for (ptr2 = ptr; *ptr2 && (grub_isspace (*ptr2)
|| (*ptr2 >= '0' && *ptr2 <= '9')
|| (*ptr2 >= 'a' && *ptr2 <= 'f')
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
ptr2++)
if (!grub_isspace (*ptr2))
datalen++;
datalen /= 2;
if (nvramptr - nvram + datalen > nvramsize)
{
grub_free (buf);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"file is too large for reserved "
" variable space");
}
for (i = 0; i < 2 * datalen; i++)
{
int hex = 0;
while (grub_isspace (*ptr))
ptr++;
if (*ptr >= '0' && *ptr <= '9')
hex = *ptr - '0';
if (*ptr >= 'a' && *ptr <= 'f')
hex = *ptr - 'a' + 10;
if (*ptr >= 'A' && *ptr <= 'F')
hex = *ptr - 'A' + 10;
if (i%2 == 0)
nvramptr[i/2] = hex << 4;
else
nvramptr[i/2] |= hex;
ptr++;
}
nvramptr += datalen;
while (grub_isspace (*ptr))
ptr++;
if (*ptr != (j ? ';' : ':'))
{
grub_free (buf);
grub_dprintf ("efiemu", j?"Not semicolon\n":"Not colon\n");
return grub_error (GRUB_ERR_BAD_OS, "can't parse %s", filename);
}
if (j)
efivar->size = datalen;
else
efivar->namelen = datalen;
ptr++;
}
}
grub_free (buf);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_efiemu_make_nvram (void)
grub_err_t
grub_efiemu_pnvram (void)
{
const char *size;
grub_err_t err;
err = grub_efiemu_autocore ();
if (err)
{
grub_free (nvram);
return err;
}
nvramsize = 0;
size = grub_env_get ("EfiEmu.pnvram.size");
if (size)
nvramsize = grub_strtoul (size, 0, 0);
if (!nvramsize)
nvramsize = 2048;
err = grub_efiemu_register_prepare_hook (nvram_set, nvram_unload, 0);
if (err)
{
grub_free (nvram);
return err;
}
nvram_handle
= grub_efiemu_request_memalign (1, nvramsize,
GRUB_EFI_RUNTIME_SERVICES_DATA);
@ -323,78 +276,5 @@ grub_efiemu_make_nvram (void)
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
grub_efiemu_request_symbols (6);
return GRUB_ERR_NONE;
}
grub_err_t
grub_efiemu_pnvram (void)
{
if (nvram)
return GRUB_ERR_NONE;
nvramsize = 2048;
high_monotonic_count = 1;
timezone = GRUB_EFI_UNSPECIFIED_TIMEZONE;
accuracy = 50000000;
daylight = 0;
nvram = grub_zalloc (nvramsize);
if (!nvram)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate space for temporary pnvram storage");
return grub_efiemu_make_nvram ();
}
static grub_err_t
grub_cmd_efiemu_pnvram (struct grub_extcmd *cmd,
int argc, char **args)
{
struct grub_arg_list *state = cmd->state;
grub_err_t err;
if (argc > 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "only one argument expected");
nvramsize = state[0].set ? grub_strtoul (state[0].arg, 0, 0) : 2048;
high_monotonic_count = state[1].set ? grub_strtoul (state[1].arg, 0, 0) : 1;
timezone = state[2].set ? grub_strtosl (state[2].arg, 0, 0)
: GRUB_EFI_UNSPECIFIED_TIMEZONE;
accuracy = state[3].set ? grub_strtoul (state[3].arg, 0, 0) : 50000000;
daylight = state[4].set ? grub_strtoul (state[4].arg, 0, 0) : 0;
nvram = grub_zalloc (nvramsize);
if (!nvram)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate space for temporary pnvram storage");
if (argc == 1 && (err = read_pnvram (args[0])))
{
grub_free (nvram);
return err;
}
return grub_efiemu_make_nvram ();
}
static grub_extcmd_t cmd;
void grub_efiemu_pnvram_cmd_register (void);
void grub_efiemu_pnvram_cmd_unregister (void);
void
grub_efiemu_pnvram_cmd_register (void)
{
cmd = grub_register_extcmd ("efiemu_pnvram", grub_cmd_efiemu_pnvram,
GRUB_COMMAND_FLAG_BOTH,
"efiemu_pnvram [FILENAME]",
"Initialise pseudo-NVRAM and load variables "
"from FILE",
options);
}
void
grub_efiemu_pnvram_cmd_unregister (void)
{
grub_unregister_extcmd (cmd);
}

View file

@ -36,7 +36,6 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
int cntconftables = 0;
struct SUFFIX (grub_efiemu_configuration_table) *conftables = 0;
struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
int i;
int handle;
grub_off_t off;
@ -54,6 +53,7 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
/* Switch from phase 1 (counting) to phase 2 (real job) */
grub_efiemu_alloc_syms ();
grub_efiemu_mm_do_alloc ();
grub_efiemu_write_sym_markers ();
grub_efiemu_system_table32 = 0;
grub_efiemu_system_table64 = 0;
@ -81,16 +81,6 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
= (struct SUFFIX (grub_efi_system_table) *)
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
/* compute CRC32 of runtime_services */
if ((err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
&handle, &off)))
return err;
runtime_services = (struct SUFFIX (grub_efiemu_runtime_services) *)
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
runtime_services->hdr.crc32 = 0;
runtime_services->hdr.crc32 = grub_getcrc32
(0, runtime_services, runtime_services->hdr.header_size);
/* Put pointer to the list of configuration tables in system table */
grub_efiemu_write_value
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
@ -113,16 +103,51 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
conftables[i].vendor_table = PTR_TO_UINT64 (cur->data);
}
err = SUFFIX (grub_efiemu_crc) ();
if (err)
{
grub_efiemu_unload ();
return err;
}
grub_dprintf ("efiemu","system_table = %p, conftables = %p (%d entries)\n",
SUFFIX (grub_efiemu_system_table), conftables, cntconftables);
return GRUB_ERR_NONE;
}
grub_err_t
SUFFIX (grub_efiemu_crc) (void)
{
grub_err_t err;
int handle;
grub_off_t off;
struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
/* compute CRC32 of runtime_services */
err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
&handle, &off);
if (err)
return err;
runtime_services = (struct SUFFIX (grub_efiemu_runtime_services) *)
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
runtime_services->hdr.crc32 = 0;
runtime_services->hdr.crc32 = grub_getcrc32
(0, runtime_services, runtime_services->hdr.header_size);
err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
if (err)
return err;
/* compute CRC32 of system table */
SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
SUFFIX (grub_efiemu_system_table)->hdr.crc32
= grub_getcrc32 (0, SUFFIX (grub_efiemu_system_table),
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
grub_dprintf ("efiemu","system_table = %p, runtime_services = %p,"
" conftables = %p (%d entries)\n",
SUFFIX (grub_efiemu_system_table), runtime_services,
conftables, cntconftables);
grub_dprintf ("efiemu","system_table = %p, runtime_services = %p\n",
SUFFIX (grub_efiemu_system_table), runtime_services);
return GRUB_ERR_NONE;
}

View file

@ -111,9 +111,8 @@ static grub_uint8_t loge[1000] = "EFIEMULOG";
static int logn = 9;
#define LOG(x) { if (logn<900) loge[logn++]=x; }
static int ptv_relocated = 0;
/* Interface with grub */
extern grub_uint8_t efiemu_ptv_relocated;
struct grub_efi_runtime_services efiemu_runtime_services;
struct grub_efi_system_table efiemu_system_table;
extern struct grub_efiemu_ptv_rel efiemu_ptv_relloc[];
@ -343,9 +342,9 @@ grub_efi_status_t EFI_FUNC
LOG ('e');
/* Ensure that we are called only once */
if (ptv_relocated)
if (efiemu_ptv_relocated)
return GRUB_EFI_UNSUPPORTED;
ptv_relocated = 1;
efiemu_ptv_relocated = 1;
/* Correct addresses using information supplied by grub */
for (cur_relloc = efiemu_ptv_relloc; cur_relloc->size;cur_relloc++)

View file

@ -26,6 +26,7 @@
static int ptv_written = 0;
static int ptv_alloc = 0;
static int ptv_handle = 0;
static int relocated_handle = 0;
static int ptv_requested = 0;
static struct grub_efiemu_sym *efiemu_syms = 0;
@ -54,6 +55,8 @@ grub_efiemu_free_syms (void)
ptv_requested = 0;
grub_efiemu_mm_return_request (ptv_handle);
ptv_handle = 0;
grub_efiemu_mm_return_request (relocated_handle);
relocated_handle = 0;
}
/* Announce that the module will need NUM allocators */
@ -114,10 +117,26 @@ grub_efiemu_alloc_syms (void)
ptv_handle = grub_efiemu_request_memalign
(1, (ptv_requested + 1) * sizeof (struct grub_efiemu_ptv_rel),
GRUB_EFI_RUNTIME_SERVICES_DATA);
relocated_handle = grub_efiemu_request_memalign
(1, sizeof (grub_uint8_t), GRUB_EFI_RUNTIME_SERVICES_DATA);
grub_efiemu_register_symbol ("efiemu_ptv_relocated", relocated_handle, 0);
grub_efiemu_register_symbol ("efiemu_ptv_relloc", ptv_handle, 0);
return grub_errno;
}
grub_err_t
grub_efiemu_write_sym_markers (void)
{
struct grub_efiemu_ptv_rel *ptv_rels
= grub_efiemu_mm_obtain_request (ptv_handle);
grub_uint8_t *relocated = grub_efiemu_mm_obtain_request (relocated_handle);
grub_memset (ptv_rels, 0, (ptv_requested + 1)
* sizeof (struct grub_efiemu_ptv_rel));
*relocated = 0;
return GRUB_ERR_NONE;
}
/* Write value (pointer to memory PLUS_HANDLE)
- (pointer to memory MINUS_HANDLE) + VALUE to ADDR assuming that the
size SIZE bytes. If PTV_NEEDED is 1 then announce it to runtime that this
@ -186,3 +205,67 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
return GRUB_ERR_NONE;
}
grub_err_t
grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
grub_efi_uintn_t descriptor_size,
grub_efi_uint32_t descriptor_version
__attribute__ ((unused)),
grub_efi_memory_descriptor_t *virtual_map)
{
grub_uint8_t *ptv_relocated;
struct grub_efiemu_ptv_rel *cur_relloc;
struct grub_efiemu_ptv_rel *ptv_rels;
ptv_relocated = grub_efiemu_mm_obtain_request (relocated_handle);
ptv_rels = grub_efiemu_mm_obtain_request (ptv_handle);
/* Ensure that we are called only once */
if (*ptv_relocated)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "EfiEmu is already relocated");
*ptv_relocated = 1;
/* Correct addresses using information supplied by grub */
for (cur_relloc = ptv_rels; cur_relloc->size; cur_relloc++)
{
grub_int64_t corr = 0;
grub_efi_memory_descriptor_t *descptr;
/* Compute correction */
for (descptr = virtual_map;
(grub_size_t) ((grub_uint8_t *) descptr
- (grub_uint8_t *) virtual_map) < memory_map_size;
descptr = (grub_efi_memory_descriptor_t *)
((grub_uint8_t *) descptr + descriptor_size))
{
if (descptr->type == cur_relloc->plustype)
corr += descptr->virtual_start - descptr->physical_start;
if (descptr->type == cur_relloc->minustype)
corr -= descptr->virtual_start - descptr->physical_start;
}
/* Apply correction */
switch (cur_relloc->size)
{
case 8:
*((grub_uint64_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
break;
case 4:
*((grub_uint32_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
break;
case 2:
*((grub_uint16_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
break;
case 1:
*((grub_uint8_t *) UINT_TO_PTR (cur_relloc->addr)) += corr;
break;
}
}
/* Recompute crc32 of system table and runtime services */
if (grub_efiemu_sizeof_uintn_t () == 4)
return grub_efiemu_crc32 ();
else
return grub_efiemu_crc64 ();
}

View file

@ -210,7 +210,7 @@ open_section (grub_file_t file, struct font_file_section *section)
else if (retval < 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font format error: can't read section name");
"font format error: can't read section name");
return 1;
}
@ -225,7 +225,7 @@ open_section (grub_file_t file, struct font_file_section *section)
else if (retval < 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font format error: can't read section length");
"font format error: can't read section length");
return 1;
}
@ -259,7 +259,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
if ((sect_length % FONT_CHAR_INDEX_ENTRY_SIZE) != 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font file format error: character index length %d "
"font file format error: character index length %d "
"is not a multiple of the entry size %d",
sect_length, FONT_CHAR_INDEX_ENTRY_SIZE);
return 1;
@ -294,7 +294,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
if (i != 0 && entry->code <= last_code)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font characters not in ascending order: %u <= %u",
"font characters not in ascending order: %u <= %u",
entry->code, last_code);
return 1;
}
@ -357,7 +357,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value)
if (section->length != 2)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font file format error: section %c%c%c%c length "
"font file format error: section %c%c%c%c length "
"is %d but should be 2",
section->name[0], section->name[1],
section->name[2], section->name[3],
@ -403,7 +403,7 @@ grub_font_load (const char *filename)
if (grub_memcmp (section.name, section_names_file, 4) != 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font file format error: 1st section must be FILE");
"font file format error: 1st section must be FILE");
goto fail;
}
@ -413,7 +413,7 @@ grub_font_load (const char *filename)
if (section.length != 4)
{
grub_error (GRUB_ERR_BAD_FONT,
"Font file format error (file type ID length is %d "
"font file format error (file type ID length is %d "
"but should be 4)", section.length);
goto fail;
}
@ -431,7 +431,7 @@ grub_font_load (const char *filename)
if (grub_memcmp (magic, pff2_magic, 4) != 0)
{
grub_error (GRUB_ERR_BAD_FONT, "Invalid font magic %x %x %x %x",
grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x",
magic[0], magic[1], magic[2], magic[3]);
goto fail;
}
@ -558,7 +558,7 @@ grub_font_load (const char *filename)
|| font->descent == 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"Invalid font file: missing some required data.");
"invalid font file: missing some required data");
goto fail;
}

View file

@ -62,7 +62,7 @@ GRUB_MOD_INIT(font_manager)
cmd_loadfont =
grub_register_command ("loadfont", loadfont_command,
"loadfont FILE...",
"FILE...",
"Specify one or more font files to load.");
cmd_lsfonts =
grub_register_command ("lsfonts", lsfonts_command,

View file

@ -182,14 +182,14 @@ grub_affs_mount (grub_disk_t disk)
/* Make sure this is an affs filesystem. */
if (grub_strncmp ((char *) (data->bblock.type), "DOS", 3))
{
grub_error (GRUB_ERR_BAD_FS, "not an affs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
goto fail;
}
/* Test if the filesystem is a OFS filesystem. */
if (! (data->bblock.flags & GRUB_AFFS_FLAG_FFS))
{
grub_error (GRUB_ERR_BAD_FS, "ofs not yet supported");
grub_error (GRUB_ERR_BAD_FS, "OFS not yet supported");
goto fail;
}
@ -231,7 +231,7 @@ grub_affs_mount (grub_disk_t disk)
}
if (-checksum != checksumr)
{
grub_error (GRUB_ERR_BAD_FS, "affs blocksize could not be determined");
grub_error (GRUB_ERR_BAD_FS, "AFFS blocksize couldn't be determined");
goto fail;
}
blocksize++;
@ -248,7 +248,7 @@ grub_affs_mount (grub_disk_t disk)
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not an affs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
grub_free (data);
grub_free (rootblock);

View file

@ -88,7 +88,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
return grub_errno;
if (hd.magic != MAGIC_BCPIO)
return grub_error (GRUB_ERR_BAD_FS, "Invalid cpio archive");
return grub_error (GRUB_ERR_BAD_FS, "invalid cpio archive");
data->size = (((grub_uint32_t) hd.filesize_1) << 16) + hd.filesize_2;
@ -130,7 +130,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
}
if (grub_memcmp (hd.magic, MAGIC_USTAR, sizeof (MAGIC_USTAR) - 1))
return grub_error (GRUB_ERR_BAD_FS, "Invalid tar archive");
return grub_error (GRUB_ERR_BAD_FS, "invalid tar archive");
if ((*name = grub_strdup (hd.name)) == NULL)
return grub_errno;

View file

@ -25,6 +25,7 @@
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/charset.h>
#define GRUB_FAT_DIR_ENTRY_SIZE 32
@ -337,7 +338,7 @@ grub_fat_mount (grub_disk_t disk)
fail:
grub_free (data);
grub_error (GRUB_ERR_BAD_FS, "not a fat filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a FAT filesystem");
return 0;
}

View file

@ -365,7 +365,7 @@ grub_hfs_mount (grub_disk_t disk)
if (grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &dir, sizeof (dir)) == 0)
{
grub_error (GRUB_ERR_BAD_FS, "can not find the hfs root directory");
grub_error (GRUB_ERR_BAD_FS, "cannot find the HFS root directory");
goto fail;
}
@ -379,7 +379,7 @@ grub_hfs_mount (grub_disk_t disk)
grub_free (data);
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a hfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a HFS filesystem");
return 0;
}
@ -1072,6 +1072,31 @@ grub_hfs_label (grub_device_t device, char **label)
return grub_errno;
}
static grub_err_t
grub_hfs_uuid (grub_device_t device, char **uuid)
{
struct grub_hfs_data *data;
grub_dl_ref (my_mod);
data = grub_hfs_mount (device->disk);
if (data && data->sblock.num_serial != 0)
{
*uuid = grub_malloc (16 + sizeof ('\0'));
grub_sprintf (*uuid, "%016llx",
(unsigned long long)
grub_be_to_cpu64 (data->sblock.num_serial));
}
else
*uuid = NULL;
grub_dl_unref (my_mod);
grub_free (data);
return grub_errno;
}
static struct grub_fs grub_hfs_fs =
@ -1082,6 +1107,7 @@ static struct grub_fs grub_hfs_fs =
.read = grub_hfs_read,
.close = grub_hfs_close,
.label = grub_hfs_label,
.uuid = grub_hfs_uuid,
.next = 0
};

View file

@ -28,6 +28,7 @@
#include <grub/types.h>
#include <grub/fshelp.h>
#include <grub/hfs.h>
#include <grub/charset.h>
#define GRUB_HFSPLUS_MAGIC 0x482B
#define GRUB_HFSPLUSX_MAGIC 0x4858
@ -501,7 +502,7 @@ grub_hfsplus_mount (grub_disk_t disk)
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
grub_free (data);
return 0;
@ -652,7 +653,7 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
btree->nodesize, (char *) node) <= 0)
{
grub_free (node);
return grub_error (GRUB_ERR_BAD_FS, "Couldn't read i-node.");
return grub_error (GRUB_ERR_BAD_FS, "couldn't read i-node");
}
nodedesc = (struct grub_hfsplus_btnode *) node;

View file

@ -1,7 +1,7 @@
/* pxe.c - Driver to provide access to the pxe filesystem */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
* Copyright (C) 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
@ -24,6 +24,7 @@
#include <grub/file.h>
#include <grub/misc.h>
#include <grub/bufio.h>
#include <grub/env.h>
#include <grub/machine/pxe.h>
#include <grub/machine/memory.h>
@ -33,11 +34,17 @@
#define SEGOFS(x) ((SEGMENT(x) << 16) + OFFSET(x))
#define LINEAR(x) (void *) (((x >> 16) <<4) + (x & 0xFFFF))
struct grub_pxe_disk_data
{
grub_uint32_t server_ip;
grub_uint32_t gateway_ip;
};
struct grub_pxenv *grub_pxe_pxenv;
grub_uint32_t grub_pxe_your_ip;
grub_uint32_t grub_pxe_server_ip;
grub_uint32_t grub_pxe_gateway_ip;
int grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE;
static grub_uint32_t grub_pxe_your_ip;
static grub_uint32_t grub_pxe_default_server_ip;
static grub_uint32_t grub_pxe_default_gateway_ip;
static unsigned grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE;
static grub_file_t curr_file = 0;
@ -56,24 +63,83 @@ grub_pxe_iterate (int (*hook) (const char *name))
return 0;
}
static grub_err_t
parse_ip (const char *val, grub_uint32_t *ip, const char **rest)
{
grub_uint32_t newip = 0;
unsigned long t;
int i;
const char *ptr = val;
for (i = 0; i < 4; i++)
{
t = grub_strtoul (ptr, (char **) &ptr, 0);
if (grub_errno)
return grub_errno;
if (t & ~0xff)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "Invalid IP.");
newip >>= 8;
newip |= (t << 24);
if (i != 3 && *ptr != '.')
return grub_error (GRUB_ERR_OUT_OF_RANGE, "Invalid IP.");
ptr++;
}
*ip = newip;
if (rest)
*rest = ptr - 1;
return 0;
}
static grub_err_t
grub_pxe_open (const char *name, grub_disk_t disk)
{
if (grub_strcmp (name, "pxe"))
struct grub_pxe_disk_data *data;
if (grub_strcmp (name, "pxe") != 0
&& grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a pxe disk");
data = grub_malloc (sizeof (*data));
if (!data)
return grub_errno;
if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
{
const char *ptr;
grub_err_t err;
ptr = name + sizeof ("pxe:") - 1;
err = parse_ip (ptr, &(data->server_ip), &ptr);
if (err)
return err;
if (*ptr == ':')
{
err = parse_ip (ptr + 1, &(data->server_ip), 0);
if (err)
return err;
}
else
data->gateway_ip = grub_pxe_default_gateway_ip;
}
else
{
data->server_ip = grub_pxe_default_server_ip;
data->gateway_ip = grub_pxe_default_gateway_ip;
}
disk->total_sectors = 0;
disk->id = (unsigned long) "pxe";
disk->id = (unsigned long) data;
disk->has_partitions = 0;
disk->data = 0;
disk->data = data;
return GRUB_ERR_NONE;
}
static void
grub_pxe_close (grub_disk_t disk __attribute((unused)))
grub_pxe_close (grub_disk_t disk)
{
grub_free (disk->data);
}
static grub_err_t
@ -107,9 +173,11 @@ static struct grub_disk_dev grub_pxe_dev =
};
static grub_err_t
grub_pxefs_dir (grub_device_t device UNUSED, const char *path UNUSED,
grub_pxefs_dir (grub_device_t device __attribute__ ((unused)),
const char *path __attribute__ ((unused)),
int (*hook) (const char *filename,
const struct grub_dirhook_info *info) UNUSED)
const struct grub_dirhook_info *info)
__attribute__ ((unused)))
{
return GRUB_ERR_NONE;
}
@ -123,6 +191,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
struct grub_pxenv_tftp_open c2;
} c;
struct grub_pxe_data *data;
struct grub_pxe_disk_data *disk_data = file->device->disk->data;
grub_file_t file_int, bufio;
if (curr_file != 0)
@ -131,8 +200,8 @@ grub_pxefs_open (struct grub_file *file, const char *name)
curr_file = 0;
}
c.c1.server_ip = grub_pxe_server_ip;
c.c1.gateway_ip = grub_pxe_gateway_ip;
c.c1.server_ip = disk_data->server_ip;
c.c1.gateway_ip = disk_data->gateway_ip;
grub_strcpy ((char *)&c.c1.filename[0], name);
grub_pxe_call (GRUB_PXENV_TFTP_GET_FSIZE, &c.c1);
if (c.c1.status)
@ -182,6 +251,7 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_pxenv_tftp_read c;
struct grub_pxe_data *data;
struct grub_pxe_disk_data *disk_data = file->device->disk->data;
grub_uint32_t pn, r;
data = file->data;
@ -201,8 +271,8 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
if (curr_file != 0)
grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o);
o.server_ip = grub_pxe_server_ip;
o.gateway_ip = grub_pxe_gateway_ip;
o.server_ip = disk_data->server_ip;
o.gateway_ip = disk_data->gateway_ip;
grub_strcpy ((char *)&o.filename[0], data->filename);
o.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT);
o.packet_size = grub_pxe_blksize;
@ -270,6 +340,99 @@ static struct grub_fs grub_pxefs_fs =
.next = 0
};
static char *
grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
const char *val __attribute__ ((unused)))
{
return NULL;
}
static void
set_mac_env (grub_uint8_t *mac_addr, grub_size_t mac_len)
{
char buf[(sizeof ("XX:") - 1) * mac_len + 1];
char *ptr = buf;
unsigned i;
for (i = 0; i < mac_len; i++)
{
grub_sprintf (ptr, "%02x:", mac_addr[i] & 0xff);
ptr += (sizeof ("XX:") - 1);
}
if (mac_len)
*(ptr - 1) = 0;
else
buf[0] = 0;
grub_env_set ("net_pxe_mac", buf);
/* XXX: Is it possible to change MAC in PXE? */
grub_register_variable_hook ("net_pxe_mac", 0, grub_env_write_readonly);
}
static void
set_env_limn_ro (const char *varname, char *value, grub_size_t len)
{
char c;
c = value[len];
value[len] = 0;
grub_env_set (varname, value);
value[len] = c;
grub_register_variable_hook (varname, 0, grub_env_write_readonly);
}
static void
parse_dhcp_vendor (void *vend, int limit)
{
grub_uint8_t *ptr, *ptr0;
ptr = ptr0 = vend;
if (grub_be_to_cpu32 (*(grub_uint32_t *) ptr) != 0x63825363)
return;
ptr = ptr + sizeof (grub_uint32_t);
while (ptr - ptr0 < limit)
{
grub_uint8_t tagtype;
grub_uint8_t taglength;
tagtype = *ptr++;
/* Pad tag. */
if (tagtype == 0)
continue;
/* End tag. */
if (tagtype == 0xff)
return;
taglength = *ptr++;
switch (tagtype)
{
case 12:
set_env_limn_ro ("net_pxe_hostname", (char *) ptr, taglength);
break;
case 15:
set_env_limn_ro ("net_pxe_domain", (char *) ptr, taglength);
break;
case 17:
set_env_limn_ro ("net_pxe_rootpath", (char *) ptr, taglength);
break;
case 18:
set_env_limn_ro ("net_pxe_extensionspath", (char *) ptr, taglength);
break;
/* If you need any other options please contact GRUB
developpement team. */
}
ptr += taglength;
}
}
static void
grub_pxe_detect (void)
{
@ -291,9 +454,15 @@ grub_pxe_detect (void)
bp = LINEAR (ci.buffer);
grub_pxe_your_ip = bp->your_ip;
grub_pxe_server_ip = bp->server_ip;
grub_pxe_gateway_ip = bp->gateway_ip;
grub_pxe_default_server_ip = bp->server_ip;
grub_pxe_default_gateway_ip = bp->gateway_ip;
set_mac_env (bp->mac_addr, bp->hw_len < sizeof (bp->mac_addr) ? bp->hw_len
: sizeof (bp->mac_addr));
set_env_limn_ro ("net_pxe_boot_file", (char *) bp->boot_file,
sizeof (bp->boot_file));
set_env_limn_ro ("net_pxe_dhcp_server_name", (char *) bp->server_name,
sizeof (bp->server_name));
parse_dhcp_vendor (&bp->vendor, sizeof (bp->vendor));
grub_pxe_pxenv = pxenv;
}
@ -309,11 +478,110 @@ grub_pxe_unload (void)
}
}
static void
set_ip_env (char *varname, grub_uint32_t ip)
{
char buf[sizeof ("XXX.XXX.XXX.XXX")];
grub_sprintf (buf, "%d.%d.%d.%d", (ip & 0xff),
(ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff);
grub_env_set (varname, buf);
}
static char *
write_ip_env (grub_uint32_t *ip, const char *val)
{
char *buf;
grub_err_t err;
grub_uint32_t newip;
err = parse_ip (val, &newip, 0);
if (err)
return 0;
/* Normalize the IP. */
buf = grub_malloc (sizeof ("XXX.XXX.XXX.XXX"));
if (!buf)
return 0;
*ip = newip;
grub_sprintf (buf, "%d.%d.%d.%d", (newip & 0xff), (newip >> 8) & 0xff,
(newip >> 16) & 0xff, (newip >> 24) & 0xff);
return buf;
}
static char *
grub_env_write_pxe_default_server (struct grub_env_var *var
__attribute__ ((unused)),
const char *val)
{
return write_ip_env (&grub_pxe_default_server_ip, val);
}
static char *
grub_env_write_pxe_default_gateway (struct grub_env_var *var
__attribute__ ((unused)),
const char *val)
{
return write_ip_env (&grub_pxe_default_gateway_ip, val);
}
static char *
grub_env_write_pxe_blocksize (struct grub_env_var *var __attribute__ ((unused)),
const char *val)
{
unsigned size;
char *buf;
size = grub_strtoul (val, 0, 0);
if (grub_errno)
return 0;
if (size < GRUB_PXE_MIN_BLKSIZE)
size = GRUB_PXE_MIN_BLKSIZE;
else if (size > GRUB_PXE_MAX_BLKSIZE)
size = GRUB_PXE_MAX_BLKSIZE;
buf = grub_malloc (sizeof ("XXXXXX XXXXXX"));
if (!buf)
return 0;
grub_sprintf (buf, "%d", size);
grub_pxe_blksize = size;
return buf;
}
GRUB_MOD_INIT(pxe)
{
grub_pxe_detect ();
if (grub_pxe_pxenv)
{
char *buf;
buf = grub_malloc (sizeof ("XXXXXX XXXXXX"));
if (buf)
{
grub_sprintf (buf, "%d", grub_pxe_blksize);
grub_env_set ("net_pxe_blksize", buf);
}
set_ip_env ("pxe_default_server", grub_pxe_default_server_ip);
set_ip_env ("pxe_default_gateway", grub_pxe_default_gateway_ip);
set_ip_env ("net_pxe_ip", grub_pxe_your_ip);
grub_register_variable_hook ("net_pxe_default_server", 0,
grub_env_write_pxe_default_server);
grub_register_variable_hook ("net_pxe_default_gateway", 0,
grub_env_write_pxe_default_gateway);
/* XXX: Is it possible to change IP in PXE? */
grub_register_variable_hook ("net_pxe_ip", 0,
grub_env_write_readonly);
grub_register_variable_hook ("net_pxe_blksize", 0,
grub_env_write_pxe_blocksize);
grub_disk_dev_register (&grub_pxe_dev);
grub_fs_register (&grub_pxefs_fs);
}

View file

@ -26,6 +26,7 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
#include <grub/charset.h>
#define GRUB_ISO9660_FSTYPE_DIR 0040000
#define GRUB_ISO9660_FSTYPE_REG 0100000
@ -279,13 +280,13 @@ grub_iso9660_mount (grub_disk_t disk)
sizeof (struct grub_iso9660_primary_voldesc),
(char *) &voldesc))
{
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
goto fail;
}
if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0)
{
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
goto fail;
}
@ -314,7 +315,7 @@ grub_iso9660_mount (grub_disk_t disk)
<< GRUB_ISO9660_LOG2_BLKSZ), 0,
sizeof (rootdir), (char *) &rootdir))
{
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
goto fail;
}
@ -330,7 +331,7 @@ grub_iso9660_mount (grub_disk_t disk)
<< GRUB_ISO9660_LOG2_BLKSZ), sua_pos,
sua_size, sua))
{
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
goto fail;
}
@ -831,7 +832,7 @@ grub_iso9660_uuid (grub_device_t device, char **uuid)
&& ! data->voldesc.modified.second[0] && ! data->voldesc.modified.second[1]
&& ! data->voldesc.modified.hundredth[0] && ! data->voldesc.modified.hundredth[1])
{
grub_error (GRUB_ERR_BAD_NUMBER, "No creation date in filesystem to generate UUID.");
grub_error (GRUB_ERR_BAD_NUMBER, "no creation date in filesystem to generate UUID");
*uuid = NULL;
}
else

View file

@ -24,6 +24,7 @@
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/charset.h>
#define GRUB_JFS_MAX_SYMLNK_CNT 8
#define GRUB_JFS_FILETYPE_MASK 0170000
@ -343,7 +344,7 @@ grub_jfs_mount (grub_disk_t disk)
if (grub_strncmp ((char *) (data->sblock.magic), "JFS1", 4))
{
grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem");
goto fail;
}
@ -362,7 +363,7 @@ grub_jfs_mount (grub_disk_t disk)
grub_free (data);
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem");
return 0;
}
@ -714,7 +715,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino)
grub_jfs_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "Can not follow symlink `%s'.", symlink);
grub_error (grub_errno, "cannot follow symlink `%s'", symlink);
return grub_errno;
}

View file

@ -311,7 +311,7 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, int ino)
grub_minix_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "Can not follow symlink `%s'.", symlink);
grub_error (grub_errno, "cannot follow symlink `%s'", symlink);
return grub_errno;
}

View file

@ -24,6 +24,7 @@
#include <grub/dl.h>
#include <grub/fshelp.h>
#include <grub/ntfs.h>
#include <grub/charset.h>
static grub_dl_t my_mod;
@ -41,7 +42,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic)
ss = u16at (buf, 6) - 1;
if (ss * (int) data->blocksize != len * GRUB_DISK_SECTOR_SIZE)
return grub_error (GRUB_ERR_BAD_FS, "Size not match",
return grub_error (GRUB_ERR_BAD_FS, "size not match",
ss * (int) data->blocksize,
len * GRUB_DISK_SECTOR_SIZE);
pu = buf + u16at (buf, 4);
@ -52,7 +53,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic)
buf += data->blocksize;
pu += 2;
if (u16at (buf, 0) != us)
return grub_error (GRUB_ERR_BAD_FS, "Fixup signature not match");
return grub_error (GRUB_ERR_BAD_FS, "fixup signature not match");
v16at (buf, 0) = v16at (pu, 0);
ss--;
}
@ -63,7 +64,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic)
static grub_err_t read_mft (struct grub_ntfs_data *data, char *buf,
grub_uint32_t mftno);
static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
grub_uint32_t ofs, grub_uint32_t len,
grub_disk_addr_t ofs, grub_size_t len,
int cached,
void
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
@ -72,7 +73,7 @@ static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
unsigned length));
static grub_err_t read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
grub_uint32_t ofs, grub_uint32_t len,
grub_disk_addr_t ofs, grub_size_t len,
int cached,
void
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
@ -146,7 +147,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
new_pos += u16at (new_pos, 4);
}
grub_error (GRUB_ERR_BAD_FS,
"Can\'t find 0x%X in attribute list",
"can\'t find 0x%X in attribute list",
(unsigned char) *at->attr_cur);
return NULL;
}
@ -185,7 +186,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr)
if (read_data (at, pa, at->edat_buf, 0, n, 0, 0))
{
grub_error (GRUB_ERR_BAD_FS,
"Fail to read non-resident attribute list");
"fail to read non-resident attribute list");
return NULL;
}
at->attr_nxt = at->edat_buf;
@ -260,9 +261,9 @@ locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
}
static char *
read_run_data (char *run, int nn, grub_uint32_t * val, int sig)
read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
{
grub_uint32_t r, v;
grub_disk_addr_t r, v;
r = 0;
v = 1;
@ -284,7 +285,7 @@ grub_err_t
grub_ntfs_read_run_list (struct grub_ntfs_rlst * ctx)
{
int c1, c2;
grub_uint32_t val;
grub_disk_addr_t val;
char *run;
run = ctx->cur_run;
@ -314,7 +315,7 @@ retry:
goto retry;
}
}
return grub_error (GRUB_ERR_BAD_FS, "Run list overflown");
return grub_error (GRUB_ERR_BAD_FS, "run list overflown");
}
run = read_run_data (run + 1, c1, &val, 0); /* length of current VCN */
ctx->curr_vcn = ctx->next_vcn;
@ -335,25 +336,25 @@ grub_ntfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t block)
struct grub_ntfs_rlst *ctx;
ctx = (struct grub_ntfs_rlst *) node;
if ((grub_uint32_t) block >= ctx->next_vcn)
if (block >= ctx->next_vcn)
{
if (grub_ntfs_read_run_list (ctx))
return -1;
return ctx->curr_lcn;
}
else
return (ctx->flags & RF_BLNK) ? 0 : ((grub_uint32_t) block -
return (ctx->flags & RF_BLNK) ? 0 : (block -
ctx->curr_vcn + ctx->curr_lcn);
}
static grub_err_t
read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
grub_uint32_t len, int cached,
read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
grub_disk_addr_t ofs, grub_size_t len, int cached,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset,
unsigned length))
{
grub_uint32_t vcn;
grub_disk_addr_t vcn;
struct grub_ntfs_rlst cc, *ctx;
if (len == 0)
@ -368,7 +369,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
if (pa[8] == 0)
{
if (ofs + len > u32at (pa, 0x10))
return grub_error (GRUB_ERR_BAD_FS, "Read out of range");
return grub_error (GRUB_ERR_BAD_FS, "read out of range");
grub_memcpy (dest, pa + u32at (pa, 0x14) + ofs, len);
return 0;
}
@ -382,13 +383,13 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
if (ctx->flags & RF_COMP)
{
if (!cached)
return grub_error (GRUB_ERR_BAD_FS, "Attribute can\'t be compressed");
return grub_error (GRUB_ERR_BAD_FS, "attribute can\'t be compressed");
if (at->sbuf)
{
if ((ofs & (~(COM_LEN - 1))) == at->save_pos)
{
grub_uint32_t n;
grub_disk_addr_t n;
n = COM_LEN - (ofs - at->save_pos);
if (n > len)
@ -411,11 +412,11 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
at->save_pos = 1;
}
vcn = ctx->target_vcn = (ofs / COM_LEN) * (COM_SEC / ctx->comp.spc);
vcn = ctx->target_vcn = (ofs >> COM_LOG_LEN) * (COM_SEC / ctx->comp.spc);
ctx->target_vcn &= ~0xF;
}
else
vcn = ctx->target_vcn = (ofs >> BLK_SHR) / ctx->comp.spc;
vcn = ctx->target_vcn = grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, 0);
ctx->next_vcn = u32at (pa, 0x10);
ctx->curr_lcn = 0;
@ -427,11 +428,13 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
if (at->flags & AF_GPOS)
{
grub_uint32_t st0, st1;
grub_disk_addr_t st0, st1;
grub_uint32_t m;
grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, &m);
st0 =
(ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc +
((ofs >> BLK_SHR) % ctx->comp.spc);
(ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc + m;
st1 = st0 + 1;
if (st1 ==
(ctx->next_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc)
@ -462,8 +465,8 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, grub_uint32_t ofs,
}
static grub_err_t
read_attr (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
grub_uint32_t len, int cached,
read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
grub_size_t len, int cached,
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
unsigned offset,
unsigned length))
@ -479,9 +482,9 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
if (at->flags & AF_ALST)
{
char *pa;
grub_uint32_t vcn;
grub_disk_addr_t vcn;
vcn = ofs / (at->mft->data->spc << BLK_SHR);
vcn = grub_divmod64 (ofs, at->mft->data->spc << BLK_SHR, 0);
pa = at->attr_nxt + u16at (at->attr_nxt, 4);
while (pa < at->attr_end)
{
@ -499,7 +502,7 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
else
ret =
(grub_errno) ? grub_errno : grub_error (GRUB_ERR_BAD_FS,
"Attribute not found");
"attribute not found");
at->attr_cur = save_cur;
return ret;
}
@ -508,9 +511,9 @@ static grub_err_t
read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno)
{
if (read_attr
(&data->mmft.attr, buf, mftno * (data->mft_size << BLK_SHR),
(&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << BLK_SHR),
data->mft_size << BLK_SHR, 0, 0))
return grub_error (GRUB_ERR_BAD_FS, "Read MFT 0x%X fails", mftno);
return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%X fails", mftno);
return fixup (data, buf, data->mft_size, "FILE");
}
@ -538,7 +541,7 @@ init_file (struct grub_ntfs_file *mft, grub_uint32_t mftno)
pa = locate_attr (&mft->attr, mft, AT_DATA);
if (pa == NULL)
return grub_error (GRUB_ERR_BAD_FS, "No $DATA in MFT 0x%X", mftno);
return grub_error (GRUB_ERR_BAD_FS, "no $DATA in MFT 0x%X", mftno);
if (!pa[8])
mft->size = u32at (pa, 0x10);
@ -640,7 +643,8 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
unsigned char *bitmap;
struct grub_ntfs_attr attr, *at;
char *cur_pos, *indx, *bmp;
int bitmap_len, ret = 0;
int ret = 0;
grub_size_t bitmap_len;
struct grub_ntfs_file *mft;
mft = (struct grub_ntfs_file *) dir;
@ -660,7 +664,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
{
if ((cur_pos = find_attr (at, AT_INDEX_ROOT)) == NULL)
{
grub_error (GRUB_ERR_BAD_FS, "No $INDEX_ROOT");
grub_error (GRUB_ERR_BAD_FS, "no $INDEX_ROOT");
goto done;
}
@ -713,7 +717,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
if (read_data (at, cur_pos, bmp, 0, bitmap_len, 0, 0))
{
grub_error (GRUB_ERR_BAD_FS,
"Fails to read non-resident $BITMAP");
"fails to read non-resident $BITMAP");
goto done;
}
bitmap_len = u32at (cur_pos, 0x30);
@ -744,14 +748,14 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
if (bitmap)
{
grub_uint32_t v, i;
grub_disk_addr_t v, i;
indx = grub_malloc (mft->data->idx_size << BLK_SHR);
if (indx == NULL)
goto done;
v = 1;
for (i = 0; i < (grub_uint32_t) bitmap_len * 8; i++)
for (i = 0; i < (grub_disk_addr_t)bitmap_len * 8; i++)
{
if (*bitmap & v)
{

View file

@ -28,7 +28,7 @@ static grub_err_t
decomp_nextvcn (struct grub_ntfs_comp *cc)
{
if (cc->comp_head >= cc->comp_tail)
return grub_error (GRUB_ERR_BAD_FS, "Compression block overflown");
return grub_error (GRUB_ERR_BAD_FS, "compression block overflown");
if (grub_disk_read
(cc->disk,
(cc->comp_table[cc->comp_head][1] -
@ -87,7 +87,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
{
if (copied > COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"Compression block too large");
"compression block too large");
if (!bits)
{
@ -112,7 +112,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
if (!copied)
{
grub_error (GRUB_ERR_BAD_FS, "Context window empty");
grub_error (GRUB_ERR_BAD_FS, "nontext window empty");
return 0;
}
@ -150,7 +150,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
{
if (cnt != COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"Invalid compression block size");
"invalid compression block size");
}
}
@ -187,7 +187,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
{
if (ctx->comp.comp_head != ctx->comp.comp_tail)
return grub_error (GRUB_ERR_BAD_FS, "Invalid compression block");
return grub_error (GRUB_ERR_BAD_FS, "invalid compression block");
ctx->comp.comp_head = ctx->comp.comp_tail = 0;
ctx->comp.cbuf_vcn = ctx->target_vcn;
ctx->comp.cbuf_ofs = (ctx->comp.spc << BLK_SHR);
@ -209,7 +209,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
}
}
nn = (16 - (ctx->target_vcn & 0xF)) / cpb;
nn = (16 - (unsigned) (ctx->target_vcn & 0xF)) / cpb;
if (nn > num)
nn = num;
num -= nn;

View file

@ -691,7 +691,7 @@ grub_reiserfs_mount (grub_disk_t disk)
if (grub_memcmp (data->superblock.magic_string,
REISERFS_MAGIC_STRING, sizeof (REISERFS_MAGIC_STRING) - 1))
{
grub_error (GRUB_ERR_BAD_FS, "not a reiserfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem");
goto fail;
}
data->disk = disk;
@ -700,7 +700,7 @@ grub_reiserfs_mount (grub_disk_t disk)
fail:
/* Disk is too small to contain a ReiserFS. */
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a reiserfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem");
grub_free (data);
return 0;
@ -998,7 +998,7 @@ grub_reiserfs_open (struct grub_file *file, const char *name)
goto fail;
if (root.block_number == 0)
{
grub_error (GRUB_ERR_BAD_FS, "Unable to find root item");
grub_error (GRUB_ERR_BAD_FS, "unable to find root item");
goto fail; /* Should never happen since checked at mount. */
}
grub_fshelp_find_file (name, &root, &found,
@ -1014,7 +1014,7 @@ grub_reiserfs_open (struct grub_file *file, const char *name)
goto fail;
if (info.block_number == 0)
{
grub_error (GRUB_ERR_BAD_FS, "Unable to find searched item");
grub_error (GRUB_ERR_BAD_FS, "unable to find searched item");
goto fail;
}
entry_version = grub_le_to_cpu16 (info.header.version);
@ -1289,7 +1289,7 @@ grub_reiserfs_dir (grub_device_t device, const char *path,
goto fail;
if (root.block_number == 0)
{
grub_error(GRUB_ERR_BAD_FS, "Root not found");
grub_error(GRUB_ERR_BAD_FS, "root not found");
goto fail;
}
grub_fshelp_find_file (path, &root, &found, grub_reiserfs_iterate_dir,

View file

@ -279,7 +279,7 @@ grub_sfs_mount (grub_disk_t disk)
/* Make sure this is a sfs filesystem. */
if (grub_strncmp ((char *) (data->rblock.header.magic), "SFS", 4))
{
grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not a SFS filesystem");
goto fail;
}
@ -307,7 +307,7 @@ grub_sfs_mount (grub_disk_t disk)
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not an sfs filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an SFS filesystem");
grub_free (data);
grub_free (rootobjc_data);

View file

@ -525,7 +525,7 @@ grub_udf_mount (grub_disk_t disk)
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
sizeof (struct grub_udf_vrs), &vrs))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
@ -539,7 +539,7 @@ grub_udf_mount (grub_disk_t disk)
(grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_CDW02, 5)) &&
(grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_TEA01, 5)))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
}
@ -552,7 +552,7 @@ grub_udf_mount (grub_disk_t disk)
if (grub_disk_read (disk, *sblklist << GRUB_UDF_LOG2_BLKSZ, 0,
sizeof (struct grub_udf_avdp), &avdp))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
@ -565,7 +565,7 @@ grub_udf_mount (grub_disk_t disk)
sblklist++;
if (*sblklist == 0)
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
}
@ -579,7 +579,7 @@ grub_udf_mount (grub_disk_t disk)
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
sizeof (struct grub_udf_tag), &tag))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
@ -596,7 +596,7 @@ grub_udf_mount (grub_disk_t disk)
sizeof (struct grub_udf_pd),
&data->pds[data->npd]))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
@ -612,7 +612,7 @@ grub_udf_mount (grub_disk_t disk)
sizeof (struct grub_udf_lvd),
&data->lvd))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}
@ -675,7 +675,7 @@ grub_udf_mount (grub_disk_t disk)
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
sizeof (struct grub_udf_fileset), &root_fs))
{
grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem");
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
goto fail;
}

Some files were not shown because too many files have changed in this diff Show more