17090Sbde/*- 27090Sbde * Copyright (c) 1995 Bruce D. Evans. 37090Sbde * All rights reserved. 47090Sbde * 57090Sbde * Redistribution and use in source and binary forms, with or without 67090Sbde * modification, are permitted provided that the following conditions 77090Sbde * are met: 87090Sbde * 1. Redistributions of source code must retain the above copyright 97090Sbde * notice, this list of conditions and the following disclaimer. 107090Sbde * 2. Redistributions in binary form must reproduce the above copyright 117090Sbde * notice, this list of conditions and the following disclaimer in the 127090Sbde * documentation and/or other materials provided with the distribution. 137090Sbde * 3. Neither the name of the author nor the names of contributors 147090Sbde * may be used to endorse or promote products derived from this software 157090Sbde * without specific prior written permission. 167090Sbde * 177090Sbde * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 187090Sbde * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 197090Sbde * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 207090Sbde * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 217090Sbde * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 227090Sbde * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 237090Sbde * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 247090Sbde * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 257090Sbde * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 267090Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 277090Sbde * SUCH DAMAGE. 287090Sbde * 2950477Speter * $FreeBSD: stable/10/sys/i386/include/md_var.h 322205 2017-08-07 22:30:18Z jkim $ 307090Sbde */ 317090Sbde 327090Sbde#ifndef _MACHINE_MD_VAR_H_ 337090Sbde#define _MACHINE_MD_VAR_H_ 347090Sbde 357090Sbde/* 367090Sbde * Miscellaneous machine-dependent declarations. 377090Sbde */ 387090Sbde 39102600Speterextern long Maxmem; 40121999Sjhbextern u_int basemem; /* PA of original top of base memory */ 4133008Sbdeextern int busdma_swi_pending; 42108947Sjhbextern u_int cpu_exthigh; 43147691Speterextern u_int cpu_feature; 44147691Speterextern u_int cpu_feature2; 45147691Speterextern u_int amd_feature; 46151348Sjkimextern u_int amd_feature2; 47184101Sjkimextern u_int amd_pminfo; 48160309Smrextern u_int via_feature_rng; 49160309Smrextern u_int via_feature_xcrypt; 50195940Skibextern u_int cpu_clflush_line_size; 51276070Sjhbextern u_int cpu_stdext_feature; 52284338Skibextern u_int cpu_stdext_feature2; 53109700Sjhbextern u_int cpu_fxsr; 5437553Sbdeextern u_int cpu_high; 55109700Sjhbextern u_int cpu_id; 56276084Sjhbextern u_int cpu_max_ext_state_size; 57159087Sdavidxuextern u_int cpu_mxcsr_mask; 58109696Sjhbextern u_int cpu_procinfo; 59151348Sjkimextern u_int cpu_procinfo2; 607090Sbdeextern char cpu_vendor[]; 61185341Sjkimextern u_int cpu_vendor_id; 62253747Savgextern u_int cpu_mon_mwait_flags; 63253747Savgextern u_int cpu_mon_min_size; 64253747Savgextern u_int cpu_mon_max_size; 65277374Skibextern u_int cpu_maxphyaddr; 66276070Sjhbextern u_int cyrix_did; 67276070Sjhb#if defined(I586_CPU) && !defined(NO_F00F_HACK) 68276070Sjhbextern int has_f00f_bug; 69276070Sjhb#endif 70278522Sjhbextern u_int hv_high; 71278522Sjhbextern char hv_vendor[]; 727090Sbdeextern char kstack[]; 7314331Speterextern char sigcode[]; 74105950Speterextern int szsigcode; 75105950Speter#ifdef COMPAT_FREEBSD4 76105950Speterextern int szfreebsd4_sigcode; 77105950Speter#endif 78105950Speter#ifdef COMPAT_43 79105950Speterextern int szosigcode; 80105950Speter#endif 81157909Speterextern uint32_t *vm_page_dump; 82157909Speterextern int vm_page_dump_size; 83205573Salcextern int workaround_erratum383; 84276080Sjhbextern int _udatasel; 85276080Sjhbextern int _ucodesel; 86276084Sjhbextern int use_xsave; 87276084Sjhbextern uint64_t xsave_mask; 887090Sbde 8992761Salfredtypedef void alias_for_inthand_t(u_int cs, u_int ef, u_int esp, u_int ss); 90276084Sjhbstruct pcb; 91276084Sjhbunion savefpu; 9283366Sjulianstruct thread; 937090Sbdestruct reg; 9439197Sjdpstruct fpreg; 9548691Sjlemonstruct dbreg; 96157909Speterstruct dumperinfo; 97286311Skibstruct segment_descriptor; 987090Sbde 99309426Sjhb/* 100309426Sjhb * Returns the maximum physical address that can be used with the 101309426Sjhb * current system. 102309426Sjhb */ 103309426Sjhbstatic __inline vm_paddr_t 104309426Sjhbcpu_getmaxphyaddr(void) 105309426Sjhb{ 106309426Sjhb#if !defined(PAE) 107309426Sjhb return (0xffffffff); 108309426Sjhb#else 109309426Sjhb return ((1ULL << cpu_maxphyaddr) - 1); 110309426Sjhb#endif 111309426Sjhb} 112309426Sjhb 113276084Sjhbvoid *alloc_fpusave(int flags); 11492761Salfredvoid bcopyb(const void *from, void *to, size_t len); 11592761Salfredvoid busdma_swi(void); 11692761Salfredvoid cpu_setregs(void); 11792761Salfredvoid cpu_switch_load_gs(void) __asm(__STRING(cpu_switch_load_gs)); 11892761Salfredvoid doreti_iret(void) __asm(__STRING(doreti_iret)); 11992761Salfredvoid doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault)); 12092761Salfredvoid doreti_popl_ds(void) __asm(__STRING(doreti_popl_ds)); 12192761Salfredvoid doreti_popl_ds_fault(void) __asm(__STRING(doreti_popl_ds_fault)); 12292761Salfredvoid doreti_popl_es(void) __asm(__STRING(doreti_popl_es)); 12392761Salfredvoid doreti_popl_es_fault(void) __asm(__STRING(doreti_popl_es_fault)); 12492761Salfredvoid doreti_popl_fs(void) __asm(__STRING(doreti_popl_fs)); 12592761Salfredvoid doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault)); 126157909Spetervoid dump_add_page(vm_paddr_t); 127157909Spetervoid dump_drop_page(vm_paddr_t); 128276070Sjhbvoid finishidentcpu(void); 12992761Salfredvoid fillw(int /*u_short*/ pat, void *base, size_t cnt); 130286311Skibvoid fill_based_sd(struct segment_descriptor *sdp, uint32_t base); 131322205Sjkimvoid identify_hypervisor(void); 132276070Sjhbvoid initializecpu(void); 133276076Sjhbvoid initializecpucache(void); 134299062Savgbool fix_cpuid(void); 13592761Salfredvoid i686_pagezero(void *addr); 136120620Sjeffvoid sse2_pagezero(void *addr); 137101235Sphkvoid init_AMD_Elan_sc520(void); 138128100Salcint is_physical_memory(vm_paddr_t addr); 139121999Sjhbint isa_nmi(int cd); 140112569Sjakevm_paddr_t kvtop(void *addr); 141276070Sjhbvoid panicifcpuunsupported(void); 142276076Sjhbvoid ppro_reenable_apic(void); 143276070Sjhbvoid printcpuinfo(void); 14493018Sbdevoid setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); 14592761Salfredint user_dbreg_trap(void); 146157909Spetervoid minidumpsys(struct dumperinfo *); 147276084Sjhbunion savefpu *get_pcb_user_save_td(struct thread *td); 148276084Sjhbunion savefpu *get_pcb_user_save_pcb(struct pcb *pcb); 149276084Sjhbstruct pcb *get_pcb_td(struct thread *td); 1507090Sbde 1517090Sbde#endif /* !_MACHINE_MD_VAR_H_ */ 152