fakee820.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 FILE_LICENCE ( GPL2_OR_LATER );
00019
00020 #include <realmode.h>
00021 #include <biosint.h>
00022
00023
00024 extern void int15_fakee820();
00025
00026
00027 static struct segoff __text16 ( real_int15_vector );
00028 #define real_int15_vector __use_text16 ( real_int15_vector )
00029
00030
00031 struct e820_entry {
00032
00033 uint64_t start;
00034
00035 uint64_t len;
00036
00037 uint32_t type;
00038 } __attribute__ (( packed ));
00039
00040 #define E820_TYPE_RAM 1
00041 #define E820_TYPE_RSVD 2
00042 #define E820_TYPE_ACPI 3
00043 #define E820_TYPE_NVS 4
00044
00045
00046 static struct e820_entry __text16_array ( e820map, [] ) __used = {
00047 { 0x00000000ULL, ( 0x000a0000ULL - 0x00000000ULL ), E820_TYPE_RAM },
00048 { 0x00100000ULL, ( 0xcfb50000ULL - 0x00100000ULL ), E820_TYPE_RAM },
00049 { 0xcfb50000ULL, ( 0xcfb64000ULL - 0xcfb50000ULL ), E820_TYPE_RSVD },
00050 { 0xcfb64000ULL, ( 0xcfb66000ULL - 0xcfb64000ULL ), E820_TYPE_RSVD },
00051 { 0xcfb66000ULL, ( 0xcfb85c00ULL - 0xcfb66000ULL ), E820_TYPE_ACPI },
00052 { 0xcfb85c00ULL, ( 0xd0000000ULL - 0xcfb85c00ULL ), E820_TYPE_RSVD },
00053 { 0xe0000000ULL, ( 0xf0000000ULL - 0xe0000000ULL ), E820_TYPE_RSVD },
00054 { 0xfe000000ULL, (0x100000000ULL - 0xfe000000ULL ), E820_TYPE_RSVD },
00055 {0x100000000ULL, (0x230000000ULL -0x100000000ULL ), E820_TYPE_RAM },
00056 };
00057 #define e820map __use_text16 ( e820map )
00058
00059 void fake_e820 ( void ) {
00060 __asm__ __volatile__ (
00061 TEXT16_CODE ( "\nint15_fakee820:\n\t"
00062 "pushfw\n\t"
00063 "cmpl $0xe820, %%eax\n\t"
00064 "jne 99f\n\t"
00065 "cmpl $0x534d4150, %%edx\n\t"
00066 "jne 99f\n\t"
00067 "pushaw\n\t"
00068 "movw %%sp, %%bp\n\t"
00069 "andb $~0x01, 22(%%bp)\n\t"
00070 "leaw e820map(%%bx), %%si\n\t"
00071 "cs rep movsb\n\t"
00072 "popaw\n\t"
00073 "movl %%edx, %%eax\n\t"
00074 "addl $20, %%ebx\n\t"
00075 "cmpl %0, %%ebx\n\t"
00076 "jne 1f\n\t"
00077 "xorl %%ebx,%%ebx\n\t"
00078 "\n1:\n\t"
00079 "popfw\n\t"
00080 "iret\n\t"
00081 "\n99:\n\t"
00082 "popfw\n\t"
00083 "ljmp *%%cs:real_int15_vector\n\t" )
00084 : : "i" ( sizeof ( e820map ) ) );
00085
00086 hook_bios_interrupt ( 0x15, ( unsigned int ) int15_fakee820,
00087 &real_int15_vector );
00088 }
00089
00090 void unfake_e820 ( void ) {
00091 unhook_bios_interrupt ( 0x15, ( unsigned int ) int15_fakee820,
00092 &real_int15_vector );
00093 }