merge mainline into net

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-02 18:52:50 +02:00
commit 03a0046581
45 changed files with 682 additions and 233 deletions

141
ChangeLog
View file

@ -1,3 +1,144 @@
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.core.def (chain): Fix coreboot filename.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/pata.c (grub_pata_initialize) [QEMU_MIPS]: Fix a
mismerge.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
Chainloading on coreboot support.
* grub-core/Makefile.core.def (chain): Add coreboot.
* grub-core/loader/i386/coreboot/chainloader.c: New file.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsd.c (grub_bsd_load): Handle relocator failure
if it happens.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
Implement time command.
* grub-core/Makefile.core.def (time): New module.
* grub-core/commands/time.c: New file.
* grub-core/script/parser.y: Remove "time" keyword.
* grub-core/script/yylex.l: Likewise.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/loader.h (grub_loader_unregister_preboot_hook): Export.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/relocator.c (malloc_in_range): Fix a memory corruption
when handling leftovers.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* util/ieee1275/grub-ofpathname.c (main): Handle --help and --version
so that help2man doesn't fail.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/drivers/ieee1275/ofnet.c (send_card_buffer) Use right
type in pointers on sparc64.
(get_card_packet): Likewise.
2011-06-27 Colin Watson <cjwatson@ubuntu.com>
* grub-core/commands/videoinfo.c (hook): Indicate current video mode
with `*'.
(grub_cmd_videoinfo): Fetch current video mode.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/scsi.c (grub_scsi_read): Limit SCSI reads to 32K
because of underlying system restrictions.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.in: Rename "ata" to "pata" and add ahci when
necessary.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
Coreboot video support.
* grub-core/Makefile.core.def (vga): Extend to coreboot and multiboot.
(vbe): Likewise.
* grub-core/kern/i386/coreboot/startup.S: Include int.S.
* grub-core/kern/i386/pc/startup.S (grub_bios_interrupt): Moved from
here ...
* grub-core/kern/i386/int.S: ... here.
* grub-core/video/i386/pc/vbe.c: Updated includes.
* grub-core/video/i386/pc/vga.c: Likewise.
* include/grub/i386/coreboot/memory.h
(GRUB_MEMORY_MACHINE_SCRATCH_ADDR): New definition.
(GRUB_MEMORY_MACHINE_SCRATCH_SEG): Likewise.
(GRUB_MEMORY_MACHINE_SCRATCH_SIZE): Likewise.
* include/grub/i386/pc/int.h (GRUB_CPU_INT_FLAGS_DEFAULT) [!PCBIOS]:
Disable interrupts.
* include/grub/i386/pc/vga.h: Removed. All users updated.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c (grub_ahci_readwrite_real): Use proper
definitions for dprintf.
* grub-core/disk/pata.c (grub_pata_readwrite): Likewise.
2011-06-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/drivers/ieee1275/ofnet.c (send_card_buffer): Fix
prototype.
(get_card_packet): Likewise.
2011-06-26 Yves Blusseau <blusseau@zetam.org>
Display the path of the file when file is not found
* grub-core/fs/fat.c: Display the filename when file is not found.
* grub-core/fs/fshelp.c: Likewise.
* grub-core/fs/hfs.c: Likewise.
* grub-core/fs/jfs.c: Likewise.
* grub-core/fs/minix.c: Likewise.
* grub-core/fs/ufs.c: Likewise.
* grub-core/fs/btrfs.c: Likewise.
* grub-core/commands/i386/pc/play.c: Likewise.
2011-06-26 Szymon Janc <szymon@janc.net.pl>
* grub-core/commands/cmp.c (grub_cmd_cmp): Remove unnecessary NULL
pointer checks before calling grub_free().
* grub-core/commands/wildcard.c (match_devices): Likewise.
* grub-core/commands/wildcard.c (match_files): Likewise.
* grub-core/fs/cpio.c (grub_cpio_dir): Likewise.
* grub-core/fs/cpio.c (grub_cpio_open): Likewise.
* grub-core/fs/udf.c (grub_udf_read_block): Likewise.
* grub-core/fs/xfs.c (grub_xfs_read_block): Likewise.
* grub-core/loader/efi/chainloader.c (grub_cmd_chainloader): Likewise.
* grub-core/normal/cmdline.c (grub_cmdline_get): Likewise.
* grub-core/script/yylex.l (grub_lexer_unput): Likewise.
* grub-core/video/readers/jpeg.c (grub_video_reader_jpeg): Likewise.
* grub-core/video/readers/png.c (grub_png_output_byte): Likewise.
2011-06-25 Patrick <p55@mailinator.com>
* grub-core/kern/main.c (grub_load_normal_mode): Correct the comment.
2011-06-25 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/i386/pc/pxe.c (grub_pxe_recv): Fix declaration.
(grub_pxe_send): Likewise.
(GRUB_MOD_INIT): Fix types.
2011-06-24 Szymon Janc <szymon@janc.net.pl>
* grub-core/io/xzio.c: Fix code style issues
2011-06-24 Vladimir Serbinenko <phcoder@gmail.com> 2011-06-24 Vladimir Serbinenko <phcoder@gmail.com>
2011-06-24 Manoel Rebelo Abranches <mrabran@gmail.com> 2011-06-24 Manoel Rebelo Abranches <mrabran@gmail.com>

View file

@ -100,10 +100,12 @@ endif
if COND_i386_coreboot if COND_i386_coreboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
endif endif
if COND_i386_multiboot if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
endif endif
if COND_i386_qemu if COND_i386_qemu

View file

@ -1295,7 +1295,9 @@ module = {
name = chain; name = chain;
efi = loader/efi/chainloader.c; efi = loader/efi/chainloader.c;
i386_pc = loader/i386/pc/chainloader.c; i386_pc = loader/i386/pc/chainloader.c;
i386_coreboot = loader/i386/coreboot/chainloader.c;
enable = i386_pc; enable = i386_pc;
enable = i386_coreboot;
enable = efi; enable = efi;
}; };
@ -1451,8 +1453,10 @@ module = {
module = { module = {
name = vga; name = vga;
i386_pc = video/i386/pc/vga.c; common = video/i386/pc/vga.c;
enable = i386_pc; enable = i386_pc;
enable = i386_coreboot;
enable = i386_multiboot;
}; };
module = { module = {
@ -1530,8 +1534,10 @@ module = {
module = { module = {
name = vbe; name = vbe;
i386_pc = video/i386/pc/vbe.c; common = video/i386/pc/vbe.c;
enable = i386_pc; enable = i386_pc;
enable = i386_coreboot;
enable = i386_multiboot;
}; };
module = { module = {
@ -1640,3 +1646,8 @@ module = {
common = commands/keylayouts.c; common = commands/keylayouts.c;
enable = videomodules; enable = videomodules;
}; };
module = {
name = time;
common = commands/time.c;
};

View file

@ -94,9 +94,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
cleanup: cleanup:
if (buf1)
grub_free (buf1); grub_free (buf1);
if (buf2)
grub_free (buf2); grub_free (buf2);
if (file1) if (file1)
grub_file_close (file1); grub_file_close (file1);

View file

@ -192,7 +192,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
file = grub_file_open (args[0]); file = grub_file_open (args[0]);
if (! file) if (! file)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo)) if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
{ {
@ -227,7 +227,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
if (*end) if (*end)
/* Was not a number either, assume it was supposed to be a file name. */ /* Was not a number either, assume it was supposed to be a file name. */
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]);
grub_dprintf ("play","tempo = %d\n", tempo); grub_dprintf ("play","tempo = %d\n", tempo);

68
grub-core/commands/time.c Normal file
View file

@ -0,0 +1,68 @@
/* echo.c - Command to display a line of text */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/time.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t
grub_cmd_time (grub_command_t ctxt __attribute__ ((unused)),
int argc, char **args)
{
grub_command_t cmd;
grub_uint32_t start;
grub_uint32_t end;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "command expected");
cmd = grub_command_find (args[0]);
if (!cmd)
return grub_error (GRUB_ERR_UNKNOWN_COMMAND, "Unknown command `%s'\n",
args[0]);
start = grub_get_time_ms ();
(cmd->func) (cmd, argc - 1, &args[1]);
end = grub_get_time_ms ();
grub_printf ("Elapsed time: %d.%03d seconds \n", (end - start) / 1000,
(end - start) % 1000);
return grub_errno;
}
static grub_command_t cmd;
GRUB_MOD_INIT(time)
{
cmd = grub_register_command ("time", grub_cmd_time,
N_("COMMAND [ARGS]"),
N_("Measure time used by COMMAND"));
}
GRUB_MOD_FINI(time)
{
grub_unregister_command (cmd);
}

