1. Allow drivers to query CIS strings from OLDCARD.

2. Include backwards compatibility good for the moment (eventually will
   be turned off in current, but allow for a short transition period).

PR:	51333
Submited by: Scott Mitchell (1)
MFC after:	2 weeks
This commit is contained in:
Warner Losh 2003-04-23 23:39:21 +00:00
parent d6b4602222
commit 9598fb9322
4 changed files with 69 additions and 0 deletions

View File

@ -147,10 +147,31 @@ struct dev_desc {
uint8_t misc[DEV_MISC_LEN]; /* For any random info */
uint8_t manufstr[DEV_MAX_CIS_LEN];
uint8_t versstr[DEV_MAX_CIS_LEN];
uint8_t cis3str[DEV_MAX_CIS_LEN];
uint8_t cis4str[DEV_MAX_CIS_LEN];
uint32_t manufacturer; /* Manufacturer ID */
uint32_t product; /* Product ID */
uint32_t prodext; /* Product ID (extended) */
};
#if __FreeBSD_version < 5000000 /* 4.x compatibility only. */
#define PIOCSDRVOLD _IOWR('P', 6, struct dev_desc_old) /* Set driver */
struct dev_desc_old {
char name[16]; /* Driver name */
int unit; /* Driver unit number */
unsigned long mem; /* Memory address of driver */
int memsize; /* Memory size (if used) */
int iobase; /* base of I/O ports */
int iosize; /* Length of I/O ports */
int irqmask; /* Interrupt number(s) to allocate */
int flags; /* Device flags */
uint8_t misc[DEV_MISC_LEN]; /* For any random info */
uint8_t manufstr[DEV_MAX_CIS_LEN];
uint8_t versstr[DEV_MAX_CIS_LEN];
uint32_t manufacturer; /* Manufacturer ID */
uint32_t product; /* Product ID */
uint32_t prodext; /* Product ID (extended) */
};
#endif
#define DEV_DESC_HAS_SIZE 1
struct pcic_reg {

View File

@ -223,6 +223,8 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
bcopy(desc->misc, devi->misc, sizeof(desc->misc));
strcpy(devi->manufstr, desc->manufstr);
strcpy(devi->versstr, desc->versstr);
strcpy(devi->cis3str, desc->cis3str);
strcpy(devi->cis4str, desc->cis4str);
devi->manufacturer = desc->manufacturer;
devi->product = desc->product;
devi->prodext = desc->prodext;
@ -476,6 +478,10 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td)
int pwval;
int s;
struct slot *slt = PCCARD_DEV2SOFTC(dev);
/*XXX*/#if __FreeBSD_version < 5000000 /* 4.x compatibility only. */
struct dev_desc d;
struct dev_desc_old *odp;
/*XXX*/#endif
if (slt == 0 && cmd != PIOCRWMEM)
return (ENXIO);
@ -606,6 +612,34 @@ crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td)
else
pccard_failure_beep();
return (err);
/***/#if __FreeBSD_version < 5000000 /* 4.x compatibility only. */
case PIOCSDRVOLD:
if (suser(td))
return (EPERM);
odp = (struct dev_desc_old *) data;
strlcpy(d.name, odp->name, sizeof(d.name));
d.unit = odp->unit;
d.mem = odp->mem;
d.memsize = odp->memsize;
d.iobase = odp->iobase;
d.iosize = odp->iosize;
d.irqmask = odp->irqmask;
d.flags = odp->flags;
memcpy(d.misc, odp->misc, sizeof(odp->misc));
strlcpy(d.manufstr, odp->manufstr, sizeof(d.manufstr));
strlcpy(d.versstr, odp->versstr, sizeof(d.versstr));
*d.cis3str = '\0';
*d.cis4str = '\0';
d.manufacturer = odp->manufacturer;
d.product = odp->product;
d.prodext = odp->prodext;
err = allocate_driver(slt, &d);
if (!err)
pccard_success_beep();
else
pccard_failure_beep();
return (err);
/***/#endif
/*
* Virtual removal/insertion
*/

View File

@ -322,6 +322,18 @@ pccard_read_ivar(device_t bus, device_t child, int which, uintptr_t *result)
case PCCARD_IVAR_PRODEXT:
*(u_int16_t *) result = devi->prodext;
return (0);
case PCCARD_IVAR_VENDOR_STR:
*(char **) result = devi->manufstr;
break;
case PCCARD_IVAR_PRODUCT_STR:
*(char **) result = devi->versstr;
break;
case PCCARD_IVAR_CIS3_STR:
*(char **) result = devi->cis3str;
break;
case PCCARD_IVAR_CIS4_STR:
*(char **) result = devi->cis4str;
break;
}
return (ENOENT);
}

View File

@ -91,6 +91,8 @@ struct pccard_devinfo {
uint8_t misc[DEV_MISC_LEN]; /* For any random info */
uint8_t manufstr[DEV_MAX_CIS_LEN];
uint8_t versstr[DEV_MAX_CIS_LEN];
uint8_t cis3str[DEV_MAX_CIS_LEN];
uint8_t cis4str[DEV_MAX_CIS_LEN];
uint32_t manufacturer; /* Manufacturer ID */
uint32_t product; /* Product ID */
uint32_t prodext; /* Product ID (extended) */