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