1*b902ab58Schristos $NetBSD: README,v 1.15 2020/04/30 00:48:10 christos Exp $ 214e25719Spgoyette 314e25719Spgoyette Kernel Developer's Manual 414e25719Spgoyette 514e25719SpgoyetteDESCRIPTION 614e25719Spgoyette The kernel example dynamic modules. 714e25719Spgoyette 8bfd0ff91Skamil This directory contains the following example modules: 9068c592bSkamil * current_time - prints current date and time in GMT/UTC 10bfd0ff91Skamil * executor - basic implementation of callout and RUN_ONCE 112c306a0eSkamil * fopsmapper - basic implementation of mmap with fileops fo_mmap 1214e25719Spgoyette * hello - the simplest `hello world' module 131afdfaefSpgoyette * luahello - the simplest `hello world' Lua module 143906dcf3Ssevan * luareadhappy - demonstrates calling Lua code from C 151514387aSkamil * mapper - basic implementation of mmap 16926e9b7fSkamil * panic_string - shows how panic is being called through a device 17bfd0ff91Skamil * ping - basic ioctl(9) 18920eeb12Skamil * ping_block - basic ioctl(9) with a block device 19926e9b7fSkamil * properties - handle incoming properties during the module load 20*b902ab58Schristos * pollpal - implementation of basic poll(9) using palindrome 21bfd0ff91Skamil * readhappy - basic implementation of read(9) with happy numbers 226a0b9e97Skamil * readhappy_mpsafe- demonstrates how to make a module MPSAFE 23e5c3c7a7Skamil * sysctl - demonstrates adding a sysctl handle dynamically 2414e25719Spgoyette 2514e25719Spgoyette To build the examples you need a local copy of NetBSD sources. You also 2614e25719Spgoyette need the comp set with toolchain. To build the module just enter a 2714e25719Spgoyette directory with example modules and use make(1): 2814e25719Spgoyette 2914e25719Spgoyette # make 3014e25719Spgoyette 3114e25719Spgoyette To load, unload, and stat the module use modload(8), modunload(8) and 3214e25719Spgoyette modstat(8). 3314e25719Spgoyette 3414e25719Spgoyette The S parameter in the Makefile files points to src/sys and it can be 3514e25719Spgoyette overloaded in this way: 3614e25719Spgoyette 3714e25719Spgoyette # make S=/data/netbsd/src/sys 3814e25719Spgoyette 39987836cbSpgoyette The code of a module does not need to be in src/sys unless it uses 4014e25719Spgoyette the autoconf(9) framework. 4114e25719Spgoyette 42987836cbSpgoyette A cross-build of a module for a target platform is possible with the 4314e25719Spgoyette build.sh framework. You need to generate the toolchain and set 4414e25719Spgoyette appropriately PATH to point bin/ in the TOOLDIR path. An example command 4514e25719Spgoyette to cross-build a module with the amd64 toolchain is as follows: 4614e25719Spgoyette 4714e25719Spgoyette # nbmake-amd64 S=/data/netbsd/src/sys 4814e25719Spgoyette 4914e25719Spgoyette 5014e25719Spgoyette The example modules should not be used on a production machine. 5114e25719Spgoyette 52987836cbSpgoyette All modules that create a cdevsw (or bdevsw) should be verified that 53987836cbSpgoyette the major number(s) should not conflict with a real device. 5414e25719Spgoyette 5514e25719SpgoyetteSEE ALSO 5675463389Spgoyette modctl(2), module(7), modload(8), modstat(8), modunload(8), module(9), 5775463389Spgoyette intro(9lua) 5814e25719Spgoyette 5914e25719SpgoyetteHISTORY 6014e25719Spgoyette An example of handling incoming properties first appeared in NetBSD 5.0 6114e25719Spgoyette and was written by Julio Merino with further modifications by Martin 6214e25719Spgoyette Husemann, Adam Hamsik, John Nemeth and Mindaugas Rasiukevicius. 6314e25719Spgoyette 6414e25719Spgoyette This document and additional modules (hello, readhappy, properties, 653906dcf3Ssevan ping, luahello and luareadhappy) first appeared in NetBSD 8.0; they were 663906dcf3Ssevan written by Kamil Rytarowski. 6714e25719Spgoyette 686a0b9e97Skamil The readhappy_mpsafe, executor and sysctls modules first appeared in NetBSD 696a0b9e97Skamil 9.0 and were authored by Siddharth Muralee. 70e5c3c7a7Skamil 71926e9b7fSkamil The panic_string module first appeared in NetBSD 9.0 and was authored by 72926e9b7fSkamil Harry Pantazis. 73926e9b7fSkamil 741514387aSkamil The mapper module first appeared in NetBSD 9.0 and was authored by 751514387aSkamil Akul Pillai. 761514387aSkamil 779ecc7056Skamil The ping_block module first appeared in NetBSD 10.0 and was authored by 789ecc7056Skamil Nisarg Joshi. 799ecc7056Skamil 802c306a0eSkamil The fopsmapper module first appeared in NetBSD 10.0 and was authored by 812c306a0eSkamil Aditya Vardhan Padala. 822c306a0eSkamil 83068c592bSkamil The current_time module first appeared in NetBSD 10.0 and was authored by 84068c592bSkamil Apurva Nandan. 85068c592bSkamil 86*b902ab58Schristos The pollpall module first appeared in NetBSD 10.0 and was authored by 87*b902ab58Schristos Ayushi Sharma. 88*b902ab58Schristos 8914e25719SpgoyetteAUTHORS 9014e25719Spgoyette This document was written by Kamil Rytarowski. 91