From 5757abe58a66598e51af535ff6dd4b4a43649540 Mon Sep 17 00:00:00 2001 From: shiba Date: Sun, 2 Sep 2001 06:37:41 +0000 Subject: Update cis tuple parser, add a pccarddevs entry, and improve PCCARD_IVAR_ETHADDR in pccard_read_ivar(). Change points: (1) Read Function Ext tuple. (2) Add Ratoc REX-R280 entry(fe driver). (3) Take ether address from function ext tuple. Reviewed by: imp Obtained from: NetBSD --- sys/dev/pccard/pccard.c | 8 ++++++-- sys/dev/pccard/pccard_cis.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ sys/dev/pccard/pccarddevs | 3 +++ sys/dev/pccard/pccarddevs.h | 5 +++++ sys/dev/pccard/pccardvar.h | 19 +++++++++++++++++++ 5 files changed, 78 insertions(+), 2 deletions(-) diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 2e11217..99096ee 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -43,6 +43,8 @@ #include #include +#include + #include #include @@ -392,7 +394,9 @@ pccard_function_init(struct pccard_function *pf) rle->res = r; } if (cfe->num_memspace > 0) { - goto not_this_one; + /* + * Not implement yet, Fix me. + */ } if (cfe->irqmask) { cfe->irqrid = 0; @@ -934,7 +938,7 @@ pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) switch (which) { default: case PCCARD_IVAR_ETHADDR: - return (ENOENT); + bcopy(func->pf_funce_lan_nid, result, ETHER_ADDR_LEN); break; case PCCARD_IVAR_VENDOR: *(u_int32_t *) result = sc->card.manufacturer; diff --git a/sys/dev/pccard/pccard_cis.c b/sys/dev/pccard/pccard_cis.c index 0fd70f0..e52d116 100644 --- a/sys/dev/pccard/pccard_cis.c +++ b/sys/dev/pccard/pccard_cis.c @@ -70,6 +70,7 @@ struct cis_state { }; int pccard_parse_cis_tuple(struct pccard_tuple *, void *); +static int decode_funce(struct pccard_tuple *, struct pccard_function *); void pccard_read_cis(struct pccard_softc *sc) @@ -768,6 +769,17 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) DPRINTF(("CISTPL_FUNCID\n")); break; + case PCCARD_CISTPL_FUNCE: + if (state->pf == NULL || state->pf->function <= 0) { + DPRINTF(("CISTPL_FUNCE is not followed by " + "valid CISTPL_FUNCID\n")); + break; + } + if (tuple->length >= 2) { + decode_funce(tuple, state->pf); + } + DPRINTF(("CISTPL_FUNCE\n")); + break; case PCCARD_CISTPL_CONFIG: if (tuple->length < 3) { DPRINTF(("CISTPL_CONFIG too short %d\n", @@ -1205,3 +1217,36 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) return (0); } + +static int +decode_funce(struct pccard_tuple *tuple, struct pccard_function *pf) +{ + int type = pccard_tuple_read_1(tuple, 0); + + switch (pf->function) { + case PCCARD_FUNCTION_DISK: + if (type == PCCARD_TPLFE_TYPE_DISK_DEVICE_INTERFACE) { + pf->pf_funce_disk_interface + = pccard_tuple_read_1(tuple, 1); + } + break; + case PCCARD_FUNCTION_NETWORK: + if (type == PCCARD_TPLFE_TYPE_LAN_NID) { + int i; + int len = pccard_tuple_read_1(tuple, 1); + if (tuple->length < 2 + len || len > 8) { + /* tuple length not enough or nid too long */ + break; + } + for (i = 0; i < len; i++) { + pf->pf_funce_lan_nid[i] + = pccard_tuple_read_1(tuple, i + 2); + } + pf->pf_funce_lan_nidlen = len; + } + break; + default: + break; + } + return 0; +} diff --git a/sys/dev/pccard/pccarddevs b/sys/dev/pccard/pccarddevs index d8a096e..394e2fa 100644 --- a/sys/dev/pccard/pccarddevs +++ b/sys/dev/pccard/pccarddevs @@ -273,6 +273,9 @@ product BAY STACK_660 0x0807 BayStack 660 Wireless LAN /* Raylink/WebGear */ product RAYTHEON WLAN 0x0000 WLAN Adapter +/* RATOC System Inc. Products */ +product RATOC REX_R280 0x1 RATOC REX-R280 + /* Samsung */ product SAMSUNG SWL_2000N 0x02 Samsung MagicLAN SWL-2000N diff --git a/sys/dev/pccard/pccarddevs.h b/sys/dev/pccard/pccarddevs.h index fb1e6ae..9be6199 100644 --- a/sys/dev/pccard/pccarddevs.h +++ b/sys/dev/pccard/pccarddevs.h @@ -474,6 +474,11 @@ #define PCCARD_PRODUCT_RAYTHEON_WLAN 0x0000 #define PCCARD_STR_RAYTHEON_WLAN "WLAN Adapter" +/* RATOC System Inc. Products */ +#define PCCARD_CIS_RATOC_REX_R280 { NULL, NULL, NULL, NULL } +#define PCCARD_PRODUCT_RATOC_REX_R280 0x1 +#define PCCARD_STR_RATOC_REX_R280 "RATOC REX-R280" + /* Samsung */ #define PCCARD_CIS_SAMSUNG_SWL_2000N { NULL, NULL, NULL, NULL } #define PCCARD_PRODUCT_SAMSUNG_SWL_2000N 0x02 diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h index 729ee5d..a2486ff 100644 --- a/sys/dev/pccard/pccardvar.h +++ b/sys/dev/pccard/pccardvar.h @@ -113,6 +113,20 @@ struct pccard_config_entry { STAILQ_ENTRY(pccard_config_entry) cfe_list; }; +struct pccard_funce_disk { + int pfd_interface; +}; + +struct pccard_funce_lan { + int pfl_nidlen; + u_int8_t pfl_nid[8]; +}; + +union pccard_funce { + struct pccard_funce_disk pfv_disk; + struct pccard_funce_lan pfv_lan; +}; + struct pccard_function { /* read off the card */ int number; @@ -140,6 +154,11 @@ struct pccard_function { driver_intr_t *intr_handler; void *intr_handler_arg; void *intr_handler_cookie; + + union pccard_funce pf_funce; /* CISTPL_FUNCE */ +#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface +#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid +#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen }; /* pf_flags */ -- cgit v1.1