1 /* $OpenBSD: set_memory.h,v 1.1 2019/04/14 10:14:52 jsg Exp $ */ 2 /* 3 * Copyright (c) 2013, 2014, 2015 Mark Kettenis 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _ASM_SET_MEMORY_H 19 #define _ASM_SET_MEMORY_H 20 21 #include <sys/atomic.h> 22 #include <machine/pmap.h> 23 24 #if defined(__amd64__) || defined(__i386__) 25 26 static inline int 27 set_pages_array_wb(struct vm_page **pages, int addrinarray) 28 { 29 int i; 30 31 for (i = 0; i < addrinarray; i++) 32 atomic_clearbits_int(&pages[i]->pg_flags, PG_PMAP_WC); 33 34 return 0; 35 } 36 37 static inline int 38 set_pages_array_wc(struct vm_page **pages, int addrinarray) 39 { 40 int i; 41 42 for (i = 0; i < addrinarray; i++) 43 atomic_setbits_int(&pages[i]->pg_flags, PG_PMAP_WC); 44 45 return 0; 46 } 47 48 static inline int 49 set_pages_array_uc(struct vm_page **pages, int addrinarray) 50 { 51 /* XXX */ 52 return 0; 53 } 54 55 static inline int 56 set_pages_wb(struct vm_page *page, int numpages) 57 { 58 KASSERT(numpages == 1); 59 atomic_clearbits_int(&page->pg_flags, PG_PMAP_WC); 60 return 0; 61 } 62 63 static inline int 64 set_pages_uc(struct vm_page *page, int numpages) 65 { 66 /* XXX */ 67 return 0; 68 } 69 70 #endif /* defined(__amd64__) || defined(__i386__) */ 71 72 #endif 73