1291406Sjhb/*-
2291406Sjhb * Copyright (c) 2015 John H. Baldwin <jhb@FreeBSD.org>
3291406Sjhb *
4291406Sjhb * Redistribution and use in source and binary forms, with or without
5291406Sjhb * modification, are permitted provided that the following conditions
6291406Sjhb * are met:
7291406Sjhb * 1. Redistributions of source code must retain the above copyright
8291406Sjhb *    notice, this list of conditions and the following disclaimer.
9291406Sjhb * 2. Redistributions in binary form must reproduce the above copyright
10291406Sjhb *    notice, this list of conditions and the following disclaimer in the
11291406Sjhb *    documentation and/or other materials provided with the distribution.
12291406Sjhb *
13291406Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14291406Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15291406Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16291406Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17291406Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18291406Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19291406Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20291406Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21291406Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22291406Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23291406Sjhb * SUCH DAMAGE.
24291406Sjhb *
25291406Sjhb * $FreeBSD: stable/11/lib/libkvm/kvm_i386.h 367457 2020-11-07 18:10:59Z dim $
26291406Sjhb */
27291406Sjhb
28291406Sjhb#ifndef __KVM_I386_H__
29291406Sjhb#define	__KVM_I386_H__
30291406Sjhb
31291406Sjhb#ifdef __i386__
32291406Sjhb#include <vm/vm.h>
33291406Sjhb#include <vm/pmap.h>
34291406Sjhb#endif
35291406Sjhb
36291406Sjhbtypedef uint32_t	i386_physaddr_t;
37291406Sjhbtypedef uint32_t	i386_pte_t;
38291406Sjhbtypedef uint32_t	i386_pde_t;
39291406Sjhbtypedef uint64_t	i386_physaddr_pae_t;
40291406Sjhbtypedef	uint64_t	i386_pte_pae_t;
41291406Sjhbtypedef	uint64_t	i386_pde_pae_t;
42291406Sjhb
43291406Sjhb#define	I386_PAGE_SHIFT		12
44291406Sjhb#define	I386_PAGE_SIZE		(1 << I386_PAGE_SHIFT)
45291406Sjhb#define	I386_PAGE_MASK		(I386_PAGE_SIZE - 1)
46291406Sjhb#define	I386_NPTEPG		(I386_PAGE_SIZE / sizeof(i386_pte_t))
47291406Sjhb#define	I386_PDRSHIFT		22
48291406Sjhb#define	I386_NBPDR		(1 << I386_PDRSHIFT)
49291406Sjhb#define	I386_PAGE_PS_MASK	(I386_NBPDR - 1)
50291406Sjhb#define	I386_NPTEPG_PAE		(I386_PAGE_SIZE / sizeof(i386_pte_pae_t))
51291406Sjhb#define	I386_PDRSHIFT_PAE	21
52291406Sjhb#define	I386_NBPDR_PAE		(1 << I386_PDRSHIFT_PAE)
53291406Sjhb#define	I386_PAGE_PS_MASK_PAE	(I386_NBPDR_PAE - 1)
54291406Sjhb
55291406Sjhb#define	I386_PG_V		0x001
56291406Sjhb#define	I386_PG_PS		0x080
57291406Sjhb#define	I386_PG_FRAME_PAE	(0x000ffffffffff000ull)
58291406Sjhb#define	I386_PG_PS_FRAME_PAE	(0x000fffffffe00000ull)
59291406Sjhb#define	I386_PG_FRAME		(0xfffff000)
60291406Sjhb#define	I386_PG_PS_FRAME	(0xffc00000)
61291406Sjhb
62291406Sjhb#ifdef __i386__
63291406Sjhb_Static_assert(PAGE_SHIFT == I386_PAGE_SHIFT, "PAGE_SHIFT mismatch");
64291406Sjhb_Static_assert(PAGE_SIZE == I386_PAGE_SIZE, "PAGE_SIZE mismatch");
65291406Sjhb_Static_assert(PAGE_MASK == I386_PAGE_MASK, "PAGE_MASK mismatch");
66291406Sjhb_Static_assert(NPTEPG == I386_NPTEPG, "NPTEPG mismatch");
67291406Sjhb_Static_assert(PDRSHIFT == I386_PDRSHIFT, "PDRSHIFT mismatch");
68291406Sjhb_Static_assert(NBPDR == I386_NBPDR, "NBPDR mismatch");
69291406Sjhb
70291406Sjhb_Static_assert(PG_V == I386_PG_V, "PG_V mismatch");
71291406Sjhb_Static_assert(PG_PS == I386_PG_PS, "PG_PS mismatch");
72293979Sjhb_Static_assert((u_int)PG_FRAME == I386_PG_FRAME, "PG_FRAME mismatch");
73291406Sjhb_Static_assert(PG_PS_FRAME == I386_PG_PS_FRAME, "PG_PS_FRAME mismatch");
74291406Sjhb#endif
75291406Sjhb
76291406Sjhbint	_i386_native(kvm_t *);
77291406Sjhb
78291406Sjhb#endif /* !__KVM_I386_H__ */
79