View file

@ -28,6 +28,7 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
static unsigned height, width, depth; static unsigned height, width, depth;
static struct grub_video_mode_info *current_mode;
static int static int
hook (const struct grub_video_mode_info *info) hook (const struct grub_video_mode_info *info)
@ -41,7 +42,13 @@ hook (const struct grub_video_mode_info *info)
if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID) if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
grub_printf (" "); grub_printf (" ");
else else
{
if (current_mode && info->mode_number == current_mode->mode_number)
grub_printf ("*");
else
grub_printf (" ");
grub_printf (" 0x%03x ", info->mode_number); grub_printf (" 0x%03x ", info->mode_number);
}
grub_printf ("%4d x %4d x %2d ", info->width, info->height, info->bpp); grub_printf ("%4d x %4d x %2d ", info->width, info->height, info->bpp);
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT) if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
@ -122,6 +129,8 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
FOR_VIDEO_ADAPTERS (adapter) FOR_VIDEO_ADAPTERS (adapter)
{ {
struct grub_video_mode_info info;
grub_printf ("Adapter '%s':\n", adapter->name); grub_printf ("Adapter '%s':\n", adapter->name);
if (!adapter->iterate) if (!adapter->iterate)
@ -130,7 +139,17 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
continue; continue;
} }
if (adapter->id != id) current_mode = NULL;
if (adapter->id == id)
{
if (grub_video_get_info (&info) == GRUB_ERR_NONE)
current_mode = &info;
else
/* Don't worry about errors. */
grub_errno = GRUB_ERR_NONE;
}
else
{ {
if (adapter->init ()) if (adapter->init ())
{ {
@ -145,6 +164,8 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
adapter->iterate (hook); adapter->iterate (hook);
current_mode = NULL;
if (adapter->id != id) if (adapter->id != id)
{ {
if (adapter->fini ()) if (adapter->fini ())

View file

@ -255,7 +255,6 @@ match_devices (const regex_t *regexp, int noparts)
for (i = 0; devs && devs[i]; i++) for (i = 0; devs && devs[i]; i++)
grub_free (devs[i]); grub_free (devs[i]);
if (devs)
grub_free (devs); grub_free (devs);
return 0; return 0;
@ -342,19 +341,16 @@ match_files (const char *prefix, const char *suffix, const char *end,
fail: fail:
if (dir)
grub_free (dir); grub_free (dir);
for (i = 0; files && files[i]; i++) for (i = 0; files && files[i]; i++)
grub_free (files[i]); grub_free (files[i]);
if (files)
grub_free (files); grub_free (files);
if (dev) if (dev)
grub_device_close (dev); grub_device_close (dev);
if (device_name)
grub_free (device_name); grub_free (device_name);
grub_error_pop (); grub_error_pop ();

View file

@ -590,7 +590,8 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
dev->command_table[0].prdt[0].size = (parms->size + (parms->size & 1) - 1) dev->command_table[0].prdt[0].size = (parms->size + (parms->size & 1) - 1)
| GRUB_AHCI_INTERRUPT_ON_COMPLETE; | GRUB_AHCI_INTERRUPT_ON_COMPLETE;
grub_dprintf ("ahci", "PRDT = %" PRIxGRUB_UINT64_T ", %x, %x (%x)\n", grub_dprintf ("ahci", "PRDT = %" PRIxGRUB_UINT64_T ", %x, %x (%"
PRIuGRUB_SIZE ")\n",
dev->command_table[0].prdt[0].data_base, dev->command_table[0].prdt[0].data_base,
dev->command_table[0].prdt[0].unused, dev->command_table[0].prdt[0].unused,
dev->command_table[0].prdt[0].size, dev->command_table[0].prdt[0].size,

View file

@ -156,7 +156,8 @@ grub_pata_readwrite (struct grub_ata *disk,
parms->taskfile.cmd, parms->taskfile.cmd,
parms->taskfile.features, parms->taskfile.features,
parms->taskfile.sectors); parms->taskfile.sectors);
grub_dprintf ("pata", "lba_high=0x%x, lba_mid=0x%x, lba_low=0x%x, size=%d\n", grub_dprintf ("pata", "lba_high=0x%x, lba_mid=0x%x, lba_low=0x%x, size=%"
PRIuGRUB_SIZE "\n",
parms->taskfile.lba_high, parms->taskfile.lba_high,
parms->taskfile.lba_mid, parms->taskfile.lba_mid,
parms->taskfile.lba_low, parms->size); parms->taskfile.lba_low, parms->size);
@ -437,15 +438,13 @@ grub_pata_initialize (void)
} }
#else #else
static grub_err_t static grub_err_t
grub_ata_initialize (void) grub_pata_initialize (void)
{ {
int i; int i;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
grub_ata_device_initialize (i, 0, grub_ata_ioaddress[i], grub_pata_device_initialize (i, 0, grub_pata_ioaddress[i]);
grub_ata_ioaddress2[i]); grub_pata_device_initialize (i, 1, grub_pata_ioaddress[i]);
grub_ata_device_initialize (i, 1, grub_ata_ioaddress[i],
grub_ata_ioaddress2[i]);
} }
return 0; return 0;
} }

View file

@ -524,17 +524,36 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
scsi = disk->data; scsi = disk->data;
while (size)
{
/* PATA doesn't support more than 32K reads.
Not sure about AHCI and USB. If it's confirmed that either of
them can do bigger reads reliably this value can be moved to 'scsi'
structure. */
grub_size_t len = 32768 >> disk->log_sector_size;
grub_err_t err;
if (len > size)
len = size;
/* Depending on the type, select a read function. */ /* Depending on the type, select a read function. */
switch (scsi->devtype) switch (scsi->devtype)
{ {
case grub_scsi_devtype_direct: case grub_scsi_devtype_direct:
return grub_scsi_read10 (disk, sector, size, buf); err = grub_scsi_read10 (disk, sector, len, buf);
if (err)
return err;
break;
case grub_scsi_devtype_cdrom: case grub_scsi_devtype_cdrom:
return grub_scsi_read12 (disk, sector, size, buf); err = grub_scsi_read12 (disk, sector, len, buf);
if (err)
return err;
break;
}
size -= len;
sector += len;
buf += len << disk->log_sector_size;
} }
/* XXX: Never reached. */
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
#if 0 /* Workaround - it works - but very slowly, from some reason #if 0 /* Workaround - it works - but very slowly, from some reason

View file

@ -1054,6 +1054,7 @@ find_path (struct grub_btrfs_data *data,
const char *ctoken; const char *ctoken;
grub_size_t ctokenlen; grub_size_t ctokenlen;
char *path_alloc = NULL; char *path_alloc = NULL;
char *origpath = NULL;
unsigned symlinks_max = 32; unsigned symlinks_max = 32;
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
@ -1062,6 +1063,9 @@ find_path (struct grub_btrfs_data *data,
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
key->offset = 0; key->offset = 0;
skip_default = 1; skip_default = 1;
origpath = grub_strdup (path);
if (!origpath)
return grub_errno;
while (1) while (1)
{ {
@ -1086,6 +1090,7 @@ find_path (struct grub_btrfs_data *data,
if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
{ {
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
} }
@ -1098,13 +1103,16 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return err; return err;
} }
if (key_cmp (key, &key_out) != 0) if (key_cmp (key, &key_out) != 0)
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
grub_free (origpath);
return err;
} }
struct grub_btrfs_dir_item *cdirel; struct grub_btrfs_dir_item *cdirel;
@ -1116,6 +1124,7 @@ find_path (struct grub_btrfs_data *data,
if (!direl) if (!direl)
{ {
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return grub_errno; return grub_errno;
} }
} }
@ -1125,6 +1134,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return err; return err;
} }
@ -1144,7 +1154,9 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
grub_free (origpath);
return err;
} }
if (!skip_default) if (!skip_default)
@ -1158,6 +1170,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return grub_error (GRUB_ERR_SYMLINK_LOOP, return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); "too deep nesting of symlinks");
} }
@ -1168,6 +1181,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return err; return err;
} }
tmp = grub_malloc (grub_le_to_cpu64 (inode.size) tmp = grub_malloc (grub_le_to_cpu64 (inode.size)
@ -1176,6 +1190,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return grub_errno; return grub_errno;
} }
@ -1186,12 +1201,14 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
grub_free (tmp); grub_free (tmp);
return grub_errno; return grub_errno;
} }
grub_memcpy (tmp + grub_le_to_cpu64 (inode.size), path, grub_memcpy (tmp + grub_le_to_cpu64 (inode.size), path,
grub_strlen (path) + 1); grub_strlen (path) + 1);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
path = path_alloc = tmp; path = path_alloc = tmp;
if (path[0] == '/') if (path[0] == '/')
{ {
@ -1218,6 +1235,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return err; return err;
} }
if (cdirel->key.object_id != key_out.object_id if (cdirel->key.object_id != key_out.object_id
@ -1225,7 +1243,9 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
grub_free (origpath);
return err;
} }
err = grub_btrfs_read_logical (data, elemaddr, err = grub_btrfs_read_logical (data, elemaddr,
&ri, sizeof (ri)); &ri, sizeof (ri));
@ -1233,6 +1253,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
return err; return err;
} }
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
@ -1246,7 +1267,9 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
grub_free (origpath);
return err;
} }
*key = cdirel->key; *key = cdirel->key;
if (*type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) if (*type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
@ -1254,6 +1277,7 @@ find_path (struct grub_btrfs_data *data,
break; break;
default: default:
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath);
grub_free (direl); grub_free (direl);
return grub_error (GRUB_ERR_BAD_FS, "unrecognised object type 0x%x", return grub_error (GRUB_ERR_BAD_FS, "unrecognised object type 0x%x",
cdirel->key.type); cdirel->key.type);

View file

@ -239,7 +239,6 @@ grub_cpio_dir (grub_device_t device, const char *path,
info.mtimeset = 1; info.mtimeset = 1;
hook (name + len, &info); hook (name + len, &info);
if (prev)
grub_free (prev); grub_free (prev);
prev = name; prev = name;
} }
@ -251,10 +250,7 @@ grub_cpio_dir (grub_device_t device, const char *path,
fail: fail:
if (prev)
grub_free (prev); grub_free (prev);
if (data)
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@ -326,7 +322,6 @@ grub_cpio_open (grub_file_t file, const char *name)
fail: fail:
if (data)
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);

