xref: /haiku/headers/private/kernel/arch/user_memory.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KERNEL_ARCH_USER_MEMORY_H
6 #define _KERNEL_ARCH_USER_MEMORY_H
7 
8 
9 #include <OS.h>
10 
11 #include <thread.h>
12 
13 
14 #ifdef __x86_64__
15 #	include <arch/generic/user_memory.h>
16 #elif defined(__M68K__)
17 #	include <arch/generic/user_memory.h>
18 #elif defined(__riscv)
19 #	include <arch/generic/user_memory.h>
20 #else
21 
22 extern "C" {
23 
24 status_t _arch_cpu_user_memcpy(void* to, const void* from, size_t size,
25 	void (**faultHandler)(void));
26 ssize_t _arch_cpu_user_strlcpy(char* to, const char* from, size_t size,
27 	void (**faultHandler)(void));
28 status_t _arch_cpu_user_memset(void* s, char c, size_t count,
29 	void (**faultHandler)(void));
30 
31 }
32 
33 
34 static inline status_t
35 arch_cpu_user_memcpy(void* to, const void* from, size_t size)
36 {
37 	return _arch_cpu_user_memcpy(to, from, size,
38 		&thread_get_current_thread()->fault_handler);
39 }
40 
41 
42 static inline ssize_t
43 arch_cpu_user_strlcpy(char* to, const char* from, size_t size)
44 {
45 	return _arch_cpu_user_strlcpy(to, from, size,
46 		&thread_get_current_thread()->fault_handler);
47 }
48 
49 
50 static inline status_t
51 arch_cpu_user_memset(void* s, char c, size_t count)
52 {
53 	return _arch_cpu_user_memset(s, c, count,
54 		&thread_get_current_thread()->fault_handler);
55 }
56 
57 
58 #endif
59 
60 #endif	// _KERNEL_ARCH_USER_MEMORY_H
61 
62