|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 k& [& W0 D1 X4 p3 p6 E
- [code]EDMA sample test application
2 q- G+ P: w- f- u n u/ L( q, m5 ` - /*/ I% n" a' \ V4 G' ]
- * edma_test.c( V0 g6 {0 N8 R2 E, [
- *$ c3 y* g# ^9 M- V% F" z
- * brief EDMA3 Test Application
# c* M% E' t# k8 D a7 T% e/ Q - *
' a; ]/ S5 e" z$ }" D% z - * This file contains EDMA3 Test code./ {" J$ ~4 V1 F" T3 Y; i
- *
0 l8 m. T& |* _3 t4 l& k0 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 `8 ~, J; c% Q# F! w8 C - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* Y& |. q( C9 L6 N6 i* P
- * TO CHANGE.0 R' P8 E& J3 }6 N/ ]
- *
2 K+ c% J+ g9 l, M% ~1 f* F3 S3 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 I! j: w7 s1 }% B& A; w1 t$ O$ N
- *
7 v! J7 V) z2 F# |0 n - * This program is free software; you can redistribute it and/or5 E/ S8 ?; A8 @; \% l8 ^) ?% F
- * modify it under the terms of the GNU General Public License as
; G$ g4 D+ M9 F5 d - * published by the Free Software Foundation version 2.0 U7 m: p3 I; }. y e9 r) C2 m
- *
9 m9 [( J2 l( o* `5 R; H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 N( l0 ^2 M# o7 [* l) f, H
- * kind, whether express or implied; without even the implied warranty7 ~, N) A' B0 }( `& t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' \" ~% E( k6 P6 ^ - * GNU General Public License for more details.# e! \5 J3 R: Y, q! I$ S( ^0 Q" F
- */" Y& _( h4 `: ^+ o" o: K. }3 R
) i- T9 Q$ v9 `! X- #include <linux/module.h>, @; h6 C, J: f" h) u2 ?
- #include <linux/init.h>; F! d9 E+ ~" S* w/ o# Q; H' h* j
- #include <linux/errno.h>
+ o9 \( @2 {, h3 j( L - #include <linux/types.h>: ?# j) E$ a4 z. x% V! ?
- #include <linux/interrupt.h>% a& r% u2 F h6 `; d( Q, F. G2 E7 k
- #include <asm/io.h>' ]$ q6 U' _6 T5 F% b
- #include <linux/moduleparam.h>1 I7 z& \3 J" {0 y# o5 b2 }8 o/ \0 a
- #include <linux/sysctl.h>
" p- T% B5 g/ r ~' b0 O! M - #include <linux/mm.h>( \$ U0 o1 B8 o" K# X& Z
- #include <linux/dma-mapping.h>5 u" O8 ~- @6 X; P/ J0 P1 E* g
9 q! B. B* X) B2 j# |0 F- #include <mach/memory.h>
7 p2 a, \1 G! B. j - #include <mach/hardware.h>- V0 \: J( T( U' ^
- #include <mach/irqs.h>; n4 Y r1 C. E7 v& `4 [
- #include <asm/hardware/edma.h>
1 ~/ d" A) w" u6 m - 2 l8 t6 p" W! T2 X6 |( [
- #undef EDMA3_DEBUG% \. B! {# U4 ^% N
- /*#define EDMA3_DEBUG*/5 z7 m- P; A$ a& N1 W" A
- " H$ G l0 \, q
- #ifdef EDMA3_DEBUG
' a) M7 ]$ c6 {, E$ \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& q/ N5 ^0 L/ U: j+ R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ H; n6 z6 b% k+ s! d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) n, l& X/ b h v* m& {
- #else: i; f. w6 P: q c. e, q+ q* c7 n
- #define DMA_PRINTK( x... )1 {9 W. ~7 s7 U( I7 \+ u( | I
- #define DMA_FN_IN
: }( Y1 c0 }! D- O - #define DMA_FN_OUT
9 l( T/ i. M7 w! S - #endif: X5 T# a8 A" Y5 m8 l6 j
/ E8 C; s' ~4 j" n- R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 G1 z4 ^; A- R* ^/ }
- #define STATIC_SHIFT 3
2 U' a, y0 u) X" H: c; Y5 j - #define TCINTEN_SHIFT 20
0 A( g) y+ o1 o" p - #define ITCINTEN_SHIFT 21
. F0 f! |( ^7 \* k9 D2 t; l - #define TCCHEN_SHIFT 220 M* X8 c2 k4 u8 W2 u' ?
- #define ITCCHEN_SHIFT 23; A. R* V" w$ i/ P0 `3 B
- 1 V' t2 I) Z( i. b% F
- static volatile int irqraised1 = 0;. o& S4 Q! l, c' V
- static volatile int irqraised2 = 0;
4 y: n3 O9 R. U" m- j2 Q, z
Z- P* f+ D1 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 c! s3 o. x: m2 D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 X1 m2 j0 b, Q4 C: R% R% c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) I+ V1 N8 }( T- G# @* x
' l& r) C3 |8 ~- dma_addr_t dmaphyssrc1 = 0;; i- c3 L9 z0 B
- dma_addr_t dmaphyssrc2 = 0;- K& d+ p; {" d& ]5 }4 m
- dma_addr_t dmaphysdest1 = 0;# h6 s* Q7 |' _1 R4 {
- dma_addr_t dmaphysdest2 = 0;! ^* @6 X+ G% g+ l t
# I4 m- I4 {. ?' v7 \8 G" i- char *dmabufsrc1 = NULL;1 d" x0 i2 t" {' M& Y! H
- char *dmabufsrc2 = NULL;
) N3 J% n) W9 n. q6 |5 `1 m! m9 h - char *dmabufdest1 = NULL;
9 W/ i( o# h: c. o: S9 b - char *dmabufdest2 = NULL;! n; X! P; ?0 B7 ^) S; C# D
- f# j& a4 {7 J/ ^, ?" @* O- static int acnt = 512;3 Y4 w" d; ^, `. j; Z: Z3 R
- static int bcnt = 8;5 A! u7 [/ _' H4 ]/ j) S# e0 Q
- static int ccnt = 8;, K! o9 C% q: d+ e$ Y4 p
) U$ T" c* `( t r+ x- module_param(acnt, int, S_IRUGO);# p7 j9 d4 _* t
- module_param(bcnt, int, S_IRUGO);
/ b ^1 q0 t. G* x+ h - module_param(ccnt, int, S_IRUGO);
复制代码 . J( P5 n; f2 E) i
& N" R' K$ w) i P1 ~3 o8 Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& R) E: g5 x/ K) v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( b: w$ N P0 B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 d/ a7 L: q( U* F5 X3 [: ^6 O
5 V+ h; p* {( F7 ]1 X" l: L1 r
) J+ Q! Q$ h r/ F5 [ |
|