cpu.h revision 92842
1296417Sdim/* 2275072Semaste * Copyright (C) 1995-1997 Wolfgang Solfrank. 3275072Semaste * Copyright (C) 1995-1997 TooLs GmbH. 4275072Semaste * All rights reserved. 5275072Semaste * 6275072Semaste * Redistribution and use in source and binary forms, with or without 7275072Semaste * modification, are permitted provided that the following conditions 8275072Semaste * are met: 9275072Semaste * 1. Redistributions of source code must retain the above copyright 10280031Sdim * notice, this list of conditions and the following disclaimer. 11275072Semaste * 2. Redistributions in binary form must reproduce the above copyright 12280031Sdim * notice, this list of conditions and the following disclaimer in the 13280031Sdim * documentation and/or other materials provided with the distribution. 14280031Sdim * 3. All advertising materials mentioning features or use of this software 15280031Sdim * must display the following acknowledgement: 16280031Sdim * This product includes software developed by TooLs GmbH. 17280031Sdim * 4. The name of TooLs GmbH may not be used to endorse or promote products 18280031Sdim * derived from this software without specific prior written permission. 19280031Sdim * 20275072Semaste * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 21275072Semaste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22275072Semaste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23275072Semaste * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24275072Semaste * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25275072Semaste * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26275072Semaste * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27275072Semaste * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28275072Semaste * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29275072Semaste * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30280031Sdim * 31280031Sdim * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ 32280031Sdim * $FreeBSD: head/sys/powerpc/include/cpu.h 92842 2002-03-20 23:17:50Z alfred $ 33280031Sdim */ 34280031Sdim 35280031Sdim#ifndef _MACHINE_CPU_H_ 36280031Sdim#define _MACHINE_CPU_H_ 37280031Sdim 38280031Sdim#include <machine/frame.h> 39280031Sdim#include <machine/pcb.h> 40275072Semaste#include <machine/psl.h> 41275072Semaste 42275072Semaste#define CLKF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 43280031Sdim#define CLKF_BASEPRI(frame) ((frame)->pri == 0) 44280031Sdim#define CLKF_PC(frame) ((frame)->srr0) 45280031Sdim#define CLKF_INTR(frame) ((frame)->depth > 0) 46296417Sdim 47275072Semaste#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 48280031Sdim#define TRAPF_PC(frame) ((frame)->srr0) 49280031Sdim 50296417Sdim#define cpu_swapout(p) 51275072Semaste#define cpu_number() 0 52280031Sdim 53280031Sdimvoid delay(int); 54280031Sdim#define DELAY(n) delay(n) 55296417Sdim 56296417Sdimextern char bootpath[]; 57296417Sdim 58280031Sdim#if defined(_KERNEL) || defined(_STANDALONE) 59296417Sdim#define CACHELINESIZE 32 60275072Semaste#endif 61280031Sdim 62280031Sdimextern void __syncicache(void *, int); 63280031Sdim 64280031Sdim/* 65275072Semaste * CTL_MACHDEP definitions. 66280031Sdim */ 67280031Sdim#define CPU_CACHELINE 1 68280031Sdim#define CPU_MAXID 2 69296417Sdim#define CPU_CONSDEV 1 70275072Semaste 71280031Sdim#define CTL_MACHDEP_NAMES { \ 72280031Sdim { 0, 0 }, \ 73280031Sdim { "cachelinesize", CTLTYPE_INT }, \ 74280031Sdim} 75280031Sdim 76280031Sdimstatic __inline u_int64_t 77280031Sdimget_cyclecount(void) 78280031Sdim{ 79280031Sdim u_int32_t upper, lower; 80280031Sdim u_int64_t time; 81 82 __asm __volatile( 83 "mftb %0\n" 84 "mftbu %1" 85 : "=r" (lower), "=r" (upper)); 86 87 time = (u_int64_t)upper; 88 time = (time << 32) + lower; 89 return (time); 90} 91 92#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) 93 94void savectx(struct pcb *); 95void fork_trampoline(void); 96 97#endif /* _MACHINE_CPU_H_ */ 98