Changeset View
Changeset View
Standalone View
Standalone View
head/stand/i386/libi386/elf64_freebsd.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
static int elf64_exec(struct preloaded_file *amp); | static int elf64_exec(struct preloaded_file *amp); | ||||
static int elf64_obj_exec(struct preloaded_file *amp); | static int elf64_obj_exec(struct preloaded_file *amp); | ||||
struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; | struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; | ||||
struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; | struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; | ||||
#define PG_V 0x001 | #define PG_V 0x001 | ||||
#define PG_RW 0x002 | #define PG_RW 0x002 | ||||
#define PG_U 0x004 | |||||
#define PG_PS 0x080 | #define PG_PS 0x080 | ||||
typedef uint64_t p4_entry_t; | typedef uint64_t p4_entry_t; | ||||
typedef uint64_t p3_entry_t; | typedef uint64_t p3_entry_t; | ||||
typedef uint64_t p2_entry_t; | typedef uint64_t p2_entry_t; | ||||
extern p4_entry_t PT4[]; | extern p4_entry_t PT4[]; | ||||
extern p3_entry_t PT3[]; | extern p3_entry_t PT3[]; | ||||
extern p2_entry_t PT2[]; | extern p2_entry_t PT2[]; | ||||
Show All 31 Lines | return(err); | ||||
/* | /* | ||||
* This is kinda brutal, but every single 1GB VM memory segment points to | * This is kinda brutal, but every single 1GB VM memory segment points to | ||||
* the same first 1GB of physical memory. But it is more than adequate. | * the same first 1GB of physical memory. But it is more than adequate. | ||||
*/ | */ | ||||
for (i = 0; i < 512; i++) { | for (i = 0; i < 512; i++) { | ||||
/* Each slot of the level 4 pages points to the same level 3 page */ | /* Each slot of the level 4 pages points to the same level 3 page */ | ||||
PT4[i] = (p4_entry_t)VTOP((uintptr_t)&PT3[0]); | PT4[i] = (p4_entry_t)VTOP((uintptr_t)&PT3[0]); | ||||
PT4[i] |= PG_V | PG_RW | PG_U; | PT4[i] |= PG_V | PG_RW; | ||||
/* Each slot of the level 3 pages points to the same level 2 page */ | /* Each slot of the level 3 pages points to the same level 2 page */ | ||||
PT3[i] = (p3_entry_t)VTOP((uintptr_t)&PT2[0]); | PT3[i] = (p3_entry_t)VTOP((uintptr_t)&PT2[0]); | ||||
PT3[i] |= PG_V | PG_RW | PG_U; | PT3[i] |= PG_V | PG_RW; | ||||
/* The level 2 page slots are mapped with 2MB pages for 1GB. */ | /* The level 2 page slots are mapped with 2MB pages for 1GB. */ | ||||
PT2[i] = i * (2 * 1024 * 1024); | PT2[i] = i * (2 * 1024 * 1024); | ||||
PT2[i] |= PG_V | PG_RW | PG_PS | PG_U; | PT2[i] |= PG_V | PG_RW | PG_PS; | ||||
} | } | ||||
entry_lo = ehdr->e_entry & 0xffffffff; | entry_lo = ehdr->e_entry & 0xffffffff; | ||||
entry_hi = (ehdr->e_entry >> 32) & 0xffffffff; | entry_hi = (ehdr->e_entry >> 32) & 0xffffffff; | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
printf("Start @ %#llx ...\n", ehdr->e_entry); | printf("Start @ %#llx ...\n", ehdr->e_entry); | ||||
#endif | #endif | ||||
Show All 11 Lines |