View file

@ -565,6 +565,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
const struct grub_dirhook_info *info)) const struct grub_dirhook_info *info))
{ {
char *dirname, *dirp; char *dirname, *dirp;
char *origpath = NULL;
int call_hook; int call_hook;
int found = 0; int found = 0;
@ -605,6 +606,10 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
return 0; return 0;
} }
origpath = grub_strdup (path);
if (!origpath)
return 0;
/* Extract a directory name. */ /* Extract a directory name. */
while (*path == '/') while (*path == '/')
path++; path++;
@ -616,7 +621,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
dirname = grub_malloc (len + 1); dirname = grub_malloc (len + 1);
if (! dirname) if (! dirname)
return 0; goto fail;
grub_memcpy (dirname, path, len); grub_memcpy (dirname, path, len);
dirname[len] = '\0'; dirname[len] = '\0';
@ -629,9 +634,11 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
grub_fat_iterate_dir (disk, data, iter_hook); grub_fat_iterate_dir (disk, data, iter_hook);
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook) if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
fail:
grub_free (dirname); grub_free (dirname);
grub_free (origpath);
return found ? dirp : 0; return found ? dirp : 0;
} }

View file

@ -197,7 +197,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
name = next; name = next;
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
} }
if (!path || path[0] != '/') if (!path || path[0] != '/')

