{"id":2579,"date":"2010-05-25T00:04:53","date_gmt":"2010-05-24T15:04:53","guid":{"rendered":"http:\/\/yasu2.prosou.nu\/blog\/index.php\/2010\/05\/25\/freebsd_device_driver\/"},"modified":"2010-05-25T00:04:53","modified_gmt":"2010-05-24T15:04:53","slug":"freebsd_device_driver","status":"publish","type":"post","link":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2010\/05\/25\/2579\/","title":{"rendered":"FreeBSD device driver"},"content":{"rendered":"<p>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, <a href=\"http:\/\/lwn.net\/Kernel\/LDD3\/\">LDD3<\/a>), I could find (almost) no comprehensive document about writing FreeBSD driver.<br \/>\n[ open\/close\/read\/write\/seek ]<br \/>\nread() and write() are mostly done by uio_move(). See uio (9) for detail.<br \/>\nBasically we don&#8217;t have to implement seek(). uio structure has a pointer to seek.<br \/>\n[ mmap ]<br \/>\nFreeBSD&#8217;s mmap implementation is really BEAUTIFUL. Just modify &#8220;vm_addr_t *paddr&#8221; to return corresponding physical address.<br \/>\n[ DMA layer ]<br \/>\nbus_dma (9) framework provides sophisticated DMA framework. I&#8217;ve read  \/usr\/src\/sys\/dev\/hifn\/hifn7751.c as my reference.<br \/>\nHappy hacking!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had wrote a Linux driver for our FPGA + PCI Express board, and recently ported it to FreeBSD. While there ar &hellip; <a href=\"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2010\/05\/25\/2579\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;FreeBSD device driver&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-2579","post","type-post","status-publish","format-standard","hentry","category-unix-"],"_links":{"self":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2579"}],"version-history":[{"count":0,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2579\/revisions"}],"wp:attachment":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}