summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2012-01-12 23:21:36 -0800
committerGerrit <chrome-bot@google.com>2012-01-13 20:11:57 -0800
commit3b736f1c94547ea5afe5b13d4ad6f7565d1a9c24 (patch)
treeac15ce93aefad1566ddf27f9647e0183ca6613f3 /lib
parentbbc467e64948383146c3b230798acb37d9e39929 (diff)
Make the memory wipe code handle 64 bit addresses properly
When telling the memory wipe infrastructure about regions it should and shouldn't wipe, some of those addresses may be 64 bits on x86. This change makes the infrastructure pass around those addresses intact instead of truncating them, and then simply ignore the regions that are unaddressable by U-Boot. BUG=None TEST=Built and booted on Lumpy. Built on Kaen Signed-off-by: Gabe Black <gabeblack@google.com> Change-Id: I657cd5480ca9a33614b032bf2a727d1a74d38b48 Reviewed-on: https://gerrit.chromium.org/gerrit/14149 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Ready: Gabe Black (Do Not Use) <gabeblack@google.com> Tested-by: Gabe Black (Do Not Use) <gabeblack@google.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/chromeos/memory_wipe.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/chromeos/memory_wipe.c b/lib/chromeos/memory_wipe.c
index f8476b35ab..7823ece031 100644
--- a/lib/chromeos/memory_wipe.c
+++ b/lib/chromeos/memory_wipe.c
@@ -28,7 +28,7 @@
*/
static void memory_wipe_insert_between(memory_wipe_edge_t *before,
- memory_wipe_edge_t *after, uintptr_t pos)
+ memory_wipe_edge_t *after, phys_addr_t pos)
{
memory_wipe_edge_t *new_edge =
(memory_wipe_edge_t *)malloc(sizeof(*new_edge));
@@ -48,7 +48,7 @@ void memory_wipe_init(memory_wipe_t *wipe)
}
static void memory_wipe_set_region_to(memory_wipe_t *wipe_info,
- uintptr_t start, uintptr_t end, int new_wiped)
+ phys_addr_t start, phys_addr_t end, int new_wiped)
{
/* whether the current region was originally going to be wiped. */
int wipe = 0;
@@ -97,13 +97,13 @@ static void memory_wipe_set_region_to(memory_wipe_t *wipe_info,
}
/* Set a region to "wiped". */
-void memory_wipe_add(memory_wipe_t *wipe, uintptr_t start, uintptr_t end)
+void memory_wipe_add(memory_wipe_t *wipe, phys_addr_t start, phys_addr_t end)
{
memory_wipe_set_region_to(wipe, start, end, 1);
}
/* Set a region to "not wiped". */
-void memory_wipe_sub(memory_wipe_t *wipe, uintptr_t start, uintptr_t end)
+void memory_wipe_sub(memory_wipe_t *wipe, phys_addr_t start, phys_addr_t end)
{
memory_wipe_set_region_to(wipe, start, end, 0);
}
@@ -112,10 +112,11 @@ void memory_wipe_sub(memory_wipe_t *wipe, uintptr_t start, uintptr_t end)
void memory_wipe_execute(memory_wipe_t *wipe)
{
memory_wipe_edge_t *cur;
+ const phys_addr_t max_addr = (phys_addr_t)~(uintptr_t)0;
VBDEBUG(PREFIX "Wipe memory regions:\n");
for (cur = wipe->head.next; cur; cur = cur->next->next) {
- uintptr_t start, end;
+ phys_addr_t start, end;
if (!cur->next) {
VBDEBUG(PREFIX "Odd number of region edges!\n");
@@ -123,8 +124,12 @@ void memory_wipe_execute(memory_wipe_t *wipe)
}
start = cur->pos;
+ if ((start & max_addr) != start)
+ break;
end = cur->next->pos;
+ if ((end & max_addr) != end)
+ end = 0;
VBDEBUG(PREFIX "\t[%#08x, 0x%08x)\n", start, end);
- memset((void *)start, 0, end - start);
+ memset((void *)(uintptr_t)start, 0, end - start);
}
}