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 #else 17 18 extern "C" { 19 20 status_t _arch_cpu_user_memcpy(void* to, const void* from, size_t size, 21 void (**faultHandler)(void)); 22 ssize_t _arch_cpu_user_strlcpy(char* to, const char* from, size_t size, 23 void (**faultHandler)(void)); 24 status_t _arch_cpu_user_memset(void* s, char c, size_t count, 25 void (**faultHandler)(void)); 26 27 } 28 29 30 static inline status_t 31 arch_cpu_user_memcpy(void* to, const void* from, size_t size) 32 { 33 return _arch_cpu_user_memcpy(to, from, size, 34 &thread_get_current_thread()->fault_handler); 35 } 36 37 38 static inline ssize_t 39 arch_cpu_user_strlcpy(char* to, const char* from, size_t size) 40 { 41 return _arch_cpu_user_strlcpy(to, from, size, 42 &thread_get_current_thread()->fault_handler); 43 } 44 45 46 static inline status_t 47 arch_cpu_user_memset(void* s, char c, size_t count) 48 { 49 return _arch_cpu_user_memset(s, c, count, 50 &thread_get_current_thread()->fault_handler); 51 } 52 53 54 #endif 55 56 #endif // _KERNEL_ARCH_USER_MEMORY_H 57 58