xref: /freebsd/sys/sys/kern_prefetch.h (revision 95ee2897)
13ee9c3c4SRandall Stewart /*-
252467047SWarner Losh  * Copyright (c) 2016-2018 Netflix, Inc.
33ee9c3c4SRandall Stewart  *
43ee9c3c4SRandall Stewart  * Redistribution and use in source and binary forms, with or without
53ee9c3c4SRandall Stewart  * modification, are permitted provided that the following conditions
63ee9c3c4SRandall Stewart  * are met:
73ee9c3c4SRandall Stewart  * 1. Redistributions of source code must retain the above copyright
83ee9c3c4SRandall Stewart  *    notice, this list of conditions and the following disclaimer.
93ee9c3c4SRandall Stewart  * 2. Redistributions in binary form must reproduce the above copyright
103ee9c3c4SRandall Stewart  *    notice, this list of conditions and the following disclaimer in the
113ee9c3c4SRandall Stewart  *    documentation and/or other materials provided with the distribution.
123ee9c3c4SRandall Stewart  *
133ee9c3c4SRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
143ee9c3c4SRandall Stewart  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
153ee9c3c4SRandall Stewart  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
163ee9c3c4SRandall Stewart  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
173ee9c3c4SRandall Stewart  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
183ee9c3c4SRandall Stewart  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
193ee9c3c4SRandall Stewart  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
203ee9c3c4SRandall Stewart  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
213ee9c3c4SRandall Stewart  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
223ee9c3c4SRandall Stewart  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
233ee9c3c4SRandall Stewart  * SUCH DAMAGE.
243ee9c3c4SRandall Stewart  */
25603bbd06SWarner Losh #ifndef __kern_prefetch_h__
263ee9c3c4SRandall Stewart #define __kern_prefetch_h__
273ee9c3c4SRandall Stewart #ifdef _KERNEL
283ee9c3c4SRandall Stewart 
293ee9c3c4SRandall Stewart static __inline void
kern_prefetch(const volatile void * addr,void * before)303ee9c3c4SRandall Stewart kern_prefetch(const volatile void *addr, void* before)
313ee9c3c4SRandall Stewart {
323ee9c3c4SRandall Stewart #if defined(__amd64__)
333ee9c3c4SRandall Stewart 	__asm __volatile("prefetcht1 (%1)":"=rm"(*((int32_t *)before)):"r"(addr):);
343ee9c3c4SRandall Stewart #else
3512693c6cSRandall Stewart /*	__builtin_prefetch(addr);*/
363ee9c3c4SRandall Stewart #endif
373ee9c3c4SRandall Stewart }
383ee9c3c4SRandall Stewart 
39603bbd06SWarner Losh #endif /* _KERNEL */
40603bbd06SWarner Losh #endif /* __kern_prefetch_h__ */
41