cpu.h revision 83682
1193240Ssam/*
2193240Ssam * Copyright (C) 1995-1997 Wolfgang Solfrank.
3193240Ssam * Copyright (C) 1995-1997 TooLs GmbH.
4193240Ssam * All rights reserved.
5193240Ssam *
6193240Ssam * Redistribution and use in source and binary forms, with or without
7193240Ssam * modification, are permitted provided that the following conditions
8193240Ssam * are met:
9193240Ssam * 1. Redistributions of source code must retain the above copyright
10193240Ssam *    notice, this list of conditions and the following disclaimer.
11193240Ssam * 2. Redistributions in binary form must reproduce the above copyright
12193240Ssam *    notice, this list of conditions and the following disclaimer in the
13193240Ssam *    documentation and/or other materials provided with the distribution.
14193240Ssam * 3. All advertising materials mentioning features or use of this software
15193240Ssam *    must display the following acknowledgement:
16193240Ssam *	This product includes software developed by TooLs GmbH.
17193240Ssam * 4. The name of TooLs GmbH may not be used to endorse or promote products
18193240Ssam *    derived from this software without specific prior written permission.
19193240Ssam *
20193240Ssam * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
21193240Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22193240Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23193240Ssam * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24193240Ssam * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25193240Ssam * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26193240Ssam * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27193240Ssam * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28193240Ssam * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29193240Ssam * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30193240Ssam *
31193240Ssam *	$NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $
32193240Ssam * $FreeBSD: head/sys/powerpc/include/cpu.h 83682 2001-09-20 00:47:17Z mp $
33193240Ssam */
34193240Ssam
35193240Ssam#ifndef _MACHINE_CPU_H_
36193240Ssam#define	_MACHINE_CPU_H_
37193240Ssam
38193240Ssam#include <machine/frame.h>
39193240Ssam#include <machine/pcb.h>
40234367Sadrian#include <machine/psl.h>
41193240Ssam
42193240Ssam#define	CLKF_USERMODE(frame)	(((frame)->srr1 & PSL_PR) != 0)
43193240Ssam#define	CLKF_BASEPRI(frame)	((frame)->pri == 0)
44193240Ssam#define	CLKF_PC(frame)		((frame)->srr0)
45193240Ssam#define	CLKF_INTR(frame)	((frame)->depth > 0)
46193240Ssam
47193240Ssam#define	TRAPF_USERMODE(frame)	((frame)->srr1 & PSL_PR) != 0)
48193240Ssam#define	TRAPF_PC(frame)		((frame)->srr0)
49193240Ssam
50193240Ssam#define	cpu_swapout(p)
51193240Ssam#define	cpu_number()		0
52193240Ssam
53193240Ssamextern void delay __P((unsigned));
54193240Ssam#define	DELAY(n)		delay(n)
55193240Ssam
56193240Ssamextern int want_resched;
57193240Ssamextern int astpending;
58193240Ssam
59193240Ssamextern char bootpath[];
60193240Ssam
61193240Ssam#if defined(_KERNEL) || defined(_STANDALONE)
62193240Ssam#define	CACHELINESIZE	32
63193240Ssam#endif
64193240Ssam
65193240Ssamextern void __syncicache __P((void *, int));
66193240Ssam
67193240Ssam/*
68193240Ssam * CTL_MACHDEP definitions.
69193240Ssam */
70193240Ssam#define	CPU_CACHELINE	1
71193240Ssam#define	CPU_MAXID	2
72193240Ssam#define CPU_CONSDEV	1
73193240Ssam
74193240Ssam#define	CTL_MACHDEP_NAMES { \
75193240Ssam	{ 0, 0 }, \
76193240Ssam	{ "cachelinesize", CTLTYPE_INT }, \
77193240Ssam}
78193240Ssam
79193240Ssamstatic __inline u_int64_t
80193240Ssamget_cyclecount(void)
81193240Ssam{
82193240Ssam	u_int32_t upper, lower;
83193240Ssam	u_int64_t time;
84193240Ssam
85193240Ssam	__asm __volatile(
86193240Ssam		"mftb %0\n"
87228621Sbschmidt		"mftbu %1"
88228621Sbschmidt		: "=r" (lower), "=r" (upper));
89228621Sbschmidt
90193240Ssam	time = (u_int64_t)upper;
91193240Ssam	time = (time << 32) + lower;
92193240Ssam	return (time);
93193240Ssam}
94193240Ssam
95193240Ssam#define	cpu_getstack(td)	((td)->td_frame->fixreg[1])
96193240Ssam
97193240Ssamvoid	savectx __P((struct pcb *));
98193240Ssam
99193240Ssam#endif	/* _MACHINE_CPU_H_ */
100193240Ssam