kernel-api.tmpl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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. !Emm/mempool.c
  140. !Emm/page-writeback.c
  141. !Emm/truncate.c
  142. </sect1>
  143. </chapter>
  144. <chapter id="ipc">
  145. <title>Kernel IPC facilities</title>
  146. <sect1><title>IPC utilities</title>
  147. !Iipc/util.c
  148. </sect1>
  149. </chapter>
  150. <chapter id="kfifo">
  151. <title>FIFO Buffer</title>
  152. <sect1><title>kfifo interface</title>
  153. !Iinclude/linux/kfifo.h
  154. !Ekernel/kfifo.c
  155. </sect1>
  156. </chapter>
  157. <chapter id="vfs">
  158. <title>The Linux VFS</title>
  159. <sect1><title>The Filesystem types</title>
  160. !Iinclude/linux/fs.h
  161. </sect1>
  162. <sect1><title>The Directory Cache</title>
  163. !Efs/dcache.c
  164. !Iinclude/linux/dcache.h
  165. </sect1>
  166. <sect1><title>Inode Handling</title>
  167. !Efs/inode.c
  168. !Efs/bad_inode.c
  169. </sect1>
  170. <sect1><title>Registration and Superblocks</title>
  171. !Efs/super.c
  172. </sect1>
  173. <sect1><title>File Locks</title>
  174. !Efs/locks.c
  175. !Ifs/locks.c
  176. </sect1>
  177. <sect1><title>Other Functions</title>
  178. !Efs/mpage.c
  179. !Efs/namei.c
  180. !Efs/buffer.c
  181. !Efs/bio.c
  182. !Efs/seq_file.c
  183. !Efs/filesystems.c
  184. !Efs/fs-writeback.c
  185. !Efs/block_dev.c
  186. </sect1>
  187. </chapter>
  188. <chapter id="proc">
  189. <title>The proc filesystem</title>
  190. <sect1><title>sysctl interface</title>
  191. !Ekernel/sysctl.c
  192. </sect1>
  193. <sect1><title>proc filesystem interface</title>
  194. !Ifs/proc/base.c
  195. </sect1>
  196. </chapter>
  197. <chapter id="sysfs">
  198. <title>The Filesystem for Exporting Kernel Objects</title>
  199. !Efs/sysfs/file.c
  200. !Efs/sysfs/symlink.c
  201. !Efs/sysfs/bin.c
  202. </chapter>
  203. <chapter id="debugfs">
  204. <title>The debugfs filesystem</title>
  205. <sect1><title>debugfs interface</title>
  206. !Efs/debugfs/inode.c
  207. !Efs/debugfs/file.c
  208. </sect1>
  209. </chapter>
  210. <chapter id="relayfs">
  211. <title>relay interface support</title>
  212. <para>
  213. Relay interface support
  214. is designed to provide an efficient mechanism for tools and
  215. facilities to relay large amounts of data from kernel space to
  216. user space.
  217. </para>
  218. <sect1><title>relay interface</title>
  219. !Ekernel/relay.c
  220. !Ikernel/relay.c
  221. </sect1>
  222. </chapter>
  223. <chapter id="netcore">
  224. <title>Linux Networking</title>
  225. <sect1><title>Networking Base Types</title>
  226. !Iinclude/linux/net.h
  227. </sect1>
  228. <sect1><title>Socket Buffer Functions</title>
  229. !Iinclude/linux/skbuff.h
  230. !Iinclude/net/sock.h
  231. !Enet/socket.c
  232. !Enet/core/skbuff.c
  233. !Enet/core/sock.c
  234. !Enet/core/datagram.c
  235. !Enet/core/stream.c
  236. </sect1>
  237. <sect1><title>Socket Filter</title>
  238. !Enet/core/filter.c
  239. </sect1>
  240. <sect1><title>Generic Network Statistics</title>
  241. !Iinclude/linux/gen_stats.h
  242. !Enet/core/gen_stats.c
  243. !Enet/core/gen_estimator.c
  244. </sect1>
  245. <sect1><title>SUN RPC subsystem</title>
  246. <!-- The !D functionality is not perfect, garbage has to be protected by comments
  247. !Dnet/sunrpc/sunrpc_syms.c
  248. -->
  249. !Enet/sunrpc/xdr.c
  250. !Enet/sunrpc/svcsock.c
  251. !Enet/sunrpc/sched.c
  252. </sect1>
  253. </chapter>
  254. <chapter id="netdev">
  255. <title>Network device support</title>
  256. <sect1><title>Driver Support</title>
  257. !Enet/core/dev.c
  258. !Enet/ethernet/eth.c
  259. !Iinclude/linux/etherdevice.h
  260. <!-- FIXME: Removed for now since no structured comments in source
  261. X!Enet/core/wireless.c
  262. -->
  263. </sect1>
  264. <sect1><title>Synchronous PPP</title>
  265. !Edrivers/net/wan/syncppp.c
  266. </sect1>
  267. </chapter>
  268. <chapter id="modload">
  269. <title>Module Support</title>
  270. <sect1><title>Module Loading</title>
  271. !Ekernel/kmod.c
  272. </sect1>
  273. <sect1><title>Inter Module support</title>
  274. <para>
  275. Refer to the file kernel/module.c for more information.
  276. </para>
  277. <!-- FIXME: Removed for now since no structured comments in source
  278. X!Ekernel/module.c
  279. -->
  280. </sect1>
  281. </chapter>
  282. <chapter id="hardware">
  283. <title>Hardware Interfaces</title>
  284. <sect1><title>Interrupt Handling</title>
  285. !Ekernel/irq/manage.c
  286. </sect1>
  287. <sect1><title>Resources Management</title>
  288. !Ikernel/resource.c
  289. </sect1>
  290. <sect1><title>MTRR Handling</title>
  291. !Earch/i386/kernel/cpu/mtrr/main.c
  292. </sect1>
  293. <sect1><title>PCI Support Library</title>
  294. !Edrivers/pci/pci.c
  295. !Edrivers/pci/pci-driver.c
  296. !Edrivers/pci/remove.c
  297. !Edrivers/pci/pci-acpi.c
  298. !Edrivers/pci/search.c
  299. !Edrivers/pci/msi.c
  300. !Edrivers/pci/bus.c
  301. <!-- FIXME: Removed for now since no structured comments in source
  302. X!Edrivers/pci/hotplug.c
  303. -->
  304. !Edrivers/pci/probe.c
  305. !Edrivers/pci/rom.c
  306. </sect1>
  307. <sect1><title>PCI Hotplug Support Library</title>
  308. !Edrivers/pci/hotplug/pci_hotplug_core.c
  309. </sect1>
  310. <sect1><title>MCA Architecture</title>
  311. <sect2><title>MCA Device Functions</title>
  312. <para>
  313. Refer to the file arch/i386/kernel/mca.c for more information.
  314. </para>
  315. <!-- FIXME: Removed for now since no structured comments in source
  316. X!Earch/i386/kernel/mca.c
  317. -->
  318. </sect2>
  319. <sect2><title>MCA Bus DMA</title>
  320. !Iinclude/asm-i386/mca_dma.h
  321. </sect2>
  322. </sect1>
  323. </chapter>
  324. <chapter id="firmware">
  325. <title>Firmware Interfaces</title>
  326. <sect1><title>DMI Interfaces</title>
  327. !Edrivers/firmware/dmi_scan.c
  328. </sect1>
  329. </chapter>
  330. <chapter id="security">
  331. <title>Security Framework</title>
  332. !Esecurity/security.c
  333. </chapter>
  334. <chapter id="audit">
  335. <title>Audit Interfaces</title>
  336. !Ekernel/audit.c
  337. !Ikernel/auditsc.c
  338. !Ikernel/auditfilter.c
  339. </chapter>
  340. <chapter id="accounting">
  341. <title>Accounting Framework</title>
  342. !Ikernel/acct.c
  343. </chapter>
  344. <chapter id="pmfuncs">
  345. <title>Power Management</title>
  346. !Ekernel/power/pm.c
  347. </chapter>
  348. <chapter id="devdrivers">
  349. <title>Device drivers infrastructure</title>
  350. <sect1><title>Device Drivers Base</title>
  351. <!--
  352. X!Iinclude/linux/device.h
  353. -->
  354. !Edrivers/base/driver.c
  355. !Edrivers/base/core.c
  356. !Edrivers/base/class.c
  357. !Edrivers/base/firmware_class.c
  358. !Edrivers/base/transport_class.c
  359. !Edrivers/base/dmapool.c
  360. <!-- Cannot be included, because
  361. attribute_container_add_class_device_adapter
  362. and attribute_container_classdev_to_container
  363. exceed allowed 44 characters maximum
  364. X!Edrivers/base/attribute_container.c
  365. -->
  366. !Edrivers/base/sys.c
  367. <!--
  368. X!Edrivers/base/interface.c
  369. -->
  370. !Edrivers/base/platform.c
  371. !Edrivers/base/bus.c
  372. </sect1>
  373. <sect1><title>Device Drivers Power Management</title>
  374. !Edrivers/base/power/main.c
  375. !Edrivers/base/power/resume.c
  376. !Edrivers/base/power/suspend.c
  377. </sect1>
  378. <sect1><title>Device Drivers ACPI Support</title>
  379. <!-- Internal functions only
  380. X!Edrivers/acpi/sleep/main.c
  381. X!Edrivers/acpi/sleep/wakeup.c
  382. X!Edrivers/acpi/motherboard.c
  383. X!Edrivers/acpi/bus.c
  384. -->
  385. !Edrivers/acpi/scan.c
  386. !Idrivers/acpi/scan.c
  387. <!-- No correct structured comments
  388. X!Edrivers/acpi/pci_bind.c
  389. -->
  390. </sect1>
  391. <sect1><title>Device drivers PnP support</title>
  392. !Edrivers/pnp/core.c
  393. <!-- No correct structured comments
  394. X!Edrivers/pnp/system.c
  395. -->
  396. !Edrivers/pnp/card.c
  397. !Edrivers/pnp/driver.c
  398. !Edrivers/pnp/manager.c
  399. !Edrivers/pnp/support.c
  400. </sect1>
  401. </chapter>
  402. <chapter id="blkdev">
  403. <title>Block Devices</title>
  404. !Eblock/ll_rw_blk.c
  405. </chapter>
  406. <chapter id="chrdev">
  407. <title>Char devices</title>
  408. !Efs/char_dev.c
  409. </chapter>
  410. <chapter id="miscdev">
  411. <title>Miscellaneous Devices</title>
  412. !Edrivers/char/misc.c
  413. </chapter>
  414. <chapter id="parportdev">
  415. <title>Parallel Port Devices</title>
  416. !Iinclude/linux/parport.h
  417. !Edrivers/parport/ieee1284.c
  418. !Edrivers/parport/share.c
  419. !Idrivers/parport/daisy.c
  420. </chapter>
  421. <chapter id="viddev">
  422. <title>Video4Linux</title>
  423. !Edrivers/media/video/videodev.c
  424. </chapter>
  425. <chapter id="snddev">
  426. <title>Sound Devices</title>
  427. !Iinclude/sound/core.h
  428. !Esound/sound_core.c
  429. !Iinclude/sound/pcm.h
  430. !Esound/core/pcm.c
  431. !Esound/core/device.c
  432. !Esound/core/info.c
  433. !Esound/core/rawmidi.c
  434. !Esound/core/sound.c
  435. !Esound/core/memory.c
  436. !Esound/core/pcm_memory.c
  437. !Esound/core/init.c
  438. !Esound/core/isadma.c
  439. !Esound/core/control.c
  440. !Esound/core/pcm_lib.c
  441. !Esound/core/hwdep.c
  442. !Esound/core/pcm_native.c
  443. !Esound/core/memalloc.c
  444. <!-- FIXME: Removed for now since no structured comments in source
  445. X!Isound/sound_firmware.c
  446. -->
  447. </chapter>
  448. <chapter id="uart16x50">
  449. <title>16x50 UART Driver</title>
  450. !Iinclude/linux/serial_core.h
  451. !Edrivers/serial/serial_core.c
  452. !Edrivers/serial/8250.c
  453. </chapter>
  454. <chapter id="z85230">
  455. <title>Z85230 Support Library</title>
  456. !Edrivers/net/wan/z85230.c
  457. </chapter>
  458. <chapter id="fbdev">
  459. <title>Frame Buffer Library</title>
  460. <para>
  461. The frame buffer drivers depend heavily on four data structures.
  462. These structures are declared in include/linux/fb.h. They are
  463. fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
  464. The last three can be made available to and from userland.
  465. </para>
  466. <para>
  467. fb_info defines the current state of a particular video card.
  468. Inside fb_info, there exists a fb_ops structure which is a
  469. collection of needed functions to make fbdev and fbcon work.
  470. fb_info is only visible to the kernel.
  471. </para>
  472. <para>
  473. fb_var_screeninfo is used to describe the features of a video card
  474. that are user defined. With fb_var_screeninfo, things such as
  475. depth and the resolution may be defined.
  476. </para>
  477. <para>
  478. The next structure is fb_fix_screeninfo. This defines the
  479. properties of a card that are created when a mode is set and can't
  480. be changed otherwise. A good example of this is the start of the
  481. frame buffer memory. This "locks" the address of the frame buffer
  482. memory, so that it cannot be changed or moved.
  483. </para>
  484. <para>
  485. The last structure is fb_monospecs. In the old API, there was
  486. little importance for fb_monospecs. This allowed for forbidden things
  487. such as setting a mode of 800x600 on a fix frequency monitor. With
  488. the new API, fb_monospecs prevents such things, and if used
  489. correctly, can prevent a monitor from being cooked. fb_monospecs
  490. will not be useful until kernels 2.5.x.
  491. </para>
  492. <sect1><title>Frame Buffer Memory</title>
  493. !Edrivers/video/fbmem.c
  494. </sect1>
  495. <!--
  496. <sect1><title>Frame Buffer Console</title>
  497. X!Edrivers/video/console/fbcon.c
  498. </sect1>
  499. -->
  500. <sect1><title>Frame Buffer Colormap</title>
  501. !Edrivers/video/fbcmap.c
  502. </sect1>
  503. <!-- FIXME:
  504. drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
  505. out until somebody adds docs. KAO
  506. <sect1><title>Frame Buffer Generic Functions</title>
  507. X!Idrivers/video/fbgen.c
  508. </sect1>
  509. KAO -->
  510. <sect1><title>Frame Buffer Video Mode Database</title>
  511. !Idrivers/video/modedb.c
  512. !Edrivers/video/modedb.c
  513. </sect1>
  514. <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
  515. !Edrivers/video/macmodes.c
  516. </sect1>
  517. <sect1><title>Frame Buffer Fonts</title>
  518. <para>
  519. Refer to the file drivers/video/console/fonts.c for more information.
  520. </para>
  521. <!-- FIXME: Removed for now since no structured comments in source
  522. X!Idrivers/video/console/fonts.c
  523. -->
  524. </sect1>
  525. </chapter>
  526. </book>