private void TraceLog(BOOL bIsRead, wdc_err status) { string sData = ""; string sInfo = ""; if (status == wdc_err.WD_STATUS_SUCCESS) { sData = (bIsRead? "R: " : "W: ") + diag_lib.DisplayHexBuffer(m_obj, m_dwBytes, m_mode); sInfo = (bIsRead ? " from " : " to ") + "offset " + m_dwOffset.ToString("X") + " on BAR " + m_dwBar.ToString() + "(" + m_device.ToString(false) + ")"; Log.TraceLog("AddrSpaceTransferForm: " + sData + sInfo); } else { sData = "failed to " + (bIsRead? "read from" : "write to") + " offset " + m_dwOffset.ToString("X") + " on BAR " + m_dwBar.ToString() + "status 0x" + status.ToString("X") + ": " + utils.Stat2Str((DWORD)status); sInfo = "(" + m_device.ToString(false) + ")"; Log.ErrLog("AddrSpaceTransferForm: " + sData + sInfo); } txtData.Text += sData + Environment.NewLine; }
/* Close handle to a PCI_0228 device */ private BOOL DeviceClose(int iSelectedIndex) { PCI_0228_Device device = pciDevList.Get(iSelectedIndex); BOOL bStatus = false; if (device.Handle != IntPtr.Zero && !(bStatus = device.Close())) { Log.ErrLog("PCI_0228_diag.DeviceClose: Failed closing PCI_0228 " + "device (" + device.ToString(false) + ")"); } else { device.Handle = IntPtr.Zero; } return(bStatus); }
/* Open a handle to a device */ private bool DeviceOpen(int iSelectedIndex) { DWORD dwStatus; PCI_0228_Device device = pciDevList.Get(iSelectedIndex); /* Open a handle to the device */ dwStatus = device.Open(); if (dwStatus != (DWORD)wdc_err.WD_STATUS_SUCCESS) { Log.ErrLog("PCI_0228_diag.DeviceOpen: Failed opening a " + "handle to the device (" + device.ToString(false) + ")"); return(false); } Log.TraceLog("PCI_0228_diag.DeviceOpen: The device was successfully open." + "You can now activate the device through the enabled menu above"); return(true); }
private void PCI_0228_EventHandler(ref WD_EVENT wdEvent, PCI_0228_Device dev) { string sAction; switch ((WD_EVENT_ACTION)wdEvent.dwAction) { case WD_EVENT_ACTION.WD_INSERT: sAction = "WD_INSERT"; break; case WD_EVENT_ACTION.WD_REMOVE: sAction = "WD_REMOVE"; break; case WD_EVENT_ACTION.WD_POWER_CHANGED_D0: sAction = "WD_POWER_CHANGED_D0"; break; case WD_EVENT_ACTION.WD_POWER_CHANGED_D1: sAction = "WD_POWER_CHANGED_D1"; break; case WD_EVENT_ACTION.WD_POWER_CHANGED_D2: sAction = "WD_POWER_CHANGED_D2"; break; case WD_EVENT_ACTION.WD_POWER_CHANGED_D3: sAction = "WD_POWER_CHANGED_D3"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_WORKING: sAction = "WD_POWER_SYSTEM_WORKING"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING1: sAction = "WD_POWER_SYSTEM_SLEEPING1"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING2: sAction = "WD_POWER_SYSTEM_SLEEPING2"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING3: sAction = "WD_POWER_SYSTEM_SLEEPING3"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_HIBERNATE: sAction = "WD_POWER_SYSTEM_HIBERNATE"; break; case WD_EVENT_ACTION.WD_POWER_SYSTEM_SHUTDOWN: sAction = "WD_POWER_SYSTEM_SHUTDOWN"; break; default: sAction = wdEvent.dwAction.ToString("X"); break; } Log.TraceLog("Received event notification of type " + sAction + " on " + dev.ToString(false)); }
private void PCI_0228_IntHandler(PCI_0228_Device dev) { Log.TraceLog("interrupt for device {" + dev.ToString(false) + "} received!"); }
private void ReadAllRegs() { WDC_REG reg = m_regs[0]; DWORD dwStatus = (DWORD)wdc_err.WD_STATUS_SUCCESS; TraceLog("displaying all registers (" + m_device.ToString(false) + ")", (wdc_err)dwStatus); for (int i = 0; i < m_regs.GetLength(0); ++i) { reg = m_regs[i]; if (!IsLegalDirection(i)) { txtData.Text = "register " + reg.sName + "is write-only" + Environment.NewLine; } else { switch (reg.dwSize) { case wdc_lib_consts.WDC_SIZE_8: { dwStatus = (m_regType == ACTION_TYPE.CFG) ? wdc_lib_decl.WDC_PciReadCfg8(m_device.Handle, reg.dwOffset, ref m_bData) : wdc_lib_decl.WDC_ReadAddr8(m_device.Handle, reg.dwAddrSpace, reg.dwOffset, ref m_bData); break; } case wdc_lib_consts.WDC_SIZE_16: { dwStatus = (m_regType == ACTION_TYPE.CFG) ? wdc_lib_decl.WDC_PciReadCfg16(m_device.Handle, reg.dwOffset, ref m_wData) : wdc_lib_decl.WDC_ReadAddr16(m_device.Handle, reg.dwAddrSpace, reg.dwOffset, ref m_wData); break; } case wdc_lib_consts.WDC_SIZE_32: { dwStatus = (m_regType == ACTION_TYPE.CFG) ? wdc_lib_decl.WDC_PciReadCfg32(m_device.Handle, reg.dwOffset, ref m_u32Data) : wdc_lib_decl.WDC_ReadAddr32(m_device.Handle, reg.dwAddrSpace, reg.dwOffset, ref m_u32Data); break; } case wdc_lib_consts.WDC_SIZE_64: { dwStatus = (m_regType == ACTION_TYPE.CFG) ? wdc_lib_decl.WDC_PciReadCfg64(m_device.Handle, reg.dwOffset, ref m_u64Data) : wdc_lib_decl.WDC_ReadAddr64(m_device.Handle, reg.dwAddrSpace, reg.dwOffset, ref m_u64Data); break; } } TraceLog((((DWORD)wdc_err.WD_STATUS_SUCCESS == dwStatus)? "read from register " + reg.sName + " 0x" + ((reg.dwSize == wdc_lib_consts.WDC_SIZE_8)? m_bData.ToString("X2"): ((reg.dwSize == wdc_lib_consts.WDC_SIZE_16)? m_wData.ToString("X4") : ((reg.dwSize == wdc_lib_consts.WDC_SIZE_32)? m_u32Data.ToString("X8") : m_u64Data.ToString("X16")))) : "failed to complete the transaction on register " + reg.sName), (wdc_err)dwStatus); } } }