xref: /dflybsd-src/sys/dev/drm/include/asm/cacheflush.h (revision 1b13d1905161b6635b9b2828628eb35b3079dcfb)
1b86cbe23SFrançois Tigeot /*
2b86cbe23SFrançois Tigeot  * Copyright (c) 2015 François Tigeot
3b86cbe23SFrançois Tigeot  * All rights reserved.
4b86cbe23SFrançois Tigeot  *
5b86cbe23SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6b86cbe23SFrançois Tigeot  * modification, are permitted provided that the following conditions
7b86cbe23SFrançois Tigeot  * are met:
8b86cbe23SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9b86cbe23SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10b86cbe23SFrançois Tigeot  *    disclaimer.
11b86cbe23SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12b86cbe23SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13b86cbe23SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14b86cbe23SFrançois Tigeot  *
15b86cbe23SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16b86cbe23SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17b86cbe23SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18b86cbe23SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19b86cbe23SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20b86cbe23SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21b86cbe23SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22b86cbe23SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23b86cbe23SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24b86cbe23SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25b86cbe23SFrançois Tigeot  */
26b86cbe23SFrançois Tigeot 
27b86cbe23SFrançois Tigeot #ifndef _ASM_CACHEFLUSH_H_
28b86cbe23SFrançois Tigeot #define _ASM_CACHEFLUSH_H_
29b86cbe23SFrançois Tigeot 
30*1b13d190SFrançois Tigeot #include <vm/pmap.h>
31*1b13d190SFrançois Tigeot #include <vm/vm_page.h>
32*1b13d190SFrançois Tigeot 
33c9fdb286SFrançois Tigeot static inline int set_memory_wc(unsigned long vaddr, int numpages)
34c9fdb286SFrançois Tigeot {
3596acd33eSMatthew Dillon 	pmap_change_attr(vaddr, numpages, PAT_WRITE_COMBINING);
36c9fdb286SFrançois Tigeot 	return 0;
37c9fdb286SFrançois Tigeot }
38c9fdb286SFrançois Tigeot 
39c9fdb286SFrançois Tigeot static inline int set_memory_wb(unsigned long vaddr, int numpages)
40c9fdb286SFrançois Tigeot {
4196acd33eSMatthew Dillon 	pmap_change_attr(vaddr, numpages, PAT_WRITE_BACK);
42c9fdb286SFrançois Tigeot 	return 0;
43c9fdb286SFrançois Tigeot }
44c9fdb286SFrançois Tigeot 
45b86cbe23SFrançois Tigeot static inline int set_pages_uc(struct vm_page *page, int num_pages)
46b86cbe23SFrançois Tigeot {
47b86cbe23SFrançois Tigeot 	pmap_change_attr(PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page)),
4896acd33eSMatthew Dillon 			 num_pages, PAT_UNCACHED);
49b86cbe23SFrançois Tigeot 
50b86cbe23SFrançois Tigeot 	return 0;
51b86cbe23SFrançois Tigeot }
52b86cbe23SFrançois Tigeot 
53b86cbe23SFrançois Tigeot #endif	/* _ASM_CACHEFLUSH_H_ */
54