summaryrefslogtreecommitdiffstats
path: root/sys/dev/sn/if_sn_pccard.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-10-25 19:56:19 +0000
committerimp <imp@FreeBSD.org>2003-10-25 19:56:19 +0000
commit08148c6afb7306fe5041d7aa718534a163898128 (patch)
tree6b9c970df55350b30c9dce96d5e4ff29f0a19eb2 /sys/dev/sn/if_sn_pccard.c
parenta7b0d8155091695eef56bd362440edb28ad41366 (diff)
downloadFreeBSD-src-08148c6afb7306fe5041d7aa718534a163898128.zip
FreeBSD-src-08148c6afb7306fe5041d7aa718534a163898128.tar.gz
Convert to bus_space.
Make the pccard attachment work with NEWCARD Start locking of the driver, but only the macros are defined right now Tested on: Megahertz CC10BT/2 # (These cards are very popular on ebay these days, and run < $10 including # shipping from some sellers).
Diffstat (limited to 'sys/dev/sn/if_sn_pccard.c')
-rw-r--r--sys/dev/sn/if_sn_pccard.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/dev/sn/if_sn_pccard.c b/sys/dev/sn/if_sn_pccard.c
index bdca9cc..57551a8 100644
--- a/sys/dev/sn/if_sn_pccard.c
+++ b/sys/dev/sn/if_sn_pccard.c
@@ -86,17 +86,59 @@ sn_pccard_probe(device_t dev)
}
static int
+sn_pccard_ascii_enaddr(const char *str, u_char *enet)
+{
+ uint8_t digit;
+ int i;
+
+ memset(enet, 0, ETHER_ADDR_LEN);
+
+ for (i = 0, digit = 0; i < (ETHER_ADDR_LEN * 2); i++) {
+ if (str[i] >= '0' && str[i] <= '9')
+ digit |= str[i] - '0';
+ else if (str[i] >= 'a' && str[i] <= 'f')
+ digit |= (str[i] - 'a') + 10;
+ else if (str[i] >= 'A' && str[i] <= 'F')
+ digit |= (str[i] - 'A') + 10;
+ else {
+ /* Bogus digit!! */
+ return (0);
+ }
+
+ /* Compensate for ordering of digits. */
+ if (i & 1) {
+ enet[i >> 1] = digit;
+ digit = 0;
+ } else
+ digit <<= 4;
+ }
+
+ return (1);
+}
+
+static int
sn_pccard_attach(device_t dev)
{
struct sn_softc *sc = device_get_softc(dev);
int i;
u_char sum;
u_char ether_addr[ETHER_ADDR_LEN];
+ const char *cisstr;
sc->pccard_enaddr = 0;
pccard_get_ether(dev, ether_addr);
for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
sum |= ether_addr[i];
+ if (sum == 0) {
+ pccard_get_cis3_str(dev, &cisstr);
+ if (strlen(cisstr) == ETHER_ADDR_LEN * 2)
+ sum = sn_pccard_ascii_enaddr(cisstr, ether_addr);
+ }
+ if (sum == 0) {
+ pccard_get_cis4_str(dev, &cisstr);
+ if (strlen(cisstr) == ETHER_ADDR_LEN * 2)
+ sum = sn_pccard_ascii_enaddr(cisstr, ether_addr);
+ }
if (sum) {
sc->pccard_enaddr = 1;
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
OpenPOWER on IntegriCloud