jkh weird problem (reading pci device memory)
Niki Denev
nike_d at cytexbg.com
Sat Aug 12 08:42:37 UTC 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John Baldwin wrote:
> On Saturday 05 August 2006 10:06, Niki Denev wrote:
>> for(i=0; i < sizeof(config_table_t); i++) {
>> r = bus_space_read_1(sc->bar.tag, sc->bar.hdl, i);
>> *((u_int8_t *)&sc->cfg_table + i) = r;
>> }
>
> Note that you can replace this with:
>
> bus_space_read_multi_1(sc->bar.tag, sc->bar.hdl, 0,
> (u_int8_t *)&sc->cfg_table, sizeof(config_table_t));
>
I can't understand why the code above gives me different results.
i.e.:
for(i=0; i < sizeof(config_table_t); i++) {
*((u_int8_t *)&sc->cfg_table + i) = bus_read_1(sc->res, i);
}
printf("cfg_table signature : %08X\n", sc->cfg_table.signature);
This prints : cfg_table signaature 0xEFEFFEFE, which is the correct signature
that should be read from the card.
But this code :
bus_read_multi_1(sc->res, 0, (u_int8_t *)&sc->cfg_table, sizeof(config_table_t));
printf("cfg_table signature : %08X\n", sc->cfg_table.signature);
prints : cfg_table signature 0xFEFEFEFE
which is not correct...
Shouldn't the above examples do exactly the same thing?
- --niki
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFE3ZR2HNAJ/fLbfrkRAlVBAJ42fHV0cQ4uw5SIdUl7TQHaKkBSKQCZAcd6
eCFWNusXoCuqm88OObX+AFw=
=J0mZ
-----END PGP SIGNATURE-----
More information about the freebsd-hackers
mailing list