From owner-freebsd-questions Tue Mar 18 12:29:47 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id MAA26016 for questions-outgoing; Tue, 18 Mar 1997 12:29:47 -0800 (PST) Received: from bmcgover-pc.cisco.com (bmcgover-pc.cisco.com [171.69.104.147]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA25984; Tue, 18 Mar 1997 12:29:26 -0800 (PST) Received: from bmcgover-pc.cisco.com (localhost.cisco.com [127.0.0.1]) by bmcgover-pc.cisco.com (8.8.5/8.8.5) with ESMTP id PAA00353; Tue, 18 Mar 1997 15:28:28 -0500 (EST) Message-Id: <199703182028.PAA00353@bmcgover-pc.cisco.com> To: questions@freebsd.org, hackers@freebsd.org Subject: Question on mapping PCI memory (Repeat) Date: Tue, 18 Mar 1997 15:28:28 -0500 From: Brian McGovern Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I apologize for re-asking this question, but ES here recently reparitioned my harddrive, and I lost all of my mail, including the answer to this question. Assume: I have a PCI card. It has 3 configuration registers at various offsets that are defined by the constants CZ_PCI_PLX9060_MEM, CZ_PCI_MEMORY_WINDOW, CZ_PCI_IRQ. I wish to be able to map the first two, which are memory addresses of dual ported ram on the card (I assume physical addresses), to virtual address space, so I can access it from the kernel. Major premise: I think I know how to do it. Minor premise: I probably have no clue, and I'm screwing it up. Therefore: I am assuming that I can use the pci_map_mem routine, and do something like: vm_offset_t vaddr, paddr; if (pci_map_mem(config_id, CZ_PCI_PLX9060_MEM, &vaddr, &paddr) == 0) die(); and then have (unsigned char *)vaddr be a pointer to my virtual memory space, which I can then memcpy to, or do things like (unsigned char *)vaddr[index] = 0; and such. Also, as an alternative, I can do it the long way, similar to: paddr = pci_conf_read(config_id, CZ_PCI_PLX9060_MEM); vaddr = (vm_offset_t)pmap_mapdev(paddr, 72); Then use vaddr as above as the virtual addresses. The questions I have are: 1.) Is this correct? If so, yea me. If not, which invokation is incorrect? 2.) Do I have to do anything extra fancy, such as take extra steps to align on page boundaries and such, and, if so, how would I go about doing that? 3.) Do I have to worry about locking the virtual memory space down? I assume they'd become kernel pages (as this is for a device driver), so they should never be "swapped". Any other comments are also welcome. Thanks. -Brian