Writing a NetBSD kernel module
In this post, we'll look at implementing a simple character device driver as a kernel module in NetBSD. Once it is loaded, userspace processes will be able to write an arbitrary byte string to the device, and on every successive read expect a cryptographically-secure pseudorandom permutation of the original byte string.
IF you've always wanted to learn how to write a NetBSD driver, here's a great starting point.