The simplest Linux kernel module-Hello-and its makefile

Source: Internet
Author: User

A simple Linux kernel module. Each row of information is displayed when the user loads and exits. It can be used as a program framework or as a test and load module.

# Include "Linux/init. H "# include" Linux/module. H "// module_license (" GPL "); -- here: the code compiled into the kernel must identify that it complies with open source protocols such as the GPL protocol. The module does not need to use static int mysc_init (void) {printk ("Hello \ n"); Return 0;} static void mysc_exit (void) {printk ("Bye \ n ");} module_init (mysc_init); module_exit (mysc_exit );

The corresponding makefile (not simplified, but can be used .)

Kernelversion = $ (shell uname-R) kerneldir =/lib/modules/$ (kernelversion)/buildcc = gccifneq ($ (kernelrelease),) obj-M: = mysc. oelsepwd :=$ (shell PWD) modules: $ (make)-C $ (kerneldir) M = $ (PWD) modulesmodules_install: $ (make)-C $ (kerneldir) M = $ (PWD) modules_installclean: Rm-RF *. O *~ Core. depend. *. CMD *. Ko *. Mod. C. tmp_versionsendif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.