⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swap_mgr.c

📁 这是韩国EQUATOR公司提供的DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:
  VlxDataFromCore.swap_unit_size =  swap_unit_size; // in bytes (vlx must convert to shorts)
  nswap                          =  2 * (TEST_STREAM_SIZE / swap_unit_size) - 1; // Actual # of swaps needed
  VlxDataFromCore.nswap          =  nswap + 2; // Add 2 swaps to push out data on the output side (be sure to pad 
                                               //   the input buffers!)
  VlxDataFromCore.fill_1[0]       = 0;
  VlxDataFromCore.fill_1[1]       = 0;
  VlxDataFromCore.fill_1[2]       = 0;
  VlxDataFromCore.fill_2[0]       = 0;
  VlxDataFromCore.fill_2[1]       = 0;
  VlxDataFromCore.fill_2[2]       = 0;

  kprintf("main(): Swapping every %d bytes, total of %d swaps\n", swap_unit_size, nswap );

  pULL = (volatile_noncached unsigned long long*)(&pVlxDataFromCore->swap_unit_size); // must be 8 byte aligned!
  *pULL = *( (unsigned long long*)(&VlxDataFromCore.swap_unit_size) );
  kprintf("Writing swap_unit_size (0x%x) to Vlmem...\n",VlxDataFromCore.swap_unit_size );
  kprintf("\tpVlxDataFromCore = 0x%08x\n", pVlxDataFromCore );
  kprintf("\tin vlmem @0x%08x : ( 0x%08x, 0x%08x ) \n"
          , pULL
          , (unsigned long)(*pULL >> 32)
          , (unsigned long)(*pULL & 0xFFFFFFFF )
  );

  pULL = (volatile_noncached unsigned long long*)(&pVlxDataFromCore->nswap); // must be 8 byte aligned!
  *pULL = *( (unsigned long long*)(&VlxDataFromCore.nswap) );
  kprintf("Writing nswap (0x%x) to Vlmem...\n",VlxDataFromCore.nswap );
  kprintf("\tpVlxDataFromCore = 0x%08x\n", pVlxDataFromCore );
  kprintf("\tin vlmem @0x%08x : ( 0x%08x, 0x%08x ) \n"
          , pULL
          , (unsigned long)(*pULL >> 32)
          , (unsigned long)(*pULL & 0xFFFFFFFF )
  );

  //
  // Kick the non-IO channels 
  //
  DsKick(MemIOPath1.srcCh.id, &dsSrc_PathW2GBi_InputStream_1);
  DsKick(IOMemPath1.dstCh.id, &dsDst_PathGBo2W_OutputStream_1);

  DsKick(MemIOPath2.srcCh.id, &dsSrc_PathW2GBi_InputStream_2);
  DsKick(IOMemPath2.dstCh.id, &dsDst_PathGBo2W_OutputStream_2);

  //
  // Start the Vlx
  //
  printf("VlxKick() \n");
  VlxResetPC();
  VlxKick();

  //
  // Check semaphore to determine if VLx is finished
  //
  iter_i = 0;
  pVlxSemaEnd = pCM1 + VLXLAB_vswap__semaEnd;
  pULL = (volatile_noncached unsigned long long*)pVlxSemaEnd;
  kprintf("Reading semaEnd from 0x%08x...\n", pVlxSemaEnd ); 
  while ( *pULL != 0 ) {
      pause();
      if( iter_i++ > SEMA_TIMEOUT_CYCLES ) break;
  }
  if ( iter_i > SEMA_TIMEOUT_CYCLES ) {
      kprintf("ERROR...semaphore timed out, resume.\n");
      fail_status |= S_FAIL_SEMA_VLX;
      //kprintf("status.gb_stall = 0x%x\n", *pVlStatusGb );
  } else {
      kprintf("...semaphore cleared, resume.\n");
  }

  // 
  // Wait for all of the data to arrive
  // 
