void show_spd(void) { int index; int i, j; int flag = 0; pop2up(); wait_keyup(); index = find_smb_controller(); if (index == -1) { cprint(POP2_Y, POP2_X+1, "SMBus Controller not known"); while (!get_key()); wait_keyup(); pop2down(); return; } else cprint(POP2_Y, POP2_X+1, "SPD Data: Slot"); smbcontrollers[index].get_adr(); for (j = 0; j < 16; j++) { if (smbcontrollers[index].read_spd(j) == 0) { dprint(POP2_Y, POP2_X + 15, j, 2, 0); for (i = 0; i < 256; i++) { hprint2(2 + POP2_Y + i / 16, 3 + POP2_X + (i % 16) * 3, spd[i], 2); } flag = 0; while(!flag) { if (get_key()) flag++; } wait_keyup(); } } pop2down(); }
void main(void) { long op1, op2; //32-bit operands char* ptr; //pointer to keypad buffer char* blanks; char kbuf[12]; //keypad buffer char c, a; int i; ptr = kbuf; blanks = " "; PLL_init(); //set system clock freq to 24MHz lcd_init(); //enable lcd keypad_enable(); //enable keypad set_lcd_addr(0x00); //display on 1st line i = 0; while(1) { c = getkey(); //read keypad a = hex2asc(c); //convert to ascii kbuf[i] = a; // and store in kbuf if(c<10) { //if 0 - 9 data8(a); // display on lcd wait_keyup(); // wait to release key i++; //increment index } else { switch(c) { case 0xE: //if enter (*) key op1 = number(ptr); //convert to binary set_lcd_addr(0x40); //display on 2nd line write_long_lcd(op1); set_lcd_addr(0x00); //clear 1st line type_lcd(blanks); wait_keyup(); //wait to release key i = 0; //reset kbuf index set_lcd_addr(0x00); //display on 2nd line break; case 0xA: //if key A op2 = number(ptr); //convert to binary op1 = op1 + op2; //compete sum set_lcd_addr(0x40); //display on 2nd line write_long_lcd(op1); set_lcd_addr(0x00); //clear 1st line type_lcd(blanks); wait_keyup(); //wait to release key i = 0; //reset kbuf index set_lcd_addr(0x00); //display on 1st line break; case 0xF: //if clear (#) key clear_lcd(); //clear lcd display wait_keyup(); //wait to release key i = 0; //reset kbuf index break; default: break; } } } }
/*** get keypad input ****/ void get_keypad_input() { char keypad_key; keypad_enable(); while(training) { keypad_key=getkey(); // get value from keypad wait_keyup(); lcd_init(); set_lcd_addr(0x00); if(keypad_key==1) { // 1 = forward move_forward(); }else if(keypad_key==4) { // 4 = left move_left(); }else if(keypad_key==7) { // 7 = right move_right(); }else if(keypad_key==0) { // 0 = reverse move_reverse(); }else if(keypad_key==6) { // 7 = pause move_pause(); }else if(keypad_key==9) { // break out of training mode training=0; move_stop(); display_movement(&stop_training); break; }else{ display_movement(&error); } ms_delay(50); } }
void performance() { extern int l1_cache, l2_cache; ulong speed; int i; popclear(); cprint(POP_Y+1, POP_X+1, " Read Write Copy"); cprint(POP_Y+3, POP_X+1, "L1 Cache:"); speed=memspeed((ulong)mapping(0x100), (l1_cache/4)*1024, 50, MS_READ); dprint(POP_Y+3, POP_X+10, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), (l1_cache/4)*1024, 50, MS_WRITE); dprint(POP_Y+3, POP_X+17, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), (l1_cache/4)*1024, 50, MS_COPY); dprint(POP_Y+3, POP_X+24, speed, 6, 0); if (l2_cache < l1_cache) { i = l1_cache / 4 + l2_cache / 4; } else { i = l1_cache; } cprint(POP_Y+5, POP_X+1, "L2 Cache:"); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_READ); dprint(POP_Y+5, POP_X+10, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_WRITE); dprint(POP_Y+5, POP_X+17, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_COPY); dprint(POP_Y+5, POP_X+24, speed, 6, 0); /* Determine memory speed. To find the memory spped we use */ /* A block size that is 5x the sum of the L1 and L2 caches */ i = (l2_cache + l1_cache) * 5; /* Make sure that we have enough memory to do the test */ if ((1 + (i * 2)) > (v->plim_upper << 2)) { i = ((v->plim_upper <<2) - 1) / 2; } cprint(POP_Y+7, POP_X+1, "Memory:"); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_READ); dprint(POP_Y+7, POP_X+10, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_WRITE); dprint(POP_Y+7, POP_X+17, speed, 6, 0); speed=memspeed((ulong)mapping(0x100), i*1024, 50, MS_COPY); dprint(POP_Y+7, POP_X+24, speed, 6, 0); wait_keyup(); while (get_key() == 0); popclear(); }
void addOper(char c, Flag *flag){ if(flag->olock == false){ flag->olock = true; clear_lcd(); //clear display, set cursor to 1st line //----------Add c to oper string------------- if(oidx > 0){ strcat(oper, kbuf); oidx += kidx; } else{ oidx = kidx; strcpy(oper, kbuf); } oper[oidx++] = c; if(c == '-'){ oper[oidx++] = ' '; flag->opback = 2; } else flag->opback = 1; flag->nlock = false; flag->deci = false; kidx = 0; //----------------------------------------------- } //end olock == false //----------------Replace Operator--------------- else { oper[oidx-flag->opback] = c; //replace most recent operator with operator c if(flag->opback == 2) { //opback = 2 means minus was last replaced oper[--oidx] = '\0'; //get rid of the space added by the minus flag->opback = 1; //change opback back to 1 } if(c == '-') { //if replacing with minus, add a space oper[oidx++] = ' '; flag->opback = 2; //opback becomes to since space added } } //--------------------------------------------- display(oper, oidx, 0x00); wait_keyup(); }
void get_config() { int flag = 0, sflag = 0, i, prt = 0; int reprint_screen = 0; ulong page; #if NMOD_FRAMEBUFFER > 0 stop_record(); #endif popup(); wait_keyup(); while(!flag) { cprint(POP_Y+1, POP_X+2, "Configuration:"); cprint(POP_Y+3, POP_X+6, "(1) Test Selection"); cprint(POP_Y+4, POP_X+6, "(2) Address Range"); cprint(POP_Y+5, POP_X+6, "(3) Memory Sizing"); cprint(POP_Y+6, POP_X+6, "(4) Error Summary"); cprint(POP_Y+7, POP_X+6, "(5) Error Report Mode"); cprint(POP_Y+8, POP_X+6, "(6) ECC Mode"); cprint(POP_Y+9, POP_X+6, "(7) Restart"); cprint(POP_Y+10, POP_X+6, "(8) Refresh Screen"); cprint(POP_Y+11, POP_X+6, "(9) Adv. Options"); cprint(POP_Y+12,POP_X+6,"(0) Continue"); /* Wait for key release */ /* Fooey! This nuts'es up the serial input. */ sflag = 0; switch(get_key()) { case 2: /* 1 - Test Selection */ popclear(); cprint(POP_Y+1, POP_X+2, "Test Selection:"); cprint(POP_Y+3, POP_X+6, "(1) Default Tests"); cprint(POP_Y+4, POP_X+6, "(2) Skip Current Test"); cprint(POP_Y+5, POP_X+6, "(3) Select Test"); cprint(POP_Y+6, POP_X+6, "(4) Select Bit Fade Test"); cprint(POP_Y+7, POP_X+6, "(0) Continue"); if (v->testsel < 0) { cprint(POP_Y+3, POP_X+5, ">"); } else { cprint(POP_Y+5, POP_X+5, ">"); } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Default */ if (v->testsel == 9) { bail++; } v->testsel = -1; find_ticks(); sflag++; cprint(LINE_INFO, COL_TST, "Std"); break; case 3: /* Skip test */ bail++; sflag++; break; case 4: /* Select test */ popclear(); cprint(POP_Y+1, POP_X+3, "Test Selection:"); cprint(POP_Y+4, POP_X+5, "Test Number [0-9]: "); i = getval(POP_Y+4, POP_X+24, 0); if (i <= 9) { if (i != v->testsel) { v->pass = -1; v->test = -1; } v->testsel = i; } find_ticks(); sflag++; bail++; cprint(LINE_INFO, COL_TST, "#"); dprint(LINE_INFO, COL_TST+1, i, 2, 1); break; case 5: if (v->testsel != 9) { v->pass = -1; v->test = -1; } v->testsel = 9; find_ticks(); sflag++; bail++; cprint(LINE_INFO, COL_TST, "#"); dprint(LINE_INFO, COL_TST+1, 9, 2, 1); break; case 11: case 57: sflag++; break; } } popclear(); break; case 3: /* 2 - Address Range */ popclear(); cprint(POP_Y+1, POP_X+2, "Test Address Range:"); cprint(POP_Y+3, POP_X+6, "(1) Set Lower Limit"); cprint(POP_Y+4, POP_X+6, "(2) Set Upper Limit"); cprint(POP_Y+5, POP_X+6, "(3) Test All Memory"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Lower Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Lower Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_lower); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page + 1 <= v->plim_upper) { v->plim_lower = page; bail++; } adj_mem(); find_ticks(); sflag++; break; case 3: /* Upper Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Upper Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_upper); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page - 1 >= v->plim_lower) { v->plim_upper = page; bail++; } adj_mem(); find_ticks(); sflag++; break; case 4: /* All of memory */ v->plim_lower = 0; v->plim_upper = v->pmap[v->msegs - 1].end; bail++; adj_mem(); find_ticks(); sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 4: /* 3 - Memory Sizing */ popclear(); cprint(POP_Y+1, POP_X+2, "Memory Sizing:"); cprint(POP_Y+3, POP_X+6, "(1) BIOS - Std"); if (e820_nr) { cprint(POP_Y+4, POP_X+6, "(2) BIOS - All"); cprint(POP_Y+5, POP_X+6, "(3) Probe"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); cprint(POP_Y+2+memsz_mode, POP_X+5, ">"); } else { cprint(POP_Y+4, POP_X+6, "(3) Probe"); cprint(POP_Y+5, POP_X+6, "(0) Continue"); if (memsz_mode == SZ_MODE_BIOS) { cprint(POP_Y+3, POP_X+5, ">"); } else { cprint(POP_Y+4, POP_X+5, ">"); } } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: memsz_mode = SZ_MODE_BIOS; wait_keyup(); restart(); /* mem_size(); v->test = 0; v->pass = 0; v->total_ticks = 0; bail++; sflag++; */ break; case 3: memsz_mode = SZ_MODE_BIOS_RES; wait_keyup(); restart(); /* mem_size(); v->test = 0; v->pass = 0; v->total_ticks = 0; bail++; sflag++; */ break; case 4: memsz_mode = SZ_MODE_PROBE; wait_keyup(); restart(); /* mem_size(); v->test = 0; v->pass = 0; v->total_ticks = 0; bail++; sflag++; */ break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 5: /* 4 - Show error summary */ popclear(); for (i=0; tseq[i].msg != NULL; i++) { cprint(POP_Y+1+i, POP_X+2, "Test:"); dprint(POP_Y+1+i, POP_X+8, i, 2, 1); cprint(POP_Y+1+i, POP_X+12, "Errors:"); dprint(POP_Y+1+i, POP_X+20, tseq[i].errors, 5, 1); } wait_keyup(); while (get_key() == 0); popclear(); break; case 6: /* 5 - Printing Mode */ popclear(); cprint(POP_Y+1, POP_X+2, "Printing Mode:"); cprint(POP_Y+3, POP_X+6, "(1) Individual Errors"); cprint(POP_Y+4, POP_X+6, "(2) BadRAM Patterns"); cprint(POP_Y+5, POP_X+6, "(3) Error Counts Only"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); cprint(POP_Y+3+v->printmode, POP_X+5, ">"); wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Separate Addresses */ v->printmode=PRINTMODE_ADDRESSES; v->eadr = 0; sflag++; break; case 3: /* BadRAM Patterns */ v->printmode=PRINTMODE_PATTERNS; sflag++; prt++; break; case 4: /* Error Counts Only */ v->printmode=PRINTMODE_NONE; sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 7: /* 6 - ECC Polling Mode */ popclear(); cprint(POP_Y+1, POP_X+2, "ECC Polling Mode:"); cprint(POP_Y+3, POP_X+6, "(1) Recommended"); cprint(POP_Y+4, POP_X+6, "(2) On"); cprint(POP_Y+5, POP_X+6, "(3) Off"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); wait_keyup(); while(!sflag) { switch(get_key()) { case 2: set_ecc_polling(-1); sflag++; break; case 3: set_ecc_polling(1); sflag++; break; case 4: set_ecc_polling(0); sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 8: wait_keyup(); restart(); break; case 9: reprint_screen = 1; flag++; break; case 10: get_menu(); break; case 11: case 57: case 28: /* 0/CR/SP - Continue */ flag++; break; } } popdown(); if (prt) { printpatn(); } if (reprint_screen){ tty_print_screen(); } }
void get_config() { int flag = 0, sflag = 0, i, prt = 0; int reprint_screen = 0; ulong page; popup(); wait_keyup(); while(!flag) { cprint(POP_Y+1, POP_X+2, "Settings:"); cprint(POP_Y+3, POP_X+6, "(1) Test Selection"); cprint(POP_Y+4, POP_X+6, "(2) Address Range"); cprint(POP_Y+5, POP_X+6, "(3) Memory Sizing"); cprint(POP_Y+6, POP_X+6, "(4) Error Report Mode"); cprint(POP_Y+7, POP_X+6, "(5) Show DMI Memory Info"); cprint(POP_Y+8, POP_X+6, "(6) ECC Mode"); cprint(POP_Y+9, POP_X+6, "(7) Restart"); cprint(POP_Y+10, POP_X+6, "(8) Refresh Screen"); //cprint(POP_Y+11, POP_X+6, "(9) Display SPD Data"); cprint(POP_Y+11, POP_X+6, "(9) Display Consecutive"); cprint(POP_Y+12, POP_X+6, " Failing Address Data"); cprint(POP_Y+13, POP_X+6, "(0) Continue"); /* Wait for key release */ /* Fooey! This nuts'es up the serial input. */ sflag = 0; switch(get_key()) { case 2: /* 1 - Test Selection */ popclear(); cprint(POP_Y+1, POP_X+2, "Test Selection:"); cprint(POP_Y+3, POP_X+6, "(1) Default Tests"); cprint(POP_Y+4, POP_X+6, "(2) Skip Current Test"); cprint(POP_Y+5, POP_X+6, "(3) Select Test"); cprint(POP_Y+6, POP_X+6, "(4) Select Bit Fade Test"); //cprint(POP_Y+7, POP_X+6, "(5) Select Uncached Test"); cprint(POP_Y+8, POP_X+6, "(0) Continue"); if (v->testsel < 0) { cprint(POP_Y+3, POP_X+5, ">"); } else { cprint(POP_Y+5, POP_X+5, ">"); } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Default */ if (v->testsel >= 9) { bail++; } v->testsel = -1; find_ticks_for_pass(); sflag++; cprint(LINE_INFO, COL_TST, "Std"); break; case 3: /* Skip test */ bail++; sflag++; break; case 4: /* Select test */ popclear(); cprint(POP_Y+1, POP_X+3, "Test Selection:"); cprint(POP_Y+4, POP_X+5, "Test Number [0-9]: "); i = getval(POP_Y+4, POP_X+24, 0); if (i <= 9) { if (i != v->testsel) { v->pass = -1; v->test = -1; } v->testsel = i; } find_ticks_for_pass(); sflag++; bail++; cprint(LINE_INFO, COL_TST, "#"); dprint(LINE_INFO, COL_TST+1, i, 2, 1); break; case 5: if (v->testsel != 9) { v->pass = -1; v->test = -1; } v->testsel = 9; find_ticks_for_pass(); sflag++; bail++; cprint(LINE_INFO, COL_TST, "#"); dprint(LINE_INFO, COL_TST+1, 9, 3, 1); break; /* case 6: if (v->testsel != 10) { v->pass = -1; v->test = -1; } v->testsel = 9+1; find_ticks_for_pass(); sflag++; bail++; cprint(LINE_INFO, COL_TST, "#"); dprint(LINE_INFO, COL_TST+1, 10, 3, 1); break; */ case 11: case 57: sflag++; break; } } popclear(); break; case 3: /* 2 - Address Range */ popclear(); cprint(POP_Y+1, POP_X+2, "Test Address Range:"); cprint(POP_Y+3, POP_X+6, "(1) Set Lower Limit"); cprint(POP_Y+4, POP_X+6, "(2) Set Upper Limit"); cprint(POP_Y+5, POP_X+6, "(3) Test All Memory"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Lower Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Lower Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_lower); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page + 1 <= v->plim_upper) { v->plim_lower = page; v->test--; bail++; } adj_mem(); find_ticks_for_pass(); sflag++; break; case 3: /* Upper Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Upper Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_upper); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page - 1 >= v->plim_lower) { v->plim_upper = page; v->test--; bail++; } adj_mem(); find_ticks_for_pass(); sflag++; break; case 4: /* All of memory */ v->plim_lower = 0; v->plim_upper = v->pmap[v->msegs - 1].end; v->test--; bail++; adj_mem(); find_ticks_for_pass(); sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 4: /* 3 - Memory Sizing */ popclear(); cprint(POP_Y+1, POP_X+2, "Memory Sizing:"); cprint(POP_Y+3, POP_X+6, "(1) BIOS - Std"); cprint(POP_Y+4, POP_X+6, "(2) Probe"); cprint(POP_Y+5, POP_X+6, "(0) Continue"); if(!e820_nr){ if (memsz_mode == SZ_MODE_BIOS) { cprint(POP_Y+3, POP_X+5, ">"); } else { cprint(POP_Y+4, POP_X+5, ">"); } } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: memsz_mode = SZ_MODE_BIOS; wait_keyup(); restart(); break; case 3: memsz_mode = SZ_MODE_PROBE; wait_keyup(); restart(); break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 5: /* 4 - Show error Mode */ popclear(); cprint(POP_Y+1, POP_X+2, "Printing Mode:"); cprint(POP_Y+3, POP_X+6, "(1) Error Summary"); cprint(POP_Y+4, POP_X+6, "(2) Individual Errors"); cprint(POP_Y+5, POP_X+6, "(3) BadRAM Patterns"); cprint(POP_Y+6, POP_X+6, "(4) Error Counts Only"); cprint(POP_Y+7, POP_X+6, "(5) DMI Device Name"); cprint(POP_Y+8, POP_X+6, "(6) Beep on Error"); cprint(POP_Y+10, POP_X+6, "(0) Cancel"); cprint(POP_Y+3+v->printmode, POP_X+5, ">"); if (beepmode) { cprint(POP_Y+8, POP_X+5, ">"); } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Error Summary */ v->printmode=PRINTMODE_SUMMARY; v->erri.eadr = 0; v->erri.hdr_flag = 0; sflag++; break; case 3: /* Separate Addresses */ v->printmode=PRINTMODE_ADDRESSES; v->erri.eadr = 0; v->erri.hdr_flag = 0; v->msg_line = LINE_SCROLL-1; sflag++; break; case 4: /* BadRAM Patterns */ v->printmode=PRINTMODE_PATTERNS; v->erri.hdr_flag = 0; sflag++; prt++; break; case 5: /* Error Counts Only */ v->printmode=PRINTMODE_NONE; v->erri.hdr_flag = 0; sflag++; break; case 6: /* Error Counts Only */ v->printmode=PRINTMODE_DMI; v->erri.hdr_flag = 0; sflag++; break; case 7: /* Set Beep On Error mode */ beepmode = !beepmode; sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 6: /* Display DMI Memory Info */ pop2up(); print_dmi_info(); pop2down(); break; case 7: /* 6 - ECC Polling Mode */ popclear(); cprint(POP_Y+1, POP_X+2, "ECC Polling Mode:"); cprint(POP_Y+3, POP_X+6, "(1) Recommended"); cprint(POP_Y+4, POP_X+6, "(2) On"); cprint(POP_Y+5, POP_X+6, "(3) Off"); cprint(POP_Y+6, POP_X+6, "(0) Continue"); wait_keyup(); while(!sflag) { switch(get_key()) { case 2: set_ecc_polling(-1); sflag++; break; case 3: set_ecc_polling(1); sflag++; break; case 4: set_ecc_polling(0); sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 8: wait_keyup(); restart(); break; case 9: reprint_screen = 1; flag++; break; case 10: //XXX was spddata //popdown(); //show_spd(); //popup(); //sflag++; //XXX was spddata ^ //Display Failing Address Data popclear(); wait_keyup(); int err_idx = 0; cprint(POP_Y+1, POP_X+2, "Consecutive Failing Addresses:"); cprint(POP_Y+3, POP_X+14, " of "); dprint(POP_Y+3, POP_X+19, v->err_range.size,4,0); cprint(POP_Y+5, POP_X+6, "Errors in range: "); cprint(POP_Y+6, POP_X+6, "Range Stride: "); cprint(POP_Y+7, POP_X+6, "High Address: 0x"); cprint(POP_Y+8, POP_X+6, "Low Address: 0x"); cprint(POP_Y+9, POP_X+6, "Histogram of faulty bits: <-bit 31, bit 0 ->"); cprint(POP_Y+12, POP_X+6, "Hit 1 to Continue, 0 to quit"); //option 1 //cprint(POP_Y+12, POP_X+6, "Hit a key to Continue"); //option 2 i = 1; int j = 0; int mag; ulong h; //loop through all records while ((i==1) && (err_idx<v->err_range.size)){ dprint(POP_Y+3, POP_X+6, err_idx+1,8,0);//number hprint(POP_Y+5, POP_X+22, v->err_range.ranges[err_idx].count_per_range);//err count per range hprint(POP_Y+6, POP_X+22, v->err_range.ranges[err_idx].range_stride);//stride per range hprint(POP_Y+7, POP_X+22, v->err_range.ranges[err_idx].high_addr);//high addr hprint(POP_Y+8, POP_X+22, v->err_range.ranges[err_idx].low_addr);//low addr //print histogram for (j=0;j<32;j++){ mag = 0; h = v->err_range.ranges[err_idx].hist[j]; while (h>0){ mag++; h = h>>1; } dprint(POP_Y+10, POP_X+6+(j*5), mag,4,0); } i = getval(POP_Y+12, POP_X+34, 0); //option 1 //wait_keyup(); //option 2 err_idx++; } //popup(); popclear(); sflag++; break; case 11: case 57: case 28: /* 0/CR/SP - Continue */ flag++; break; } } popdown(); if (prt) { printpatn(); } if (reprint_screen){ tty_print_screen(); } }
void shiftMode(char key, Flag *flag){ switch(key){ case 0xA: //if memory set (A) key - save number midx = kidx; strcpy(mem, kbuf); //copy data from kbuf to mem flag->save = true; led_on(1); //turn on 2nd led to indicate saved number wait_keyup(); break; case 0xB: //if memory recall (B) key - get saved number if(flag->save == true){ flag->olock = false; flag->nlock = true; strcpy(kbuf, mem); kidx = midx; //kbuf[kidx] = '\0'; clrLine(2); //clear line 2 display(kbuf, kidx, 0x40); wait_keyup(); } break; case 0x1: //if plus '+' (1) key addOper('+', flag); break; case 0x2: //if minus '-' (2) key addOper('-', flag); break; case 0x3: //if mod '%' (3) key addOper('%', flag); break; case 0x4: //if multiply '*' (4) key addOper('*', flag); break; case 0x5: //if divide key '/' (5) key addOper('/', flag); break; case 0x6: //if power '^' (6) key addOper('^', flag); break; case 0x7: //if left parenthesis '(' (7) key if(flag->olock == true){ flag->leftpar += 1; kbuf[kidx++] = '('; display(kbuf,kidx, 0x40); wait_keyup(); } break; case 0x8: //if right parenthesis ')' (8) key if(flag->leftpar>0 && flag->olock==false){ //if '(' present flag->leftpar -= 1; kbuf[kidx++] = ')'; display(kbuf,kidx, 0x40); flag->nlock = true; //nlock = true to stop taking number inputs wait_keyup(); } break; case 0x9: //if factorial '!' (9) key addOper('!', flag); break; case 0xC: //if clear (C) key flag->nlock = false; flag->olock = true; flag->deci = false; flag = createFlag(); clear_lcd(); kidx = 0; //reset kbuf index kbuf[kidx] = '\0'; //clear kbuf oidx = 0; //reset oper index oper[oidx] = '\0'; //clear oper substart = 0; set_lcd_addr(0x40); wait_keyup(); //wait to release key break; case 0xD: // if shift (D) key flag->shift = false; wait_keyup(); //wait to release key break; case 0xF: //if equal (#) key clrLine(1); //-------------------- if(oidx > 0){ strcat(oper, kbuf); oidx += kidx; } else{ oidx = kidx; strcpy(oper, kbuf); } oper[oidx++] = ' '; flag->nlock = false; flag->deci = false; kidx = 0; //------------------- --oidx; //remove space display(oper, oidx, 0x40); wait_keyup(); break; case 0x0: break; default: break; } //end switch }
void stdMode(char key, Flag *flag){ int i; char a = hex2asc(key); //convert to ascii kbuf[kidx] = a; // and store in kbuf if(key<10 && flag->nlock == false){ //if 0 - 9 if(kidx < 16){ flag->olock = false; // reset operator lock wait_keyup(); // wait to release key kidx++; //increment index display(kbuf, kidx,0x40); } } //end if(c<10) else{ //c !<10 switch(key){ /* case 0xB: sprintf(s, "%g", d); clear_lcd(); set_lcd_addr(0x40); type_lcd(s); wait_keyup(); break;*/ case 0xE: //if decimal (*) key if(flag->deci == false){ flag->deci = true; wait_keyup(); //wait to release key kbuf[kidx++] = '.'; //store '.' in kbuf display(kbuf, kidx, 0x40); } break; case 0xA: //if Postfix (A) key if(flag->post == false) { flag->post = true; //set flag to indicate input will be in postfix notation led_on(0); //turn on led 0 clrLine(2); kidx = 0; //reset index kbuf[kidx] = '\0'; //clear keypad buffer for new input } else { flag->post = false; //back to prefix mode led_off(0); //turn off led 0 clrLine(2); kidx = 0; kbuf[kidx] = '\0'; } wait_keyup(); break; case 0xC: //if delete (C) key if(kidx > 0){ //make sure index does not go below 0 if(is_number(kbuf[kidx-1])) flag->olock = true; if(kbuf[kidx-1] == '.') flag->deci = false; if(kbuf[kidx-1] == '(') flag->leftpar -= 1; if(kbuf[kidx-1] == ')') { flag->leftpar += 1; flag->nlock = false; flag->olock = false; } else flag->olock = true; kbuf[--kidx] = '\0'; //delete char at i by changing to null char clrLine(2); display(kbuf, kidx, 0x40); } wait_keyup(); break; case 0xD: //if shift (D) key flag->shift = true; wait_keyup(); //wait to release key break; case 0xF: //if negative (#) key if(flag->neg == false){ flag->neg = true; for(i = kidx; i > 0; i--){ kbuf[i] = kbuf[i-1]; } kbuf[0] = '-'; kidx++; } else{ flag->neg = false; for(i = 0; i < kidx; i++){ kbuf[i] = kbuf[i+1]; } kidx--; } clrLine(2); display(kbuf, kidx, 0x40); wait_keyup(); break; default: break; } //switch } //end else (c !< 10) }
void get_config() { int flag = 0, sflag = 0, i, j, k, n, m, prt = 0; int reprint_screen = 0; char cp[64]; ulong page; popup(); wait_keyup(); while(!flag) { cprint(POP_Y+1, POP_X+2, "Settings:"); cprint(POP_Y+3, POP_X+4, "(1) Select wat MEMEZ to test"); cprint(POP_Y+4, POP_X+4, "(2) Address Range"); cprint(POP_Y+5, POP_X+4, "(3) O NOES ERRORZ Mode"); cprint(POP_Y+6, POP_X+4, "(4) Select with COREZ 2 test"); cprint(POP_Y+7, POP_X+4, "(5) Refresh Screen"); cprint(POP_Y+8, POP_X+4, "(6) DISPLYUZ DMI DATUZ"); cprint(POP_Y+9, POP_X+4, "(7) such RAM much SPD"); cprint(POP_Y+11, POP_X+4, "(0) Continue rowHAMMER TIME"); /* Wait for key release */ /* Fooey! This nuts'es up the serial input. */ sflag = 0; switch(get_key()) { case 2: /* 1 - Test Selection */ popclear(); cprint(POP_Y+1, POP_X+2, "Test Selection:"); cprint(POP_Y+3, POP_X+6, "(1) Default Tests"); cprint(POP_Y+4, POP_X+6, "(2) Skip Current Test"); cprint(POP_Y+5, POP_X+6, "(3) Select Test"); cprint(POP_Y+6, POP_X+6, "(4) Enter Test List"); cprint(POP_Y+7, POP_X+6, "(0) Cancel"); if (v->testsel < 0) { cprint(POP_Y+3, POP_X+5, ">"); } else { cprint(POP_Y+5, POP_X+5, ">"); } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Default - All tests */ i = 0; while (tseq[i].cpu_sel) { tseq[i].sel = 1; i++; } find_ticks_for_pass(); sflag++; break; case 3: /* Skip test */ bail++; sflag++; break; case 4: /* Select test */ popclear(); cprint(POP_Y+1, POP_X+3, "Test Selection:"); cprint(POP_Y+4, POP_X+5, "Test Number [1-11]: "); n = getval(POP_Y+4, POP_X+24, 0) - 1; if (n <= 11) { /* Deselect all tests */ i = 0; while (tseq[i].cpu_sel) { tseq[i].sel = 0; i++; } /* Now set the selection */ tseq[n].sel = 1; v->pass = -1; test = n; find_ticks_for_pass(); sflag++; bail++; } break; case 5: /* Enter a test list */ popclear(); cprint(POP_Y+1, POP_X+3, "Enter a comma separated list"); cprint(POP_Y+2, POP_X+3, "of tests to execute:"); cprint(POP_Y+5, POP_X+5, "List: "); /* Deselect all tests */ k = 0; while (tseq[k].cpu_sel) { tseq[k].sel = 0; k++; } /* Get the list */ for (i=0; i<64; i++) cp[i] = 0; get_list(POP_Y+5, POP_X+10, 64, cp); /* Now enable all of the tests in the * list */ i = j = m = 0; while (1) { if (isdigit(cp[i])) { n = cp[i]-'0'; j = j*10 + n; i++; if (cp[i] == ',' || cp[i] == 0){ if (j < k) { tseq[j].sel = 1; m++; } if (cp[i] == 0) break; j = 0; i++; } } } /* If we didn't select at least one * test turn them all back on */ if (m == 0) { k = 0; while (tseq[k].cpu_sel) { tseq[k].sel = 1; k++; } } v->pass = -1; test = n; find_ticks_for_pass(); sflag++; bail++; break; case 11: case 57: sflag++; break; } } popclear(); break; case 3: /* 2 - Address Range */ popclear(); cprint(POP_Y+1, POP_X+2, "rowHAMMER TIME Address Range:"); cprint(POP_Y+3, POP_X+6, "(1) Set Lower Limit"); cprint(POP_Y+4, POP_X+6, "(2) Set Upper Limit"); cprint(POP_Y+5, POP_X+6, "(3) Test All Memory"); cprint(POP_Y+6, POP_X+6, "(0) Cancel"); wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Lower Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Lower Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_lower); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page + 1 <= v->plim_upper) { v->plim_lower = page; test--; bail++; } adj_mem(); find_chunks(); find_ticks_for_pass(); sflag++; break; case 3: /* Upper Limit */ popclear(); cprint(POP_Y+2, POP_X+4, "Upper Limit: "); cprint(POP_Y+4, POP_X+4, "Current: "); aprint(POP_Y+4, POP_X+13, v->plim_upper); cprint(POP_Y+6, POP_X+4, "New: "); page = getval(POP_Y+6, POP_X+9, 12); if (page - 1 >= v->plim_lower) { v->plim_upper = page; bail++; test--; } adj_mem(); find_chunks(); find_ticks_for_pass(); sflag++; break; case 4: /* All of memory */ v->plim_lower = 0; v->plim_upper = v->pmap[v->msegs - 1].end; test--; bail++; adj_mem(); find_chunks(); find_ticks_for_pass(); sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 4: /* Error Mode */ popclear(); cprint(POP_Y+1, POP_X+2, "Printing Mode:"); cprint(POP_Y+3, POP_X+6, "(1) O NOES ALL ERRORZ"); cprint(POP_Y+4, POP_X+6, "(2) O NOES ONE ERRORZ"); cprint(POP_Y+5, POP_X+6, "(3) BadRAM Patterns. BADRAM"); cprint(POP_Y+6, POP_X+6, "(4) O NOES HOW MANYZ ERRORZ"); cprint(POP_Y+7, POP_X+6, "(5) BEEP BEEP BEEP ERRORZ"); cprint(POP_Y+8, POP_X+6, "(0) GTFO"); cprint(POP_Y+3+v->printmode, POP_X+5, ">"); if (beepmode) { cprint(POP_Y+7, POP_X+5, ">"); } wait_keyup(); while (!sflag) { switch(get_key()) { case 2: /* Error Summary */ v->printmode=PRINTMODE_SUMMARY; v->erri.eadr = 0; v->erri.hdr_flag = 0; sflag++; break; case 3: /* Separate Addresses */ v->printmode=PRINTMODE_ADDRESSES; v->erri.eadr = 0; v->erri.hdr_flag = 0; v->msg_line = LINE_SCROLL-1; sflag++; break; case 4: /* BadRAM Patterns */ v->printmode=PRINTMODE_PATTERNS; v->erri.hdr_flag = 0; sflag++; prt++; break; case 5: /* Error Counts Only */ v->printmode=PRINTMODE_NONE; v->erri.hdr_flag = 0; sflag++; break; case 6: /* Set Beep On Error mode */ beepmode = !beepmode; sflag++; break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 5: /* CPU Mode */ reprint_screen = 1; popclear(); cprint(POP_Y+1, POP_X+2, "BRAINE Selection Mode:"); cprint(POP_Y+3, POP_X+6, "(1) Parallel (All)"); cprint(POP_Y+4, POP_X+6, "(2) Round Robin Hood (RRbH)"); cprint(POP_Y+5, POP_X+6, "(3) Sequential (Seq)"); cprint(POP_Y+6, POP_X+6, "(0) NOPE BYE"); cprint(POP_Y+2+cpu_mode, POP_X+5, ">"); wait_keyup(); while(!sflag) { switch(get_key()) { case 2: if (cpu_mode != CPM_ALL) bail++; cpu_mode = CPM_ALL; sflag++; popdown(); cprint(9,34,"All"); popup(); break; case 3: if (cpu_mode != CPM_RROBIN) bail++; cpu_mode = CPM_RROBIN; sflag++; popdown(); cprint(9,34,"RRb"); popup(); break; case 4: if (cpu_mode != CPM_SEQ) bail++; cpu_mode = CPM_SEQ; sflag++; popdown(); cprint(9,34,"Seq"); popup(); break; case 11: case 57: /* 0/CR - Continue */ sflag++; break; } } popclear(); break; case 6: reprint_screen = 1; flag++; break; case 7: /* Display DMI Memory Info */ pop2up(); print_dmi_info(); pop2down(); break; case 8: /* Display SPD Data */ popdown(); show_spd(); popup(); sflag++; break; case 11: case 57: case 28: /* 0/CR/SP - Continue */ flag++; break; } } popdown(); if (prt) { printpatn(); } if (reprint_screen){ tty_print_screen(); } }
void print_dmi_info(void){ int i,j,page; char * string=0; if(!dmi_initialized) init_dmi(); if (mem_devs_count == 0){ cprint(POP2_Y+1, POP2_X+2, "No valid DMI Memory Devices info found"); while (get_key() == 0); return; } for(page=1; page <= 1 + (mem_devs_count-1)/8; page++){ pop2clear(); cprint(POP2_Y+1, POP2_X+2, "DMI Memory Device Info (page "); itoa(string,page); cprint(POP2_Y+1, POP2_X+32, string); cprint(POP2_Y+1, POP2_X+33, "/"); itoa(string,1 + (mem_devs_count-1)/8); cprint(POP2_Y+1, POP2_X+34, string); cprint(POP2_Y+1, POP2_X+35, ")"); cprint(POP2_Y+3, POP2_X+4, "Location Size(MB) Speed(MHz) Type Form"); cprint(POP2_Y+4, POP2_X+4, "--------------------------------------------------------------"); for(i=8*(page-1); i<mem_devs_count && i<8*page; i++){ int size_in_mb; int yof; yof=POP2_Y+5+2*(i-8*(page-1)); cprint(yof, POP2_X+4, get_tstruct_string(&(mem_devs[i]->header), mem_devs[i]->dev_locator)); if (mem_devs[i]->size == 0){ cprint(yof, POP2_X+4+18, "Empty"); }else if (mem_devs[i]->size == 0xFFFF){ cprint(yof, POP2_X+4+18, "Unknown"); }else{ size_in_mb = 0xEFFF & mem_devs[i]->size; if (mem_devs[i]->size & 0x8000) size_in_mb = size_in_mb<<10; itoa(string, size_in_mb); cprint(yof, POP2_X+4+18, string); } //this is the only field that needs to be SMBIOS 2.3+ if ( mem_devs[i]->speed && mem_devs[i]->header.length > 21){ itoa(string, mem_devs[i]->speed); cprint(yof, POP2_X+4+27, string); }else{ cprint(yof, POP2_X+4+27, "Unknown"); } cprint(yof, POP2_X+4+37, memory_types[mem_devs[i]->type]); cprint(yof, POP2_X+4+44, form_factors[mem_devs[i]->form]); //print mappings int mapped=0,of=0; cprint(yof+1, POP2_X+6,"mapped to: "); for(j=0; j<md_maps_count; j++){ if (mem_devs[i]->header.handle != md_maps[j]->md_handle) continue; if (mapped++){ cprint(yof+1, POP2_X+17+of, ","); of++; } hprint3(yof+1, POP2_X+17+of, md_maps[j]->start<<10, 12); of += 12; cprint(yof+1, POP2_X+17+of, "-"); of++; hprint3(yof+1, POP2_X+17+of, md_maps[j]->end<<10, 12); of += 12; } if (!mapped) cprint(yof+1, POP2_X+17, "No mapping (Interleaved Device)"); } wait_keyup(); while (get_key() == 0); } }