diff options
author | imp <imp@FreeBSD.org> | 2001-06-05 23:42:51 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-06-05 23:42:51 +0000 |
commit | ff377bfabd3b4454f252ac4ed62abfb4b5915b37 (patch) | |
tree | 4916d620c9c5d4b21203cf0bde0145fbd369fc02 /sys/dev/cardbus/cardbus_cis.c | |
parent | a54c77f56c1a66e1d5e062eb8a751e9e1580f95c (diff) | |
download | FreeBSD-src-ff377bfabd3b4454f252ac4ed62abfb4b5915b37.zip FreeBSD-src-ff377bfabd3b4454f252ac4ed62abfb4b5915b37.tar.gz |
Use bus_space when reading CIS. This allows us to access it in 8 bit
mode, which is what the standard mandates.
Submitted by: Takanori Watanabe-san
Reviewed by: jhb
Diffstat (limited to 'sys/dev/cardbus/cardbus_cis.c')
-rw-r--r-- | sys/dev/cardbus/cardbus_cis.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/cardbus/cardbus_cis.c b/sys/dev/cardbus/cardbus_cis.c index 7d80108..492b5ce 100644 --- a/sys/dev/cardbus/cardbus_cis.c +++ b/sys/dev/cardbus/cardbus_cis.c @@ -387,6 +387,8 @@ cardbus_read_tuple_mem(device_t dev, device_t child, u_int32_t *start, u_int8_t *tupledata) { struct resource *mem; + bus_space_tag_t bt; + bus_space_handle_t bh; int rid; int ret; @@ -398,6 +400,8 @@ cardbus_read_tuple_mem(device_t dev, device_t child, u_int32_t *start, mem = bus_alloc_resource(child, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); + bt = rman_get_bustag(mem); + bh = rman_get_bushandle(mem); if (mem == NULL) { device_printf(dev, "Failed to get memory for CIS reading\n"); return ENOMEM; @@ -407,13 +411,13 @@ cardbus_read_tuple_mem(device_t dev, device_t child, u_int32_t *start, ret = cardbus_read_tuple_exrom(dev, mem, start, off, tupleid, len, tupledata); } else { - /* XXX byte order? */ - unsigned char* ptr; - ptr = (unsigned char*)rman_get_virtual(mem) - + CARDBUS_CIS_ADDR(*start) + *off; - *tupleid = ptr[0]; - *len = ptr[1]; - memcpy(tupledata, ptr+2, *len); + *tupleid = bus_space_read_1(bt, bh, + CARDBUS_CIS_ADDR(*start) + *off); + *len = bus_space_read_1(bt, bh, + CARDBUS_CIS_ADDR(*start) + *off + 1); + bus_space_read_multi_1(rman_get_bustag(mem), + rman_get_bushandle(mem), + *off + CARDBUS_CIS_ADDR(*start), tupledata, *len); ret = 0; *off += *len+2; } |