|
|
f96e0b |
From 617d656f2e310da90dd5d4f426cb7f7c9d7a3069 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Colin Watson <cjwatson@ubuntu.com>
|
|
|
f96e0b |
Date: Mon, 21 Jan 2013 14:41:06 +0000
|
|
|
f96e0b |
Subject: [PATCH 131/482] Fix powerpc and sparc64 build failures caused by
|
|
|
f96e0b |
un-nesting memory map iterators.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 ++++
|
|
|
f96e0b |
grub-core/loader/powerpc/ieee1275/linux.c | 41 +++++++++++++++++++++----------
|
|
|
f96e0b |
grub-core/loader/sparc64/ieee1275/linux.c | 38 +++++++++++++++++-----------
|
|
|
f96e0b |
3 files changed, 57 insertions(+), 27 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 1c3958f..04572d2 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,10 @@
|
|
|
f96e0b |
2013-01-21 Colin Watson <cjwatson@ubuntu.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ Fix powerpc and sparc64 build failures caused by un-nesting memory
|
|
|
f96e0b |
+ map iterators.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-01-21 Colin Watson <cjwatson@ubuntu.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/disk/arc/arcdisk.c (grub_arcdisk_iterate): Fix
|
|
|
f96e0b |
parameter declarations.
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
|
|
|
f96e0b |
index b150904..c977941 100644
|
|
|
f96e0b |
--- a/grub-core/loader/powerpc/ieee1275/linux.c
|
|
|
f96e0b |
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
|
|
|
f96e0b |
@@ -51,37 +51,47 @@ static char *linux_args;
|
|
|
f96e0b |
typedef void (*kernel_entry_t) (void *, unsigned long, int (void *),
|
|
|
f96e0b |
unsigned long, unsigned long);
|
|
|
f96e0b |
|
|
|
f96e0b |
+/* Context for grub_linux_claimmap_iterate. */
|
|
|
f96e0b |
+struct grub_linux_claimmap_iterate_ctx
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_addr_t target;
|
|
|
f96e0b |
+ grub_size_t size;
|
|
|
f96e0b |
+ grub_size_t align;
|
|
|
f96e0b |
+ grub_addr_t found_addr;
|
|
|
f96e0b |
+};
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* Helper for grub_linux_claimmap_iterate. */
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
alloc_mem (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
|
|
|
f96e0b |
void *data)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_addr_t *found_addr = data;
|
|
|
f96e0b |
+ struct grub_linux_claimmap_iterate_ctx *ctx = data;
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_uint64_t end = addr + len;
|
|
|
f96e0b |
- addr = ALIGN_UP (addr, align);
|
|
|
f96e0b |
- target = ALIGN_UP (target, align);
|
|
|
f96e0b |
+ addr = ALIGN_UP (addr, ctx->align);
|
|
|
f96e0b |
+ ctx->target = ALIGN_UP (ctx->target, ctx->align);
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Target above the memory chunk. */
|
|
|
f96e0b |
- if (type != GRUB_MEMORY_AVAILABLE || target > end)
|
|
|
f96e0b |
+ if (type != GRUB_MEMORY_AVAILABLE || ctx->target > end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Target inside the memory chunk. */
|
|
|
f96e0b |
- if (target >= addr && target < end && size <= end - target)
|
|
|
f96e0b |
+ if (ctx->target >= addr && ctx->target < end &&
|
|
|
f96e0b |
+ ctx->size <= end - ctx->target)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- if (grub_claimmap (target, size) == GRUB_ERR_NONE)
|
|
|
f96e0b |
+ if (grub_claimmap (ctx->target, ctx->size) == GRUB_ERR_NONE)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- *found_addr = target;
|
|
|
f96e0b |
+ ctx->found_addr = ctx->target;
|
|
|
f96e0b |
return 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
grub_print_error ();
|
|
|
f96e0b |
}
|
|
|
f96e0b |
/* Target below the memory chunk. */
|
|
|
f96e0b |
- if (target < addr && addr + size <= end)
|
|
|
f96e0b |
+ if (ctx->target < addr && addr + ctx->size <= end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- if (grub_claimmap (addr, size) == GRUB_ERR_NONE)
|
|
|
f96e0b |
+ if (grub_claimmap (addr, ctx->size) == GRUB_ERR_NONE)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- *found_addr = addr;
|
|
|
f96e0b |
+ ctx->found_addr = addr;
|
|
|
f96e0b |
return 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
grub_print_error ();
|
|
|
f96e0b |
@@ -93,11 +103,16 @@ static grub_addr_t
|
|
|
f96e0b |
grub_linux_claimmap_iterate (grub_addr_t target, grub_size_t size,
|
|
|
f96e0b |
grub_size_t align)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_addr_t found_addr = (grub_addr_t) -1;
|
|
|
f96e0b |
+ struct grub_linux_claimmap_iterate_ctx ctx = {
|
|
|
f96e0b |
+ .target = target,
|
|
|
f96e0b |
+ .size = size,
|
|
|
f96e0b |
+ .align = align,
|
|
|
f96e0b |
+ .found_addr = (grub_addr_t) -1
|
|
|
f96e0b |
+ };
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_machine_mmap_iterate (alloc_mem, &found_addr);
|
|
|
f96e0b |
+ grub_machine_mmap_iterate (alloc_mem, &ctx;;
|
|
|
f96e0b |
|
|
|
f96e0b |
- return found_addr;
|
|
|
f96e0b |
+ return ctx.found_addr;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
|
|
|
f96e0b |
index a485284..c85fcfd 100644
|
|
|
f96e0b |
--- a/grub-core/loader/sparc64/ieee1275/linux.c
|
|
|
f96e0b |
+++ b/grub-core/loader/sparc64/ieee1275/linux.c
|
|
|
f96e0b |
@@ -180,32 +180,39 @@ grub_linux_unload (void)
|
|
|
f96e0b |
|
|
|
f96e0b |
#define FOUR_MB (4 * 1024 * 1024)
|
|
|
f96e0b |
|
|
|
f96e0b |
+/* Context for alloc_phys. */
|
|
|
f96e0b |
+struct alloc_phys_ctx
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_addr_t size;
|
|
|
f96e0b |
+ grub_addr_t ret;
|
|
|
f96e0b |
+};
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* Helper for alloc_phys. */
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
|
|
|
f96e0b |
grub_memory_type_t type, void *data)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_addr_t *ret = data;
|
|
|
f96e0b |
+ struct alloc_phys_ctx *ctx = data;
|
|
|
f96e0b |
grub_addr_t end = addr + len;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (type != 1)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
addr = ALIGN_UP (addr, FOUR_MB);
|
|
|
f96e0b |
- if (addr + size >= end)
|
|
|
f96e0b |
+ if (addr + ctx->size >= end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (addr >= grub_phys_start && addr < grub_phys_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
|
|
|
f96e0b |
- if (addr + size >= end)
|
|
|
f96e0b |
+ if (addr + ctx->size >= end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if ((addr + size) >= grub_phys_start
|
|
|
f96e0b |
- && (addr + size) < grub_phys_end)
|
|
|
f96e0b |
+ if ((addr + ctx->size) >= grub_phys_start
|
|
|
f96e0b |
+ && (addr + ctx->size) < grub_phys_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
|
|
|
f96e0b |
- if (addr + size >= end)
|
|
|
f96e0b |
+ if (addr + ctx->size >= end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -216,30 +223,33 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
|
|
|
f96e0b |
if (addr >= linux_paddr && addr < linux_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
addr = linux_end;
|
|
|
f96e0b |
- if (addr + size >= end)
|
|
|
f96e0b |
+ if (addr + ctx->size >= end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if ((addr + size) >= linux_paddr
|
|
|
f96e0b |
- && (addr + size) < linux_end)
|
|
|
f96e0b |
+ if ((addr + ctx->size) >= linux_paddr
|
|
|
f96e0b |
+ && (addr + ctx->size) < linux_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
addr = linux_end;
|
|
|
f96e0b |
- if (addr + size >= end)
|
|
|
f96e0b |
+ if (addr + ctx->size >= end)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- *ret = addr;
|
|
|
f96e0b |
+ ctx->ret = addr;
|
|
|
f96e0b |
return 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_addr_t
|
|
|
f96e0b |
alloc_phys (grub_addr_t size)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_addr_t ret = (grub_addr_t) -1;
|
|
|
f96e0b |
+ struct alloc_phys_ctx ctx = {
|
|
|
f96e0b |
+ .size = size,
|
|
|
f96e0b |
+ .ret = (grub_addr_t) -1
|
|
|
f96e0b |
+ };
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_machine_mmap_iterate (alloc_phys_choose, &ret;;
|
|
|
f96e0b |
+ grub_machine_mmap_iterate (alloc_phys_choose, &ctx;;
|
|
|
f96e0b |
|
|
|
f96e0b |
- return ret;
|
|
|
f96e0b |
+ return ctx.ret;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|