iPXE
Data Structures | Macros | Functions | Variables
fakee820.c File Reference
#include <realmode.h>
#include <biosint.h>

Go to the source code of this file.

Data Structures

struct  e820_entry
 An INT 15,e820 memory map entry. More...
 

Macros

#define real_int15_vector   __use_text16 ( real_int15_vector )
 
#define E820_TYPE_RAM   1
 Normal memory. More...
 
#define E820_TYPE_RSVD   2
 Reserved and unavailable. More...
 
#define E820_TYPE_ACPI   3
 ACPI reclaim memory. More...
 
#define E820_TYPE_NVS   4
 ACPI NVS memory. More...
 
#define e820map   __use_text16 ( e820map )
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void int15_fakee820 ()
 Assembly routine in inline asm. More...
 
static struct segoff __text16 (real_int15_vector)
 Original INT 15 handler. More...
 
struct e820_entry __attribute__ ((packed))
 
static struct e820_entry __text16_array (e820map)
 Fake e820 map. More...
 
void fake_e820 (void)
 
void unfake_e820 (void)
 

Variables

uint64_t start
 Start of region. More...
 
uint64_t len
 Length of region. More...
 
uint32_t type
 Type of region. More...
 

Macro Definition Documentation

◆ real_int15_vector

#define real_int15_vector   __use_text16 ( real_int15_vector )

Definition at line 33 of file fakee820.c.

◆ E820_TYPE_RAM

#define E820_TYPE_RAM   1

Normal memory.

Definition at line 45 of file fakee820.c.

◆ E820_TYPE_RSVD

#define E820_TYPE_RSVD   2

Reserved and unavailable.

Definition at line 46 of file fakee820.c.

◆ E820_TYPE_ACPI

#define E820_TYPE_ACPI   3

ACPI reclaim memory.

Definition at line 47 of file fakee820.c.

◆ E820_TYPE_NVS

#define E820_TYPE_NVS   4

ACPI NVS memory.

Definition at line 48 of file fakee820.c.

◆ e820map

#define e820map   __use_text16 ( e820map )

Definition at line 62 of file fakee820.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ int15_fakee820()

void int15_fakee820 ( )

Assembly routine in inline asm.

Referenced by fake_e820(), and unfake_e820().

◆ __text16()

static struct segoff __text16 ( real_int15_vector  )
static

Original INT 15 handler.

◆ __attribute__()

struct e820_entry __attribute__ ( (packed)  )

◆ __text16_array()

static struct e820_entry __text16_array ( e820map  )
static

Fake e820 map.

Definition at line 51 of file fakee820.c.

51  {
52  { 0x00000000ULL, ( 0x000a0000ULL - 0x00000000ULL ), E820_TYPE_RAM },
53  { 0x00100000ULL, ( 0xcfb50000ULL - 0x00100000ULL ), E820_TYPE_RAM },
54  { 0xcfb50000ULL, ( 0xcfb64000ULL - 0xcfb50000ULL ), E820_TYPE_RSVD },
55  { 0xcfb64000ULL, ( 0xcfb66000ULL - 0xcfb64000ULL ), E820_TYPE_RSVD },
56  { 0xcfb66000ULL, ( 0xcfb85c00ULL - 0xcfb66000ULL ), E820_TYPE_ACPI },
57  { 0xcfb85c00ULL, ( 0xd0000000ULL - 0xcfb85c00ULL ), E820_TYPE_RSVD },
58  { 0xe0000000ULL, ( 0xf0000000ULL - 0xe0000000ULL ), E820_TYPE_RSVD },
59  { 0xfe000000ULL, (0x100000000ULL - 0xfe000000ULL ), E820_TYPE_RSVD },
60  {0x100000000ULL, (0x230000000ULL -0x100000000ULL ), E820_TYPE_RAM },
61 };
#define E820_TYPE_ACPI
ACPI reclaim memory.
Definition: fakee820.c:47
#define E820_TYPE_RAM
Normal memory.
Definition: fakee820.c:45
#define E820_TYPE_RSVD
Reserved and unavailable.
Definition: fakee820.c:46

References E820_TYPE_ACPI, E820_TYPE_RAM, and E820_TYPE_RSVD.

◆ fake_e820()

void fake_e820 ( void  )

Definition at line 64 of file fakee820.c.

64  {
66  TEXT16_CODE ( "\nint15_fakee820:\n\t"
67  "pushfw\n\t"
68  "cmpl $0xe820, %%eax\n\t"
69  "jne 99f\n\t"
70  "cmpl $0x534d4150, %%edx\n\t"
71  "jne 99f\n\t"
72  "pushaw\n\t"
73  "movw %%sp, %%bp\n\t"
74  "andb $~0x01, 22(%%bp)\n\t" /* Clear return CF */
75  "leaw e820map(%%bx), %%si\n\t"
76  "cs rep movsb\n\t"
77  "popaw\n\t"
78  "movl %%edx, %%eax\n\t"
79  "addl $20, %%ebx\n\t"
80  "cmpl %0, %%ebx\n\t"
81  "jne 1f\n\t"
82  "xorl %%ebx,%%ebx\n\t"
83  "\n1:\n\t"
84  "popfw\n\t"
85  "iret\n\t"
86  "\n99:\n\t"
87  "popfw\n\t"
88  "ljmp *%%cs:real_int15_vector\n\t" )
89  : : "i" ( sizeof ( e820map ) ) );
90 
93 }
#define e820map
Definition: fakee820.c:62
unsigned long intptr_t
Definition: stdint.h:21
#define real_int15_vector
Definition: fakee820.c:33
void hook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Hook INT vector.
Definition: biosint.c:24
void int15_fakee820()
Assembly routine in inline asm.
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__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 TEXT16_CODE(asm_code_str)
Definition: libkir.h:217

References __asm__(), __volatile__(), e820map, hook_bios_interrupt(), int15_fakee820(), real_int15_vector, and TEXT16_CODE.

Referenced by hide_etherboot().

◆ unfake_e820()

void unfake_e820 ( void  )

Definition at line 95 of file fakee820.c.

95  {
98 }
unsigned long intptr_t
Definition: stdint.h:21
#define real_int15_vector
Definition: fakee820.c:33
int unhook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Unhook INT vector.
Definition: biosint.c:69
void int15_fakee820()
Assembly routine in inline asm.

References int15_fakee820(), real_int15_vector, and unhook_bios_interrupt().

Referenced by unhide_etherboot().

Variable Documentation

◆ start

uint64_t start

Start of region.

Definition at line 31 of file fakee820.c.

◆ len

uint64_t len

Length of region.

Definition at line 33 of file fakee820.c.

◆ type

uint32_t type

Type of region.

Definition at line 35 of file fakee820.c.