xref: /dflybsd-src/sys/dev/drm/include/asm/cacheflush.h (revision c9fdb286e8cd49a28c261fa6acfd075587b7115c)
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*c9fdb286SFrançois Tigeot static inline int set_memory_wc(unsigned long vaddr, int numpages)
31*c9fdb286SFrançois Tigeot {
32*c9fdb286SFrançois Tigeot 	pmap_change_attr(vaddr, numpages * PAGE_SIZE, PAT_WRITE_COMBINING);
33*c9fdb286SFrançois Tigeot 	return 0;
34*c9fdb286SFrançois Tigeot }
35*c9fdb286SFrançois Tigeot 
36*c9fdb286SFrançois Tigeot static inline int set_memory_wb(unsigned long vaddr, int numpages)
37*c9fdb286SFrançois Tigeot {
38*c9fdb286SFrançois Tigeot 	pmap_change_attr(vaddr, numpages * PAGE_SIZE, PAT_WRITE_BACK);
39*c9fdb286SFrançois Tigeot 	return 0;
40*c9fdb286SFrançois Tigeot }
41*c9fdb286SFrançois Tigeot 
42b86cbe23SFrançois Tigeot static inline int set_pages_uc(struct vm_page *page, int num_pages)
43b86cbe23SFrançois Tigeot {
44b86cbe23SFrançois Tigeot 	pmap_change_attr(PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page)),
45b86cbe23SFrançois Tigeot 			 num_pages << PAGE_SHIFT, PAT_UNCACHED);
46b86cbe23SFrançois Tigeot 
47b86cbe23SFrançois Tigeot 	return 0;
48b86cbe23SFrançois Tigeot }
49b86cbe23SFrançois Tigeot 
50b86cbe23SFrançois Tigeot #endif	/* _ASM_CACHEFLUSH_H_ */
51