/* V2MemTest - A CLI Tool to test & fix Voodoo² TMU System * Copyright (C) 2026 ChaCha * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define _BSD_SOURCE 1 #include #include #include #include #include #include "cvg.h" #include #include "sst1init.h" #include "fxpci.h" #include "V2MemTest.h" #include "FaultSources.h" #include "Utils.h" #include "Draw.h" #include "Test_Address.h" #include "Test_Data.h" #include "Test_Data_Huge.h" const char szTitle[] = "V2MemTest-%d.%d.%d - A CLI Tool to test & fix Voodoo² TMU System\n" "Copyright (C) 2026 ChaCha\n"; const char szLicence[] = "This program is free software : you can redistribute it and/or modify it under\n" "the terms of the GNU General Public License as published by the Free Software\n" "Foundation either version 3 of the License, or (at your option) any later version.\n" "This program is distributed in the hope that it will be useful, but WITHOUT ANY\n" "WARRANTY !\n"; const char szHelp[] = "Usage ./v2memtest \n" "\n" "options:\n" "\t-h :\tthis output\n" "\n" "\t-v :\tset log level to the specified value.\n" "\t\t 0: ERR, 1: INFO, 2: WARN, 3: DEBUG, 4: TRACE\n" "\n" "\t-fl :\tset a log file path & name.\n" "\n" "\t-fd :\tset a failure report path & base name.\n" "\t\t Note that the test name will be appended to the file name.\n" "\t\t eg: file name is 'foo' running 'data-bitmove' :\n" "\t\t foo_data-bitmove.tsv\n"; def_sOptions sOptions = { .ucLogLevel = E_LOGLEVEL__WARNING, .bLogStdOut = 1, .szLogFileName = {0}, .szTSVFile = {0}, .usNbLoops = 1, }; int main(int argc, char **argv) { unsigned long long ullNbErrorAll = 0; const unsigned char boardNum = 0; sst1DeviceInfoStruct devInfo; FxU32* sst; SstRegs *sstregs; printf(szTitle, V2MEMTEST__VERSION__MAJOR, V2MEMTEST__VERSION__MINOR, V2MEMTEST__VERSION__PATCH); putchar('\n'); puts(szLicence); putchar('\n'); srandom(time(NULL)); FaultSource_Reset(); for(int j=0; j<100; j++) { if ((sst = sst1InitMapBoard(boardNum)) == NULL) { fprintf(stderr, "No Voodoo boards found\n"); exit(-1); } sst1InitRegisters(sst); if (sst1InitGetDeviceInfo(sst, &devInfo) == FXFALSE) { fprintf(stderr, "Couldn't get info for Voodoo # %d\n", boardNum); exit(-1); } /* grGlideInit(); GrHwConfiguration hwconfig; if(!grSstQueryHardware(&hwconfig)) { fprintf(stderr, "Couldn't get glide info for Voodoo # %d\n", boardNum); exit(-1); } grSstSelect(boardNum); */ sstregs = (SstRegs *) sst; printf("FBI Memory: %d MB\n", devInfo.fbiMemSize); for (int tmu = 0; tmu < devInfo.numberTmus; tmu++) { printf("TMU %d RAM: %d MB\n", tmu, devInfo.tmuMemSize[tmu]); } putchar('\n'); ISET(sstregs->lfbMode, SST_LFB_RGBALANES_ARGB | SST_LFB_READFRONTBUFFER); ISET(sstregs->fbzMode, SST_DRAWBUFFER_FRONT | SST_RGBWRMASK); ISET(sstregs->fbzColorPath, SST_RGBSEL_TREXOUT | SST_CC_PASS | SST_ENTEXTUREMAP); ISET(sstregs->textureMode, SST_RGB565 | SST_TC_REPLACE | SST_TCA_REPLACE); ISET(sstregs->tLOD, 0); //if(devInfo.tmuMemSize[1]==1) continue; //devInfo.numberTmus=1; //devInfo.tmuMemSize[1]==1; for (int tmu = 0; tmu < devInfo.numberTmus; tmu++) { printf("Testing Board %d, TMU %d, %dMB \n\n",boardNum,tmu,devInfo.tmuMemSize[tmu]); puts("# address & control lines test - cumulated"); for(int j=0;j<100;j++) { const unsigned long long err = RenderTestAddress(&devInfo, sst, sstregs, tmu, devInfo.tmuMemSize[tmu]); ullNbErrorAll += err; putchar( err ? 'E' : '-'); fflush(stdout); } putchar('\n'); puts("# data test - single bit move"); for(int j=0;j<100;j++) { const unsigned long long err = test_TMU_datalines(&devInfo, sst, sstregs, tmu , 0, //bit shift devInfo.tmuMemSize[tmu]); ullNbErrorAll += err; putchar( err ? 'E' : '-'); fflush(stdout); } putchar('\n'); puts("# data test - random pattern"); for(int j=0;j<100;j++) { const unsigned long long err = test_TMU_datalines(&devInfo, sst, sstregs, tmu , 1, // random devInfo.tmuMemSize[tmu]); ullNbErrorAll += err; putchar( err ? 'E' : '-'); fflush(stdout); } putchar('\n'); puts("# data test - huge data"); for(int j=0;j<10;j++) { const unsigned long long err = test_TMU_datalines_Huge( &devInfo, sst, sstregs, tmu , devInfo.tmuMemSize[tmu]); ullNbErrorAll += err; putchar( err ? 'E' : '-'); fflush(stdout); } putchar('\n'); } } FaultSource_Sort(); FaultSource_Display(); printf("Test Complete, ullNbErrorAll = %lld\n",ullNbErrorAll); //grGlideShutdown(); pciClose(); return 0; }