对已知的地址进行数据读取,需要用到下面读取函数:
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;
}