1 /* SPDX-License-Identifier: GPL-2.0-only */
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
)
24 if (!low_memory_size
|| !ebda_segment
|| !ebda_size
)
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
);
39 zero_n(ebda
, ebda_size
);
40 write_le16(ebda
, ebda_kb
);
43 void setup_default_ebda(void)
45 if (acpi_is_wakeup_s3())
48 setup_ebda(DEFAULT_EBDA_LOWMEM
,