kernel-api.tmpl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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-x86/atomic_32.h
  41. !Iinclude/asm-x86/unaligned_32.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. <sect1><title>Device Resource Management</title>
  76. !Edrivers/base/devres.c
  77. </sect1>
  78. </chapter>
  79. <chapter id="adt">
  80. <title>Data Types</title>
  81. <sect1><title>Doubly Linked Lists</title>
  82. !Iinclude/linux/list.h
  83. </sect1>
  84. </chapter>
  85. <chapter id="libc">
  86. <title>Basic C Library Functions</title>
  87. <para>
  88. When writing drivers, you cannot in general use routines which are
  89. from the C Library. Some of the functions have been found generally
  90. useful and they are listed below. The behaviour of these functions
  91. may vary slightly from those defined by ANSI, and these deviations
  92. are noted in the text.
  93. </para>
  94. <sect1><title>String Conversions</title>
  95. !Ilib/vsprintf.c
  96. !Elib/vsprintf.c
  97. </sect1>
  98. <sect1><title>String Manipulation</title>
  99. <!-- All functions are exported at now
  100. X!Ilib/string.c
  101. -->
  102. !Elib/string.c
  103. </sect1>
  104. <sect1><title>Bit Operations</title>
  105. !Iinclude/asm-x86/bitops_32.h
  106. </sect1>
  107. </chapter>
  108. <chapter id="kernel-lib">
  109. <title>Basic Kernel Library Functions</title>
  110. <para>
  111. The Linux kernel provides more basic utility functions.
  112. </para>
  113. <sect1><title>Bitmap Operations</title>
  114. !Elib/bitmap.c
  115. !Ilib/bitmap.c
  116. </sect1>
  117. <sect1><title>Command-line Parsing</title>
  118. !Elib/cmdline.c
  119. </sect1>
  120. <sect1 id="crc"><title>CRC Functions</title>
  121. !Elib/crc7.c
  122. !Elib/crc16.c
  123. !Elib/crc-itu-t.c
  124. !Elib/crc32.c
  125. !Elib/crc-ccitt.c
  126. </sect1>
  127. </chapter>
  128. <chapter id="mm">
  129. <title>Memory Management in Linux</title>
  130. <sect1><title>The Slab Cache</title>
  131. !Iinclude/linux/slab.h
  132. !Emm/slab.c
  133. </sect1>
  134. <sect1><title>User Space Memory Access</title>
  135. !Iinclude/asm-x86/uaccess_32.h
  136. !Earch/x86/lib/usercopy_32.c
  137. </sect1>
  138. <sect1><title>More Memory Management Functions</title>
  139. !Emm/readahead.c
  140. !Emm/filemap.c
  141. !Emm/memory.c
  142. !Emm/vmalloc.c
  143. !Imm/page_alloc.c
  144. !Emm/mempool.c
  145. !Emm/page-writeback.c
  146. !Emm/truncate.c
  147. </sect1>
  148. </chapter>
  149. <chapter id="ipc">
  150. <title>Kernel IPC facilities</title>
  151. <sect1><title>IPC utilities</title>
  152. !Iipc/util.c
  153. </sect1>
  154. </chapter>
  155. <chapter id="kfifo">
  156. <title>FIFO Buffer</title>
  157. <sect1><title>kfifo interface</title>
  158. !Iinclude/linux/kfifo.h
  159. !Ekernel/kfifo.c
  160. </sect1>
  161. </chapter>
  162. <chapter id="relayfs">
  163. <title>relay interface support</title>
  164. <para>
  165. Relay interface support
  166. is designed to provide an efficient mechanism for tools and
  167. facilities to relay large amounts of data from kernel space to
  168. user space.
  169. </para>
  170. <sect1><title>relay interface</title>
  171. !Ekernel/relay.c
  172. !Ikernel/relay.c
  173. </sect1>
  174. </chapter>
  175. <chapter id="netcore">
  176. <title>Linux Networking</title>
  177. <sect1><title>Networking Base Types</title>
  178. !Iinclude/linux/net.h
  179. </sect1>
  180. <sect1><title>Socket Buffer Functions</title>
  181. !Iinclude/linux/skbuff.h
  182. !Iinclude/net/sock.h
  183. !Enet/socket.c
  184. !Enet/core/skbuff.c
  185. !Enet/core/sock.c
  186. !Enet/core/datagram.c
  187. !Enet/core/stream.c
  188. </sect1>
  189. <sect1><title>Socket Filter</title>
  190. !Enet/core/filter.c
  191. </sect1>
  192. <sect1><title>Generic Network Statistics</title>
  193. !Iinclude/linux/gen_stats.h
  194. !Enet/core/gen_stats.c
  195. !Enet/core/gen_estimator.c
  196. </sect1>
  197. <sect1><title>SUN RPC subsystem</title>
  198. <!-- The !D functionality is not perfect, garbage has to be protected by comments
  199. !Dnet/sunrpc/sunrpc_syms.c
  200. -->
  201. !Enet/sunrpc/xdr.c
  202. !Enet/sunrpc/svcsock.c
  203. !Enet/sunrpc/sched.c
  204. </sect1>
  205. </chapter>
  206. <chapter id="netdev">
  207. <title>Network device support</title>
  208. <sect1><title>Driver Support</title>
  209. !Enet/core/dev.c
  210. !Enet/ethernet/eth.c
  211. !Enet/sched/sch_generic.c
  212. !Iinclude/linux/etherdevice.h
  213. !Iinclude/linux/netdevice.h
  214. </sect1>
  215. <sect1><title>PHY Support</title>
  216. !Edrivers/net/phy/phy.c
  217. !Idrivers/net/phy/phy.c
  218. !Edrivers/net/phy/phy_device.c
  219. !Idrivers/net/phy/phy_device.c
  220. !Edrivers/net/phy/mdio_bus.c
  221. !Idrivers/net/phy/mdio_bus.c
  222. </sect1>
  223. <!-- FIXME: Removed for now since no structured comments in source
  224. <sect1><title>Wireless</title>
  225. X!Enet/core/wireless.c
  226. </sect1>
  227. -->
  228. <sect1><title>Synchronous PPP</title>
  229. !Edrivers/net/wan/syncppp.c
  230. </sect1>
  231. </chapter>
  232. <chapter id="modload">
  233. <title>Module Support</title>
  234. <sect1><title>Module Loading</title>
  235. !Ekernel/kmod.c
  236. </sect1>
  237. <sect1><title>Inter Module support</title>
  238. <para>
  239. Refer to the file kernel/module.c for more information.
  240. </para>
  241. <!-- FIXME: Removed for now since no structured comments in source
  242. X!Ekernel/module.c
  243. -->
  244. </sect1>
  245. </chapter>
  246. <chapter id="hardware">
  247. <title>Hardware Interfaces</title>
  248. <sect1><title>Interrupt Handling</title>
  249. !Ekernel/irq/manage.c
  250. </sect1>
  251. <sect1><title>DMA Channels</title>
  252. !Ekernel/dma.c
  253. </sect1>
  254. <sect1><title>Resources Management</title>
  255. !Ikernel/resource.c
  256. !Ekernel/resource.c
  257. </sect1>
  258. <sect1><title>MTRR Handling</title>
  259. !Earch/x86/kernel/cpu/mtrr/main.c
  260. </sect1>
  261. <sect1><title>PCI Support Library</title>
  262. !Edrivers/pci/pci.c
  263. !Edrivers/pci/pci-driver.c
  264. !Edrivers/pci/remove.c
  265. !Edrivers/pci/pci-acpi.c
  266. !Edrivers/pci/search.c
  267. !Edrivers/pci/msi.c
  268. !Edrivers/pci/bus.c
  269. <!-- FIXME: Removed for now since no structured comments in source
  270. X!Edrivers/pci/hotplug.c
  271. -->
  272. !Edrivers/pci/probe.c
  273. !Edrivers/pci/rom.c
  274. </sect1>
  275. <sect1><title>PCI Hotplug Support Library</title>
  276. !Edrivers/pci/hotplug/pci_hotplug_core.c
  277. </sect1>
  278. <sect1><title>MCA Architecture</title>
  279. <sect2><title>MCA Device Functions</title>
  280. <para>
  281. Refer to the file arch/x86/kernel/mca_32.c for more information.
  282. </para>
  283. <!-- FIXME: Removed for now since no structured comments in source
  284. X!Earch/x86/kernel/mca_32.c
  285. -->
  286. </sect2>
  287. <sect2><title>MCA Bus DMA</title>
  288. !Iinclude/asm-x86/mca_dma.h
  289. </sect2>
  290. </sect1>
  291. </chapter>
  292. <chapter id="firmware">
  293. <title>Firmware Interfaces</title>
  294. <sect1><title>DMI Interfaces</title>
  295. !Edrivers/firmware/dmi_scan.c
  296. </sect1>
  297. <sect1><title>EDD Interfaces</title>
  298. !Idrivers/firmware/edd.c
  299. </sect1>
  300. </chapter>
  301. <chapter id="security">
  302. <title>Security Framework</title>
  303. !Esecurity/security.c
  304. </chapter>
  305. <chapter id="audit">
  306. <title>Audit Interfaces</title>
  307. !Ekernel/audit.c
  308. !Ikernel/auditsc.c
  309. !Ikernel/auditfilter.c
  310. </chapter>
  311. <chapter id="accounting">
  312. <title>Accounting Framework</title>
  313. !Ikernel/acct.c
  314. </chapter>
  315. <chapter id="pmfuncs">
  316. <title>Power Management</title>
  317. !Ekernel/power/pm.c
  318. </chapter>
  319. <chapter id="devdrivers">
  320. <title>Device drivers infrastructure</title>
  321. <sect1><title>Device Drivers Base</title>
  322. <!--
  323. X!Iinclude/linux/device.h
  324. -->
  325. !Edrivers/base/driver.c
  326. !Edrivers/base/core.c
  327. !Edrivers/base/class.c
  328. !Edrivers/base/firmware_class.c
  329. !Edrivers/base/transport_class.c
  330. !Edrivers/base/dmapool.c
  331. <!-- Cannot be included, because
  332. attribute_container_add_class_device_adapter
  333. and attribute_container_classdev_to_container
  334. exceed allowed 44 characters maximum
  335. X!Edrivers/base/attribute_container.c
  336. -->
  337. !Edrivers/base/sys.c
  338. <!--
  339. X!Edrivers/base/interface.c
  340. -->
  341. !Edrivers/base/platform.c
  342. !Edrivers/base/bus.c
  343. </sect1>
  344. <sect1><title>Device Drivers Power Management</title>
  345. !Edrivers/base/power/resume.c
  346. !Edrivers/base/power/suspend.c
  347. </sect1>
  348. <sect1><title>Device Drivers ACPI Support</title>
  349. <!-- Internal functions only
  350. X!Edrivers/acpi/sleep/main.c
  351. X!Edrivers/acpi/sleep/wakeup.c
  352. X!Edrivers/acpi/motherboard.c
  353. X!Edrivers/acpi/bus.c
  354. -->
  355. !Edrivers/acpi/scan.c
  356. !Idrivers/acpi/scan.c
  357. <!-- No correct structured comments
  358. X!Edrivers/acpi/pci_bind.c
  359. -->
  360. </sect1>
  361. <sect1><title>Device drivers PnP support</title>
  362. !Idrivers/pnp/core.c
  363. <!-- No correct structured comments
  364. X!Edrivers/pnp/system.c
  365. -->
  366. !Edrivers/pnp/card.c
  367. !Idrivers/pnp/driver.c
  368. !Edrivers/pnp/manager.c
  369. !Edrivers/pnp/support.c
  370. </sect1>
  371. <sect1><title>Userspace IO devices</title>
  372. !Edrivers/uio/uio.c
  373. !Iinclude/linux/uio_driver.h
  374. </sect1>
  375. </chapter>
  376. <chapter id="blkdev">
  377. <title>Block Devices</title>
  378. !Eblock/ll_rw_blk.c
  379. </chapter>
  380. <chapter id="chrdev">
  381. <title>Char devices</title>
  382. !Efs/char_dev.c
  383. </chapter>
  384. <chapter id="miscdev">
  385. <title>Miscellaneous Devices</title>
  386. !Edrivers/char/misc.c
  387. </chapter>
  388. <chapter id="parportdev">
  389. <title>Parallel Port Devices</title>
  390. !Iinclude/linux/parport.h
  391. !Edrivers/parport/ieee1284.c
  392. !Edrivers/parport/share.c
  393. !Idrivers/parport/daisy.c
  394. </chapter>
  395. <chapter id="message_devices">
  396. <title>Message-based devices</title>
  397. <sect1><title>Fusion message devices</title>
  398. !Edrivers/message/fusion/mptbase.c
  399. !Idrivers/message/fusion/mptbase.c
  400. !Edrivers/message/fusion/mptscsih.c
  401. !Idrivers/message/fusion/mptscsih.c
  402. !Idrivers/message/fusion/mptctl.c
  403. !Idrivers/message/fusion/mptspi.c
  404. !Idrivers/message/fusion/mptfc.c
  405. !Idrivers/message/fusion/mptlan.c
  406. </sect1>
  407. <sect1><title>I2O message devices</title>
  408. !Iinclude/linux/i2o.h
  409. !Idrivers/message/i2o/core.h
  410. !Edrivers/message/i2o/iop.c
  411. !Idrivers/message/i2o/iop.c
  412. !Idrivers/message/i2o/config-osm.c
  413. !Edrivers/message/i2o/exec-osm.c
  414. !Idrivers/message/i2o/exec-osm.c
  415. !Idrivers/message/i2o/bus-osm.c
  416. !Edrivers/message/i2o/device.c
  417. !Idrivers/message/i2o/device.c
  418. !Idrivers/message/i2o/driver.c
  419. !Idrivers/message/i2o/pci.c
  420. !Idrivers/message/i2o/i2o_block.c
  421. !Idrivers/message/i2o/i2o_scsi.c
  422. !Idrivers/message/i2o/i2o_proc.c
  423. </sect1>
  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. <chapter id="input_subsystem">
  527. <title>Input Subsystem</title>
  528. !Iinclude/linux/input.h
  529. !Edrivers/input/input.c
  530. !Edrivers/input/ff-core.c
  531. !Edrivers/input/ff-memless.c
  532. </chapter>
  533. <chapter id="spi">
  534. <title>Serial Peripheral Interface (SPI)</title>
  535. <para>
  536. SPI is the "Serial Peripheral Interface", widely used with
  537. embedded systems because it is a simple and efficient
  538. interface: basically a multiplexed shift register.
  539. Its three signal wires hold a clock (SCK, often in the range
  540. of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
  541. a "Master In, Slave Out" (MISO) data line.
  542. SPI is a full duplex protocol; for each bit shifted out the
  543. MOSI line (one per clock) another is shifted in on the MISO line.
  544. Those bits are assembled into words of various sizes on the
  545. way to and from system memory.
  546. An additional chipselect line is usually active-low (nCS);
  547. four signals are normally used for each peripheral, plus
  548. sometimes an interrupt.
  549. </para>
  550. <para>
  551. The SPI bus facilities listed here provide a generalized
  552. interface to declare SPI busses and devices, manage them
  553. according to the standard Linux driver model, and perform
  554. input/output operations.
  555. At this time, only "master" side interfaces are supported,
  556. where Linux talks to SPI peripherals and does not implement
  557. such a peripheral itself.
  558. (Interfaces to support implementing SPI slaves would
  559. necessarily look different.)
  560. </para>
  561. <para>
  562. The programming interface is structured around two kinds of driver,
  563. and two kinds of device.
  564. A "Controller Driver" abstracts the controller hardware, which may
  565. be as simple as a set of GPIO pins or as complex as a pair of FIFOs
  566. connected to dual DMA engines on the other side of the SPI shift
  567. register (maximizing throughput). Such drivers bridge between
  568. whatever bus they sit on (often the platform bus) and SPI, and
  569. expose the SPI side of their device as a
  570. <structname>struct spi_master</structname>.
  571. SPI devices are children of that master, represented as a
  572. <structname>struct spi_device</structname> and manufactured from
  573. <structname>struct spi_board_info</structname> descriptors which
  574. are usually provided by board-specific initialization code.
  575. A <structname>struct spi_driver</structname> is called a
  576. "Protocol Driver", and is bound to a spi_device using normal
  577. driver model calls.
  578. </para>
  579. <para>
  580. The I/O model is a set of queued messages. Protocol drivers
  581. submit one or more <structname>struct spi_message</structname>
  582. objects, which are processed and completed asynchronously.
  583. (There are synchronous wrappers, however.) Messages are
  584. built from one or more <structname>struct spi_transfer</structname>
  585. objects, each of which wraps a full duplex SPI transfer.
  586. A variety of protocol tweaking options are needed, because
  587. different chips adopt very different policies for how they
  588. use the bits transferred with SPI.
  589. </para>
  590. !Iinclude/linux/spi/spi.h
  591. !Fdrivers/spi/spi.c spi_register_board_info
  592. !Edrivers/spi/spi.c
  593. </chapter>
  594. <chapter id="i2c">
  595. <title>I<superscript>2</superscript>C and SMBus Subsystem</title>
  596. <para>
  597. I<superscript>2</superscript>C (or without fancy typography, "I2C")
  598. is an acronym for the "Inter-IC" bus, a simple bus protocol which is
  599. widely used where low data rate communications suffice.
  600. Since it's also a licensed trademark, some vendors use another
  601. name (such as "Two-Wire Interface", TWI) for the same bus.
  602. I2C only needs two signals (SCL for clock, SDA for data), conserving
  603. board real estate and minimizing signal quality issues.
  604. Most I2C devices use seven bit addresses, and bus speeds of up
  605. to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet
  606. found wide use.
  607. I2C is a multi-master bus; open drain signaling is used to
  608. arbitrate between masters, as well as to handshake and to
  609. synchronize clocks from slower clients.
  610. </para>
  611. <para>
  612. The Linux I2C programming interfaces support only the master
  613. side of bus interactions, not the slave side.
  614. The programming interface is structured around two kinds of driver,
  615. and two kinds of device.
  616. An I2C "Adapter Driver" abstracts the controller hardware; it binds
  617. to a physical device (perhaps a PCI device or platform_device) and
  618. exposes a <structname>struct i2c_adapter</structname> representing
  619. each I2C bus segment it manages.
  620. On each I2C bus segment will be I2C devices represented by a
  621. <structname>struct i2c_client</structname>. Those devices will
  622. be bound to a <structname>struct i2c_driver</structname>,
  623. which should follow the standard Linux driver model.
  624. (At this writing, a legacy model is more widely used.)
  625. There are functions to perform various I2C protocol operations; at
  626. this writing all such functions are usable only from task context.
  627. </para>
  628. <para>
  629. The System Management Bus (SMBus) is a sibling protocol. Most SMBus
  630. systems are also I2C conformant. The electrical constraints are
  631. tighter for SMBus, and it standardizes particular protocol messages
  632. and idioms. Controllers that support I2C can also support most
  633. SMBus operations, but SMBus controllers don't support all the protocol
  634. options that an I2C controller will.
  635. There are functions to perform various SMBus protocol operations,
  636. either using I2C primitives or by issuing SMBus commands to
  637. i2c_adapter devices which don't support those I2C operations.
  638. </para>
  639. !Iinclude/linux/i2c.h
  640. !Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info
  641. !Edrivers/i2c/i2c-core.c
  642. </chapter>
  643. <chapter id="splice">
  644. <title>splice API</title>
  645. <para>
  646. splice is a method for moving blocks of data around inside the
  647. kernel, without continually transferring them between the kernel
  648. and user space.
  649. </para>
  650. !Ffs/splice.c
  651. </chapter>
  652. <chapter id="pipes">
  653. <title>pipes API</title>
  654. <para>
  655. Pipe interfaces are all for in-kernel (builtin image) use.
  656. They are not exported for use by modules.
  657. </para>
  658. !Iinclude/linux/pipe_fs_i.h
  659. !Ffs/pipe.c
  660. </chapter>
  661. </book>