From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 5 14:06:22 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 628CC16A4DA for ; Sat, 5 Aug 2006 14:06:22 +0000 (UTC) (envelope-from nike_d@cytexbg.com) Received: from mail.interbgc.com (mx01.cablebg.net [217.9.224.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 6FBA243D46 for ; Sat, 5 Aug 2006 14:06:20 +0000 (GMT) (envelope-from nike_d@cytexbg.com) Received: (qmail 87532 invoked from network); 5 Aug 2006 14:06:19 -0000 Received: from nike_d@cytexbg.com by keeper.interbgc.com by uid 1002 with qmail-scanner-1.14 (uvscan: v4.2.40/v4374. spamassassin: 2.63. Clear:SA:0(0.1/8.0):. Processed in 1.095461 secs); 05 Aug 2006 14:06:19 -0000 X-Spam-Status: No, hits=0.1 required=8.0 Received: from niked.ddns.cablebg.net (HELO tormentor.totalterror.net) (85.130.14.211) by mx01.interbgc.com with SMTP; 5 Aug 2006 14:06:18 -0000 Received: (qmail 48036 invoked from network); 5 Aug 2006 14:06:17 -0000 Received: from unknown (HELO ?10.0.0.3?) (10.0.0.3) by tormentor.totalterror.net with SMTP; 5 Aug 2006 14:06:17 -0000 Message-ID: <44D4A5DC.7080403@cytexbg.com> Date: Sat, 05 Aug 2006 17:06:20 +0300 From: Niki Denev User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 0.94.0.0 OpenPGP: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: jkh weird problem (reading pci device memory) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2006 14:06:22 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm trying to port a linux driver to freebsd (hsdpa/umts nozomi card), and i'm experiencing some really weird problem... probably due to my limited kernel knowledge/experience. Here it is the attach routine, which tries to read a portion of the device memory into a specially formatted struct. Then the first filed in the struct is compared to a predefined value (a signature) to make sure that the read was successfull. The problem is that right now this only works if i do the printfs marked with XXX. When i comment them the read returns something that looks to me like random garbage... probably i'm doing something very stupid, or missing something essential... any insight is greatly appreciated. Again, here is the original linux driver for reference : http://www.pharscape.org/3G/nozomi_2.1_060703.tar.gz P.S.: This is on 7.0-CURRENT Thanks in advance! Regards, Niki Denev [ code ] int nozomi_attach(device_t dev) { struct nozomi_softc *sc; int i; u_int8_t r; sc = device_get_softc(dev); sc->noz_dev = dev; sc->bar.id = PCIR_BAR(0); sc->bar.res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->bar.id, 0, ~0, 1, RF_ACTIVE); sc->bar.tag = rman_get_bustag(sc->bar.res); sc->bar.hdl = rman_get_bushandle(sc->bar.res); sc->base_addr = rman_get_start(sc->bar.res); sc->virt_addr = rman_get_virtual(sc->bar.res); /* set card type to F32_8 on no match */ sc->card_type = rman_get_size(sc->bar.res) == 2048 ? F32_2 : F32_8; device_printf(sc->noz_dev, "card has %uKB memory\n", sc->card_type); /* XXX if i don't print these the reading of the bus memory will be incorrect */ printf("phys address 0x%08lx\n", sc->base_addr); printf("virt address 0x%p\n", sc->virt_addr); printf("cfg address 0x%p\n", &sc->cfg_table); 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; } if(sc->cfg_table.signature != CONFIG_MAGIC) { printf("ConfigTable Bad! 0x%08X != 0x%08X\n", sc->cfg_table.signature, CONFIG_MAGIC); return(ENXIO); } [ code continues ... ] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE1KXcHNAJ/fLbfrkRAhEZAKCvz1+ZBDH+mSMBLtoreAGDlzSL4wCgsZcL yxziRoie0cqIFYCzdI4gAkk= =6D/Y -----END PGP SIGNATURE-----