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