26 //! @SYMTestActions 001 Check that the rom is paged |
26 //! @SYMTestActions 001 Check that the rom is paged |
27 //! @SYMTestExpectedResults All tests should pass. |
27 //! @SYMTestExpectedResults All tests should pass. |
28 //! @SYMTestPriority High |
28 //! @SYMTestPriority High |
29 //! @SYMTestStatus Implemented |
29 //! @SYMTestStatus Implemented |
30 |
30 |
|
31 #define __E32TEST_EXTENSION__ |
31 #include <e32test.h> |
32 #include <e32test.h> |
32 RTest test(_L("T_NANDPAGING")); |
33 RTest test(_L("T_NANDPAGING")); |
33 |
34 |
34 #include <e32rom.h> |
35 #include <e32rom.h> |
35 #include <e32svr.h> |
36 #include <e32svr.h> |
36 #include <u32hal.h> |
37 #include <u32hal.h> |
37 #include <f32file.h> |
38 #include <f32file.h> |
38 #include <f32dbg.h> |
39 #include <f32dbg.h> |
39 #include "testdefs.h" |
40 #include "testdefs.h" |
40 #include <hal.h> |
41 #include <hal.h> |
|
42 #include "nfe.h" |
41 |
43 |
42 |
44 |
43 TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect. |
45 TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect. |
44 TInt locDriveNumber; |
46 TInt locDriveNumber; |
45 |
47 |
507 { |
509 { |
508 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
510 TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
509 TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart; |
511 TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart; |
510 TUint size = romHeader->iPageableRomSize; |
512 TUint size = romHeader->iPageableRomSize; |
511 TUint8* addr=NULL; |
513 TUint8* addr=NULL; |
512 TBool flush; |
|
513 while (Testing) |
514 while (Testing) |
514 { |
515 { |
515 PageSemaphore.Wait(); // wait for main thread to want paging. |
516 PageSemaphore.Wait(); // wait for main thread to want paging. |
516 flush = (PagesBeingPaged==0); |
|
517 addr=start+((TInt64(Random())*TInt64(size))>>32); |
517 addr=start+((TInt64(Random())*TInt64(size))>>32); |
518 PageDoneSemaphore.Signal(); // Acknolage request. |
518 PageDoneSemaphore.Signal(); // Acknowledge request. |
519 |
519 |
520 PageMutex.Wait(); |
520 PageMutex.Wait(); |
|
521 TBool flush = (PagesBeingPaged==0); // Ensure only one thread is flushing the cache at a time. |
521 PagesBeingPaged++; |
522 PagesBeingPaged++; |
522 PageMutex.Signal(); |
523 PageMutex.Signal(); |
523 |
524 |
524 if (flush) |
525 if (flush) |
525 UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
526 UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
542 { |
543 { |
543 test.Next(_L("Defering test - Skipped!")); |
544 test.Next(_L("Defering test - Skipped!")); |
544 return; |
545 return; |
545 } |
546 } |
546 |
547 |
|
548 // If the NFE test media driver extension is present, ALL the drive is encrypted; |
|
549 // this means that there will be very few free blocks in the free block reservoir: this effectively |
|
550 // disables background garbage collection and all block erasing needs to happen on the fly... |
|
551 TNfeDeviceInfo nfeDeviceinfo; |
|
552 TPtr8 nfeDeviceInfoBuf((TUint8*) &nfeDeviceinfo, sizeof(nfeDeviceinfo)); |
|
553 nfeDeviceInfoBuf.FillZ(); |
|
554 TInt r = Drive.QueryDevice((RLocalDrive::TQueryDevice) EQueryNfeDeviceInfo, nfeDeviceInfoBuf); |
|
555 /* |
|
556 if (r == KErrNone) |
|
557 { |
|
558 test.Printf(_L("NFE device detected, aborting garbage collection test for now\n")); |
|
559 return; |
|
560 } |
|
561 */ |
|
562 // Create some free blocks by creating a huge file and then deleting it.... |
|
563 if (r == KErrNone) |
|
564 { |
|
565 test.Printf(_L("NFE device detected\n")); |
|
566 RFile file; |
|
567 |
|
568 TBuf<256> tempFileName = _L("?:\\f32-tst\\"); |
|
569 tempFileName[0] = 'A'+DriveNumber; |
|
570 |
|
571 r = TheFs.MkDirAll(tempFileName); |
|
572 test(r==KErrNone || r== KErrAlreadyExists); |
|
573 |
|
574 tempFileName+= _L("TEMP.TXT"); |
|
575 |
|
576 r = file.Replace(TheFs, tempFileName, EFileWrite); |
|
577 test_KErrNone(r); |
|
578 |
|
579 for (TInt fileSize = KMaxTInt; fileSize > 0; fileSize >>= 1) |
|
580 { |
|
581 r = file.SetSize(fileSize); |
|
582 test.Printf(_L("Setting file size to %d, r %d\n"), fileSize, r); |
|
583 if (r == KErrNone) |
|
584 break; |
|
585 } |
|
586 file.Close(); |
|
587 r = TheFs.Delete(tempFileName); |
|
588 test_KErrNone(r); |
|
589 } |
|
590 |
|
591 |
|
592 |
547 TInt timeout; |
593 TInt timeout; |
548 TInt writesNeeded=100; |
594 TInt writesNeeded=100; |
549 TInt r = KErrNone; |
|
550 RFile tempFile; |
595 RFile tempFile; |
551 TInt i; |
596 TInt i; |
552 TInt ii; |
597 TInt ii; |
553 TInt runs=0; |
598 TInt runs=0; |
554 |
599 |
591 CreateFile(tempFile,_L("nandpage.txt")); |
636 CreateFile(tempFile,_L("nandpage.txt")); |
592 |
637 |
593 |
638 |
594 for (ii=0; ii<MaxDeferLoops; ii++) // Repeat the test, 'MaxDeferLoops' number of times. This can be set on cammand line. |
639 for (ii=0; ii<MaxDeferLoops; ii++) // Repeat the test, 'MaxDeferLoops' number of times. This can be set on cammand line. |
595 { |
640 { |
|
641 writesNeeded=100; |
596 timeout=20; |
642 timeout=20; |
597 do // while ((pageGarbageCount==0) && (timeout>0)); |
643 do // while ((pageGarbageCount==0) && (timeout>0)); |
598 // ie, while garbage collection hasn't happened, or timed out |
644 // ie, while garbage collection hasn't happened, or timed out |
599 { |
645 { |
600 timeout--; |
646 timeout--; |