166458Sdfr/*- 266458Sdfr * Copyright (c) 1998 Doug Rabson 366458Sdfr * All rights reserved. 466458Sdfr * 566458Sdfr * Redistribution and use in source and binary forms, with or without 666458Sdfr * modification, are permitted provided that the following conditions 766458Sdfr * are met: 866458Sdfr * 1. Redistributions of source code must retain the above copyright 966458Sdfr * notice, this list of conditions and the following disclaimer. 1066458Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1166458Sdfr * notice, this list of conditions and the following disclaimer in the 1266458Sdfr * documentation and/or other materials provided with the distribution. 1366458Sdfr * 1466458Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1566458Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1666458Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1766458Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1866458Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1966458Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2066458Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2166458Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2266458Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2366458Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2466458Sdfr * SUCH DAMAGE. 2566458Sdfr * 2666458Sdfr * $FreeBSD: releng/10.2/sys/ia64/include/cpufunc.h 205713 2010-03-26 21:22:02Z marcel $ 2766458Sdfr */ 2866458Sdfr 2966458Sdfr#ifndef _MACHINE_CPUFUNC_H_ 3066458Sdfr#define _MACHINE_CPUFUNC_H_ 3166458Sdfr 3266458Sdfr#ifdef _KERNEL 3366458Sdfr 3466458Sdfr#include <sys/types.h> 3583511Sdfr#include <machine/ia64_cpu.h> 3696912Smarcel#include <machine/vmparam.h> 3766458Sdfr 38143063Sjoerg#ifndef _SYS_CDEFS_H_ 39143063Sjoerg#error this file needs sys/cdefs.h as a prerequisite 40143063Sjoerg#endif 41143063Sjoerg 4293264Sdillonstruct thread; 4388088Sjhb 44127253Smarcel#define IA64_FIXED_BREAK 0x84B5D 45127253Smarcel 46143063Sjoerg#ifdef __GNUCLIKE_ASM 4766458Sdfr 4866458Sdfrstatic __inline void 4966458Sdfrbreakpoint(void) 5066458Sdfr{ 51127253Smarcel __asm __volatile("break.m %0" :: "i"(IA64_FIXED_BREAK)); 5266458Sdfr} 5366458Sdfr 54124478Sdes#define HAVE_INLINE_FFS 55132871Smarcel#define ffs(x) __builtin_ffs(x) 56123419Speter 5783511Sdfr 5866458Sdfrstatic __inline void 59205713Smarcelia64_disable_intr(void) 6066458Sdfr{ 61114208Smarcel __asm __volatile ("rsm psr.i"); 6266458Sdfr} 6366458Sdfr 6466458Sdfrstatic __inline void 65205713Smarcelia64_enable_intr(void) 6666458Sdfr{ 67114208Smarcel __asm __volatile ("ssm psr.i;; srlz.d"); 6866458Sdfr} 6966458Sdfr 7092870Sdfrstatic __inline register_t 7192781Sdfrintr_disable(void) 7266458Sdfr{ 7392870Sdfr register_t psr; 74205713Smarcel 75114208Smarcel __asm __volatile ("mov %0=psr;;" : "=r"(psr)); 76205713Smarcel ia64_disable_intr(); 77115295Smarcel return ((psr & IA64_PSR_I) ? 1 : 0); 7866458Sdfr} 7966458Sdfr 8066458Sdfrstatic __inline void 81115295Smarcelintr_restore(register_t ie) 8266458Sdfr{ 83115295Smarcel if (ie) 84205713Smarcel ia64_enable_intr(); 8566458Sdfr} 8666458Sdfr 87143063Sjoerg#endif /* __GNUCLIKE_ASM */ 88143063Sjoerg 8966458Sdfr#endif /* _KERNEL */ 9066458Sdfr 9166458Sdfr#endif /* !_MACHINE_CPUFUNC_H_ */ 92