pull-in emu-lite branch
This commit is contained in:
commit
692d7c2855
120 changed files with 3842 additions and 13152 deletions
|
@ -24,7 +24,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/kernel.h>
|
||||
|
||||
void
|
||||
grub_efi_init (void)
|
||||
|
@ -42,39 +42,58 @@ grub_efi_init (void)
|
|||
void
|
||||
grub_efi_set_prefix (void)
|
||||
{
|
||||
grub_efi_loaded_image_t *image;
|
||||
grub_efi_loaded_image_t *image = NULL;
|
||||
char *device = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
image = grub_efi_get_loaded_image (grub_efi_image_handle);
|
||||
if (image)
|
||||
{
|
||||
char *pptr = NULL;
|
||||
if (grub_prefix[0] == '(')
|
||||
{
|
||||
pptr = grub_strrchr (grub_prefix, ')');
|
||||
if (pptr)
|
||||
{
|
||||
device = grub_strndup (grub_prefix + 1, pptr - grub_prefix - 1);
|
||||
pptr++;
|
||||
}
|
||||
}
|
||||
if (!pptr)
|
||||
pptr = grub_prefix;
|
||||
if (pptr[0])
|
||||
path = grub_strdup (pptr);
|
||||
}
|
||||
|
||||
if (!device || !path)
|
||||
image = grub_efi_get_loaded_image (grub_efi_image_handle);
|
||||
if (image && !device)
|
||||
device = grub_efidisk_get_device_name (image->device_handle);
|
||||
|
||||
if (image && !path)
|
||||
{
|
||||
char *device;
|
||||
char *file;
|
||||
char *p;
|
||||
|
||||
device = grub_efidisk_get_device_name (image->device_handle);
|
||||
file = grub_efi_get_filename (image->file_path);
|
||||
path = grub_efi_get_filename (image->file_path);
|
||||
|
||||
if (device && file)
|
||||
{
|
||||
char *p;
|
||||
char *prefix;
|
||||
|
||||
/* Get the directory. */
|
||||
p = grub_strrchr (file, '/');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
|
||||
prefix = grub_xasprintf ("(%s)%s", device, file);
|
||||
if (prefix)
|
||||
{
|
||||
|
||||
grub_env_set ("prefix", prefix);
|
||||
grub_free (prefix);
|
||||
}
|
||||
}
|
||||
|
||||
grub_free (device);
|
||||
grub_free (file);
|
||||
/* Get the directory. */
|
||||
p = grub_strrchr (path, '/');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
if (device && path)
|
||||
{
|
||||
char *prefix;
|
||||
|
||||
prefix = grub_xasprintf ("(%s)%s", device, path);
|
||||
if (prefix)
|
||||
{
|
||||
grub_env_set ("prefix", prefix);
|
||||
grub_free (prefix);
|
||||
}
|
||||
}
|
||||
|
||||
grub_free (device);
|
||||
grub_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -98,6 +98,10 @@ struct hd_geometry
|
|||
# include <sys/disk.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
# include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/disklabel.h> /* struct disklabel */
|
||||
|
@ -312,6 +316,138 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
static int
|
||||
device_is_mapped (const char *dev)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (dev, &st) < 0)
|
||||
return 0;
|
||||
|
||||
return dm_is_dm_major (major (st.st_rdev));
|
||||
}
|
||||
#endif /* HAVE_DEVICE_MAPPER */
|
||||
|
||||
#if defined(__linux__) || defined(__CYGWIN__) || defined(__NetBSD__)
|
||||
static grub_disk_addr_t
|
||||
find_partition_start (const char *dev)
|
||||
{
|
||||
int fd;
|
||||
# if !defined(__NetBSD__)
|
||||
struct hd_geometry hdg;
|
||||
# else /* defined(__NetBSD__) */
|
||||
struct disklabel label;
|
||||
int index;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
# ifdef HAVE_DEVICE_MAPPER
|
||||
if (device_is_mapped (dev)) {
|
||||
struct dm_task *task = NULL;
|
||||
grub_uint64_t start, length;
|
||||
char *target_type, *params, *space;
|
||||
grub_disk_addr_t partition_start;
|
||||
|
||||
/* If any device-mapper operation fails, we fall back silently to
|
||||
HDIO_GETGEO. */
|
||||
task = dm_task_create (DM_DEVICE_TABLE);
|
||||
if (! task)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_task_create failed\n");
|
||||
goto devmapper_fail;
|
||||
}
|
||||
|
||||
if (! dm_task_set_name (task, dev))
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_task_set_name failed\n");
|
||||
goto devmapper_fail;
|
||||
}
|
||||
|
||||
if (! dm_task_run (task))
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_task_run failed\n");
|
||||
goto devmapper_fail;
|
||||
}
|
||||
|
||||
dm_get_next_target (task, NULL, &start, &length, &target_type, ¶ms);
|
||||
if (! target_type)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "no dm target\n");
|
||||
goto devmapper_fail;
|
||||
}
|
||||
if (strcmp (target_type, "linear") != 0)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "ignoring dm target %s (not linear)\n",
|
||||
target_type);
|
||||
goto devmapper_fail;
|
||||
}
|
||||
if (! params)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "no dm params\n");
|
||||
goto devmapper_fail;
|
||||
}
|
||||
|
||||
/* The params string for a linear target looks like this:
|
||||
DEVICE-NAME START-SECTOR
|
||||
Parse this out. */
|
||||
space = strchr (params, ' ');
|
||||
if (! space)
|
||||
goto devmapper_fail;
|
||||
errno = 0;
|
||||
partition_start = strtoull (space + 1, NULL, 10);
|
||||
if (errno == 0)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm %s starts at %llu\n",
|
||||
dev, (unsigned long long) partition_start);
|
||||
dm_task_destroy (task);
|
||||
return partition_start;
|
||||
}
|
||||
|
||||
devmapper_fail:
|
||||
if (task)
|
||||
dm_task_destroy (task);
|
||||
}
|
||||
# endif /* HAVE_DEVICE_MAPPER */
|
||||
|
||||
fd = open (dev, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot open `%s' while attempting to get disk geometry", dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
# else /* defined(__NetBSD__) */
|
||||
configure_device_driver (fd);
|
||||
if (ioctl (fd, DIOCGDINFO, &label) == -1)
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot get disk geometry of `%s'", dev);
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
return hdg.start;
|
||||
# else /* defined(__NetBSD__) */
|
||||
index = dev[strlen(dev) - 1] - 'a';
|
||||
|
||||
if (index >= label.d_npartitions)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"no disk label entry for `%s'", dev);
|
||||
return 0;
|
||||
}
|
||||
return (grub_disk_addr_t) label.d_partitions[index].p_offset;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
}
|
||||
#endif /* __linux__ || __CYGWIN__ */
|
||||
|
||||
#ifdef __linux__
|
||||
/* Cache of partition start sectors for each disk. */
|
||||
struct linux_partition_cache
|
||||
|
@ -365,28 +501,26 @@ linux_find_partition (char *dev, unsigned long sector)
|
|||
for (i = 1; i < 10000; i++)
|
||||
{
|
||||
int fd;
|
||||
struct hd_geometry hdg;
|
||||
grub_disk_addr_t start;
|
||||
|
||||
sprintf (p, format, i);
|
||||
|
||||
fd = open (real_dev, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
|
||||
if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
{
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
if (hdg.start == sector)
|
||||
start = find_partition_start (real_dev);
|
||||
/* We don't care about errors here. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
if (start == sector)
|
||||
{
|
||||
struct linux_partition_cache *new_cache_item;
|
||||
|
||||
new_cache_item = xmalloc (sizeof *new_cache_item);
|
||||
new_cache_item->dev = xstrdup (dev);
|
||||
new_cache_item->start = hdg.start;
|
||||
new_cache_item->start = start;
|
||||
new_cache_item->partno = i;
|
||||
grub_list_push (GRUB_AS_LIST_P (&linux_partition_cache_list),
|
||||
GRUB_AS_LIST (new_cache_item));
|
||||
|
@ -877,7 +1011,7 @@ make_device_name (int drive, int dos_part, int bsd_part)
|
|||
}
|
||||
|
||||
static char *
|
||||
convert_system_partition_to_system_disk (const char *os_dev)
|
||||
convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
char *path = xmalloc (PATH_MAX);
|
||||
|
@ -995,6 +1129,96 @@ convert_system_partition_to_system_disk (const char *os_dev)
|
|||
p[4] = '\0';
|
||||
return path;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
/* If this is a DM-RAID device. */
|
||||
if ((strncmp ("mapper/", p, 7) == 0))
|
||||
{
|
||||
static struct dm_tree *tree = NULL;
|
||||
uint32_t maj, min;
|
||||
struct dm_tree_node *node, *child;
|
||||
void *handle;
|
||||
const char *node_uuid, *mapper_name, *child_uuid, *child_name;
|
||||
|
||||
if (! tree)
|
||||
tree = dm_tree_create ();
|
||||
|
||||
if (! tree)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_tree_create failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
maj = major (st->st_rdev);
|
||||
min = minor (st->st_rdev);
|
||||
if (! dm_tree_add_dev (tree, maj, min))
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node = dm_tree_find_node (tree, maj, min);
|
||||
if (! node)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "dm_tree_find_node failed\n");
|
||||
return NULL;
|
||||
}
|
||||
node_uuid = dm_tree_node_get_uuid (node);
|
||||
if (! node_uuid)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s has no DM uuid\n", path);
|
||||
return NULL;
|
||||
}
|
||||
else if (strncmp (node_uuid, "DMRAID-", 7) != 0)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s is not DM-RAID\n", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = NULL;
|
||||
mapper_name = NULL;
|
||||
/* Counter-intuitively, device-mapper refers to the disk-like
|
||||
device containing a DM-RAID partition device as a "child" of
|
||||
the partition device. */
|
||||
child = dm_tree_next_child (&handle, node, 0);
|
||||
if (! child)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s has no DM children\n", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
child_uuid = dm_tree_node_get_uuid (child);
|
||||
if (! child_uuid)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s child has no DM uuid\n", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
else if (strncmp (child_uuid, "DMRAID-", 7) != 0)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s child is not DM-RAID\n", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
child_name = dm_tree_node_get_name (child);
|
||||
if (! child_name)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s child has no DM name\n", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
mapper_name = child_name;
|
||||
|
||||
devmapper_out:
|
||||
if (! mapper_name)
|
||||
{
|
||||
/* This is a DM-RAID disk, not a partition. */
|
||||
mapper_name = dm_tree_node_get_name (node);
|
||||
if (! mapper_name)
|
||||
{
|
||||
grub_dprintf ("hostdisk", "%s has no DM name\n", path);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return xasprintf ("/dev/mapper/%s", mapper_name);
|
||||
}
|
||||
#endif /* HAVE_DEVICE_MAPPER */
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -1091,12 +1315,12 @@ device_is_wholedisk (const char *os_dev)
|
|||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
static int
|
||||
find_system_device (const char *os_dev)
|
||||
find_system_device (const char *os_dev, struct stat *st)
|
||||
{
|
||||
unsigned int i;
|
||||
char *os_disk;
|
||||
|
||||
os_disk = convert_system_partition_to_system_disk (os_dev);
|
||||
os_disk = convert_system_partition_to_system_disk (os_dev, st);
|
||||
if (! os_disk)
|
||||
return -1;
|
||||
|
||||
|
@ -1130,7 +1354,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
drive = find_system_device (os_dev);
|
||||
drive = find_system_device (os_dev, &st);
|
||||
if (drive < 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
|
@ -1138,8 +1362,8 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (grub_strcmp (os_dev, convert_system_partition_to_system_disk (os_dev))
|
||||
== 0)
|
||||
if (grub_strcmp (os_dev,
|
||||
convert_system_partition_to_system_disk (os_dev, &st)) == 0)
|
||||
return make_device_name (drive, -1, -1);
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
|
@ -1164,15 +1388,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
{
|
||||
char *name;
|
||||
grub_disk_t disk;
|
||||
int fd;
|
||||
# if !defined(__NetBSD__)
|
||||
struct hd_geometry hdg;
|
||||
typeof (hdg.start) p_offset;
|
||||
# else /* defined(__NetBSD__) */
|
||||
struct disklabel label;
|
||||
int index;
|
||||
u_int32_t p_offset;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
grub_disk_addr_t start;
|
||||
int dos_part = -1;
|
||||
int bsd_part = -1;
|
||||
auto int find_partition (grub_disk_t dsk,
|
||||
|
@ -1187,7 +1403,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
|
||||
part_start = grub_partition_get_start (partition);
|
||||
|
||||
if (p_offset == part_start)
|
||||
if (start == part_start)
|
||||
{
|
||||
if (partition->parent)
|
||||
{
|
||||
|
@ -1215,49 +1431,18 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
/* Since os_dev and convert_system_partition_to_system_disk (os_dev) are
|
||||
* different, we know that os_dev is of the form /dev/r[wsc]d[0-9]+[a-z]
|
||||
* and in particular it cannot be a floppy device. */
|
||||
index = os_dev[strlen(os_dev) - 1] - 'a';
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
fd = open (os_dev, O_RDONLY);
|
||||
if (fd == -1)
|
||||
start = find_partition_start (os_dev);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' while attempting to get disk geometry", os_dev);
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
if (ioctl (fd, HDIO_GETGEO, &hdg))
|
||||
# else /* defined(__NetBSD__) */
|
||||
configure_device_driver (fd);
|
||||
if (ioctl (fd, DIOCGDINFO, &label) == -1)
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot get disk geometry of `%s'", os_dev);
|
||||
close (fd);
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
grub_util_info ("%s starts from %lu", os_dev, start);
|
||||
|
||||
close (fd);
|
||||
|
||||
# if !defined(__NetBSD__)
|
||||
p_offset = hdg.start;
|
||||
# else /* defined(__NetBSD__) */
|
||||
if (index >= label.d_npartitions)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"no disk label entry for `%s'", os_dev);
|
||||
free (name);
|
||||
return 0;
|
||||
}
|
||||
p_offset = label.d_partitions[index].p_offset;
|
||||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
grub_util_info ("%s starts from %lu", os_dev, p_offset);
|
||||
|
||||
if (p_offset == 0 && device_is_wholedisk (os_dev))
|
||||
if (start == 0 && device_is_wholedisk (os_dev))
|
||||
return name;
|
||||
|
||||
grub_util_info ("opening the device %s", name);
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/err.h>
|
||||
|
@ -176,6 +179,19 @@ grub_get_rtc (void)
|
|||
* GRUB_TICKS_PER_SECOND / 1000000));
|
||||
}
|
||||
|
||||
char *
|
||||
canonicalize_file_name (const char *path)
|
||||
{
|
||||
char *ret;
|
||||
#ifdef PATH_MAX
|
||||
ret = xmalloc (PATH_MAX);
|
||||
(void) realpath (path, ret);
|
||||
#else
|
||||
ret = realpath (path, NULL);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Convert POSIX path to Win32 path,
|
||||
remove drive letter, replace backslashes. */
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/dl.h>
|
||||
|
@ -33,8 +32,10 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/cpu/tsc.h>
|
||||
#ifdef GRUB_MACHINE_QEMU
|
||||
#include <grub/machine/kernel.h>
|
||||
#endif
|
||||
|
||||
#define GRUB_FLOPPY_REG_DIGITAL_OUTPUT 0x3f2
|
||||
|
||||
|
@ -146,6 +147,6 @@ grub_arch_modules_addr (void)
|
|||
#ifdef GRUB_MACHINE_QEMU
|
||||
return grub_core_entry_addr + grub_kernel_image_size;
|
||||
#else
|
||||
return ALIGN_UP((grub_addr_t) _end, GRUB_MOD_ALIGN);
|
||||
return ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <multiboot.h>
|
||||
#include <multiboot2.h>
|
||||
|
||||
|
@ -42,7 +42,7 @@ _start:
|
|||
* This is a special data area at a fixed offset from the beginning.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||
|
||||
VARIABLE(grub_prefix)
|
||||
/* to be filled by grub-mkimage */
|
||||
|
@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
|
|||
* Leave some breathing room for the prefix.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
||||
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||
|
||||
/*
|
||||
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <multiboot.h>
|
||||
#include <multiboot2.h>
|
||||
|
||||
|
@ -43,7 +42,7 @@ _start:
|
|||
* This is a special data area at a fixed offset from the beginning.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||
|
||||
VARIABLE(grub_prefix)
|
||||
/* to be filled by grub-mkimage */
|
||||
|
@ -52,7 +51,7 @@ VARIABLE(grub_prefix)
|
|||
* Leave some breathing room for the prefix.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
||||
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||
|
||||
codestart:
|
||||
movl %eax, EXT_C(grub_ieee1275_entry_fn)
|
||||
|
|
|
@ -75,8 +75,8 @@ make_install_device (void)
|
|||
ptr += grub_strlen (ptr);
|
||||
|
||||
if (grub_install_bsd_part >= 0)
|
||||
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ",%c",
|
||||
grub_install_bsd_part + 'a');
|
||||
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ",%u",
|
||||
grub_install_bsd_part + 1);
|
||||
ptr += grub_strlen (ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <grub/machine/memory.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
grub_err_t
|
||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
||||
|
@ -28,6 +29,8 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
struct grub_machine_mmap_entry *entry
|
||||
= (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
|
||||
grub_memset (entry, 0, sizeof (entry));
|
||||
|
||||
/* Check if grub_get_mmap_entry works. */
|
||||
cont = grub_get_mmap_entry (entry, 0);
|
||||
|
||||
|
@ -43,6 +46,8 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
if (! cont)
|
||||
break;
|
||||
|
||||
grub_memset (entry, 0, sizeof (entry));
|
||||
|
||||
cont = grub_get_mmap_entry (entry, cont);
|
||||
}
|
||||
while (entry->size);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
_start:
|
||||
jmp codestart
|
||||
|
||||
. = _start + GRUB_KERNEL_MACHINE_CORE_ENTRY_ADDR
|
||||
. = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
|
||||
VARIABLE(grub_core_entry_addr)
|
||||
.long 0
|
||||
VARIABLE(grub_kernel_image_size)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <grub/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
int (*grub_ieee1275_entry_fn) (void *);
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/ieee1275/ofdisk.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
/* The minimal heap size we can live with. */
|
||||
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
|
||||
|
@ -295,5 +294,5 @@ grub_get_rtc (void)
|
|||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return ALIGN_UP((grub_addr_t) _end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
|
||||
return ALIGN_UP((grub_addr_t) _end + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
enum grub_ieee1275_parse_type
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/mips/kernel.h>
|
||||
|
||||
void
|
||||
grub_machine_set_prefix (void)
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
#define BASE_ADDR 8
|
||||
|
||||
|
@ -32,13 +33,13 @@ _start:
|
|||
start:
|
||||
bal codestart
|
||||
base:
|
||||
. = _start + GRUB_KERNEL_CPU_COMPRESSED_SIZE
|
||||
. = _start + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
||||
compressed_size:
|
||||
.long 0
|
||||
. = _start + GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE
|
||||
. = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
total_module_size:
|
||||
.long 0
|
||||
. = _start + GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE
|
||||
. = _start + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE
|
||||
kernel_image_size:
|
||||
.long 0
|
||||
codestart:
|
||||
|
@ -105,10 +106,10 @@ argdone:
|
|||
#endif
|
||||
|
||||
/* Decompress the payload. */
|
||||
addiu $a0, $s0, GRUB_KERNEL_CPU_RAW_SIZE - BASE_ADDR
|
||||
addiu $a0, $s0, GRUB_KERNEL_MACHINE_RAW_SIZE - BASE_ADDR
|
||||
lui $a1, %hi(compressed)
|
||||
addiu $a1, %lo(compressed)
|
||||
lw $a2, (GRUB_KERNEL_CPU_COMPRESSED_SIZE - BASE_ADDR)($s0)
|
||||
lw $a2, (GRUB_KERNEL_MACHINE_COMPRESSED_SIZE - BASE_ADDR)($s0)
|
||||
move $s1, $a1
|
||||
|
||||
/* $a0 contains source compressed address, $a1 is destination,
|
||||
|
@ -134,9 +135,9 @@ reloccont:
|
|||
addiu $t1, %lo(cont)
|
||||
|
||||
jr $t1
|
||||
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
|
||||
. = _start + GRUB_KERNEL_MACHINE_RAW_SIZE
|
||||
compressed:
|
||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||
|
||||
VARIABLE(grub_prefix)
|
||||
|
||||
|
@ -146,7 +147,7 @@ VARIABLE(grub_prefix)
|
|||
* Leave some breathing room for the prefix.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
||||
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
VARIABLE (grub_arch_busclock)
|
||||
.long 0
|
||||
|
@ -171,17 +172,17 @@ cont:
|
|||
/* Move the modules out of BSS. */
|
||||
lui $t1, %hi(_start)
|
||||
addiu $t1, %lo(_start)
|
||||
lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($s0)
|
||||
lw $t2, (GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE - BASE_ADDR)($s0)
|
||||
addu $t2, $t1, $t2
|
||||
|
||||
lui $t1, %hi(_end)
|
||||
addiu $t1, %lo(_end)
|
||||
addiu $t1, (GRUB_MOD_ALIGN-1)
|
||||
li $t3, (GRUB_MOD_ALIGN-1)
|
||||
addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1)
|
||||
li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1)
|
||||
nor $t3, $t3, $0
|
||||
and $t1, $t1, $t3
|
||||
|
||||
lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
|
||||
lw $t3, (GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
|
||||
|
||||
/* Backward copy. */
|
||||
add $t1, $t1, $t3
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
|
||||
extern void grub_video_sm712_init (void);
|
||||
extern void grub_video_init (void);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
.extern __bss_start
|
||||
.extern _end
|
||||
|
@ -30,7 +30,7 @@ start:
|
|||
_start:
|
||||
b codestart
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||
|
||||
VARIABLE(grub_prefix)
|
||||
/* to be filled by grub-mkelfimage */
|
||||
|
@ -39,7 +39,7 @@ VARIABLE(grub_prefix)
|
|||
* Leave some breathing room for the prefix.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
||||
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||
|
||||
codestart:
|
||||
li 2, 0
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
.text
|
||||
.align 4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue