|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! |( k7 H! E- E9 O/ A& ?- [code]EDMA sample test application
; c$ F/ A! O* ]# Z - /*
) G& c, v; A, B+ S - * edma_test.c
, ^4 t; U; y$ a1 N# F8 g. v% i$ f - *
& D! W- T7 v* r" j. a - * brief EDMA3 Test Application
1 b2 w( v1 B Z# R - *
+ U; Z& r/ [" Y4 y$ } - * This file contains EDMA3 Test code.
, U f$ U6 X+ i& F. ^ U - *2 J' F" _, x& R; M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( e: S/ R( D t4 p& ]5 h3 G- d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( T2 d8 W& f6 g7 s - * TO CHANGE.
. A6 T+ U8 e! Y - *0 x% f% `! k5 o, L6 ?" u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 [; M7 d8 {$ E6 Q! o3 a( i$ T
- *
% y; |$ a: O. ]* w! d: v# _) i - * This program is free software; you can redistribute it and/or
7 s" ?2 c! t) q& g) i E - * modify it under the terms of the GNU General Public License as" y4 [6 ?) u( {6 d8 u
- * published by the Free Software Foundation version 2.
( H) u0 H, }4 `' u8 n) I* C - *
% u4 j2 ~; A7 Z# k6 s - * This program is distributed "as is" WITHOUT ANY WARRANTY of any# _9 |. Z X6 }3 o& h, l
- * kind, whether express or implied; without even the implied warranty
# n# I" k: P5 b# ` - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& ` r2 B7 V S4 P' Q8 e& x - * GNU General Public License for more details.) t# r. R5 {+ Y* k9 x
- */: [% ]) T6 Z7 g+ I1 E
0 B3 @$ j$ I) o0 b- |- #include <linux/module.h>
! o Q9 ]9 c. |7 @( z - #include <linux/init.h>
5 y) ]/ [8 j1 {0 e: }' b8 p) M - #include <linux/errno.h>
% M3 M: e% R* b H5 b - #include <linux/types.h>' f" U& }, _/ a3 v0 s. L7 K' ^
- #include <linux/interrupt.h>
# }' Y$ m$ E" j* z! A - #include <asm/io.h> K" h9 i6 a( @; d+ P5 M* c
- #include <linux/moduleparam.h>
6 b9 d9 ]) D. f8 l - #include <linux/sysctl.h>
; a J3 C1 U$ J: P - #include <linux/mm.h>, f) H7 R+ Z! l) e, W' Y$ b" b
- #include <linux/dma-mapping.h>
4 U+ I0 @7 u5 S5 r- m - ; Q1 x7 c: ?# K+ x a+ ~+ D
- #include <mach/memory.h>
' D/ r) D& ]+ n. P - #include <mach/hardware.h>
# M( Z8 R0 P" E$ g* ? - #include <mach/irqs.h>
) f% w! t( k1 l z/ p: G' N - #include <asm/hardware/edma.h>
0 i3 n9 t8 y( @3 z* g$ g/ q; z8 n - 9 @; [- w0 }1 Q2 [! `
- #undef EDMA3_DEBUG
' ]% k/ ]& j! O - /*#define EDMA3_DEBUG*/
) N. a+ o5 U# u. V - " Y. W6 h0 r3 G3 L3 y" k! H
- #ifdef EDMA3_DEBUG4 n* v0 U+ v% V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* c. F6 e* U* `9 Q6 w) v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) b1 n6 _8 l. n. W$ f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' t! N5 n# v! {9 `9 @3 V
- #else: B! m8 J9 e5 z W- ?
- #define DMA_PRINTK( x... )- G+ W, n" `7 a. m
- #define DMA_FN_IN0 `! s/ \5 M. L: Z* i
- #define DMA_FN_OUT
. J: q1 G% r7 f: T - #endif5 g" g! X* o$ S4 A5 D
) R% C" \) i6 B3 E" ~- a3 K1 s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ s! K8 k( f4 J- l; e+ k% x7 S* @
- #define STATIC_SHIFT 3
4 x) Q5 |, A: r+ u# E- E& H7 d7 h9 T - #define TCINTEN_SHIFT 20
) E; z) Y* E) n+ Q. N. \ - #define ITCINTEN_SHIFT 21
7 Z" O C7 G/ K {- q4 r- o8 w W - #define TCCHEN_SHIFT 22
+ K* e- |" n( y) |. \1 G* O1 [ - #define ITCCHEN_SHIFT 23. U \4 D0 V' H$ I9 e
- 3 j8 b( s/ @& l6 ~! F, B. N" E( K7 @0 N
- static volatile int irqraised1 = 0;" [+ O6 N& G2 e2 i9 Q
- static volatile int irqraised2 = 0;1 v6 j8 X& F( [! M$ S( z
- : q# W! k! m( J% \5 N
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. B6 ~ F, l. ?- u- {1 j% _9 K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 l) Z6 R [, P& x) P- W, u) p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, H; f+ N# a, T - 3 F+ |$ W9 M, D5 N/ e1 q% U
- dma_addr_t dmaphyssrc1 = 0;
8 w* v4 P3 j. _ - dma_addr_t dmaphyssrc2 = 0;
/ T+ b" g* V1 X9 V! W - dma_addr_t dmaphysdest1 = 0;* a# J7 T# k: q( m$ M
- dma_addr_t dmaphysdest2 = 0;
2 l8 s# }# c" C
( r/ H: \1 h+ W# ]5 \- char *dmabufsrc1 = NULL;# w+ a' X% \- s! B R5 m& s
- char *dmabufsrc2 = NULL;
- K1 b, B$ q8 B/ o( O - char *dmabufdest1 = NULL;6 k$ U& |* ?1 O* c% ^) B
- char *dmabufdest2 = NULL;+ J/ U; i+ U4 K; u1 i9 A, m
, |$ G. n L6 ~) m0 M- static int acnt = 512; z; S0 d! g. \9 i) k
- static int bcnt = 8;+ L; s m0 F \. B/ Z
- static int ccnt = 8;- \4 \: k& S& u( L
. F2 o a% K2 t- module_param(acnt, int, S_IRUGO);
0 z9 E0 Q# R/ r - module_param(bcnt, int, S_IRUGO);
/ ^4 P1 Y) N0 t, Y7 ?7 L - module_param(ccnt, int, S_IRUGO);
复制代码
( ?6 d0 y3 z! ]: h! @+ x. m
3 T; K _9 \# v4 H4 O+ O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& ?' u Y* r2 s/ W; @$ V/ O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
c5 E# @ Q8 R$ t. c6 @" g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
w/ o' ^$ [) \0 W' M) H
! Y9 o7 d/ t, L; G) L3 H
. T) h2 W( w2 u/ u+ n: K |
|