|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ l- ~ `% \$ a( O- [code]EDMA sample test application
1 c& d3 s/ g5 F4 E, G( Z- R - /*) {1 T7 X7 a9 y1 W
- * edma_test.c X* Z7 [8 K- @1 y/ m' f
- *" {+ g3 s+ I5 x
- * brief EDMA3 Test Application
+ F$ ~ @9 [+ |) j - *
' x1 K& i3 A4 d9 Q - * This file contains EDMA3 Test code.8 s! q9 |: d2 S: i
- *7 i. X" h3 ^% K( z3 |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( G2 ^2 m( ^; `* \( o4 S% K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- k( Y. w2 ] N* p' } - * TO CHANGE. ?" M) O* D) I% O
- *3 A: z4 d/ r t/ X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# B/ }! ]. B) S! W
- *
* t" h# g: Q! s' U3 [$ ^- S7 Z* v - * This program is free software; you can redistribute it and/or
9 I5 n% f+ E* K( F* l! D/ {; t6 C8 k - * modify it under the terms of the GNU General Public License as
- J7 @! c7 Z& i8 c* ^+ n Q - * published by the Free Software Foundation version 2.
7 k Y% H* @ k. P - *
1 `8 L7 b0 X8 r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( l/ v7 V! ^# X* K1 z - * kind, whether express or implied; without even the implied warranty
, j; Q9 ^: [, j' u* v8 Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 j5 g& s' H$ z: m( j9 w
- * GNU General Public License for more details.
; J( k4 j8 d* l% K - */
7 m; {# v. O! N( Q" o2 g& g
3 F. h! t) Y. q' P8 \, j- #include <linux/module.h># V) B9 [( v) D% l9 G; R) F
- #include <linux/init.h>
3 K& U a* p& X2 A - #include <linux/errno.h>3 W& k& \; `$ [- f
- #include <linux/types.h>
. r# E8 x9 p% B# ~ - #include <linux/interrupt.h>+ {1 b) s6 Y4 v, J
- #include <asm/io.h>$ j3 V6 H% j. R, Q: `5 U
- #include <linux/moduleparam.h>% c# \6 n* E& y4 c. W# G
- #include <linux/sysctl.h>4 t$ f$ @: @$ Y1 V9 U: |8 {
- #include <linux/mm.h>2 M. ^( \' ^8 b. K
- #include <linux/dma-mapping.h>
! |* T: f- |3 P, ~3 O2 t
5 L M+ G# N8 b5 M2 ]* N- #include <mach/memory.h>2 I5 ~. J6 T: q+ F
- #include <mach/hardware.h>
( V3 A, ?% x1 o( l! K9 a - #include <mach/irqs.h>6 W1 |; N; I- a0 K2 _0 H* v" z
- #include <asm/hardware/edma.h>) W: F1 o) \4 V5 Y/ J, {9 K6 g4 V& z
: ~9 F0 b# k5 R' {- #undef EDMA3_DEBUG
* t$ I% m. ^3 W0 u - /*#define EDMA3_DEBUG*/
. C/ J. R1 g; a% j" K9 T - # d( I i$ H, u/ ~5 j2 A
- #ifdef EDMA3_DEBUG
6 I6 m( \9 G( ]5 X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- Z; d7 M7 X! k. R! P$ m7 f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 S% H9 D* b1 Q0 `5 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 [) S9 N: j: t; U# Y( h2 y J
- #else
, I- L5 z5 M+ R1 l7 _! o - #define DMA_PRINTK( x... )$ v S2 [6 I4 ]) {; U" \
- #define DMA_FN_IN
. E& {) Y- e& A - #define DMA_FN_OUT. b- x! R$ [9 L* f+ o; g; Q
- #endif
: j. x/ o" N/ R5 i# ^4 Y
( i; P7 W$ ]- c, h9 T% r- #define MAX_DMA_TRANSFER_IN_BYTES (32768); Y- ~! {2 K- _& }, [. M Q& y, n2 q- g
- #define STATIC_SHIFT 3
% h; ~+ b; K- D8 u( S% {( ~ - #define TCINTEN_SHIFT 205 r8 D3 r) |3 z" w5 v
- #define ITCINTEN_SHIFT 21
( V$ J2 l7 a% D1 L. K, n( h; |" ` - #define TCCHEN_SHIFT 22+ W9 q0 P; X7 ?0 |
- #define ITCCHEN_SHIFT 23
' k7 n5 u) v% n( y
* Q' X+ r' u, D9 N, c. w) ~" Y$ o- static volatile int irqraised1 = 0;0 z* M9 k" L; J& B% J
- static volatile int irqraised2 = 0;- x, T7 Y. t) q7 O, T! k A
- 3 C# B! q# t9 n0 l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 k5 ]5 U& [; L+ \7 M2 G8 W4 X% `" ?: _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 t# _& [0 e8 ^* e; G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 ^3 s7 C T1 T$ s) l5 G
& C' y, i9 e+ g& \4 N8 a1 m- dma_addr_t dmaphyssrc1 = 0;" O Q6 {! N, V! f* h, v' D
- dma_addr_t dmaphyssrc2 = 0;; _# n* l$ J* }2 r$ B! Y
- dma_addr_t dmaphysdest1 = 0;
& W% j8 U: r6 V7 C4 m - dma_addr_t dmaphysdest2 = 0;% f" ^: R4 ^( G9 c3 G0 _
- ! q% v$ U0 L" \; U2 Q. r
- char *dmabufsrc1 = NULL;- c/ P2 F' E8 T2 G% o0 E; W
- char *dmabufsrc2 = NULL;; u7 l; J* @8 Q
- char *dmabufdest1 = NULL;
4 q# y$ D' i" o! |9 S. x" N - char *dmabufdest2 = NULL;5 D/ d- p( [! ]* X
) T' _/ h6 Y) \; N8 }- static int acnt = 512;: G: E8 u$ ?8 m. a! ^
- static int bcnt = 8;; H2 w- y# N' U/ x9 {
- static int ccnt = 8;
! ^" p1 |" O& B' \
5 q. S4 x& i/ J- module_param(acnt, int, S_IRUGO);; b2 {5 h! r) k0 `
- module_param(bcnt, int, S_IRUGO);
6 \, L' P: R1 k: r, u0 m$ w - module_param(ccnt, int, S_IRUGO);
复制代码
0 b2 y! ]2 R4 [5 I1 G3 [' V
8 _% y( F8 @; K7 H# n& ~ V! _5 b 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ j' O5 o/ b0 |5 {* C( f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! N2 x; ~) j, F+ S) E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: H# A+ f# M: r1 I4 S+ U9 n
" Q# E- O) Z4 _. c! z0 J% b' N8 T
* ]' |7 u/ U0 e5 q X |
|