mb/asus/p8z77-m: Drop GPIO by I/O
[coreboot2.git] / src / arch / x86 / ebda.c
blobf3e8fd2844f9ab192f34d9643a32dbd77e1c7757
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi.h>
4 #include <bootstate.h>
5 #include <commonlib/endian.h>
6 #include <types.h>
8 #define X86_BDA_SIZE 0x200
9 #define X86_BDA_BASE ((void *)0x400)
10 #define X86_EBDA_SEGMENT ((void *)0x40e)
11 #define X86_EBDA_LOWMEM ((void *)0x413)
13 static void *get_ebda_start(void)
15 return (void *)((uintptr_t)CONFIG_DEFAULT_EBDA_SEGMENT << 4);
19 * EBDA area is representing a 1KB memory area just below
20 * the top of conventional memory (below 1MB)
23 static void setup_ebda(u32 low_memory_size, u16 ebda_segment, u16 ebda_size)
25 u16 low_memory_kb;
26 u16 ebda_kb;
27 void *ebda;
29 if (!low_memory_size || !ebda_segment || !ebda_size)
30 return;
32 low_memory_kb = low_memory_size >> 10;
33 ebda_kb = ebda_size >> 10;
34 ebda = get_ebda_start();
36 /* clear BIOS DATA AREA */
37 zero_n(X86_BDA_BASE, X86_BDA_SIZE);
39 /* Avoid unaligned write16() since it's undefined behavior */
40 write_le16(X86_EBDA_LOWMEM, low_memory_kb);
41 write_le16(X86_EBDA_SEGMENT, ebda_segment);
43 /* Set up EBDA */
44 zero_n(ebda, ebda_size);
45 write_le16(ebda, ebda_kb);
48 static void setup_default_ebda(void *unused)
50 if (acpi_is_wakeup_s3())
51 return;
53 setup_ebda(CONFIG_DEFAULT_EBDA_LOWMEM,
54 CONFIG_DEFAULT_EBDA_SEGMENT,
55 CONFIG_DEFAULT_EBDA_SIZE);
58 /* Ensure EBDA is prepared before Option ROMs. */
59 BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, setup_default_ebda, NULL);