Date: Sat, 12 Aug 2006 11:09:34 -0700 From: John-Mark Gurney <gurney_j@resnet.uoregon.edu> To: Niki Denev <nike_d@cytexbg.com> Cc: freebsd-hackers@freebsd.org Subject: Re: jkh weird problem (reading pci device memory) Message-ID: <20060812180934.GN99774@funkthat.com> In-Reply-To: <44DD9476.7020706@cytexbg.com> References: <44D4A5DC.7080403@cytexbg.com> <200608071527.50711.jhb@freebsd.org> <44DD9476.7020706@cytexbg.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Niki Denev wrote this message on Sat, Aug 12, 2006 at 11:42 +0300: > -----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? No, read_multi reads from the same location every time.. This is for things like a FIFO where the value can change each time, you want bus_read_region_1... Read the bus_space(9) man page for more info about the differences between the two... http://www.freebsd.org/cgi/man.cgi?query=bus_space&apropos=0&sektion=0&manpath=FreeBSD+6.1-RELEASE&format=html -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060812180934.GN99774>