kernel-api.tmpl 14 KB

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