/* Map a virtual address to a physical address and optionally invalidate any old mapping. */
static void x86_phys_map_page(uintptr_t virt, phys_addr_t phys, int invlpg)
/* Map a virtual address to a physical address and optionally invalidate any old mapping. */
static void x86_phys_map_page(uintptr_t virt, phys_addr_t phys, int invlpg)
{
	uintptr_t pdpt_idx = (virt >> 30) & 0x3;
	uintptr_t pdt_idx = (virt >> 21) & 0x1ff;
	struct pde *pde = &(pdts[pdpt_idx][pdt_idx]);
	memset(pde, 0, sizeof(struct pde));
	pde->p = 1;
	pde->rw = 1;
	pde->us = 1;
	pde->ps = 1;
	pde->base = phys >> 21;
	if (invlpg) {
		__asm__ __volatile__(
			"invlpg %0\n\t"
			:
			: "m" (*(uint8_t *)virt)
		);
	}
}