📄 apifunctions.c
字号:
DEVICE_EXTENSION *pdx,
U16 offset,
U32 *pValue
)
{
S16 VpdRetries;
S16 VpdPollCount;
U32 RegisterValue;
// Check for unaligned offset
if (offset & 0x3)
{
*pValue = (U32)-1;
return ApiInvalidOffset;
}
// Prepare VPD command
RegisterValue = ((U32)offset << 16) | 0x3;
VpdRetries = VPD_COMMAND_MAX_RETRIES;
do
{
/**************************************
* This loop will continue until the
* VPD reports success or until we reach
* the maximum number of retries
**************************************/
// Send VPD Command
PLX_PCI_REG_WRITE(
pdx,
PCI9030_VPD_CAP_ID,
RegisterValue
);
// Poll until VPD operation has completed
VpdPollCount = VPD_STATUS_MAX_POLL;
do
{
// Delay for a bit for VPD operation
Plx_sleep(VPD_STATUS_POLL_DELAY);
// Get VPD Status
PLX_PCI_REG_READ(
pdx,
PCI9030_VPD_CAP_ID,
&RegisterValue
);
// Check for command completion
if (RegisterValue & (1 << 31))
{
/*******************************************
* The VPD successfully read the EEPROM. Get
* the value & return a status of SUCCESS.
*******************************************/
// Get the VPD Data result
PLX_PCI_REG_READ(
pdx,
PCI9030_VPD_DATA,
&RegisterValue
);
*pValue = RegisterValue;
return ApiSuccess;
}
}
while (VpdPollCount--);
}
while (VpdRetries--);
/******************************************
* VPD access failed if we reach this
* point - return an ERROR status
*******************************************/
DebugPrintf(("ERROR - PlxPciVpdRead() failed, VPD timeout\n"));
*pValue = (U32)-1;
return ApiFailed;
}
/******************************************************************************
*
* Function : PlxPciVpdWrite
*
* Description: Write to the Vital Product Data
*
******************************************************************************/
RETURN_CODE
PlxPciVpdWrite(
DEVICE_EXTENSION *pdx,
U16 offset,
U32 VpdData
)
{
S16 VpdRetries;
S16 VpdPollCount;
U32 RegisterValue;
// Check for unaligned offset
if (offset & 0x3)
return ApiInvalidOffset;
// Put write value into VPD Data register
PLX_PCI_REG_WRITE(
pdx,
PCI9030_VPD_DATA,
VpdData
);
// Prepare VPD command
RegisterValue = (1 << 31) | ((U32)offset << 16) | 0x3;
VpdRetries = VPD_COMMAND_MAX_RETRIES;
do
{
/**************************************
* This loop will continue until the
* VPD reports success or until we reach
* the maximum number of retries
**************************************/
// Send VPD command
PLX_PCI_REG_WRITE(
pdx,
PCI9030_VPD_CAP_ID,
RegisterValue
);
// Poll until VPD operation has completed
VpdPollCount = VPD_STATUS_MAX_POLL;
do
{
// Delay for a bit for VPD operation
Plx_sleep(VPD_STATUS_POLL_DELAY);
// Get VPD Status
PLX_PCI_REG_READ(
pdx,
PCI9030_VPD_CAP_ID,
&RegisterValue
);
// Check for command completion
if ((RegisterValue & (1 << 31)) == 0)
{
/*******************************************
* The VPD successfully wrote to the EEPROM.
*******************************************/
return ApiSuccess;
}
}
while (VpdPollCount--);
}
while (VpdRetries--);
/******************************************
* VPD access failed if we reach this
* point - return an ERROR status
*******************************************/
DebugPrintf(("ERROR - PlxPciVpdWrite() failed, VPD timeout\n"));
return ApiFailed;
}
/******************************************************************************
*
* Function : PlxEepromPresent
*
* Description: Determine if a programmed EEPROM is present on the device
*
******************************************************************************/
RETURN_CODE
PlxEepromPresent(
DEVICE_EXTENSION *pdx,
BOOLEAN *pFlag
)
{
U32 RegisterValue;
// Get EEPROM status register
RegisterValue =
PLX_REG_READ(
pdx,
PCI9030_EEPROM_CTRL
);
if (RegisterValue & (1 << 28))
{
*pFlag = TRUE;
}
else
{
*pFlag = FALSE;
}
return ApiSuccess;
}
/******************************************************************************
*
* Function : PlxEepromReadByOffset
*
* Description: Read a value from the EEPROM at a specified offset
*
******************************************************************************/
RETURN_CODE
PlxEepromReadByOffset(
DEVICE_EXTENSION *pdx,
U16 offset,
U32 *pValue
)
{
// Verify the offset
if ((offset & 0x3) || (offset > 0x200))
{
DebugPrintf(("ERROR - Invalid EEPROM offset\n"));
return ApiInvalidOffset;
}
// Read EEPROM
Pci9000_EepromReadByOffset(
pdx,
Eeprom93CS56,
offset,
pValue
);
DebugPrintf((
"EEPROM Offset %02X = %08X\n",
offset,
*pValue
));
return ApiSuccess;
}
/******************************************************************************
*
* Function : PlxEepromWriteByOffset
*
* Description: Write a 32-bit value to the EEPROM at a specified offset
*
******************************************************************************/
RETURN_CODE
PlxEepromWriteByOffset(
DEVICE_EXTENSION *pdx,
U16 offset,
U32 value
)
{
U32 RegisterSave;
// Verify the offset
if ((offset & 0x3) || (offset > 0x200))
{
DebugPrintf(("ERROR - Invalid EEPROM offset\n"));
return ApiInvalidOffset;
}
// Unprotect the EEPROM for write access
RegisterSave =
PLX_REG_READ(
pdx,
PCI9030_INT_CTRL_STAT
);
PLX_REG_WRITE(
pdx,
PCI9030_INT_CTRL_STAT,
RegisterSave & ~(0xFF << 16)
);
// Write to EEPROM
Pci9000_EepromWriteByOffset(
pdx,
Eeprom93CS56,
offset,
value
);
// Restore EEPROM Write-Protected Address Boundary
PLX_REG_WRITE(
pdx,
PCI9030_INT_CTRL_STAT,
RegisterSave
);
DebugPrintf((
"Wrote %08X to EEPROM Offset %02X\n",
value,
offset
));
return ApiSuccess;
}
/******************************************************************************
*
* Function : PlxRegisterMailboxRead
*
* Description: Reads a valid Mailbox register from the PLX device
*
******************************************************************************/
RETURN_CODE
PlxRegisterMailboxRead(
DEVICE_EXTENSION *pdx,
MAILBOX_ID MailboxId,
U32 *pValue
)
{
*pValue = (U32)-1;
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxRegisterMailboxWrite
*
* Description: Write to one of the PLX device's Mailbox registers
*
******************************************************************************/
RETURN_CODE
PlxRegisterMailboxWrite(
DEVICE_EXTENSION *pdx,
MAILBOX_ID MailboxId,
U32 value
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxRegisterDoorbellRead
*
* Description: Returns the last doorbell interrupt value
*
******************************************************************************/
RETURN_CODE
PlxRegisterDoorbellRead(
DEVICE_EXTENSION *pdx,
U32 *pValue
)
{
*pValue = (U32)-1;
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxRegisterDoorbellWrite
*
* Description: Sets the local Doorbell Register
*
******************************************************************************/
RETURN_CODE
PlxRegisterDoorbellWrite(
DEVICE_EXTENSION *pdx,
U32 value
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxMuInboundPortRead
*
* Description: Read the Inbound messaging port of a PLX device
*
******************************************************************************/
RETURN_CODE
PlxMuInboundPortRead(
DEVICE_EXTENSION *pdx,
U32 *pFrame
)
{
*pFrame = (U32)-1;
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxMuInboundPortWrite
*
* Description: Write a posted message frame to the inbound port
*
******************************************************************************/
RETURN_CODE
PlxMuInboundPortWrite(
DEVICE_EXTENSION *pdx,
U32 Frame
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxMuOutboundPortRead
*
* Description: Reads the posted message frame from the outbound port
*
******************************************************************************/
RETURN_CODE
PlxMuOutboundPortRead(
DEVICE_EXTENSION *pdx,
U32 *pFrame
)
{
*pFrame = (U32)-1;
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxMuOutboundPortWrite
*
* Description: Writes to the outbound port with a free message frame
*
******************************************************************************/
RETURN_CODE
PlxMuOutboundPortWrite(
DEVICE_EXTENSION *pdx,
U32 Frame
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaControl
*
* Description: Control the DMA engine
*
******************************************************************************/
RETURN_CODE
PlxDmaControl(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
DMA_COMMAND command
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaStatus
*
* Description: Get status of a DMA channel
*
******************************************************************************/
RETURN_CODE
PlxDmaStatus(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaBlockChannelOpen
*
* Description: Requests usage of a device's DMA channel
*
******************************************************************************/
RETURN_CODE
PlxDmaBlockChannelOpen(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
DMA_CHANNEL_DESC *pDesc,
VOID *pOwner
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaBlockTransfer
*
* Description: Performs DMA block transfer
*
******************************************************************************/
RETURN_CODE
PlxDmaBlockTransfer(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
DMA_TRANSFER_ELEMENT *pDmaData
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaBlockChannelClose
*
* Description: Close a previously opened channel
*
******************************************************************************/
RETURN_CODE
PlxDmaBlockChannelClose(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
BOOLEAN bCheckInProgress
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaSglChannelOpen
*
* Description: Open a DMA channel for SGL mode
*
******************************************************************************/
RETURN_CODE
PlxDmaSglChannelOpen(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
DMA_CHANNEL_DESC *pDesc,
VOID *pOwner
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaSglTransfer
*
* Description: Performs a DMA SGL transfer
*
******************************************************************************/
RETURN_CODE
PlxDmaSglTransfer(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
DMA_TRANSFER_ELEMENT *pDmaData
)
{
return ApiUnsupportedFunction;
}
/******************************************************************************
*
* Function : PlxDmaSglChannelClose
*
* Description: Close a previously opened channel
*
******************************************************************************/
RETURN_CODE
PlxDmaSglChannelClose(
DEVICE_EXTENSION *pdx,
DMA_CHANNEL channel,
BOOLEAN bCheckInProgress
)
{
return ApiUnsupportedFunction;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -