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