|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 z1 K) Y# E- b* }3 I
- [code]EDMA sample test application) b, N+ L& t- ^
- /*
5 l; y2 `- U( K - * edma_test.c
2 Y5 m7 H, {$ l; i - *0 G6 y6 J' m5 Q
- * brief EDMA3 Test Application- t4 _+ t6 C' M% E9 a2 t& y
- */ O2 n' j8 Y) ]* v: y
- * This file contains EDMA3 Test code.
9 p* ]+ N7 ~; }2 O+ {$ q, a; n - *: {* c( f% L$ k2 w0 H8 H9 H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" e( f* R: b. N9 Q8 o, Q5 n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 x) u* y6 Z. I7 m' H; t& g
- * TO CHANGE.
5 e" G, B" f- c- L: X - *+ o5 }( I( o$ P+ F- ]) _ v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 ?$ U7 o" E1 ], J% B - *
~7 L4 p( q% @7 X% O; K! Q - * This program is free software; you can redistribute it and/or
) w! g, d; n/ `6 R$ g - * modify it under the terms of the GNU General Public License as
7 L1 B! p+ U! O0 f& v$ S - * published by the Free Software Foundation version 2.! ]+ {1 d+ N& n$ o
- *
$ C* x1 |9 u. }0 E+ g8 m* R0 H. B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 i, S+ v# r# L% x+ J8 Q9 V1 o
- * kind, whether express or implied; without even the implied warranty( M& _+ H+ A+ T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: u/ `: Z& G; @( h6 B
- * GNU General Public License for more details.% e3 V( ~- G- b' ^" u' q) p3 \5 ?
- */2 o# c8 n! y6 _: X0 i) K3 c8 ?
- 3 @' e2 M' }, K2 L6 {- C. |* }# N5 H
- #include <linux/module.h>/ H% R6 J' B: |2 p/ [
- #include <linux/init.h>
2 S$ U. X6 H( ] } - #include <linux/errno.h>4 F0 W3 `3 e- ? D
- #include <linux/types.h>
2 i, q& y9 P! V, {* Q' ^ - #include <linux/interrupt.h>
) K7 M! K K' f6 I - #include <asm/io.h>
+ A3 D, y' ^! I% G7 I) \) n4 y - #include <linux/moduleparam.h>! L7 L& l! ]5 n; M" M
- #include <linux/sysctl.h>. U9 `$ ?; y1 Y& x# s
- #include <linux/mm.h>8 p' Y8 x) {5 l: p/ n
- #include <linux/dma-mapping.h>
4 \$ N. @. w* {, w
/ T6 P8 t; {* S- #include <mach/memory.h>: \# Z, f* O a( m* y& H
- #include <mach/hardware.h>8 }' \0 u$ F3 B5 b% B
- #include <mach/irqs.h>
# `9 _& q$ u( j0 w( N" Z - #include <asm/hardware/edma.h>
( _9 [% R- E: {" [. |4 J9 I- e) ^6 \
: j/ ]! V2 [; w1 B; d: g' A- #undef EDMA3_DEBUG
- Q0 S1 q: \9 T" U0 o - /*#define EDMA3_DEBUG*/
# M% Y U4 c0 d$ _+ y U- } - ! o$ v/ C) P- S
- #ifdef EDMA3_DEBUG I$ o) R& k. s0 W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ K3 p) Y5 P( g1 s, W/ I9 c$ i% Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
^2 K# q/ E. |7 b) } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 E! q# W9 `% H3 m
- #else
% o6 a; Z, d1 b( m5 r' |& D6 h - #define DMA_PRINTK( x... )
2 {0 j: u6 x% e- a8 d+ O" V/ O - #define DMA_FN_IN; s# b! N" ^8 e: @' L7 f& t
- #define DMA_FN_OUT% @' z* u! ]4 {7 r3 e4 j
- #endif( J7 P+ j" |* a1 v
- R" m$ ^+ `* g3 F) j! g( e( A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 g5 x" A: k, d1 R" A3 J
- #define STATIC_SHIFT 38 O! o3 c& k6 p8 F- f( j4 k1 R
- #define TCINTEN_SHIFT 20
6 W7 c( y% |# E! n& K - #define ITCINTEN_SHIFT 21" A# C5 S* E! i0 m1 K2 \3 o8 e9 Y
- #define TCCHEN_SHIFT 22' H6 m0 ^7 w# @4 o
- #define ITCCHEN_SHIFT 23, X" l3 e; Q6 H+ X( Q8 h& i, H
- ; n1 e) F1 _! f( q' M4 r
- static volatile int irqraised1 = 0;5 k! J* L V+ V2 P0 W$ M; V
- static volatile int irqraised2 = 0;5 z2 Y6 X) D1 l, }" o) u N0 T* u1 C
* O2 A( D& {$ ?& U2 p' m, ~+ p. C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- @8 |! s$ W5 A0 [ I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
m; t% o, ]5 _: e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" ?& }. s* f3 L
& T, [0 \" S0 }, J8 g0 d- dma_addr_t dmaphyssrc1 = 0;
( [2 j' o# U5 }( E7 Q2 |/ b - dma_addr_t dmaphyssrc2 = 0;' R2 L7 O' b X P
- dma_addr_t dmaphysdest1 = 0;
|2 K( Q% m/ |6 ~ - dma_addr_t dmaphysdest2 = 0;
7 I( j' G. F" K* p1 I* w! @$ P
2 S4 b6 Y* W# A. r- char *dmabufsrc1 = NULL;
2 D! i0 Y' w2 z; V - char *dmabufsrc2 = NULL;
; A! Y& c+ f2 X* @ - char *dmabufdest1 = NULL;
; _) o5 D7 T: I. y9 n/ y, M - char *dmabufdest2 = NULL;+ n" X0 M( @! H! T, a4 e
- 1 I' [, \- y7 y3 Z
- static int acnt = 512;
; {. n+ e$ f2 d8 p6 |' \4 k4 E, T$ i - static int bcnt = 8;: ~; \/ H) b* P% N" T5 T
- static int ccnt = 8;
]0 p9 X) | d
, d4 F% L8 T7 A" x% U* a& K9 ^4 r- module_param(acnt, int, S_IRUGO);
; S) N: C2 E3 R* c0 a - module_param(bcnt, int, S_IRUGO);% T4 y, X- D. ]6 l1 E; T
- module_param(ccnt, int, S_IRUGO);
复制代码
) @. ?3 V3 q, ^- W: I/ B( n2 W" G
5 Y; I" {$ ]4 O8 Q1 P& N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) y; Q5 Y! F8 E% S' L' l2 Y1 L& o7 {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' w' L7 l- `+ D" v! U; t8 r2 C* F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 L, Q. s4 h) i- A: A W5 b, }/ Z0 f( M1 o# X3 z
6 f7 K+ D% f* `* N9 p3 g
|
|