git repos for lemote 502 board
[pmon-gdium.git] / sys / arch / i386 / include / cpu.h
blobbc3582ad7136b20872953b6c89651c73ae74735a
1 /* $OpenBSD: cpu.h,v 1.41 2002/03/14 01:26:33 millert Exp $ */
2 /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
4 /*-
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
39 * @(#)cpu.h 5.4 (Berkeley) 5/9/91
42 #ifndef _I386_CPU_H_
43 #define _I386_CPU_H_
46 * Definitions unique to i386 cpu support.
48 #include <machine/psl.h>
49 #include <machine/frame.h>
50 #include <machine/segments.h>
53 * definitions of cpu-dependent requirements
54 * referenced in generic code
56 #define cpu_swapin(p) /* nothing */
59 * Arguments to hardclock, softclock and statclock
60 * encapsulate the previous machine state in an opaque
61 * clockframe; for now, use generic intrframe.
63 * XXX intrframe has a lot of gunk we don't need.
65 #define clockframe intrframe
67 #define CLKF_USERMODE(frame) USERMODE((frame)->if_cs, (frame)->if_eflags)
68 #define CLKF_BASEPRI(frame) ((frame)->if_ppl == 0)
69 #define CLKF_PC(frame) ((frame)->if_eip)
70 #define CLKF_INTR(frame) (IDXSEL((frame)->if_cs) == GICODE_SEL)
73 * Preempt the current process if in interrupt from user mode,
74 * or after the current trap/syscall if in system mode.
76 int want_resched; /* resched() was called */
77 #define need_resched() (want_resched = 1, setsoftast())
80 * Give a profiling tick to the current process when the user profiling
81 * buffer pages are invalid. On the i386, request an ast to send us
82 * through trap(), marking the proc as needing a profiling tick.
84 #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, setsoftast())
87 * Notify the current process (p) that it has a signal pending,
88 * process as soon as possible.
90 #define signotify(p) setsoftast()
93 * We need a machine-independent name for this.
95 #define DELAY(x) delay(x)
96 void delay(int);
98 #if defined(I586_CPU) || defined(I686_CPU)
100 * High resolution clock support (Pentium only)
102 void calibrate_cyclecounter(void);
103 #ifndef HZ
104 extern u_quad_t pentium_base_tsc;
105 #define CPU_CLOCKUPDATE(otime, ntime) \
106 do { \
107 if (pentium_mhz) { \
108 __asm __volatile("cli\n" \
109 "movl (%3), %%eax\n" \
110 "movl %%eax, (%2)\n" \
111 "movl 4(%3), %%eax\n" \
112 "movl %%eax, 4(%2)\n" \
113 ".byte 0xf, 0x31\n" \
114 "sti\n" \
115 "#%0 %1 %2 %3" \
116 : "=m" (*otime), \
117 "=A" (pentium_base_tsc) \
118 : "c" (otime), "b" (ntime)); \
120 else { \
121 *(otime) = *(ntime); \
123 } while (0)
124 #endif
125 #endif
128 * pull in #defines for kinds of processors
130 #include <machine/cputypes.h>
132 struct cpu_nocpuid_nameclass {
133 int cpu_vendor;
134 const char *cpu_vendorname;
135 const char *cpu_name;
136 int cpu_class;
137 void (*cpu_setup)(const char *, int, int);
140 struct cpu_cpuid_nameclass {
141 const char *cpu_id;
142 int cpu_vendor;
143 const char *cpu_vendorname;
144 struct cpu_cpuid_family {
145 int cpu_class;
146 const char *cpu_models[CPU_MAXMODEL+2];
147 void (*cpu_setup)(const char *, int, int);
148 } cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1];
151 struct cpu_cpuid_feature {
152 int feature_bit;
153 const char *feature_name;
156 #ifdef _KERNEL
157 extern int cpu;
158 extern int cpu_class;
159 extern int cpu_feature;
160 extern int cpu_apmwarn;
161 extern int cpu_apmhalt;
162 extern int cpuid_level;
163 extern const struct cpu_nocpuid_nameclass i386_nocpuid_cpus[];
164 extern const struct cpu_cpuid_nameclass i386_cpuid_cpus[];
166 #if defined(I586_CPU) || defined(I686_CPU)
167 extern int pentium_mhz;
168 #endif
170 #ifdef I586_CPU
171 /* F00F bug fix stuff for pentium cpu */
172 extern int cpu_f00f_bug;
173 void fix_f00f(void);
174 #endif
176 #ifndef PMON
177 /* dkcsum.c */
178 void dkcsumattach(void);
180 /* machdep.c */
181 void dumpconf(void);
182 void cpu_reset(void);
183 void i386_proc0_tss_ldt_init(void);
185 /* locore.s */
186 struct region_descriptor;
187 void lgdt(struct region_descriptor *);
188 void fillw(short, void *, size_t);
189 short fusword(u_short *);
190 int susword(u_short *t, u_short);
192 struct pcb;
193 void savectx(struct pcb *);
194 void switch_exit(struct proc *);
195 void proc_trampoline(void);
197 /* clock.c */
198 void initrtclock(void);
199 void startrtclock(void);
200 void rtcdrain(void *);
202 /* npx.c */
203 void npxdrop(void);
204 void npxsave(void);
206 #if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE)
207 /* math_emulate.c */
208 int math_emulate(struct trapframe *);
209 #endif
211 #ifdef USER_LDT
212 /* sys_machdep.h */
213 void i386_user_cleanup(struct pcb *);
214 int i386_get_ldt(struct proc *, void *, register_t *);
215 int i386_set_ldt(struct proc *, void *, register_t *);
216 #endif
218 /* isa_machdep.c */
219 void isa_defaultirq(void);
220 int isa_nmi(void);
222 /* pmap.c */
223 void pmap_bootstrap(vm_offset_t);
225 /* vm_machdep.c */
226 int kvtop(caddr_t);
228 #ifdef VM86
229 /* vm86.c */
230 void vm86_gpfault(struct proc *, int);
231 #endif /* VM86 */
233 #ifdef GENERIC
234 /* swapgeneric.c */
235 void setconf(void);
236 #endif /* GENERIC */
237 #endif /* !PMON */
238 #endif /* _KERNEL */
241 * CTL_MACHDEP definitions.
243 #define CPU_CONSDEV 1 /* dev_t: console terminal device */
244 #define CPU_BIOS 2 /* BIOS variables */
245 #define CPU_BLK2CHR 3 /* convert blk maj into chr one */
246 #define CPU_CHR2BLK 4 /* convert chr maj into blk one */
247 #define CPU_ALLOWAPERTURE 5 /* allow mmap of /dev/xf86 */
248 #define CPU_CPUVENDOR 6 /* cpuid vendor string */
249 #define CPU_CPUID 7 /* cpuid */
250 #define CPU_CPUFEATURE 8 /* cpuid features */
251 #define CPU_APMWARN 9 /* APM battery warning percentage */
252 #define CPU_KBDRESET 10 /* keyboard reset under pcvt */
253 #define CPU_APMHALT 11 /* halt -p hack */
254 #define CPU_MAXID 12 /* number of valid machdep ids */
256 #define CTL_MACHDEP_NAMES { \
257 { 0, 0 }, \
258 { "console_device", CTLTYPE_STRUCT }, \
259 { "bios", CTLTYPE_INT }, \
260 { "blk2chr", CTLTYPE_STRUCT }, \
261 { "chr2blk", CTLTYPE_STRUCT }, \
262 { "allowaperture", CTLTYPE_INT }, \
263 { "cpuvendor", CTLTYPE_STRING }, \
264 { "cpuid", CTLTYPE_INT }, \
265 { "cpufeature", CTLTYPE_INT }, \
266 { "apmwarn", CTLTYPE_INT }, \
267 { "kbdreset", CTLTYPE_INT }, \
268 { "apmhalt", CTLTYPE_INT }, \
271 static __inline int get_count __P((void));
272 static __inline int
273 get_count()
275 #if 0
276 int _decr_;
278 __asm__ volatile("mfspr %0, 22\n" : "=r"(_decr_));
279 return( 0 - _decr_);
280 #else
281 return (0);
282 #endif
285 #endif /* !_I386_CPU_H_ */