Changeset View
Changeset View
Standalone View
Standalone View
head/stand/userboot/userboot/elf64_freebsd.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
#define CR4_VMXE (1UL << 13) | #define CR4_VMXE (1UL << 13) | ||||
#define CR4_PSE 0x00000010 | #define CR4_PSE 0x00000010 | ||||
#define CR0_PG 0x80000000 | #define CR0_PG 0x80000000 | ||||
#define CR0_PE 0x00000001 /* Protected mode Enable */ | #define CR0_PE 0x00000001 /* Protected mode Enable */ | ||||
#define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */ | #define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */ | ||||
#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; | ||||
#define GUEST_NULL_SEL 0 | #define GUEST_NULL_SEL 0 | ||||
#define GUEST_CODE_SEL 1 | #define GUEST_CODE_SEL 1 | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | elf64_exec(struct preloaded_file *fp) | ||||
/* | /* | ||||
* This is kinda brutal, but every single 1GB VM memory segment | * This is kinda brutal, but every single 1GB VM memory segment | ||||
* points to the same first 1GB of physical memory. But it is | * points to the same first 1GB of physical memory. But it is | ||||
* more than adequate. | * 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) 0x3000; | PT4[i] = (p4_entry_t) 0x3000; | ||||
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) 0x4000; | PT3[i] = (p3_entry_t) 0x4000; | ||||
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; | ||||
} | } | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
printf("Start @ %#"PRIx64" ...\n", ehdr->e_entry); | printf("Start @ %#"PRIx64" ...\n", ehdr->e_entry); | ||||
#endif | #endif | ||||
dev_cleanup(); | dev_cleanup(); | ||||
Show All 29 Lines |