From owner-freebsd-questions Thu Dec 20 16:53:51 2001 Delivered-To: freebsd-questions@freebsd.org Received: from alicia.nttmcl.com (alicia.nttmcl.com [216.69.69.10]) by hub.freebsd.org (Postfix) with ESMTP id E6DD737B417 for ; Thu, 20 Dec 2001 16:53:47 -0800 (PST) Received: from ntt27f48otgmw8 (dhcp246.nttmcl.com [216.69.69.246]) by alicia.nttmcl.com (8.10.1/8.10.1) with SMTP id fBL0rlv11846 for ; Thu, 20 Dec 2001 16:53:47 -0800 (PST) Reply-To: From: "Anuranjan" To: Subject: Memory mapped device Date: Thu, 20 Dec 2001 16:55:19 -0800 Message-ID: <015401c189ba$2a52db00$f64545d8@ntt27f48otgmw8> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi , I'm trying to write some driver code for a memory mapped device (PCI bus). struct xxx_softc *sc = device_get_softc(dev); struct resource *res; /* * Map control/status registers. */ command = pci_read_config(dev, PCIR_COMMAND, 4); command |= (PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); pci_write_config(dev, PCIR_COMMAND, command, 4); command = pci_read_config(dev, PCIR_COMMAND, 4); if (!(command & PCIM_CMD_MEMEN)) { printf("xxx%d: failed to enable memory mapping!\n", unit); error = ENXIO; goto fail; } else printf("xxx%d: memory mapping enabled\n", unit); mem_rid = 0x10; res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid, 0ul, ~0ul, size, RF_ACTIVE); I've been able to probe the device correctly, get the IRQ resource allocated correctly etc, I don't get any errors in this mapping enable and alloc code either. But when I try accessing the device I don't get the correct results (can't get to the eeprom, and can't access correct values from the register offsets. u_int32_t s = bus_space_read_4(sc->btag, sc->bhandle, REGISTER_OFFSET); The device is basically a Cardbus card attached to the freebsd 4.3 PCI bus through a Cardbus/PCI extender card. I don't know exactly why it couldn't be working here. Is it the problem with the mapping, or is it with the device, or with the freeBSD mechanism? I'm a newbie so please excuse me if I'm posting this at the wrong forum and let me know the right place to go to. Thanks in advance A To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message