10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51106Smrj * Common Development and Distribution License (the "License"). 61106Smrj * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*9870SRoger.Faulkner@Sun.COM 220Sstevel@tonic-gate /* 23*9870SRoger.Faulkner@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_ARCHSYSTM_H 280Sstevel@tonic-gate #define _SYS_ARCHSYSTM_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate /* 310Sstevel@tonic-gate * A selection of ISA-dependent interfaces 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <vm/seg_enum.h> 350Sstevel@tonic-gate #include <vm/page.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef _KERNEL 420Sstevel@tonic-gate 430Sstevel@tonic-gate extern greg_t getfp(void); 440Sstevel@tonic-gate extern int getpil(void); 450Sstevel@tonic-gate 460Sstevel@tonic-gate extern ulong_t getcr0(void); 470Sstevel@tonic-gate extern void setcr0(ulong_t); 480Sstevel@tonic-gate extern ulong_t getcr2(void); 497589SVikram.Hegde@Sun.COM extern void iommu_cpu_nop(void); 507589SVikram.Hegde@Sun.COM extern void clflush_insn(caddr_t addr); 517589SVikram.Hegde@Sun.COM extern void mfence_insn(void); 520Sstevel@tonic-gate 530Sstevel@tonic-gate #if defined(__i386) 540Sstevel@tonic-gate extern uint16_t getgs(void); 550Sstevel@tonic-gate extern void setgs(uint16_t); 563446Smrj 573446Smrj extern void patch_sse(void); 583446Smrj extern void patch_sse2(void); 590Sstevel@tonic-gate #endif 600Sstevel@tonic-gate 613446Smrj extern void cli(void); 620Sstevel@tonic-gate extern void sti(void); 630Sstevel@tonic-gate 640Sstevel@tonic-gate extern void tenmicrosec(void); 650Sstevel@tonic-gate 663446Smrj extern void restore_int_flag(ulong_t); 673446Smrj extern void intr_restore(ulong_t); 683446Smrj extern ulong_t clear_int_flag(void); 693446Smrj extern ulong_t intr_clear(void); 703446Smrj extern ulong_t getflags(void); 713446Smrj extern int interrupts_enabled(void); 720Sstevel@tonic-gate 731414Scindi extern void int3(void); 741414Scindi extern void int18(void); 750Sstevel@tonic-gate extern void int20(void); 767349SAdrian.Frost@Sun.COM extern void int_cmci(void); 770Sstevel@tonic-gate 780Sstevel@tonic-gate #if defined(__amd64) 790Sstevel@tonic-gate extern void sys_syscall(); 800Sstevel@tonic-gate extern void sys_syscall32(); 810Sstevel@tonic-gate extern void sys_lcall32(); 820Sstevel@tonic-gate extern void sys_syscall_int(); 832712Snn35248 extern void brand_sys_syscall(); 842712Snn35248 extern void brand_sys_syscall32(); 852712Snn35248 extern void brand_sys_syscall_int(); 863446Smrj extern int update_sregs(); 875084Sjohnlev extern void reset_sregs(); 880Sstevel@tonic-gate #elif defined(__i386) 890Sstevel@tonic-gate extern void sys_call(); 902712Snn35248 extern void brand_sys_call(); 910Sstevel@tonic-gate #endif 920Sstevel@tonic-gate extern void sys_sysenter(); 930Sstevel@tonic-gate extern void _sys_sysenter_post_swapgs(); 942712Snn35248 extern void brand_sys_sysenter(); 952712Snn35248 extern void _brand_sys_sysenter_post_swapgs(); 960Sstevel@tonic-gate 970Sstevel@tonic-gate extern void dosyscall(void); 980Sstevel@tonic-gate 990Sstevel@tonic-gate extern void bind_hwcap(void); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate extern uint16_t inw(int port); 1020Sstevel@tonic-gate extern uint32_t inl(int port); 1030Sstevel@tonic-gate extern void outw(int port, uint16_t value); 1040Sstevel@tonic-gate extern void outl(int port, uint32_t value); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate extern void pc_reset(void) __NORETURN; 1072866Sszhou extern void efi_reset(void) __NORETURN; 1080Sstevel@tonic-gate extern void reset(void) __NORETURN; 1090Sstevel@tonic-gate extern int goany(void); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate extern void setgregs(klwp_t *, gregset_t); 1120Sstevel@tonic-gate extern void getgregs(klwp_t *, gregset_t); 1130Sstevel@tonic-gate extern void setfpregs(klwp_t *, fpregset_t *); 1140Sstevel@tonic-gate extern void getfpregs(klwp_t *, fpregset_t *); 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL) 1170Sstevel@tonic-gate extern void getgregs32(klwp_t *, gregset32_t); 1180Sstevel@tonic-gate extern void setfpregs32(klwp_t *, fpregset32_t *); 1190Sstevel@tonic-gate extern void getfpregs32(klwp_t *, fpregset32_t *); 1200Sstevel@tonic-gate #endif 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate struct fpu_ctx; 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate extern void fp_free(struct fpu_ctx *, int); 1250Sstevel@tonic-gate extern void fp_save(struct fpu_ctx *); 1260Sstevel@tonic-gate extern void fp_restore(struct fpu_ctx *); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate extern int fpu_pentium_fdivbug; 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate extern void sep_save(void *); 1310Sstevel@tonic-gate extern void sep_restore(void *); 1320Sstevel@tonic-gate 1332712Snn35248 extern void brand_interpositioning_enable(void); 1342712Snn35248 extern void brand_interpositioning_disable(void); 1352712Snn35248 1360Sstevel@tonic-gate struct regs; 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate extern int instr_size(struct regs *, caddr_t *, enum seg_rw); 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate extern int enable_cbcp; /* patchable in /etc/system */ 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate extern uint_t cpu_hwcap_flags; 1430Sstevel@tonic-gate extern uint_t cpu_freq; 1440Sstevel@tonic-gate extern uint64_t cpu_freq_hz; 1450Sstevel@tonic-gate 1463446Smrj extern int use_sse_pagecopy; 1473446Smrj extern int use_sse_pagezero; 1483446Smrj extern int use_sse_copy; 1493446Smrj 1500Sstevel@tonic-gate extern caddr_t i86devmap(pfn_t, pgcnt_t, uint_t); 1510Sstevel@tonic-gate extern page_t *page_numtopp_alloc(pfn_t pfnum); 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate extern void hwblkclr(void *, size_t); 1540Sstevel@tonic-gate extern void hwblkpagecopy(const void *, void *); 1553446Smrj extern void page_copy_no_xmm(void *dst, void *src); 1563446Smrj extern void block_zero_no_xmm(void *dst, int len); 1573446Smrj #define BLOCKZEROALIGN (4 * sizeof (void *)) 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate extern void (*kcpc_hw_enable_cpc_intr)(void); 1600Sstevel@tonic-gate 1613446Smrj extern void init_desctbls(void); 1620Sstevel@tonic-gate 1632712Snn35248 extern user_desc_t *cpu_get_gdt(void); 1642712Snn35248 1653446Smrj extern void switch_sp_and_call(void *, void (*)(uint_t, uint_t), uint_t, 1663446Smrj uint_t); 1670Sstevel@tonic-gate extern hrtime_t (*gethrtimef)(void); 1680Sstevel@tonic-gate extern hrtime_t (*gethrtimeunscaledf)(void); 1690Sstevel@tonic-gate extern void (*scalehrtimef)(hrtime_t *); 1700Sstevel@tonic-gate extern void (*gethrestimef)(timestruc_t *); 1710Sstevel@tonic-gate 1723446Smrj extern void av_dispatch_softvect(uint_t); 1733446Smrj extern void av_dispatch_autovect(uint_t); 1743446Smrj extern uint_t atomic_btr32(uint32_t *, uint_t); 1753446Smrj extern uint_t bsrw_insn(uint16_t); 1763446Smrj extern int sys_rtt_common(struct regs *); 1773446Smrj extern void fakesoftint(void); 1783446Smrj 1795084Sjohnlev extern void *plat_traceback(void *); 1803446Smrj 1815084Sjohnlev #if defined(__xpv) 1825084Sjohnlev extern void xen_init_callbacks(void); 1835084Sjohnlev extern void xen_set_callback(void (*)(void), uint_t, uint_t); 1845084Sjohnlev extern void xen_printf(const char *, ...); 1855084Sjohnlev #define cpr_dprintf xen_printf 1865084Sjohnlev extern int xpv_panicking; 1875084Sjohnlev #define IN_XPV_PANIC() (xpv_panicking > 0) 1885084Sjohnlev #else 1893446Smrj extern void setup_mca(void); 1905159Sjohnlev extern void pat_sync(void); 1915322Ssudheer extern void patch_tsc_read(int); 1928377SBill.Holler@Sun.COM #if defined(__amd64) && !defined(__xpv) 1938377SBill.Holler@Sun.COM extern void patch_memops(uint_t); 1948377SBill.Holler@Sun.COM #endif /* defined(__amd64) && !defined(__xpv) */ 1953446Smrj #define cpr_dprintf prom_printf 1965084Sjohnlev #define IN_XPV_PANIC() (__lintzero) 1975084Sjohnlev #endif 1983446Smrj 1990Sstevel@tonic-gate #endif /* _KERNEL */ 2000Sstevel@tonic-gate 2013446Smrj #if defined(_KERNEL) || defined(_BOOT) 2023446Smrj extern uint8_t inb(int port); 2033446Smrj extern void outb(int port, uint8_t value); 2043446Smrj #endif 2053446Smrj 2060Sstevel@tonic-gate #ifdef __cplusplus 2070Sstevel@tonic-gate } 2080Sstevel@tonic-gate #endif 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate #endif /* _SYS_ARCHSYSTM_H */ 211