1139825Simp/*- 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: releng/10.3/sys/powerpc/include/cpu.h 262675 2014-03-02 02:35:46Z jhibbits $ 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 42199886Snwhitehorn/* 43199886Snwhitehorn * CPU Feature Attributes 44199886Snwhitehorn * 45199886Snwhitehorn * These are defined in the PowerPC ELF ABI for the AT_HWCAP vector, 46199886Snwhitehorn * and are exported to userland via the machdep.cpu_features 47199886Snwhitehorn * sysctl. 48199886Snwhitehorn */ 49199886Snwhitehorn 50199886Snwhitehornextern int cpu_features; 51199886Snwhitehorn 52199886Snwhitehorn#define PPC_FEATURE_32 0x80000000 /* Always true */ 53199886Snwhitehorn#define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */ 54199886Snwhitehorn#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 55199886Snwhitehorn#define PPC_FEATURE_HAS_FPU 0x08000000 56199886Snwhitehorn#define PPC_FEATURE_HAS_MMU 0x04000000 57199886Snwhitehorn#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 58199886Snwhitehorn 59199886Snwhitehorn#define PPC_FEATURE_BITMASK \ 60199886Snwhitehorn "\20" \ 61199886Snwhitehorn "\040PPC32\037PPC64\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" 62199886Snwhitehorn 6391459Sbenno#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) 6479036Sbenno#define TRAPF_PC(frame) ((frame)->srr0) 6579036Sbenno 6677957Sbenno#define cpu_swapout(p) 6777957Sbenno#define cpu_number() 0 6877957Sbenno 6977957Sbenno/* 7077957Sbenno * CTL_MACHDEP definitions. 7177957Sbenno */ 7277957Sbenno#define CPU_CACHELINE 1 7377957Sbenno 7477957Sbennostatic __inline u_int64_t 7577957Sbennoget_cyclecount(void) 7677957Sbenno{ 77109476Sgrehan u_int32_t _upper, _lower; 78109476Sgrehan u_int64_t _time; 7977957Sbenno 8077957Sbenno __asm __volatile( 8177957Sbenno "mftb %0\n" 8277957Sbenno "mftbu %1" 83109476Sgrehan : "=r" (_lower), "=r" (_upper)); 8477957Sbenno 85109476Sgrehan _time = (u_int64_t)_upper; 86109476Sgrehan _time = (_time << 32) + _lower; 87109476Sgrehan return (_time); 8877957Sbenno} 8977957Sbenno 9083682Smp#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) 91133084Smux#define cpu_spinwait() /* nothing */ 9277957Sbenno 93184316Smarcelextern char btext[]; 94184316Smarcelextern char etext[]; 95184316Smarcel 96118990Smarcelvoid cpu_halt(void); 97118990Smarcelvoid cpu_reset(void); 98262675Sjhibbitsvoid cpu_sleep(void); 99262675Sjhibbitsvoid flush_disable_caches(void); 100118990Smarcelvoid fork_trampoline(void); 101118990Smarcelvoid swi_vm(void *); 102118990Smarcel 10377957Sbenno#endif /* _MACHINE_CPU_H_ */ 104