cpu.h revision 158445
1230557Sjimharris/*- 2230557Sjimharris * Copyright (C) 1995-1997 Wolfgang Solfrank. 3230557Sjimharris * Copyright (C) 1995-1997 TooLs GmbH. 4230557Sjimharris * All rights reserved. 5230557Sjimharris * 6230557Sjimharris * Redistribution and use in source and binary forms, with or without 7230557Sjimharris * modification, are permitted provided that the following conditions 8230557Sjimharris * are met: 9230557Sjimharris * 1. Redistributions of source code must retain the above copyright 10230557Sjimharris * notice, this list of conditions and the following disclaimer. 11230557Sjimharris * 2. Redistributions in binary form must reproduce the above copyright 12230557Sjimharris * notice, this list of conditions and the following disclaimer in the 13230557Sjimharris * documentation and/or other materials provided with the distribution. 14230557Sjimharris * 3. All advertising materials mentioning features or use of this software 15230557Sjimharris * must display the following acknowledgement: 16230557Sjimharris * This product includes software developed by TooLs GmbH. 17230557Sjimharris * 4. The name of TooLs GmbH may not be used to endorse or promote products 18230557Sjimharris * derived from this software without specific prior written permission. 19230557Sjimharris * 20230557Sjimharris * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 21230557Sjimharris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22230557Sjimharris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23230557Sjimharris * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25230557Sjimharris * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26230557Sjimharris * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27230557Sjimharris * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28230557Sjimharris * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29230557Sjimharris * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30230557Sjimharris * 31230557Sjimharris * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ 32230557Sjimharris * $FreeBSD: head/sys/powerpc/include/cpu.h 158445 2006-05-11 17:29:25Z phk $ 33230557Sjimharris */ 34230557Sjimharris 35230557Sjimharris#ifndef _MACHINE_CPU_H_ 36230557Sjimharris#define _MACHINE_CPU_H_ 37230557Sjimharris 38230557Sjimharris#include <machine/frame.h> 39230557Sjimharris#include <machine/pcb.h> 40230557Sjimharris#include <machine/psl.h> 41230557Sjimharris 42230557Sjimharris#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 43230557Sjimharris#define TRAPF_PC(frame) ((frame)->srr0) 44230557Sjimharris 45230557Sjimharris#define cpu_swapout(p) 46230557Sjimharris#define cpu_number() 0 47230557Sjimharris 48230557Sjimharris#if defined(_KERNEL) || defined(_STANDALONE) 49230557Sjimharris#define CACHELINESIZE 32 50230557Sjimharris#endif 51230557Sjimharris 52230557Sjimharrisextern void __syncicache(void *, int); 53230557Sjimharris 54230557Sjimharris/* 55230557Sjimharris * CTL_MACHDEP definitions. 56230557Sjimharris */ 57230557Sjimharris#define CPU_CACHELINE 1 58230557Sjimharris 59230557Sjimharrisstatic __inline u_int64_t 60230557Sjimharrisget_cyclecount(void) 61230557Sjimharris{ 62230557Sjimharris u_int32_t _upper, _lower; 63230557Sjimharris u_int64_t _time; 64230557Sjimharris 65230557Sjimharris __asm __volatile( 66230557Sjimharris "mftb %0\n" 67230557Sjimharris "mftbu %1" 68230557Sjimharris : "=r" (_lower), "=r" (_upper)); 69230557Sjimharris 70230557Sjimharris _time = (u_int64_t)_upper; 71230557Sjimharris _time = (_time << 32) + _lower; 72230557Sjimharris return (_time); 73230557Sjimharris} 74230557Sjimharris 75230557Sjimharris#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) 76230557Sjimharris#define cpu_spinwait() /* nothing */ 77230557Sjimharris 78230557Sjimharrisvoid cpu_halt(void); 79230557Sjimharrisvoid cpu_reset(void); 80230557Sjimharrisvoid fork_trampoline(void); 81230557Sjimharrisvoid swi_vm(void *); 82230557Sjimharris 83230557Sjimharris/* XXX the following should not be here. */ 84230557Sjimharrisvoid savectx(struct pcb *); 85230557Sjimharrisint kcopy(const void *, void *, size_t); 86230557Sjimharris 87230557Sjimharris#endif /* _MACHINE_CPU_H_ */ 88230557Sjimharris