1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2019 Joyent, Inc. 25 */ 26 27 #ifndef _SYS_ARCHSYSTM_H 28 #define _SYS_ARCHSYSTM_H 29 30 /* 31 * A selection of ISA-dependent interfaces 32 */ 33 34 #include <vm/seg_enum.h> 35 #include <vm/page.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #ifdef _KERNEL 42 43 extern greg_t getfp(void); 44 extern int getpil(void); 45 46 extern ulong_t getcr0(void); 47 extern void setcr0(ulong_t); 48 extern ulong_t getcr8(void); 49 extern void setcr8(ulong_t); 50 extern ulong_t getcr2(void); 51 extern void clflush_insn(caddr_t addr); 52 extern void mfence_insn(void); 53 54 #if defined(__i386) 55 extern uint16_t getgs(void); 56 extern void setgs(uint16_t); 57 58 #endif 59 60 extern kmem_cache_t *fpsave_cachep; 61 62 extern void cli(void); 63 extern void sti(void); 64 65 extern void tenmicrosec(void); 66 67 extern void restore_int_flag(ulong_t); 68 extern void intr_restore(ulong_t); 69 extern ulong_t clear_int_flag(void); 70 extern ulong_t intr_clear(void); 71 extern ulong_t getflags(void); 72 extern int interrupts_enabled(void); 73 74 extern void int3(void); 75 extern void int18(void); 76 extern void int20(void); 77 extern void int_cmci(void); 78 79 #if defined(__amd64) 80 extern void sys_syscall(), tr_sys_syscall(); 81 extern void sys_syscall32(), tr_sys_syscall32(); 82 extern void sys_lcall32(); 83 extern void sys_syscall_int(); 84 extern void tr_sys_syscall_int(); 85 extern void brand_sys_syscall(), tr_brand_sys_syscall(); 86 extern void brand_sys_syscall32(), tr_brand_sys_syscall32(); 87 extern void brand_sys_syscall_int(), tr_brand_sys_syscall_int(); 88 extern int update_sregs(); 89 extern void reset_sregs(); 90 #elif defined(__i386) 91 extern void sys_call(); 92 extern void tr_sys_call(); 93 extern void brand_sys_call(); 94 #endif 95 extern void sys_sysenter(); 96 extern void tr_sys_sysenter(); 97 extern void brand_sys_sysenter(); 98 extern void tr_brand_sys_sysenter(); 99 100 extern void dosyscall(void); 101 102 extern void bind_hwcap(void); 103 104 extern uint16_t inw(int port); 105 extern uint32_t inl(int port); 106 extern void outw(int port, uint16_t value); 107 extern void outl(int port, uint32_t value); 108 109 extern void pc_reset(void) __NORETURN; 110 extern void efi_reset(void) __NORETURN; 111 extern void reset(void) __NORETURN; 112 extern int goany(void); 113 114 extern void setgregs(klwp_t *, gregset_t); 115 extern void getgregs(klwp_t *, gregset_t); 116 extern void setfpregs(klwp_t *, fpregset_t *); 117 extern void getfpregs(klwp_t *, fpregset_t *); 118 119 #if defined(_SYSCALL32_IMPL) 120 extern void getgregs32(klwp_t *, gregset32_t); 121 extern void setfpregs32(klwp_t *, fpregset32_t *); 122 extern void getfpregs32(klwp_t *, fpregset32_t *); 123 #endif 124 125 struct fpu_ctx; 126 127 extern void fp_free(struct fpu_ctx *); 128 extern void fp_save(struct fpu_ctx *); 129 extern void fp_restore(struct fpu_ctx *); 130 131 extern int fpu_pentium_fdivbug; 132 133 extern void sep_save(void *); 134 extern void sep_restore(void *); 135 136 extern void brand_interpositioning_enable(void *); 137 extern void brand_interpositioning_disable(void *); 138 139 struct regs; 140 141 extern int instr_size(struct regs *, caddr_t *, enum seg_rw); 142 143 extern int enable_cbcp; /* patchable in /etc/system */ 144 145 extern uint_t cpu_hwcap_flags; 146 extern uint_t cpu_freq; 147 extern uint64_t cpu_freq_hz; 148 149 extern int use_sse_pagecopy; 150 extern int use_sse_pagezero; 151 extern int use_sse_copy; 152 153 extern caddr_t i86devmap(pfn_t, pgcnt_t, uint_t); 154 extern page_t *page_numtopp_alloc(pfn_t pfnum); 155 156 extern void hwblkclr(void *, size_t); 157 extern void hwblkpagecopy(const void *, void *); 158 extern void page_copy_no_xmm(void *dst, void *src); 159 extern void block_zero_no_xmm(void *dst, int len); 160 #define BLOCKZEROALIGN (4 * sizeof (void *)) 161 162 extern void (*kcpc_hw_enable_cpc_intr)(void); 163 164 extern void init_desctbls(void); 165 166 extern user_desc_t *cpu_get_gdt(void); 167 168 extern void switch_sp_and_call(void *, void (*)(uint_t, uint_t), uint_t, 169 uint_t); 170 extern hrtime_t (*gethrtimef)(void); 171 extern hrtime_t (*gethrtimeunscaledf)(void); 172 extern void (*scalehrtimef)(hrtime_t *); 173 extern uint64_t (*unscalehrtimef)(hrtime_t); 174 extern void (*gethrestimef)(timestruc_t *); 175 176 extern void av_dispatch_softvect(uint_t); 177 extern void av_dispatch_autovect(uint_t); 178 extern uint_t atomic_btr32(uint32_t *, uint_t); 179 extern uint_t bsrw_insn(uint16_t); 180 extern int sys_rtt_common(struct regs *); 181 extern void fakesoftint(void); 182 183 extern void *plat_traceback(void *); 184 185 /* 186 * The following two macros are the four byte instruction sequence of stac, nop 187 * and clac, nop. These are used in startup_smap() and hotinline_smap() as a 188 * part of properly setting up the valid instructions. For more information on 189 * SMAP, see uts/intel/ml/copy.s, uts/i86pc/os/machdep.c and 190 * uts/common/os/modctl.c. 191 * 192 * Note that smap_disable and smap_enable are resolved to stubs at compile time, 193 * but inlined at runtime by do_hotinlines() in uts/i86pc/os/machdep.c. 194 */ 195 #define SMAP_CLAC_INSTR 0x90ca010f 196 #define SMAP_STAC_INSTR 0x90cb010f 197 extern void smap_disable(void); 198 extern void smap_enable(void); 199 200 #if defined(__xpv) 201 extern void xen_init_callbacks(void); 202 extern void xen_set_callback(void (*)(void), uint_t, uint_t); 203 extern void xen_printf(const char *, ...); 204 #define cpr_dprintf xen_printf 205 extern int xpv_panicking; 206 #define IN_XPV_PANIC() (xpv_panicking > 0) 207 #else 208 extern void setup_mca(void); 209 extern void pat_sync(void); 210 extern void patch_tsc_read(int); 211 #if defined(__amd64) && !defined(__xpv) 212 extern void patch_memops(uint_t); 213 #endif /* defined(__amd64) && !defined(__xpv) */ 214 extern void setup_xfem(void); 215 #define cpr_dprintf prom_printf 216 #define IN_XPV_PANIC() (__lintzero) 217 #endif 218 219 #endif /* _KERNEL */ 220 221 #if defined(_KERNEL) || defined(_BOOT) 222 extern uint8_t inb(int port); 223 extern void outb(int port, uint8_t value); 224 #endif 225 226 #ifdef __cplusplus 227 } 228 #endif 229 230 #endif /* _SYS_ARCHSYSTM_H */ 231