#include <linux/kernel.h>1#include <linux/init.h>2#include <linux/memblock.h>34#include <asm/setup.h>5#include <asm/bios_ebda.h>67#define BIOS_LOWMEM_KILOBYTES 0x41389/*10* The BIOS places the EBDA/XBDA at the top of conventional11* memory, and usually decreases the reported amount of12* conventional memory (int 0x12) too. This also contains a13* workaround for Dell systems that neglect to reserve EBDA.14* The same workaround also avoids a problem with the AMD768MPX15* chipset: reserve a page before VGA to prevent PCI prefetch16* into it (errata #56). Usually the page is reserved anyways,17* unless you have no PS/2 mouse plugged in.18*/19void __init reserve_ebda_region(void)20{21unsigned int lowmem, ebda_addr;2223/* To determine the position of the EBDA and the */24/* end of conventional memory, we need to look at */25/* the BIOS data area. In a paravirtual environment */26/* that area is absent. We'll just have to assume */27/* that the paravirt case can handle memory setup */28/* correctly, without our help. */29if (paravirt_enabled())30return;3132/* end of low (conventional) memory */33lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);34lowmem <<= 10;3536/* start of EBDA area */37ebda_addr = get_bios_ebda();3839/* Fixup: bios puts an EBDA in the top 64K segment */40/* of conventional memory, but does not adjust lowmem. */41if ((lowmem - ebda_addr) <= 0x10000)42lowmem = ebda_addr;4344/* Fixup: bios does not report an EBDA at all. */45/* Some old Dells seem to need 4k anyhow (bugzilla 2990) */46if ((ebda_addr == 0) && (lowmem >= 0x9f000))47lowmem = 0x9f000;4849/* Paranoia: should never happen, but... */50if ((lowmem == 0) || (lowmem >= 0x100000))51lowmem = 0x9f000;5253/* reserve all memory between lowmem and the 1MB mark */54memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved");55}565758