1 /* $OpenBSD: set_memory.h,v 1.3 2020/09/11 09:27:10 mpi 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/systm.h> 22 #include <sys/atomic.h> 23 24 #include <sys/param.h> /* for PAGE_SIZE on i386 */ 25 #include <uvm/uvm_extern.h> 26 27 #include <machine/pmap.h> 28 29 #if defined(__amd64__) || defined(__i386__) 30 31 static inline int 32 set_pages_array_wb(struct vm_page **pages, int addrinarray) 33 { 34 int i; 35 36 for (i = 0; i < addrinarray; i++) 37 atomic_clearbits_int(&pages[i]->pg_flags, PG_PMAP_WC); 38 39 return 0; 40 } 41 42 static inline int 43 set_pages_array_wc(struct vm_page **pages, int addrinarray) 44 { 45 int i; 46 47 for (i = 0; i < addrinarray; i++) 48 atomic_setbits_int(&pages[i]->pg_flags, PG_PMAP_WC); 49 50 return 0; 51 } 52 53 static inline int 54 set_pages_array_uc(struct vm_page **pages, int addrinarray) 55 { 56 /* XXX */ 57 return 0; 58 } 59 60 static inline int 61 set_pages_wb(struct vm_page *page, int numpages) 62 { 63 KASSERT(numpages == 1); 64 atomic_clearbits_int(&page->pg_flags, PG_PMAP_WC); 65 return 0; 66 } 67 68 static inline int 69 set_pages_uc(struct vm_page *page, int numpages) 70 { 71 /* XXX */ 72 return 0; 73 } 74 75 #endif /* defined(__amd64__) || defined(__i386__) */ 76 77 #endif 78