diff options
author | Regia König | 2021-04-22 11:52:22 +0200 |
---|---|---|
committer | Regia König | 2021-04-22 11:52:22 +0200 |
commit | 7fb47b7e54acdf585b16c25617e44b2acb67d64f (patch) | |
tree | c5d1f33397e9436897bd9a56ad705b35a41edb66 | |
parent | Split GUIDs (diff) | |
parent | Try to fix failure cause by optimization pragma (diff) | |
download | memtest86-7fb47b7e54acdf585b16c25617e44b2acb67d64f.tar.gz memtest86-7fb47b7e54acdf585b16c25617e44b2acb67d64f.tar.xz memtest86-7fb47b7e54acdf585b16c25617e44b2acb67d64f.zip |
Merge branch 'master' of git.openslx.org:openslx-ng/memtest86
21 files changed, 719 insertions, 685 deletions
diff --git a/efi_memtest/Makefile b/efi_memtest/Makefile index 7ca8698..5a3a9ed 100644 --- a/efi_memtest/Makefile +++ b/efi_memtest/Makefile @@ -11,8 +11,11 @@ CFLAGS += -fno-common CFLAGS += -fno-strict-aliasing -g # EFI uses Microsoft ABI so no red zone is defined CFLAGS += -mno-red-zone -# use %rip-relative addressing wherever possible + +# use %rip-relative addressing wherever possible?? Or not? CFLAGS += -fpie +#CFLAGS += -fno-pie -no-pie -static + CFLAGS += -fPIC CFLAGS += -ffunction-sections CFLAGS += -fdata-sections @@ -68,7 +71,7 @@ $(MAIN_FILE).efi: $(MAIN_FILE).dll $(MAIN_FILE).dll: $(MAIN_FILE).lib - $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $(MAIN_FILE).dll \ + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) $(LIBRARIES) -o $(MAIN_FILE).dll \ -nostdlib \ -Wl,-n,-q,--gc-sections \ -Wl,--entry,_ModuleEntryPoint \ @@ -78,14 +81,13 @@ $(MAIN_FILE).dll: $(MAIN_FILE).lib -Wl,--script=memtest86+/efi/Include/GccBase.lds \ -z common-page-size=0x40 \ -u _ModuleEntryPoint \ - -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings \ - $(LIBRARIES) + -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings objcopy --strip-unneeded -R .eh_frame -v $(MAIN_FILE).dll $(MAIN_FILE).dll strip -R .strtab MemtestEfi.dll $(MAIN_FILE).lib: $(OBJS) gcc-ar crv OUTPUT/$(MAIN_FILE).lib $^ - rm $^ + #rm $^ $(MAIN_FILE).obj: $(MAIN_FILE).c $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $(MAIN_FILE).obj \ diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c index 0399b30..dcde760 100644 --- a/efi_memtest/MemtestEfi.c +++ b/efi_memtest/MemtestEfi.c @@ -12,6 +12,7 @@ extern EFI_SYSTEM_TABLE *gST; short logflag = 1; short log_fine = 0; +short log_cpuspeed = 0; short log_memspeed = 0; short log_mem_tbl = 1; short log_comp_seg = 0; diff --git a/efi_memtest/memtest86+/config.c b/efi_memtest/memtest86+/config.c index 03e1554..b848af1 100644 --- a/efi_memtest/memtest86+/config.c +++ b/efi_memtest/memtest86+/config.c @@ -12,6 +12,8 @@ #include "dmi.h" #include "stdint.h" +#include "logger.h" + extern int bail, beepmode; extern struct tseq tseq[]; extern short e820_nr; @@ -387,62 +389,21 @@ void get_config() void popup() { - print_popup(); - /*int i, j; - char *pp; - - for (i=POP_Y; i<POP_Y + POP_H; i++) { - for (j=POP_X; j<POP_X + POP_W; j++) { - pp = (char *)(uintptr_t)(SCREEN_ADR + (i * 160) + (j * 2)); - save[0][i-POP_Y][j-POP_X] = *pp; */ /* Save screen */ - /*set_scrn_buf(i, j, ' '); - *pp = ' '; */ /* Clear */ - /*pp++; - save[1][i-POP_Y][j-POP_X] = *pp; - *pp = 0x07; */ /* Change Background to black *//* - } - } - tty_print_region(POP_Y, POP_X, POP_Y+POP_H, POP_X+POP_W);*/ } void popdown() { print_mainscreen(); - /*int i, j; - char *pp; - - for (i=POP_Y; i<POP_Y + POP_H; i++) { - for (j=POP_X; j<POP_X + POP_W; j++) { - pp = (char *)(uintptr_t)(SCREEN_ADR + (i * 160) + (j * 2)); - *pp = save[0][i-POP_Y][j-POP_X];*/ /* Restore screen */ - /*set_scrn_buf(i, j, save[0][i-POP_Y][j-POP_X]); - pp++; - *pp = save[1][i-POP_Y][j-POP_X];*/ /* Restore color *//* - } - } - tty_print_region(POP_Y, POP_X, POP_Y+POP_H, POP_X+POP_W);*/ } void popclear() { print_popup(); - /*int i, j; - char *pp; - - for (i=POP_Y; i<POP_Y + POP_H; i++) { - for (j=POP_X; j<POP_X + POP_W; j++) { - pp = (char *)(uintptr_t)(SCREEN_ADR + (i * 160) + (j * 2)); - *pp = ' ';*/ /* Clear popup */ - /* set_scrn_buf(i, j, ' '); - pp++; - } - } - tty_print_region(POP_Y, POP_X, POP_Y+POP_H, POP_X+POP_W);*/ } -void pop2up() +void pop2up() // TODO when is this needed? { int i, j; char *pp; @@ -497,6 +458,13 @@ void pop2clear() void adj_mem(void) { + + if(1) { + char log[23] = "vvaaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } int i; vv->selected_pages = 0; @@ -504,11 +472,14 @@ void adj_mem(void) /* Segment inside limits ? */ if (vv->pmap[i].start >= vv->plim_lower && vv->pmap[i].end <= vv->plim_upper) { + + print_log(">>>>> 1", 7); // TODO remove vv->selected_pages += (vv->pmap[i].end - vv->pmap[i].start); continue; } /* Segment starts below limit? */ if (vv->pmap[i].start < vv->plim_lower) { + print_log(">>>>> 2", 7); // TODO remove /* Also ends below limit? */ if (vv->pmap[i].end < vv->plim_lower) { continue; @@ -527,6 +498,13 @@ void adj_mem(void) } /* Segment ends above limit? */ if (vv->pmap[i].end > vv->plim_upper) { + print_log(">>>>> 3", 7); // TODO remove + if(1) { + char log[23] = "plim_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } /* Also starts above limit? */ if (vv->pmap[i].start > vv->plim_upper) { continue; diff --git a/efi_memtest/memtest86+/cpuid.c b/efi_memtest/memtest86+/cpuid.c index 6edaf4d..b3030a5 100644 --- a/efi_memtest/memtest86+/cpuid.c +++ b/efi_memtest/memtest86+/cpuid.c @@ -85,9 +85,9 @@ void get_cpuid() } if (logflag) { - char vendor[26] = "get_cpuid(): Vendor ID = "; - vendor[25] = cpu_id.vend_id.char_array[0]; - print_log(vendor, sizeof(vendor)); + char vendor[26] = "get_cpuid(): Vendor ID = "; + vendor[25] = cpu_id.vend_id.char_array[0]; + print_log(vendor, sizeof(vendor)); } /* Get cache information */ diff --git a/efi_memtest/memtest86+/efi/Include/libs/BaseLib.lib b/efi_memtest/memtest86+/efi/Include/libs/BaseLib.lib Binary files differdeleted file mode 100644 index 676c5a9..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/BaseLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/BaseMemoryLib.lib b/efi_memtest/memtest86+/efi/Include/libs/BaseMemoryLib.lib Binary files differdeleted file mode 100644 index 15f74d2..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/BaseMemoryLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/BasePcdLibNull.lib b/efi_memtest/memtest86+/efi/Include/libs/BasePcdLibNull.lib Binary files differdeleted file mode 100644 index 4b10117..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/BasePcdLibNull.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/BasePrintLib.lib b/efi_memtest/memtest86+/efi/Include/libs/BasePrintLib.lib Binary files differdeleted file mode 100644 index 10650b0..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/BasePrintLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiApplicationEntryPoint.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiApplicationEntryPoint.lib Binary files differdeleted file mode 100644 index de9d990..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiApplicationEntryPoint.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiBootServicesTableLib.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiBootServicesTableLib.lib Binary files differdeleted file mode 100644 index 8e880f0..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiBootServicesTableLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiDebugLibStdErr.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiDebugLibStdErr.lib Binary files differdeleted file mode 100644 index 1864609..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiDebugLibStdErr.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiDevicePathLib.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiDevicePathLib.lib Binary files differdeleted file mode 100644 index 99bef02..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiDevicePathLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiLib.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiLib.lib Binary files differdeleted file mode 100644 index d8170ed..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiMemoryAllocationLib.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiMemoryAllocationLib.lib Binary files differdeleted file mode 100644 index 0e2ce9d..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiMemoryAllocationLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/Include/libs/UefiRuntimeServicesTableLib.lib b/efi_memtest/memtest86+/efi/Include/libs/UefiRuntimeServicesTableLib.lib Binary files differdeleted file mode 100644 index e31760f..0000000 --- a/efi_memtest/memtest86+/efi/Include/libs/UefiRuntimeServicesTableLib.lib +++ /dev/null diff --git a/efi_memtest/memtest86+/efi/display.c b/efi_memtest/memtest86+/efi/display.c index 08c06e9..7ae3c2a 100644 --- a/efi_memtest/memtest86+/efi/display.c +++ b/efi_memtest/memtest86+/efi/display.c @@ -8,24 +8,20 @@ extern volatile short btflag; extern EFI_SYSTEM_TABLE *gST; -extern struct barrier_s *barr; +extern struct barrier_s *barr; #define CONSOLE_WIDTH 80 CHAR16 scroll_buffer[10][79]; int scroll_begin = 0; -void clear_screen() -{ +void clear_screen() { - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; Console->SetMode(Console, 2); // TODO set only if it's possible Console->SetAttribute(Console, EFI_TEXT_ATTR(EFI_BLACK, EFI_CYAN)); Console->ClearScreen(Console); -/* - char msg[] = "Screen cleared efi\n"; - print_log(msg, sizeof(msg));*/ if (btflag) { Console->SetCursorPosition(Console, 0, 1); @@ -43,9 +39,9 @@ void clear_screen() Console->SetCursorPosition(Console, 0, 0); for (int i = 0; i < 10; i++) { - for (int j = 0; j < 78; j++) { - scroll_buffer[i][j] = ' '; - } + for (int j = 0; j < 78; j++) { + scroll_buffer[i][j] = ' '; + } scroll_buffer[i][78] = '\0'; } @@ -54,19 +50,29 @@ void clear_screen() int print_mainscreen() { extern int num_cpus; + extern int l1_cache, l2_cache, l3_cache; + extern char *cpu_type_s; + extern ulong cpu_speed; + extern ulong speed_l1; + extern ulong speed_l2; + extern ulong speed_l3; + //extern ulong memspeed_end_high; clear_screen(); - + + /* + * Frame + */ 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(1, 0, "CLK:"); + cprint(2, 0, "L1 Cache:"); + cprint(3, 0, "L2 Cache:"); + cprint(4, 0, "L3 Cache:"); cprint(5, 0, "Memory : "); cprint(6, 0, "------------------------------------------------------------------------------"); cprint(7, 0, "Core#:"); @@ -80,7 +86,51 @@ int print_mainscreen() { for(int i=0; i < 6; i++) { cprint(i, COL_MID-2, "| "); } - + + /* + * specific information + */ + cprint(0, COL_MID, cpu_type_s); + + // cpu and memory speed + int off = 4; + if (cpu_speed < 999499 + 50) { + cprint(1, off, " . MHz"); + dprint(1, off+1, cpu_speed/1000, 3, 1); + dprint(1, off+5, (cpu_speed/100)%10, 1, 0); + } else { + cprint(1, off, " MHz"); + dprint(1, off, cpu_speed/1000, 5, 0); + } + + if (speed_l1) { + cprint(2, 16, " MB/s"); + dprint(2, 16, speed_l1, 6, 0); + } + + if (speed_l2) { + cprint(3, 16, " MB/s"); + dprint(3, 16, speed_l2, 6, 0); + } + + if (speed_l3) { + cprint(4, 16, " MB/s"); + dprint(4, 16, speed_l3, 6, 0); + } + + // TODO it just prints zeros. hprint(11,40,memspeed_end_high); + + // Print out cache information + cprint(2, 0, "L1 Cache: K "); + dprint(2, 11, l1_cache, 3, 0); + + cprint(3, 0, "L2 Cache: K "); + dprint(3, 10, l2_cache, 4, 0); + + + cprint(4, 0, "L3 Cache: K "); + aprint(4, 10, l3_cache/4); + //dprint(4, 10, l3_cache, 4, 0); footer(); @@ -99,6 +149,9 @@ int print_mainscreen() { cprint(LINE_RAM,9, "Running..."); } + + + /* * Now follow the prints from common_err() */ @@ -117,24 +170,24 @@ int print_mainscreen() { break; case PRINTMODE_ADDRESSES: - if (vv->erri.hdr_flag == 0) { + if (vv->erri.hdr_flag == 0) { cprint(LINE_HEADER, 0, "Tst Pass Failing Address Good Bad Err-Bits Count CPU"); cprint(LINE_HEADER+1, 0, "--- ---- ----------------------- -------- -------- -------- ----- ----"); } - break; + break; case PRINTMODE_PATTERNS: - break; + break; case PRINTMODE_NONE: - break; + break; } - return 0; + return 0; } // TODO UEFI functions @@ -142,6 +195,7 @@ void getChar16FromInt(CHAR16* buffer, int num) { int length = 0; int tmp = num; + while(tmp > 10) { tmp = tmp / 10; Print(L"HJK %d", 6); @@ -151,10 +205,9 @@ void getChar16FromInt(CHAR16* buffer, int num) { /* Boot trace function */ short tidx = 25; -void btrace(int me, int line, char *msg, int wait, long v1, long v2) // TODO -{ +void btrace(int me, int line, char *msg, int wait, long v1, long v2) {// TODO - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; int y, x; @@ -165,9 +218,11 @@ void btrace(int me, int line, char *msg, int wait, long v1, long v2) // TODO y = tidx%13; x = tidx/13*40; cplace(y+11, x+1, ' '); + if (++tidx > 25) { tidx = 0; } + y = tidx%13; x = tidx/13*40; @@ -175,13 +230,13 @@ void btrace(int me, int line, char *msg, int wait, long v1, long v2) // TODO Console->OutputString(Console, L">\n"); CHAR16 *buff; getChar16FromInt(buff, me); - /* TODO Console->SetCursorPosition(Console, 2, 11); + /* TODO Console->SetCursorPosition(Console, 2, 11); CHAR16 num[8]; itoa(num, me); Console->OutputString(Console, num);*/ //dprint(y+11, x+2, me, 2, 0); //dprint(y+11, x+5, line, 4, 0); - /* Console->SetCursorPosition(Console, 10, 11); + /* Console->SetCursorPosition(Console, 10, 11); Console->OutputString(Console, msg); cprint(y+11, x+10, msg);*/ //hprint(y+11, x+22, v1); @@ -194,10 +249,10 @@ void btrace(int me, int line, char *msg, int wait, long v1, long v2) // TODO void add_scroll_line(int x, int y, const char *text) { - for (int i = 0; text[i]; ++i) - { - scroll_buffer[(scroll_begin + y)%10][x + i] = text[i]; - } + + for (int i = 0; text[i]; ++i) { + scroll_buffer[(scroll_begin + y)%10][x + i] = text[i]; + } } /* @@ -206,7 +261,7 @@ void add_scroll_line(int x, int y, const char *text) { void cprint(int y, int x, const char *text) { - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; /* register int i; char *dptr; @@ -219,6 +274,7 @@ void cprint(int y, int x, const char *text) // tty_print_line(y, x, text); CHAR16 output_text[CONSOLE_WIDTH - 1]; // TODO think about the size int i; + for (i = 0; text[i]; i++) { output_text[i] = text[i]; } @@ -227,10 +283,10 @@ void cprint(int y, int x, const char *text) output_text[i] = '\0'; Console->SetCursorPosition(Console, x, y); Console->OutputString(Console, output_text); + if (y <= 23 && y>= 14) { - add_scroll_line(x, (y - 14), text); + add_scroll_line(x, (y - 14), text); } - } /* @@ -239,12 +295,14 @@ void cprint(int y, int x, const char *text) void trace_init(const char *text) { - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; CHAR16 output_text[CONSOLE_WIDTH - 1]; // TODO think about the size int i; + for (i = 0; text[i]; i++) { output_text[i] = text[i]; + if(i == CONSOLE_WIDTH) break; } @@ -254,58 +312,53 @@ void trace_init(const char *text) INT32 row = Console->Mode->CursorRow; Console->SetCursorPosition(Console, 0, row + 1); Console->OutputString(Console, output_text); - - } void print_popup() { -EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; - - Console->SetAttribute(Console, EFI_TEXT_ATTR(EFI_BLACK, EFI_BLACK)); - Console->ClearScreen(Console); + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + Console->SetAttribute(Console, EFI_TEXT_ATTR(EFI_BLACK, EFI_BLACK)); + Console->ClearScreen(Console); - Console->SetAttribute(Console, EFI_TEXT_ATTR(EFI_BLACK, EFI_CYAN)); + Console->SetAttribute(Console, EFI_TEXT_ATTR(EFI_BLACK, EFI_CYAN)); - for (int i = 0; i < POP_H; i++) { - Console->SetCursorPosition(Console, POP_X, POP_Y + i); - Console->OutputString(Console, L" "); // width: pop_w=34 - } + for (int i = 0; i < POP_H; i++) { + Console->SetCursorPosition(Console, POP_X, POP_Y + i); + Console->OutputString(Console, L" "); // width: pop_w=34 + } } void clear_scroll_region() { - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; - - int scroll_lines = 10; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; - for (int i = 0; i < scroll_lines; i++) { - Console->SetCursorPosition(Console, 0, LINE_SCROLL + i); - Console->OutputString(Console, L" "); - } + int scroll_lines = 10; - Console->SetCursorPosition(Console, 0, LINE_SCROLL - 1); + for (int i = 0; i < scroll_lines; i++) { + Console->SetCursorPosition(Console, 0, LINE_SCROLL + i); + Console->OutputString(Console, L" "); + } + Console->SetCursorPosition(Console, 0, LINE_SCROLL - 1); } void print_scroll_region() { - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = gST->ConOut; - // clear_scroll_region? + // clear_scroll_region? - for (int i = 0; i < 79; i++) { - scroll_buffer[scroll_begin][i] = ' '; - } + for (int i = 0; i < 79; i++) { + scroll_buffer[scroll_begin][i] = ' '; + } scroll_buffer[scroll_begin][78] = '\0'; - scroll_begin++; - scroll_begin %= 10; + scroll_begin++; + scroll_begin %= 10; - for (int i = 0; i < 9; ++i) - { - Console->SetCursorPosition(Console, 0, LINE_SCROLL + i); - Console->OutputString(Console, scroll_buffer[(scroll_begin + i) % 10]); - } + for (int i = 0; i < 9; ++i) { + Console->SetCursorPosition(Console, 0, LINE_SCROLL + i); + Console->OutputString(Console, scroll_buffer[(scroll_begin + i) % 10]); + } }
\ No newline at end of file diff --git a/efi_memtest/memtest86+/efi/init.c b/efi_memtest/memtest86+/efi/init.c index accfede..cd9a851 100644 --- a/efi_memtest/memtest86+/efi/init.c +++ b/efi_memtest/memtest86+/efi/init.c @@ -35,6 +35,7 @@ extern char cpu_mask[]; extern void initialise_cpus(); extern short logflag; +extern short log_cpuspeed; extern short log_memspeed; /* Here we store all of the cpuid data */ @@ -43,6 +44,7 @@ extern struct cpu_ident cpu_id; int l1_cache=0, l2_cache=0, l3_cache=0; int tsc_invariable = 0; ulong extclock; +char *cpu_type_s; ulong memspeed(ulong src, ulong len, int iter); static void cpu_type(void); @@ -210,67 +212,16 @@ void failsafe(int msec, int scs) } } -/*static void display_init(void) -{ - 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("[LINE_SCROLL;24r");*/ /* Set scroll area row 7-23 */ - /* serial_echo_print("[H[2J");*/ /* Clear Screen */ - /*serial_echo_print("[37m[44m"); - serial_echo_print("[0m"); - serial_echo_print("[37m[44m");*/ - - /* 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("[0m"); -} -*/ /* * Initialize test, setup screen and find out how much memory there is. */ -void init(void) -{ +void init(void) { outb(0x8, 0x3f2); /* Kill Floppy Motor */ /* Turn on cache */ set_cache(1); - /* Setup the display */ - // display_init(); - - vv->pass = 0; vv->msg_line = 0; vv->ecount = 0; @@ -291,9 +242,11 @@ void init(void) vv->erri.ebits = 0; vv->erri.hdr_flag = 0; vv->erri.tbits = 0; + for (int i=0; tseq[i].msg != NULL; i++) { tseq[i].errors = 0; } + if (dmi_initialized) { for (int i=0; i < MAX_DMI_MEMDEVS; i++){ if (dmi_err_cnts[i] > 0) { @@ -311,7 +264,7 @@ void init(void) /* setup pci */ pci_init(); - get_cache_size(); + get_cache_size(); cpu_type(); @@ -321,17 +274,17 @@ void init(void) // failsafe(5000, 0x3B); // TODO depends on correct behavior of cpuspeed if (logflag) { - char log[34] = "init(): vv->fail_safe = "; - int length = 24; - int_to_charr(vv->fail_safe, log, &length); - print_log(log, length); + char log[34] = "init(): vv->fail_safe = "; + int length = 24; + int_to_charr(vv->fail_safe, log, &length); + print_log(log, length); } if (logflag) { - char log[29] = "init(): num_cpus = "; - int length = 19; - int_to_charr(num_cpus, log, &length); - print_log(log, length); + char log[29] = "init(): num_cpus = "; + int length = 19; + int_to_charr(num_cpus, log, &length); + print_log(log, length); } /* Initalize SMP */ @@ -364,11 +317,16 @@ void init(void) 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; + /* + * WARNING: do not print anything before this statement. Otherwise it will be overwritten + */ print_mainscreen(); } @@ -378,9 +336,10 @@ void init(void) void get_cache_size() { if (logflag) { - char log[] = "get_cache_size() started."; - print_log(log, sizeof(log) - 1); + char log[] = "get_cache_size() started."; + print_log(log, sizeof(log) - 1); } + int i, j, n, size; unsigned int v[4]; unsigned char *dp = (unsigned char *)v; @@ -389,265 +348,220 @@ void get_cache_size() struct cpuid4_ecx *ecx = (struct cpuid4_ecx *)&v[2]; switch(cpu_id.vend_id.char_array[0]) { - /* AMD Processors */ - case 'A': - //l1_cache = cpu_id.cache_info.amd.l1_i_sz; - l1_cache = cpu_id.cache_info.amd.l1_d_sz; - l2_cache = cpu_id.cache_info.amd.l2_sz; - l3_cache = cpu_id.cache_info.amd.l3_sz; - l3_cache *= 512; - - if (logflag) { - char log[40] = "get_cache_size(): l1_cache = "; - int length = 29; - int_to_charr(l1_cache, log, &length); - print_log(log, length); - } + /* AMD Processors */ + case 'A': + //l1_cache = cpu_id.cache_info.amd.l1_i_sz; + l1_cache = cpu_id.cache_info.amd.l1_d_sz; + l2_cache = cpu_id.cache_info.amd.l2_sz; + l3_cache = cpu_id.cache_info.amd.l3_sz; + l3_cache *= 512; - if (logflag) { - char log[40] = "get_cache_size(): l2_cache = "; - int length = 29; - int_to_charr(l2_cache, log, &length); - print_log(log, length); - } + break; - if (logflag) { - char log[40] = "get_cache_size(): l3_cache = "; - int length = 29; - int_to_charr(l3_cache, log, &length); - print_log(log, length); + case 'G': + /* Intel Processors */ + l1_cache = 0; + l2_cache = 0; + l3_cache = 0; - } + /* Use CPUID(4) if it is available */ + if (cpu_id.max_cpuid > 3) { - break; - case 'G': - /* Intel Processors */ - l1_cache = 0; - l2_cache = 0; - l3_cache = 0; - - /* Use CPUID(4) if it is available */ - if (cpu_id.max_cpuid > 3) { - - /* figure out how many cache leaves */ - n = -1; - do - { + /* figure out how many cache leaves */ + n = -1; + do { ++n; // Do cpuid(4) loop to find out num_cache_leaves cpuid_count(4, n, &v[0], &v[1], &v[2], &v[3]); - } while ((eax->ctype) != 0); + } while ((eax->ctype) != 0); - /* loop through all of the leaves */ - for (i=0; i<n; i++) - { - cpuid_count(4, i, &v[0], &v[1], &v[2], &v[3]); + /* loop through all of the leaves */ + for (i=0; i<n; i++) { + cpuid_count(4, i, &v[0], &v[1], &v[2], &v[3]); /* Check for a valid cache type */ - if (eax->ctype == 1 || eax->ctype == 3) - { - - /* Compute the cache size */ - size = (ecx->number_of_sets + 1) * - (ebx->coherency_line_size + 1) * - (ebx->physical_line_partition + 1) * - (ebx->ways_of_associativity + 1); - size /= 1024; - - switch (eax->level) - { - case 1: - l1_cache += size; - break; - case 2: - l2_cache += size; - break; - case 3: - l3_cache += size; - break; - } - } - } - - if (logflag) { - char log[40] = "get_cache_size(): l1_cache = "; - int length = 29; - int_to_charr(l1_cache, log, &length); - print_log(log, length); - } - - if (logflag) { - char log[40] = "get_cache_size(): l2_cache = "; - int length = 29; - int_to_charr(l2_cache, log, &length); - print_log(log, length); - } - - if (logflag) { - char log[40] = "get_cache_size(): l3_cache = "; - int length = 29; - int_to_charr(l3_cache, log, &length); - print_log(log, length); - } - - return; - } + if (eax->ctype == 1 || eax->ctype == 3) { + + /* Compute the cache size */ + size = (ecx->number_of_sets + 1) * + (ebx->coherency_line_size + 1) * + (ebx->physical_line_partition + 1) * + (ebx->ways_of_associativity + 1); + size /= 1024; + + switch (eax->level) { + case 1: + l1_cache += size; + break; + case 2: + l2_cache += size; + break; + case 3: + l3_cache += size; + break; + } + } + } + + break; + } - /* No CPUID(4) so we use the older CPUID(2) method */ - /* Get number of times to iterate */ - cpuid(2, &v[0], &v[1], &v[2], &v[3]); - n = v[0] & 0xff; - for (i=0 ; i<n ; i++) { + /* No CPUID(4) so we use the older CPUID(2) method */ + /* Get number of times to iterate */ cpuid(2, &v[0], &v[1], &v[2], &v[3]); - - /* If bit 31 is set, this is an unknown format */ - for (j=0 ; j<3 ; j++) { - if (v[j] & (1 << 31)) { - v[j] = 0; - } - } - - /* Byte 0 is level count, not a descriptor */ - for (j = 1 ; j < 16 ; j++) { - switch(dp[j]) { - case 0x6: - case 0xa: - case 0x66: - l1_cache += 8; - break; - case 0x8: - case 0xc: - case 0xd: - case 0x60: - case 0x67: - l1_cache += 16; - break; - case 0xe: - l1_cache += 24; - break; - case 0x9: - case 0x2c: - case 0x30: - case 0x68: - l1_cache += 32; - break; - case 0x39: - case 0x3b: - case 0x41: - case 0x79: - l2_cache += 128; - break; - case 0x3a: - l2_cache += 192; - break; - case 0x21: - case 0x3c: - case 0x3f: - case 0x42: - case 0x7a: - case 0x82: - l2_cache += 256; - break; - case 0x3d: - l2_cache += 384; - break; - case 0x3e: - case 0x43: - case 0x7b: - case 0x7f: - case 0x80: - case 0x83: - case 0x86: - l2_cache += 512; - break; - case 0x44: - case 0x78: - case 0x7c: - case 0x84: - case 0x87: - l2_cache += 1024; - break; - case 0x45: - case 0x7d: - case 0x85: - l2_cache += 2048; - break; - case 0x48: - l2_cache += 3072; + n = v[0] & 0xff; + for (i=0 ; i<n ; i++) { + cpuid(2, &v[0], &v[1], &v[2], &v[3]); + + /* If bit 31 is set, this is an unknown format */ + for (j=0 ; j<3 ; j++) { + if (v[j] & (1 << 31)) { + v[j] = 0; + } + } + + /* Byte 0 is level count, not a descriptor */ + for (j = 1 ; j < 16 ; j++) { + switch(dp[j]) { + case 0x6: + case 0xa: + case 0x66: + l1_cache += 8; + break; + case 0x8: + case 0xc: + case 0xd: + case 0x60: + case 0x67: + l1_cache += 16; + break; + case 0xe: + l1_cache += 24; + break; + case 0x9: + case 0x2c: + case 0x30: + case 0x68: + l1_cache += 32; break; - case 0x4e: - l2_cache += 6144; - break; - case 0x23: - case 0xd0: - l3_cache += 512; - break; - case 0xd1: - case 0xd6: - l3_cache += 1024; - break; - case 0x25: - case 0xd2: - case 0xd7: - case 0xdc: - case 0xe2: - l3_cache += 2048; - break; - case 0x29: - case 0x46: - case 0x49: - case 0xd8: - case 0xdd: - case 0xe3: - l3_cache += 4096; - break; - case 0x4a: - l3_cache += 6144; - break; - case 0x47: - case 0x4b: - case 0xde: - case 0xe4: - l3_cache += 8192; - break; - case 0x4c: - case 0xea: - l3_cache += 12288; - break; - case 0x4d: - l3_cache += 16384; - break; - case 0xeb: - l3_cache += 18432; - break; - case 0xec: - l3_cache += 24576; - break; - } /* end switch */ - } /* end for 1-16 */ - } /* end for 0 - n */ - - if (logflag) { - char log[40] = "get_cache_size(): l1_cache = "; - int length = 29; - int_to_charr(l1_cache, log, &length); - print_log(log, length); - } + case 0x39: + case 0x3b: + case 0x41: + case 0x79: + l2_cache += 128; + break; + case 0x3a: + l2_cache += 192; + break; + case 0x21: + case 0x3c: + case 0x3f: + case 0x42: + case 0x7a: + case 0x82: + l2_cache += 256; + break; + case 0x3d: + l2_cache += 384; + break; + case 0x3e: + case 0x43: + case 0x7b: + case 0x7f: + case 0x80: + case 0x83: + case 0x86: + l2_cache += 512; + break; + case 0x44: + case 0x78: + case 0x7c: + case 0x84: + case 0x87: + l2_cache += 1024; + break; + case 0x45: + case 0x7d: + case 0x85: + l2_cache += 2048; + break; + case 0x48: + l2_cache += 3072; + break; + case 0x4e: + l2_cache += 6144; + break; + case 0x23: + case 0xd0: + l3_cache += 512; + break; + case 0xd1: + case 0xd6: + l3_cache += 1024; + break; + case 0x25: + case 0xd2: + case 0xd7: + case 0xdc: + case 0xe2: + l3_cache += 2048; + break; + case 0x29: + case 0x46: + case 0x49: + case 0xd8: + case 0xdd: + case 0xe3: + l3_cache += 4096; + break; + case 0x4a: + l3_cache += 6144; + break; + case 0x47: + case 0x4b: + case 0xde: + case 0xe4: + l3_cache += 8192; + break; + case 0x4c: + case 0xea: + l3_cache += 12288; + break; + case 0x4d: + l3_cache += 16384; + break; + case 0xeb: + l3_cache += 18432; + break; + case 0xec: + l3_cache += 24576; + break; + } /* end switch */ + } /* end for 1-16 */ + } /* end for 0 - n */ - if (logflag) { - char log[40] = "get_cache_size(): l2_cache = "; - int length = 29; - int_to_charr(l2_cache, log, &length); - print_log(log, length); - } + } - if (logflag) { - char log[40] = "get_cache_size(): l3_cache = "; - int length = 29; - int_to_charr(l3_cache, log, &length); - print_log(log, length); - } - } + if (logflag) { + char log[40] = "get_cache_size(): l1_cache = "; + int length = 29; + int_to_charr(l1_cache, log, &length); + print_log(log, length); + } + + if (logflag) { + char log[40] = "get_cache_size(): l2_cache = "; + int length = 29; + int_to_charr(l2_cache, log, &length); + print_log(log, length); + } + + if (logflag) { + char log[40] = "get_cache_size(): l3_cache = "; + int length = 29; + int_to_charr(l3_cache, log, &length); + print_log(log, length); + } } /* @@ -679,7 +593,7 @@ void detect_imc(void) case 0x7: imc_type = 0x0105; // Kabini & related (Family 16h) break; - } + } return; } @@ -761,11 +675,10 @@ void smp_default_mode(void) /* * Find CPU type */ -void cpu_type(void) -{ +void cpu_type(void) { /* If we can get a brand string use it, and we are done */ if (cpu_id.max_xcpuid >= 0x80000004) { - cprint(0, COL_MID, cpu_id.brand_id.char_array); // TODO this hides an other cprint output + cpu_type_s = cpu_id.brand_id.char_array; //If we have a brand string, maybe we have an IMC. Check that. detect_imc(); smp_default_mode(); @@ -781,22 +694,22 @@ void cpu_type(void) case 4: switch(cpu_id.vers.bits.model) { case 3: - cprint(0, COL_MID, "AMD 486DX2"); + cpu_type_s = "AMD 486DX2"; break; case 7: - cprint(0, COL_MID, "AMD 486DX2-WB"); + cpu_type_s = "AMD 486DX2-WB"; break; case 8: - cprint(0, COL_MID, "AMD 486DX4"); + cpu_type_s = "AMD 486DX4"; break; case 9: - cprint(0, COL_MID, "AMD 486DX4-WB"); + cpu_type_s = "AMD 486DX4-WB"; break; case 14: - cprint(0, COL_MID, "AMD 5x86-WT"); + cpu_type_s = "AMD 5x86-WT"; break; case 15: - cprint(0, COL_MID, "AMD 5x86-WB"); + cpu_type_s = "AMD 5x86-WB"; break; } /* Since we can't get CPU speed or cache info return */ @@ -807,58 +720,56 @@ void cpu_type(void) case 1: case 2: case 3: - cprint(0, COL_MID, "AMD K5"); + cpu_type_s = "AMD K5"; l1_cache = 8; break; case 6: case 7: - cprint(0, COL_MID, "AMD K6"); + cpu_type_s = "AMD K6"; break; case 8: - cprint(0, COL_MID, "AMD K6-2"); + cpu_type_s = "AMD K6-2"; break; case 9: - cprint(0, COL_MID, "AMD K6-III"); + cpu_type_s = "AMD K6-III"; break; case 13: - cprint(0, COL_MID, "AMD K6-III+"); + cpu_type_s = "AMD K6-III+"; break; } break; case 6: - switch(cpu_id.vers.bits.model) { case 1: - cprint(0, COL_MID, "AMD Athlon (0.25)"); + cpu_type_s = "AMD Athlon (0.25)"; break; case 2: case 4: - cprint(0, COL_MID, "AMD Athlon (0.18)"); + cpu_type_s = "AMD Athlon (0.18)"; break; case 6: if (l2_cache == 64) { - cprint(0, COL_MID, "AMD Duron (0.18)"); + cpu_type_s = "AMD Duron (0.18)"; } else { - cprint(0, COL_MID, "Athlon XP (0.18)"); + cpu_type_s = "Athlon XP (0.18)"; } break; case 8: case 10: if (l2_cache == 64) { - cprint(0, COL_MID, "AMD Duron (0.13)"); + cpu_type_s = "AMD Duron (0.13)"; } else { - cprint(0, COL_MID, "Athlon XP (0.13)"); + cpu_type_s = "Athlon XP (0.13)"; } break; case 3: case 7: - cprint(0, COL_MID, "AMD Duron"); + cpu_type_s = "AMD Duron"; /* Duron stepping 0 CPUID for L2 is broken */ /* (AMD errata T13)*/ if (cpu_id.vers.bits.stepping == 0) { /* stepping 0 */ /* Hard code the right L2 size */ l2_cache = 64; - } else { } break; } @@ -873,41 +784,42 @@ void cpu_type(void) case 'G': if ( cpu_id.vend_id.char_array[7] == 'T' ) { /* GenuineTMx86 */ if (cpu_id.vers.bits.family == 5) { - cprint(0, COL_MID, "TM 5x00"); + cpu_type_s = "TM 5x00"; } else if (cpu_id.vers.bits.family == 15) { - cprint(0, COL_MID, "TM 8x00"); + cpu_type_s = "TM 8x00"; } l1_cache = cpu_id.cache_info.ch[3] + cpu_id.cache_info.ch[7]; l2_cache = (cpu_id.cache_info.ch[11]*256) + cpu_id.cache_info.ch[10]; } else { /* GenuineIntel */ if (cpu_id.vers.bits.family == 4) { - switch(cpu_id.vers.bits.model) { - case 0: - case 1: - cprint(0, COL_MID, "Intel 486DX"); - break; - case 2: - cprint(0, COL_MID, "Intel 486SX"); - break; - case 3: - cprint(0, COL_MID, "Intel 486DX2"); - break; - case 4: - cprint(0, COL_MID, "Intel 486SL"); - break; - case 5: - cprint(0, COL_MID, "Intel 486SX2"); - break; - case 7: - cprint(0, COL_MID, "Intel 486DX2-WB"); - break; - case 8: - cprint(0, COL_MID, "Intel 486DX4"); - break; - case 9: - cprint(0, COL_MID, "Intel 486DX4-WB"); - break; - } + switch(cpu_id.vers.bits.model) { + case 0: + case 1: + cpu_type_s = "Intel 486DX"; + break; + case 2: + cpu_type_s = "Intel 486SX"; + break; + case 3: + cpu_type_s = "Intel 486DX2"; + break; + case 4: + cpu_type_s = "Intel 486SL"; + break; + case 5: + cpu_type_s = "Intel 486SX2"; + break; + case 7: + cpu_type_s = "Intel 486DX2-WB"; + break; + case 8: + cpu_type_s = "Intel 486DX4"; + break; + case 9: + cpu_type_s = "Intel 486DX4-WB"; + break; + } + } /* Since we can't get CPU speed or cache info return */ return; } @@ -920,15 +832,15 @@ void cpu_type(void) case 1: case 2: case 3: + case 4: case 7: - cprint(0, COL_MID, "Pentium"); + cpu_type_s = "Pentium"; if (l1_cache == 0) { l1_cache = 8; } break; - case 4: case 8: - cprint(0, COL_MID, "Pentium-MMX"); + cpu_type_s = "Pentium-MMX"; if (l1_cache == 0) { l1_cache = 16; } @@ -939,65 +851,65 @@ void cpu_type(void) switch(cpu_id.vers.bits.model) { case 0: case 1: - cprint(0, COL_MID, "Pentium Pro"); + cpu_type_s = "Pentium Pro"; break; case 3: case 4: - cprint(0, COL_MID, "Pentium II"); + cpu_type_s = "Pentium II"; break; case 5: if (l2_cache == 0) { - cprint(0, COL_MID, "Celeron"); + cpu_type_s = "Celeron"; } else { - cprint(0, COL_MID, "Pentium II"); + cpu_type_s = "Pentium II"; } break; case 6: - if (l2_cache == 128) { - cprint(0, COL_MID, "Celeron"); - } else { - cprint(0, COL_MID, "Pentium II"); - } - } - break; - case 7: - case 8: - case 11: if (l2_cache == 128) { - cprint(0, COL_MID, "Celeron"); + cpu_type_s = "Celeron"; } else { - cprint(0, COL_MID, "Pentium III"); + cpu_type_s = "Pentium II"; } + break; + case 7: + case 8: case 9: if (l2_cache == 512) { - cprint(0, COL_MID, "Celeron M (0.13)"); + cpu_type_s = "Celeron M (0.13)"; } else { - cprint(0, COL_MID, "Pentium M (0.13)"); + cpu_type_s = "Pentium M (0.13)"; } break; - case 10: - cprint(0, COL_MID, "Pentium III Xeon"); + case 10: + cpu_type_s = "Pentium III Xeon"; break; + case 11: + if (l2_cache == 128) { + cpu_type_s = "Celeron"; + } else { + cpu_type_s = "Pentium III"; + } + break; case 12: l1_cache = 24; - cprint(0, COL_MID, "Atom (0.045)"); + cpu_type_s = "Atom (0.045)"; break; case 13: if (l2_cache == 1024) { - cprint(0, COL_MID, "Celeron M (0.09)"); + cpu_type_s = "Celeron M (0.09)"; } else { - cprint(0, COL_MID, "Pentium M (0.09)"); + cpu_type_s = "Pentium M (0.09)"; } break; case 14: - cprint(0, COL_MID, "Intel Core"); + cpu_type_s = "Intel Core"; break; case 15: if (l2_cache == 1024) { - cprint(0, COL_MID, "Pentium E"); + cpu_type_s = "Pentium E"; } else { - cprint(0, COL_MID, "Intel Core 2"); + cpu_type_s = "Intel Core 2"; } break; } @@ -1008,24 +920,24 @@ void cpu_type(void) case 1: case 2: if (l2_cache == 128) { - cprint(0, COL_MID, "Celeron"); + cpu_type_s = "Celeron"; } else { - cprint(0, COL_MID, "Pentium 4"); + cpu_type_s = "Pentium 4"; } break; case 3: case 4: if (l2_cache == 256) { - cprint(0, COL_MID, "Celeron (0.09)"); + cpu_type_s = "Celeron (0.09)"; } else { - cprint(0, COL_MID, "Pentium 4 (0.09)"); + cpu_type_s = "Pentium 4 (0.09)"; } break; case 6: - cprint(0, COL_MID, "Pentium D (65nm)"); + cpu_type_s = "Pentium D (65nm)"; break; default: - cprint(0, COL_MID, "Unknown Intel"); + cpu_type_s = "Unknown Intel"; break; break; } @@ -1040,29 +952,29 @@ void cpu_type(void) l2_cache = cpu_id.cache_info.ch[11]; switch(cpu_id.vers.bits.family){ case 5: - cprint(0, COL_MID, "Centaur 5x86"); + cpu_type_s = "Centaur 5x86"; break; case 6: // VIA C3 switch(cpu_id.vers.bits.model){ default: if (cpu_id.vers.bits.stepping < 8) { - cprint(0, COL_MID, "VIA C3 Samuel2"); + cpu_type_s = "VIA C3 Samuel2"; } else { - cprint(0, COL_MID, "VIA C3 Eden"); + cpu_type_s = "VIA C3 Eden"; } break; case 10: - cprint(0, COL_MID, "VIA C7 (C5J)"); + cpu_type_s = "VIA C7 (C5J)"; l1_cache = 64; l2_cache = 128; break; case 13: - cprint(0, COL_MID, "VIA C7 (C5R)"); + cpu_type_s = "VIA C7 (C5R)"; l1_cache = 64; l2_cache = 128; break; case 15: - cprint(0, COL_MID, "VIA Isaiah (CN)"); + cpu_type_s = "VIA Isaiah (CN)"; l1_cache = 64; l2_cache = 128; break; @@ -1073,10 +985,10 @@ void cpu_type(void) case 5: switch(cpu_id.vers.bits.model) { case 0: - cprint(0, COL_MID, "Cyrix 6x86MX/MII"); + cpu_type_s = "Cyrix 6x86MX/MII"; break; case 4: - cprint(0, COL_MID, "Cyrix GXm"); + cpu_type_s = "Cyrix GXm"; break; } return; @@ -1084,20 +996,20 @@ void cpu_type(void) case 6: // VIA C3 switch(cpu_id.vers.bits.model) { case 6: - cprint(0, COL_MID, "Cyrix III"); + cpu_type_s = "Cyrix III"; break; case 7: if (cpu_id.vers.bits.stepping < 8) { - cprint(0, COL_MID, "VIA C3 Samuel2"); + cpu_type_s = "VIA C3 Samuel2"; } else { - cprint(0, COL_MID, "VIA C3 Ezra-T"); + cpu_type_s = "VIA C3 Ezra-T"; } break; case 8: - cprint(0, COL_MID, "VIA C3 Ezra-T"); + cpu_type_s = "VIA C3 Ezra-T"; break; case 9: - cprint(0, COL_MID, "VIA C3 Nehemiah"); + cpu_type_s = "VIA C3 Nehemiah"; break; } // L1 = L2 = 64 KB from Cyrix III to Nehemiah @@ -1112,11 +1024,11 @@ void cpu_type(void) /* Make a guess at the family */ switch(cpu_id.vers.bits.family) { case 5: - cprint(0, COL_MID, "586"); + cpu_type_s = "586"; case 6: - cprint(0, COL_MID, "686"); + cpu_type_s = "686"; default: - cprint(0, COL_MID, "Unidentified Processor"); + cpu_type_s = "Unidentified Processor"; } } } @@ -1124,90 +1036,64 @@ void cpu_type(void) #define STEST_ADDR 0x100000 /* Measure memory speed starting at 1MB */ /* Measure and display CPU and cache sizes and speeds */ -void cpu_cache_speed() -{ +ulong cpu_speed; +ulong speed_l1; +ulong speed_l2; +ulong speed_l3; +void cpu_cache_speed() { if (logflag) { - char log[] = "cpu_cache_speed() started."; - print_log(log, sizeof(log) - 1); + char log[] = "cpu_cache_speed() started."; + print_log(log, sizeof(log) - 1); } - int i, off = 4; - ulong speed; - + int i; /* Print CPU speed */ - if ((speed = cpuspeed()) > 0) { - if (speed < 999499) { - speed += 50; /* for rounding */ - cprint(1, off, " . MHz"); - dprint(1, off+1, speed/1000, 3, 1); - dprint(1, off+5, (speed/100)%10, 1, 0); + if ((cpu_speed = cpuspeed()) > 0) { + if (cpu_speed < 999499) { + cpu_speed += 50; /* for rounding */ } else { - speed += 500; /* for rounding */ - cprint(1, off, " MHz"); - dprint(1, off, speed/1000, 5, 0); + cpu_speed += 500; /* for rounding */ } - extclock = speed; + extclock = cpu_speed; } - if (logflag) { - char log[38] = "cpu_cache_speed(): speed = "; - int length = 27; - int_to_charr(extclock, log, &length); - print_log(log, length); + if (logflag && log_cpuspeed) { + char log[38] = "cpu_cache_speed(): speed = "; + int length = 27; + int_to_charr(extclock, log, &length); + print_log(log, length); } - /* Print out L1 cache info */ /* To measure L1 cache speed we use a block size that is 1/4th */ /* of the total L1 cache size since half of it is for instructions */ if (l1_cache) { - cprint(2, 0, "L1 Cache: K "); - dprint(2, 11, l1_cache, 3, 0); - if ((speed=memspeed(STEST_ADDR, (l1_cache/2)*1024, 200))) { - cprint(2, 16, " MB/s"); - dprint(2, 16, speed, 6, 0); - } + speed_l1 = memspeed(STEST_ADDR, (l1_cache/2)*1024, 200); } - /* Print out L2 cache info */ /* We measure the L2 cache speed by using a block size that is */ /* the size of the L1 cache. We have to fudge if the L1 */ /* cache is bigger than the L2 */ if (l2_cache) { - cprint(3, 0, "L2 Cache: K "); - dprint(3, 10, l2_cache, 4, 0); - - if (l2_cache < l1_cache) { + if (l2_cache < l1_cache) { i = l1_cache / 4 + l2_cache / 4; } else { i = l1_cache; } - if ((speed=memspeed(STEST_ADDR, i*1024, 200))) { - cprint(3, 16, " MB/s"); - dprint(3, 16, speed, 6, 0); - } + speed_l2 = memspeed(STEST_ADDR, i*1024, 200); } - /* Print out L3 cache info */ + /* We measure the L3 cache speed by using a block size that is */ /* 2X the size of the L2 cache. */ - if (l3_cache) - { - cprint(4, 0, "L3 Cache: K "); - aprint(4, 10, l3_cache/4); - //dprint(4, 10, l3_cache, 4, 0); - - i = l2_cache*2; - - if ((speed=memspeed(STEST_ADDR, i*1024, 150))) { - cprint(4, 16, " MB/s"); - dprint(4, 16, speed, 6, 0); - } - } + if (l3_cache) { + i = l2_cache*2; + speed_l3 = memspeed(STEST_ADDR, i*1024, 150); + } } /* Measure and display memory speed, multitasked using all CPUs */ -ulong spd[MAX_CPUS]; +//ulong spd[MAX_CPUS]; // TODO can we remove this var? void get_mem_speed(int me, int ncpus) { int i; @@ -1216,7 +1102,7 @@ void get_mem_speed(int me, int ncpus) /* Determine memory speed. To find the memory speed we use * A block size that is the sum of all the L1, L2 & L3 caches * in all cpus * 6 */ - i = (l3_cache + l2_cache + l1_cache) * 4; + i = (l3_cache + l2_cache + l1_cache) * 4; // TODO is this calculation correct? The car ncpus is not used /* Make sure that we have enough memory to do the test */ /* If not use all we have */ @@ -1243,16 +1129,16 @@ void get_mem_speed(int me, int ncpus) #define TICKS 59659 /* 50 ms */ /* Returns CPU clock in khz */ -ulong stlow, sthigh; static int cpuspeed(void) { - if (logflag) { - char log[] = "cpuspeed() started."; - print_log(log, sizeof(log) - 1); + if (logflag && log_cpuspeed) { + char log[] = "cpuspeed() started."; + print_log(log, sizeof(log) - 1); } int loops; - //ulong end_low, end_high; + int stlow, sthigh; + int end_low, end_high; if (cpu_id.fid.bits.rdtsc == 0 ) { return(-1); @@ -1264,30 +1150,32 @@ static int cpuspeed(void) outb(TICKS & 0xff, 0x42); outb(TICKS >> 8, 0x42); + /* Get start time */ asm __volatile__ ("rdtsc":"=a" (stlow),"=d" (sthigh)); - loops = 0; do { loops++; } while ((inb(0x61) & 0x20) == 0); - /*asm __volatile__ ( - "rdtsc\n\t" \ - "subl stlow,%%eax\n\t" \ - "sbbl sthigh,%%edx\n\t" \ - :"=a" (end_low), "=d" (end_high) - );*/ + /* Get difference to end time */ + asm __volatile__ ( + "rdtsc\n\t" \ + "subl %2, %%eax\n\t" \ + "sbbl %3, %%edx\n\t" \ + :"=a" (end_low), "=d" (end_high) + :"r" (stlow), "r" (sthigh) + ); /* Make sure we have a credible result */ - /*if (loops < 4 || end_low < 50000) { + if (loops < 4 || end_low < 50000) { return(-1); } vv->clks_msec = end_low/50; -*/ - //if (tsc_invariable) end_low = correct_tsc(end_low); - if (logflag) { + if (tsc_invariable) end_low = correct_tsc(end_low); + + if (logflag && log_cpuspeed) { char log[35] = "cpuspeed(): clks_msec = "; int length = 24; int_to_charr(vv->clks_msec, log, &length); @@ -1299,32 +1187,33 @@ static int cpuspeed(void) /* Measure cache speed by copying a block of memory. */ /* Returned value is kbytes/second */ +ulong memspeed_end_high; ulong memspeed(ulong src, ulong len, int iter) { - if (logflag) { - char log[] = "\nmemspeed(ulong src, long len, int iter) started."; - print_log(log, sizeof(log) - 1); + if (logflag && log_memspeed) { + char log[] = "\nmemspeed(ulong src, long len, int iter) started."; + print_log(log, sizeof(log) - 1); } if (logflag && log_memspeed) { - char log[38] = "memspeed(): src = "; - int length = 18; - int_to_charr(src, log, &length); - print_log(log, length); + char log[38] = "memspeed(): src = "; + int length = 18; + int_to_charr(src, log, &length); + print_log(log, length); } if (logflag && log_memspeed) { - char log[38] = "memspeed(): len = "; - int length = 18; - int_to_charr(len, log, &length); - print_log(log, length); + char log[38] = "memspeed(): len = "; + int length = 18; + int_to_charr(len, log, &length); + print_log(log, length); } if (logflag && log_memspeed) { - char log[39] = "memspeed(): iter = "; - int length = 19; - int_to_charr(iter, log, &length); - print_log(log, length); + char log[39] = "memspeed(): iter = "; + int length = 19; + int_to_charr(iter, log, &length); + print_log(log, length); } @@ -1335,17 +1224,17 @@ ulong memspeed(ulong src, ulong len, int iter) ulong cal_low, cal_high; if (logflag && log_memspeed) { - char log[22] = "memspeed(): rdtsc = "; - int length = 20; - int_to_charr(cpu_id.fid.bits.rdtsc, log, &length); - print_log(log, length); + char log[22] = "memspeed(): rdtsc = "; + int length = 20; + int_to_charr(cpu_id.fid.bits.rdtsc, log, &length); + print_log(log, length); } if (cpu_id.fid.bits.rdtsc == 0 ) { if (logflag && log_memspeed) { - char log[] = "memspeed(): returning with -1 because rdtsc = 0"; - print_log(log, sizeof(log) - 1); + char log[] = "memspeed(): returning with -1 because rdtsc = 0"; + print_log(log, sizeof(log) - 1); } return(-1); @@ -1353,8 +1242,8 @@ ulong memspeed(ulong src, ulong len, int iter) if (len == 0) { if (logflag && log_memspeed) { - char log[] = "memspeed(): returning with -2 because len = 0"; - print_log(log, sizeof(log) - 1); + char log[] = "memspeed(): returning with -2 because len = 0"; + print_log(log, sizeof(log) - 1); } return(-2); @@ -1364,8 +1253,8 @@ ulong memspeed(ulong src, ulong len, int iter) wlen = len / 4; /* Length is bytes */ if (logflag && log_memspeed) { - char log[] = "\nmemspeed(): Calibrate overhead with a zero word copy."; - print_log(log, sizeof(log) - 1); + char log[] = "\nmemspeed(): Calibrate overhead with a zero word copy."; + print_log(log, sizeof(log) - 1); } /* Calibrate the overhead with a zero word copy */ @@ -1492,7 +1381,7 @@ ulong memspeed(ulong src, ulong len, int iter) ); /* Make sure that the result fits in 32 bits */ - hprint(11,40,end_high); + memspeed_end_high = end_high; if (end_high) { if (logflag && log_memspeed) { diff --git a/efi_memtest/memtest86+/efi/logger.c b/efi_memtest/memtest86+/efi/logger.c index 4d6955a..eb3211a 100644 --- a/efi_memtest/memtest86+/efi/logger.c +++ b/efi_memtest/memtest86+/efi/logger.c @@ -360,6 +360,18 @@ void print_pmap() { int msegs = vv->msegs; + char log[42] ="print_pmap(): msegs = "; + int length = 22; + int_to_charr(msegs, log, &length); + print_log(log, length); + + if(1) { + char log[23] = "vv addr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } + for (int i = 0; i < msegs; i++) { char log1[33] = "\nprint_pmap(): start = "; diff --git a/efi_memtest/memtest86+/efi/memory_tables.c b/efi_memtest/memtest86+/efi/memory_tables.c index bd5413d..fbf4a7f 100644 --- a/efi_memtest/memtest86+/efi/memory_tables.c +++ b/efi_memtest/memtest86+/efi/memory_tables.c @@ -39,6 +39,13 @@ int query_memory_table(void) { int flag = 0; + if(1) { + char log[23] = "vvqaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } + UINTN MemoryMapSize = 0; EFI_MEMORY_DESCRIPTOR *memoryMap = NULL; UINTN LocalMapKey; diff --git a/efi_memtest/memtest86+/main.c b/efi_memtest/memtest86+/main.c index b219867..386e930 100644 --- a/efi_memtest/memtest86+/main.c +++ b/efi_memtest/memtest86+/main.c @@ -203,6 +203,20 @@ void set_defaults() } restart_flag = 0; tseq[10].sel = 0; + + if(1) { + char log[23] = "vv addr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "plim_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } } @@ -420,27 +434,58 @@ void test_start(void) //parse_command_line(); // TODO not possible yet if (logflag) print_log("test_start(): Command line parsed, now clear_screen()", 53); - clear_screen(); + /* Initialize the barrier so the lock in btrace will work. * Will get redone later when we know how many CPUs we have */ barrier_init(1); + btrace(my_cpu_num, __LINE__, "Begin ", 1, 0, 0); + + if(1) { + char log[23] = "pllm_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } + + /* Find memory size */ mem_size(); /* must be called before initialise_cpus(); */ + + if(1) { + char log[23] = "pllm_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } + + /* Fill in the CPUID table */ get_cpuid(); /* Startup the other CPUs */ start_seq = 1; + //initialise_cpus(); todo smp btrace(my_cpu_num, __LINE__, "BeforeInit", 1, 0, 0); /* Draw the screen and get system information */ + /* + * WARNING: do not print anything except btrace before this statement. + * Otherwise it will be overwritten. + */ init(); /* Set defaults and initialize variables */ set_defaults(); + if(1) { + char log[] = "plim_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } + if (logflag) print_log("test_start(): set_defaults() finished.", 38); /* Setup base address for testing, 1 MB */ @@ -554,7 +599,8 @@ void test_start(void) int_to_charr(cpu_id.fid.bits.lm, log, &length); print_log(log, length); } - setup_mm_modes(); + + setup_mm_modes(); // TODO do we need it anymore? Since we already start in 64 bit mode /* Get the memory Speed with all CPUs */ //get_mem_speed(my_cpu_num, num_cpus); @@ -665,12 +711,12 @@ void test_start(void) run_cpus = tseq[test].cpu_sel; } } - if (logflag) { + /*if (logflag) { char log[50] = "test_start(): mstr_cpu in switch stmt = "; int length = 40; int_to_charr(mstr_cpu, log, &length); print_log(log, length); - } + }*/ mstr_cpu = 0; // TODO remove. Hope that it is set when smp is enabled break; } @@ -1002,6 +1048,13 @@ int do_test(int my_ord) cprint(LINE_PAT, COL_MID+25, " "); }*/ + if (logflag) { + char log[41] = ">>>>>>>>>>>>>>>>>>>> "; + int length = 21; + int_to_charr(vv->selected_pages, log, &length); + print_log(log, length); + } + /* Update display of memory segments being tested */ p0 = page_of(vv->map[0].start); p1 = page_of(vv->map[segs-1].end); @@ -1492,47 +1545,7 @@ static int compute_segments(struct pmap win, int me) if (end >= wend) { end = wend; } -#if 0 - cprint(LINE_SCROLL+(2*i), 0, " ("); - hprint(LINE_SCROLL+(2*i), 2, start); - cprint(LINE_SCROLL+(2*i), 10, ", "); - hprint(LINE_SCROLL+(2*i), 12, end); - cprint(LINE_SCROLL+(2*i), 20, ") "); - - cprint(LINE_SCROLL+(2*i), 22, "r("); - hprint(LINE_SCROLL+(2*i), 24, wstart); - cprint(LINE_SCROLL+(2*i), 32, ", "); - hprint(LINE_SCROLL+(2*i), 34, wend); - cprint(LINE_SCROLL+(2*i), 42, ") "); - - cprint(LINE_SCROLL+(2*i), 44, "p("); - hprint(LINE_SCROLL+(2*i), 46, vv->plim_lower); - cprint(LINE_SCROLL+(2*i), 54, ", "); - hprint(LINE_SCROLL+(2*i), 56, vv->plim_upper); - cprint(LINE_SCROLL+(2*i), 64, ") "); - - cprint(LINE_SCROLL+(2*i+1), 0, "w("); - hprint(LINE_SCROLL+(2*i+1), 2, win.start); - cprint(LINE_SCROLL+(2*i+1), 10, ", "); - hprint(LINE_SCROLL+(2*i+1), 12, win.end); - cprint(LINE_SCROLL+(2*i+1), 20, ") "); - - cprint(LINE_SCROLL+(2*i+1), 22, "m("); - hprint(LINE_SCROLL+(2*i+1), 24, vv->pmap[i].start); - cprint(LINE_SCROLL+(2*i+1), 32, ", "); - hprint(LINE_SCROLL+(2*i+1), 34, vv->pmap[i].end); - cprint(LINE_SCROLL+(2*i+1), 42, ") "); - - cprint(LINE_SCROLL+(2*i+1), 44, "i="); - hprint(LINE_SCROLL+(2*i+1), 46, i); - - cprint(LINE_SCROLL+(2*i+2), 0, - " " - " "); - cprint(LINE_SCROLL+(2*i+3), 0, - " " - " "); -#endif + if (logflag && log_comp_seg) { char log[49] = "\ncompute_segments(): start = "; int length = 29; @@ -1584,21 +1597,7 @@ static int compute_segments(struct pmap win, int me) int_to_charr((unsigned long)vv->map[sg].end, log, &length); print_log(log, length); } -#if 0 - hprint(LINE_SCROLL+(sg+1), 0, sg); - hprint(LINE_SCROLL+(sg+1), 12, vv->map[sg].pbase_addr); - hprint(LINE_SCROLL+(sg+1), 22, start); - hprint(LINE_SCROLL+(sg+1), 32, end); - hprint(LINE_SCROLL+(sg+1), 42, mapping(start)); - hprint(LINE_SCROLL+(sg+1), 52, emapping(end)); - cprint(LINE_SCROLL+(sg+2), 0, - " " - " "); -#endif -#if 0 - cprint(LINE_SCROLL+(2*i+1), 54, ", sg="); - hprint(LINE_SCROLL+(2*i+1), 59, sg); -#endif + sg++; } } diff --git a/efi_memtest/memtest86+/memsize.c b/efi_memtest/memtest86+/memsize.c index aebbd0b..56f20be 100644 --- a/efi_memtest/memtest86+/memsize.c +++ b/efi_memtest/memtest86+/memsize.c @@ -22,10 +22,17 @@ static void sort_pmap(void); /* * Find out how much memory there is. */ -#pragma GCC push_options -#pragma GCC optimize ("O0") +//#pragma GCC push_options +//#pragma GCC optimize ("O0") void mem_size(void) { + + if(1) { + char log[23] = "vvmaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } int i = 0, flag = 0; vv->test_pages = 0; @@ -48,19 +55,97 @@ void mem_size(void) } } + if(1) { + char log[23] = "vvmaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } + get_mem_size(flag, e820_nr, e820); + if(1) { + char log[23] = "pmap.end = "; + int length = 11; + int_to_charr(vv->pmap[vv->msegs-1].end, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "msegs = "; + int length = 8; + int_to_charr(vv->msegs, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "vvmaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } /* Guarantee that pmap entries are in ascending order */ sort_pmap(); + if(1) { + char log[23] = "vvmaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } vv->plim_lower = 0; vv->plim_upper = vv->pmap[vv->msegs-1].end; + if(1) { + char log[23] = "pmap.end = "; + int length = 11; + int_to_charr(vv->pmap[vv->msegs-1].end, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "msegs = "; + int length = 8; + int_to_charr(vv->msegs, log, &length); + print_log(log, length); + } + + print_pmap(); // TODO remove + + if(1) { + char log[23] = "pmap.end = "; + int length = 11; + int_to_charr(vv->pmap[vv->msegs-1].end, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "msegs = "; + int length = 8; + int_to_charr(vv->msegs, log, &length); + print_log(log, length); + } + + if(1) { + char log[23] = "pffm_upper = "; + int length = 13; + int_to_charr(vv->plim_upper, log, &length); + print_log(log, length); + } + adj_mem(); } -#pragma GCC pop_options +//#pragma GCC pop_options static void sort_pmap(void) { + + if(1) { + char log[23] = "vvpaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } + int i, j; /* Do an insertion sort on the pmap, on an already sorted * list this should be a O(1) algorithm. @@ -82,4 +167,12 @@ static void sort_pmap(void) vv->pmap[j] = temp; } } + + + if(1) { + char log[23] = "vvpaddr = "; + int length = 10; + int_to_charr((ulong)vv, log, &length); + print_log(log, length); + } }
\ No newline at end of file |