|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* X; o' H# d0 A+ t- [code]EDMA sample test application
1 A4 O" t8 t) s+ `& r - /*8 n# x: p' Z' o/ g' R1 p
- * edma_test.c
; g) X2 s# l+ G/ d. ~8 N( y4 O - *
" @( T# W2 r+ i1 H2 x1 u2 g2 n - * brief EDMA3 Test Application
! Z! y( V' f/ V& g& {9 Y8 v - *# k2 q$ Z# ?# G6 r/ m( _
- * This file contains EDMA3 Test code.. `; D: g9 W. g
- *
- J8 A- q7 [. r, O( e8 k3 S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( l3 m ?0 V& ?. z6 P' L$ \, V1 t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, h m2 Z: h9 @& M0 {+ m$ Z
- * TO CHANGE.
7 Z6 E ]7 B9 w. }$ ?7 N4 x - *# ]# ^" o" @6 K7 Q) f6 A8 E' q. n3 b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 a. m5 z1 C- w0 `- p
- *) z3 g% B1 d' L* ? w
- * This program is free software; you can redistribute it and/or2 {& R- G X, W I) O; B9 `
- * modify it under the terms of the GNU General Public License as3 H Z! s3 n% t' `
- * published by the Free Software Foundation version 2.
4 m. y5 ]9 Y& f( ]& ^. G - *. k: Z& b& W- g( L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; ?; F4 i1 u& \0 L7 l ^. w& y - * kind, whether express or implied; without even the implied warranty) V& v( \* u4 y2 D9 w3 S2 E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 U' H, C! B3 C! G1 a. z# n$ m2 A
- * GNU General Public License for more details.9 e4 w% \' ^5 d6 ]
- */3 Z3 l7 z; ?& G, W8 B( r7 m
# D1 s9 L& c! A+ U4 R" W/ C: b: G- #include <linux/module.h>( T% G9 z& v" @ W6 V( h
- #include <linux/init.h>3 c4 _3 h5 z6 s1 o+ f7 O
- #include <linux/errno.h>
, ^7 p6 Y9 X W' b5 N - #include <linux/types.h>
6 B9 u9 g3 @0 ]7 Y8 l - #include <linux/interrupt.h>
) O3 Z+ @3 W9 V8 H - #include <asm/io.h>+ \) N# P' ]. x* D( f ^& t$ ~
- #include <linux/moduleparam.h>- i/ \! W" i0 z8 x
- #include <linux/sysctl.h>% }* I9 `: H' ?% C! h1 Z
- #include <linux/mm.h>
: \7 }- F) B: J! Y p% S. A - #include <linux/dma-mapping.h>3 z- |: w6 M+ l2 q1 a( ~0 T [
7 Q3 h1 T. [1 c U: M. Q7 ^3 u- #include <mach/memory.h>; k! n" B* b6 u- C) Q9 Y" n
- #include <mach/hardware.h>
+ p5 F7 C: |, p% N - #include <mach/irqs.h>* K- X- G5 v% P# q! U
- #include <asm/hardware/edma.h>; X( n9 i `. ~6 z' E( J
2 y& L7 z4 h5 b1 o9 r2 r2 _' t- #undef EDMA3_DEBUG9 F' [6 P. S. Z" q i s g
- /*#define EDMA3_DEBUG*/
3 U" A; G8 S7 g* ^5 U) t; P% d - $ j4 Z, v1 T. e% p/ U5 Q" s$ r; ?
- #ifdef EDMA3_DEBUG1 }8 G1 N6 [) ?0 ~9 r/ l X
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 o8 a) ], T! @' g. m! Z6 w3 A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) Z" W: Z. g% e4 h& E2 m; S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ D5 V, K# [: d6 C6 X" p
- #else* W, y) s& V0 g( _! E, V( u! u
- #define DMA_PRINTK( x... )
. r: M" d7 a. W9 m2 q - #define DMA_FN_IN7 l, K3 f6 M: t% w6 n( F
- #define DMA_FN_OUT3 R# H" z% X, g( Y' E
- #endif
0 ~" i0 j4 X# D: n( F - * @1 v& P1 B" O" T. V! \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 Y0 j: A `5 ?# m5 Z - #define STATIC_SHIFT 3/ e! \% f$ T# n z, i8 k3 s
- #define TCINTEN_SHIFT 20
% j1 _# }5 F( p' k- P - #define ITCINTEN_SHIFT 212 s+ T( ^* @5 n! F( C
- #define TCCHEN_SHIFT 22; |( d1 u* c( K& U+ n F
- #define ITCCHEN_SHIFT 23, g3 g1 Y9 p, C0 j# R0 N k+ d
- ; g! {8 T) A- {8 v
- static volatile int irqraised1 = 0;
9 N3 Z. s; C2 N# e- m - static volatile int irqraised2 = 0; m: }1 d' s( a
+ [$ n$ ~% ~! G, Y2 e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 y, u' C Y; ?/ j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# S* k8 ^5 S3 s. e5 `$ B6 L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 g& t+ P6 z' L9 E( ?
2 E& X- G9 o' d% X, `, d2 l- dma_addr_t dmaphyssrc1 = 0;, D: ~" a# Z* [/ b2 p( e
- dma_addr_t dmaphyssrc2 = 0; ]7 ?4 b7 C. r3 {; c
- dma_addr_t dmaphysdest1 = 0;
* l& v3 h% ~+ E# N% ] - dma_addr_t dmaphysdest2 = 0;$ O' k _0 L# j$ T0 e2 f) ?0 {
7 \( E) ?, b. }( q) }6 z$ X- char *dmabufsrc1 = NULL;
8 W4 s( R \! M& T9 M - char *dmabufsrc2 = NULL;; m3 F* a3 A2 f% t# B) H9 V
- char *dmabufdest1 = NULL;
0 }; W f- }! @3 Y- ]0 t$ Z - char *dmabufdest2 = NULL;" X: X3 B: `# y$ i
- " I: Q; C4 u. ^( ~6 K
- static int acnt = 512;
+ m+ j4 U+ a, ~$ \# ]0 C - static int bcnt = 8;
% d0 W% i4 {; b s) m& S - static int ccnt = 8;0 T1 h$ u! N: V& K9 V5 ?
- $ `; b7 q6 x) I3 D4 C3 J+ K- t
- module_param(acnt, int, S_IRUGO);% A1 c$ n; G e
- module_param(bcnt, int, S_IRUGO);% Q7 J! y' j. O$ Y" I' [
- module_param(ccnt, int, S_IRUGO);
复制代码
4 D$ [9 }, F/ z( p
# V `# R" `( q0 t: I 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: b6 k8 F" s6 N( m9 |/ X {. g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 `, P* a& V5 F% L" r+ p8 ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* I9 Q7 h2 ~0 C$ ~# v5 s% @/ A1 x
/ h/ p7 S o+ B& O0 i" {- n
* Y7 i) j. @2 t ~1 Z |
|