xref: /openbsd/lib/libc/arch/mips64/gen/cacheflush.c (revision 6029ab56)
1 /*	$OpenBSD: cacheflush.c,v 1.1 2009/09/27 18:20:13 miod Exp $	*/
2 
3 /*
4  * Copyright (c) 2009 Miodrag Vallat.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * IRIX-compatible cacheflush() and _flush_cache() functions
21  */
22 
23 #include <sys/types.h>
24 #include <machine/sysarch.h>
25 
26 int
cacheflush(void * addr,int nbytes,int cache)27 cacheflush(void *addr, int nbytes, int cache)
28 {
29 	struct mips64_cacheflush_args args;
30 
31 	args.va = (vaddr_t)addr;
32 	args.sz = (size_t)nbytes;
33 	args.which = cache;
34 	return sysarch(MIPS64_CACHEFLUSH, (void *)&args);
35 }
36 
37 __weak_alias(_flush_cache, cacheflush);
38