cpufunc.h revision 78342
1/*- 2 * Copyright (c) 1998 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/powerpc/include/cpufunc.h 78342 2001-06-16 07:14:07Z benno $ 27 */ 28 29#ifndef _MACHINE_CPUFUNC_H_ 30#define _MACHINE_CPUFUNC_H_ 31 32#ifdef _KERNEL 33 34#include <sys/types.h> 35 36#ifdef __GNUC__ 37 38static __inline void 39breakpoint(void) 40{ 41 return; 42} 43 44#endif 45 46/* 47 * Bogus interrupt manipulation 48 */ 49static __inline void 50disable_intr(void) 51{ 52 u_int32_t msr; 53 54 msr = 0; 55 __asm __volatile( 56 "mfmsr %0\n\t" 57 "rlwinm %0, %0, 0, 17, 15\n\t" 58 "mtmsr %0" 59 : "+r" (msr)); 60 61 return; 62} 63 64static __inline void 65enable_intr(void) 66{ 67 u_int32_t msr; 68 69 msr = 0; 70 __asm __volatile( 71 "mfmsr %0\n\t" 72 "ori %0, %0, 0x8000\n\t" 73 "mtmsr %0" 74 : "+r" (msr)); 75 76 return; 77} 78 79static __inline u_int 80save_intr(void) 81{ 82 u_int msr; 83 84 __asm __volatile("mfmsr %0" : "=r" (msr)); 85 86 return msr; 87} 88 89static __inline critical_t 90critical_enter(void) 91{ 92 return ((critical_t)save_intr()); 93} 94 95static __inline void 96restore_intr(u_int msr) 97{ 98 __asm __volatile("mtmsr %0" : : "r" (msr)); 99 100 return; 101} 102 103static __inline void 104critical_exit(critical_t msr) 105{ 106 return (restore_intr((u_int)msr)); 107} 108 109static __inline void 110powerpc_mb(void) 111{ 112 __asm __volatile("eieio;" : : : "memory"); 113} 114 115static __inline void 116*powerpc_get_globalp(void) 117{ 118 void *ret; 119 120 __asm __volatile("mfsprg %0, 0" : "=r" (ret)); 121 122 return(ret); 123} 124 125#endif /* _KERNEL */ 126 127#endif /* !_MACHINE_CPUFUNC_H_ */ 128