本文整理汇总了C++中pcmcia_get_first_tuple函数的典型用法代码示例。如果您正苦于以下问题:C++ pcmcia_get_first_tuple函数的具体用法?C++ pcmcia_get_first_tuple怎么用?C++ pcmcia_get_first_tuple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pcmcia_get_first_tuple函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: first_tuple
static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
cisparse_t *parse)
{
int i = pcmcia_get_first_tuple(handle, tuple);
if (i != CS_SUCCESS) return i;
return get_tuple(handle, tuple, parse);
}
示例2: nsp_cs_config
static void nsp_cs_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
cs_failed:
return;
}
示例3: first_tuple
static int first_tuple(client_handle_t handle, tuple_t *tuple,
cisparse_t *parse)
{
int i = pcmcia_get_first_tuple(handle, tuple);
if (i != CS_SUCCESS) return i;
return get_tuple(handle, tuple, parse);
}
示例4: first_tuple
static int first_tuple(struct pcmcia_device * handle, tuple_t *tuple,
cisparse_t *parse)
{
int i;
i = pcmcia_get_first_tuple(handle, tuple);
if (i != 0) return i;
i = pcmcia_get_tuple_data(handle, tuple);
if (i != 0) return i;
return PCMCIA_PARSE_TUPLE(tuple, parse);
}
示例5: first_tuple
static int
first_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
{
int i;
i = pcmcia_get_first_tuple(handle, tuple);
if (i != CS_SUCCESS)
return CS_NO_MORE_ITEMS;
i = pcmcia_get_tuple_data(handle, tuple);
if (i != CS_SUCCESS)
return i;
return pcmcia_parse_tuple(handle, tuple, parse);
}
示例6: pdacf_config
static void pdacf_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
struct snd_pdacf *pdacf = link->priv;
tuple_t tuple;
cisparse_t *parse = NULL;
config_info_t conf;
u_short buf[32];
int last_fn, last_ret;
snd_printdd(KERN_DEBUG "pdacf_config called\n");
parse = kmalloc(sizeof(*parse), GFP_KERNEL);
if (! parse) {
snd_printk(KERN_ERR "pdacf_config: cannot allocate\n");
return;
}
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
tuple.Attributes = 0;
tuple.TupleData = (cisdata_t *)buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
tuple.DesiredTuple = CISTPL_CONFIG;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse));
link->conf.ConfigBase = parse->config.base;
link->conf.ConfigIndex = 0x5;
kfree(parse);
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
link->conf.Vcc = conf.Vcc;
/* Configure card */
link->state |= DEV_CONFIG;
CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
goto failed;
link->dev = &pdacf->node;
link->state &= ~DEV_CONFIG_PENDING;
return;
cs_failed:
cs_error(link->handle, last_fn, last_ret);
failed:
pcmcia_release_configuration(link->handle);
pcmcia_release_io(link->handle, &link->io);
pcmcia_release_irq(link->handle, &link->irq);
}
示例7: pcmcia_loop_config
/**
* pcmcia_loop_config() - loop over configuration options
* @p_dev: the struct pcmcia_device which we need to loop for.
* @conf_check: function to call for each configuration option.
* It gets passed the struct pcmcia_device, the CIS data
* describing the configuration option, and private data
* being passed to pcmcia_loop_config()
* @priv_data: private data to be passed to the conf_check function.
*
* pcmcia_loop_config() loops over all configuration options, and calls
* the driver-specific conf_check() for each one, checking whether
* it is a valid one. Returns 0 on success or errorcode otherwise.
*/
int pcmcia_loop_config(struct pcmcia_device *p_dev,
int (*conf_check) (struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data),
void *priv_data)
{
struct pcmcia_cfg_mem *cfg_mem;
tuple_t *tuple;
int ret;
unsigned int vcc;
cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL);
if (cfg_mem == NULL)
return -ENOMEM;
/* get the current Vcc setting */
vcc = p_dev->socket->socket.Vcc;
tuple = &cfg_mem->tuple;
tuple->TupleData = cfg_mem->buf;
tuple->TupleDataMax = 255;
tuple->TupleOffset = 0;
tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
tuple->Attributes = 0;
ret = pcmcia_get_first_tuple(p_dev, tuple);
while (!ret) {
cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry;
if (pcmcia_get_tuple_data(p_dev, tuple))
goto next_entry;
if (pcmcia_parse_tuple(tuple, &cfg_mem->parse))
goto next_entry;
/* default values */
p_dev->conf.ConfigIndex = cfg->index;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
cfg_mem->dflt = *cfg;
ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data);
if (!ret)
break;
next_entry:
ret = pcmcia_get_next_tuple(p_dev, tuple);
}
return ret;
}
示例8: pdacf_config
static int pdacf_config(struct pcmcia_device *link)
{
struct snd_pdacf *pdacf = link->priv;
tuple_t tuple;
cisparse_t *parse = NULL;
u_short buf[32];
int last_fn, last_ret;
snd_printdd(KERN_DEBUG "pdacf_config called\n");
parse = kmalloc(sizeof(*parse), GFP_KERNEL);
if (! parse) {
snd_printk(KERN_ERR "pdacf_config: cannot allocate\n");
return -ENOMEM;
}
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
tuple.Attributes = 0;
tuple.TupleData = (cisdata_t *)buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
tuple.DesiredTuple = CISTPL_CONFIG;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
link->conf.ConfigBase = parse->config.base;
link->conf.ConfigIndex = 0x5;
kfree(parse);
CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
goto failed;
link->dev_node = &pdacf->node;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
pcmcia_disable_device(link);
return -ENODEV;
}
示例9: nmclan_config
static int nmclan_config(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
mace_private *lp = netdev_priv(dev);
tuple_t tuple;
u_char buf[64];
int i, last_ret, last_fn;
kio_addr_t ioaddr;
DEBUG(0, "nmclan_config(0x%p)\n", link);
CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
dev->irq = link->irq.AssignedIRQ;
dev->base_addr = link->io.BasePort1;
ioaddr = dev->base_addr;
/* Read the ethernet address from the CIS. */
tuple.DesiredTuple = 0x80 /* CISTPL_CFTABLE_ENTRY_MISC */;
tuple.TupleData = buf;
tuple.TupleDataMax = 64;
tuple.TupleOffset = 0;
tuple.Attributes = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
/* Verify configuration by reading the MACE ID. */
{
char sig[2];
sig[0] = mace_read(lp, ioaddr, MACE_CHIPIDL);
sig[1] = mace_read(lp, ioaddr, MACE_CHIPIDH);
if ((sig[0] == 0x40) && ((sig[1] & 0x0F) == 0x09)) {
DEBUG(0, "nmclan_cs configured: mace id=%x %x\n",
sig[0], sig[1]);
} else {
printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should"
" be 0x40 0x?9\n", sig[0], sig[1]);
return -ENODEV;
}
}
if(mace_init(lp, ioaddr, dev->dev_addr) == -1)
goto failed;
/* The if_port symbol can be set when the module is loaded */
if (if_port <= 2)
dev->if_port = if_port;
else
printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n");
link->dev_node = &lp->node;
SET_NETDEV_DEV(dev, &handle_to_dev(link));
i = register_netdev(dev);
if (i != 0) {
printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n");
link->dev_node = NULL;
goto failed;
}
strcpy(lp->node.dev_name, dev->name);
printk(KERN_INFO "%s: nmclan: port %#3lx, irq %d, %s port, hw_addr ",
dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]);
for (i = 0; i < 6; i++)
printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
nmclan_release(link);
return -ENODEV;
} /* nmclan_config */
示例10: prism2sta_config
void prism2sta_config(dev_link_t *link)
{
client_handle_t handle;
wlandevice_t *wlandev;
hfa384x_t *hw;
int last_fn;
int last_ret;
tuple_t tuple;
cisparse_t parse;
config_info_t socketconf;
UINT8 buf[64];
int minVcc = 0;
int maxVcc = 0;
cistpl_cftable_entry_t dflt = { 0 };
DBFENTER;
handle = link->handle;
wlandev = (wlandevice_t*)link->priv;
hw = wlandev->priv;
/* Collect the config register info */
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
/* Configure card */
link->state |= DEV_CONFIG;
/* Acquire the current socket config (need Vcc setting) */
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &socketconf));
/* Loop through the config table entries until we find one that works */
/* Assumes a complete and valid CIS */
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
CFG_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
CFG_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
if (cfg->index == 0) goto next_entry;
link->conf.ConfigIndex = cfg->index;
/* Lets print out the Vcc that the controller+pcmcia-cs set
* for us, cause that's what we're going to use.
*/
WLAN_LOG_DEBUG(1,"Initial Vcc=%d/10v\n", socketconf.Vcc);
if (prism2_ignorevcc) {
link->conf.Vcc = socketconf.Vcc;
goto skipvcc;
}
/* Use power settings for Vcc and Vpp if present */
/* Note that the CIS values need to be rescaled */
if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
WLAN_LOG_DEBUG(1, "Vcc obtained from curtupl.VNOM\n");
minVcc = maxVcc =
cfg->vcc.param[CISTPL_POWER_VNOM]/10000;
} else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
WLAN_LOG_DEBUG(1, "Vcc set from dflt.VNOM\n");
minVcc = maxVcc =
dflt.vcc.param[CISTPL_POWER_VNOM]/10000;
} else if ((cfg->vcc.present & (1<<CISTPL_POWER_VMAX)) &&
(cfg->vcc.present & (1<<CISTPL_POWER_VMIN)) ) {
WLAN_LOG_DEBUG(1, "Vcc set from curtupl(VMIN,VMAX)\n"); minVcc = cfg->vcc.param[CISTPL_POWER_VMIN]/10000;
maxVcc = cfg->vcc.param[CISTPL_POWER_VMAX]/10000;
} else if ((dflt.vcc.present & (1<<CISTPL_POWER_VMAX)) &&
(dflt.vcc.present & (1<<CISTPL_POWER_VMIN)) ) {
WLAN_LOG_DEBUG(1, "Vcc set from dflt(VMIN,VMAX)\n");
minVcc = dflt.vcc.param[CISTPL_POWER_VMIN]/10000;
maxVcc = dflt.vcc.param[CISTPL_POWER_VMAX]/10000;
}
if ( socketconf.Vcc >= minVcc && socketconf.Vcc <= maxVcc) {
link->conf.Vcc = socketconf.Vcc;
} else {
/* [MSM]: Note that I've given up trying to change
* the Vcc if a change is indicated. It seems the
* system&socketcontroller&card vendors can't seem
* to get it right, so I'm tired of trying to hack
* my way around it. pcmcia-cs does its best using
* the voltage sense pins but sometimes the controller
* lies. Then, even if we have a good read on the VS
* pins, some system designs will silently ignore our
* requests to set the voltage. Additionally, some
* vendors have 3.3v indicated on their sense pins,
* but 5v specified in the CIS or vice-versa. I've
* had it. My only recommendation is "let the buyer
* beware". Your system might supply 5v to a 3v card
* (possibly causing damage) or a 3v capable system
* might supply 5v to a 3v capable card (wasting
//.........这里部分代码省略.........
示例11: prism2_cs_probe
static int prism2_cs_probe(struct pcmcia_device *pdev)
{
int rval = 0;
struct wlandevice *wlandev = NULL;
hfa384x_t *hw = NULL;
config_info_t socketconf;
cisparse_t *parse = NULL;
tuple_t tuple;
uint8_t buf[64];
int last_fn, last_ret;
cistpl_cftable_entry_t dflt = { 0 };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
dev_link_t *link;
#endif
DBFENTER;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
/* Set up interrupt type */
pdev->conf.IntType = INT_MEMORY_AND_IO;
#else
link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
if (link == NULL)
return -ENOMEM;
memset(link, 0, sizeof(dev_link_t));
link->conf.Vcc = 33;
link->conf.IntType = INT_MEMORY_AND_IO;
link->handle = pdev;
pdev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
#endif
// VCC crap?
parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
wlandev = create_wlan();
if (!wlandev || !parse) {
WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
rval = -EIO;
goto failed;
}
hw = wlandev->priv;
if ( wlan_setup(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);
rval = -EIO;
goto failed;
}
/* Initialize the hw struct for now */
hfa384x_create(hw, 0, 0, NULL);
hw->wlandev = wlandev;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
hw->pdev = pdev;
pdev->priv = wlandev;
#else
hw->link = link;
link->priv = wlandev;
#endif
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, parse));
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
pdev->conf.ConfigBase = parse->config.base;
pdev->conf.Present = parse->config.rmask[0];
#else
link->conf.ConfigBase = parse->config.base;
link->conf.Present = parse->config.rmask[0];
link->conf.Vcc = socketconf.Vcc;
#endif
CS_CHECK(GetConfigurationInfo,
pcmcia_get_configuration_info(pdev, &socketconf));
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple));
for (;;) {
cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
CFG_CHECK(GetTupleData,
pcmcia_get_tuple_data(pdev, &tuple));
CFG_CHECK(ParseTuple,
pcmcia_parse_tuple(pdev, &tuple, parse));
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
dflt = *cfg;
if (cfg->index == 0)
goto next_entry;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)
//.........这里部分代码省略.........
示例12: ds_ioctl
static int ds_ioctl(struct inode * inode, struct file * file,
u_int cmd, u_long arg)
{
socket_t i = minor(inode->i_rdev);
socket_info_t *s;
u_int size;
int ret, err;
ds_ioctl_arg_t buf;
DEBUG(2, "ds_ioctl(socket %d, %#x, %#lx)\n", i, cmd, arg);
if ((i >= sockets) || (sockets == 0))
return -ENODEV;
s = &socket_table[i];
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL;
/* Permission check */
if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN))
return -EPERM;
if (cmd & IOC_IN) {
err = verify_area(VERIFY_READ, (char *)arg, size);
if (err) {
DEBUG(3, "ds_ioctl(): verify_read = %d\n", err);
return err;
}
}
if (cmd & IOC_OUT) {
err = verify_area(VERIFY_WRITE, (char *)arg, size);
if (err) {
DEBUG(3, "ds_ioctl(): verify_write = %d\n", err);
return err;
}
}
err = ret = 0;
if (cmd & IOC_IN) copy_from_user((char *)&buf, (char *)arg, size);
switch (cmd) {
case DS_ADJUST_RESOURCE_INFO:
ret = pcmcia_adjust_resource_info(s->handle, &buf.adjust);
break;
case DS_GET_CARD_SERVICES_INFO:
ret = pcmcia_get_card_services_info(&buf.servinfo);
break;
case DS_GET_CONFIGURATION_INFO:
ret = pcmcia_get_configuration_info(s->handle, &buf.config);
break;
case DS_GET_FIRST_TUPLE:
ret = pcmcia_get_first_tuple(s->handle, &buf.tuple);
break;
case DS_GET_NEXT_TUPLE:
ret = pcmcia_get_next_tuple(s->handle, &buf.tuple);
break;
case DS_GET_TUPLE_DATA:
buf.tuple.TupleData = buf.tuple_parse.data;
buf.tuple.TupleDataMax = sizeof(buf.tuple_parse.data);
ret = pcmcia_get_tuple_data(s->handle, &buf.tuple);
break;
case DS_PARSE_TUPLE:
buf.tuple.TupleData = buf.tuple_parse.data;
ret = pcmcia_parse_tuple(s->handle, &buf.tuple, &buf.tuple_parse.parse);
break;
case DS_RESET_CARD:
ret = pcmcia_reset_card(s->handle, NULL);
break;
case DS_GET_STATUS:
ret = pcmcia_get_status(s->handle, &buf.status);
break;
case DS_VALIDATE_CIS:
ret = pcmcia_validate_cis(s->handle, &buf.cisinfo);
break;
case DS_SUSPEND_CARD:
ret = pcmcia_suspend_card(s->handle, NULL);
break;
case DS_RESUME_CARD:
ret = pcmcia_resume_card(s->handle, NULL);
break;
case DS_EJECT_CARD:
ret = pcmcia_eject_card(s->handle, NULL);
break;
case DS_INSERT_CARD:
ret = pcmcia_insert_card(s->handle, NULL);
break;
case DS_ACCESS_CONFIGURATION_REGISTER:
if ((buf.conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN))
return -EPERM;
ret = pcmcia_access_configuration_register(s->handle, &buf.conf_reg);
break;
case DS_GET_FIRST_REGION:
ret = pcmcia_get_first_region(s->handle, &buf.region);
break;
case DS_GET_NEXT_REGION:
ret = pcmcia_get_next_region(s->handle, &buf.region);
break;
case DS_GET_FIRST_WINDOW:
buf.win_info.handle = (window_handle_t)s->handle;
//.........这里部分代码省略.........
示例13: first_tuple
static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
{
if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
return CS_NO_MORE_ITEMS;
return get_tuple(handle, tuple, parse);
}
示例14: sl811_cs_config
static void sl811_cs_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
struct device *parent = &handle_to_dev(handle);
local_info_t *dev = link->priv;
tuple_t tuple;
cisparse_t parse;
int last_fn, last_ret;
u_char buf[64];
config_info_t conf;
cistpl_cftable_entry_t dflt = { 0 };
DBG(0, "sl811_cs_config(0x%p)\n", link);
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
/* Configure card */
link->state |= DEV_CONFIG;
/* Look up the current Vcc */
CS_CHECK(GetConfigurationInfo,
pcmcia_get_configuration_info(handle, &conf));
link->conf.Vcc = conf.Vcc;
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
if (pcmcia_get_tuple_data(handle, &tuple) != 0
|| pcmcia_parse_tuple(handle, &tuple, &parse)
!= 0)
goto next_entry;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT) {
dflt = *cfg;
}
if (cfg->index == 0)
goto next_entry;
link->conf.ConfigIndex = cfg->index;
/* Use power settings for Vcc and Vpp if present */
/* Note that the CIS values need to be rescaled */
if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000
!= conf.Vcc)
goto next_entry;
} else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000
!= conf.Vcc)
goto next_entry;
}
if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
link->conf.Vpp1 = link->conf.Vpp2 =
cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
link->conf.Vpp1 = link->conf.Vpp2 =
dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
/* we need an interrupt */
if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
link->conf.Attributes |= CONF_ENABLE_IRQ;
/* IO window settings */
link->io.NumPorts1 = link->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
link->io.BasePort1 = io->win[0].base;
link->io.NumPorts1 = io->win[0].len;
if (pcmcia_request_io(link->handle, &link->io) != 0)
goto next_entry;
}
break;
next_entry:
if (link->io.NumPorts1)
pcmcia_release_io(link->handle, &link->io);
last_ret = pcmcia_get_next_tuple(handle, &tuple);
}
/* require an IRQ and two registers */
if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
goto cs_failed;
if (link->conf.Attributes & CONF_ENABLE_IRQ)
//.........这里部分代码省略.........
示例15: labpc_config
static void labpc_config(struct pcmcia_device *link)
{
struct local_info_t *dev = link->priv;
tuple_t tuple;
cisparse_t parse;
int last_ret;
u_char buf[64];
win_req_t req;
memreq_t map;
cistpl_cftable_entry_t dflt = { 0 };
DEBUG(0, "labpc_config(0x%p)\n", link);
/*
This reads the card's CONFIG tuple to find its configuration
registers.
*/
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
last_ret = pcmcia_get_first_tuple(link, &tuple);
if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
last_ret = pcmcia_get_tuple_data(link, &tuple);
if (last_ret) {
cs_error(link, GetTupleData, last_ret);
goto cs_failed;
}
last_ret = pcmcia_parse_tuple(&tuple, &parse);
if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
/*
In this loop, we scan the CIS for configuration table entries,
each of which describes a valid card configuration, including
voltage, IO window, memory window, and interrupt settings.
We make no assumptions about the card to be configured: we use
just the information available in the CIS. In an ideal world,
this would work for any PCMCIA card, but it requires a complete
and accurate CIS. In practice, a driver usually "knows" most of
these things without consulting the CIS, and most client drivers
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
last_ret = pcmcia_get_first_tuple(link, &tuple);
if (last_ret) {
cs_error(link, GetFirstTuple, last_ret);
goto cs_failed;
}
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
if (pcmcia_get_tuple_data(link, &tuple))
goto next_entry;
if (pcmcia_parse_tuple(&tuple, &parse))
goto next_entry;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
dflt = *cfg;
if (cfg->index == 0)
goto next_entry;
link->conf.ConfigIndex = cfg->index;
/* Does this card need audio output? */
if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
link->conf.Attributes |= CONF_ENABLE_SPKR;
link->conf.Status = CCSR_AUDIO_ENA;
}
/* Do we need to allocate an interrupt? */
if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
link->conf.Attributes |= CONF_ENABLE_IRQ;
/* IO window settings */
link->io.NumPorts1 = link->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
link->io.BasePort1 = io->win[0].base;
link->io.NumPorts1 = io->win[0].len;
if (io->nwin > 1) {
link->io.Attributes2 = link->io.Attributes1;
link->io.BasePort2 = io->win[1].base;
link->io.NumPorts2 = io->win[1].len;
}
/* This reserves IO space but doesn't actually enable it */
if (pcmcia_request_io(link, &link->io))
goto next_entry;
//.........这里部分代码省略.........