xref: /illumos-gate/usr/src/uts/intel/sys/archsystm.h (revision 6a604193b70017bd933cd973200b3f13803674b2)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_ARCHSYSTM_H
27 #define	_SYS_ARCHSYSTM_H
28 
29 /*
30  * A selection of ISA-dependent interfaces
31  */
32 
33 #include <vm/seg_enum.h>
34 #include <vm/page.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #ifdef _KERNEL
41 
42 extern greg_t getfp(void);
43 extern int getpil(void);
44 
45 extern ulong_t getcr0(void);
46 extern void setcr0(ulong_t);
47 extern ulong_t getcr2(void);
48 extern void iommu_cpu_nop(void);
49 extern void clflush_insn(caddr_t addr);
50 extern void mfence_insn(void);
51 
52 #if defined(__i386)
53 extern uint16_t getgs(void);
54 extern void setgs(uint16_t);
55 
56 extern void patch_sse(void);
57 extern void patch_sse2(void);
58 #endif
59 
60 extern void cli(void);
61 extern void sti(void);
62 
63 extern void tenmicrosec(void);
64 
65 extern void restore_int_flag(ulong_t);
66 extern void intr_restore(ulong_t);
67 extern ulong_t clear_int_flag(void);
68 extern ulong_t intr_clear(void);
69 extern ulong_t getflags(void);
70 extern int interrupts_enabled(void);
71 
72 extern void int3(void);
73 extern void int18(void);
74 extern void int20(void);
75 extern void int_cmci(void);
76 
77 #if defined(__amd64)
78 extern void sys_syscall();
79 extern void sys_syscall32();
80 extern void sys_lcall32();
81 extern void sys_syscall_int();
82 extern void brand_sys_syscall();
83 extern void brand_sys_syscall32();
84 extern void brand_sys_syscall_int();
85 extern int update_sregs();
86 extern void reset_sregs();
87 #elif defined(__i386)
88 extern void sys_call();
89 extern void brand_sys_call();
90 #endif
91 extern void sys_sysenter();
92 extern void _sys_sysenter_post_swapgs();
93 extern void brand_sys_sysenter();
94 extern void _brand_sys_sysenter_post_swapgs();
95 
96 extern void dosyscall(void);
97 
98 extern void bind_hwcap(void);
99 
100 extern uint16_t inw(int port);
101 extern uint32_t inl(int port);
102 extern void outw(int port, uint16_t value);
103 extern void outl(int port, uint32_t value);
104 
105 extern void pc_reset(void) __NORETURN;
106 extern void efi_reset(void) __NORETURN;
107 extern void reset(void) __NORETURN;
108 extern int goany(void);
109 
110 extern void setgregs(klwp_t *, gregset_t);
111 extern void getgregs(klwp_t *, gregset_t);
112 extern void setfpregs(klwp_t *, fpregset_t *);
113 extern void getfpregs(klwp_t *, fpregset_t *);
114 
115 #if defined(_SYSCALL32_IMPL)
116 extern void getgregs32(klwp_t *, gregset32_t);
117 extern void setfpregs32(klwp_t *, fpregset32_t *);
118 extern void getfpregs32(klwp_t *, fpregset32_t *);
119 #endif
120 
121 struct fpu_ctx;
122 
123 extern void fp_free(struct fpu_ctx *, int);
124 extern void fp_save(struct fpu_ctx *);
125 extern void fp_restore(struct fpu_ctx *);
126 
127 extern int fpu_pentium_fdivbug;
128 
129 extern void sep_save(void *);
130 extern void sep_restore(void *);
131 
132 extern void brand_interpositioning_enable(void);
133 extern void brand_interpositioning_disable(void);
134 
135 struct regs;
136 
137 extern int instr_size(struct regs *, caddr_t *, enum seg_rw);
138 
139 extern void realsigprof(int, int);
140 
141 extern int enable_cbcp; /* patchable in /etc/system */
142 
143 extern uint_t cpu_hwcap_flags;
144 extern uint_t cpu_freq;
145 extern uint64_t cpu_freq_hz;
146 
147 extern int use_sse_pagecopy;
148 extern int use_sse_pagezero;
149 extern int use_sse_copy;
150 
151 extern caddr_t i86devmap(pfn_t, pgcnt_t, uint_t);
152 extern page_t *page_numtopp_alloc(pfn_t pfnum);
153 
154 extern void hwblkclr(void *, size_t);
155 extern void hwblkpagecopy(const void *, void *);
156 extern void page_copy_no_xmm(void *dst, void *src);
157 extern void block_zero_no_xmm(void *dst, int len);
158 #define	BLOCKZEROALIGN (4 * sizeof (void *))
159 
160 extern void (*kcpc_hw_enable_cpc_intr)(void);
161 
162 extern void init_desctbls(void);
163 
164 extern user_desc_t *cpu_get_gdt(void);
165 
166 extern void switch_sp_and_call(void *, void (*)(uint_t, uint_t), uint_t,
167 	uint_t);
168 extern hrtime_t (*gethrtimef)(void);
169 extern hrtime_t (*gethrtimeunscaledf)(void);
170 extern void (*scalehrtimef)(hrtime_t *);
171 extern void (*gethrestimef)(timestruc_t *);
172 
173 extern void av_dispatch_softvect(uint_t);
174 extern void av_dispatch_autovect(uint_t);
175 extern uint_t atomic_btr32(uint32_t *, uint_t);
176 extern uint_t bsrw_insn(uint16_t);
177 extern int sys_rtt_common(struct regs *);
178 extern void fakesoftint(void);
179 
180 extern void *plat_traceback(void *);
181 
182 #if defined(__xpv)
183 extern void xen_init_callbacks(void);
184 extern void xen_set_callback(void (*)(void), uint_t, uint_t);
185 extern void xen_printf(const char *, ...);
186 #define	cpr_dprintf xen_printf
187 extern int xpv_panicking;
188 #define	IN_XPV_PANIC() (xpv_panicking > 0)
189 #else
190 extern void setup_mca(void);
191 extern void pat_sync(void);
192 extern void patch_tsc_read(int);
193 #define	cpr_dprintf prom_printf
194 #define	IN_XPV_PANIC() (__lintzero)
195 #endif
196 
197 #endif /* _KERNEL */
198 
199 #if defined(_KERNEL) || defined(_BOOT)
200 extern uint8_t inb(int port);
201 extern void outb(int port, uint8_t value);
202 #endif
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif	/* _SYS_ARCHSYSTM_H */
209