x86_64: implement bootstrap function for pmap interface

This commit is contained in:
2023-02-06 20:50:28 +00:00
parent 52b3a5d6a5
commit 625eac9ca7
8 changed files with 423 additions and 4 deletions

View File

@@ -0,0 +1,54 @@
#ifndef ARCH_PAGING_H_
#define ARCH_PAGING_H_
#include <socks/types.h>
#include <socks/compiler.h>
#define PTE_PRESENT 0x01ULL
#define PTE_RW 0x02ULL
#define PTE_USR 0x04ULL
#define PTE_WRITETHROUGH 0x08ULL
#define PTE_NOCACHE 0x10ULL
#define PTE_PAGESIZE 0x80ULL
#define PTE_NX 0x8000000000000000ULL
typedef phys_addr_t pml4t_ptr_t;
typedef uint64_t pte_t;
typedef struct pml4t {
phys_addr_t p_entries[512];
} __packed pml4t_t;
typedef struct pdpt {
union {
/* 4KiB and 2MiB pages */
phys_addr_t p_entries[512];
/* 1GiB pages */
pte_t p_pages[512];
};
} __packed pdpt_t;
typedef struct pdir {
union {
/* 4KiB pages */
phys_addr_t p_entries[512];
/* 2MiB pages */
pte_t p_pages[512];
};
} __packed pdir_t;
typedef struct ptab {
pte_t p_pages[512];
} __packed ptab_t;
typedef enum page_size {
PS_4K,
PS_2M,
PS_1G,
} page_size_t;
/* returns 1 if gigabyte pages are supported by the CPU, 0 otherwise.
defined in pmap_ctrl.S */
extern int gigabyte_pages(void);
#endif

View File

@@ -0,0 +1,9 @@
#ifndef SOCKS_X86_64_PMAP_H_
#define SOCKS_X86_64_PMAP_H_
#include <arch/paging.h>
typedef pml4t_ptr_t ml_pmap_t;
typedef uint64_t ml_pfn_t;
#endif