I had wrote a Linux driver for our FPGA + PCI Express board, and recently ported it to FreeBSD. While there are many documentation for Linux device driver (i.e, LDD3), I could find (almost) no comprehensive document about writing FreeBSD driver.
[ open/close/read/write/seek ]
read() and write() are mostly done by uio_move(). See uio (9) for detail.
Basically we don’t have to implement seek(). uio structure has a pointer to seek.
[ mmap ]
FreeBSD’s mmap implementation is really BEAUTIFUL. Just modify “vm_addr_t *paddr” to return corresponding physical address.
[ DMA layer ]
bus_dma (9) framework provides sophisticated DMA framework. I’ve read /usr/src/sys/dev/hifn/hifn7751.c as my reference.
Happy hacking!