mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 08:52:07 +01:00
MFPAO: support wildcard entry for generic serial and fixed
disk as fallthrough entry. Submitted by: MIHIRA Sanpei Yoshiro <sanpei@sanpei.org>, iwasaki Reviewed by: imp, -mobile ML and nomads ML in Japan Obtained from: http://www.freebsd.org/~iwasaki/pccard/pccardd-generic.diff http://home.jp.freebsd.org/~sanpei/4-current/usr.sbin-pccard-pccardd.diff
This commit is contained in:
parent
b76f24f759
commit
1ea7ed21c8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59053
@ -1059,3 +1059,23 @@ card "Xircom" "CreditCard Ethernet 10/100 + Modem 56"
|
||||
insert /etc/pccard_ether $device
|
||||
remove logger -t pccard:$device -s Xircom CreditCard Modem removed
|
||||
remove /sbin/ifconfig $device delete
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
# "Wildcard" entries
|
||||
#
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
# GENERIC PCMCIA modem
|
||||
generic serial
|
||||
config auto "sio" ?
|
||||
reset 10000 # for unstable cards
|
||||
insert logger -t pccard:$device -s PCMCIA Modem inserted
|
||||
remove logger -t pccard:$device -s PCMCIA Modem removed
|
||||
|
||||
# GENERIC Flash ATA / ATA HDD
|
||||
generic fixed_disk
|
||||
config auto "ata" ?
|
||||
insert logger -t pccard:$device -s Flash ATA / ATA HDD inserted
|
||||
remove logger -t pccard:$device -s Flash ATA / ATA HDD removed
|
||||
|
||||
|
@ -185,14 +185,17 @@ void
|
||||
card_removed(struct slot *sp)
|
||||
{
|
||||
struct card *cp;
|
||||
int in_use = 0;
|
||||
|
||||
if (sp->cis)
|
||||
freecis(sp->cis);
|
||||
if (sp->config) {
|
||||
if (sp->config->inuse && sp->config->driver->inuse)
|
||||
in_use = 1;
|
||||
sp->config->inuse = 0;
|
||||
sp->config->driver->inuse = 0;
|
||||
}
|
||||
if ((cp = sp->card) != 0)
|
||||
if ((cp = sp->card) != 0 && in_use)
|
||||
execute(cp->remove, sp);
|
||||
sp->cis = 0;
|
||||
sp->config = 0;
|
||||
@ -229,10 +232,36 @@ card_inserted(struct slot *sp)
|
||||
#if 0
|
||||
dumpcis(sp->cis);
|
||||
#endif
|
||||
for (cp = cards; cp; cp = cp->next)
|
||||
if (strncmp(cp->manuf, sp->cis->manuf, CIS_MAXSTR) == 0 &&
|
||||
strncmp(cp->version, sp->cis->vers, CIS_MAXSTR) == 0)
|
||||
for (cp = cards; cp; cp = cp->next) {
|
||||
switch (cp->deftype) {
|
||||
case DT_VERS:
|
||||
if (strncmp(cp->manuf, sp->cis->manuf, CIS_MAXSTR) == 0 &&
|
||||
strncmp(cp->version, sp->cis->vers, CIS_MAXSTR) == 0) {
|
||||
logmsg("Card \"%s\"(\"%s\") "
|
||||
"matched \"%s\" (\"%s\") ",
|
||||
sp->cis->manuf, sp->cis->vers,
|
||||
cp->manuf, cp->version
|
||||
);
|
||||
goto escape;
|
||||
}
|
||||
break;
|
||||
case DT_FUNC:
|
||||
if (cp->func_id == sp->cis->func_id1) {
|
||||
logmsg("Card \"%s\"(\"%s\") "
|
||||
"[%s] [%s] "
|
||||
"has function ID %d\n",
|
||||
sp->cis->manuf, sp->cis->vers,
|
||||
sp->cis->add_info1, sp->cis->add_info2,
|
||||
cp->func_id);
|
||||
goto escape;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logmsg("Unknown deftype %d\n", cp->deftype);
|
||||
die("cardd.c:card_inserted()");
|
||||
}
|
||||
}
|
||||
escape:
|
||||
sp->card = cp;
|
||||
#if 0
|
||||
reset_slot(sp);
|
||||
|
@ -67,6 +67,8 @@ struct card {
|
||||
struct card *next;
|
||||
char *manuf;
|
||||
char *version;
|
||||
u_char func_id;
|
||||
int deftype;
|
||||
struct ether *ether; /* For net cards, ether at offset */
|
||||
int reset_time; /* Reset time */
|
||||
int iosize; /* I/O window size (ignore location) */
|
||||
@ -183,3 +185,5 @@ void readfile(char *);
|
||||
#define DEFAULT_INDEX 1
|
||||
#define AUTO_INDEX 2
|
||||
|
||||
#define DT_VERS 0
|
||||
#define DT_FUNC 1
|
||||
|
@ -62,6 +62,7 @@ static char *keys[] = {
|
||||
"iosize", /* 12 */
|
||||
"debuglevel", /* 13 */
|
||||
"include", /* 14 */
|
||||
"function", /* 15 */
|
||||
0
|
||||
};
|
||||
|
||||
@ -79,6 +80,16 @@ static char *keys[] = {
|
||||
#define KWD_IOSIZE 12
|
||||
#define KWD_DEBUGLEVEL 13
|
||||
#define KWD_INCLUDE 14
|
||||
#define KWD_FUNCTION 15
|
||||
|
||||
/* for keyword compatibility with PAO/plain FreeBSD */
|
||||
static struct {
|
||||
char *alias;
|
||||
u_int key;
|
||||
} key_aliases[] = {
|
||||
{"generic", KWD_FUNCTION},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
struct flags {
|
||||
char *name;
|
||||
@ -93,6 +104,7 @@ static void error(char *);
|
||||
static int keyword(char *);
|
||||
static int irq_tok(int);
|
||||
static int config_tok(unsigned char *);
|
||||
static int func_tok(void);
|
||||
static int debuglevel_tok(int);
|
||||
static struct allocblk *ioblk_tok(int);
|
||||
static struct allocblk *memblk_tok(int);
|
||||
@ -101,7 +113,7 @@ static int iosize_tok(void);
|
||||
static void file_include(char *);
|
||||
|
||||
static void addcmd(struct cmd **);
|
||||
static void parse_card(void);
|
||||
static void parse_card(int);
|
||||
|
||||
/*
|
||||
* Read a file and parse the pcmcia configuration data.
|
||||
@ -202,7 +214,11 @@ parsefile(void)
|
||||
break;
|
||||
case KWD_CARD:
|
||||
/* Card definition. */
|
||||
parse_card();
|
||||
parse_card(DT_VERS);
|
||||
break;
|
||||
case KWD_FUNCTION:
|
||||
/* Function definition. */
|
||||
parse_card(DT_FUNC);
|
||||
break;
|
||||
case KWD_DEBUGLEVEL:
|
||||
i = debuglevel_tok(0);
|
||||
@ -228,7 +244,7 @@ parsefile(void)
|
||||
* Parse a card definition.
|
||||
*/
|
||||
static void
|
||||
parse_card(void)
|
||||
parse_card(int deftype)
|
||||
{
|
||||
char *man, *vers, *tmp;
|
||||
unsigned char index_type;
|
||||
@ -238,11 +254,25 @@ parse_card(void)
|
||||
struct ether *ether;
|
||||
|
||||
confp = 0;
|
||||
man = newstr(next_tok());
|
||||
vers = newstr(next_tok());
|
||||
cp = xmalloc(sizeof(*cp));
|
||||
cp->manuf = man;
|
||||
cp->version = vers;
|
||||
cp->deftype = deftype;
|
||||
switch (deftype) {
|
||||
case DT_VERS:
|
||||
man = newstr(next_tok());
|
||||
vers = newstr(next_tok());
|
||||
cp->manuf = man;
|
||||
cp->version = vers;
|
||||
cp->func_id = 0;
|
||||
break;
|
||||
case DT_FUNC:
|
||||
cp->manuf = "";
|
||||
cp->version = "";
|
||||
cp->func_id = (u_char) func_tok();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "parse_card: unknown deftype %d\n", deftype);
|
||||
exit(1);
|
||||
}
|
||||
cp->reset_time = 50;
|
||||
cp->next = 0;
|
||||
if (!last_card) {
|
||||
@ -497,6 +527,21 @@ config_tok(unsigned char *index_type)
|
||||
*index_type = NORMAL_INDEX;
|
||||
return num_tok();
|
||||
}
|
||||
/*
|
||||
* Function ID token
|
||||
*/
|
||||
static int
|
||||
func_tok(void)
|
||||
{
|
||||
if (strcmp("serial", next_tok()) == 0)
|
||||
return 2;
|
||||
pusht = 1;
|
||||
if (strcmp("fixed_disk", next_tok()) == 0)
|
||||
return 4;
|
||||
pusht = 1;
|
||||
return num_tok();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* debuglevel token. Must be between 0 and 9.
|
||||
@ -548,6 +593,12 @@ keyword(char *str)
|
||||
for (s = keys; *s; s++, i++)
|
||||
if (strcmp(*s, str) == 0)
|
||||
return (i);
|
||||
|
||||
/* search keyword aliases too */
|
||||
for (i = 0; key_aliases[i].key ; i++)
|
||||
if (strcmp(key_aliases[i].alias, str) == 0)
|
||||
return (key_aliases[i].key);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -195,6 +195,29 @@ and
|
||||
.Em remove
|
||||
commands are allowed, and they are executed in the order they
|
||||
are listed.
|
||||
.Ss "Wildcard entries"
|
||||
Following two wildcard entries of card identifiers are available
|
||||
for generic type of the cards:
|
||||
.Pp
|
||||
.Dl generic serial
|
||||
.Dl generic fixed_disk
|
||||
.Pp
|
||||
The keyword
|
||||
.Em serial
|
||||
matches ``Functional ID: Serial port/modem'' and
|
||||
.Em fixed_disk
|
||||
matches ``Fixed disk card''.
|
||||
The syntax is the same of
|
||||
.Em "card identifiers"
|
||||
but used ``generic'' instead of ``card'' in the first line.
|
||||
These are in the last of
|
||||
.Nm
|
||||
because unmatched cards with the other
|
||||
.Em card
|
||||
entries can match these entries secondly.
|
||||
The alias ``function'' can be used instead of ``generic'' because of
|
||||
the historical reason.
|
||||
.Pp
|
||||
.Sh EXAMPLE
|
||||
A typical configuration file may appear thus:
|
||||
.Bd -literal
|
||||
|
@ -47,6 +47,7 @@ static void cis_info(struct cis *, unsigned char *, int);
|
||||
static void device_desc(unsigned char *, int, struct dev_mem *);
|
||||
static void config_map(struct cis *, unsigned char *, int);
|
||||
static void cis_config(struct cis *, unsigned char *, int);
|
||||
static void cis_func_id(struct cis *, unsigned char *, int);
|
||||
static struct tuple_list *read_one_tuplelist(int, int, off_t);
|
||||
static struct tuple_list *read_tuples(int);
|
||||
static struct tuple *find_tuple_in_list(struct tuple_list *, unsigned char);
|
||||
@ -123,6 +124,10 @@ readcis(int fd)
|
||||
case CIS_CONFIG: /* 0x1B */
|
||||
cis_config(cp, tp->data, tp->length);
|
||||
break;
|
||||
case CIS_FUNC_ID: /* 0x21 */
|
||||
cis_func_id(cp, tp->data, tp->length);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return (cp);
|
||||
@ -181,6 +186,15 @@ cis_info(struct cis *cp, unsigned char *p, int len)
|
||||
while (*p++);
|
||||
strncpy(cp->add_info2, p, CIS_MAXSTR - 1);
|
||||
}
|
||||
/*
|
||||
* Fills in CIS function ID.
|
||||
*/
|
||||
static void
|
||||
cis_func_id(struct cis *cp, unsigned char *p, int len)
|
||||
{
|
||||
cp->func_id1 = *p++;
|
||||
cp->func_id2 = *p++;
|
||||
}
|
||||
|
||||
/*
|
||||
* device_desc - decode device descriptor.
|
||||
|
@ -119,6 +119,7 @@ struct cis {
|
||||
unsigned char last_config;
|
||||
unsigned char ccrs;
|
||||
unsigned long reg_addr;
|
||||
unsigned char func_id1, func_id2;
|
||||
struct dev_mem attr_mem;
|
||||
struct dev_mem common_mem;
|
||||
struct cis_config *def_config;
|
||||
|
Loading…
Reference in New Issue
Block a user