From owner-freebsd-drivers@freebsd.org Mon Sep 24 02:45:26 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E0C210A24C4 for ; Mon, 24 Sep 2018 02:45:26 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E53488CB02 for ; Mon, 24 Sep 2018 02:45:25 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id F1E3F6B for ; Mon, 24 Sep 2018 04:45:23 +0200 (CEST) Received: from rolf.obsigna.com (rolf.obsigna.com [192.168.222.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id D0DBE1350F946 for ; Sun, 23 Sep 2018 23:45:19 -0300 (BRT) From: "Dr. Rolf Jansen" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Writing a PCIe-Driver Message-Id: Date: Sun, 23 Sep 2018 23:45:18 -0300 To: freebsd-drivers@freebsd.org X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2018 02:45:26 -0000 Hello, A couple of years ago, with the valuable help of people on this list, I = managed to write a PCI driver for the National Instruments DAQ card, NI = PCI-6251. The driver was kept very simple, only map the BAR=E2=80=99s = and some DMA memory into the user space. The DAC/ADC and DIO is then all = controlled from user space by writing command codes to certain offsets = from the mapped BAR=E2=80=99s, and reading data from the mapped DMA = memory and/or from other given offsets. See: How to map device addresses into user space = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml Now, I need to do exactly the same for a PCIe card, namely the NI = PCIe-6351. However, I even cannot see where to start. For PCI cards, the = respective chapter 11 in the FreeBSD Architecture Handbook was quite = helpful, for getting started, in no time, I got the PCI card probed and = attached. https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html The dumb approach, probing the device ID and attaching the PCI(e) driver = to the PCIe device in a similar fashion didn=E2=80=99t work - I didn=E2=80= =99t expect this either, however, where would I start? How do I attach = my driver to a PCIe card on FreeBSD 11 or 12? Please can somebody push me into the right direction. Once I got the = driver attached to the card, I guess, I would be able to adapt the = mem-mapping code of my old driver for the new card. Best regards Rolf