View file

@ -921,7 +921,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
if (! grub_hfs_find_node (data, (char *) &key, data->cat_root, if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec))) 0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
{ {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath);
goto fail; goto fail;
} }

View file

@ -699,7 +699,7 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
} }
grub_jfs_closedir (diro); grub_jfs_closedir (diro);
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
return grub_errno; return grub_errno;
} }

View file

@ -424,7 +424,7 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
pos += sizeof (ino) + data->filename_size; pos += sizeof (ino) + data->filename_size;
} while (pos < GRUB_MINIX_INODE_SIZE (data)); } while (pos < GRUB_MINIX_INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
return grub_errno; return grub_errno;
} }

View file

@ -546,7 +546,6 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
} }
fail: fail:
if (buf)
grub_free (buf); grub_free (buf);
return 0; return 0;

View file

@ -514,7 +514,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
pos += grub_le_to_cpu16 (dirent.direntlen); pos += grub_le_to_cpu16 (dirent.direntlen);
} while (pos < INODE_SIZE (data)); } while (pos < INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path);
return grub_errno; return grub_errno;
} }

View file

@ -324,7 +324,6 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
} }
} }
if (leaf)
grub_free (leaf); grub_free (leaf);
return GRUB_XFS_FSB_TO_BLOCK(node->data, ret); return GRUB_XFS_FSB_TO_BLOCK(node->data, ret);

View file

@ -48,7 +48,7 @@ static struct grub_fs grub_xzio_fs;
static grub_size_t static grub_size_t
decode_vli (const grub_uint8_t buf[], grub_size_t size_max, decode_vli (const grub_uint8_t buf[], grub_size_t size_max,
grub_uint64_t * num) grub_uint64_t *num)
{ {
if (size_max == 0) if (size_max == 0)
return 0; return 0;
@ -71,7 +71,7 @@ decode_vli (const grub_uint8_t buf[], grub_size_t size_max,
} }
static grub_ssize_t static grub_ssize_t
read_vli (grub_file_t file, grub_uint64_t * num) read_vli (grub_file_t file, grub_uint64_t *num)
{ {
grub_uint8_t buf[VLI_MAX_DIGITS]; grub_uint8_t buf[VLI_MAX_DIGITS];
grub_ssize_t read; grub_ssize_t read;
@ -92,6 +92,8 @@ static int
test_header (grub_file_t file) test_header (grub_file_t file)
{ {
grub_xzio_t xzio = file->data; grub_xzio_t xzio = file->data;
enum xz_ret ret;
xzio->buf.in_size = grub_file_read (xzio->file, xzio->inbuf, xzio->buf.in_size = grub_file_read (xzio->file, xzio->inbuf,
STREAM_HEADER_SIZE); STREAM_HEADER_SIZE);
@ -101,7 +103,7 @@ test_header (grub_file_t file)
return 0; return 0;
} }
enum xz_ret ret = xz_dec_run (xzio->dec, &xzio->buf); ret = xz_dec_run (xzio->dec, &xzio->buf);
if (ret == XZ_FORMAT_ERROR) if (ret == XZ_FORMAT_ERROR)
{ {
@ -132,8 +134,8 @@ test_footer (grub_file_t file)
grub_uint64_t records; grub_uint64_t records;
grub_file_seek (xzio->file, xzio->file->size - FOOTER_MAGIC_SIZE); grub_file_seek (xzio->file, xzio->file->size - FOOTER_MAGIC_SIZE);
if (grub_file_read (xzio->file, footer, FOOTER_MAGIC_SIZE) != if (grub_file_read (xzio->file, footer, FOOTER_MAGIC_SIZE)
FOOTER_MAGIC_SIZE != FOOTER_MAGIC_SIZE
|| grub_memcmp (footer, FOOTER_MAGIC, FOOTER_MAGIC_SIZE) != 0) || grub_memcmp (footer, FOOTER_MAGIC, FOOTER_MAGIC_SIZE) != 0)
goto ERROR; goto ERROR;
@ -150,8 +152,8 @@ test_footer (grub_file_t file)
xzio->file->size - XZ_STREAM_FOOTER_SIZE - backsize); xzio->file->size - XZ_STREAM_FOOTER_SIZE - backsize);
/* Test index marker. */ /* Test index marker. */
if (grub_file_read (xzio->file, &imarker, sizeof (imarker)) != if (grub_file_read (xzio->file, &imarker, sizeof (imarker))
sizeof (imarker) && imarker != 0x00) != sizeof (imarker) && imarker != 0x00)
goto ERROR; goto ERROR;
if (read_vli (xzio->file, &records) <= 0) if (read_vli (xzio->file, &records) <= 0)

View file

@ -87,3 +87,4 @@ codestart:
*/ */
#include "../realmode.S" #include "../realmode.S"
#include "../int.S"

140
grub-core/kern/i386/int.S Normal file
View file

@ -0,0 +1,140 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 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/>.
*/
FUNCTION(grub_bios_interrupt)
pushf
cli
#ifndef GRUB_MACHINE_PCBIOS
sidt protidt
#endif
popf
pushl %ebp
pushl %ecx
pushl %eax
pushl %ebx
pushl %esi
pushl %edi
pushl %edx
movb %al, intno
movl (%edx), %eax
movl %eax, LOCAL(bios_register_eax)
movw 4(%edx), %ax
movw %ax, LOCAL(bios_register_es)
movw 6(%edx), %ax
movw %ax, LOCAL(bios_register_ds)
movw 8(%edx), %ax
movw %ax, LOCAL(bios_register_flags)
movl 12(%edx), %ebx
movl 16(%edx), %ecx
movl 20(%edx), %edi
movl 24(%edx), %esi
movl 28(%edx), %edx
call prot_to_real
.code16
pushf
cli
#ifndef GRUB_MACHINE_PCBIOS
lidt realidt
#endif
mov %ds, %ax
push %ax
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_es):
.short 0
movw %ax, %es
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_ds):
.short 0
movw %ax, %ds
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_flags):
.short 0
push %ax
popf
/* movl imm32, %eax*/
.byte 0x66, 0xb8
LOCAL(bios_register_eax):
.long 0
/* int imm8. */
.byte 0xcd
intno:
.byte 0
movl %eax, %cs:LOCAL(bios_register_eax)
movw %ds, %ax
movw %ax, %cs:LOCAL(bios_register_ds)
pop %ax
mov %ax, %ds
pushf
pop %ax
movw %ax, LOCAL(bios_register_flags)
mov %es, %ax
movw %ax, LOCAL(bios_register_es)
popf
DATA32 call real_to_prot
.code32
popl %eax
movl %ebx, 12(%eax)
movl %ecx, 16(%eax)
movl %edi, 20(%eax)
movl %esi, 24(%eax)
movl %edx, 28(%eax)
movl %eax, %edx
movl LOCAL(bios_register_eax), %eax
movl %eax, (%edx)
movw LOCAL(bios_register_es), %ax
movw %ax, 4(%edx)
movw LOCAL(bios_register_ds), %ax
movw %ax, 6(%edx)
movw LOCAL(bios_register_flags), %ax
movw %ax, 8(%edx)
popl %edi
popl %esi
popl %ebx
popl %eax
popl %ecx
popl %ebp
#ifndef GRUB_MACHINE_PCBIOS
lidt protidt
#endif
ret
#ifndef GRUB_MACHINE_PCBIOS
realidt:
.word 0x100
.long 0
protidt:
.word 0
.long 0
#endif

View file

@ -910,102 +910,4 @@ FUNCTION(grub_pxe_call)
popl %ebp popl %ebp
ret ret
FUNCTION(grub_bios_interrupt) #include "../int.S"
pushl %ebp
pushl %ecx
pushl %eax
pushl %ebx
pushl %esi
pushl %edi
pushl %edx
movb %al, intno
movl (%edx), %eax
movl %eax, LOCAL(bios_register_eax)
movw 4(%edx), %ax
movw %ax, LOCAL(bios_register_es)
movw 6(%edx), %ax
movw %ax, LOCAL(bios_register_ds)
movw 8(%edx), %ax
movw %ax, LOCAL(bios_register_flags)
movl 12(%edx), %ebx
movl 16(%edx), %ecx
movl 20(%edx), %edi
movl 24(%edx), %esi
movl 28(%edx), %edx
call prot_to_real
.code16
mov %ds, %ax
push %ax
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_es):
.short 0
movw %ax, %es
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_ds):
.short 0
movw %ax, %ds
/* movw imm16, %ax*/
.byte 0xb8
LOCAL(bios_register_flags):
.short 0
push %ax
popf
/* movl imm32, %eax*/
.byte 0x66, 0xb8
LOCAL(bios_register_eax):
.long 0
/* int imm8. */
.byte 0xcd
intno:
.byte 0
movl %eax, %cs:LOCAL(bios_register_eax)
movw %ds, %ax
movw %ax, %cs:LOCAL(bios_register_ds)
pop %ax
mov %ax, %ds
pushf
pop %ax
movw %ax, LOCAL(bios_register_flags)
mov %es, %ax
movw %ax, LOCAL(bios_register_es)
DATA32 call real_to_prot
.code32
popl %eax
movl %ebx, 12(%eax)
movl %ecx, 16(%eax)
movl %edi, 20(%eax)
movl %esi, 24(%eax)
movl %edx, 28(%eax)
movl %eax, %edx
movl LOCAL(bios_register_eax), %eax
movl %eax, (%edx)
movw LOCAL(bios_register_es), %ax
movw %ax, 4(%edx)
movw LOCAL(bios_register_ds), %ax
movw %ax, 6(%edx)
movw LOCAL(bios_register_flags), %ax
movw %ax, 8(%edx)
popl %edi
popl %esi
popl %ebx
popl %eax
popl %ecx
popl %ebp
ret

View file

@ -206,7 +206,7 @@ grub_load_normal_mode (void)
/* Load the module. */ /* Load the module. */
grub_dl_load ("normal"); grub_dl_load ("normal");
/* Something went wrong. Print errors here to let user know why we're entering rescue mode. */ /* Print errors if any. */
grub_print_error (); grub_print_error ();
grub_errno = 0; grub_errno = 0;

