soc/intel/common/block: fix storage size of HEST log address
[coreboot.git] / src / arch / x86 / ebda.c
blob0e3465a04004cdf13e59d612c351616b2ad2144f
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <stdint.h>
4 #include <acpi/acpi.h>
5 #include <arch/ebda.h>
6 #include <commonlib/endian.h>
8 static void *get_ebda_start(void)
10 return (void *)((uintptr_t)DEFAULT_EBDA_SEGMENT << 4);
14 * EBDA area is representing a 1KB memory area just below
15 * the top of conventional memory (below 1MB)
18 static void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size)
20 u16 low_memory_kb;
21 u16 ebda_kb;
22 void *ebda;
24 if (!low_memory_size || !ebda_segment || !ebda_size)
25 return;
27 low_memory_kb = low_memory_size >> 10;
28 ebda_kb = ebda_size >> 10;
29 ebda = get_ebda_start();
31 /* clear BIOS DATA AREA */
32 zero_n(X86_BDA_BASE, X86_BDA_SIZE);
34 /* Avoid unaligned write16() since it's undefined behavior */
35 write_le16(X86_EBDA_LOWMEM, low_memory_kb);
36 write_le16(X86_EBDA_SEGMENT, ebda_segment);
38 /* Set up EBDA */
39 zero_n(ebda, ebda_size);
40 write_le16(ebda, ebda_kb);
43 void setup_default_ebda(void)
45 if (acpi_is_wakeup_s3())
46 return;
48 setup_ebda(DEFAULT_EBDA_LOWMEM,
49 DEFAULT_EBDA_SEGMENT,
50 DEFAULT_EBDA_SIZE);