From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 12 18:09:39 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A76016A4E0; Sat, 12 Aug 2006 18:09:39 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id D85FF43D45; Sat, 12 Aug 2006 18:09:38 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (m6mrs3iru1dnp6tm@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k7CI9afP072114; Sat, 12 Aug 2006 11:09:36 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k7CI9Yp3072113; Sat, 12 Aug 2006 11:09:34 -0700 (PDT) (envelope-from jmg) Date: Sat, 12 Aug 2006 11:09:34 -0700 From: John-Mark Gurney To: Niki Denev Message-ID: <20060812180934.GN99774@funkthat.com> Mail-Followup-To: Niki Denev , John Baldwin , freebsd-hackers@freebsd.org References: <44D4A5DC.7080403@cytexbg.com> <200608071527.50711.jhb@freebsd.org> <44DD9476.7020706@cytexbg.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44DD9476.7020706@cytexbg.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org Subject: Re: jkh weird problem (reading pci device memory) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2006 18:09:39 -0000 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."