14 data using DMA. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
14 data using DMA. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
15 <p>The following diagram shows the general relationship between the various |
15 <p>The following diagram shows the general relationship between the various |
16 classes and structs that form the DMA Framework. The individual items are |
16 classes and structs that form the DMA Framework. The individual items are |
17 described in more detail below. </p> |
17 described in more detail below. </p> |
18 <fig id="GUID-C6B032F0-7E05-5E29-8024-B713C42A2434"> |
18 <fig id="GUID-C6B032F0-7E05-5E29-8024-B713C42A2434"> |
19 <image href="GUID-D43AB2F5-32AE-540C-80D8-DE8B2072F1E6_d0e367729_href.png" placement="inline"/> |
19 <image href="GUID-D43AB2F5-32AE-540C-80D8-DE8B2072F1E6_d0e389226_href.png" placement="inline"/> |
20 </fig> |
20 </fig> |
21 <section id="GUID-D9855D5F-3D4D-5A65-A1BB-B7CB94E60316"><title>The DMA Software |
21 <section id="GUID-D9855D5F-3D4D-5A65-A1BB-B7CB94E60316"><title>The DMA Software |
22 Controller</title> <p>This is the <xref href="GUID-25398075-927B-36E4-B953-16785EC4086C.dita"><apiname>TDmac</apiname></xref> object. It has |
22 Controller</title> <p>This is the <xref href="GUID-25398075-927B-36E4-B953-16785EC4086C.dita"><apiname>TDmac</apiname></xref> object. It has |
23 two purposes: </p> <ul> |
23 two purposes: </p> <ul> |
24 <li id="GUID-E4C8A5C5-192B-5E3E-A2F1-D884BF7FE641"><p>It defines the main |
24 <li id="GUID-E4C8A5C5-192B-5E3E-A2F1-D884BF7FE641"><p>It defines the main |
42 <section id="GUID-34B8E965-9C5C-533E-BFE6-EB9B486A81BB"><title>Descriptors</title> <p>DMA |
42 <section id="GUID-34B8E965-9C5C-533E-BFE6-EB9B486A81BB"><title>Descriptors</title> <p>DMA |
43 controllers operating in scatter/gather mode are configured via a linked list |
43 controllers operating in scatter/gather mode are configured via a linked list |
44 of small data structures describing the data to be transferred. These data |
44 of small data structures describing the data to be transferred. These data |
45 structures are called descriptors. (Note that the use of the term descriptor |
45 structures are called descriptors. (Note that the use of the term descriptor |
46 in the context of DMA should not be confused with the same term widely used |
46 in the context of DMA should not be confused with the same term widely used |
47 in Symbian OS to refer to the family of <xref href="GUID-52D07F46-2162-380C-A775-C3BB335C42F5.dita"><apiname>TDesC</apiname></xref> derived classes). </p> <p>The |
47 in Symbian platform to refer to the family of <xref href="GUID-52D07F46-2162-380C-A775-C3BB335C42F5.dita"><apiname>TDesC</apiname></xref> derived |
48 Symbian platform DMA Framework always uses descriptor data structures to store |
48 classes). </p> <p>The Symbian platform DMA Framework always uses descriptor |
49 transfer-configuration-information, even if the underlying DMA controller |
49 data structures to store transfer-configuration-information, even if the underlying |
50 does not support scatter/gather mode. </p> <p>The following example illustrates |
50 DMA controller does not support scatter/gather mode. </p> <p>The following |
51 the idea: assume that a device driver needs to transfer two disjoint blocks |
51 example illustrates the idea: assume that a device driver needs to transfer |
52 of memory, A and B, into another block C. Block A starts at address 1000 and |
52 two disjoint blocks of memory, A and B, into another block C. Block A starts |
53 is 300 bytes long. Block B starts at address 2000 and is 700 bytes long. The |
53 at address 1000 and is 300 bytes long. Block B starts at address 2000 and |
54 destination buffer C starts at address 5000 and is 1000 bytes long. Assume |
54 is 700 bytes long. The destination buffer C starts at address 5000 and is |
55 that the DMA descriptors are allocated in a pool starting at address 600. |
55 1000 bytes long. Assume that the DMA descriptors are allocated in a pool starting |
56 The following diagram shows the scatter/gather list that the device driver |
56 at address 600. The following diagram shows the scatter/gather list that the |
57 might create: </p> <fig id="GUID-966DC875-FA9E-59E5-A1CA-842F4A82592D"> |
57 device driver might create: </p> <fig id="GUID-966DC875-FA9E-59E5-A1CA-842F4A82592D"> |
58 <image href="GUID-EA0C5715-7CE8-5415-A915-D5701E3C957A_d0e367824_href.png" placement="inline"/> |
58 <image href="GUID-EA0C5715-7CE8-5415-A915-D5701E3C957A_d0e389323_href.png" placement="inline"/> |
59 </fig> <p>If the DMA controller supports the scatter/gather arrangement, then |
59 </fig> <p>If the DMA controller supports the scatter/gather arrangement, then |
60 the framework uses a structure that will be specific to the hardware. This |
60 the framework uses a structure that will be specific to the hardware. This |
61 structure is defined in the platform specific layer. </p> <p>If the DMA controller |
61 structure is defined in the platform specific layer. </p> <p>If the DMA controller |
62 does not support scatter/gather, then the framework uses the generic structure <xref href="GUID-D7934AD9-38F6-325A-A734-F867D886D7C2.dita"><apiname>SDmaPseudoDes</apiname></xref> containing |
62 does not support scatter/gather, then the framework uses the generic structure <xref href="GUID-D7934AD9-38F6-325A-A734-F867D886D7C2.dita"><apiname>SDmaPseudoDes</apiname></xref> containing |
63 the following information: </p> <ul> |
63 the following information: </p> <ul> |
82 to embed additional data in a structure whose layout may be hardware-imposed. </p> <p>Descriptors |
82 to embed additional data in a structure whose layout may be hardware-imposed. </p> <p>Descriptors |
83 and descriptor headers are stored in two parallel arrays allocated at boot-time, |
83 and descriptor headers are stored in two parallel arrays allocated at boot-time, |
84 and each descriptor is always associated with the header of same index, so |
84 and each descriptor is always associated with the header of same index, so |
85 that there is always a one-to-one relationship between the header and the |
85 that there is always a one-to-one relationship between the header and the |
86 descriptor. </p> <fig id="GUID-A635E3EA-883C-5857-8690-E0AE6F43CAC4"> |
86 descriptor. </p> <fig id="GUID-A635E3EA-883C-5857-8690-E0AE6F43CAC4"> |
87 <image href="GUID-99F7E70F-2733-57B2-94F5-A0C0FF9219FE_d0e367880_href.png" placement="inline"/> |
87 <image href="GUID-99F7E70F-2733-57B2-94F5-A0C0FF9219FE_d0e389379_href.png" placement="inline"/> |
88 </fig> <p>In the current design, the only information in the descriptor header |
88 </fig> <p>In the current design, the only information in the descriptor header |
89 is a pointer, <codeph>SDmaDesHdr::iNext</codeph>, that is used to chain headers |
89 is a pointer, <codeph>SDmaDesHdr::iNext</codeph>, that is used to chain headers |
90 together on various lists. So, although the pool of headers is allocated as |
90 together on various lists. So, although the pool of headers is allocated as |
91 an array, they are almost always accessed by following the chain of pointers |
91 an array, they are almost always accessed by following the chain of pointers |
92 linking one header to the next. </p> <p>Descriptors are <i>always</i> accessed |
92 linking one header to the next. </p> <p>Descriptors are <i>always</i> accessed |
117 requests have pointers to the first and last headers in the list. </p> <p>When |
117 requests have pointers to the first and last headers in the list. </p> <p>When |
118 the request is idle, the header list ends with a NULL pointer. This is not |
118 the request is idle, the header list ends with a NULL pointer. This is not |
119 always true when the request is queued (i.e. when the request is being transferred |
119 always true when the request is queued (i.e. when the request is being transferred |
120 or is still pending). The following diagram shows an idle request with three |
120 or is still pending). The following diagram shows an idle request with three |
121 fragments. </p> <fig id="GUID-0A5594BD-05E4-5A97-A3F7-459E3F8638A2"> |
121 fragments. </p> <fig id="GUID-0A5594BD-05E4-5A97-A3F7-459E3F8638A2"> |
122 <image href="GUID-CF252B09-335E-5831-94A6-0B16B64C5030_d0e367966_href.png" placement="inline"/> |
122 <image href="GUID-CF252B09-335E-5831-94A6-0B16B64C5030_d0e389465_href.png" placement="inline"/> |
123 </fig> <p>Splitting a request into fragments is useful because: </p> <ul> |
123 </fig> <p>Splitting a request into fragments is useful because: </p> <ul> |
124 <li id="GUID-BEA0F4C5-4308-54E9-82AB-91570ACC9ADC"><p>it insulates device |
124 <li id="GUID-BEA0F4C5-4308-54E9-82AB-91570ACC9ADC"><p>it insulates device |
125 drivers from the maximum transfer size supported by the underlying DMA controller. </p> </li> |
125 drivers from the maximum transfer size supported by the underlying DMA controller. </p> </li> |
126 <li id="GUID-A768A76B-DD9E-5A25-92D3-23A69299C096"><p>the source and destination |
126 <li id="GUID-A768A76B-DD9E-5A25-92D3-23A69299C096"><p>the source and destination |
127 DMA buffers may not be physically contiguous and thus require fragmenting. </p> </li> |
127 DMA buffers may not be physically contiguous and thus require fragmenting. </p> </li> |
181 channel has a pointer to the header associated with the descriptor being transferred. |
181 channel has a pointer to the header associated with the descriptor being transferred. |
182 The headers of all queued requests are linked together on one linked list. </p> <p>The |
182 The headers of all queued requests are linked together on one linked list. </p> <p>The |
183 following diagram shows a DMA channel with a three-fragment request being |
183 following diagram shows a DMA channel with a three-fragment request being |
184 transferred and a two-fragment one pending. The fragment currently being transferred |
184 transferred and a two-fragment one pending. The fragment currently being transferred |
185 is the second one of the first request. </p> <fig id="GUID-36E11A64-4626-53F9-925C-3DC323DEA895"> |
185 is the second one of the first request. </p> <fig id="GUID-36E11A64-4626-53F9-925C-3DC323DEA895"> |
186 <image href="GUID-86C21C9B-9F08-579F-84E9-CBE46F756373_d0e368079_href.png" placement="inline"/> |
186 <image href="GUID-86C21C9B-9F08-579F-84E9-CBE46F756373_d0e389578_href.png" placement="inline"/> |
187 </fig> <p>The <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita"><apiname>TDmaChannel</apiname></xref> class contains the code and data |
187 </fig> <p>The <xref href="GUID-83882548-FAC5-3EFF-92ED-14D1D9A85D37.dita"><apiname>TDmaChannel</apiname></xref> class contains the code and data |
188 that is common to all of the channel types. The code and data for the specific |
188 that is common to all of the channel types. The code and data for the specific |
189 channel types: single buffer, double buffer, and scatter/gather channels, |
189 channel types: single buffer, double buffer, and scatter/gather channels, |
190 are implemented in the derived classes: <xref href="GUID-A8B4AD1B-770C-363E-A0DE-C78A9786CBDC.dita"><apiname>TDmaSbChannel</apiname></xref>, <xref href="GUID-FD76AF08-6250-3054-8A06-16343E385B23.dita"><apiname>TDmaDbChannel</apiname></xref>, |
190 are implemented in the derived classes: <xref href="GUID-A8B4AD1B-770C-363E-A0DE-C78A9786CBDC.dita"><apiname>TDmaSbChannel</apiname></xref>, <xref href="GUID-FD76AF08-6250-3054-8A06-16343E385B23.dita"><apiname>TDmaDbChannel</apiname></xref>, |
191 and <xref href="GUID-2D4CFBB1-8D64-3CF5-B6F0-B24D16D5BAD4.dita"><apiname>TDmaSgChannel</apiname></xref> respectively. </p> <p><b>TDmaSbChannel |
191 and <xref href="GUID-2D4CFBB1-8D64-3CF5-B6F0-B24D16D5BAD4.dita"><apiname>TDmaSgChannel</apiname></xref> respectively. </p> <p><b>TDmaSbChannel |
192 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
192 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
193 the state machine that <xref href="GUID-A8B4AD1B-770C-363E-A0DE-C78A9786CBDC.dita"><apiname>TDmaSbChannel</apiname></xref> implements to deal |
193 the state machine that <xref href="GUID-A8B4AD1B-770C-363E-A0DE-C78A9786CBDC.dita"><apiname>TDmaSbChannel</apiname></xref> implements to deal |
194 with a single buffer channel. </p> <fig id="GUID-82A8742D-CE5E-5EA2-A19E-6DCA30D9AE61"> |
194 with a single buffer channel. </p> <fig id="GUID-82A8742D-CE5E-5EA2-A19E-6DCA30D9AE61"> |
195 <image href="GUID-85332468-292D-589B-891B-0E7ACBADC7BA_d0e368115_href.png" placement="inline"/> |
195 <image href="GUID-85332468-292D-589B-891B-0E7ACBADC7BA_d0e389614_href.png" placement="inline"/> |
196 </fig> <p><b>TDmaDbChannel |
196 </fig> <p><b>TDmaDbChannel |
197 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
197 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
198 the state machine that <xref href="GUID-FD76AF08-6250-3054-8A06-16343E385B23.dita"><apiname>TDmaDbChannel</apiname></xref> implements to deal |
198 the state machine that <xref href="GUID-FD76AF08-6250-3054-8A06-16343E385B23.dita"><apiname>TDmaDbChannel</apiname></xref> implements to deal |
199 with a double buffer channel. </p> <fig id="GUID-1CF4D292-310C-5D75-9E3B-2DB65217FEEA"> |
199 with a double buffer channel. </p> <fig id="GUID-1CF4D292-310C-5D75-9E3B-2DB65217FEEA"> |
200 <image href="GUID-91958EA5-9444-5895-B4B8-F2C670B81CD7_d0e368132_href.png" placement="inline"/> |
200 <image href="GUID-91958EA5-9444-5895-B4B8-F2C670B81CD7_d0e389631_href.png" placement="inline"/> |
201 </fig> <p><b>TDmaSgChannel |
201 </fig> <p><b>TDmaSgChannel |
202 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
202 State Machine</b> </p> <p>For reference purposes, the following diagram shows |
203 the state machine that <xref href="GUID-2D4CFBB1-8D64-3CF5-B6F0-B24D16D5BAD4.dita"><apiname>TDmaSgChannel</apiname></xref> implements to deal |
203 the state machine that <xref href="GUID-2D4CFBB1-8D64-3CF5-B6F0-B24D16D5BAD4.dita"><apiname>TDmaSgChannel</apiname></xref> implements to deal |
204 with a scatter/gather channel. </p> <fig id="GUID-1206C662-9856-57A1-A0C5-FDF74F2A3BD3"> |
204 with a scatter/gather channel. </p> <fig id="GUID-1206C662-9856-57A1-A0C5-FDF74F2A3BD3"> |
205 <image href="GUID-09EE01E2-BF5E-5302-BA25-46C440ADECF5_d0e368149_href.png" placement="inline"/> |
205 <image href="GUID-09EE01E2-BF5E-5302-BA25-46C440ADECF5_d0e389648_href.png" placement="inline"/> |
206 </fig> </section> |
206 </fig> </section> |
207 <section id="GUID-2F8979D3-A4DC-5919-B027-F8C17739A05D"><title>Streaming and |
207 <section id="GUID-2F8979D3-A4DC-5919-B027-F8C17739A05D"><title>Streaming and |
208 Scatter/Gather DMA Controllers</title> <p>When a transfer request is queued |
208 Scatter/Gather DMA Controllers</title> <p>When a transfer request is queued |
209 onto a channel that is already transferring data, the header descriptor for |
209 onto a channel that is already transferring data, the header descriptor for |
210 the new list of descriptors is appended to the header of the previous request |
210 the new list of descriptors is appended to the header of the previous request |
211 on the queue. If the underlying DMA controller supports hardware descriptors, |
211 on the queue. If the underlying DMA controller supports hardware descriptors, |
212 they must also be linked together. </p> <p>The following diagram shows how |
212 they must also be linked together. </p> <p>The following diagram shows how |
213 headers and descriptors for a new request are appended to the existing ones |
213 headers and descriptors for a new request are appended to the existing ones |
214 for a DMA controller. The dashed arrows represent the new links. </p> <fig id="GUID-7E06E92E-C8D1-53FF-AF03-5B1A3EBC1EA5"> |
214 for a DMA controller. The dashed arrows represent the new links. </p> <fig id="GUID-7E06E92E-C8D1-53FF-AF03-5B1A3EBC1EA5"> |
215 <image href="GUID-28F3F720-A2E0-59C9-8BB4-B6124CFC6C89_d0e368165_href.png" placement="inline"/> |
215 <image href="GUID-28F3F720-A2E0-59C9-8BB4-B6124CFC6C89_d0e389664_href.png" placement="inline"/> |
216 </fig> <p> <i>Note that hardware descriptors are linked together using physical |
216 </fig> <p> <i>Note that hardware descriptors are linked together using physical |
217 addresses, not virtual ones.</i> </p> <p>Linking hardware descriptors together |
217 addresses, not virtual ones.</i> </p> <p>Linking hardware descriptors together |
218 is implemented in the platform specific layer. There are two issues to consider: </p> <ul> |
218 is implemented in the platform specific layer. There are two issues to consider: </p> <ul> |
219 <li id="GUID-4236DD82-FFAD-56D3-B46F-9D2198E0349A"><p>The channel may go idle |
219 <li id="GUID-4236DD82-FFAD-56D3-B46F-9D2198E0349A"><p>The channel may go idle |
220 before the linking is complete, which means that the data for the new request |
220 before the linking is complete, which means that the data for the new request |