cpu.h revision 94751
167Ssundar/* 267Ssundar * Copyright (C) 1995-1997 Wolfgang Solfrank. 3970Sattila * Copyright (C) 1995-1997 TooLs GmbH. 467Ssundar * All rights reserved. 567Ssundar * 667Ssundar * Redistribution and use in source and binary forms, with or without 7970Sattila * modification, are permitted provided that the following conditions 867Ssundar * are met: 967Ssundar * 1. Redistributions of source code must retain the above copyright 10970Sattila * notice, this list of conditions and the following disclaimer. 1167Ssundar * 2. Redistributions in binary form must reproduce the above copyright 1267Ssundar * notice, this list of conditions and the following disclaimer in the 1367Ssundar * documentation and/or other materials provided with the distribution. 14970Sattila * 3. All advertising materials mentioning features or use of this software 1567Ssundar * must display the following acknowledgement: 1667Ssundar * This product includes software developed by TooLs GmbH. 1767Ssundar * 4. The name of TooLs GmbH may not be used to endorse or promote products 18970Sattila * derived from this software without specific prior written permission. 1967Ssundar * 2067Ssundar * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2167Ssundar * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2267Ssundar * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2367Ssundar * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2467Ssundar * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2567Ssundar * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2667Ssundar * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2767Ssundar * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2867Ssundar * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2967Ssundar * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3067Ssundar * 3167Ssundar * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ 3267Ssundar * $FreeBSD: head/sys/powerpc/include/cpu.h 94751 2002-04-15 12:02:43Z benno $ 3367Ssundar */ 3467Ssundar 3567Ssundar#ifndef _MACHINE_CPU_H_ 3667Ssundar#define _MACHINE_CPU_H_ 3767Ssundar 3867Ssundar#include <machine/frame.h> 3967Ssundar#include <machine/pcb.h> 4067Ssundar#include <machine/psl.h> 4167Ssundar 4267Ssundar#define CLKF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 4367Ssundar#define CLKF_BASEPRI(frame) ((frame)->pri == 0) 4467Ssundar#define CLKF_PC(frame) ((frame)->srr0) 4567Ssundar#define CLKF_INTR(frame) ((frame)->depth > 0) 4667Ssundar 4767Ssundar#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 4867Ssundar#define TRAPF_PC(frame) ((frame)->srr0) 4967Ssundar 5067Ssundar#define cpu_swapout(p) 51#define cpu_number() 0 52 53#define DELAY(n) delay(n) 54 55extern char bootpath[]; 56 57#if defined(_KERNEL) || defined(_STANDALONE) 58#define CACHELINESIZE 32 59#endif 60 61extern void __syncicache(void *, int); 62 63/* 64 * CTL_MACHDEP definitions. 65 */ 66#define CPU_CACHELINE 1 67#define CPU_MAXID 2 68#define CPU_CONSDEV 1 69 70#define CTL_MACHDEP_NAMES { \ 71 { 0, 0 }, \ 72 { "cachelinesize", CTLTYPE_INT }, \ 73} 74 75static __inline u_int64_t 76get_cyclecount(void) 77{ 78 u_int32_t upper, lower; 79 u_int64_t time; 80 81 __asm __volatile( 82 "mftb %0\n" 83 "mftbu %1" 84 : "=r" (lower), "=r" (upper)); 85 86 time = (u_int64_t)upper; 87 time = (time << 32) + lower; 88 return (time); 89} 90 91#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) 92 93void savectx(struct pcb *); 94void fork_trampoline(void); 95 96#endif /* _MACHINE_CPU_H_ */ 97