/*
  iter_i = 0;
  while ( *pSemaDstXfer == 0 ) {
      pause();
      if( iter_i++ > SEMA_TIMEOUT_CYCLES ) break;
  }
  if ( iter_i > SEMA_TIMEOUT_CYCLES ) {
      kprintf("ERROR...data semaphore timed out, resume.\n");
      fail_status |= S_FAIL_SEMA_DATA;
      kprintf("status.gb_stall = 0x%x\n", *pVlStatusGb );
  } else {
      kprintf("...data semaphore cleared, resume.\n");
  }
*/

  kprintf("VlxStop\n");
  VlxStop();

  //
  // Check the data
  //  ~ Check the data between the start marker (0xaaaa)
  //    and the end marker (0xeeee)
  //
  kprintf("\nChecking Output...\n");

  kprintf("\n");

  //
  // Check Stream 1
  //   ~ Look for 2 consecutive bytes with the value 0xee : indicates end
  //
  iter_i = 0;
  while ( test_stream_1_src[iter_i] != 0xee ) {
      if ( iter_i >= TEST_STREAM_SIZE - 1 ) {
          kprintf("\tERROR, index to test_stream_1_src[] exceeded max.\n");
          fail_status |= S_FAIL_OTHER;
          break;
      }
      if ( test_stream_1_src[iter_i] != test_stream_1_dst[iter_i] ) {
          fail_status |= S_FAIL_DATA;
      }
     #ifdef _CONFIG_VERBOSE
      kprintf("\ttest_stream_1_src %d : src = 0x%x, dst = 0x%x\n"
         ,iter_i
         ,test_stream_1_src[iter_i]
         ,test_stream_1_dst[iter_i]
      );
     #endif
      iter_i++;
  } // while(test_stream_1_src)

  //
  // Check Stream 2
  //   ~ Look for end code 0xee
  //
  iter_i = 0;
  while ( test_stream_2_src[iter_i] != 0xee ) {
      if ( iter_i >= TEST_STREAM_SIZE - 1 ) {
          kprintf("\tERROR, index to test_stream_2_src[] exceeded max.\n");
          fail_status |= S_FAIL_OTHER;
          break;
      }
      if ( test_stream_2_src[iter_i] != test_stream_2_dst[iter_i] ) {
          fail_status |= S_FAIL_DATA;
      }
     #ifdef _CONFIG_VERBOSE
      kprintf("\ttest_stream_2_src %d : src = 0x%x, dst = 0x%x\n"
         ,iter_i
         ,test_stream_2_src[iter_i]
         ,test_stream_2_dst[iter_i]
      );
     #endif
      iter_i++;
  } // while(test_stream_2_src)

   
  // Get Vlx status

    kprintf("\nVlx Status struct :\n");
    kprintf("\tgb_stall          = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->gb_stall ) );
    kprintf("\texit_code         = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->exit_code ) );
    kprintf("\tstart_code_found1 = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->start_code_found_1 ) );
    kprintf("\tstart_code_found2 = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->start_code_found_2 ) );
    kprintf("\tnswap             = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->nswap ) );
    kprintf("\tswapcount         = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->swapcount ) );
    kprintf("\tswap_unit         = 0x%x\n", VlMemRead16( (VNC_UINT16*)&pVlxStatus->swap_unit ) );

   kprintf("\nProgram status : 0x%08x\n", fail_status);

  DsClosePath(MemIOPath1.id);
  DsClosePath(IOMemPath1.id);
  DsClosePath(MemIOPath2.id);
  DsClosePath(IOMemPath2.id);

  if ( fail_status == S_PASS ) {
      kprintf("\nPASSED!! \n");
  } else {
      kprintf("\nFAILED!! \n");

      if ( fail_status & S_FAIL_SEMA_VLX )    kprintf("\tStatus : S_FAIL_SEMA_VLX\n");
      if ( fail_status & S_FAIL_DATA )        kprintf("\tStatus : S_FAIL_DATA\n");
      if ( fail_status & S_FAIL_OTHER )       kprintf("\tStatus : S_FAIL_OTHER\n");
      if ( fail_status & S_FAIL_SEMA_DATA_1 ) kprintf("\tStatus : S_FAIL_SEMA_DATA_1\n");
      if ( fail_status & S_FAIL_SEMA_DATA_2 ) kprintf("\tStatus : S_FAIL_SEMA_DATA_2\n");

  }

  exit(0);

} // end main()

void InitDsReqPath(
    DS_PATH_INFO* dsPathRequest,
    BOOL          isSrcIO,
    BOOL          isDstIO,
    SINT32        bufferSize,
    SINT32        srcSize,
    SINT32        dstSize
)
{
    dsPathRequest->srcCh.transferBurstSize      = DS_DEFAULT;
    dsPathRequest->srcCh.minInterburstDelay     = DS_DEFAULT;
    dsPathRequest->srcCh.dtsPriority            = 0;
    dsPathRequest->srcCh.channelPriority        = DS_DEFAULT;
    dsPathRequest->srcCh.descriptorFetchMode    = DS_ACCESS_MODE_COHERENT_ALLOCATE;
    dsPathRequest->srcCh.wayMask                = DS_DEFAULT;
    dsPathRequest->srcCh.base                   = 0;

    dsPathRequest->dstCh.transferBurstSize      = DS_DEFAULT;
    dsPathRequest->dstCh.minInterburstDelay     = DS_DEFAULT;
    dsPathRequest->dstCh.dtsPriority            = 0;
    dsPathRequest->dstCh.channelPriority        = DS_DEFAULT;
    dsPathRequest->dstCh.descriptorFetchMode    = DS_ACCESS_MODE_COHERENT_ALLOCATE;
    dsPathRequest->dstCh.wayMask                = DS_DEFAULT;
    dsPathRequest->dstCh.base                   = 0;

    dsPathRequest->buf.bufferSize               = bufferSize; // in bytes
    dsPathRequest->buf.srcChunkSize             = srcSize;
    dsPathRequest->buf.dstChunkSize             = dstSize;

    dsPathRequest->isSrcIO                      = isSrcIO;
    dsPathRequest->isDstIO                      = isDstIO;

    dsPathRequest->flags                        = 0;

} // end InitDsReqPath()

int pause() {
  int i;
  int k;

  for(i=0;i<50;i++) {
    k = i;
  }
  return(k);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -