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