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

📄 swap_mgr.c

📁 这是韩国EQUATOR公司提供的DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/**
*** Copyright (c) 2001 Equator Technologies, Inc.
**/

//#define _CONFIG_VERBOSE

#define SEMA_TIMEOUT_CYCLES  10000
#define VNC_UINT16  volatile_noncached unsigned short

#define TEST_STREAM_SIZE     256  // not including the padding on the end  
#define PAD_SIZE     128  // not including the padding on the end  
#define DS_BUFFER_SIZE        64  // ds buffer size of the io-io transfer

#define S_PASS               0
#define S_FAIL_SEMA_VLX     (0x1 << 0)
#define S_FAIL_DATA         (0x1 << 1)
#define S_FAIL_OTHER        (0x1 << 2)
#define S_FAIL_SEMA_DATA_1  (0x1 << 3)
#define S_FAIL_SEMA_DATA_2  (0x1 << 4)

#include <eti/ds.h>
#include <mm.h>
#include <eti/vlx.h>
#include "swap_mgr.h"
//#include "pio_dbg.h"
#include "vlx_c/vdata.h" // Pick up VLx data structures
#include "vswap_vlx.h"   // pick up the VLX binary labels

#define nwaste 0       // waste first nwaste shorts (start from nwaste)

extern VLX_BIN vswap;

extern unsigned char test_stream_1_src[];
extern unsigned char test_stream_2_src[];

PVLX_BIN pVlxBin = &vswap;

