按地址读取数据

对已知的地址进行数据读取,需要用到下面读取函数:

UInt32 wdc_lib_decl.WDC_ReadAddr8(WDC_DEVICE_HANDLE hDev, UInt32 dwAddrSpace, uint dwOffset, ref byte val)   //1 byte
UInt32 wdc_lib_decl.WDC_ReadAddr16(WDC_DEVICE_HANDLE hDev, UInt32 dwAddrSpace, uint dwOffset, ref ushort val)//2 bytes
UInt32 wdc_lib_decl.WDC_ReadAddr32(WDC_DEVICE_HANDLE hDev, UInt32 dwAddrSpace, uint dwOffset, ref uint val)  //3 bytes
UInt32 wdc_lib_decl.WDC_ReadAddr64(WDC_DEVICE_HANDLE hDev, UInt32 dwAddrSpace, uint dwOffset, ref ulong val) //4 bytes

Example:

<pre name="code" class="csharp">
private WDC_ADDR_MODE m_mode = WDC_ADDR_MODE.WDC_MODE_8;
private byte[] m_bData = new byte[1];//result
private WDC_ADDR_MODE m_mode = WDC_ADDR_MODE.WDC_MODE_16;
private byte[] m_wData = new byte[2];//result
private WDC_ADDR_MODE m_mode = WDC_ADDR_MODE.WDC_MODE_32;
private byte[] m_u32Data = new byte[4];//result
private WDC_ADDR_MODE m_mode = WDC_ADDR_MODE.WDC_MODE_64;
private byte[] m_u64Data = new byte[8];//result

private UInt32 m_dwOffset = 0x00;
private UInt32 m_dwBar = (UInt32)cmboBar.SelectedIndex;//PCI BAR

switch (m_mode)
{
    case WDC_ADDR_MODE.WDC_MODE_8:
        dwStatus = wdc_lib_decl.WDC_ReadAddr8(device.Handle, m_dwBar, m_dwOffset, ref m_bData[0]);
        break;
    case WDC_ADDR_MODE.WDC_MODE_16:
        dwStatus = wdc_lib_decl.WDC_ReadAddr16(device.Handle, m_dwBar, m_dwOffset, ref m_wData[0]);
        break;
    case WDC_ADDR_MODE.WDC_MODE_32:
        dwStatus = wdc_lib_decl.WDC_ReadAddr32(device.Handle, m_dwBar, m_dwOffset, ref m_u32Data[0]);
        break;
    case WDC_ADDR_MODE.WDC_MODE_64:
        dwStatus =dc_lib_decl.WDC_ReadAddr64(device.Handle, m_dwBar, m_dwOffset, ref m_u64Data[0]);
        break;
}

大量数据的读取,要用到

 
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"></span><pre name="code" class="csharp">
UInt32 DLLCALLCONV WDC_ReadAddrBlock(
    WDC_DEVICE_HANDLE hDev,
    UInt32 dwAddrSpace,
    KPTR dwOffset,
    UInt32 dwBytes,
    PVOID pData,//output data pointer; could be array of byte,UInt16,UInt32,UInt64
    WDC_ADDR_MODE mode,
    WDC_ADDR_RW_OPTIONS options);



Example:

private byte[] m_bData;
private UInt16[] m_wData;
private UInt32[] m_u32Data;
private UInt64[] m_u64Data;	
UInt32 dwFloorBytes = ((UInt32)(m_dwBytes / (UInt32)m_mode)) *(UInt32)m_mode;//number of bytes to be read
private bool m_bAutoInc = true;//Auto Increase
WDC_ADDR_RW_OPTIONS dwOptions = (m_bAutoInc ?WDC_ADDR_RW_OPTIONS.WDC_ADDR_RW_DEFAULT : WDC_ADDR_RW_OPTIONS.WDC_ADDR_RW_NO_AUTOINC);
switch (m_mode)
{
    case WDC_ADDR_MODE.WDC_MODE_8:
        dwStatus = wdc_lib_decl.WDC_ReadAddrBlock(device.Handle, m_dwBar, m_dwOffset, dwFloorBytes, m_bData, m_mode, dwOptions);
        break;
    case WDC_ADDR_MODE.WDC_MODE_16:
        dwStatus = wdc_lib_decl.WDC_ReadAddrBlock(device.Handle, m_dwBar, m_dwOffset, dwFloorBytes, m_wData, m_mode, dwOptions);
        break;

    case WDC_ADDR_MODE.WDC_MODE_32:
        dwStatus = wdc_lib_decl.WDC_ReadAddrBlock(device.Handle, m_dwBar, m_dwOffset, dwFloorBytes, m_u32Data, m_mode, dwOptions);
        break;

    case WDC_ADDR_MODE.WDC_MODE_64:
        dwStatus = wdc_lib_decl.WDC_ReadAddrBlock(device.Handle, m_dwBar, m_dwOffset, dwFloorBytes, m_u64Data, m_mode, dwOptions);
        break;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值