summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2012-01-18 15:44:49 -0800
committerGabe Black (Do Not Use) <gabeblack@google.com>2012-01-18 21:51:18 -0800
commit9c15747348aa2aed0c0192b6c85b65b464b448d5 (patch)
tree4e4c928cf818baa60cbd1784f1b2969ab582d2cd /lib
parent29538919a8c0206c320162c061ce2511ea86e1e6 (diff)
Introduce arch_phys_memset which works like memset but on physical memory
The default implementation of this function is just memset, but other implementations will be needed when physical memory isn't accessible by U-Boot using normal addressing mechanisms. BUG=chrome-os-partner:7579 TEST=From the original, larger patch: Built and booted on Lumpy, Stumpy, and Kaen. Looked at the log to see that the regions in high memory are listed as cleared. Artificially injected a range to "clear" with 0xA5 and then 0x5A which was over the framebuffer and covered part or all of the screen on Lumpy. Verified that the screen was partially or completely filled with an appropriate looking color. Had U-Boot print the PDTs it was generating to verify that the high address bits were preserved. Identity mapped only some of memory and verified that things that should be mapped were accessible and things that shouldn't be weren't. Signed-off-by: Gabe Black <gabeblack@google.com> Change-Id: Ie1ba5bbb8ee2847f450d0057611deee397c316cf Reviewed-on: https://gerrit.chromium.org/gerrit/14417 Reviewed-by: 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/Makefile1
-rw-r--r--lib/physmem.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/Makefile b/lib/Makefile
index afa6914e1be..68b4828df38 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -45,6 +45,7 @@ COBJS-$(CONFIG_LMB) += lmb.o
COBJS-y += ldiv.o
COBJS-$(CONFIG_MD5) += md5.o
COBJS-y += net_utils.o
+COBJS-y += physmem.o
COBJS-y += qsort.o
COBJS-$(CONFIG_SHA1) += sha1.o
COBJS-$(CONFIG_SHA256) += sha256.o
diff --git a/lib/physmem.c b/lib/physmem.c
new file mode 100644
index 00000000000..0f035edcbe5
--- /dev/null
+++ b/lib/physmem.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ */
+
+#include <common.h>
+#include <physmem.h>
+
+static phys_addr_t __arch_phys_memset(phys_addr_t s, int c, phys_size_t n)
+{
+ void *s_ptr = (void *)(uintptr_t)s;
+
+ assert(((phys_addr_t)(uintptr_t)s) == s);
+ assert(((phys_addr_t)(uintptr_t)(s + n)) == s + n);
+ return (phys_addr_t)(uintptr_t)memset(s_ptr, c, n);
+}
+
+phys_addr_t arch_phys_memset(phys_addr_t s, int c, phys_size_t n)
+ __attribute__((weak, alias("__arch_phys_memset")));