Pull thermal into release branch
[linux-drm-fsl-dcu.git] / Documentation / DocBook / kernel-api.tmpl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5 <book id="LinuxKernelAPI">
6  <bookinfo>
7   <title>The Linux Kernel API</title>
8   
9   <legalnotice>
10    <para>
11      This documentation is free software; you can redistribute
12      it and/or modify it under the terms of the GNU General Public
13      License as published by the Free Software Foundation; either
14      version 2 of the License, or (at your option) any later
15      version.
16    </para>
17       
18    <para>
19      This program is distributed in the hope that it will be
20      useful, but WITHOUT ANY WARRANTY; without even the implied
21      warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22      See the GNU General Public License for more details.
23    </para>
24       
25    <para>
26      You should have received a copy of the GNU General Public
27      License along with this program; if not, write to the Free
28      Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29      MA 02111-1307 USA
30    </para>
31       
32    <para>
33      For more details see the file COPYING in the source
34      distribution of Linux.
35    </para>
36   </legalnotice>
37  </bookinfo>
38
39 <toc></toc>
40
41   <chapter id="Basics">
42      <title>Driver Basics</title>
43      <sect1><title>Driver Entry and Exit points</title>
44 !Iinclude/linux/init.h
45      </sect1>
46
47      <sect1><title>Atomic and pointer manipulation</title>
48 !Iinclude/asm-i386/atomic.h
49 !Iinclude/asm-i386/unaligned.h
50      </sect1>
51
52      <sect1><title>Delaying, scheduling, and timer routines</title>
53 !Iinclude/linux/sched.h
54 !Ekernel/sched.c
55 !Ekernel/timer.c
56      </sect1>
57      <sect1><title>High-resolution timers</title>
58 !Iinclude/linux/ktime.h
59 !Iinclude/linux/hrtimer.h
60 !Ekernel/hrtimer.c
61      </sect1>
62      <sect1><title>Workqueues and Kevents</title>
63 !Ekernel/workqueue.c
64      </sect1>
65      <sect1><title>Internal Functions</title>
66 !Ikernel/exit.c
67 !Ikernel/signal.c
68 !Iinclude/linux/kthread.h
69 !Ekernel/kthread.c
70      </sect1>
71
72      <sect1><title>Kernel objects manipulation</title>
73 <!--
74 X!Iinclude/linux/kobject.h
75 -->
76 !Elib/kobject.c
77      </sect1>
78
79      <sect1><title>Kernel utility functions</title>
80 !Iinclude/linux/kernel.h
81 !Ekernel/printk.c
82 !Ekernel/panic.c
83 !Ekernel/sys.c
84 !Ekernel/rcupdate.c
85      </sect1>
86
87      <sect1><title>Device Resource Management</title>
88 !Edrivers/base/devres.c
89      </sect1>
90
91   </chapter>
92
93   <chapter id="adt">
94      <title>Data Types</title>
95      <sect1><title>Doubly Linked Lists</title>
96 !Iinclude/linux/list.h
97      </sect1>
98   </chapter>
99
100   <chapter id="libc">
101      <title>Basic C Library Functions</title>
102
103      <para>
104        When writing drivers, you cannot in general use routines which are
105        from the C Library.  Some of the functions have been found generally
106        useful and they are listed below.  The behaviour of these functions
107        may vary slightly from those defined by ANSI, and these deviations
108        are noted in the text.
109      </para>
110
111      <sect1><title>String Conversions</title>
112 !Ilib/vsprintf.c
113 !Elib/vsprintf.c
114      </sect1>
115      <sect1><title>String Manipulation</title>
116 <!-- All functions are exported at now
117 X!Ilib/string.c
118  -->
119 !Elib/string.c
120      </sect1>
121      <sect1><title>Bit Operations</title>
122 !Iinclude/asm-i386/bitops.h
123      </sect1>
124   </chapter>
125
126   <chapter id="kernel-lib">
127      <title>Basic Kernel Library Functions</title>
128
129      <para>
130        The Linux kernel provides more basic utility functions.
131      </para>
132
133      <sect1><title>Bitmap Operations</title>
134 !Elib/bitmap.c
135 !Ilib/bitmap.c
136      </sect1>
137
138      <sect1><title>Command-line Parsing</title>
139 !Elib/cmdline.c
140      </sect1>
141
142      <sect1><title>CRC Functions</title>
143 !Elib/crc16.c
144 !Elib/crc32.c
145 !Elib/crc-ccitt.c
146      </sect1>
147   </chapter>
148
149   <chapter id="mm">
150      <title>Memory Management in Linux</title>
151      <sect1><title>The Slab Cache</title>
152 !Iinclude/linux/slab.h
153 !Emm/slab.c
154      </sect1>
155      <sect1><title>User Space Memory Access</title>
156 !Iinclude/asm-i386/uaccess.h
157 !Earch/i386/lib/usercopy.c
158      </sect1>
159      <sect1><title>More Memory Management Functions</title>
160 !Iinclude/linux/rmap.h
161 !Emm/readahead.c
162 !Emm/filemap.c
163 !Emm/memory.c
164 !Emm/vmalloc.c
165 !Imm/page_alloc.c
166 !Emm/mempool.c
167 !Emm/page-writeback.c
168 !Emm/truncate.c
169      </sect1>
170   </chapter>
171
172
173   <chapter id="ipc">
174      <title>Kernel IPC facilities</title>
175
176      <sect1><title>IPC utilities</title>
177 !Iipc/util.c
178      </sect1>
179   </chapter>
180
181   <chapter id="kfifo">
182      <title>FIFO Buffer</title>
183      <sect1><title>kfifo interface</title>
184 !Iinclude/linux/kfifo.h
185 !Ekernel/kfifo.c
186      </sect1>
187   </chapter>
188
189   <chapter id="relayfs">
190      <title>relay interface support</title>
191
192      <para>
193         Relay interface support
194         is designed to provide an efficient mechanism for tools and
195         facilities to relay large amounts of data from kernel space to
196         user space.
197      </para>
198
199      <sect1><title>relay interface</title>
200 !Ekernel/relay.c
201 !Ikernel/relay.c
202      </sect1>
203   </chapter>
204
205   <chapter id="netcore">
206      <title>Linux Networking</title>
207      <sect1><title>Networking Base Types</title>
208 !Iinclude/linux/net.h
209      </sect1>
210      <sect1><title>Socket Buffer Functions</title>
211 !Iinclude/linux/skbuff.h
212 !Iinclude/net/sock.h
213 !Enet/socket.c
214 !Enet/core/skbuff.c
215 !Enet/core/sock.c
216 !Enet/core/datagram.c
217 !Enet/core/stream.c
218      </sect1>
219      <sect1><title>Socket Filter</title>
220 !Enet/core/filter.c
221      </sect1>
222      <sect1><title>Generic Network Statistics</title>
223 !Iinclude/linux/gen_stats.h
224 !Enet/core/gen_stats.c
225 !Enet/core/gen_estimator.c
226      </sect1>
227      <sect1><title>SUN RPC subsystem</title>
228 <!-- The !D functionality is not perfect, garbage has to be protected by comments
229 !Dnet/sunrpc/sunrpc_syms.c
230 -->
231 !Enet/sunrpc/xdr.c
232 !Enet/sunrpc/svcsock.c
233 !Enet/sunrpc/sched.c
234      </sect1>
235   </chapter>
236
237   <chapter id="netdev">
238      <title>Network device support</title>
239      <sect1><title>Driver Support</title>
240 !Enet/core/dev.c
241 !Enet/ethernet/eth.c
242 !Iinclude/linux/etherdevice.h
243 !Edrivers/net/phy/phy.c
244 !Idrivers/net/phy/phy.c
245 !Edrivers/net/phy/phy_device.c
246 !Idrivers/net/phy/phy_device.c
247 !Edrivers/net/phy/mdio_bus.c
248 !Idrivers/net/phy/mdio_bus.c
249 <!-- FIXME: Removed for now since no structured comments in source
250 X!Enet/core/wireless.c
251 -->
252      </sect1>
253      <sect1><title>Synchronous PPP</title>
254 !Edrivers/net/wan/syncppp.c
255      </sect1>
256   </chapter>
257
258   <chapter id="modload">
259      <title>Module Support</title>
260      <sect1><title>Module Loading</title>
261 !Ekernel/kmod.c
262      </sect1>
263      <sect1><title>Inter Module support</title>
264         <para>
265            Refer to the file kernel/module.c for more information.
266         </para>
267 <!-- FIXME: Removed for now since no structured comments in source
268 X!Ekernel/module.c
269 -->
270      </sect1>
271   </chapter>
272
273   <chapter id="hardware">
274      <title>Hardware Interfaces</title>
275      <sect1><title>Interrupt Handling</title>
276 !Ekernel/irq/manage.c
277      </sect1>
278
279      <sect1><title>DMA Channels</title>
280 !Ekernel/dma.c
281      </sect1>
282
283      <sect1><title>Resources Management</title>
284 !Ikernel/resource.c
285 !Ekernel/resource.c
286      </sect1>
287
288      <sect1><title>MTRR Handling</title>
289 !Earch/i386/kernel/cpu/mtrr/main.c
290      </sect1>
291
292      <sect1><title>PCI Support Library</title>
293 !Edrivers/pci/pci.c
294 !Edrivers/pci/pci-driver.c
295 !Edrivers/pci/remove.c
296 !Edrivers/pci/pci-acpi.c
297 !Edrivers/pci/search.c
298 !Edrivers/pci/msi.c
299 !Edrivers/pci/bus.c
300 <!-- FIXME: Removed for now since no structured comments in source
301 X!Edrivers/pci/hotplug.c
302 -->
303 !Edrivers/pci/probe.c
304 !Edrivers/pci/rom.c
305      </sect1>
306      <sect1><title>PCI Hotplug Support Library</title>
307 !Edrivers/pci/hotplug/pci_hotplug_core.c
308      </sect1>
309      <sect1><title>MCA Architecture</title>
310         <sect2><title>MCA Device Functions</title>
311            <para>
312               Refer to the file arch/i386/kernel/mca.c for more information.
313            </para>
314 <!-- FIXME: Removed for now since no structured comments in source
315 X!Earch/i386/kernel/mca.c
316 -->
317         </sect2>
318         <sect2><title>MCA Bus DMA</title>
319 !Iinclude/asm-i386/mca_dma.h
320         </sect2>
321      </sect1>
322   </chapter>
323
324   <chapter id="firmware">
325      <title>Firmware Interfaces</title>
326      <sect1><title>DMI Interfaces</title>
327 !Edrivers/firmware/dmi_scan.c
328      </sect1>
329      <sect1><title>EDD Interfaces</title>
330 !Idrivers/firmware/edd.c
331      </sect1>
332   </chapter>
333
334   <chapter id="security">
335      <title>Security Framework</title>
336 !Esecurity/security.c
337   </chapter>
338
339   <chapter id="audit">
340      <title>Audit Interfaces</title>
341 !Ekernel/audit.c
342 !Ikernel/auditsc.c
343 !Ikernel/auditfilter.c
344   </chapter>
345
346   <chapter id="accounting">
347      <title>Accounting Framework</title>
348 !Ikernel/acct.c
349   </chapter>
350
351   <chapter id="pmfuncs">
352      <title>Power Management</title>
353 !Ekernel/power/pm.c
354   </chapter>
355
356   <chapter id="devdrivers">
357      <title>Device drivers infrastructure</title>
358      <sect1><title>Device Drivers Base</title>
359 <!--
360 X!Iinclude/linux/device.h
361 -->
362 !Edrivers/base/driver.c
363 !Edrivers/base/core.c
364 !Edrivers/base/class.c
365 !Edrivers/base/firmware_class.c
366 !Edrivers/base/transport_class.c
367 !Edrivers/base/dmapool.c
368 <!-- Cannot be included, because
369      attribute_container_add_class_device_adapter
370  and attribute_container_classdev_to_container
371      exceed allowed 44 characters maximum
372 X!Edrivers/base/attribute_container.c
373 -->
374 !Edrivers/base/sys.c
375 <!--
376 X!Edrivers/base/interface.c
377 -->
378 !Edrivers/base/platform.c
379 !Edrivers/base/bus.c
380      </sect1>
381      <sect1><title>Device Drivers Power Management</title>
382 !Edrivers/base/power/main.c
383 !Edrivers/base/power/resume.c
384 !Edrivers/base/power/suspend.c
385      </sect1>
386      <sect1><title>Device Drivers ACPI Support</title>
387 <!-- Internal functions only
388 X!Edrivers/acpi/sleep/main.c
389 X!Edrivers/acpi/sleep/wakeup.c
390 X!Edrivers/acpi/motherboard.c
391 X!Edrivers/acpi/bus.c
392 -->
393 !Edrivers/acpi/scan.c
394 !Idrivers/acpi/scan.c
395 <!-- No correct structured comments
396 X!Edrivers/acpi/pci_bind.c
397 -->
398      </sect1>
399      <sect1><title>Device drivers PnP support</title>
400 !Edrivers/pnp/core.c
401 <!-- No correct structured comments
402 X!Edrivers/pnp/system.c
403  -->
404 !Edrivers/pnp/card.c
405 !Edrivers/pnp/driver.c
406 !Edrivers/pnp/manager.c
407 !Edrivers/pnp/support.c
408      </sect1>
409   </chapter>
410
411   <chapter id="blkdev">
412      <title>Block Devices</title>
413 !Eblock/ll_rw_blk.c
414   </chapter>
415
416   <chapter id="chrdev">
417         <title>Char devices</title>
418 !Efs/char_dev.c
419   </chapter>
420
421   <chapter id="miscdev">
422      <title>Miscellaneous Devices</title>
423 !Edrivers/char/misc.c
424   </chapter>
425
426   <chapter id="parportdev">
427      <title>Parallel Port Devices</title>
428 !Iinclude/linux/parport.h
429 !Edrivers/parport/ieee1284.c
430 !Edrivers/parport/share.c
431 !Idrivers/parport/daisy.c
432   </chapter>
433
434   <chapter id="message_devices">
435         <title>Message-based devices</title>
436      <sect1><title>Fusion message devices</title>
437 !Edrivers/message/fusion/mptbase.c
438 !Idrivers/message/fusion/mptbase.c
439 !Edrivers/message/fusion/mptscsih.c
440 !Idrivers/message/fusion/mptscsih.c
441 !Idrivers/message/fusion/mptctl.c
442 !Idrivers/message/fusion/mptspi.c
443 !Idrivers/message/fusion/mptfc.c
444 !Idrivers/message/fusion/mptlan.c
445      </sect1>
446      <sect1><title>I2O message devices</title>
447 !Iinclude/linux/i2o.h
448 !Idrivers/message/i2o/core.h
449 !Edrivers/message/i2o/iop.c
450 !Idrivers/message/i2o/iop.c
451 !Idrivers/message/i2o/config-osm.c
452 !Edrivers/message/i2o/exec-osm.c
453 !Idrivers/message/i2o/exec-osm.c
454 !Idrivers/message/i2o/bus-osm.c
455 !Edrivers/message/i2o/device.c
456 !Idrivers/message/i2o/device.c
457 !Idrivers/message/i2o/driver.c
458 !Idrivers/message/i2o/pci.c
459 !Idrivers/message/i2o/i2o_block.c
460 !Idrivers/message/i2o/i2o_scsi.c
461 !Idrivers/message/i2o/i2o_proc.c
462      </sect1>
463   </chapter>
464
465   <chapter id="snddev">
466      <title>Sound Devices</title>
467 !Iinclude/sound/core.h
468 !Esound/sound_core.c
469 !Iinclude/sound/pcm.h
470 !Esound/core/pcm.c
471 !Esound/core/device.c
472 !Esound/core/info.c
473 !Esound/core/rawmidi.c
474 !Esound/core/sound.c
475 !Esound/core/memory.c
476 !Esound/core/pcm_memory.c
477 !Esound/core/init.c
478 !Esound/core/isadma.c
479 !Esound/core/control.c
480 !Esound/core/pcm_lib.c
481 !Esound/core/hwdep.c
482 !Esound/core/pcm_native.c
483 !Esound/core/memalloc.c
484 <!-- FIXME: Removed for now since no structured comments in source
485 X!Isound/sound_firmware.c
486 -->
487   </chapter>
488
489   <chapter id="uart16x50">
490      <title>16x50 UART Driver</title>
491 !Iinclude/linux/serial_core.h
492 !Edrivers/serial/serial_core.c
493 !Edrivers/serial/8250.c
494   </chapter>
495
496   <chapter id="z85230">
497      <title>Z85230 Support Library</title>
498 !Edrivers/net/wan/z85230.c
499   </chapter>
500
501   <chapter id="fbdev">
502      <title>Frame Buffer Library</title>
503
504      <para>
505        The frame buffer drivers depend heavily on four data structures.  
506        These structures are declared in include/linux/fb.h.  They are 
507        fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. 
508        The last three can be made available to and from userland. 
509      </para>
510
511      <para>
512        fb_info defines the current state of a particular video card. 
513        Inside fb_info, there exists a fb_ops structure which is a 
514        collection of needed functions to make fbdev and fbcon work.
515        fb_info is only visible to the kernel.
516      </para>
517
518      <para>
519        fb_var_screeninfo is used to describe the features of a video card 
520        that are user defined.  With fb_var_screeninfo, things such as
521        depth and the resolution may be defined.
522      </para>
523
524      <para>
525        The next structure is fb_fix_screeninfo. This defines the 
526        properties of a card that are created when a mode is set and can't 
527        be changed otherwise.  A good example of this is the start of the 
528        frame buffer memory.  This "locks" the address of the frame buffer
529        memory, so that it cannot be changed or moved.
530      </para>
531
532      <para>
533        The last structure is fb_monospecs. In the old API, there was 
534        little importance for fb_monospecs. This allowed for forbidden things 
535        such as setting a mode of 800x600 on a fix frequency monitor. With 
536        the new API, fb_monospecs prevents such things, and if used 
537        correctly, can prevent a monitor from being cooked.  fb_monospecs
538        will not be useful until kernels 2.5.x.
539      </para>
540
541      <sect1><title>Frame Buffer Memory</title>
542 !Edrivers/video/fbmem.c
543      </sect1>
544 <!--
545      <sect1><title>Frame Buffer Console</title>
546 X!Edrivers/video/console/fbcon.c
547      </sect1>
548 -->
549      <sect1><title>Frame Buffer Colormap</title>
550 !Edrivers/video/fbcmap.c
551      </sect1>
552 <!-- FIXME:
553   drivers/video/fbgen.c has no docs, which stuffs up the sgml.  Comment
554   out until somebody adds docs.  KAO
555      <sect1><title>Frame Buffer Generic Functions</title>
556 X!Idrivers/video/fbgen.c
557      </sect1>
558 KAO -->
559      <sect1><title>Frame Buffer Video Mode Database</title>
560 !Idrivers/video/modedb.c
561 !Edrivers/video/modedb.c
562      </sect1>
563      <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
564 !Edrivers/video/macmodes.c
565      </sect1>
566      <sect1><title>Frame Buffer Fonts</title>
567         <para>
568            Refer to the file drivers/video/console/fonts.c for more information.
569         </para>
570 <!-- FIXME: Removed for now since no structured comments in source
571 X!Idrivers/video/console/fonts.c
572 -->
573      </sect1>
574   </chapter>
575
576   <chapter id="input_subsystem">
577      <title>Input Subsystem</title>
578 !Iinclude/linux/input.h
579 !Edrivers/input/input.c
580 !Edrivers/input/ff-core.c
581 !Edrivers/input/ff-memless.c
582   </chapter>
583
584   <chapter id="spi">
585       <title>Serial Peripheral Interface (SPI)</title>
586   <para>
587         SPI is the "Serial Peripheral Interface", widely used with
588         embedded systems because it is a simple and efficient
589         interface:  basically a multiplexed shift register.
590         Its three signal wires hold a clock (SCK, often in the range
591         of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
592         a "Master In, Slave Out" (MISO) data line.
593         SPI is a full duplex protocol; for each bit shifted out the
594         MOSI line (one per clock) another is shifted in on the MISO line.
595         Those bits are assembled into words of various sizes on the
596         way to and from system memory.
597         An additional chipselect line is usually active-low (nCS);
598         four signals are normally used for each peripheral, plus
599         sometimes an interrupt.
600   </para>
601   <para>
602         The SPI bus facilities listed here provide a generalized
603         interface to declare SPI busses and devices, manage them
604         according to the standard Linux driver model, and perform
605         input/output operations.
606         At this time, only "master" side interfaces are supported,
607         where Linux talks to SPI peripherals and does not implement
608         such a peripheral itself.
609         (Interfaces to support implementing SPI slaves would
610         necessarily look different.)
611   </para>
612   <para>
613         The programming interface is structured around two kinds of driver,
614         and two kinds of device.
615         A "Controller Driver" abstracts the controller hardware, which may
616         be as simple as a set of GPIO pins or as complex as a pair of FIFOs
617         connected to dual DMA engines on the other side of the SPI shift
618         register (maximizing throughput).  Such drivers bridge between
619         whatever bus they sit on (often the platform bus) and SPI, and
620         expose the SPI side of their device as a
621         <structname>struct spi_master</structname>.
622         SPI devices are children of that master, represented as a
623         <structname>struct spi_device</structname> and manufactured from
624         <structname>struct spi_board_info</structname> descriptors which
625         are usually provided by board-specific initialization code.
626         A <structname>struct spi_driver</structname> is called a
627         "Protocol Driver", and is bound to a spi_device using normal
628         driver model calls.
629   </para>
630   <para>
631         The I/O model is a set of queued messages.  Protocol drivers
632         submit one or more <structname>struct spi_message</structname>
633         objects, which are processed and completed asynchronously.
634         (There are synchronous wrappers, however.)  Messages are
635         built from one or more <structname>struct spi_transfer</structname>
636         objects, each of which wraps a full duplex SPI transfer.
637         A variety of protocol tweaking options are needed, because
638         different chips adopt very different policies for how they
639         use the bits transferred with SPI.
640   </para>
641 !Iinclude/linux/spi/spi.h
642 !Fdrivers/spi/spi.c spi_register_board_info
643 !Edrivers/spi/spi.c
644   </chapter>
645
646 </book>