1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Unreliable Guide To Hacking The Linux Kernel</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel"><link rel="next" href="introduction.html" title="Chapter 1. Introduction"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Unreliable Guide To Hacking The Linux Kernel</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="introduction.html">Next</a></td></tr></table><hr></div><div class="book"><div class="titlepage"><div><div><h1 class="title"><a name="lk-hacking-guide"></a>Unreliable Guide To Hacking The Linux Kernel</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Rusty</span> <span class="surname">Russell</span></h3><div class="affiliation"><div class="address"><p><br> 2      <code class="email"><<a class="email" href="mailto:rusty@rustcorp.com.au">rusty@rustcorp.com.au</a>></code><br> 3     </p></div></div></div></div></div><div><p class="releaseinfo"> 4 This is the first release of this document as part of the kernel tarball. 5 </p></div><div><p class="copyright">Copyright © 2005 Rusty Russell</p></div><div><div class="legalnotice"><a name="idp1108752228"></a><p> 6 This documentation is free software; you can redistribute 7 it and/or modify it under the terms of the GNU General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later 10 version. 11 </p><p> 12 This program is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied 14 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 See the GNU General Public License for more details. 16 </p><p> 17 You should have received a copy of the GNU General Public 18 License along with this program; if not, write to the Free 19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 MA 02111-1307 USA 21 </p><p> 22 For more details see the file COPYING in the source 23 distribution of Linux. 24 </p></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="chapter"><a href="introduction.html">1. Introduction</a></span></dt><dt><span class="chapter"><a href="basic-players.html">2. The Players</a></span></dt><dd><dl><dt><span class="sect1"><a href="basic-players.html#basics-usercontext">User Context</a></span></dt><dt><span class="sect1"><a href="basics-hardirqs.html">Hardware Interrupts (Hard IRQs)</a></span></dt><dt><span class="sect1"><a href="basics-softirqs.html">Software Interrupt Context: Softirqs and Tasklets</a></span></dt></dl></dd><dt><span class="chapter"><a href="basic-rules.html">3. Some Basic Rules</a></span></dt><dt><span class="chapter"><a href="ioctls.html">4. ioctls: Not writing a new system call</a></span></dt><dt><span class="chapter"><a href="deadlock-recipes.html">5. Recipes for Deadlock</a></span></dt><dt><span class="chapter"><a href="common-routines.html">6. Common Routines</a></span></dt><dd><dl><dt><span class="sect1"><a href="common-routines.html#routines-printk"> 25 <code class="function">printk()</code> 26 <code class="filename">include/linux/kernel.h</code> 27 </a></span></dt><dt><span class="sect1"><a href="routines-copy.html"> 28 <code class="function">copy_[to/from]_user()</code> 29 / 30 <code class="function">get_user()</code> 31 / 32 <code class="function">put_user()</code> 33 <code class="filename">include/asm/uaccess.h</code> 34 </a></span></dt><dt><span class="sect1"><a href="routines-kmalloc.html"><code class="function">kmalloc()</code>/<code class="function">kfree()</code> 35 <code class="filename">include/linux/slab.h</code></a></span></dt><dt><span class="sect1"><a href="routines-current.html"><code class="function">current</code> 36 <code class="filename">include/asm/current.h</code></a></span></dt><dt><span class="sect1"><a href="routines-udelay.html"><code class="function">mdelay()</code>/<code class="function">udelay()</code> 37 <code class="filename">include/asm/delay.h</code> 38 <code class="filename">include/linux/delay.h</code> 39 </a></span></dt><dt><span class="sect1"><a href="routines-endian.html"><code class="function">cpu_to_be32()</code>/<code class="function">be32_to_cpu()</code>/<code class="function">cpu_to_le32()</code>/<code class="function">le32_to_cpu()</code> 40 <code class="filename">include/asm/byteorder.h</code> 41 </a></span></dt><dt><span class="sect1"><a href="routines-local-irqs.html"><code class="function">local_irq_save()</code>/<code class="function">local_irq_restore()</code> 42 <code class="filename">include/linux/irqflags.h</code> 43 </a></span></dt><dt><span class="sect1"><a href="routines-softirqs.html"><code class="function">local_bh_disable()</code>/<code class="function">local_bh_enable()</code> 44 <code class="filename">include/linux/interrupt.h</code></a></span></dt><dt><span class="sect1"><a href="routines-processorids.html"><code class="function">smp_processor_id</code>() 45 <code class="filename">include/asm/smp.h</code></a></span></dt><dt><span class="sect1"><a href="routines-init.html"><span class="type">__init</span>/<span class="type">__exit</span>/<span class="type">__initdata</span> 46 <code class="filename">include/linux/init.h</code></a></span></dt><dt><span class="sect1"><a href="routines-init-again.html"><code class="function">__initcall()</code>/<code class="function">module_init()</code> 47 <code class="filename">include/linux/init.h</code></a></span></dt><dt><span class="sect1"><a href="routines-moduleexit.html"> <code class="function">module_exit()</code> 48 <code class="filename">include/linux/init.h</code> </a></span></dt><dt><span class="sect1"><a href="routines-module-use-counters.html"> <code class="function">try_module_get()</code>/<code class="function">module_put()</code> 49 <code class="filename">include/linux/module.h</code></a></span></dt></dl></dd><dt><span class="chapter"><a href="queues.html">7. Wait Queues 50 <code class="filename">include/linux/wait.h</code> 51 </a></span></dt><dd><dl><dt><span class="sect1"><a href="queues.html#queue-declaring">Declaring</a></span></dt><dt><span class="sect1"><a href="queue-waitqueue.html">Queuing</a></span></dt><dt><span class="sect1"><a href="queue-waking.html">Waking Up Queued Tasks</a></span></dt></dl></dd><dt><span class="chapter"><a href="atomic-ops.html">8. Atomic Operations</a></span></dt><dt><span class="chapter"><a href="symbols.html">9. Symbols</a></span></dt><dd><dl><dt><span class="sect1"><a href="symbols.html#sym-exportsymbols"><code class="function">EXPORT_SYMBOL()</code> 52 <code class="filename">include/linux/export.h</code></a></span></dt><dt><span class="sect1"><a href="sym-exportsymbols-gpl.html"><code class="function">EXPORT_SYMBOL_GPL()</code> 53 <code class="filename">include/linux/export.h</code></a></span></dt></dl></dd><dt><span class="chapter"><a href="conventions.html">10. Routines and Conventions</a></span></dt><dd><dl><dt><span class="sect1"><a href="conventions.html#conventions-doublelinkedlist">Double-linked lists 54 <code class="filename">include/linux/list.h</code></a></span></dt><dt><span class="sect1"><a href="convention-returns.html">Return Conventions</a></span></dt><dt><span class="sect1"><a href="conventions-borkedcompile.html">Breaking Compilation</a></span></dt><dt><span class="sect1"><a href="conventions-initialising.html">Initializing structure members</a></span></dt><dt><span class="sect1"><a href="conventions-gnu-extns.html">GNU Extensions</a></span></dt><dt><span class="sect1"><a href="conventions-cplusplus.html">C++</a></span></dt><dt><span class="sect1"><a href="conventions-ifdef.html">#if</a></span></dt></dl></dd><dt><span class="chapter"><a href="submitting.html">11. Putting Your Stuff in the Kernel</a></span></dt><dt><span class="chapter"><a href="cantrips.html">12. Kernel Cantrips</a></span></dt><dt><span class="chapter"><a href="credits.html">13. Thanks</a></span></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="introduction.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"> </td><td width="40%" align="right" valign="top"> Chapter 1. Introduction</td></tr></table></div></body></html> 55