|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 H6 y. ~/ V& Y7 @- F! h. `! J- [code]EDMA sample test application0 `9 U$ t" g" V* v
- /*0 r; f% S2 p0 L! ^1 w! n& |. Q
- * edma_test.c
~/ p- w: N% u7 ?$ t - *. V' e. M/ L: T* E- p" L* K
- * brief EDMA3 Test Application
) J( h s9 H6 O- I - *, s7 I" _9 E5 Q
- * This file contains EDMA3 Test code.
7 F; ?2 w, ? ` P - *! h( R0 a+ `8 k3 {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; e+ b! {& d7 r( |6 e* X& {0 f; U8 Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 k6 U: E9 b. o2 @/ L7 u! J- G+ p - * TO CHANGE.
' I* m$ w# k0 }; |& S+ R; W - *
! H. k$ b" |$ ~1 q0 Y$ y4 P" k - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- [" a0 f. A! b* G7 V1 a
- *1 q2 ]2 N/ \$ b4 H7 T
- * This program is free software; you can redistribute it and/or
4 @# _4 K* ]0 F! x0 R9 I - * modify it under the terms of the GNU General Public License as
: k0 Z2 g& s! i- q. o U' c' | - * published by the Free Software Foundation version 2.
; L: B# \2 M8 J1 H* V( _ - *
) r* N+ I V6 [! d' J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) y& M" e2 m. _' ^
- * kind, whether express or implied; without even the implied warranty
! l8 Y, r" A2 B7 K4 V h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: W, {8 {& m2 L* H' I& x - * GNU General Public License for more details.
- Y# N2 C$ W8 I4 S" w - */
. K; ~$ g% `% \# n4 \5 t) [
0 o7 F p& `* |0 A1 D; K3 `% C- #include <linux/module.h>
, p7 _7 ], R/ `( P/ r% {9 ] - #include <linux/init.h>
7 k5 E! L/ ^4 `3 p& r; M: D. ^ - #include <linux/errno.h>
) G$ u/ t; _/ s# G" G& U - #include <linux/types.h>( Q. v+ h' I/ [8 u' |1 X4 n
- #include <linux/interrupt.h>
0 S$ w9 c6 Z4 F4 Y- r; ^ - #include <asm/io.h>
* h+ Z6 K+ C8 M6 U6 Z# C, I# x - #include <linux/moduleparam.h>4 f5 N/ ?" S- J7 u
- #include <linux/sysctl.h>, D' u1 K7 F, [5 e5 [- U5 G
- #include <linux/mm.h>$ E+ x" ]4 A* N
- #include <linux/dma-mapping.h>+ k( X& x! v3 O, T( J; M
+ `' P7 r. i7 P- \: t, X5 z- #include <mach/memory.h>* j2 Y7 g1 ^: m9 v$ {" W
- #include <mach/hardware.h>6 X, m3 \$ k; n+ N. o; Q
- #include <mach/irqs.h>
7 F3 K: P' w1 C. Q, Q - #include <asm/hardware/edma.h>
7 i% v, K" [: m2 l& L0 Z - 9 V; U# p: B9 Y8 f- e; k' w
- #undef EDMA3_DEBUG
; H; d& r- n3 S! \2 N - /*#define EDMA3_DEBUG*/
$ R$ s+ L- Z. W2 G
% z: K; R6 B _5 O6 s7 f+ h- #ifdef EDMA3_DEBUG
, k" u E2 @. ]: }$ z/ b) A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 p) l& F# K( X5 t3 i5 w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 L2 @ m6 L' J- _0 {/ {" r' z0 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 n" s# R# J6 j4 H
- #else& h# i- z" x& u, W m9 y0 ?
- #define DMA_PRINTK( x... )
S, v( V2 T! p l( i& Z - #define DMA_FN_IN
9 N6 w; W3 j/ F T& r4 w0 i B" ~ - #define DMA_FN_OUT
7 s1 q9 Z* Y+ b - #endif
3 a& X) L8 D; n, f# @
# _/ l; W3 t% z O8 Q9 h8 M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 Z8 g' n% z% e' [6 `
- #define STATIC_SHIFT 3
: I3 j5 n0 ?: ?0 k6 Q- v - #define TCINTEN_SHIFT 20
2 `; u B: ]6 R" a4 W& g - #define ITCINTEN_SHIFT 21
* N5 C1 {* j+ m - #define TCCHEN_SHIFT 22
2 N! P1 W9 M- Z) J) ` - #define ITCCHEN_SHIFT 23
' Z6 v- v& c! E) S# V* \ - ( j$ ]4 W& j2 k- o2 }7 e, e
- static volatile int irqraised1 = 0;( L9 s/ C( _ v3 l& V
- static volatile int irqraised2 = 0;- V4 o; o8 R3 u. j' n5 F
- ! v2 b1 r! ~, n, g. y0 H& j" f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 a, M# I/ }" S! U) O- e/ [. h6 c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ P/ a# z& G* C% ^- } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* }/ y$ ]" o" V
. F. g. Q9 u8 n+ q( _ P- dma_addr_t dmaphyssrc1 = 0;: f3 Y& h7 q: V
- dma_addr_t dmaphyssrc2 = 0;4 L7 ^0 U7 i0 _0 }8 O z9 w
- dma_addr_t dmaphysdest1 = 0;* i) \! L5 @& K9 j/ N9 ^
- dma_addr_t dmaphysdest2 = 0;
& i+ B! J: k0 x6 p' k. u0 V
) l+ c. p+ p" M+ n- char *dmabufsrc1 = NULL;
2 F4 ^) w! y% w# P" J- u, x% F - char *dmabufsrc2 = NULL;* [- m6 T5 X; s- J1 q3 r
- char *dmabufdest1 = NULL;
1 s$ N0 C* D- Z) q( f+ i& ^ - char *dmabufdest2 = NULL;
3 Y8 a% M8 {# Y$ t8 n% M - 1 P) I6 k/ i- t) N# F0 C
- static int acnt = 512; r! }: Q) s' L0 {
- static int bcnt = 8;0 Y* f0 j% W" a. G( X
- static int ccnt = 8;
" B9 M0 a9 q( v4 W - # m p1 A+ P1 S2 b: y- `+ l# C
- module_param(acnt, int, S_IRUGO);+ ?/ H' p/ B0 _3 h; {/ E, E! t
- module_param(bcnt, int, S_IRUGO);" c, w) n/ L- ]$ H* q' D0 }$ H
- module_param(ccnt, int, S_IRUGO);
复制代码
) i6 ^1 t k! [
- h3 p& x9 L1 ?& D+ \4 Y- O! j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- r0 \3 e( d/ t. E v9 Garm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 b4 ]0 n- `9 e- Y8 U U7 |7 m1 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 S* O# g, q1 ?0 c* ]! C/ c: X* X8 g3 q
* ]2 g: n- S- A j! I9 L |
|