1 /* $OpenBSD: asm_macro.h,v 1.10 2014/03/29 18:09:29 guenther Exp $ */ 2 /* 3 * Mach Operating System 4 * Copyright (c) 1993-1991 Carnegie Mellon University 5 * Copyright (c) 1991 OMRON Corporation 6 * All Rights Reserved. 7 * 8 * Permission to use, copy, modify and distribute this software and its 9 * documentation is hereby granted, provided that both the copyright 10 * notice and this permission notice appear in all copies of the 11 * software, derivative works or modified versions, and any portions 12 * thereof, and that both notices appear in supporting documentation. 13 * 14 * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CONDITION. CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND 16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * Carnegie Mellon requests users of this software to return to 19 * 20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * School of Computer Science 22 * Carnegie Mellon University 23 * Pittsburgh PA 15213-3890 24 * 25 * any improvements or extensions that they make and grant Carnegie the 26 * rights to redistribute these changes. 27 */ 28 29 #ifndef _M88K_ASM_MACRO_H_ 30 #define _M88K_ASM_MACRO_H_ 31 32 /* 33 * Various compiler macros used for speed and efficiency. 34 * Anyone can include. 35 */ 36 37 /* 38 * Flush the data pipeline. 39 */ 40 #define flush_pipeline() \ 41 __asm__ volatile ("tb1 0, %%r0, 0" ::: "memory") 42 43 /* 44 * Set the PSR. 45 */ 46 static __inline__ void set_psr(u_int psr) 47 { 48 __asm__ volatile ("stcr %0, %%cr1" :: "r" (psr)); 49 flush_pipeline(); 50 } 51 52 /* 53 * Get the PSR. 54 */ 55 static __inline__ u_int get_psr(void) 56 { 57 u_int psr; 58 __asm__ volatile ("ldcr %0, %%cr1" : "=r" (psr)); 59 return (psr); 60 } 61 62 /* 63 * Provide access from C code to the assembly instruction ff1 64 */ 65 static __inline__ u_int ff1(u_int val) 66 { 67 __asm__ volatile ("ff1 %0, %0" : "=r" (val) : "0" (val)); 68 return (val); 69 } 70 71 static __inline__ u_int get_cpu_pid(void) 72 { 73 u_int pid; 74 __asm__ volatile ("ldcr %0, %%cr0" : "=r" (pid)); 75 return (pid); 76 } 77 78 #endif /* _M88K_ASM_MACRO_H_ */ 79