int mem_operation_write_addr_comp(int num_operations,void *seg_address,void *pattern_ptr,int trap_flag,void *seg,void *stanza,void *pattern_sz_ptr,void* seed){ int i=0,rc=0; unsigned long *rw_ptr = (unsigned long *)seg_address; unsigned long address = *(unsigned long *)seg_address; unsigned long read_dw_data; for (i=0;i<num_operations;i++){ *rw_ptr = address; dcbf((volatile unsigned long*)rw_ptr); read_dw_data = *(unsigned long *)rw_ptr; if(read_dw_data != address) { if(trap_flag){ #ifndef __HTX_LINUX__ trap(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)rw_ptr,(unsigned long)seg,(unsigned long)stanza); #else do_trap_htx64(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)rw_ptr,(unsigned long)seg,(unsigned long)stanza); #endif } rc = i+1; break; } rw_ptr = rw_ptr + 1; address = (unsigned long)rw_ptr; rc = 0; } return rc; }
int mem_operation_rim_byte(int num_operations,void *seg_address,void *pattern_ptr,int trap_flag,void *seg,void *stanza,void *pattern_sz_ptr,void* seed){ int i=0,rc=0; char *w_ptr = (char*)seg_address; char read_data; for (i=0; i < num_operations; i++) { *w_ptr = *(char*)pattern_ptr; read_data = *(char*)w_ptr; dcbf((volatile char*)w_ptr); read_data = *(char*)w_ptr; if(read_data != *(char*)pattern_ptr) { if(trap_flag){ #ifndef __HTX_LINUX__ trap(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)w_ptr,(unsigned long)seg,(unsigned long)stanza); #else do_trap_htx64(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)w_ptr,(unsigned long)seg,(unsigned long)stanza); #endif } rc = i+1; break; } w_ptr = w_ptr + 1; rc = 0; } return rc; }
int mem_operation_comp_byte(int num_operations,void *seg_address,void *pattern_ptr,int trap_flag,void *seg,void *stanza,void *pattern_sz_ptr,void* seed){ volatile unsigned char *ptr = (unsigned char *)seg_address, *loc_pattern_ptr = (unsigned char *)pattern_ptr; int i=0,rc=0; for (i=0; i < num_operations; i++) { if(*ptr != *loc_pattern_ptr) { if(trap_flag){ #ifndef __HTX_LINUX__ trap(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)ptr,(unsigned long)seg,(unsigned long)stanza); #else do_trap_htx64(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)ptr,(unsigned long)seg,(unsigned long)stanza); #endif } rc = i+1; break; } ptr = ptr + 1; rc = 0; } return rc; }
int mem_operation_comp_addr(int num_operations,void *seg_address,void *pattern_ptr,int trap_flag,void *seg,void *stanza,void *pattern_sz_ptr,void* seed){ int i=0,rc=0; unsigned long *ptr = (unsigned long *)seg_address ; unsigned long address = *(unsigned long *)seg_address; for (i=0; i < num_operations; i++) { if(*ptr != address) { if(trap_flag){ #ifndef __HTX_LINUX__ trap(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)ptr,(unsigned long)seg,(unsigned long)stanza); #else do_trap_htx64(0xBEEFDEAD,i,(unsigned long)seg_address,(unsigned long)pattern_ptr,(unsigned long)ptr,(unsigned long)seg,(unsigned long)stanza); #endif } rc = i+1; break; } ptr = ptr + 1; address = (unsigned long)ptr; rc = 0; } return rc; }
char cmpbuf(struct htx_data *ps, struct ruleinfo *pr, int loop, int *blkno, char wbuf[], char rbuf[]) { int c, mis_flag = FALSE; char s[3], ctime[9], path[128]; char work_str[512], msg1[MAX_TEXT_MSG]; static int cnt_flag = FALSE; register long i, j; static ushort cnt = 0, m2f2_cnt = 0; static struct { int start_lba; int offset; time_t dtime; char cpath[128]; char rpath[128]; } m2f2[M2F2_MISCOM_THRESH]; i = 0; while ( (mis_flag == FALSE) && (i < pr->dlen) ) { if ( wbuf[i] != rbuf[i] ) { if ( crash_on_mis && ( strcmp(pr->mode, "M2F2") != 0 ) ) { #ifndef __HTX_LINUX__ /* AIX */ setleds( 0x2010 ); trap(0xBEEFDEAD, wbuf, rbuf, i, ps, pr); #else do_trap_htx64( 0xBEEFDEAD, wbuf, rbuf, i, ps, pr ); #endif } /* crash_sys(0xBEEFDEAD, wbuf, rbuf, i, ps->sdev_id); */ mis_flag = TRUE; } else i++; } if ( mis_flag == TRUE ) { ps->bad_others = ps->bad_others + 1; sprintf(msg1, "Miscompare at buffer offset %d (0x%x) " "\ncbuf (baseaddr 0x%x) ", i, i, wbuf); for ( j = i; ((j - i) < 20) && (j < pr->dlen); j++ ) { sprintf(s, "%0.2x", wbuf[j]); strcat(msg1, s); } sprintf(work_str, "\nrbuf (baseaddr 0x%x) ",rbuf); strcat(msg1, work_str); for ( j = i; ((j - i) < 20) && (j < pr->dlen); j++ ) { sprintf(s, "%0.2x", rbuf[j]); strcat(msg1, s); } strcat(msg1, "\n"); if ( strcmp(pr->mode, "M2F2") != 0 ) { cnt++; if ( cnt < 10 ) { strcpy(path, DUMP_PATH); strcat(path, "htx"); strcat(path, &(ps->sdev_id[5])); strcat(path, ".cbuf"); sprintf(work_str, "%-d", cnt); strcat(path, work_str); hxfsbuf(wbuf, pr->dlen, path, ps); sprintf(work_str, "Compare buffer saved in %s\n", path); strcat(msg1, work_str); strcpy(path, DUMP_PATH); strcat(path, "htx"); strcat(path, &(ps->sdev_id[5])); strcat(path, ".rbuf"); sprintf(work_str, "%-d", cnt); strcat(path, work_str); hxfsbuf(rbuf, pr->dlen, path, ps); sprintf(work_str, "Read buffer saved in %s\n", path); strcat(msg1, work_str); } else { sprintf(work_str, "The maximum number of saved miscompare " "buffers (10) have already\n been saved " "The compare and read buffers for this " "miscompare will\nnot be saved to disk"); strcat(msg1, work_str); } /* prt_msg_asis(ps, pr, loop, blkno, 100, HARD, msg1); */ prt_msg_asis(ps, pr, loop, blkno, 100, HTX_HE_MISCOMPARE, msg1); return(1); } else { if ( cnt_flag == TRUE ) { if ( m2f2_cnt == 1 ) { for ( c = 0; c < (M2F2_MISCOM_THRESH - 1); c++ ) { unlink(m2f2[c].cpath); unlink(m2f2[c].rpath); } rename(m2f2[2].cpath, m2f2[0].cpath); rename(m2f2[2].rpath, m2f2[0].rpath); m2f2[0].start_lba = m2f2[2].start_lba; m2f2[0].offset = m2f2[2].offset; m2f2[0].dtime = m2f2[2].dtime; } else { for ( c = 0; c < (M2F2_MISCOM_THRESH - 1); c++ ) { unlink(m2f2[c].cpath); unlink(m2f2[c].rpath); rename(m2f2[c+1].cpath, m2f2[c].cpath); rename(m2f2[c+1].rpath, m2f2[c].rpath); m2f2[c].start_lba = m2f2[c+1].start_lba; m2f2[c].offset = m2f2[c+1].offset; m2f2[c].dtime = m2f2[c+1].dtime; } } cnt_flag = FALSE; } m2f2[m2f2_cnt].start_lba = blkno[0]; m2f2[m2f2_cnt].offset = i; (void) time(&m2f2[m2f2_cnt].dtime); m2f2_cnt++; strcpy(path, DUMP_PATH); strcat(path, "m2f2"); strcat(path, &(ps->sdev_id[5])); strcat(path, ".cbuf"); sprintf(work_str, "%-d", m2f2_cnt); strcat(path, work_str); strcpy(m2f2[m2f2_cnt-1].cpath, path); hxfsbuf(wbuf, pr->dlen, path, ps); sprintf(work_str, "M2F2 Compare buffer saved in %s\n", path); strcat(msg1, work_str); strcpy(path, DUMP_PATH); strcat(path, "m2f2"); strcat(path, &(ps->sdev_id[5])); strcat(path, ".rbuf"); sprintf(work_str, "%-d", m2f2_cnt); strcat(path, work_str); strcpy(m2f2[m2f2_cnt-1].rpath, path); hxfsbuf(rbuf, pr->dlen, path, ps); sprintf(work_str, "M2F2 Read buffer saved in %s\n", path); strcat(msg1, work_str); if ( m2f2_cnt < M2F2_MISCOM_THRESH ) { strcat(msg1,"\n NOTE: The above miscompare is reported as a SOFT error because \n 3 miscompares are allowed in one hour for M2F2 data. \n We trap to kdb / xmon if the number of miscompares exceeds 3 in one hour."); prt_msg_asis(ps, pr, loop, blkno, 4, SOFT, msg1); return(0); } else { if ( m2f2[2].dtime > (m2f2[0].dtime + 3600) ) { if ( m2f2[2].dtime > (m2f2[1].dtime + 3600) ) m2f2_cnt = 1; else m2f2_cnt--; cnt_flag = TRUE; prt_msg_asis(ps, pr, loop, blkno, 0, SOFT, msg1); return(0); } else { if ( crash_on_mis ) { #ifndef __HTX_LINUX__ /* AIX */ setleds( 0x2010 ); trap(0xBEEFDEAD, wbuf, rbuf, i, ps, pr); #else do_trap_htx64( 0xBEEFDEAD, wbuf, rbuf, i, ps, pr ); #endif } sprintf(work_str, "There have been %d M2F2 miscompares in" " the past HOUR!\n", M2F2_MISCOM_THRESH); strcat(msg1, work_str); strftime(&ctime, 9, "%T", localtime(&m2f2[0].dtime)); sprintf(work_str, "Start LBA = %d Offset = %d Time = %s\n", m2f2[0].start_lba, m2f2[0].offset, ctime); strcat(msg1, work_str); strftime(&ctime, 9, "%T", localtime(&m2f2[1].dtime)); sprintf(work_str, "Start LBA = %d Offset = %d Time = %s\n", m2f2[1].start_lba, m2f2[1].offset, ctime); strcat(msg1, work_str); strftime(&ctime, 9, "%T", localtime(&m2f2[2].dtime)); sprintf(work_str, "Start LBA = %d Offset = %d Time = %s\n", m2f2[2].start_lba, m2f2[2].offset, ctime); strcat(msg1, work_str); m2f2_cnt--; cnt_flag = TRUE; /* prt_msg_asis(ps, pr, loop, blkno, 100, HARD, msg1); */ prt_msg_asis(ps, pr, loop, blkno, 100, HTX_HE_MISCOMPARE, msg1); return(-1); } } } } return(0); }