summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorRyan Salsamendi <rsalsamendi@hotmail.com>2017-06-16 13:15:31 -0700
committerMartin Roth <martinroth@google.com>2017-06-20 03:13:18 +0200
commitf511c1f11895397606be103823fd3a33c6e92811 (patch)
tree6a7b16ed03e950fa04100f6a857f1488289bea36 /src/arch
parent927f06a565dcbf973739e2c91cc1ea2814338609 (diff)
arch/x86/ebda: Change memcpy() to endian wrappers
Change memcpy()s and memset()s to endian.h wrappers for consistency and safety. Add zero_n() wrapper to safely clear memory. Change-Id: If155d82608c81992f05eae4d2223de6f506e98c5 Signed-off-by: Ryan Salsamendi <rsalsamendi@hotmail.com> Reviewed-on: https://review.coreboot.org/20240 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/ebda.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/arch/x86/ebda.c b/src/arch/x86/ebda.c
index b5dfb413ae..c828aa4f76 100644
--- a/src/arch/x86/ebda.c
+++ b/src/arch/x86/ebda.c
@@ -19,6 +19,7 @@
#include <arch/io.h>
#include <arch/ebda.h>
#include <arch/acpi.h>
+#include <commonlib/endian.h>
void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size)
{
@@ -38,15 +39,15 @@ void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size)
ebda = (void *)((uintptr_t)ebda_segment << 4);
/* clear BIOS DATA AREA */
- memset(X86_BDA_BASE, 0, X86_BDA_SIZE);
+ zero_n(X86_BDA_BASE, X86_BDA_SIZE);
/* Avoid unaligned write16() since it's undefined behavior */
- memcpy(X86_EBDA_LOWMEM, &low_memory_kb, sizeof(low_memory_kb));
- memcpy(X86_EBDA_SEGMENT, &ebda_segment, sizeof(ebda_segment));
+ write_le16(X86_EBDA_LOWMEM, low_memory_kb);
+ write_le16(X86_EBDA_SEGMENT, ebda_segment);
/* Set up EBDA */
- memset(ebda, 0, ebda_size);
- memcpy(ebda, &ebda_kb, sizeof(ebda_kb));
+ zero_n(ebda, ebda_size);
+ write_le16(ebda, ebda_kb);
}
void setup_default_ebda(void)