📄 fpa_systest.c
字号:
};/* immed23 test */#define base FPA_BASEstruct cmd_ptr_path { u_long addr; u_long data_start; u_long data_incr; u_long num_data; u_long data_shift; u_long data_mask; u_long mux_sel; u_long cntxt_mask; u_long dorin;};struct cmd_ptr_path cmdrimm[] = {/* * addr dstart dincr numd dshft dmsk muxsel cntxtmsk * dorin */ {base + 0x800, 0x00000000, 0x00000040, 512, 06, 0x01f, 6, 0x1f, 0x000}, /* imm2 - reg */ {base + 0x800, 0x00008000, 0x00000040, 512, 06, 0x1ff, 6, 0x00, 0x400}, /* imm2 - constant */ {base + 0x800, 0x00000000, 0x00010000, 512, 16, 0x01f, 7, 0x1f, 0x000}, /* imm3 - reg */ {base + 0x800, 0x02000000, 0x00010000, 512, 16, 0x1ff, 7, 0x00, 0x400}, /* imm3 - constant */ {0x000, 0x00000000, 0x00000000, 00, 00, 0x000, 0, 0x00, 0} /* end */};struct cmd_ptr_addr { u_long addr_start; u_long addr_incr; u_long numa; u_long ashift; u_long amask; u_long muxsel;};struct cmd_ptr_addr spaddrimm[] = { {base + 0x0000, 4, 32, 3, 0x0f, 6}, /* sp, dp short */ {base + 0x0c00, 4, 64, 3, 0x1f, 6}, /* same */ {base + 0x0e00, 4, 16, 3, 0x07, 6}, {base + 0x1000, 8, 16, 3, 0x0f, 6}, /* extended - reg 2 */ {000, 0, 0, 0, 0, 0} /* end of table */};struct cmd_ptr_addr dpaddrimm[] = { {base + 0x1800, 4, 32, 3, 0x0f, 6}, /* ext immed2 */ {base + 0x1800, 0x80, 16, 7, 0x0f, 7}, {000, 0, 0, 0, 0, 0} /* end of table */};/* simpleins test */struct test_instructions { int address; int status;};struct test_instructions instr1[] = {/* address status */ {0xe0000000, 0x01}, /* SP NOP */ {0xe0000004, 0x1d}, /* DP NOP */ {0xe0001000, 0x01}, /* DP NOP */ {0xe000095c, 0x13}, /* UNIMPL */ {0x00000, 0x00}};/* micro store register test */u_long wstatus_res[] = { 0xa004, 0xa119, 0xa200, 0xa300, 0x2400, 0x2500, 0x2600, 0x2700, 0x2800, 0x2900, 0x2a00, 0x2b00, 0x2c00, 0x2d00, 0x2e00, 0x2f02};u_long wstatus_res1[] = { 0xa004, 0xa119, 0xa200, 0x2300, 0x2400, 0x2500, 0x2600, 0x2700, 0x2800, 0x2900, 0x2a00, 0x2b00, 0x2c00, 0x2d00, 0x2e00, 0x2f02};/* Weitek status test */#define zero_sp 0x00000000#define zero_msw 0x00000000#define zero_lsw 0x00000000#define half_sp 0x3f000000#define half_msw 0x3fe00000#define half_lsw 0x00000000#define one_sp 0x3f800000#define one_msw 0x3ff00000#define one_lsw 0x00000000#define two_sp 0x40000000#define two_msw 0x40000000#define two_lsw 0x00000000#define pi_sp 0x40490fdb#define pi_msw 0x400921fb#define pi_lsw 0x54442d18#define pi_4_sp 0x3f490fdb#define pi_4_msw 0x3fe921fb#define pi_4_lsw 0x54442d18#define inf_sp 0x7f800000#define inf_msw 0x7ff00000#define inf_lsw 0x00000000#define nan_sp 0x7fbfffff#define nan_msw 0x7ff7ffff#define nan_lsw 0xffffffff#define denorm_sp 0x00000001#define denorm_msw 0x00000000#define denorm_lsw 0x00000001#define maxn_sp 0x7f7fffff#define maxn_msw 0x7fefffff#define maxn_lsw 0xffffffff#define minn_sp 0x00800000#define minn_msw 0x00100000#define minn_lsw 0x00000000#define min1_sp 0x00800001#define min1_msw 0x00100001#define min1_lsw 0x00010001#define maxd_sp 0x007fffff#define maxd_msw 0x000fffff#define maxd_lsw 0xffffffff#define nocare 0#define add_sp (base + 0xa80)#define add_dp (base + 0xa84)#define div_sp (base + 0xa30)#define div_dp (base + 0xa34)#define mult_sp (base + 0xa08)#define mult_dp (base + 0xa0c)struct testws { u_long a_msw; u_long a_lsw; u_long b_msw; u_long b_lsw; u_long instr; u_long status;};struct testws test_ws[] = {/* a_msw a_lsw b_msw b_lsw instr status *//* ALU */ {zero_sp, nocare, zero_sp, nocare, add_sp, 0x0}, /* zero,ex */ {zero_msw, zero_lsw, zero_msw, zero_lsw, add_dp, 0x0}, {inf_sp, nocare, inf_sp, nocare, add_sp, 0x1}, /* inf,ex */ {inf_msw, inf_lsw, inf_msw, inf_lsw, add_dp, 0x1}, {one_sp, nocare, one_sp, nocare, add_sp, 0x2}, /* fin,ex */ {one_msw, one_lsw, one_msw, one_lsw, add_dp, 0x2}, {one_sp, nocare, pi_sp, nocare, div_sp, 0x3}, /* fin,inex */ {one_msw, one_lsw, pi_msw, pi_lsw, div_dp, 0x3},/* status 0x4 is unused on both chips *//* unused */ {maxn_sp, nocare, maxn_sp, nocare, add_sp, 0x5}, /* ovfl,inex */ {maxn_msw, maxn_lsw, maxn_msw, maxn_lsw, add_dp, 0x5}, {minn_sp, nocare, two_sp, nocare, div_sp, 0x6}, /* unfl */ {minn_msw, minn_lsw, two_msw, two_lsw, div_dp, 0x6}, {minn_sp, nocare, pi_sp, nocare, div_sp, 0x7}, /* unfl,inex */ {minn_msw, minn_lsw, pi_msw, pi_lsw, div_dp, 0x7}, {maxd_sp, nocare, two_sp, nocare, div_sp, 0x8}, /* a-denorm */ {maxd_msw, maxd_lsw, two_msw, two_lsw, div_dp, 0x8}, {two_sp, nocare, maxd_sp, nocare, div_sp, 0x9}, /* b-denorm */ {one_msw, one_lsw, maxd_msw, maxd_lsw, div_dp, 0x9}, {maxd_sp, nocare, maxd_sp, nocare, div_sp, 0xa}, /* ab-denorm */ {maxd_msw, maxd_lsw, maxd_msw, maxd_lsw, div_dp, 0xa}, {one_sp, nocare, zero_sp, nocare, div_sp, 0xb}, /* div 0 */ {one_msw, one_lsw, zero_msw, zero_lsw, div_dp, 0xb}, {nan_sp, nocare, zero_sp, nocare, add_sp, 0xc}, /* a-nan */ {nan_msw, nan_lsw, zero_msw, zero_lsw, add_dp, 0xc}, {zero_sp, nocare, nan_sp, nocare, add_sp, 0xd}, /* b-nan */ {zero_sp, nocare, nan_msw, nan_lsw, add_dp, 0xd}, {nan_sp, nocare, nan_sp, nocare, add_sp, 0xe}, /* ab-nan */ {nan_msw, nan_lsw, nan_msw, nan_lsw, add_dp, 0xe}, {inf_sp, nocare, inf_sp, nocare, div_sp, 0xf}, /* invalid */ {inf_msw, inf_lsw, inf_msw, inf_lsw, div_dp, 0xf},/* MULT */ {zero_sp, nocare, zero_sp, nocare, mult_sp, 0x0}, /* zero,ex */ {zero_msw, zero_lsw, zero_msw, zero_lsw, mult_dp, 0x0}, {inf_sp, nocare, inf_sp, nocare, mult_sp, 0x1}, /* inf,ex */ {inf_msw, inf_lsw, inf_msw, inf_lsw, mult_dp, 0x1}, {one_sp, nocare, one_sp, nocare, mult_sp, 0x2}, /* fin,ex */ {one_msw, one_lsw, one_msw, one_lsw, mult_dp, 0x2}, {pi_sp, nocare, pi_sp, nocare, mult_sp, 0x3}, /* fin,inex */ {pi_msw, pi_lsw, pi_msw, pi_lsw, mult_dp, 0x3},/* status 0x4 is unused on both chips */ {maxn_sp, nocare, maxn_sp, nocare, mult_sp, 0x5}, /* ovfl,inex */ {maxn_msw, maxn_lsw, maxn_msw, maxn_lsw, mult_dp, 0x5}, {minn_sp, nocare, half_sp, nocare, mult_sp, 0x6}, /* unfl */ {minn_msw, minn_lsw, half_msw, half_lsw, mult_dp, 0x6}, {min1_sp, nocare, pi_4_sp, nocare, mult_sp, 0x7}, /* unfl,inex */ {min1_msw, min1_lsw, pi_4_msw, pi_4_lsw, mult_dp, 0x7}, {maxd_sp, nocare, half_sp, nocare, mult_sp, 0x8}, /* a-denorm */ {maxd_msw, maxd_lsw, half_msw, half_lsw, mult_dp, 0x8}, {half_sp, nocare, maxd_sp, nocare, mult_sp, 0x9}, /* b-denorm */ {half_msw, half_lsw, maxd_msw, maxd_lsw, mult_dp, 0x9}, {denorm_sp, nocare, denorm_sp, nocare, mult_sp, 0xa}, /* ab-denorm */ {denorm_msw, denorm_lsw, denorm_msw, denorm_lsw, mult_dp, 0xa},/* status 0xb is divide by zero and is unused by the MULT */ {nan_sp, nocare, zero_sp, nocare, mult_sp, 0xc}, /* a-nan */ {nan_msw, nan_lsw, zero_msw, zero_lsw, mult_dp, 0xc}, {zero_sp, nocare, nan_sp, nocare, mult_sp, 0xd}, /* b-nan */ {zero_sp, nocare, nan_msw, nan_lsw, mult_dp, 0xd}, {nan_sp, nocare, nan_sp, nocare, mult_sp, 0xe}, /* ab-nan */ {nan_msw, nan_lsw, nan_msw, nan_lsw, mult_dp, 0xe}, {inf_sp, nocare, zero_sp, nocare, mult_sp, 0xf}, /* invalid */ {inf_msw, inf_lsw, zero_msw, zero_lsw, mult_dp, 0xf}, {00, 00, 000, 000, 0000, 0x0}};extern int verbose, debug;int errno;u_long contexts;int dev_no;u_long *ram_ptr, *rw_ram_ptr, *st_reg_ptr;int open_fpa;extern int lin_pack_test();int sig_err_flag = 0x0;int seg_sig_flag = 0x0;char null_str[2];int res_seg_svmask;int res_seg_svonstack;void (*res_seg_svhandler) ();int restore_svmask;int restore_svonstack;void (*restore_svhandler) ();int temp_test_number;struct sigvec newfpe, oldfpe, oldseg, newseg;void sigsegv_handler(), sigfpe_handler();fpa_systest(){ int value, i, val_rotate; int val, io_value; signal(SIGSEGV, sigsegv_handler); signal(SIGFPE, sigfpe_handler); if (verbose) printf("FPA: FPA System(Reliability) Test.\n"); st_reg_ptr = (u_long *) FPA_STATE_PTR; close(open_fpa); if (!(winitfp_())) { if (verbose) printf("FPA: Could not open FPA.\n"); exit(-1); } contexts = 0x0; /* initialize the context * number */ value = open_new_context(); if (value == 0) { val_rotate = *st_reg_ptr & 0x1F; contexts = (1 << val_rotate); if (verbose) printf("FPA: All Tests - Context Number = %d\n", val_rotate); temp_test_number = 0; if (debug || verbose) printf("FPA: Ierr Test.\n"); if (ierr_test()) { printf("FAILED Ierr Test\n"); fail_close(); return (-1); } temp_test_number = 1; if (verbose || debug) printf("FPA: Imask Test.\n"); if (imask_test()) { printf("FAILED Imask Test\n"); fail_close(); return (-1); } temp_test_number = 2; if (verbose || debug) printf("FPA: Load Pointer Test.\n"); if (ldptr_test()) { printf("FAILED Load Pointer Test\n"); fail_close(); return (-1); } /* turn the load enable bit to check the rams */ if ((io_value = ioctl(dev_no, FPA_LOAD_ON, (char *) null_str)) >= 0) { /* do the ram tests only * if the user is super * user */ temp_test_number = 3; if (verbose || debug) printf("FPA: Mapping Ram Test.\n"); if (map_ram()) { printf("FAILED Mapping Ram Test\n"); ioctl(dev_no, FPA_LOAD_OFF, (char *) null_str); fail_close(); return (-1); } temp_test_number = 4; if (verbose || debug) printf("FPA: Micro Store Ram Test.\n"); if (ustore_ram()) { printf("FAILED Micro Store Ram Test\n"); ioctl(dev_no, FPA_LOAD_OFF, (char *) null_str); fail_close(); return (-1); } ioctl(dev_no, FPA_LOAD_OFF, (char *) null_str); } temp_test_number = 5; if (verbose || debug) printf("FPA: Register Ram Upper Half Test.\n"); if (reg_uh_ram()) { printf("FAILED Register Ram Upper Half Test\n"); fail_close(); return (-1); } temp_test_number = 6; if (verbose || debug) printf("FPA: Register Ram Lower Half Test.\n"); if (reg_ram()) { printf("FAILED Register Ram Lower Half Test\n"); fail_close(); return (-1); } temp_test_number = 7; if (verbose || debug) printf("FPA: Simple Instruction Test.\n"); if (sim_ins_test()) { printf("FAILED Simple Instruction Test\n"); fail_close(); return (-1); } temp_test_number = 8; if (verbose || debug) printf("FPA: Shadow Ram Test.\n"); if (shadow_ram()) { printf("FAILED Shadow Ram Test\n"); fail_close(); return (-1); } temp_test_number = 9; if (verbose || debug) printf("FPA: Pointer Test.\n"); if (pointer_test()) { printf("FAILED Pointer Test\n"); fail_close(); return (-1); } temp_test_number = 10; if (verbose || debug) printf("FPA: Pointer Increment and Decrement Test.\n"); if (ptr_incdec_test()) { printf("FAILED Pointer Increment and Decrement Test\n"); fail_close(); return (-1); } sig_err_flag = 0xff; /* set the flag for error * handler */ temp_test_number = 11; if (verbose || debug) printf("FPA: Lock Test.\n"); if (lock_test()) { printf("FAILED Lock Test\n"); fail_close(); return (-1); } sig_err_flag = 0; /* reset the flag for error * handler */ seg_sig_flag = 0xff; /* set the flag for seg error * handler */ temp_test_number = 12; if (verbose || debug) printf("FPA: Nack Test.\n"); nack2_test(); /* if anything goes wrong the * program will not come back */ seg_sig_flag = 0x0; /* reset the flag for seg * error handler */ temp_test_number = 13; if (verbose || debug) printf("FPA F+ Test.\n"); if (wlwf_test()) { printf("FAILED F+ Test\n"); fail_close(); return (-1); } temp_test_number = 14; if (verbose || debug) printf("FPA: Mode Register Test.\n"); if (test_mode_reg()) { printf("FAILED Mode Register Test\n"); fail_close(); return (-1); } temp_test_number = 15; if (verbose || debug) printf("FPA: Wstatus Register Test.\n"); if (test_wstatus_reg()) { printf("FAILED Wstatus Register Test\n"); fail_close(); return (-1); } temp_test_number = 16; if (verbose || debug) printf("FPA: Weitek Data Path Test.\n"); if (fpa_wd()) { printf("FAILED Weitek Data Path Test\n"); fail_close(); return (-1); } temp_test_number = 17; if (verbose || debug) printf("FPA: Weitek Operation Test.\n"); if (w_op_test()) { printf("FAILED Weitek Operation Test\n"); fail_close(); return (-1); } temp_test_number = 18; if (verbose || debug) printf("FPA: Weitek Status Test.\n"); if (fpa_ws()) { printf("FAILED Weitek Status Test\n"); fail_close(); return (-1); } temp_test_number = 19; if (verbose || debug) printf("FPA: Jump Conditions Test.\n"); if (w_jump_cond_test()) { printf("FAILED Jump Condition Test\n"); fail_close(); return (-1); } temp_test_number = 20; if (verbose || debug) printf("FPA: Timing Test.\n"); if (timing()) { printf("FAILED Timing Test\n"); fail_close(); return (-1); } temp_test_number = 21; if (verbose || debug) printf("FPA: Linpack Test.\n"); if (val = lin_pack_test()) { if (val == 1) { fail_close(); } else { fail_close(); } return (-1); } close_new_context(); } else { restore_signals();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -