Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. void memdump(u32 memstart, u32 memlen)
  3. {
  4.   u8 data[BLOCKSIZE];
  5.   u32 i, sizeptr, multiple;
  6.   FIL dumpbin;
  7.  
  8. //mem1 size: 25165824 = 0x1800000
  9. //block size: 4096 (memlen should be a multiple of this block size) = 0x1000
  10.  
  11.   char *filename = (char*)malloc( 32 );
  12.   sprintf( filename, "/%.6smem1dump.bin", (char*)0x0 );
  13.   u32 fres = f_open( &dumpbin, filename, FA_READ|FA_WRITE|FA_OPEN_ALWAYS );
  14.   free( filename );
  15.   if( fres != FR_OK )
  16.   {
  17.         write32( 0x0D800070, 1 );
  18.         dbgprintf( "MEMDUMP: Could not open memdump.bin: %d\n", fres );
  19.       write32( 0x0D800070, 0 );
  20.   }
  21.   else
  22.   {
  23.         multiple = memlen/BLOCKSIZE;
  24.         if( memlen != multiple*BLOCKSIZE )
  25.         {
  26.           write32( 0x0D800070, 1 );
  27.           dbgprintf("MEMDUMP: Size of dump, %08X, is not multiple of %08X bytes\n", memlen, BLOCKSIZE );
  28.         write32( 0x0D800070, 0 );              
  29.         }
  30.         else
  31.         {
  32.           for( i=0; i<multiple; i++ )
  33.           {
  34.             memcpy( data, (void *)(memstart+i*BLOCKSIZE), sizeof(data) );
  35.             f_write( &dumpbin, data, sizeof(data), &sizeptr );
  36.           }
  37.         }
  38.         f_close( &dumpbin );
  39.   }
  40. }