📄 1553_junk_bm-5_bu69080s1.c
字号:
/*******************************************************************
* Function: bu69080s1_cs_GetDeviceTupleInfo *
* *
* Description: Gets a Device tuple from the PCMCIA card and *
* stores info in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: handle - Pass a valid client handle; aquired from *
* link->handle *
* *
* return 0 - Success; *
* !0 - Failure; error codes are defined by Card *
* Services functions *
*******************************************************************/
int bu69080s1_cs_GetDeviceTupleInfo(client_handle_t handle)
{
cisparse_t cisparse;
cistpl_device_t *pdevice = &(cisparse.device);
int nStatus;
if((nStatus = bu69080s1_cs_GetTuple(GetFirstTuple, CISTPL_DEVICE, &cisparse)) == 0)
{
m_aCards[m_bNumberOfCards].CIS.unAccessSpeed = pdevice->dev[0].speed;
m_aCards[m_bNumberOfCards].CIS.unMemorySize = pdevice->dev[0].size;
}
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetConfigTupleInfo *
* *
* Description: Gets a Config tuple from the PCMCIA card and stores*
* info in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: handle - Pass a valid client handle; aquired from *
* link->handle *
* *
* return 0 - Success; *
* !0 - Failure; error codes are defined by Card *
* Services functions *
*******************************************************************/
int bu69080s1_cs_GetConfigTupleInfo(client_handle_t handle)
{
cisparse_t cisparse;
cistpl_config_t *pconfig = &(cisparse.config);
int nStatus;
if((nStatus = bu69080s1_cs_GetTuple(GetFirstTuple, CISTPL_CONFIG, &cisparse)) == 0)
{
m_aCards[m_bNumberOfCards].CIS.unConfigBase = pconfig->base;
m_aCards[m_bNumberOfCards].CIS.unPresent = pconfig->rmask[0];
m_aCards[m_bNumberOfCards].CIS.ucConfigIndex = pconfig->last_idx;
}
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetCFTableTupleInfo *
* *
* Description: Gets a Cftable_entry tuple from the PCMCIA card *
* and stores info in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: handle - Pass a valid client handle; aquired from *
* link->handle *
* *
* return 0 - Success; *
* !0 - Failure; error codes are defined by Card *
* Services functions *
*******************************************************************/
int bu69080s1_cs_GetCFTableTupleInfo(client_handle_t handle)
{
cisparse_t cisparse;
cistpl_cftable_entry_t *pentry = &(cisparse.cftable_entry);
cistpl_io_t *pio = &(pentry->io);
cistpl_irq_t *pirq = &(pentry->irq);
cistpl_mem_t *pmem = &(pentry->mem);
int nIndex;
int nStatus;
if((nStatus = bu69080s1_cs_GetTuple(GetFirstTuple, CISTPL_CFTABLE_ENTRY, &cisparse)) == 0)
{
m_aCards[m_bNumberOfCards].CIS.ucConfigIndex = pentry->index;
m_aCards[m_bNumberOfCards].CIS.io.flags = pio->flags;
m_aCards[m_bNumberOfCards].CIS.io.nwin = pio->nwin;
printk("%s: CIS: IO port windows: %d", MODULE_NAME, pio->nwin);
// Store multiple IO window info
for(nIndex = 0; nIndex < m_aCards[m_bNumberOfCards].CIS.io.nwin; nIndex++)
{
printk(" Base: 0x%04x Len: 0x%04x", pio->win[nIndex].base, pio->win[nIndex].len);
m_aCards[m_bNumberOfCards].CIS.io.win[nIndex].base = pio->win[nIndex].base;
m_aCards[m_bNumberOfCards].CIS.io.win[nIndex].len = pio->win[nIndex].len;
}
m_aCards[m_bNumberOfCards].CIS.irq.IRQInfo1 = pirq->IRQInfo1;
m_aCards[m_bNumberOfCards].CIS.irq.IRQInfo2 = pirq->IRQInfo2;
printk(" Allowed IRQs: ");
if((pirq->IRQInfo1 & IRQ_INFO2_VALID) != 0)
{
for(nIndex = 0; nIndex < 16; nIndex++) // Dislpay allowed IRQs
{
if((pirq->IRQInfo2 & (1 << nIndex)) != 0)
printk("%x", nIndex);
}
}
else
printk("%x", pirq->IRQInfo1); // Display single allowed IRQ (hope its free :)
m_aCards[m_bNumberOfCards].CIS.mem.nwin = pmem->nwin;
printk(" mem windows: %d", m_aCards[m_bNumberOfCards].CIS.mem.nwin);
for(nIndex = 0; nIndex < pmem->nwin; nIndex++) // Store multiple memory window info
{
m_aCards[m_bNumberOfCards].CIS.mem.win[nIndex].len = pmem->win[nIndex].len;
m_aCards[m_bNumberOfCards].CIS.mem.win[nIndex].card_addr = pmem->win[nIndex].card_addr;
printk(" 0x%04x-0x%04x", m_aCards[m_bNumberOfCards].CIS.mem.win[nIndex].card_addr, m_aCards[m_bNumberOfCards].CIS.mem.win[nIndex].card_addr + m_aCards[m_bNumberOfCards].CIS.mem.win[nIndex].len);
};
printk("\n");
}
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetManfidTupleInfo *
* *
* Description: Gets a manfid tuple from the PCMCIA card and *
* stores info in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: handle - Pass a valid client handle; aquired from *
* link->handle *
* *
* return 0 - Success; *
* !0 - Failure; error codes are defined by Card *
* Services functions *
*******************************************************************/
int bu69080s1_cs_GetManfidTupleInfo(client_handle_t handle)
{
cisparse_t cisparse;
int nStatus;
cistpl_manfid_t *pmanfid = &cisparse.manfid;
if((nStatus = bu69080s1_cs_GetTuple(GetFirstTuple, CISTPL_MANFID, &cisparse)) == 0)
{
m_aCards[m_bNumberOfCards].CIS.manfid.manf = pmanfid->manf;
m_aCards[m_bNumberOfCards].CIS.manfid.card = pmanfid->card;
m_aCards[m_bNumberOfCards].wDeviceID = m_aCards[m_bNumberOfCards].CIS.manfid.card;
}
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetCisIO *
* *
* Description: Copies an IO tuple info from the PCMCIA card into *
* in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: pio - Pass an io struct containing CIS data *
* aquired from cisparse.cftable_entry.io *
* *
* return 0 - Success; *
* 1 - Failure; No io windows info was available *
*******************************************************************/
int bu69080s1_cs_GetCisIO(io_req_t *pio)
{
int nStatus;
if(m_aCards[m_bNumberOfCards].CIS.io.nwin > 0) // Copy first io window info if available
{
pio->BasePort1 = m_aCards[m_bNumberOfCards].CIS.io.win[0].base;
pio->NumPorts1 = m_aCards[m_bNumberOfCards].CIS.io.win[0].len;
//Set IO to 8 bit if specified by CIS
if(m_aCards[m_bNumberOfCards].CIS.io.flags & CISTPL_IO_8BIT)
pio->Attributes1 = IO_DATA_PATH_WIDTH_8;
//Set IO to 16 bit if specified by CIS
else if(m_aCards[m_bNumberOfCards].CIS.io.flags & CISTPL_IO_16BIT)
pio->Attributes1 = IO_DATA_PATH_WIDTH_16;
else
pio->Attributes1 = IO_DATA_PATH_WIDTH_AUTO; //Set IO to Auto if not specified
pio->IOAddrLines = m_aCards[m_bNumberOfCards].CIS.io.flags & CISTPL_IO_LINES_MASK;
if(m_aCards[m_bNumberOfCards].CIS.io.nwin > 1) // Copy second io window info if available
{
pio->BasePort2 = m_aCards[m_bNumberOfCards].CIS.io.win[1].base;
pio->NumPorts2 = m_aCards[m_bNumberOfCards].CIS.io.win[1].len;
pio->Attributes2 = pio->Attributes1;
}
// Ignore other io window info, Linux Card Services can't use it anyway :)
nStatus = 0;
}
else
nStatus = 1;
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_configIO *
* *
* Description: Configure device IO using device CIS. IO is only *
* requested, the Card Services call, *
* RequestConfiguration, does the actual config. *
* *
* Parameters: plink - Pass the device link; Call from the *
* bu69080s1_cs_configIO(link) function *
* passing link, same as plink (used p as *
* pointer prefix). *
* *
* return: 0 - Success; Device IO was successfully requested*
* !0 - Failure. Error codes are defined by Card *
* Services functions *
*******************************************************************/
int bu69080s1_cs_configIO(dev_link_t *plink)
{
int nStatus;
plink->io.BasePort1 = 0; //io_req_t
plink->io.NumPorts1 = 0;
plink->io.Attributes1 = 0;
plink->io.BasePort2 = 0;
plink->io.NumPorts2 = 0;
plink->io.Attributes2 = 0;
plink->io.IOAddrLines = 0;
if((nStatus = bu69080s1_cs_GetCisIO(&(plink->io))) == 0)
nStatus = CardServices(RequestIO, plink->handle, &plink->io);
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetCisIRQ *
* *
* Description: Copies an IRQ tuple info from the PCMCIA card into *
* in m_aCards[m_bNumberOfCards].CIS *
* *
* Parameters: pirqreq - Pass an irq struct containing CIS data; *
* aquired from cisparse.cftable_entry.irq *
* *
* return: Void *
*******************************************************************/
void bu69080s1_cs_GetCisIRQ(irq_req_t *pirqreq)
{
pirqreq->IRQInfo1 = m_aCards[m_bNumberOfCards].CIS.irq.IRQInfo1;
pirqreq->IRQInfo2 = m_aCards[m_bNumberOfCards].CIS.irq.IRQInfo2;
}
/*******************************************************************
* Function: bu69080s1_cs_configIRQ *
* *
* Description: Configure device IRQ using device CIS. IRQ is ONLY *
* requested. A Card Services call *
* RequestConfiguration does the actual config *
* *
* Parameters: plink - Pass the device link; Call from the *
* bu69080s1_cs_configIO(link) function *
* passing link, same as plink (used p as *
* pointer prefix). *
* *
* return: 0 - Success; *
* 1 - Failure; no io windows info was available *
*******************************************************************/
int bu69080s1_cs_configIRQ(dev_link_t *plink)
{
irq_req_t *pirqreq = &(plink->irq);
int nStatus;
pirqreq->Attributes = 0; // Initialise IRQ request to not request
pirqreq->AssignedIRQ = 0;
pirqreq->Handler = NULL;
pirqreq->Instance = NULL;
bu69080s1_cs_GetCisIRQ(pirqreq);
if((nStatus = CardServices(RequestIRQ, plink->handle, &plink->irq)) == 0)
{
m_CardIO[m_bNumberOfCards].cIRQRequest = __REQUESTED__;
nStatus = 0;
}
else
{
printk("%s: CIS IRQ request failed, searching for a spare IRQ ", MODULE_NAME);
plink->irq.IRQInfo1 = 1;
do // Search for an IRQ if CIS IRQ failed
{
printk("%d ", plink->irq.IRQInfo1);
if((nStatus = CardServices(RequestIRQ, plink->handle, &plink->irq)) != 0)
plink->irq.IRQInfo1++;
}
while((nStatus != 0) && (plink->irq.IRQInfo1 >= 1) && (plink->irq.IRQInfo1 <= 15 ));
}
return nStatus;
}
/*******************************************************************
* Function: bu69080s1_cs_GetCisWindows *
* *
* Description: Copies
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -