17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 54ab75253Smrj * Common Development and Distribution License (the "License"). 64ab75253Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21e0cf54a5SRoger A. Faulkner 227c478bd9Sstevel@tonic-gate /* 2350200e77SFrank Van Der Linden * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. 2442cd1931SJohn Levon * Copyright 2019 Joyent, Inc. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_ARCHSYSTM_H 287c478bd9Sstevel@tonic-gate #define _SYS_ARCHSYSTM_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * A selection of ISA-dependent interfaces 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h> 357c478bd9Sstevel@tonic-gate #include <vm/page.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef _KERNEL 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate extern greg_t getfp(void); 447c478bd9Sstevel@tonic-gate extern int getpil(void); 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate extern ulong_t getcr0(void); 477c478bd9Sstevel@tonic-gate extern void setcr0(ulong_t); 482ef50f01SJoe Bonasera extern ulong_t getcr8(void); 492ef50f01SJoe Bonasera extern void setcr8(ulong_t); 507c478bd9Sstevel@tonic-gate extern ulong_t getcr2(void); 5186c1f4dcSVikram Hegde extern void clflush_insn(caddr_t addr); 5286c1f4dcSVikram Hegde extern void mfence_insn(void); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #if defined(__i386) 557c478bd9Sstevel@tonic-gate extern uint16_t getgs(void); 567c478bd9Sstevel@tonic-gate extern void setgs(uint16_t); 57ae115bc7Smrj 587c478bd9Sstevel@tonic-gate #endif 597c478bd9Sstevel@tonic-gate 60088d69f8SJerry Jelinek extern kmem_cache_t *fpsave_cachep; 617af88ac7SKuriakose Kuruvilla 62ae115bc7Smrj extern void cli(void); 637c478bd9Sstevel@tonic-gate extern void sti(void); 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate extern void tenmicrosec(void); 667c478bd9Sstevel@tonic-gate 67ae115bc7Smrj extern void restore_int_flag(ulong_t); 68ae115bc7Smrj extern void intr_restore(ulong_t); 69ae115bc7Smrj extern ulong_t clear_int_flag(void); 70ae115bc7Smrj extern ulong_t intr_clear(void); 71ae115bc7Smrj extern ulong_t getflags(void); 72ae115bc7Smrj extern int interrupts_enabled(void); 737c478bd9Sstevel@tonic-gate 747aec1d6eScindi extern void int3(void); 757aec1d6eScindi extern void int18(void); 767c478bd9Sstevel@tonic-gate extern void int20(void); 77e3d60c9bSAdrian Frost extern void int_cmci(void); 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #if defined(__amd64) 8074ecdb51SJohn Levon extern void sys_syscall(), tr_sys_syscall(); 8174ecdb51SJohn Levon extern void sys_syscall32(), tr_sys_syscall32(); 827c478bd9Sstevel@tonic-gate extern void sys_lcall32(); 837c478bd9Sstevel@tonic-gate extern void sys_syscall_int(); 8474ecdb51SJohn Levon extern void tr_sys_syscall_int(); 8574ecdb51SJohn Levon extern void brand_sys_syscall(), tr_brand_sys_syscall(); 8674ecdb51SJohn Levon extern void brand_sys_syscall32(), tr_brand_sys_syscall32(); 8774ecdb51SJohn Levon extern void brand_sys_syscall_int(), tr_brand_sys_syscall_int(); 88ae115bc7Smrj extern int update_sregs(); 89843e1988Sjohnlev extern void reset_sregs(); 907c478bd9Sstevel@tonic-gate #elif defined(__i386) 917c478bd9Sstevel@tonic-gate extern void sys_call(); 9274ecdb51SJohn Levon extern void tr_sys_call(); 939acbbeafSnn extern void brand_sys_call(); 947c478bd9Sstevel@tonic-gate #endif 957c478bd9Sstevel@tonic-gate extern void sys_sysenter(); 9674ecdb51SJohn Levon extern void tr_sys_sysenter(); 979acbbeafSnn extern void brand_sys_sysenter(); 9874ecdb51SJohn Levon extern void tr_brand_sys_sysenter(); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern void dosyscall(void); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate extern void bind_hwcap(void); 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate extern uint16_t inw(int port); 1057c478bd9Sstevel@tonic-gate extern uint32_t inl(int port); 1067c478bd9Sstevel@tonic-gate extern void outw(int port, uint16_t value); 1077c478bd9Sstevel@tonic-gate extern void outl(int port, uint32_t value); 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate extern void pc_reset(void) __NORETURN; 110f2be5148Sszhou extern void efi_reset(void) __NORETURN; 1117c478bd9Sstevel@tonic-gate extern void reset(void) __NORETURN; 1127c478bd9Sstevel@tonic-gate extern int goany(void); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate extern void setgregs(klwp_t *, gregset_t); 1157c478bd9Sstevel@tonic-gate extern void getgregs(klwp_t *, gregset_t); 1167c478bd9Sstevel@tonic-gate extern void setfpregs(klwp_t *, fpregset_t *); 1177c478bd9Sstevel@tonic-gate extern void getfpregs(klwp_t *, fpregset_t *); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL) 1207c478bd9Sstevel@tonic-gate extern void getgregs32(klwp_t *, gregset32_t); 1217c478bd9Sstevel@tonic-gate extern void setfpregs32(klwp_t *, fpregset32_t *); 1227c478bd9Sstevel@tonic-gate extern void getfpregs32(klwp_t *, fpregset32_t *); 1237c478bd9Sstevel@tonic-gate #endif 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate struct fpu_ctx; 1267c478bd9Sstevel@tonic-gate 127*5a469116SPatrick Mooney extern void fp_free(struct fpu_ctx *); 1287c478bd9Sstevel@tonic-gate extern void fp_save(struct fpu_ctx *); 1297c478bd9Sstevel@tonic-gate extern void fp_restore(struct fpu_ctx *); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate extern int fpu_pentium_fdivbug; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate extern void sep_save(void *); 1347c478bd9Sstevel@tonic-gate extern void sep_restore(void *); 1357c478bd9Sstevel@tonic-gate 136*5a469116SPatrick Mooney extern void brand_interpositioning_enable(void *); 137*5a469116SPatrick Mooney extern void brand_interpositioning_disable(void *); 1389acbbeafSnn 1397c478bd9Sstevel@tonic-gate struct regs; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate extern int instr_size(struct regs *, caddr_t *, enum seg_rw); 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate extern int enable_cbcp; /* patchable in /etc/system */ 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate extern uint_t cpu_hwcap_flags; 1467c478bd9Sstevel@tonic-gate extern uint_t cpu_freq; 1477c478bd9Sstevel@tonic-gate extern uint64_t cpu_freq_hz; 1487c478bd9Sstevel@tonic-gate 149ae115bc7Smrj extern int use_sse_pagecopy; 150ae115bc7Smrj extern int use_sse_pagezero; 151ae115bc7Smrj extern int use_sse_copy; 152ae115bc7Smrj 1537c478bd9Sstevel@tonic-gate extern caddr_t i86devmap(pfn_t, pgcnt_t, uint_t); 1547c478bd9Sstevel@tonic-gate extern page_t *page_numtopp_alloc(pfn_t pfnum); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate extern void hwblkclr(void *, size_t); 1577c478bd9Sstevel@tonic-gate extern void hwblkpagecopy(const void *, void *); 158ae115bc7Smrj extern void page_copy_no_xmm(void *dst, void *src); 159ae115bc7Smrj extern void block_zero_no_xmm(void *dst, int len); 160ae115bc7Smrj #define BLOCKZEROALIGN (4 * sizeof (void *)) 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate extern void (*kcpc_hw_enable_cpc_intr)(void); 1637c478bd9Sstevel@tonic-gate 164ae115bc7Smrj extern void init_desctbls(void); 1657c478bd9Sstevel@tonic-gate 1669acbbeafSnn extern user_desc_t *cpu_get_gdt(void); 1679acbbeafSnn 168ae115bc7Smrj extern void switch_sp_and_call(void *, void (*)(uint_t, uint_t), uint_t, 169ae115bc7Smrj uint_t); 1707c478bd9Sstevel@tonic-gate extern hrtime_t (*gethrtimef)(void); 1717c478bd9Sstevel@tonic-gate extern hrtime_t (*gethrtimeunscaledf)(void); 1727c478bd9Sstevel@tonic-gate extern void (*scalehrtimef)(hrtime_t *); 173113b131bSEric Saxe extern uint64_t (*unscalehrtimef)(hrtime_t); 1747c478bd9Sstevel@tonic-gate extern void (*gethrestimef)(timestruc_t *); 1757c478bd9Sstevel@tonic-gate 176ae115bc7Smrj extern void av_dispatch_softvect(uint_t); 177ae115bc7Smrj extern void av_dispatch_autovect(uint_t); 178ae115bc7Smrj extern uint_t atomic_btr32(uint32_t *, uint_t); 179ae115bc7Smrj extern uint_t bsrw_insn(uint16_t); 180ae115bc7Smrj extern int sys_rtt_common(struct regs *); 181ae115bc7Smrj extern void fakesoftint(void); 182ae115bc7Smrj 183843e1988Sjohnlev extern void *plat_traceback(void *); 184ae115bc7Smrj 1853ce2fcdcSRobert Mustacchi /* 186425251fdSSam Gwydir * The following two macros are the four byte instruction sequence of stac, nop 187425251fdSSam Gwydir * and clac, nop. These are used in startup_smap() and hotinline_smap() as a 188425251fdSSam Gwydir * part of properly setting up the valid instructions. For more information on 189f0089e39SRichard Lowe * SMAP, see uts/intel/ml/copy.s, uts/i86pc/os/machdep.c and 190425251fdSSam Gwydir * uts/common/os/modctl.c. 191425251fdSSam Gwydir * 192425251fdSSam Gwydir * Note that smap_disable and smap_enable are resolved to stubs at compile time, 193425251fdSSam Gwydir * but inlined at runtime by do_hotinlines() in uts/i86pc/os/machdep.c. 1943ce2fcdcSRobert Mustacchi */ 195425251fdSSam Gwydir #define SMAP_CLAC_INSTR 0x90ca010f 196425251fdSSam Gwydir #define SMAP_STAC_INSTR 0x90cb010f 1973ce2fcdcSRobert Mustacchi extern void smap_disable(void); 1983ce2fcdcSRobert Mustacchi extern void smap_enable(void); 1993ce2fcdcSRobert Mustacchi 200843e1988Sjohnlev #if defined(__xpv) 201843e1988Sjohnlev extern void xen_init_callbacks(void); 202843e1988Sjohnlev extern void xen_set_callback(void (*)(void), uint_t, uint_t); 203843e1988Sjohnlev extern void xen_printf(const char *, ...); 204843e1988Sjohnlev #define cpr_dprintf xen_printf 205843e1988Sjohnlev extern int xpv_panicking; 206843e1988Sjohnlev #define IN_XPV_PANIC() (xpv_panicking > 0) 207843e1988Sjohnlev #else 208ae115bc7Smrj extern void setup_mca(void); 2091d03c31eSjohnlev extern void pat_sync(void); 210247dbb3dSsudheer extern void patch_tsc_read(int); 21122cc0e45SBill Holler #if defined(__amd64) && !defined(__xpv) 21222cc0e45SBill Holler extern void patch_memops(uint_t); 21322cc0e45SBill Holler #endif /* defined(__amd64) && !defined(__xpv) */ 2147af88ac7SKuriakose Kuruvilla extern void setup_xfem(void); 215ae115bc7Smrj #define cpr_dprintf prom_printf 216843e1988Sjohnlev #define IN_XPV_PANIC() (__lintzero) 217843e1988Sjohnlev #endif 218ae115bc7Smrj 2197c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2207c478bd9Sstevel@tonic-gate 221ae115bc7Smrj #if defined(_KERNEL) || defined(_BOOT) 222ae115bc7Smrj extern uint8_t inb(int port); 223ae115bc7Smrj extern void outb(int port, uint8_t value); 224ae115bc7Smrj #endif 225ae115bc7Smrj 2267c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2277c478bd9Sstevel@tonic-gate } 2287c478bd9Sstevel@tonic-gate #endif 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate #endif /* _SYS_ARCHSYSTM_H */ 231