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

📄 validate.c

📁 针对linux休眠suspend显卡状态保存恢复的一个办法
💻 C
📖 第 1 页 / 共 3 页
字号:
        for (s = 0x100; s < 0xFF00; s += 0x100) {                       \            M.x86.R_EFLG = inflags = flags = def_flags;                 \            for (f = 0; f < 2; f++) {                                   \                M.x86.intr = 0;                                         \                M.x86.R_AX = d & 0xFFFF;                                \                M.x86.R_DX = d >> 16;                                   \                name(s);                                            \                r_quot = M.x86.R_AX;                                    \                r_rem = M.x86.R_DX;                                     \                if (M.x86.intr & INTR_SYNCH)                            \                    continue;                                           \                name##_asm(&flags,&r_asm_quot,&r_asm_rem,d & 0xFFFF,d >> 16,s);\                if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \                    failed = true;                                      \                if (failed || trace) {                                  \                    if (failed)                                         \                        printk("fail\n");                               \                    printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n",                      \                        r_quot, r_rem, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG));     \                    printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n",                      \                        r_asm_quot, r_asm_rem, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags));  \                    }                                                       \                M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF);   \                if (failed)                                                 \                    break;                                                  \                }                                                           \            if (failed)                                                     \                break;                                                      \            }                                                               \        if (failed)                                                         \            break;                                                          \        }                                                                   \    if (!failed)                                                            \        printk("passed\n");                                                 \}#define VAL_LONG_DIV(name)                                              \    printk("Validating %s ... ", #name);                                \{                                                                       \    u32         d,s;                                                    \    u32         r_quot,r_rem,r_asm_quot,r_asm_rem;                      \	u32         flags,inflags;                                          \    int         f,failed = false;                                       \    char        buf1[80],buf2[80];                                      \    for (d = 0; d < 0xFF000000; d += 0x1000000) {                       \        for (s = 0x100; s < 0xFF00; s += 0x100) {                       \            M.x86.R_EFLG = inflags = flags = def_flags;                 \            for (f = 0; f < 2; f++) {                                   \                M.x86.intr = 0;                                         \                M.x86.R_EAX = d;                                        \                M.x86.R_EDX = 0;                                        \                name(s);                                            \                r_quot = M.x86.R_EAX;                                   \                r_rem = M.x86.R_EDX;                                    \                if (M.x86.intr & INTR_SYNCH)                            \                    continue;                                           \                name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,0,s);        \                if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \                    failed = true;                                      \                if (failed || trace) {                                  \                    if (failed)                                         \                        printk("fail\n");                               \                    printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n",                       \                        r_quot, r_rem, #name, 0, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG));  \                    printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n",                       \                        r_asm_quot, r_asm_rem, #name"_asm", 0, d, s, print_flags(buf1,inflags), print_flags(buf2,flags));   \                    }                                                       \                M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF);   \                if (failed)                                                 \                    break;                                                  \                }                                                           \            if (failed)                                                     \                break;                                                      \            }                                                               \        if (failed)                                                         \            break;                                                          \        }                                                                   \    if (!failed)                                                            \        printk("passed\n");                                                 \}void printk(const char *fmt, ...){    va_list argptr;    va_start(argptr, fmt);    vfprintf(stdout, fmt, argptr);    fflush(stdout);    va_end(argptr);}char * print_flags(char *buf,ulong flags){    char *separator = "";    buf[0] = 0;    if (flags & F_CF) {        strcat(buf,separator);        strcat(buf,"CF");        separator = ",";        }    if (flags & F_PF) {        strcat(buf,separator);        strcat(buf,"PF");        separator = ",";        }    if (flags & F_AF) {        strcat(buf,separator);        strcat(buf,"AF");        separator = ",";        }    if (flags & F_ZF) {        strcat(buf,separator);        strcat(buf,"ZF");        separator = ",";        }    if (flags & F_SF) {        strcat(buf,separator);        strcat(buf,"SF");        separator = ",";        }    if (flags & F_OF) {        strcat(buf,separator);        strcat(buf,"OF");        separator = ",";        }    if (separator[0] == 0)        strcpy(buf,"None");    return buf;}int main(int argc){    ulong   def_flags;    int trace = false;    if (argc > 1)        trace = true;    memset(&M, 0, sizeof(M));    def_flags = get_flags_asm() & ~ALL_FLAGS;    VAL_WORD_UNARY(aaa_word);    VAL_WORD_UNARY(aas_word);    VAL_WORD_UNARY(aad_word);    VAL_WORD_UNARY(aam_word);    VAL_BYTE_BYTE_BINARY(adc_byte);    VAL_WORD_WORD_BINARY(adc_word);    VAL_LONG_LONG_BINARY(adc_long);    VAL_BYTE_BYTE_BINARY(add_byte);    VAL_WORD_WORD_BINARY(add_word);    VAL_LONG_LONG_BINARY(add_long);    VAL_BYTE_BYTE_BINARY(and_byte);    VAL_WORD_WORD_BINARY(and_word);    VAL_LONG_LONG_BINARY(and_long);    VAL_BYTE_BYTE_BINARY(cmp_byte);    VAL_WORD_WORD_BINARY(cmp_word);    VAL_LONG_LONG_BINARY(cmp_long);    VAL_BYTE_UNARY(daa_byte);    VAL_BYTE_UNARY(das_byte);   // Fails for 0x9A (out of range anyway)    VAL_BYTE_UNARY(dec_byte);    VAL_WORD_UNARY(dec_word);    VAL_LONG_UNARY(dec_long);    VAL_BYTE_UNARY(inc_byte);    VAL_WORD_UNARY(inc_word);    VAL_LONG_UNARY(inc_long);    VAL_BYTE_BYTE_BINARY(or_byte);    VAL_WORD_WORD_BINARY(or_word);    VAL_LONG_LONG_BINARY(or_long);    VAL_BYTE_UNARY(neg_byte);    VAL_WORD_UNARY(neg_word);    VAL_LONG_UNARY(neg_long);    VAL_BYTE_UNARY(not_byte);    VAL_WORD_UNARY(not_word);    VAL_LONG_UNARY(not_long);    VAL_BYTE_ROTATE(rcl_byte);    VAL_WORD_ROTATE(rcl_word);    VAL_LONG_ROTATE(rcl_long);    VAL_BYTE_ROTATE(rcr_byte);    VAL_WORD_ROTATE(rcr_word);    VAL_LONG_ROTATE(rcr_long);    VAL_BYTE_ROTATE(rol_byte);    VAL_WORD_ROTATE(rol_word);    VAL_LONG_ROTATE(rol_long);    VAL_BYTE_ROTATE(ror_byte);    VAL_WORD_ROTATE(ror_word);    VAL_LONG_ROTATE(ror_long);    VAL_BYTE_ROTATE(shl_byte);    VAL_WORD_ROTATE(shl_word);    VAL_LONG_ROTATE(shl_long);    VAL_BYTE_ROTATE(shr_byte);    VAL_WORD_ROTATE(shr_word);    VAL_LONG_ROTATE(shr_long);    VAL_BYTE_ROTATE(sar_byte);    VAL_WORD_ROTATE(sar_word);    VAL_LONG_ROTATE(sar_long);    VAL_WORD_ROTATE_DBL(shld_word);    VAL_LONG_ROTATE_DBL(shld_long);    VAL_WORD_ROTATE_DBL(shrd_word);    VAL_LONG_ROTATE_DBL(shrd_long);    VAL_BYTE_BYTE_BINARY(sbb_byte);    VAL_WORD_WORD_BINARY(sbb_word);    VAL_LONG_LONG_BINARY(sbb_long);    VAL_BYTE_BYTE_BINARY(sub_byte);    VAL_WORD_WORD_BINARY(sub_word);    VAL_LONG_LONG_BINARY(sub_long);    VAL_BYTE_BYTE_BINARY(xor_byte);    VAL_WORD_WORD_BINARY(xor_word);    VAL_LONG_LONG_BINARY(xor_long);    VAL_VOID_BYTE_BINARY(test_byte);    VAL_VOID_WORD_BINARY(test_word);    VAL_VOID_LONG_BINARY(test_long);    VAL_BYTE_MUL(imul_byte);    VAL_WORD_MUL(imul_word);    VAL_LONG_MUL(imul_long);    VAL_BYTE_MUL(mul_byte);    VAL_WORD_MUL(mul_word);    VAL_LONG_MUL(mul_long);    VAL_BYTE_DIV(idiv_byte);    VAL_WORD_DIV(idiv_word);    VAL_LONG_DIV(idiv_long);    VAL_BYTE_DIV(div_byte);    VAL_WORD_DIV(div_word);    VAL_LONG_DIV(div_long);    return 0;}

⌨️ 快捷键说明

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