⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uaccess.h

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 H
📖 第 1 页 / 共 2 页
字号:
#define __get_user_asm_2(x, ptr, err)                                      \({                                                                         \        __asm__ __volatile__ (  "   sr    %1,%1\n"                         \                                "   la    4,%2\n"                          \                                "   sacf  512\n"                           \                                "0: lh    %0,0(4)\n"                       \                                "1: sacf  0\n"                             \                                ".section .fixup,\"ax\"\n"                 \                                "2: lhi   %1,%h3\n"                        \                                "   jg    1b\n"                            \                                ".previous\n"                              \                                ".section __ex_table,\"a\"\n"              \                                "   .align 8\n"                            \                                "   .quad 0b,2b\n"                         \                                ".previous"                                \                                : "=d" (x) , "=&d" (err)                   \                                : "m" (*(const __u16*)(ptr)),"K" (-EFAULT) \                                : "cc", "4" );                             \})#define __get_user_asm_1(x, ptr, err)                                     \({                                                                        \        __asm__ __volatile__ (  "   sr    %1,%1\n"                        \                                "   la    4,%2\n"                         \                                "   sr    %0,%0\n"                        \                                "   sacf  512\n"                          \                                "0: ic    %0,0(4)\n"                      \                                "1: sacf  0\n"                            \                                ".section .fixup,\"ax\"\n"                \                                "2: lhi   %1,%h3\n"                       \                                "   jg    1b\n"                           \                                ".previous\n"                             \                                ".section __ex_table,\"a\"\n"             \                                "   .align 8\n"                           \                                "   .quad 0b,2b\n"                        \                                ".previous"                               \                                : "=d" (x) , "=&d" (err)                  \                                : "m" (*(const __u8*)(ptr)),"K" (-EFAULT) \                                : "cc", "4" );                            \})#define __get_user(x, ptr)                                      \({                                                              \        int __gu_err;                                           \        switch (sizeof(*(ptr))) {                               \                case 1:                                         \                        __get_user_asm_1(x,ptr,__gu_err);       \                        break;                                  \                case 2:                                         \                        __get_user_asm_2(x,ptr,__gu_err);       \                        break;                                  \                case 4:                                         \                        __get_user_asm_4(x,ptr,__gu_err);       \                        break;                                  \                case 8:                                         \                        __get_user_asm_8(x,ptr,__gu_err);       \                        break;                                  \                default:                                        \                        (x) = 0;                                \                        __gu_err = __get_user_bad();            \                break;                                          \        }                                                       \        __gu_err;                                               \})#define get_user(x, ptr)                                        \({                                                              \        long __gu_err = -EFAULT;                                \        __typeof__(ptr) __gu_addr = (ptr);                      \        __typeof__(*(ptr)) __x;                                 \        if (__access_ok((long)__gu_addr,sizeof(*(ptr)))) {      \                __gu_err = 0;                                   \                __get_user((__x), (__gu_addr));                 \                (x) = __x;                                      \        }                                                       \        else                                                    \                (x) = 0;                                        \        __gu_err;                                               \})extern int __get_user_bad(void);/* * access register are set up, that 4 points to secondary (user) , 2 to primary (kernel) */extern long __copy_to_user_asm(const void *from, long n, void *to);#define __copy_to_user(to, from, n)                             \({                                                              \        __copy_to_user_asm(from, n, to);                        \})#define copy_to_user(to, from, n)                               \({                                                              \        long err = 0;                                           \        __typeof__(n) __n = (n);                                \        if (__access_ok(to,__n)) {                              \                err = __copy_to_user_asm(from, __n, to);        \        }                                                       \        else                                                    \                err = __n;                                      \        err;                                                    \})extern long __copy_from_user_asm(void *to, long n, const void *from);#define __copy_from_user(to, from, n)                           \({                                                              \        __copy_from_user_asm(to, n, from);                      \})#define copy_from_user(to, from, n)                             \({                                                              \        long err = 0;                                           \        __typeof__(n) __n = (n);                                \        if (__access_ok(from,__n)) {                            \                err = __copy_from_user_asm(to, __n, from);      \        }                                                       \        else                                                    \                err = __n;                                      \        err;                                                    \})/* * Copy a null terminated string from userspace. */static inline long__strncpy_from_user(char *dst, const char *src, long count){        long len;        __asm__ __volatile__ (  "   slgr  %0,%0\n"				"   lgr   2,%1\n"                                "   lgr   4,%2\n"                                "   slr   3,3\n"                                "   sacf  512\n"                                "0: ic    3,0(%0,4)\n"                                "1: stc   3,0(%0,2)\n"                                "   ltr   3,3\n"                                "   jz    2f\n"                                "   aghi  %0,1\n"                                "   cgr   %0,%3\n"                                "   jl    0b\n"                                "2: sacf  0\n"				".section .fixup,\"ax\"\n"				"3: lghi  %0,%h4\n"				"   jg    2b\n"  				".previous\n"				".section __ex_table,\"a\"\n"				"   .align 8\n"				"   .quad  0b,3b\n"				"   .quad  1b,3b\n"				".previous"                                : "=&a" (len)                                : "a"  (dst), "d" (src), "d" (count),                                  "K" (-EFAULT)                                : "cc", "2" ,"3", "4" );        return len;}static inline longstrncpy_from_user(char *dst, const char *src, long count){        long res = -EFAULT;        if (access_ok(VERIFY_READ, src, 1))                res = __strncpy_from_user(dst, src, count);        return res;}/* * Return the size of a string (including the ending 0) * * Return 0 for error */static inline unsigned longstrnlen_user(const char * src, unsigned long n){#if 0        __asm__ __volatile__ ("   algr  %0,%1\n"                              "   slgr  0,0\n"                              "   lgr   4,%1\n"                              "   sacf  512\n"                              "0: srst  %0,4\n"                              "   jo    0b\n"                              "   slgr  %0,%1\n"                              "   aghi  %0,1\n"                              "1: sacf  0\n"                              ".section .fixup,\"ax\"\n"                              "2: slgr  %0,%0\n"                              "   jg    1b\n"                              ".previous\n"                              ".section __ex_table,\"a\"\n"                              "   .align 8\n"                              "   .quad  0b,2b\n"                              ".previous"                              : "+&a" (n) : "d" (src)                              : "cc", "0", "4" );#else	__asm__ __volatile__ ("   lgr   4,%1\n"			      "   sacf  512\n"			      "0: cli   0(4),0x00\n"                              "   la    4,1(4)\n"			      "   je    1f\n"                              "   brctg %0,0b\n"			      "1: lgr   %0,4\n"			      "   slgr  %0,%1\n"			      "2: sacf  0\n"                              ".section .fixup,\"ax\"\n"                              "3: slgr  %0,%0\n"                              "   jg    2b\n"                                ".previous\n"			      ".section __ex_table,\"a\"\n"			      "   .align 8\n"			      "   .quad  0b,3b\n"			      ".previous"			      : "+&a" (n) : "d" (src)			      : "cc", "4" );#endif        return n;}#define strlen_user(str) strnlen_user(str, ~0UL)/* * Zero Userspace */extern long __clear_user_asm(void *to, long n);#define __clear_user(to, n)                                     \({                                                              \        __clear_user_asm(to, n);                                \})static inline unsigned longclear_user(void *to, unsigned long n){        if (access_ok(VERIFY_WRITE, to, n))                n = __clear_user(to, n);        return n;}#endif                                 /* _S390_UACCESS_H                  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -