|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 M8 Q8 c$ v/ n P' {+ r- [code]EDMA sample test application
, a& N: ], ^; m( i5 Z - /*
* @$ H5 c( @" ~# I/ c# o2 i: ~ - * edma_test.c
' u. |1 C' u* ~8 ?' ^ - *
3 ^+ m' l4 }1 A: W - * brief EDMA3 Test Application
) V, ~% f1 M- U- D1 C - *3 p, t$ w' K% x9 R& n1 K) p6 O
- * This file contains EDMA3 Test code.. y" x0 K) z* k. p9 H4 y
- *
: |7 A# n F, Q$ @4 l4 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 l. }, R5 ?8 }, Q; U# b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT @/ i4 s3 a* ?) W
- * TO CHANGE.
s5 s. D9 k+ j0 z @+ N( T- k - *
" F J. f% ^" ?% K) ~6 X X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 ?) R5 x! c: ?3 t% K
- *
1 Y. M8 ^$ V: V4 o# E( X9 H! l - * This program is free software; you can redistribute it and/or
2 e4 X* }* o% x! z - * modify it under the terms of the GNU General Public License as4 ` n! P- N$ d7 c5 _- ?6 ^
- * published by the Free Software Foundation version 2.
# j8 f3 I. Y$ W. h - *
: Y; k8 h! u& D" H; u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! K! \, O6 `; S: s! U
- * kind, whether express or implied; without even the implied warranty
. }5 D" b* U5 l$ c' O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; @* E: x3 p p7 y- L - * GNU General Public License for more details.. M; J- J* I+ W, e
- */
) M. K- z$ W* s/ M5 x' }9 R
" T' M% b4 y/ X3 L# ^0 v1 D3 t5 t$ t: V- #include <linux/module.h>
9 @. |6 x g" i* ?% @ T - #include <linux/init.h>
7 ]: k% P4 m2 ^2 i$ m) O. d* e. R - #include <linux/errno.h># B* l$ {; ^: ^5 x
- #include <linux/types.h>4 ]3 j) L2 F- @: T; }
- #include <linux/interrupt.h>
2 a8 s2 [6 ?4 o4 j; s$ ~! s - #include <asm/io.h>
* J. c( p. ~9 r# s- m+ \ - #include <linux/moduleparam.h>. R; [0 C) W, k5 @( o9 U/ R- J/ x
- #include <linux/sysctl.h>
- _7 V: o/ I1 h- |0 ~, }& q - #include <linux/mm.h>
0 ^) y3 ?6 P. ?; K2 t - #include <linux/dma-mapping.h>' z8 r0 M E8 p1 U& I
- " I& X8 y4 Q# w. h9 n
- #include <mach/memory.h>
. G; f' A& e) @/ R+ y* b) J+ t - #include <mach/hardware.h>
$ d7 F' z4 a, i. a6 q' j' J! S - #include <mach/irqs.h>
k6 ^! v6 S6 M- y% s - #include <asm/hardware/edma.h>+ T Q1 e% L7 U
% {" y N( K+ R1 m" R# S5 }" m3 Q- #undef EDMA3_DEBUG/ o3 T6 D) j" _0 p, c0 }4 M
- /*#define EDMA3_DEBUG*/
4 j, S( K& K3 ^
5 ]5 |& T" Y- d; G% `8 g1 n- #ifdef EDMA3_DEBUG
2 Y8 S3 @2 ^* n6 a5 Z8 a8 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 h$ l$ G |, X F* [2 \& u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: B- [6 X) R6 B+ t* t9 L9 C" w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 _! @) L" g" p
- #else
8 V! v% x4 b$ |/ [* Z - #define DMA_PRINTK( x... )
: F, F* k- E& \) X3 | - #define DMA_FN_IN
- T: m J8 h: Q0 o - #define DMA_FN_OUT
; H O% j* N1 Z: L - #endif
, U) _: ^/ n* M3 x& [9 u x
! t) O# {" @8 _( h0 |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! m6 A" q. S! ], D - #define STATIC_SHIFT 3
4 H. ~5 Z# ]9 M2 @ - #define TCINTEN_SHIFT 20
7 ^1 u# Q7 o: | - #define ITCINTEN_SHIFT 218 M |/ x) o: @" j+ i4 m4 w
- #define TCCHEN_SHIFT 22. m# r% a0 O. O+ x, v: b5 S/ m* {
- #define ITCCHEN_SHIFT 23
6 H9 `7 ^3 e* r
5 m# d) r3 s: s' {- static volatile int irqraised1 = 0;" _: Q7 @ ]1 p: q4 g2 g8 g" r: e _+ `
- static volatile int irqraised2 = 0;9 b" q( b- n: A9 V7 W
- 3 v! x( t. H9 y/ |! Y9 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 b. W/ g( Y' ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# G- ^0 M" Y( x/ M5 N, o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 A& b$ W* K7 K" C i$ X" |
; k% K7 P( N- d8 k0 o- dma_addr_t dmaphyssrc1 = 0;- a8 _6 D* N$ ?/ w" U( q; M( X
- dma_addr_t dmaphyssrc2 = 0;
! R9 K) j$ y! D* U t9 G - dma_addr_t dmaphysdest1 = 0;
! u. B; _/ ^0 e8 q+ v: t) j - dma_addr_t dmaphysdest2 = 0;6 P! R3 v; h; n
0 W2 A, P( h. |( t6 W9 W3 }- char *dmabufsrc1 = NULL;
* d# T0 B6 `8 s& X, J+ \( B. ` - char *dmabufsrc2 = NULL;
7 b/ _9 A' f. t - char *dmabufdest1 = NULL;
, G' b7 A y( s* ~2 N8 O2 g, @3 G - char *dmabufdest2 = NULL;
8 C6 j0 F7 m: B) v+ a. s - - F4 z B3 R4 X% T! B3 p; U7 h
- static int acnt = 512;/ B" |+ ~6 \& {2 d
- static int bcnt = 8;
, {. r. ]7 {+ W: K$ b+ f7 H - static int ccnt = 8;0 U6 }. N0 _" [5 D
- / X3 v- A- t/ Z; O2 D
- module_param(acnt, int, S_IRUGO);
9 q% i* I0 {9 [ n( r& M - module_param(bcnt, int, S_IRUGO);
\1 H1 g. V- {2 T2 ]4 S - module_param(ccnt, int, S_IRUGO);
复制代码
% O- W. s: Y& W; s( Y' U
% M; ?2 s! {$ d |0 P$ W; C+ k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 d7 \9 ?2 O( ?: r9 z3 @8 A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 @+ |3 {9 u# ~4 M1 I; f# X; e. N7 Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 i0 B! S A9 y/ I
/ n0 u, r" B ^4 S
* ~1 L& D9 l) x! r6 b1 ~; c1 A' R |
|