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