kernel-api.tmpl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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. <book id="LinuxKernelAPI">
  5. <bookinfo>
  6. <title>The Linux Kernel API</title>
  7. <legalnotice>
  8. <para>
  9. This documentation is free software; you can redistribute
  10. it and/or modify it under the terms of the GNU General Public
  11. License as published by the Free Software Foundation; either
  12. version 2 of the License, or (at your option) any later
  13. version.
  14. </para>
  15. <para>
  16. This program is distributed in the hope that it will be
  17. useful, but WITHOUT ANY WARRANTY; without even the implied
  18. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. See the GNU General Public License for more details.
  20. </para>
  21. <para>
  22. You should have received a copy of the GNU General Public
  23. License along with this program; if not, write to the Free
  24. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. MA 02111-1307 USA
  26. </para>
  27. <para>
  28. For more details see the file COPYING in the source
  29. distribution of Linux.
  30. </para>
  31. </legalnotice>
  32. </bookinfo>
  33. <toc></toc>
  34. <chapter id="Basics">
  35. <title>Driver Basics</title>
  36. <sect1><title>Driver Entry and Exit points</title>
  37. !Iinclude/linux/init.h
  38. </sect1>
  39. <sect1><title>Atomic and pointer manipulation</title>
  40. !Iinclude/asm-i386/atomic.h
  41. !Iinclude/asm-i386/unaligned.h
  42. </sect1>
  43. <sect1><title>Delaying, scheduling, and timer routines</title>
  44. !Iinclude/linux/sched.h
  45. !Ekernel/sched.c
  46. !Ekernel/timer.c
  47. </sect1>
  48. <sect1><title>High-resolution timers</title>
  49. !Iinclude/linux/ktime.h
  50. !Iinclude/linux/hrtimer.h
  51. !Ekernel/hrtimer.c
  52. </sect1>
  53. <sect1><title>Workqueues and Kevents</title>
  54. !Ekernel/workqueue.c
  55. </sect1>
  56. <sect1><title>Internal Functions</title>
  57. !Ikernel/exit.c
  58. !Ikernel/signal.c
  59. !Iinclude/linux/kthread.h
  60. !Ekernel/kthread.c
  61. </sect1>
  62. <sect1><title>Kernel objects manipulation</title>
  63. <!--
  64. X!Iinclude/linux/kobject.h
  65. -->
  66. !Elib/kobject.c
  67. </sect1>
  68. <sect1><title>Kernel utility functions</title>
  69. !Iinclude/linux/kernel.h
  70. !Ekernel/printk.c
  71. !Ekernel/panic.c
  72. !Ekernel/sys.c
  73. !Ekernel/rcupdate.c
  74. </sect1>
  75. </chapter>
  76. <chapter id="adt">
  77. <title>Data Types</title>
  78. <sect1><title>Doubly Linked Lists</title>
  79. !Iinclude/linux/list.h
  80. </sect1>
  81. </chapter>
  82. <chapter id="libc">
  83. <title>Basic C Library Functions</title>
  84. <para>
  85. When writing drivers, you cannot in general use routines which are
  86. from the C Library. Some of the functions have been found generally
  87. useful and they are listed below. The behaviour of these functions
  88. may vary slightly from those defined by ANSI, and these deviations
  89. are noted in the text.
  90. </para>
  91. <sect1><title>String Conversions</title>
  92. !Ilib/vsprintf.c
  93. !Elib/vsprintf.c
  94. </sect1>
  95. <sect1><title>String Manipulation</title>
  96. <!-- All functions are exported at now
  97. X!Ilib/string.c
  98. -->
  99. !Elib/string.c
  100. </sect1>
  101. <sect1><title>Bit Operations</title>
  102. !Iinclude/asm-i386/bitops.h
  103. </sect1>
  104. </chapter>
  105. <chapter id="kernel-lib">
  106. <title>Basic Kernel Library Functions</title>
  107. <para>
  108. The Linux kernel provides more basic utility functions.
  109. </para>
  110. <sect1><title>Bitmap Operations</title>
  111. !Elib/bitmap.c
  112. !Ilib/bitmap.c
  113. </sect1>
  114. <sect1><title>Command-line Parsing</title>
  115. !Elib/cmdline.c
  116. </sect1>
  117. <sect1><title>CRC Functions</title>
  118. !Elib/crc16.c
  119. !Elib/crc32.c
  120. !Elib/crc-ccitt.c
  121. </sect1>
  122. </chapter>
  123. <chapter id="mm">
  124. <title>Memory Management in Linux</title>
  125. <sect1><title>The Slab Cache</title>
  126. !Iinclude/linux/slab.h
  127. !Emm/slab.c
  128. </sect1>
  129. <sect1><title>User Space Memory Access</title>
  130. !Iinclude/asm-i386/uaccess.h
  131. !Earch/i386/lib/usercopy.c
  132. </sect1>
  133. <sect1><title>More Memory Management Functions</title>
  134. !Iinclude/linux/rmap.h
  135. !Emm/readahead.c
  136. !Emm/filemap.c
  137. !Emm/memory.c
  138. !Emm/vmalloc.c
  139. !Imm/page_alloc.c
  140. !Emm/mempool.c
  141. !Emm/page-writeback.c
  142. !Emm/truncate.c
  143. </sect1>
  144. </chapter>
  145. <chapter id="ipc">
  146. <title>Kernel IPC facilities</title>
  147. <sect1><title>IPC utilities</title>
  148. !Iipc/util.c
  149. </sect1>
  150. </chapter>
  151. <chapter id="kfifo">
  152. <title>FIFO Buffer</title>
  153. <sect1><title>kfifo interface</title>
  154. !Iinclude/linux/kfifo.h
  155. !Ekernel/kfifo.c
  156. </sect1>
  157. </chapter>
  158. <chapter id="vfs">
  159. <title>The Linux VFS</title>
  160. <sect1><title>The Filesystem types</title>
  161. !Iinclude/linux/fs.h
  162. </sect1>
  163. <sect1><title>The Directory Cache</title>
  164. !Efs/dcache.c
  165. !Iinclude/linux/dcache.h
  166. </sect1>
  167. <sect1><title>Inode Handling</title>
  168. !Efs/inode.c
  169. !Efs/bad_inode.c
  170. </sect1>
  171. <sect1><title>Registration and Superblocks</title>
  172. !Efs/super.c
  173. </sect1>
  174. <sect1><title>File Locks</title>
  175. !Efs/locks.c
  176. !Ifs/locks.c
  177. </sect1>
  178. <sect1><title>Other Functions</title>
  179. !Efs/mpage.c
  180. !Efs/namei.c
  181. !Efs/buffer.c
  182. !Efs/bio.c
  183. !Efs/seq_file.c
  184. !Efs/filesystems.c
  185. !Efs/fs-writeback.c
  186. !Efs/block_dev.c
  187. </sect1>
  188. </chapter>
  189. <chapter id="proc">
  190. <title>The proc filesystem</title>
  191. <sect1><title>sysctl interface</title>
  192. !Ekernel/sysctl.c
  193. </sect1>
  194. <sect1><title>proc filesystem interface</title>
  195. !Ifs/proc/base.c
  196. </sect1>
  197. </chapter>
  198. <chapter id="sysfs">
  199. <title>The Filesystem for Exporting Kernel Objects</title>
  200. !Efs/sysfs/file.c
  201. !Efs/sysfs/symlink.c
  202. !Efs/sysfs/bin.c
  203. </chapter>
  204. <chapter id="debugfs">
  205. <title>The debugfs filesystem</title>
  206. <sect1><title>debugfs interface</title>
  207. !Efs/debugfs/inode.c
  208. !Efs/debugfs/file.c
  209. </sect1>
  210. </chapter>
  211. <chapter id="relayfs">
  212. <title>relay interface support</title>
  213. <para>
  214. Relay interface support
  215. is designed to provide an efficient mechanism for tools and
  216. facilities to relay large amounts of data from kernel space to
  217. user space.
  218. </para>
  219. <sect1><title>relay interface</title>
  220. !Ekernel/relay.c
  221. !Ikernel/relay.c
  222. </sect1>
  223. </chapter>
  224. <chapter id="netcore">
  225. <title>Linux Networking</title>
  226. <sect1><title>Networking Base Types</title>
  227. !Iinclude/linux/net.h
  228. </sect1>
  229. <sect1><title>Socket Buffer Functions</title>
  230. !Iinclude/linux/skbuff.h
  231. !Iinclude/net/sock.h
  232. !Enet/socket.c
  233. !Enet/core/skbuff.c
  234. !Enet/core/sock.c
  235. !Enet/core/datagram.c
  236. !Enet/core/stream.c
  237. </sect1>
  238. <sect1><title>Socket Filter</title>
  239. !Enet/core/filter.c
  240. </sect1>
  241. <sect1><title>Generic Network Statistics</title>
  242. !Iinclude/linux/gen_stats.h
  243. !Enet/core/gen_stats.c
  244. !Enet/core/gen_estimator.c
  245. </sect1>
  246. <sect1><title>SUN RPC subsystem</title>
  247. <!-- The !D functionality is not perfect, garbage has to be protected by comments
  248. !Dnet/sunrpc/sunrpc_syms.c
  249. -->
  250. !Enet/sunrpc/xdr.c
  251. !Enet/sunrpc/svcsock.c
  252. !Enet/sunrpc/sched.c
  253. </sect1>
  254. </chapter>
  255. <chapter id="netdev">
  256. <title>Network device support</title>
  257. <sect1><title>Driver Support</title>
  258. !Enet/core/dev.c
  259. !Enet/ethernet/eth.c
  260. !Iinclude/linux/etherdevice.h
  261. <!-- FIXME: Removed for now since no structured comments in source
  262. X!Enet/core/wireless.c
  263. -->
  264. </sect1>
  265. <sect1><title>Synchronous PPP</title>
  266. !Edrivers/net/wan/syncppp.c
  267. </sect1>
  268. </chapter>
  269. <chapter id="modload">
  270. <title>Module Support</title>
  271. <sect1><title>Module Loading</title>
  272. !Ekernel/kmod.c
  273. </sect1>
  274. <sect1><title>Inter Module support</title>
  275. <para>
  276. Refer to the file kernel/module.c for more information.
  277. </para>
  278. <!-- FIXME: Removed for now since no structured comments in source
  279. X!Ekernel/module.c
  280. -->
  281. </sect1>
  282. </chapter>
  283. <chapter id="hardware">
  284. <title>Hardware Interfaces</title>
  285. <sect1><title>Interrupt Handling</title>
  286. !Ekernel/irq/manage.c
  287. </sect1>
  288. <sect1><title>DMA Channels</title>
  289. !Ekernel/dma.c
  290. </sect1>
  291. <sect1><title>Resources Management</title>
  292. !Ikernel/resource.c
  293. !Ekernel/resource.c
  294. </sect1>
  295. <sect1><title>MTRR Handling</title>
  296. !Earch/i386/kernel/cpu/mtrr/main.c
  297. </sect1>
  298. <sect1><title>PCI Support Library</title>
  299. !Edrivers/pci/pci.c
  300. !Edrivers/pci/pci-driver.c
  301. !Edrivers/pci/remove.c
  302. !Edrivers/pci/pci-acpi.c
  303. !Edrivers/pci/search.c
  304. !Edrivers/pci/msi.c
  305. !Edrivers/pci/bus.c
  306. <!-- FIXME: Removed for now since no structured comments in source
  307. X!Edrivers/pci/hotplug.c
  308. -->
  309. !Edrivers/pci/probe.c
  310. !Edrivers/pci/rom.c
  311. </sect1>
  312. <sect1><title>PCI Hotplug Support Library</title>
  313. !Edrivers/pci/hotplug/pci_hotplug_core.c
  314. </sect1>
  315. <sect1><title>MCA Architecture</title>
  316. <sect2><title>MCA Device Functions</title>
  317. <para>
  318. Refer to the file arch/i386/kernel/mca.c for more information.
  319. </para>
  320. <!-- FIXME: Removed for now since no structured comments in source
  321. X!Earch/i386/kernel/mca.c
  322. -->
  323. </sect2>
  324. <sect2><title>MCA Bus DMA</title>
  325. !Iinclude/asm-i386/mca_dma.h
  326. </sect2>
  327. </sect1>
  328. </chapter>
  329. <chapter id="firmware">
  330. <title>Firmware Interfaces</title>
  331. <sect1><title>DMI Interfaces</title>
  332. !Edrivers/firmware/dmi_scan.c
  333. </sect1>
  334. </chapter>
  335. <chapter id="security">
  336. <title>Security Framework</title>
  337. !Esecurity/security.c
  338. </chapter>
  339. <chapter id="audit">
  340. <title>Audit Interfaces</title>
  341. !Ekernel/audit.c
  342. !Ikernel/auditsc.c
  343. !Ikernel/auditfilter.c
  344. </chapter>
  345. <chapter id="accounting">
  346. <title>Accounting Framework</title>
  347. !Ikernel/acct.c
  348. </chapter>
  349. <chapter id="pmfuncs">
  350. <title>Power Management</title>
  351. !Ekernel/power/pm.c
  352. </chapter>
  353. <chapter id="devdrivers">
  354. <title>Device drivers infrastructure</title>
  355. <sect1><title>Device Drivers Base</title>
  356. <!--
  357. X!Iinclude/linux/device.h
  358. -->
  359. !Edrivers/base/driver.c
  360. !Edrivers/base/core.c
  361. !Edrivers/base/class.c
  362. !Edrivers/base/firmware_class.c
  363. !Edrivers/base/transport_class.c
  364. !Edrivers/base/dmapool.c
  365. <!-- Cannot be included, because
  366. attribute_container_add_class_device_adapter
  367. and attribute_container_classdev_to_container
  368. exceed allowed 44 characters maximum
  369. X!Edrivers/base/attribute_container.c
  370. -->
  371. !Edrivers/base/sys.c
  372. <!--
  373. X!Edrivers/base/interface.c
  374. -->
  375. !Edrivers/base/platform.c
  376. !Edrivers/base/bus.c
  377. </sect1>
  378. <sect1><title>Device Drivers Power Management</title>
  379. !Edrivers/base/power/main.c
  380. !Edrivers/base/power/resume.c
  381. !Edrivers/base/power/suspend.c
  382. </sect1>
  383. <sect1><title>Device Drivers ACPI Support</title>
  384. <!-- Internal functions only
  385. X!Edrivers/acpi/sleep/main.c
  386. X!Edrivers/acpi/sleep/wakeup.c
  387. X!Edrivers/acpi/motherboard.c
  388. X!Edrivers/acpi/bus.c
  389. -->
  390. !Edrivers/acpi/scan.c
  391. !Idrivers/acpi/scan.c
  392. <!-- No correct structured comments
  393. X!Edrivers/acpi/pci_bind.c
  394. -->
  395. </sect1>
  396. <sect1><title>Device drivers PnP support</title>
  397. !Edrivers/pnp/core.c
  398. <!-- No correct structured comments
  399. X!Edrivers/pnp/system.c
  400. -->
  401. !Edrivers/pnp/card.c
  402. !Edrivers/pnp/driver.c
  403. !Edrivers/pnp/manager.c
  404. !Edrivers/pnp/support.c
  405. </sect1>
  406. </chapter>
  407. <chapter id="blkdev">
  408. <title>Block Devices</title>
  409. !Eblock/ll_rw_blk.c
  410. </chapter>
  411. <chapter id="chrdev">
  412. <title>Char devices</title>
  413. !Efs/char_dev.c
  414. </chapter>
  415. <chapter id="miscdev">
  416. <title>Miscellaneous Devices</title>
  417. !Edrivers/char/misc.c
  418. </chapter>
  419. <chapter id="parportdev">
  420. <title>Parallel Port Devices</title>
  421. !Iinclude/linux/parport.h
  422. !Edrivers/parport/ieee1284.c
  423. !Edrivers/parport/share.c
  424. !Idrivers/parport/daisy.c
  425. </chapter>
  426. <chapter id="viddev">
  427. <title>Video4Linux</title>
  428. !Edrivers/media/video/videodev.c
  429. </chapter>
  430. <chapter id="snddev">
  431. <title>Sound Devices</title>
  432. !Iinclude/sound/core.h
  433. !Esound/sound_core.c
  434. !Iinclude/sound/pcm.h
  435. !Esound/core/pcm.c
  436. !Esound/core/device.c
  437. !Esound/core/info.c
  438. !Esound/core/rawmidi.c
  439. !Esound/core/sound.c
  440. !Esound/core/memory.c
  441. !Esound/core/pcm_memory.c
  442. !Esound/core/init.c
  443. !Esound/core/isadma.c
  444. !Esound/core/control.c
  445. !Esound/core/pcm_lib.c
  446. !Esound/core/hwdep.c
  447. !Esound/core/pcm_native.c
  448. !Esound/core/memalloc.c
  449. <!-- FIXME: Removed for now since no structured comments in source
  450. X!Isound/sound_firmware.c
  451. -->
  452. </chapter>
  453. <chapter id="uart16x50">
  454. <title>16x50 UART Driver</title>
  455. !Iinclude/linux/serial_core.h
  456. !Edrivers/serial/serial_core.c
  457. !Edrivers/serial/8250.c
  458. </chapter>
  459. <chapter id="z85230">
  460. <title>Z85230 Support Library</title>
  461. !Edrivers/net/wan/z85230.c
  462. </chapter>
  463. <chapter id="fbdev">
  464. <title>Frame Buffer Library</title>
  465. <para>
  466. The frame buffer drivers depend heavily on four data structures.
  467. These structures are declared in include/linux/fb.h. They are
  468. fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
  469. The last three can be made available to and from userland.
  470. </para>
  471. <para>
  472. fb_info defines the current state of a particular video card.
  473. Inside fb_info, there exists a fb_ops structure which is a
  474. collection of needed functions to make fbdev and fbcon work.
  475. fb_info is only visible to the kernel.
  476. </para>
  477. <para>
  478. fb_var_screeninfo is used to describe the features of a video card
  479. that are user defined. With fb_var_screeninfo, things such as
  480. depth and the resolution may be defined.
  481. </para>
  482. <para>
  483. The next structure is fb_fix_screeninfo. This defines the
  484. properties of a card that are created when a mode is set and can't
  485. be changed otherwise. A good example of this is the start of the
  486. frame buffer memory. This "locks" the address of the frame buffer
  487. memory, so that it cannot be changed or moved.
  488. </para>
  489. <para>
  490. The last structure is fb_monospecs. In the old API, there was
  491. little importance for fb_monospecs. This allowed for forbidden things
  492. such as setting a mode of 800x600 on a fix frequency monitor. With
  493. the new API, fb_monospecs prevents such things, and if used
  494. correctly, can prevent a monitor from being cooked. fb_monospecs
  495. will not be useful until kernels 2.5.x.
  496. </para>
  497. <sect1><title>Frame Buffer Memory</title>
  498. !Edrivers/video/fbmem.c
  499. </sect1>
  500. <!--
  501. <sect1><title>Frame Buffer Console</title>
  502. X!Edrivers/video/console/fbcon.c
  503. </sect1>
  504. -->
  505. <sect1><title>Frame Buffer Colormap</title>
  506. !Edrivers/video/fbcmap.c
  507. </sect1>
  508. <!-- FIXME:
  509. drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
  510. out until somebody adds docs. KAO
  511. <sect1><title>Frame Buffer Generic Functions</title>
  512. X!Idrivers/video/fbgen.c
  513. </sect1>
  514. KAO -->
  515. <sect1><title>Frame Buffer Video Mode Database</title>
  516. !Idrivers/video/modedb.c
  517. !Edrivers/video/modedb.c
  518. </sect1>
  519. <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
  520. !Edrivers/video/macmodes.c
  521. </sect1>
  522. <sect1><title>Frame Buffer Fonts</title>
  523. <para>
  524. Refer to the file drivers/video/console/fonts.c for more information.
  525. </para>
  526. <!-- FIXME: Removed for now since no structured comments in source
  527. X!Idrivers/video/console/fonts.c
  528. -->
  529. </sect1>
  530. </chapter>
  531. </book>