summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c481
1 files changed, 238 insertions, 243 deletions
diff --git a/init.c b/init.c
index 57239da..64be39f 100644
--- a/init.c
+++ b/init.c
@@ -56,129 +56,125 @@ extern int dmi_err_cnts[MAX_DMI_MEMDEVS];
/* 3: MP SMP - 4-7: RSVD */
void failsafe(int msec, int scs)
{
- int i;
- ulong sh, sl, l, h, t;
- unsigned char c;
- volatile char *pp;
-
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
- *pp = 0x1E;
- }
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<3; i++, pp+=2) {
- *pp = 0x9E;
- }
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(55*2)+1); i<3; i++, pp+=2) {
- *pp = 0x9E;
- }
+ int i;
+ ulong sh, sl, l, h, t;
+ unsigned char c;
+ volatile char *pp;
- cprint(18, 18, "==> Press F1 to enter Fail-Safe Mode <==");
+ for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
+ *pp = 0x1E;
+ }
+ for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<3; i++, pp+=2) {
+ *pp = 0x9E;
+ }
+ for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(55*2)+1); i<3; i++, pp+=2) {
+ *pp = 0x9E;
+ }
+
+ cprint(18, 18, "==> Press F1 to enter Fail-Safe Mode <==");
- if(v->fail_safe & 2)
- {
- cprint(19, 15, "==> Press F2 to force Multi-Threading (SMP) <==");
- }
-
- /* save the starting time */
- asm __volatile__(
- "rdtsc":"=a" (sl),"=d" (sh));
-
- /* loop for n seconds */
- while (1) {
- asm __volatile__(
- "rdtsc":"=a" (l),"=d" (h));
- asm __volatile__ (
- "subl %2,%0\n\t"
- "sbbl %3,%1"
- :"=a" (l), "=d" (h)
- :"g" (sl), "g" (sh),
- "0" (l), "1" (h));
-
- t = h * ((unsigned)0xffffffff / v->clks_msec);
- t += (l / v->clks_msec);
-
- /* Is the time up? */
- if (t >= msec) { break; }
+ if(vv->fail_safe & 2)
+ {
+ cprint(19, 15, "==> Press F2 to force Multi-Threading (SMP) <==");
+ }
+
+ /* save the starting time */
+ asm __volatile__
+ ("rdtsc":"=a" (sl),"=d" (sh));
+
+ /* loop for n seconds */
+ while (1) {
+ asm __volatile__(
+ "rdtsc":"=a" (l),"=d" (h));
+ asm __volatile__ (
+ "subl %2,%0\n\t"
+ "sbbl %3,%1"
+ :"=a" (l), "=d" (h)
+ :"g" (sl), "g" (sh),
+ "0" (l), "1" (h));
+
+ t = h * ((unsigned)0xffffffff / vv->clks_msec);
+ t += (l / vv->clks_msec);
+
+ /* Is the time up? */
+ if (t >= msec) { break; }
- /* Is expected Scan code pressed? */
- c = get_key();
- c &= 0x7f;
+ /* Is expected Scan code pressed? */
+ c = get_key();
+ c &= 0x7f;
- /* F1 */
- if(c == scs) { v->fail_safe |= 1; break; }
+ /* F1 */
+ if(c == scs) { vv->fail_safe |= 1; break; }
- /* F2 */
- if(c == scs+1)
- {
- v->fail_safe ^= 2;
- break;
-
- }
+ /* F2 */
+ if(c == scs+1)
+ {
+ vv->fail_safe ^= 2;
+ break;
+
+ }
- /* F3 */
- if(c == scs+2)
- {
- if(v->fail_safe & 2) { v->fail_safe ^= 2; }
- v->fail_safe |= 8;
- break;
- }
-
- }
-
- cprint(18, 18, " ");
- cprint(19, 15, " ");
-
- for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
- *pp = 0x17;
- }
-
+ /* F3 */
+ if(c == scs+2)
+ {
+ if(vv->fail_safe & 2) { vv->fail_safe ^= 2; }
+ vv->fail_safe |= 8;
+ break;
+ }
+ }
+
+ cprint(18, 18, " ");
+ cprint(19, 15, " ");
+
+ for(i=0, pp=(char *)(SCREEN_ADR+(18*160)+(18*2)+1); i<40; i++, pp+=2) {
+ *pp = 0x17;
+ }
}
-
-
static void display_init(void)
{
- int i;
- volatile char *pp;
+ int i;
+ volatile char *pp;
- /* Set HW cursor out of screen boundaries */
- __outb(0x0F, 0x03D4);
- __outb(0xFF, 0x03D5);
-
- __outb(0x0E, 0x03D4);
- __outb(0xFF, 0x03D5);
-
-
- serial_echo_init();
- serial_echo_print("INE_SCROLL;24r"); /* Set scroll area row 7-23 */
- serial_echo_print(""); /* Clear Screen */
- serial_echo_print("");
- serial_echo_print("");
- serial_echo_print("");
-
- /* Clear screen & set background to blue */
- for(i=0, pp=(char *)(SCREEN_ADR); i<80*24; i++) {
- *pp++ = ' ';
- *pp++ = 0x17;
- }
-
- /* Make the name background green */
- for(i=0, pp=(char *)(SCREEN_ADR+1); i<TITLE_WIDTH; i++, pp+=2) {
- *pp = 0x20;
- }
- cprint(0, 0, " Memtest86 5.01 ");
-
- /* Set Blinking "+" */
- for(i=0, pp=(char *)(SCREEN_ADR+1); i<2; i++, pp+=30) {
- *pp = 0xA4;
- }
- cprint(0, 15, "+");
-
- /* Do reverse video for the bottom display line */
- for(i=0, pp=(char *)(SCREEN_ADR+1+(24 * 160)); i<80; i++, pp+=2) {
- *pp = 0x71;
- }
-
- serial_echo_print("");
+ /* Set HW cursor out of screen boundaries */
+ __outb(0x0F, 0x03D4);
+ __outb(0xFF, 0x03D5);
+
+ __outb(0x0E, 0x03D4);
+ __outb(0xFF, 0x03D5);
+
+
+ serial_echo_init();
+ serial_echo_print("INE_SCROLL;24r"); /* Set scroll area row 7-23 */
+ serial_echo_print(""); /* Clear Screen */
+ serial_echo_print("");
+ serial_echo_print("");
+ serial_echo_print("");
+
+ /* Clear screen & set background to blue */
+ for(i=0, pp=(char *)(SCREEN_ADR); i<80*24; i++) {
+ *pp++ = ' ';
+ *pp++ = 0x17;
+ }
+
+ /* Make the name background green */
+ for(i=0, pp=(char *)(SCREEN_ADR+1); i<TITLE_WIDTH; i++, pp+=2) {
+ *pp = 0x20;
+ }
+ cprint(0, 0, " Memtest86 5.31b ");
+
+ /* Set Blinking "+" */
+ for(i=0, pp=(char *)(SCREEN_ADR+1); i<2; i++, pp+=30) {
+ *pp = 0xA4;
+ }
+ cprint(0, 15, "+");
+
+ /* Do reverse video for the bottom display line */
+ for(i=0, pp=(char *)(SCREEN_ADR+1+(24 * 160)); i<80; i++, pp+=2) {
+ *pp = 0x71;
+ }
+
+ serial_echo_print("");
}
/*
@@ -186,149 +182,148 @@ static void display_init(void)
*/
void init(void)
{
- int i;
+ int i;
- outb(0x8, 0x3f2); /* Kill Floppy Motor */
+ outb(0x8, 0x3f2); /* Kill Floppy Motor */
- /* Turn on cache */
- set_cache(1);
+ /* Turn on cache */
+ set_cache(1);
- /* Setup the display */
- display_init();
+ /* Setup the display */
+ display_init();
- cprint(5, 60, "| Time: 0:00:00");
- cprint(1, COL_MID,"Pass %");
- cprint(2, COL_MID,"Test %");
- cprint(3, COL_MID,"Test #");
- cprint(4, COL_MID,"Testing: ");
- cprint(5, COL_MID,"Pattern: ");
- cprint(1, 0, "CLK: (32b Mode)");
- cprint(2, 0, "L1 Cache: Unknown ");
- cprint(3, 0, "L2 Cache: Unknown ");
- cprint(4, 0, "L3 Cache: None ");
- cprint(5, 0, "Memory : ");
- cprint(6, 0, "------------------------------------------------------------------------------");
- cprint(7, 0, "Core#:");
- cprint(8, 0, "State:");
- cprint(9, 0, "Cores: Active / Total (Run: All) | Pass: 0 Errors: 0 ");
- cprint(10, 0, "------------------------------------------------------------------------------");
-
- /*
+ cprint(5, 60, "| Time: 0:00:00");
+ cprint(1, COL_MID,"Pass %");
+ cprint(2, COL_MID,"Test %");
+ cprint(3, COL_MID,"Test #");
+ cprint(4, COL_MID,"Testing: ");
+ cprint(5, COL_MID,"Pattern: ");
+ cprint(1, 0, "CLK: (32b Mode)");
+ cprint(2, 0, "L1 Cache: Unknown ");
+ cprint(3, 0, "L2 Cache: Unknown ");
+ cprint(4, 0, "L3 Cache: None ");
+ cprint(5, 0, "Memory : ");
+ cprint(6, 0, "------------------------------------------------------------------------------");
+ cprint(7, 0, "Core#:");
+ cprint(8, 0, "State:");
+ cprint(9, 0, "Cores: Active / Total (Run: All) | Pass: 0 Errors: 0 ");
+ cprint(10, 0, "------------------------------------------------------------------------------");
+
+ /*
for(i=0, pp=(char *)(SCREEN_ADR+(5*160)+(53*2)+1); i<20; i++, pp+=2) {
- *pp = 0x92;
+ *pp = 0x92;
}
-
+
for(i=0, pp=(char *)(SCREEN_ADR+0*160+1); i<80; i++, pp+=2) {
- *pp = 0x47;
+ *pp = 0x47;
}
- */
-
- cprint(7, 39, "| Chipset : Unknown");
- cprint(8, 39, "| Memory Type : Unknown");
+ */
+ cprint(7, 39, "| Chipset : Unknown");
+ cprint(8, 39, "| Memory Type : Unknown");
- for(i=0; i < 6; i++) {
- cprint(i, COL_MID-2, "| ");
- }
-
- footer();
-
- aprint(5, 10, v->test_pages);
-
- v->pass = 0;
- v->msg_line = 0;
- v->ecount = 0;
- v->ecc_ecount = 0;
- v->testsel = -1;
- v->msg_line = LINE_SCROLL-1;
- v->scroll_start = v->msg_line * 160;
- v->erri.low_addr.page = 0x7fffffff;
- v->erri.low_addr.offset = 0xfff;
- v->erri.high_addr.page = 0;
- v->erri.high_addr.offset = 0;
- v->erri.min_bits = 32;
- v->erri.max_bits = 0;
- v->erri.min_bits = 32;
- v->erri.max_bits = 0;
- v->erri.maxl = 0;
- v->erri.cor_err = 0;
- v->erri.ebits = 0;
- v->erri.hdr_flag = 0;
- v->erri.tbits = 0;
- for (i=0; tseq[i].msg != NULL; i++) {
- tseq[i].errors = 0;
- }
- if (dmi_initialized) {
- for (i=0; i < MAX_DMI_MEMDEVS; i++){
- if (dmi_err_cnts[i] > 0) {
- dmi_err_cnts[i] = 0;
- }
- }
- }
+ for(i=0; i < 6; i++) {
+ cprint(i, COL_MID-2, "| ");
+ }
- /* setup beep mode */
- beepmode = BEEP_MODE;
+ footer();
+
+ aprint(5, 10, vv->test_pages);
+
+ vv->pass = 0;
+ vv->msg_line = 0;
+ vv->ecount = 0;
+ vv->ecc_ecount = 0;
+ vv->testsel = -1;
+ vv->msg_line = LINE_SCROLL-1;
+ vv->scroll_start = vv->msg_line * 160;
+ vv->erri.low_addr.page = 0x7fffffff;
+ vv->erri.low_addr.offset = 0xfff;
+ vv->erri.high_addr.page = 0;
+ vv->erri.high_addr.offset = 0;
+ vv->erri.min_bits = 32;
+ vv->erri.max_bits = 0;
+ vv->erri.min_bits = 32;
+ vv->erri.max_bits = 0;
+ vv->erri.maxl = 0;
+ vv->erri.cor_err = 0;
+ vv->erri.ebits = 0;
+ vv->erri.hdr_flag = 0;
+ vv->erri.tbits = 0;
+ for (i=0; tseq[i].msg != NULL; i++) {
+ tseq[i].errors = 0;
+ }
+ if (dmi_initialized) {
+ for (i=0; i < MAX_DMI_MEMDEVS; i++){
+ if (dmi_err_cnts[i] > 0) {
+ dmi_err_cnts[i] = 0;
+ }
+ }
+ }
- /* Get the cpu and cache information */
- get_cpuid();
+ /* setup beep mode */
+ beepmode = BEEP_MODE;
- /* setup pci */
- pci_init();
+ /* Get the cpu and cache information */
+ get_cpuid();
- get_cache_size();
+ /* setup pci */
+ pci_init();
- cpu_type();
+ get_cache_size();
- cpu_cache_speed();
+ cpu_type();
- /* Check fail safe */
- failsafe(5000, 0x3B);
+ cpu_cache_speed();
- /* Initalize SMP */
- initialise_cpus();
-
- for (i = 0; i <num_cpus; i++) {
- dprint(7, i+7, i%10, 1, 0);
- cprint(8, i+7, "S");
- }
+ /* Check fail safe */
+ failsafe(5000, 0x3B);
- dprint(9, 19, num_cpus, 2, 0);
+ /* Initalize SMP */
+ initialise_cpus();
- if((v->fail_safe & 3) == 2)
- {
- cprint(LINE_CPU,9, "(SMP: Disabled)");
- cprint(LINE_RAM,9, "Running...");
- }
- // dprint(10, 5, found_cpus, 2, 0);
+ for (i = 0; i <num_cpus; i++) {
+ dprint(7, i+7, i%10, 1, 0);
+ cprint(8, i+7, "S");
+ }
- /* Find Memory Specs */
- if(v->fail_safe & 1)
- {
- cprint(LINE_CPU, COL_SPEC, " **** FAIL SAFE **** FAIL SAFE **** ");
- cprint(LINE_RAM, COL_SPEC, " No detection, same reliability ");
- } else {
- find_controller();
- get_spd_spec();
- if(num_cpus <= 16 && !(v->fail_safe & 4)) { coretemp(); }
- }
+ dprint(9, 19, num_cpus, 2, 0);
- if(v->check_temp > 0 && !(v->fail_safe & 4))
- {
- cprint(LINE_CPU, 26, "| CPU Temp");
- cprint(LINE_CPU+1, 26, "| øC");
- }
+ if((vv->fail_safe & 3) == 2)
+ {
+ cprint(LINE_CPU,9, "(SMP: Disabled)");
+ cprint(LINE_RAM,9, "Running...");
+ }
+ // dprint(10, 5, found_cpus, 2, 0);
+
+ /* Find Memory Specs */
+ if(vv->fail_safe & 1)
+ {
+ cprint(LINE_CPU, COL_SPEC, " **** FAIL SAFE **** FAIL SAFE **** ");
+ cprint(LINE_RAM, COL_SPEC, " No detection, same reliability ");
+ } else {
+ find_controller();
+ get_spd_spec();
+ if(num_cpus <= 16 && !(vv->fail_safe & 4)) { coretemp(); }
+ }
+
+ if(vv->check_temp > 0 && !(vv->fail_safe & 4))
+ {
+ cprint(LINE_CPU, 26, "| CPU Temp");
+ cprint(LINE_CPU+1, 26, "| øC");
+ }
- beep(600);
- beep(1000);
+ beep(600);
+ beep(1000);
- /* Record the start time */
- asm __volatile__ ("rdtsc":"=a" (v->startl),"=d" (v->starth));
- v->snapl = v->startl;
- v->snaph = v->starth;
- if (l1_cache == 0) { l1_cache = 64; }
- if (l2_cache == 0) { l1_cache = 512; }
- v->printmode=PRINTMODE_ADDRESSES;
- v->numpatn=0;
+ /* Record the start time */
+ asm __volatile__ ("rdtsc":"=a" (vv->startl),"=d" (vv->starth));
+ vv->snapl = vv->startl;
+ vv->snaph = vv->starth;
+ if (l1_cache == 0) { l1_cache = 64; }
+ if (l2_cache == 0) { l1_cache = 512; }
+ vv->printmode=PRINTMODE_ADDRESSES;
+ vv->numpatn=0;
}
/* Get cache sizes for most AMD and Intel CPUs, exceptions for old CPUs are
@@ -578,13 +573,13 @@ void detect_imc(void)
{
case 0x5:
if(cpu_id.vers.bits.extendedModel == 2) { imc_type = 0x0003; } // Core i3/i5 1st Gen 45 nm (NHM)
- if(cpu_id.vers.bits.extendedModel == 3) { v->fail_safe |= 4; } // Atom Clover Trail
+ if(cpu_id.vers.bits.extendedModel == 3) { vv->fail_safe |= 4; } // Atom Clover Trail
if(cpu_id.vers.bits.extendedModel == 4) { imc_type = 0x0007; } // HSW-ULT
break;
case 0x6:
if(cpu_id.vers.bits.extendedModel == 3) {
imc_type = 0x0009; // Atom Cedar Trail
- v->fail_safe |= 4; // Disable Core temp
+ vv->fail_safe |= 4; // Disable Core temp
}
break;
case 0xA:
@@ -606,7 +601,7 @@ void detect_imc(void)
{
case 0x1:
if(cpu_id.vers.bits.stepping > 9) { imc_type = 0x0008; } // Atom PineView
- v->fail_safe |= 4; // Disable Core temp
+ vv->fail_safe |= 4; // Disable Core temp
break;
case 0x2:
imc_type = 0x0002; // Core i7 1st Gen 32 nm (WMR)
@@ -633,16 +628,16 @@ void smp_default_mode(void)
{
int i, result;
char *cpupsn = cpu_id.brand_id.char_array;
- char *disabledcpu[] = { "Opteron", "Xeon", "Genuine Intel" };
+ char *disabledcpu[] = { "Opteron", "Xeon", "EPYC", "Genuine Intel" };
for(i = 0; i < 3; i++)
{
- result = strstr(cpupsn , disabledcpu[i]);
- if(result != -1) { v->fail_safe |= 0b10; }
+ result = mt86_strstr(cpupsn , disabledcpu[i]);
+ if(result != -1) { vv->fail_safe |= 0b10; }
}
// For 5.01 release, SMP disabled by defualt by config.h toggle
- if(conservative_smp) { v->fail_safe |= 0b10; }
+ if(conservative_smp) { vv->fail_safe |= 0b10; }
}
@@ -1096,8 +1091,8 @@ void get_mem_speed(int me, int ncpus)
/* Make sure that we have enough memory to do the test */
/* If not use all we have */
- if ((1 + (i * 2)) > (v->plim_upper << 2)) {
- i = ((v->plim_upper <<2) - 1) / 2;
+ if ((1 + (i * 2)) > (vv->plim_upper << 2)) {
+ i = ((vv->plim_upper <<2) - 1) / 2;
}
speed = memspeed(STEST_ADDR, i * 1024, 100);
@@ -1145,11 +1140,11 @@ static int cpuspeed(void)
if (loops < 4 || end_low < 50000) {
return(-1);
}
- v->clks_msec = end_low/50;
+ vv->clks_msec = end_low/50;
if (tsc_invariable) end_low = correct_tsc(end_low);
- return(v->clks_msec);
+ return(vv->clks_msec);
}
/* Measure cache speed by copying a block of memory. */
@@ -1259,7 +1254,7 @@ ulong memspeed(ulong src, ulong len, int iter)
if (tsc_invariable) end_low = correct_tsc(end_low);
- return((v->clks_msec)/end_low);
+ return((vv->clks_msec)/end_low);
}
#define rdmsr(msr,val1,val2) \