41 #define SMAP ( 0x534d4150 ) 55 #define E820_TYPE_RAM 1 56 #define E820_TYPE_RESERVED 2 57 #define E820_TYPE_ACPI 3 58 #define E820_TYPE_NVS 4 60 #define E820_ATTR_ENABLED 0x00000001UL 61 #define E820_ATTR_NONVOLATILE 0x00000002UL 62 #define E820_ATTR_UNKNOWN 0xfffffffcUL 64 #define E820_MIN_SIZE 20 68 #define e820buf __use_data16 ( e820buf ) 72 #define memmap_post __use_data16 ( memmap_post ) 80 uint16_t extmem_1m_to_16m_k, extmem_16m_plus_64k;
81 uint16_t confmem_1m_to_16m_k, confmem_16m_plus_64k;
87 DBG (
"INT 15,e801 not available during POST\n" );
96 "=a" ( extmem_1m_to_16m_k ),
97 "=b" ( extmem_16m_plus_64k ),
98 "=c" ( confmem_1m_to_16m_k ),
99 "=d" ( confmem_16m_plus_64k )
103 DBG (
"INT 15,e801 failed with CF set\n" );
107 if ( ! ( extmem_1m_to_16m_k | extmem_16m_plus_64k ) ) {
108 DBG (
"INT 15,e801 extmem=0, using confmem\n" );
109 extmem_1m_to_16m_k = confmem_1m_to_16m_k;
110 extmem_16m_plus_64k = confmem_16m_plus_64k;
113 extmem = ( extmem_1m_to_16m_k + ( extmem_16m_plus_64k * 64 ) );
114 DBG (
"INT 15,e801 extended memory size %d+64*%d=%d kB " 115 "[100000,%llx)\n", extmem_1m_to_16m_k, extmem_16m_plus_64k,
116 extmem, ( 0x100000 + ( ( (
uint64_t ) extmem ) * 1024 ) ) );
123 if ( extmem == ( 0x400000 - 0x400 ) ) {
124 DBG (
"INT 15,e801 reported whole 4GB; assuming insane\n" );
141 :
"=a" ( extmem ) :
"a" ( 0x8800 ) );
143 DBG (
"INT 15,88 extended memory size %d kB [100000, %x)\n",
144 extmem, ( 0x100000 + ( extmem * 1024 ) ) );
157 unsigned int extmem_e801;
158 unsigned int extmem_88;
163 return ( extmem_e801 ? extmem_e801 : extmem_88 );
183 DBG (
"INT 15,e820 not available during POST\n" );
204 :
"=a" ( smap ),
"=b" (
next ),
207 :
"a" ( 0xe820 ),
"b" (
next ),
213 if ( smap !=
SMAP ) {
214 DBG (
"INT 15,e820 failed SMAP signature check\n" );
219 DBG (
"INT 15,e820 returned only %d bytes\n",
size );
224 DBG (
"INT 15,e820 terminated on CF set\n" );
229 if ( ( memmap->
count == 0 ) &&
231 DBG (
"INT 15,e820 failed, first entry not RAM\n" );
235 DBG (
"INT 15,e820 region [%llx,%llx) type %d",
240 ?
"enabled" :
"disabled" ) );
242 DBG (
", non-volatile" );
265 if ( prev_region && ( region->
start == prev_region->
end ) ) {
266 prev_region->
end = region->
end;
268 prev_region = region;
274 sizeof ( memmap->
regions[0] ) ) ) {
275 DBG (
"INT 15,e820 too many regions returned\n" );
282 }
while (
next != 0 );
290 if ( memmap->
count < 2 ) {
291 DBG (
"INT 15,e820 returned only %d regions; assuming " 292 "insane\n", memmap->
count );
296 DBG (
"INT 15,e820 region 0 starts at %llx (expected 0); " 301 DBG (
"INT 15,e820 region 1 starts at %llx (expected 100000); " 315 unsigned int basemem, extmem;
318 DBG (
"Fetching system memory map\n" );
321 memset ( memmap, 0,
sizeof ( *memmap ) );
325 DBG (
"FBMS base memory size %d kB [0,%x)\n",
326 basemem, ( basemem * 1024 ) );
330 if ( (
rc =
meme820 ( memmap ) ) == 0 ) {
331 DBG (
"Obtained system memory map via INT 15,e820\n" );
336 DBG (
"INT 15,e820 failed; constructing map\n" );
339 memmap->
regions[1].
end = 0x100000 + ( extmem * 1024 );
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
void get_memmap(struct memory_map *memmap)
Get memory map.
uint32_t attrs
Extended attributes (optional)
#define E820_ATTR_ENABLED
PROVIDE_IOAPI(x86, get_memmap, x86_get_memmap)
uint32_t next
Next descriptor address.
unsigned int count
Number of used regions.
static unsigned int basememsize(void)
Get size of base memory from BIOS free base memory counter.
uint8_t size
Entry size (in 32-bit words)
#define E820_ATTR_NONVOLATILE
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned long long uint64_t
#define offsetof(type, field)
Get offset of a field within a structure.
#define E820_ATTR_UNKNOWN
#define ENOTSUP
Operation not supported.
struct memory_region regions[MAX_MEMORY_REGIONS]
Memory regions.
uint64_t start
Start of region.
#define E820_TYPE_RAM
Normal memory.
void x86_get_memmap(struct memory_map *memmap)
Get memory map.
unsigned int extmemsize(void)
Get size of extended memory.
An INT 15,e820 memory map entry.
struct e820_entry __attribute__((packed))
uint64_t len
Length of region.
uint32_t attrs
Extended attributes (optional)
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
static struct e820_entry __bss16(e820buf)
Buffer for INT 15,e820 calls.
uint32_t type
Type of region.
static unsigned int extmemsize_88(void)
Get size of extended memory via INT 15,88.
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
#define ENOTTY
Inappropriate I/O control operation.
uint64_t start
Physical start address.
#define __from_data16(pointer)
typeof(acpi_finder=acpi_find)
ACPI table finder.
#define DBG(...)
Print a debugging message.
uint64_t end
Physical end address.
#define REAL_CODE(asm_code_str)
#define SMAP
Magic value for INT 15,e820 calls.
#define NULL
NULL pointer (VOID *)
static int meme820(struct memory_map *memmap)
Get e820 memory map.
void * memset(void *dest, int character, size_t len) __nonnull
static unsigned int extmemsize_e801(void)
Get size of extended memory via INT 15,e801.