/* DF-5658 checker: re-evaluate every ASSYM expression from
 * sys/platform/vkernel64/x86_64/genassym.c in an independent TU, plus the
 * (d)-item savevext/TLS offsets and the missing-export target offsets.
 * Compiled with the exact genassym.o CFLAGS of the VKERNEL64 build tree.
 */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/assym.h>
#include <sys/interrupt.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/errno.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/lock.h>
#include <sys/resourcevar.h>
#include <machine/frame.h>
#include <machine/tss.h>
#include <sys/vmmeter.h>
#include <sys/machintr.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <net/if.h>
#include <netinet/in.h>
#include <vfs/nfs/nfsv2.h>
#include <vfs/nfs/rpcv2.h>
#include <vfs/nfs/nfs.h>
#include <vfs/nfs/nfsdiskless.h>
#include <machine/segments.h>
#include <machine/sigframe.h>
#include <machine/globaldata.h>
#include <machine/specialreg.h>
#include <machine/pcb.h>
#include <machine/smp.h>
#include <machine/thread.h>
#include <machine/vframe.h>

/* every emitted ASSYM, same order as genassym.c */
#define P(x) printf("%s\t0x%lx\n", #x, (unsigned long)(x))
int main(void) {
	printf("VM_PMAP\t0x%lx\n",(unsigned long)offsetof(struct vmspace, vm_pmap));
	printf("PM_ACTIVE\t0x%lx\n",(unsigned long)offsetof(struct pmap, pm_active));
	printf("PM_ACTIVE_LOCK\t0x%lx\n",(unsigned long)offsetof(struct pmap, pm_active_lock));
	printf("LWP_VMSPACE\t0x%lx\n",(unsigned long)offsetof(struct lwp, lwp_vmspace));
	printf("GD_CURTHREAD\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_curthread));
	printf("GD_CPUID\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_cpuid));
	printf("GD_CPUMASK\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_cpumask));
	printf("GD_OTHER_CPUS\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_other_cpus));
	printf("CPULOCK_EXCLBIT\t0x%lx\n",(unsigned long)CPULOCK_EXCLBIT);
	printf("CPULOCK_EXCL\t0x%lx\n",(unsigned long)CPULOCK_EXCL);
	printf("CPULOCK_INCR\t0x%lx\n",(unsigned long)CPULOCK_INCR);
	printf("CPULOCK_CNTMASK\t0x%lx\n",(unsigned long)CPULOCK_CNTMASK);
	printf("PCB_R15\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_r15));
	printf("PCB_R14\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_r14));
	printf("PCB_R13\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_r13));
	printf("PCB_R12\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_r12));
	printf("PCB_RBP\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_rbp));
	printf("PCB_RSP\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_rsp));
	printf("PCB_RBX\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_rbx));
	printf("PCB_RIP\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_rip));
	printf("TSS_RSP0\t0x%lx\n",(unsigned long)offsetof(struct x86_64tss, tss_rsp0));
	printf("PCB_DR0\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr0));
	printf("PCB_DR1\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr1));
	printf("PCB_DR2\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr2));
	printf("PCB_DR3\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr3));
	printf("PCB_DR6\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr6));
	printf("PCB_DR7\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_dr7));
	printf("PCB_DBREGS\t0x%lx\n",(unsigned long)PCB_DBREGS);
	printf("PCB_FLAGS\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_flags));
	printf("PCB_FSBASE\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_fsbase));
	printf("PCB_GSBASE\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_gsbase));
	printf("PCB_SAVEFPU\t0x%lx\n",(unsigned long)offsetof(struct pcb, pcb_save));
	printf("PCB_SAVEFPU_SIZE\t0x%lx\n",(unsigned long)sizeof(union savefpu));
	printf("SIGF_HANDLER\t0x%lx\n",(unsigned long)offsetof(struct sigframe, sf_ahu.sf_handler));
	printf("SIGF_UC\t0x%lx\n",(unsigned long)offsetof(struct sigframe, sf_uc));
	printf("TD_LWP\t0x%lx\n",(unsigned long)offsetof(struct thread, td_lwp));
	printf("TD_PCB\t0x%lx\n",(unsigned long)offsetof(struct thread, td_pcb));
	printf("TD_SP\t0x%lx\n",(unsigned long)offsetof(struct thread, td_sp));
	printf("TD_PRI\t0x%lx\n",(unsigned long)offsetof(struct thread, td_pri));
	printf("TD_CRITCOUNT\t0x%lx\n",(unsigned long)offsetof(struct thread, td_critcount));
	printf("TD_FLAGS\t0x%lx\n",(unsigned long)offsetof(struct thread, td_flags));
	printf("TD_SAVEFPU\t0x%lx\n",(unsigned long)offsetof(struct thread, td_savefpu));
	printf("TDF_RUNNING\t0x%lx\n",(unsigned long)TDF_RUNNING);
	printf("GD_NPXTHREAD\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_npxthread));

	/* ---- item (d): vkernel-specific vextframe/TLS aliasing chain ---- */
	printf("CHECK_td_mach\t0x%lx\n",(unsigned long)offsetof(struct thread, td_mach));
	printf("CHECK_mtd_savefpu\t0x%lx\n",(unsigned long)offsetof(struct thread, td_mach.mtd_savefpu));
	printf("CHECK_mtd_savevext\t0x%lx\n",(unsigned long)offsetof(struct thread, td_mach.mtd_savevext));
	printf("CHECK_td_savevext\t0x%lx\n",(unsigned long)offsetof(struct thread, td_savevext));
	printf("CHECK_td_tls\t0x%lx\n",(unsigned long)offsetof(struct thread, td_tls));
	printf("CHECK_vx_tls\t0x%lx\n",(unsigned long)offsetof(struct vextframe, vx_tls));
	printf("CHECK_savevext_after_savefpu\t0x%lx\n",(unsigned long)(offsetof(struct thread, td_mach.mtd_savevext)-offsetof(struct thread, td_mach.mtd_savefpu)));

	/* ---- what the 13 restorable missing exports SHOULD be ---- */
	printf("MISSING_GD_REQFLAGS\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_reqflags));
	printf("MISSING_GD_COMMON_TSS\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_common_tss));
	printf("MISSING_GD_COMMON_TSSD\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_common_tssd));
	printf("MISSING_GD_TSS_GDT\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_tss_gdt));
	printf("MISSING_GD_FPU_LOCK\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_fpu_lock));
	printf("MISSING_GD_SAVEFPU\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_savefpu));
	printf("MISSING_GD_SS_EFLAGS\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_ss_eflags));
	printf("MISSING_GD_INTR_NESTING_LEVEL\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_intr_nesting_level));
	printf("MISSING_GD_FPENDING\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_fpending));
	printf("MISSING_GD_IPENDING\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_ipending));
	printf("MISSING_GD_SPENDING\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_spending));
	printf("MISSING_GD_CURRENTLDT\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, gd_currentldt));
	printf("MISSING_GD_CNT\t0x%lx\n",(unsigned long)offsetof(struct mdglobaldata, mi.gd_cnt));
	printf("MISSING_MDGLOBALDATA_SIZE\t0x%lx\n",(unsigned long)sizeof(struct mdglobaldata));
	return 0;
}
