180708Sjake/*-
282899Sjake * Copyright (c) 1990 The Regents of the University of California.
380708Sjake * All rights reserved.
480708Sjake *
582899Sjake * This code is derived from software contributed to Berkeley by
682899Sjake * William Jolitz.
782899Sjake *
880708Sjake * Redistribution and use in source and binary forms, with or without
980708Sjake * modification, are permitted provided that the following conditions
1080708Sjake * are met:
1180708Sjake * 1. Redistributions of source code must retain the above copyright
1280708Sjake *    notice, this list of conditions and the following disclaimer.
1380708Sjake * 2. Redistributions in binary form must reproduce the above copyright
1480708Sjake *    notice, this list of conditions and the following disclaimer in the
1580708Sjake *    documentation and/or other materials provided with the distribution.
1682899Sjake * 4. Neither the name of the University nor the names of its contributors
1782899Sjake *    may be used to endorse or promote products derived from this software
1882899Sjake *    without specific prior written permission.
1980708Sjake *
2082899Sjake * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2180708Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2280708Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2382899Sjake * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2480708Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2580708Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2680708Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2780708Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2880708Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2980708Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3080708Sjake * SUCH DAMAGE.
3180708Sjake *
3282899Sjake *	from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
3382899Sjake *	from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29
3480708Sjake * $FreeBSD: releng/10.3/sys/sparc64/include/cpu.h 253750 2013-07-28 18:44:17Z avg $
3580708Sjake */
3680708Sjake
3780708Sjake#ifndef	_MACHINE_CPU_H_
3880708Sjake#define	_MACHINE_CPU_H_
3980708Sjake
4080708Sjake#include <machine/frame.h>
4182899Sjake#include <machine/tstate.h>
4280708Sjake
4380709Sjake#define	TRAPF_PC(tfp)		((tfp)->tf_tpc)
4482899Sjake#define	TRAPF_USERMODE(tfp)	(((tfp)->tf_tstate & TSTATE_PRIV) == 0)
4580708Sjake
4683366Sjulian#define	cpu_getstack(td)	((td)->td_frame->tf_sp)
4783366Sjulian#define	cpu_setstack(td, sp)	((td)->td_frame->tf_sp = (sp))
48133084Smux#define	cpu_spinwait()		/* nothing */
4980709Sjake
50253750Savg#ifdef _KERNEL
51253750Savg
52100783Sjakeextern	char btext[];
53100783Sjakeextern	char etext[];
54100783Sjake
55204152Smariusvoid	cheetah_init(u_int cpu_impl);
56230628Smariusvoid	cpu_halt(void) __dead2;
57230628Smariusvoid	cpu_reset(void) __dead2;
5880709Sjakevoid	fork_trampoline(void);
59118990Smarcelvoid	swi_vm(void *v);
60223719Smariusvoid	zeus_init(u_int cpu_impl);
6180709Sjake
6280708Sjakestatic __inline u_int64_t
6380708Sjakeget_cyclecount(void)
6480708Sjake{
6580709Sjake
6688619Sjake	return (rd(tick));
6780708Sjake}
6880708Sjake
6985256Sjake#endif
7085256Sjake
7180708Sjake#endif /* !_MACHINE_CPU_H_ */
72