#include #include #include #include "memsize.h" #include "memMarco.h" #include "commMEC.h" extern u64 gMemDiagStartAddr; extern u64 gDiagAvailAddr; extern u64 gMemDiagRegionSize; extern u64 gMemDiagTOLMAddr; extern u64 gMemDiagTOHMAddr; extern u64 gMemDiagTSEGAddr; extern u64 gMemDiagTSEGSize; mdc init_MemDiagCmd() { mdc cmd; cmd.forward=1; cmd.write_pattern=(u64) NULL; cmd.verify_pattern=(u64) NULL; cmd.dma=0; cmd.error_item=0; cmd.error_code=0; return cmd; } int mem_region(mdc cmd, u64 testAddr, u64 testSize) { u64 sizeUnTest; u64 sizeToTest; u64 curTestAddr; u64 totalRegion; u64 idxRegion; u64* pRegionBase; u64* pRegionTest; char msg[200]; int tmp; M_INIT_TEST_BASE(testAddr); M_INIT_TEST_REGION(testAddr, testSize); totalRegion = testSize / MEM_RAM_IOREMAP_MAX_SIZE; if (testSize % MEM_RAM_IOREMAP_MAX_SIZE){ totalRegion++; } if ( testSize < sizeof(u64) ) testSize=sizeof(u64); sizeUnTest = testSize; if(cmd.forward==-1) testAddr += testSize; //printk("item %d, testAddr 0x%lx,\ntestSize 0x%lx\n", cmd.error_item, testAddr, testSize); //printk(" for(idxRegion = 0; idxRegion < totalRegion; idxRegion++)\n"); for(idxRegion = 0; idxRegion < totalRegion; idxRegion++) { curTestAddr = testAddr + (idxRegion * cmd.forward * MEM_RAM_IOREMAP_MAX_SIZE); if(sizeUnTest >= MEM_RAM_IOREMAP_MAX_SIZE) { sizeToTest = MEM_RAM_IOREMAP_MAX_SIZE; }else{ sizeToTest = sizeUnTest; } sizeUnTest-=sizeToTest; //Calculate the starting address for this test region if ((gMemDiagTSEGAddr > 0) && (gMemDiagTSEGSize > 0) && ((curTestAddr + (sizeToTest * cmd.forward)) >= gMemDiagTSEGAddr) && (curTestAddr < (gMemDiagTSEGAddr + gMemDiagTSEGSize))) { printk("Skip TSG zone %LX\n", curTestAddr); continue; } tmp=0; if(cmd.forward==-1){ if( (curTestAddr - MEM_RAM_IOREMAP_MAX_SIZE) >= gMemDiagTOLMAddr ) { tmp=1; } }else{ if(curTestAddr >= gMemDiagTOLMAddr) { tmp=1; } } if(tmp == 1) { curTestAddr = MEM_JF_CORE_REG_TOHMH_START + curTestAddr - gMemDiagTOLMAddr; } if(cmd.forward==-1){ pRegionBase = (u64 *)ioremap( (curTestAddr-sizeToTest) , sizeToTest); pRegionTest = pRegionBase + (int)(sizeToTest/sizeof(u64)) + cmd.forward; //sizeToTest = sizeToTest - sizeof(u64); }else{ pRegionBase = (u64 *)ioremap(curTestAddr, sizeToTest); pRegionTest = pRegionBase; } //printk(" curTestAddr: 0x%lx, sizeToTest: 0x%lx totalRegion:%d, MEM_RAM_IOREMAP_MAX_SIZE=0x%lx idxRegion %d\n", curTestAddr, sizeToTest, totalRegion, MEM_RAM_IOREMAP_MAX_SIZE, idxRegion); if ( pRegionBase == NULL ){ printk("NULL >> curTestAddr: 0x%Lx, sizeToTest: 0x%Lx \n", curTestAddr, sizeToTest); }else{ // printk("<> curTestAddr: 0x%lx, sizeToTest: 0x%lx \n", curTestAddr, sizeToTest); tmp=0; while(sizeToTest > 0){ if (cmd.verify_pattern != (u64) NULL) { if( *pRegionTest != cmd.verify_pattern ){ sprintf(msg,"[FAIL] verify pRegionTest 0x%Lx, 0x%Lx\n", *pRegionTest, cmd.verify_pattern); cmd.error_code=MEM_DIAG_ERROR_CODE_DATA_VERIFY_ERR; errorReport(cmd, msg); return 1; // Error } } if (cmd.write_pattern != (u64) NULL){ *pRegionTest = cmd.write_pattern; } sizeToTest = sizeToTest - sizeof(u64); pRegionTest = pRegionTest + cmd.forward; tmp++; } // printk("tmp %d idxRegion <%d> %d sizeToTest 0x%lx\n",tmp, idxRegion, (pRegionTest-pRegionBase), sizeToTest); iounmap((void *)pRegionBase); } if (totalRegion > 10) { if (idxRegion%2){ printk("\r/"); }else{ printk("\r\\"); } } } return 0; }