main() {

  //-------------------------------------------------------
  // DECLARATIONS
  //-------------------------------------------------------

    SCODE status = 15;

    DS_PATH_INFO   reqMemIOPath1, MemIOPath1;
    DS_PATH_INFO   reqIOMemPath1, IOMemPath1;
    DS_DESCRIPTOR  dsSrc_PathW2GBi_InputStream_1; 
    DS_DESCRIPTOR  dsDst_PathGBo2W_OutputStream_1; 

    DS_PATH_INFO   reqMemIOPath2, MemIOPath2;
    DS_PATH_INFO   reqIOMemPath2, IOMemPath2;
    DS_DESCRIPTOR  dsSrc_PathW2GBi_InputStream_2; 
    DS_DESCRIPTOR  dsDst_PathGBo2W_OutputStream_2; 

    type_data_from_core_struct  VlxDataFromCore;
    type_data_from_core_struct* pVlxDataFromCore;

    type_gb_ds_struct* pVlxGbConfig1;
    type_gb_ds_struct* pVlxGbConfig2;
    type_status_struct*    pVlxStatus;

    unsigned short getBitsData1;
    unsigned short getBitsData2;
    unsigned long  fail_status  = S_PASS;
  
    unsigned short* pCM1=(unsigned short *)VlxLookupCM1();

    unsigned char test_stream_1_dst[2*TEST_STREAM_SIZE];
    unsigned char test_stream_2_dst[2*TEST_STREAM_SIZE];
    unsigned int iter_i = 0;
    unsigned int nswap = 0;
    unsigned int swap_unit_size = 0;

    unsigned short  gbCtrl;
    unsigned short  bufInIndex, bufOutIndex;

    volatile_noncached unsigned long long* pULL;
    volatile_noncached unsigned short*     pVlxSemaEnd;

  //volatile_cached unsigned char* pSemaDstXfer = &test_stream_1_dst[TEST_STREAM_SIZE-1];

  //-------------------------------------------------------
  // EXECUTION
  //-------------------------------------------------------


  pVlxDataFromCore = (type_data_from_core_struct*)(pCM1 + VLXLAB_vswap__data_from_core);
  pVlxGbConfig1    = (type_gb_ds_struct*)(pCM1 + VLXLAB_vswap__gb_config1);
  pVlxGbConfig2    = (type_gb_ds_struct*)(pCM1 + VLXLAB_vswap__gb_config2);
  pVlxStatus       = (type_status_struct*)(pCM1+VLXLAB_vswap__status);

  //
  // Setup for IO-IO path for 1st channel GB out and 2nd channel GB in.
  //

  // Stream 1
  InitDsReqPath(
      &reqMemIOPath1  // DS_PATH_INFO
      ,FALSE          // isSrcIO
      ,TRUE           // isDstIO
      ,DS_BUFFER_SIZE // DS bufferSize in bytes
      ,32             // srcChunkSize in bytes
      ,0              // dstChunkSize in bytes
  );

  InitDsReqPath(
      &reqIOMemPath1  // DS_PATH_INFO
      ,TRUE           // isSrcIO
      ,FALSE          // isDstIO
      ,DS_BUFFER_SIZE // DS bufferSize in bytes
      ,0              // srcChunkSize in bytes
      ,64             // dstChunkSize in bytes
  );

  // Stream 2
  InitDsReqPath(
      &reqMemIOPath2  // DS_PATH_INFO
      ,FALSE          // isSrcIO
      ,TRUE           // isDstIO
      ,DS_BUFFER_SIZE // DS bufferSize in bytes
      ,32             // srcChunkSize in bytes
      ,0              // dstChunkSize in bytes
  );

  InitDsReqPath(
      &reqIOMemPath2  // DS_PATH_INFO
      ,TRUE           // isSrcIO
      ,FALSE          // isDstIO
      ,DS_BUFFER_SIZE // DS bufferSize in bytes
      ,0              // srcChunkSize in bytes
      ,64             // dstChunkSize in bytes
  );

  // Stream 1
  status = DsOpenPath(&reqMemIOPath1, &MemIOPath1);
  status |= DsOpenPath(&reqIOMemPath1, &IOMemPath1);

  // Stream 2
  status |= DsOpenPath(&reqMemIOPath2, &MemIOPath2);
  status |= DsOpenPath(&reqIOMemPath2, &IOMemPath2);

  if ( status != S_OK ) printf("ERROR : S_ERROR returned for status of DsOpenPath()...\n");

  //
  // Setup I/O for Stream1
  //
  DsDescSetGenericFmt1(
      &dsSrc_PathW2GBi_InputStream_1,        // this descriptor
      &dsSrc_PathW2GBi_InputStream_1,        // next descriptor
      DS_DESC_HALT | DS_DESC_DATA_ACCESS_NC, // optoins
      (char*)&test_stream_1_src[0],          // target addr (src)
      TEST_STREAM_SIZE + PAD_SIZE,           // width
      1,                                     // count
      0                                      // stride
  );

  DsDescSetGenericFmt1(
      &dsDst_PathGBo2W_OutputStream_1,         // this descriptor
      &dsDst_PathGBo2W_OutputStream_1,         // next descriptor
      DS_DESC_HALT | DS_DESC_DATA_ACCESS_CA,  // options
      (char*)&test_stream_1_dst[0],           // target addr (dst)
      TEST_STREAM_SIZE + PAD_SIZE,            // width
      1,                                      // count
      0                                       // stride
   );

  //
  // Setup I/O for Stream1
  //
  DsDescSetGenericFmt1(
      &dsSrc_PathW2GBi_InputStream_2,         // this descriptor
      &dsSrc_PathW2GBi_InputStream_2,         // next descriptor
      DS_DESC_HALT | DS_DESC_DATA_ACCESS_NC, // optoins
      (char*)&test_stream_2_src[0],          // target addr
      TEST_STREAM_SIZE + PAD_SIZE,           // width
      1,                                     // count
      0                                      // stride
  );

  DsDescSetGenericFmt1(
      &dsDst_PathGBo2W_OutputStream_2,         // this descriptor
      &dsDst_PathGBo2W_OutputStream_2,         // next descriptor
      DS_DESC_HALT | DS_DESC_DATA_ACCESS_CA,  // options
      (char*)&test_stream_2_dst[0],           // target addr
      TEST_STREAM_SIZE + PAD_SIZE,            // width
      1,                                      // count
      0                                       // stride
   );

    //
    // Setup getBitsData
    //

    // 15 : jpeg consume 0x00
    // 14 : jpeg dct mode
    // 13 : per-byte bit reversal to GB input
    // 12 : per-byte bit reversal from GB output
    gbCtrl       = 0x3; // disable per-byte bit reversal on in and out
    bufInIndex   = DsGetBufferIndexFromDS_BUFFER(MemIOPath1.buf.id);
    bufOutIndex  = DsGetBufferIndexFromDS_BUFFER(IOMemPath1.buf.id);
    getBitsData1 =  (((gbCtrl & 0xf) << 12) | ((bufInIndex & 0x3f) << 6) | (bufOutIndex & 0x3f));

    gbCtrl       = 0x3; // disable per-byte bit reversal on in and out
    bufInIndex   = DsGetBufferIndexFromDS_BUFFER(MemIOPath2.buf.id);
    bufOutIndex  = DsGetBufferIndexFromDS_BUFFER(IOMemPath2.buf.id);
    getBitsData2 =  (((gbCtrl & 0xf) << 12) | ((bufInIndex & 0x3f) << 6) | (bufOutIndex & 0x3f));

  //
  //  Load the VLx program into CM1 -- note that we have embedded the
  //  getbits control information within the program and not used
  //  the VlxCtrlGetBits() which is broken until we get PIOs to FFU memory
  //  implemented the right way in the casim dcache
  //
  status = VlxLoadBinaryByValue(
      pVlxBin,                                 // the pointer to the binary
      ((pVlxBin->BinaryByteLength + 1) >> 1),  // length to transfer is 16-bit quantities
      VLXLAB_vswap_PCSTART,                    // transfer from the beginning of the binary
      0,                                      // which is the beginning of CM1 (offset 0)
      VLX_LOAD_PIO                            // using the PIOs for the transfer.
  );

  VlMemWrite16((VNC_UINT16*)&pVlxGbConfig1->ds_ctrl,getBitsData1);
  VlMemWrite16((VNC_UINT16*)&pVlxGbConfig2->ds_ctrl,getBitsData2);

  //
  // Write control data to vlx
  //
  swap_unit_size                 =  64; // in bytes

⌨️ 快捷键说明

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