📄 i21555.c
字号:
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((0x80000001) | (downstream_dev->bus << 16) | (downstream_dev->device << 11) |
(downstream_dev->function << 8) | (regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA | (regOffset & 3), data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_PrimaryDoorbellIrqStatus - Read the Primary Interface Doorbell Interrupt Status
*
* This function reads the primary doorbell interrupt status. Each bit of the 16-bit
* return value represents one of the 16 doorbell interrupts. If the status bit is set,
* and the interrupt is not masked, then the corresponding interrupt will drive the
* primary interface's doorbell interrupt. This function may operate on the local (on-board)
* 21555 or an off-board 21555. When operating on the local 21555 set i21555_dev = NULL.
* Otherwise, i21555_dev must point to the bus, device, and function of the 21555 to operate on.
*
*
* RETURNS: An unsigned 16-bit interger that represents the status of the 16 doorbell interrupts.
*
* SEE ALSO:
*/
UINT16 i21555_PrimaryDoorbellIrqStatus(PCI_LOC *i21555_dev)
{
UINT16 status = 0;
UINT32 csrReg = 0;
int old_interface = 0;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
status = PCI_IN_WORD(csrReg + I21555_CSR_PRI_SET_IRQ);
}
if(old_interface) setCurrentPciInterface(old_interface);
return status;
}
/**********************************************************************************************
*
* i21555_PrimaryDoorbellIrqSet - Set one of the Primary Interface Doorbell Interrupts
*
* This function sets one of the 16 primary doorbell interrupt bits. If the interrupt is not
* masked, then the corresponding interrupt will drive the primary interface's doorbell
* interrupt. This function may operate on the local (on-board) 21555 or an off-board 21555.
* When operating on the local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point
* to the bus, device, and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_PrimaryDoorbellIrqSet(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_PRI_SET_IRQ, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_PrimaryDoorbellIrqClear - Clear one of the Primary Interface Doorbell Interrupts
*
* This function clears one of the 16 primary doorbell interrupt bits. This function may
* operate on the local (on-board) 21555 or an off-board 21555. When operating on the
* local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point to the bus, device,
* and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_PrimaryDoorbellIrqClear(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_PRI_CLEAR_IRQ, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_PrimaryDoorbellIrqMask - Mask one of the Primary Interface Doorbell Interrupts
*
* This function masks one of the 16 primary doorbell interrupt bits. This function may
* operate on the local (on-board) 21555 or an off-board 21555. When operating on the
* local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point to the bus, device,
* and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_PrimaryDoorbellIrqMask(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_PRI_SET_IRQ_MASK, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_PrimaryDoorbellIrqUnmask - Unmask one of the Primary Interface Doorbell Interrupts
*
* This function unmasks one of the 16 primary doorbell interrupt bits. This function may
* operate on the local (on-board) 21555 or an off-board 21555. When operating on the
* local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point to the bus, device,
* and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_PrimaryDoorbellIrqUnmask(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_PRI_CLEAR_IRQ_MASK, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_SecondaryDoorbellIrqStatus - Read the Secondary Interface Doorbell Interrupt Status
*
* This function reads the secondary doorbell interrupt status. Each bit of the 16-bit
* return value represents one of the 16 doorbell interrupts. If the status bit is set,
* and the interrupt is not masked, then the corresponding interrupt will drive the
* secondary interface's doorbell interrupt. This function may operate on the local (on-board)
* 21555 or an off-board 21555. When operating on the local 21555 set i21555_dev = NULL.
* Otherwise, i21555_dev must point to the bus, device, and function of the 21555 to operate on.
*
*
* RETURNS: An unsigned 16-bit interger that represents the status of the 16 doorbell interrupts.
*
* SEE ALSO:
*/
UINT16 i21555_SecondaryDoorbellIrqStatus(PCI_LOC *i21555_dev)
{
UINT16 status = 0;
UINT32 csrReg = 0;
int old_interface = 0;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
status = PCI_IN_WORD(csrReg + I21555_CSR_SEC_SET_IRQ);
}
if(old_interface) setCurrentPciInterface(old_interface);
return status;
}
/**********************************************************************************************
*
* i21555_SecondaryDoorbellIrqSet - Set one of the Secondary Interface Doorbell Interrupts
*
* This function sets one of the 16 secondary doorbell interrupt bits. If the interrupt is not
* masked, then the corresponding interrupt will drive the secondary interface's doorbell
* interrupt. This function may operate on the local (on-board) 21555 or an off-board 21555.
* When operating on the local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point
* to the bus, device, and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_SecondaryDoorbellIrqSet(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_SEC_SET_IRQ, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_SecondaryDoorbellIrqClear - Clear one of the Secondary Interface Doorbell Interrupts
*
* This function clears one of the 16 secondary doorbell interrupt bits. This function may
* operate on the local (on-board) 21555 or an off-board 21555. When operating on the
* local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point to the bus, device,
* and function of the 21555 to operate on.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_SecondaryDoorbellIrqClear(PCI_LOC *i21555_dev, int irq_bit)
{
UINT32 csrReg = 0;
UINT16 irqBitMask = 0;
int old_interface = 0;
/* check for valid bit number */
if(irq_bit < 0 || irq_bit > 15) return;
irqBitMask = 1 << irq_bit;
/* if 21555 device not specified, use local device */
if(i21555_dev == NULL)
{
i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
}
/* get address of CSR registers */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CSR_IO_BAR, &csrReg);
csrReg &= PCI_IOBASE_MASK;
if(csrReg)
{
PCI_OUT_WORD(csrReg + I21555_CSR_SEC_CLEAR_IRQ, irqBitMask);
}
if(old_interface) setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_SecondaryDoorbellIrqMask - Mask one of the Secondary Interface Doorbell Interrupts
*
* This function masks one of the 16 secondary doorbell interrupt bits. This function may
* operate on the local (on-board) 21555 or an off-board 21555. When operating on the
* local 21555 set i21555_dev = NULL. Otherwise, i21555_dev must point to the bus, device,
* and function of the 21555 to operate on.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -