cpu.h revision 79036
177957Sbenno/* 277957Sbenno * Copyright (C) 1995-1997 Wolfgang Solfrank. 377957Sbenno * Copyright (C) 1995-1997 TooLs GmbH. 477957Sbenno * All rights reserved. 577957Sbenno * 677957Sbenno * Redistribution and use in source and binary forms, with or without 777957Sbenno * modification, are permitted provided that the following conditions 877957Sbenno * are met: 977957Sbenno * 1. Redistributions of source code must retain the above copyright 1077957Sbenno * notice, this list of conditions and the following disclaimer. 1177957Sbenno * 2. Redistributions in binary form must reproduce the above copyright 1277957Sbenno * notice, this list of conditions and the following disclaimer in the 1377957Sbenno * documentation and/or other materials provided with the distribution. 1477957Sbenno * 3. All advertising materials mentioning features or use of this software 1577957Sbenno * must display the following acknowledgement: 1677957Sbenno * This product includes software developed by TooLs GmbH. 1777957Sbenno * 4. The name of TooLs GmbH may not be used to endorse or promote products 1877957Sbenno * derived from this software without specific prior written permission. 1977957Sbenno * 2077957Sbenno * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2177957Sbenno * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2277957Sbenno * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2377957Sbenno * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2477957Sbenno * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2577957Sbenno * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2677957Sbenno * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2777957Sbenno * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2877957Sbenno * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2977957Sbenno * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3077957Sbenno * 3177957Sbenno * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ 3277957Sbenno * $FreeBSD: head/sys/powerpc/include/cpu.h 79036 2001-07-01 02:38:38Z benno $ 3377957Sbenno */ 3477957Sbenno 3577957Sbenno#ifndef _MACHINE_CPU_H_ 3677957Sbenno#define _MACHINE_CPU_H_ 3777957Sbenno 3877957Sbenno#include <machine/frame.h> 3977957Sbenno#include <machine/pcb.h> 4077957Sbenno#include <machine/psl.h> 4177957Sbenno 4277957Sbenno#define CLKF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 4377957Sbenno#define CLKF_BASEPRI(frame) ((frame)->pri == 0) 4477957Sbenno#define CLKF_PC(frame) ((frame)->srr0) 4577957Sbenno#define CLKF_INTR(frame) ((frame)->depth > 0) 4677957Sbenno 4779036Sbenno#define TRAPF_USERMODE(frame) ((frame)->srr1 & PSL_PR) != 0) 4879036Sbenno#define TRAPF_PC(frame) ((frame)->srr0) 4979036Sbenno 5077957Sbenno#define cpu_swapout(p) 5177957Sbenno#define cpu_number() 0 5277957Sbenno 5377957Sbennoextern void delay __P((unsigned)); 5477957Sbenno#define DELAY(n) delay(n) 5577957Sbenno 5677957Sbennoextern int want_resched; 5777957Sbennoextern int astpending; 5877957Sbenno 5977957Sbenno#define need_proftick(p) ((p)->p_flag |= PS_OWEUPC, astpending = 1) 6077957Sbenno 6177957Sbennoextern char bootpath[]; 6277957Sbenno 6377957Sbenno#if defined(_KERNEL) || defined(_STANDALONE) 6477957Sbenno#define CACHELINESIZE 32 6577957Sbenno#endif 6677957Sbenno 6777957Sbennoextern void __syncicache __P((void *, int)); 6877957Sbenno 6977957Sbenno/* 7077957Sbenno * CTL_MACHDEP definitions. 7177957Sbenno */ 7277957Sbenno#define CPU_CACHELINE 1 7377957Sbenno#define CPU_MAXID 2 7477957Sbenno#define CPU_CONSDEV 1 7577957Sbenno 7677957Sbenno#define CTL_MACHDEP_NAMES { \ 7777957Sbenno { 0, 0 }, \ 7877957Sbenno { "cachelinesize", CTLTYPE_INT }, \ 7977957Sbenno} 8077957Sbenno 8177957Sbennostatic __inline u_int64_t 8277957Sbennoget_cyclecount(void) 8377957Sbenno{ 8477957Sbenno u_int32_t upper, lower; 8577957Sbenno u_int64_t time; 8677957Sbenno 8777957Sbenno __asm __volatile( 8877957Sbenno "mftb %0\n" 8977957Sbenno "mftbu %1" 9077957Sbenno : "=r" (lower), "=r" (upper)); 9177957Sbenno 9277957Sbenno time = (u_int64_t)upper; 9377957Sbenno time = (time << 32) + lower; 9477957Sbenno return (time); 9577957Sbenno} 9677957Sbenno 9778962Sjhb#define cpu_getstack(p) ((p)->p_frame->fixreg[1]) 9877957Sbenno 9977957Sbennovoid savectx __P((struct pcb *)); 10077957Sbenno 10177957Sbenno#endif /* _MACHINE_CPU_H_ */ 102