|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, L1 c$ i) v9 y- [code]EDMA sample test application
$ M2 B* s' i" w" C; a - /*0 Y9 B% Z- r9 R
- * edma_test.c
) N5 ]7 c/ z! d! j$ o, } - *
. t! r {! k" q7 C2 b - * brief EDMA3 Test Application9 M# W; {4 x6 r) ^- W) c8 E3 w* c' d
- *
9 F5 Q8 D! c2 G2 Z - * This file contains EDMA3 Test code." |/ c5 |! l2 M; J) m2 g
- *# @8 I Z1 c( i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ i4 S P4 _; q+ E+ o# Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 g5 a) h( S+ a: B0 o# h - * TO CHANGE./ p! r. F* ^7 M5 q9 i2 Z3 w
- *0 ]8 X- ^$ A, H/ h+ S; k7 i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ L+ ]( w8 h) H5 s7 s3 f X( \ - *$ e2 n- w2 L9 u5 b
- * This program is free software; you can redistribute it and/or
/ J6 N1 b ^" M$ I( S - * modify it under the terms of the GNU General Public License as
4 N5 m+ ~+ w7 W, A; g" G* {, T9 i - * published by the Free Software Foundation version 2.! n; m5 Q$ U6 k1 F- [( W
- * B. {# a; K/ f5 W+ c% N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ J) l8 F/ d( O$ F* C - * kind, whether express or implied; without even the implied warranty
% _* s2 r4 }) e9 P+ ~9 e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, o/ n+ a7 ]' k+ ]0 l0 K7 j5 A - * GNU General Public License for more details.
2 L1 O$ t9 z6 \ - */1 }2 c: S/ o1 t! A7 I, t
$ i3 e# O9 C7 q6 k- #include <linux/module.h>2 W8 ~( {2 l9 f3 _
- #include <linux/init.h>
# b3 O3 o/ }7 {3 a: s$ V6 c - #include <linux/errno.h>$ S" C L6 t2 B# h& s4 i# F
- #include <linux/types.h>( x( S0 B- Y& P) ~
- #include <linux/interrupt.h>+ T( q* G* m) p" A
- #include <asm/io.h>0 Z2 r2 q+ L: q' n# v5 @
- #include <linux/moduleparam.h>
; L" `+ Q, A, P+ R- Q9 ?1 t - #include <linux/sysctl.h>+ }$ t+ \, C+ g' l6 Q; i- ]
- #include <linux/mm.h>3 ]- E3 x. s1 A2 z+ c5 L t5 {' m
- #include <linux/dma-mapping.h>' q$ a+ [% G, b2 a, [* ^) K
+ Z( k" O& `7 ~) v% X' C) M, b- #include <mach/memory.h>8 v5 E% h2 n5 M* ]
- #include <mach/hardware.h>
% k$ B' l1 i" v/ J( \ - #include <mach/irqs.h>
6 T2 U! b% F: J# W7 [ - #include <asm/hardware/edma.h>3 J* x: t$ Q+ k2 V: Y, P+ ^1 f$ k
- 8 n4 e. ]' _3 S5 _. K% D
- #undef EDMA3_DEBUG. c6 h% S2 C: I9 ^7 q% f3 d3 N
- /*#define EDMA3_DEBUG*/
- D6 d4 L; z7 k/ x0 b
4 D2 l& h* r- q# H( _" [/ B- #ifdef EDMA3_DEBUG
5 X. i, f; J2 q3 }3 F" F4 Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 U) }7 [5 r& j1 }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 n+ q7 f7 U: Z3 D. V7 x+ m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* x- K$ b$ m: M1 x7 i - #else, \5 g2 v; h+ {) q& j2 }. W) \
- #define DMA_PRINTK( x... )
/ ~7 ]$ t$ z3 l3 ^( o8 f K - #define DMA_FN_IN
8 P* x$ j8 X2 g# S" O$ b - #define DMA_FN_OUT
; V: i/ }& C ]% W9 ?1 l - #endif
0 C$ M; |4 F& J* S) l7 B8 j
% }0 Q' \2 U. }; s* y! h8 b2 |" X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. v3 h+ P* q# a - #define STATIC_SHIFT 3% N% ~4 W+ ?; J1 I3 ^7 f
- #define TCINTEN_SHIFT 207 Q! L/ M+ L' T) C- i: v, K
- #define ITCINTEN_SHIFT 21
+ u! }$ C/ c5 \" u% a0 E, s - #define TCCHEN_SHIFT 22
5 B/ ^' `% X$ ] - #define ITCCHEN_SHIFT 23, D4 z9 c7 y+ J7 ?$ H' Z! H
- ! v5 J2 u3 N. d0 F# [! c- c
- static volatile int irqraised1 = 0;
2 \0 Q3 z9 o3 ~2 s) L4 }4 C0 @ - static volatile int irqraised2 = 0;
# j- D# n4 W: k) u7 o - 9 R. }9 [7 S8 T0 M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: T! q9 [$ G8 d9 S- Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 {4 U( X7 ^" s2 K. w7 d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 O! K/ x4 g0 f. g, j( t/ X
- 7 u) ^9 D% a5 s" i
- dma_addr_t dmaphyssrc1 = 0;
# Z% Z8 z4 @6 q8 `. { - dma_addr_t dmaphyssrc2 = 0;
) J. W& S u$ C' i* z - dma_addr_t dmaphysdest1 = 0;
1 K" G- I6 F5 t0 p - dma_addr_t dmaphysdest2 = 0;, \+ z) t/ S4 ]' t" q. t* g1 w7 q
/ ^6 n& s. x$ d- char *dmabufsrc1 = NULL;3 C7 b) A+ W, a \# Q; ]0 E9 s
- char *dmabufsrc2 = NULL;
! ]$ H5 p4 N# }6 X7 Q, N - char *dmabufdest1 = NULL;
. s% h9 X5 j0 D& [1 w - char *dmabufdest2 = NULL;
8 E( j3 s: h' F
. V# e! v$ x1 f& i" k1 D# \- static int acnt = 512;* _2 \! p$ k2 ~
- static int bcnt = 8;' f+ {+ Y# \+ h
- static int ccnt = 8;
6 E" ?+ w: M2 z; J6 ?7 U) ~. z
1 D2 y% J& L/ f9 @3 \, t7 b- module_param(acnt, int, S_IRUGO);! M9 Q# ~) D) E( f0 [' I
- module_param(bcnt, int, S_IRUGO);! k" s" F0 ?4 Z/ }4 \4 j. S1 N
- module_param(ccnt, int, S_IRUGO);
复制代码
% Y0 C2 w" L, n/ Y' x' K/ c6 N* ^# G" Y' J6 T: A$ b
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ i" |" X4 O& v; w' U% d/ V1 c+ X
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& r! c( f+ H% ~0 C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( D! ]; k, e0 B, F" t
6 Q7 J, ] v1 ?
. l0 P% t! B9 [3 I" p |
|