|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( p. S" q: X6 n( |' c- [code]EDMA sample test application
a% y/ F* q. y* i+ H& W - /*9 k( A& N6 {0 U ?, |/ Q
- * edma_test.c
7 B2 N% ^2 a3 O/ L9 E$ \0 C5 I - *) N) R" N8 m4 i. I( j6 T
- * brief EDMA3 Test Application8 r, E9 }; B+ {7 Y0 _1 Y/ g
- *1 V# l- g* y% P
- * This file contains EDMA3 Test code.
0 `- I4 P7 V3 s3 K4 u - *
4 G7 h8 X8 k+ ]( s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; ^! o6 Z' L5 D1 p& D& h8 x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" Y! ?$ u. I6 d
- * TO CHANGE.' B9 \- N( y% S$ n, Y
- *
0 G" z8 L* t% H5 ]+ U, m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ ?7 \, X- w+ B2 j; s
- *$ M7 Z2 c7 W! ?9 |3 D0 s
- * This program is free software; you can redistribute it and/or
/ i8 \9 R' ?' j, X7 S - * modify it under the terms of the GNU General Public License as+ a' ?5 t& z5 a' d8 I x
- * published by the Free Software Foundation version 2.
6 p1 j: U1 ]9 `. u# {9 B \ - *: u( G, u g5 J( |& k1 M% g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 I$ a9 G6 _. ^) O' w
- * kind, whether express or implied; without even the implied warranty
7 w8 O2 Z& F$ }. U# u4 u) W0 w3 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' J- I4 N3 i8 O0 [: ? - * GNU General Public License for more details.4 J5 z& D4 w+ Y4 j
- */
5 X+ c- R# {6 u5 \2 N, o$ j
5 e& ^; D) p- m8 f7 R- #include <linux/module.h>/ \. Q) I- T* C d, C5 f( b0 Y8 O
- #include <linux/init.h>) S8 e4 r* g' }! k* O
- #include <linux/errno.h>
# h* R3 V$ |3 I8 [; o - #include <linux/types.h>
% Q( Q& j x; E - #include <linux/interrupt.h>1 n5 q" A3 F7 P) ^3 K
- #include <asm/io.h>& D# Z& R, U5 P: c1 y" }
- #include <linux/moduleparam.h>
1 p7 V1 @, h9 K6 O - #include <linux/sysctl.h>4 C% u! |% J/ h- C
- #include <linux/mm.h>
7 J3 {2 F* |8 P# r - #include <linux/dma-mapping.h>
( P8 D% N& w! J2 W
3 U$ d8 v, I$ v) n4 w) v% |- #include <mach/memory.h>% z+ _/ f5 {) r K c h
- #include <mach/hardware.h>& x( i8 A5 c3 Q; G9 E* j
- #include <mach/irqs.h>
7 o2 O" {( r( t+ E1 d& f - #include <asm/hardware/edma.h>
; E; g, O( X% C
8 G$ V9 E$ c6 n/ I% C- #undef EDMA3_DEBUG
$ R: Z7 w6 g' t- S; m8 a/ L - /*#define EDMA3_DEBUG*/6 Z; }$ L. b% ~! L/ A+ Y4 s4 b; X
, b) N! i I+ T( T/ t" j s- h+ Y R- #ifdef EDMA3_DEBUG$ N4 v2 u" m) R( s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 V4 x* S$ [# A2 c4 d9 g- s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), a1 R2 p/ x2 P0 Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ d" a% r" _# `
- #else
; f- H" f$ A3 j - #define DMA_PRINTK( x... )- C, `' _7 R9 w& I$ z5 L
- #define DMA_FN_IN# d% G. l& ]! [; }
- #define DMA_FN_OUT
, ]5 s. W8 A8 [3 L. ] - #endif
1 a% l4 c' r. ~3 G. X+ ^ - # N1 K$ r% ?7 _6 ^2 n" n
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 Y' S6 V- b) R - #define STATIC_SHIFT 3
x( n2 \" H7 y, B4 m9 X - #define TCINTEN_SHIFT 20* I8 I& k9 g5 g" b- J/ W8 B% {
- #define ITCINTEN_SHIFT 218 U& J( w# n3 W" \. I
- #define TCCHEN_SHIFT 22
( a1 u0 O3 ~8 S5 m - #define ITCCHEN_SHIFT 23. \* r+ @% t1 G1 c
$ I# q6 d3 F: X' ^) P# c4 Q- static volatile int irqraised1 = 0;/ i1 P3 k- }) N. D$ R; J
- static volatile int irqraised2 = 0;
" i# ~+ [4 d" f! M
* c8 j. Z# x ~: q6 q x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 u0 O7 ?) H! k3 R/ S4 w* r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% E$ p1 b$ d u. ~. t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: f1 \% ?- |( K( H% k$ o$ v3 i - + L& X* {! z; @1 O2 u
- dma_addr_t dmaphyssrc1 = 0;
1 w3 Q: \- t$ N* P7 F - dma_addr_t dmaphyssrc2 = 0;
. V! n$ E |' x5 H# ]. m - dma_addr_t dmaphysdest1 = 0;
q! e1 `7 M' k6 \+ W* C: V - dma_addr_t dmaphysdest2 = 0;4 r, \! I9 r3 ^9 \
. B) X# U8 i x- char *dmabufsrc1 = NULL;* y, m* h- c$ t2 r( W, B+ e
- char *dmabufsrc2 = NULL;3 \# x7 O6 _7 V; X4 a% c9 U' r
- char *dmabufdest1 = NULL;8 E6 W3 x1 y' C5 p8 \ u9 J5 W
- char *dmabufdest2 = NULL;
3 G; t q1 n* `0 N; h" P
( h. g. M5 q" S/ l ?- static int acnt = 512;1 P; `# ^8 o- X" T
- static int bcnt = 8;
$ j5 D U6 t: x - static int ccnt = 8;
4 X8 ?8 U% {! R- f* X; R
" y8 n# B) u1 F1 @- module_param(acnt, int, S_IRUGO);# a# G0 [& z, D. f
- module_param(bcnt, int, S_IRUGO);
7 g9 r* V+ q& l. z. E5 R3 Y7 P - module_param(ccnt, int, S_IRUGO);
复制代码 ) v, r/ s" M2 {3 w6 @
3 ]( h* w. _- S& N: e 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# a% n6 o5 |8 L* |4 ~1 b5 T. P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 a' t) i# F2 ^, i7 \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( o/ J5 W. {) P7 z# C1 W' o
; [% V3 Y* D$ U7 y/ q6 e. @+ z# q2 a: T( ^( F, u" S1 [
|
|