1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* William Jolitz.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1993-10-08 20:51:00 +00:00
|
|
|
* from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
1993-11-07 17:43:17 +00:00
|
|
|
#ifndef _MACHINE_CPU_H_
|
1994-09-18 21:37:56 +00:00
|
|
|
#define _MACHINE_CPU_H_
|
1993-11-07 17:43:17 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Definitions unique to i386 cpu support.
|
|
|
|
*/
|
1997-08-09 00:04:06 +00:00
|
|
|
#include <machine/psl.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <machine/frame.h>
|
|
|
|
#include <machine/segments.h>
|
2000-09-07 01:33:02 +00:00
|
|
|
#include <machine/globals.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* definitions of cpu-dependent requirements
|
|
|
|
* referenced in generic code
|
|
|
|
*/
|
|
|
|
#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */
|
|
|
|
|
|
|
|
#define cpu_exec(p) /* nothing */
|
1994-05-25 09:21:21 +00:00
|
|
|
#define cpu_swapin(p) /* nothing */
|
2001-06-29 11:10:41 +00:00
|
|
|
#define cpu_getstack(p) ((p)->p_frame->tf_esp)
|
|
|
|
#define cpu_setstack(p, ap) ((p)->p_frame->tf_esp = (ap))
|
1993-06-12 14:58:17 +00:00
|
|
|
|
2001-02-10 02:20:34 +00:00
|
|
|
#define TRAPF_USERMODE(framep) \
|
|
|
|
((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM))
|
|
|
|
#define TRAPF_PC(framep) ((framep)->tf_eip)
|
|
|
|
|
1997-08-09 00:04:06 +00:00
|
|
|
#define CLKF_USERMODE(framep) \
|
2001-02-10 02:20:34 +00:00
|
|
|
((ISPL((framep)->cf_cs) == SEL_UPL) || ((framep)->cf_eflags & PSL_VM))
|
1994-05-25 09:21:21 +00:00
|
|
|
#define CLKF_PC(framep) ((framep)->cf_eip)
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
/*
|
|
|
|
* CTL_MACHDEP definitions.
|
|
|
|
*/
|
|
|
|
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
|
1996-04-05 03:36:31 +00:00
|
|
|
#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */
|
1996-03-29 14:14:07 +00:00
|
|
|
#define CPU_DISRTCSET 3 /* int: disable resettodr() call */
|
|
|
|
#define CPU_BOOTINFO 4 /* struct: bootinfo */
|
1996-04-05 03:36:31 +00:00
|
|
|
#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */
|
|
|
|
#define CPU_MAXID 6 /* number of valid machdep ids */
|
1994-05-25 09:21:21 +00:00
|
|
|
|
|
|
|
#define CTL_MACHDEP_NAMES { \
|
|
|
|
{ 0, 0 }, \
|
|
|
|
{ "console_device", CTLTYPE_STRUCT }, \
|
1994-09-16 01:05:24 +00:00
|
|
|
{ "adjkerntz", CTLTYPE_INT }, \
|
1994-10-04 18:25:51 +00:00
|
|
|
{ "disable_rtc_set", CTLTYPE_INT }, \
|
1995-07-16 10:33:38 +00:00
|
|
|
{ "bootinfo", CTLTYPE_STRUCT }, \
|
1996-04-05 03:36:31 +00:00
|
|
|
{ "wall_cmos_clock", CTLTYPE_INT }, \
|
1994-05-25 09:21:21 +00:00
|
|
|
}
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1997-10-27 17:23:18 +00:00
|
|
|
extern char btext[];
|
|
|
|
extern char etext[];
|
2001-02-19 03:00:34 +00:00
|
|
|
extern u_int tsc_present;
|
1997-04-07 07:16:06 +00:00
|
|
|
|
|
|
|
void fork_trampoline __P((void));
|
2000-11-21 19:55:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return contents of in-cpu fast counter as a sort of "bogo-time"
|
|
|
|
* for non-critical timing.
|
|
|
|
*/
|
|
|
|
static __inline u_int64_t
|
|
|
|
get_cyclecount(void)
|
|
|
|
{
|
|
|
|
#if defined(I386_CPU) || defined(I486_CPU)
|
|
|
|
struct timespec tv;
|
|
|
|
|
2000-12-02 17:59:41 +00:00
|
|
|
if (!tsc_present) {
|
2000-11-21 19:55:21 +00:00
|
|
|
nanotime(&tv);
|
|
|
|
return (tv.tv_sec * (u_int64_t)1000000000 + tv.tv_nsec);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return (rdtsc());
|
|
|
|
}
|
|
|
|
|
1993-10-08 20:51:00 +00:00
|
|
|
#endif
|
1994-09-18 21:37:56 +00:00
|
|
|
|
|
|
|
#endif /* !_MACHINE_CPU_H_ */
|