1 #ifndef _ARCH_USERCOPY_H
2 #define _ARCH_USERCOPY_H
4 #include <kern/types.h>
9 static inline void copyin(T *uptr, T *kdata, int count)
11 // OPT: use alignof for movsw and movsl versions
12 ulong bytes = sizeof(*kdata) * count;
15 if ((ulong)uptr + bytes >= PHYSMEM_START ||
16 (ulong)uptr + bytes < (ulong)uptr) {
23 ".section .extable,\"a\"\n"
27 ".previous\n" : "+c" (bytes), "+D" (kdata), "+S" (uptr), "=d" (cause));
31 throw_idl(MemoryFault, reinterpret_cast<ulong>(uptr),
32 0, NULL, NULL, cause);
37 static inline void copyin(T *uptr, T &kdata)
39 // OPT: special versions for common small sizes
40 copyin(uptr, &kdata, 1);
44 static inline T copyin(T *uptr)
52 static inline void copyout(T *uptr, T *kdata, int count)
54 // OPT: use alignof for movsw and movsl versions
55 ulong bytes = sizeof(*kdata) * count;
58 if ((ulong)uptr + bytes >= PHYSMEM_START ||
59 (ulong)uptr + bytes < (ulong)uptr) {
66 ".section .extable,\"a\"\n"
69 ".previous\n" : "+c" (bytes), "+S" (kdata), "+D" (uptr), "=d" (cause));
73 throw_idl(MemoryFault, reinterpret_cast<ulong>(uptr),
74 0, NULL, NULL, cause);
79 static inline void copyout(T *uptr, T &kdata)
81 copyout(uptr, &kdata, sizeof(kdata));