1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
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.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-06-12 14:58:17 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2022-08-31 18:56:49 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <sys/systm.h> /* For cpu_ticks(). */
|
|
|
|
#endif
|
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>
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
#define cpu_exec(p) /* nothing */
|
2004-08-03 18:44:27 +00:00
|
|
|
#define cpu_swapin(p) /* nothing */
|
2001-09-12 08:38:13 +00:00
|
|
|
#define cpu_getstack(td) ((td)->td_frame->tf_esp)
|
2004-08-03 18:44:27 +00:00
|
|
|
#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))
|
|
|
|
#define cpu_spinwait() ia32_pause()
|
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)
|
|
|
|
|
2013-07-28 18:44:17 +00:00
|
|
|
#ifdef _KERNEL
|
2013-09-06 22:17:02 +00:00
|
|
|
/*
|
|
|
|
* Struct containing pointers to CPU management functions whose
|
|
|
|
* implementation is run time selectable. Selection can be made,
|
|
|
|
* for example, based on detection of a particular CPU variant or
|
|
|
|
* hypervisor environment.
|
|
|
|
*/
|
|
|
|
struct cpu_ops {
|
2013-09-20 22:59:22 +00:00
|
|
|
void (*cpu_init)(void);
|
|
|
|
void (*cpu_resume)(void);
|
2013-09-06 22:17:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct cpu_ops cpu_ops;
|
1997-10-27 17:23:18 +00:00
|
|
|
extern char btext[];
|
|
|
|
extern char etext[];
|
1997-04-07 07:16:06 +00:00
|
|
|
|
2003-08-16 16:57:57 +00:00
|
|
|
void cpu_halt(void);
|
2018-11-05 22:54:03 +00:00
|
|
|
void cpu_lock_delay(void);
|
2003-08-16 16:57:57 +00:00
|
|
|
void cpu_reset(void);
|
2002-03-20 05:48:58 +00:00
|
|
|
void fork_trampoline(void);
|
2000-11-21 19:55:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return contents of in-cpu fast counter as a sort of "bogo-time"
|
2003-02-05 08:55:10 +00:00
|
|
|
* for random-harvesting purposes.
|
2000-11-21 19:55:21 +00:00
|
|
|
*/
|
2011-03-14 23:30:14 +00:00
|
|
|
static __inline uint64_t
|
2000-11-21 19:55:21 +00:00
|
|
|
get_cyclecount(void)
|
|
|
|
{
|
|
|
|
|
2011-04-04 22:56:33 +00:00
|
|
|
return (cpu_ticks());
|
2000-11-21 19:55:21 +00:00
|
|
|
}
|
|
|
|
|
1993-10-08 20:51:00 +00:00
|
|
|
#endif
|
1994-09-18 21:37:56 +00:00
|
|
|
|
|
|
|
#endif /* !_MACHINE_CPU_H_ */
|