View file

@ -764,6 +764,9 @@ malloc_in_range (struct grub_relocator *rel,
int inreg = 0, regbeg = 0, ncol = 0; int inreg = 0, regbeg = 0, ncol = 0;
#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
int fwin = 0, fwb = 0, fwlefto = 0; int fwin = 0, fwb = 0, fwlefto = 0;
#endif
#if GRUB_RELOCATOR_HAVE_LEFTOVERS
int last_lo = 0;
#endif #endif
int last_start = 0; int last_start = 0;
for (j = 0; j < N; j++) for (j = 0; j < N; j++)
@ -855,7 +858,7 @@ malloc_in_range (struct grub_relocator *rel,
unsigned offend = alloc_end unsigned offend = alloc_end
% GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT; % GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
struct grub_relocator_fw_leftover *lo struct grub_relocator_fw_leftover *lo
= events[last_start].leftover; = events[last_lo].leftover;
lo->freebytes[offstart / 8] lo->freebytes[offstart / 8]
&= ((1 << (8 - (start % 8))) - 1); &= ((1 << (8 - (start % 8))) - 1);
grub_memset (lo->freebytes + (offstart + 7) / 8, 0, grub_memset (lo->freebytes + (offstart + 7) / 8, 0,
@ -910,6 +913,7 @@ malloc_in_range (struct grub_relocator *rel,
#if GRUB_RELOCATOR_HAVE_LEFTOVERS #if GRUB_RELOCATOR_HAVE_LEFTOVERS
case REG_LEFTOVER_START: case REG_LEFTOVER_START:
fwlefto++; fwlefto++;
last_lo = j;
break; break;
case REG_LEFTOVER_END: case REG_LEFTOVER_END:
@ -1009,7 +1013,8 @@ malloc_in_range (struct grub_relocator *rel,
curschu->extra = ne; curschu->extra = ne;
} }
} }
#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
#if GRUB_RELOCATOR_HAVE_LEFTOVERS
if (!oom && typepre == CHUNK_TYPE_FIRMWARE) if (!oom && typepre == CHUNK_TYPE_FIRMWARE)
{ {
grub_addr_t fstart, fend; grub_addr_t fstart, fend;
@ -1021,7 +1026,6 @@ malloc_in_range (struct grub_relocator *rel,
= ALIGN_UP (alloc_end, = ALIGN_UP (alloc_end,
GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT); GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
#if GRUB_RELOCATOR_HAVE_LEFTOVERS
{ {
struct grub_relocator_fw_leftover *lo1 = NULL; struct grub_relocator_fw_leftover *lo1 = NULL;
struct grub_relocator_fw_leftover *lo2 = NULL; struct grub_relocator_fw_leftover *lo2 = NULL;
@ -1081,10 +1085,8 @@ malloc_in_range (struct grub_relocator *rel,
curschu->pre = lo1; curschu->pre = lo1;
curschu->post = lo2; curschu->post = lo2;
} }
#endif
} }
#if GRUB_RELOCATOR_HAVE_LEFTOVERS
if (typepre == CHUNK_TYPE_LEFTOVER) if (typepre == CHUNK_TYPE_LEFTOVER)
{ {
curschu->pre = events[last_start].leftover; curschu->pre = events[last_start].leftover;
@ -1092,7 +1094,6 @@ malloc_in_range (struct grub_relocator *rel,
} }
#endif #endif
#endif
if (!oom) if (!oom)
cural++; cural++;
else else

View file

@ -329,7 +329,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (file) if (file)
grub_file_close (file); grub_file_close (file);
if (file_path)
grub_free (file_path); grub_free (file_path);
if (address) if (address)

View file

@ -1322,6 +1322,11 @@ grub_bsd_load (int argc, char *argv[])
goto fail; goto fail;
relocator = grub_relocator_new (); relocator = grub_relocator_new ();
if (!relocator)
{
grub_file_close (file);
goto fail;
}
elf = grub_elf_file (file); elf = grub_elf_file (file);
if (elf) if (elf)

View file

@ -0,0 +1,145 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/loader.h>
#include <grub/memory.h>
#include <grub/i386/memory.h>
#include <grub/file.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/mm.h>
#include <grub/elfload.h>
#include <grub/video.h>
#include <grub/relocator.h>
#include <grub/i386/relocator.h>
#include <grub/command.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_addr_t entry;
static struct grub_relocator *relocator = NULL;
static grub_err_t
grub_chain_boot (void)
{
struct grub_relocator32_state state;
grub_video_set_mode ("text", 0, 0);
state.eip = entry;
return grub_relocator32_boot (relocator, state);
}
static grub_err_t
grub_chain_unload (void)
{
grub_relocator_unload (relocator);
relocator = NULL;
return GRUB_ERR_NONE;
}
static grub_err_t
grub_chain_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr, int *do_load)
{
grub_err_t err;
grub_relocator_chunk_t ch;
if (phdr->p_type != PT_LOAD)
{
*do_load = 0;
return 0;
}
*do_load = 1;
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
phdr->p_paddr, phdr->p_memsz);
if (err)
return err;
*addr = (grub_addr_t) get_virtual_current_address (ch);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_cmd_chain (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_err_t err;
grub_file_t file;
grub_elf_t elf;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "filename expected");
grub_loader_unset ();
file = grub_file_open (argv[0]);
if (!file)
return grub_errno;
relocator = grub_relocator_new ();
if (!relocator)
{
grub_file_close (file);
return grub_errno;
}
elf = grub_elf_file (file);
if (!elf)
{
grub_relocator_unload (relocator);
relocator = 0;
grub_file_close (file);
}
if (!grub_elf_is_elf32 (elf))
{
grub_relocator_unload (relocator);
relocator = 0;
grub_elf_close (elf);
}
entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF;
err = grub_elf32_load (elf, grub_chain_elf32_hook, 0, 0);
grub_elf_close (elf);
if (err)
return err;
grub_loader_set (grub_chain_boot, grub_chain_unload, 0);
return GRUB_ERR_NONE;
}
static grub_command_t cmd_chain;
GRUB_MOD_INIT (chain)
{
cmd_chain = grub_register_command ("chainloader", grub_cmd_chain,
N_("FILE"), N_("Load another payload"));
}
GRUB_MOD_FINI (chain)
{
grub_unregister_command (cmd_chain);
grub_chain_unload ();
}

View file

@ -35,7 +35,7 @@ send_card_buffer (const struct grub_net_card *dev,
{ {
grub_efi_status_t st; grub_efi_status_t st;
grub_efi_simple_network_t *net = dev->efi_net; grub_efi_simple_network_t *net = dev->efi_net;
st = efi_call_7 (net->transmit, net, 0, pack->tail - pack->data, st = efi_call_7 (net->transmit, net, 0, (pack->tail - pack->data),
pack->data, NULL, NULL, NULL); pack->data, NULL, NULL, NULL);
if (st != GRUB_EFI_SUCCESS) if (st != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO, "Couldn't send network packet."); return grub_error (GRUB_ERR_IO, "Couldn't send network packet.");

View file

@ -55,10 +55,9 @@ card_close (struct grub_net_card *dev)
} }
static grub_err_t static grub_err_t
send_card_buffer (const struct grub_net_card *dev, send_card_buffer (const struct grub_net_card *dev, struct grub_net_buff *pack)
struct grub_net_buff *pack)
{ {
int actual; grub_ssize_t actual;
int status; int status;
struct grub_ofnetcard_data *data = dev->data; struct grub_ofnetcard_data *data = dev->data;
@ -71,11 +70,10 @@ send_card_buffer (const struct grub_net_card *dev,
} }
static grub_ssize_t static grub_ssize_t
get_card_packet (const struct grub_net_card *dev, get_card_packet (const struct grub_net_card *dev, struct grub_net_buff *nb)
struct grub_net_buff *nb)
{ {
grub_ssize_t actual;
int actual, rc; int rc;
struct grub_ofnetcard_data *data = dev->data; struct grub_ofnetcard_data *data = dev->data;
grub_uint64_t start_time; grub_uint64_t start_time;

View file

@ -500,7 +500,6 @@ grub_cmdline_get (const char *prompt)
case GRUB_TERM_CTRL | 'k': case GRUB_TERM_CTRL | 'k':
if (lpos < llen) if (lpos < llen)
{ {
if (kill_buf)
grub_free (kill_buf); grub_free (kill_buf);
kill_buf = grub_malloc ((llen - lpos + 1) kill_buf = grub_malloc ((llen - lpos + 1)
@ -566,7 +565,6 @@ grub_cmdline_get (const char *prompt)
{ {
grub_size_t n = lpos; grub_size_t n = lpos;
if (kill_buf)
grub_free (kill_buf); grub_free (kill_buf);
kill_buf = grub_malloc (n + 1); kill_buf = grub_malloc (n + 1);

View file

@ -74,7 +74,6 @@
%token <arg> GRUB_PARSER_TOKEN_THEN "then" %token <arg> GRUB_PARSER_TOKEN_THEN "then"
%token <arg> GRUB_PARSER_TOKEN_UNTIL "until" %token <arg> GRUB_PARSER_TOKEN_UNTIL "until"
%token <arg> GRUB_PARSER_TOKEN_WHILE "while" %token <arg> GRUB_PARSER_TOKEN_WHILE "while"
%token <arg> GRUB_PARSER_TOKEN_TIME "time"
%token <arg> GRUB_PARSER_TOKEN_FUNCTION "function" %token <arg> GRUB_PARSER_TOKEN_FUNCTION "function"
%token <arg> GRUB_PARSER_TOKEN_NAME "name" %token <arg> GRUB_PARSER_TOKEN_NAME "name"
%token <arg> GRUB_PARSER_TOKEN_WORD "word" %token <arg> GRUB_PARSER_TOKEN_WORD "word"
@ -147,7 +146,6 @@ argument : "case" { $$ = grub_script_add_arglist (state, 0, $1); }
| "until" { $$ = grub_script_add_arglist (state, 0, $1); } | "until" { $$ = grub_script_add_arglist (state, 0, $1); }
| "while" { $$ = grub_script_add_arglist (state, 0, $1); } | "while" { $$ = grub_script_add_arglist (state, 0, $1); }
| "function" { $$ = grub_script_add_arglist (state, 0, $1); } | "function" { $$ = grub_script_add_arglist (state, 0, $1); }
| "time" { $$ = grub_script_add_arglist (state, 0, $1); }
| word { $$ = $1; } | word { $$ = $1; }
; ;

View file

@ -161,7 +161,6 @@ MULTILINE {WORD}?((\"{DQCHR}*)|(\'{SQCHR}*)|(\\\n))
"}" { RECORD; return GRUB_PARSER_TOKEN_RBR; } "}" { RECORD; return GRUB_PARSER_TOKEN_RBR; }
"[[" { RECORD; return GRUB_PARSER_TOKEN_RSQBR2; } "[[" { RECORD; return GRUB_PARSER_TOKEN_RSQBR2; }
"]]" { RECORD; return GRUB_PARSER_TOKEN_LSQBR2; } "]]" { RECORD; return GRUB_PARSER_TOKEN_LSQBR2; }
"time" { RECORD; return GRUB_PARSER_TOKEN_TIME; }
"case" { RECORD; return GRUB_PARSER_TOKEN_CASE; } "case" { RECORD; return GRUB_PARSER_TOKEN_CASE; }
"do" { RECORD; return GRUB_PARSER_TOKEN_DO; } "do" { RECORD; return GRUB_PARSER_TOKEN_DO; }
"done" { RECORD; return GRUB_PARSER_TOKEN_DONE; } "done" { RECORD; return GRUB_PARSER_TOKEN_DONE; }
@ -355,7 +354,6 @@ grub_lexer_unput (const char *text, yyscan_t yyscanner)
{ {
struct grub_lexer_param *lexerstate = yyget_extra (yyscanner)->lexerstate; struct grub_lexer_param *lexerstate = yyget_extra (yyscanner)->lexerstate;
if (lexerstate->prefix)
grub_free (lexerstate->prefix); grub_free (lexerstate->prefix);
lexerstate->prefix = grub_strdup (text); lexerstate->prefix = grub_strdup (text);

View file

@ -20,15 +20,14 @@
#include <grub/err.h> #include <grub/err.h>
#include <grub/machine/memory.h> #include <grub/machine/memory.h>
#include <grub/machine/vga.h> #include <grub/i386/pc/vbe.h>
#include <grub/machine/vbe.h>
#include <grub/video_fb.h> #include <grub/video_fb.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/video.h> #include <grub/video.h>
#include <grub/machine/int.h> #include <grub/i386/pc/int.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -377,7 +376,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
if (vbe_mode < 0x100) if (vbe_mode < 0x100)
{ {
/* If this is not a VESA mode, guess address. */ /* If this is not a VESA mode, guess address. */
framebuffer.ptr = (grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR; framebuffer.ptr = (grub_uint8_t *) 0xa0000;
} }
else else
{ {

View file

@ -18,8 +18,7 @@
#define grub_video_render_target grub_video_fbrender_target #define grub_video_render_target grub_video_fbrender_target
#include <grub/machine/vga.h> #include <grub/i386/pc/int.h>
#include <grub/machine/int.h>
#include <grub/machine/console.h> #include <grub/machine/console.h>
#include <grub/cpu/io.h> #include <grub/cpu/io.h>
#include <grub/mm.h> #include <grub/mm.h>
@ -34,7 +33,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define VGA_WIDTH 640 #define VGA_WIDTH 640
#define VGA_HEIGHT 350 #define VGA_HEIGHT 350
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR) #define VGA_MEM ((grub_uint8_t *) 0xa0000)
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8)) #define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
static unsigned char text_mode; static unsigned char text_mode;

View file

@ -750,7 +750,6 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
grub_jpeg_decode_jpeg (data); grub_jpeg_decode_jpeg (data);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
if (data->huff_value[i])
grub_free (data->huff_value[i]); grub_free (data->huff_value[i]);
grub_free (data); grub_free (data);

View file

@ -625,7 +625,6 @@ grub_png_output_byte (struct grub_png_data *data, grub_uint8_t n)
} }
} }
if (blank_line)
grub_free (blank_line); grub_free (blank_line);
data->cur_column = 0; data->cur_column = 0;

View file

@ -28,6 +28,10 @@
#include <grub/memory.h> #include <grub/memory.h>
#endif #endif
#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000
#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4)
#define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x10000
#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */ #define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */ #define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */

View file

@ -45,7 +45,12 @@ struct grub_bios_int_registers
#define GRUB_CPU_INT_FLAGS_INTERRUPT 0x200 #define GRUB_CPU_INT_FLAGS_INTERRUPT 0x200
#define GRUB_CPU_INT_FLAGS_DIRECTION 0x400 #define GRUB_CPU_INT_FLAGS_DIRECTION 0x400
#define GRUB_CPU_INT_FLAGS_OVERFLOW 0x800 #define GRUB_CPU_INT_FLAGS_OVERFLOW 0x800
#ifdef GRUB_MACHINE_PCBIOS
#define GRUB_CPU_INT_FLAGS_DEFAULT GRUB_CPU_INT_FLAGS_INTERRUPT #define GRUB_CPU_INT_FLAGS_DEFAULT GRUB_CPU_INT_FLAGS_INTERRUPT
#else
#define GRUB_CPU_INT_FLAGS_DEFAULT 0
#endif
void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno, void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno,
struct grub_bios_int_registers *regs); struct grub_bios_int_registers *regs);

View file

@ -1,28 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,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/>.
*/
#ifndef GRUB_VGA_MACHINE_HEADER
#define GRUB_VGA_MACHINE_HEADER 1
#include <grub/symbol.h>
#include <grub/machine/memory.h>
/* The VGA (at the beginning of upper memory). */
#define GRUB_MEMORY_MACHINE_VGA_ADDR GRUB_MEMORY_MACHINE_UPPER
#endif /* ! GRUB_VGA_MACHINE_HEADER */

View file

@ -61,6 +61,6 @@ void *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func)
grub_loader_preboot_hook_prio_t prio); grub_loader_preboot_hook_prio_t prio);
/* Unregister given preboot hook. */ /* Unregister given preboot hook. */
void grub_loader_unregister_preboot_hook (void *hnd); void EXPORT_FUNC (grub_loader_unregister_preboot_hook) (void *hnd);
#endif /* ! GRUB_LOADER_HEADER */ #endif /* ! GRUB_LOADER_HEADER */

View file

@ -275,7 +275,7 @@ if test -e "${pc_dir}" ; then
fi fi
# build multiboot core.img # build multiboot core.img
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "ata at_keyboard" make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "pata ahci at_keyboard"
if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
@ -296,11 +296,11 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img" grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
fi fi
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "ata at_keyboard" make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "pata at_keyboard"
if [ -e "${iso9660_dir}/boot/qemu.img" ] && [ -d "${rom_directory}" ]; then if [ -e "${iso9660_dir}/boot/qemu.img" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/qemu.img" "${rom_directory}/qemu.img" cp "${iso9660_dir}/boot/qemu.img" "${rom_directory}/qemu.img"
fi fi
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "ata at_keyboard" make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "pata ahci at_keyboard"
if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/coreboot.elf" "${rom_directory}/coreboot.elf" cp "${iso9660_dir}/boot/coreboot.elf" "${rom_directory}/coreboot.elf"
fi fi

View file

@ -32,11 +32,16 @@ int main(int argc, char **argv)
grub_util_init_nls (); grub_util_init_nls ();
if (argc != 2) if (argc != 2 || strcmp (argv[1], "--help") == 0)
{ {
printf("Usage: %s DEVICE\n", program_name); printf("Usage: %s DEVICE\n", program_name);
return 1; return 1;
} }
if (strcmp (argv[1], "--version") == 0)
{
printf ("%s\n", PACKAGE_STRING);
return 1;
}
of_path = grub_util_devname_to_ofpath (argv[1]); of_path = grub_util_devname_to_ofpath (argv[1]);
printf("%s\n", of_path); printf("%s\n", of_path);