Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/21536
Change subject: arch/x86: Add ebda read/write functions into EBDA library ......................................................................
arch/x86: Add ebda read/write functions into EBDA library
This patch provides new APIs to write into EBDA area and read from EBDA area based on user input structure.
Change-Id: I26d5c0ba82c842f0b734a8e0f03abf148737c5c4 Signed-off-by: Subrata Banik subrata.banik@intel.com --- M src/arch/x86/ebda.c M src/arch/x86/include/arch/ebda.h 2 files changed, 67 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/21536/1
diff --git a/src/arch/x86/ebda.c b/src/arch/x86/ebda.c index c828aa4..61db30e 100644 --- a/src/arch/x86/ebda.c +++ b/src/arch/x86/ebda.c @@ -20,6 +20,58 @@ #include <arch/ebda.h> #include <arch/acpi.h> #include <commonlib/endian.h> +#include <console/console.h> + +static void *get_ebda_start(void) +{ + return (void *)((uintptr_t)DEFAULT_EBDA_SEGMENT << 4); +} + +/* + * EBDA area is representing a 1KB memory area just below + * the top of conventional memory (below 1MB) + */ + +/* + * write_ebda_data is a wrapper function to write into EBDA area + * in DWORD mode. + * + * data = data to be written into EBDA area + * length = input data size in bytes + */ +void write_ebda_data(void *data, size_t length) +{ + void *ebda; + int count = 0; + + if (length > DEFAULT_EBDA_SIZE) + die("Input data width is more than EBDA size!"); + + ebda = get_ebda_start(); + + while (count < length) { + write_le32(ebda, *((uint32_t *)(data + count))); + count += sizeof(uint32_t); + ebda += sizeof(uint32_t); + } +} + +/* + * read_ebda_data is a wrapper function to read from EBDA area + * + * return data read from EBDA area + */ +void *read_ebda_data(size_t length) +{ + void *ebda; + static void *data; + + ebda = get_ebda_start(); + + memcpy(data, ebda, length); + + return data; +}
void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size) { @@ -36,7 +88,7 @@
low_memory_kb = low_memory_size >> 10; ebda_kb = ebda_size >> 10; - ebda = (void *)((uintptr_t)ebda_segment << 4); + ebda = get_ebda_start();
/* clear BIOS DATA AREA */ zero_n(X86_BDA_BASE, X86_BDA_SIZE); diff --git a/src/arch/x86/include/arch/ebda.h b/src/arch/x86/include/arch/ebda.h index 428bc92..7e2e4fa 100644 --- a/src/arch/x86/include/arch/ebda.h +++ b/src/arch/x86/include/arch/ebda.h @@ -31,5 +31,19 @@
void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size); void setup_default_ebda(void); +/* + * write_ebda_data is a wrapper function to write into EBDA area + * in DWORD mode. + * + * data = data to be written into EBDA area + * length = input data size in bytes + */ +void write_ebda_data(void *data, size_t length); +/* + * read_ebda_data is a wrapper function to read from EBDA area + * + * return data read from EBDA area + */ +void *read_ebda_data(size_t length);
#endif