|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 Y. R" S* z: [1 f5 j* c- [code]EDMA sample test application
0 b5 U; K: V( L; K/ ] - /*6 b7 B# k' d$ t- L
- * edma_test.c
' |# _) q9 Z2 p3 p& C9 s: F, g - *
' W- K( i) B$ w- @" T/ ^2 C/ } - * brief EDMA3 Test Application& p; C$ D: n5 n2 y
- *9 t& u" C. s" O3 A! X% }/ h0 G' S: K2 r; z
- * This file contains EDMA3 Test code.: V- g) k- T5 o2 Q
- *
. D9 @ s; N- l5 z$ h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. U: r5 }$ c0 R1 u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 Z0 m8 w Y/ r7 g/ E
- * TO CHANGE.2 C; [& o0 b& z& t
- *
- }+ s* Y* N; O. S- @3 z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! H6 y; o% b( B( [3 g
- *
2 }5 P4 P" v W, v' j% ~ - * This program is free software; you can redistribute it and/or
2 K* Q; p7 A4 N9 ], g - * modify it under the terms of the GNU General Public License as
o9 N) t4 P7 E& x( E2 c - * published by the Free Software Foundation version 2.9 `+ c; B! X* g! a' J5 ~0 g
- *3 f# a! r0 Q" ?9 G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. y4 r7 W7 j9 B7 v" I. w6 n - * kind, whether express or implied; without even the implied warranty- a8 r9 m+ ]! ?. a- [" L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 F1 }' d& O- i- P4 r: {6 E- { - * GNU General Public License for more details.
! w$ P/ h' r/ S# y3 S1 @* E - */
# o) Q1 H, D! y+ ^
8 D9 z K5 q: Y( ]; r- #include <linux/module.h>0 v3 b9 r2 }$ ~4 N
- #include <linux/init.h>$ h. N w7 A ^- K. ~! L
- #include <linux/errno.h>
$ @, X# i4 O6 o% Y9 D# U( S( b/ u$ S - #include <linux/types.h>
, |# E2 F) X7 M: }1 U) X2 P - #include <linux/interrupt.h>! m2 @! `# ]1 C; [+ @9 j: f
- #include <asm/io.h>
5 H3 P% B: F% a- j0 H% w& O - #include <linux/moduleparam.h> A2 G0 d" j1 ~6 M3 o, ]1 w
- #include <linux/sysctl.h>) O1 h8 Z2 A9 y0 e0 W
- #include <linux/mm.h>0 s( q" b) n$ D" n
- #include <linux/dma-mapping.h>
3 B0 \ ]; X' }: F9 T9 a
7 B& |) o5 ~# Y$ S; s! s- #include <mach/memory.h>
1 `+ m& a% K' ~) d% ? - #include <mach/hardware.h>% a% T P- P) h. m v' n! a
- #include <mach/irqs.h>
4 \* L6 `" L6 y5 Y - #include <asm/hardware/edma.h>4 c% g9 D4 p$ }' G8 k# m8 ]4 `
- $ R# r1 x B; E. I- k: m! `3 o1 Q
- #undef EDMA3_DEBUG
; h' x) J1 s7 I) a1 Q8 L8 X - /*#define EDMA3_DEBUG*/
8 R! [. }2 }* D2 g - # d9 h# b4 L8 ~% b' u, e
- #ifdef EDMA3_DEBUG
* o1 b4 w( q) n* K, c. B3 m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 g- o4 ?" a9 Q* R6 m; c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 k0 X0 C5 B9 C- r% e9 Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); ]' O6 I8 g" W1 B
- #else
& B- b0 X, H; G# y - #define DMA_PRINTK( x... )2 f5 m0 d7 s! \
- #define DMA_FN_IN
) v8 _: q6 J0 u. ?( X - #define DMA_FN_OUT
/ _9 ]+ \! M. l; A! j - #endif" ]7 A' O( B% p; R E& Z) c# [8 K
& @- m8 Y1 p5 V. `8 ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 h$ \' x6 \. _5 ^
- #define STATIC_SHIFT 3
8 g- }9 l9 N8 Y% W) j& F/ k - #define TCINTEN_SHIFT 205 p* ?( T% Y% j' U1 U
- #define ITCINTEN_SHIFT 21' J/ o. O. X: G
- #define TCCHEN_SHIFT 22+ L; `: M' d3 i; m B) {
- #define ITCCHEN_SHIFT 23
& x0 ^# G( c( ]& B/ n - % {7 ^0 f2 L+ ~9 S8 V& ]
- static volatile int irqraised1 = 0;
5 P: V: U0 Z: H' l O! c/ o- J( n - static volatile int irqraised2 = 0;" ^7 G" y5 N! v/ N' s2 \& x" M
- : ~8 R$ X; L, e$ Z, M" \' G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& K; p5 W- T \- @6 l# Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ N; @& R% O3 Z9 ^$ i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# u/ ]/ L1 I3 a# |
& n" i9 r4 j& V |1 o( O. C- dma_addr_t dmaphyssrc1 = 0;9 W P! A9 g6 s% _, ]( s
- dma_addr_t dmaphyssrc2 = 0;
3 ]3 m' f( k1 ^& y' B: h - dma_addr_t dmaphysdest1 = 0;; J: [( u; T2 i3 }. m
- dma_addr_t dmaphysdest2 = 0;4 }. ]1 T$ k4 c
/ i3 |/ Q: _" Z* \ N, g! }- char *dmabufsrc1 = NULL;! ^5 ^$ `3 A7 c. K& G2 V, T) \
- char *dmabufsrc2 = NULL;+ N3 z- D& M1 e& J3 W U2 r
- char *dmabufdest1 = NULL;
' G0 @. ^& a r1 }; x$ O% p8 l" | - char *dmabufdest2 = NULL;4 R7 A! O" z! t7 m4 A
5 y) k- F9 J1 R, \; a) |- static int acnt = 512;
1 A2 Q. u( u9 i, @ - static int bcnt = 8;& C) F4 X; `0 y' a
- static int ccnt = 8;' v, u, ^- X' y; @% `
2 L/ V I- K- l6 L- module_param(acnt, int, S_IRUGO);
4 x1 \- a4 e5 r$ K! Z1 y8 C6 x# L- [ - module_param(bcnt, int, S_IRUGO);
/ z, }+ C: W. ^5 O: J - module_param(ccnt, int, S_IRUGO);
复制代码 8 H6 N& ^2 v- N$ f
3 k3 K( r$ e: B) o" T; | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ F! p: B, L* H8 I: carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 b5 U; q$ ^. E7 J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% @3 w3 o" }$ |
5 X, ~- I7 f* l4 E
$ s) K$ _ F3 A/ ~6 M
|
|