|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 {7 O2 h6 U: h _( {# I0 A. E
- [code]EDMA sample test application
% _7 b1 W1 L& M+ B$ ]4 ^ - /*
" h1 y+ `6 H9 j: B+ f - * edma_test.c
4 S n* _ Z3 u; ?/ m: z5 \. k - *! N& g- v! f+ Y% M2 n
- * brief EDMA3 Test Application1 Q: i/ t5 [( ^' P) a% |; l
- *
1 a6 Q0 s( x1 B; u$ ^. x - * This file contains EDMA3 Test code.
8 I; L! O0 K7 Y' @8 l; `( f" q - *
0 `$ D5 H# s1 [4 V5 c8 n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* C) R2 o' E0 y" Q. y* H7 f" T3 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* z& R: Q3 K" f, f" [" n5 G - * TO CHANGE.
6 n+ t6 _. f( N q9 g5 k% n# k - *# v- O2 i5 z P# J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. b' n4 J8 d7 [, C4 c" p
- *
0 Q+ f- u" Y, A* @8 S& ?" |1 g" B - * This program is free software; you can redistribute it and/or
" p: y$ l) U0 v: G4 {/ s - * modify it under the terms of the GNU General Public License as% x6 k4 e& F N
- * published by the Free Software Foundation version 2.# O! U0 h: i |* @' C* g
- * P6 S6 U" B: w( b% C$ M0 \" A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 }" z" Z9 L% Y
- * kind, whether express or implied; without even the implied warranty3 d) u8 @& q g! i. h% z4 s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 N) s- H t1 p
- * GNU General Public License for more details.
4 T. k" R& G% ^ - */$ o- U5 p2 f$ I4 K% Z1 Q) D- r
- " R$ z7 O7 L+ w8 r
- #include <linux/module.h>/ \* f* l. f4 J9 v( U$ d4 Z* f) E: H
- #include <linux/init.h>2 t( P- b! X$ X$ `- j0 w- \" `
- #include <linux/errno.h>, d' ?0 R: R% M8 P6 \! c/ Y
- #include <linux/types.h>0 L: |7 u( k0 C, A, e
- #include <linux/interrupt.h>' L7 H0 }% v: X c& }5 b6 P* i& b1 @
- #include <asm/io.h>
+ } P# S% j" U: R; p" [. e - #include <linux/moduleparam.h>6 ?; T }$ S2 [2 r6 `- h
- #include <linux/sysctl.h>
' y; K4 l/ A6 h1 j. E x - #include <linux/mm.h>
& N* S# A& _$ n1 P, G `/ ~2 P - #include <linux/dma-mapping.h>$ z) q# c& w; Q$ O1 t3 O
- & a" n( F& q. |9 J* J+ ?4 e
- #include <mach/memory.h># e ^' M* j) A/ H
- #include <mach/hardware.h>
0 J& _) `& ]" Z( i; Y" c - #include <mach/irqs.h>. ~+ L. q/ s* e. H: V6 h9 `
- #include <asm/hardware/edma.h>
: g9 w2 J2 T" S: v8 d - ) V3 Y0 i- V) e/ h
- #undef EDMA3_DEBUG
3 z5 T) J( W) U$ A% {5 G - /*#define EDMA3_DEBUG*/7 N' Z/ x4 R! F$ w* D" h$ x
- ( o* s0 r* P- P6 | ~4 E' u
- #ifdef EDMA3_DEBUG
% V. m( H5 z/ `4 A8 H9 b" B. u0 s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& C8 v$ G0 c3 H; G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 s' j: f$ g7 w) {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& K- D$ @$ }9 Y( x: H
- #else
& M+ U1 V2 }- [$ j# N' z2 l - #define DMA_PRINTK( x... )
2 K: t, m/ P) b( b; U3 X& e - #define DMA_FN_IN( e( N% ?4 T/ F8 [$ ]) [0 k
- #define DMA_FN_OUT8 w' s" V( ?7 @ e8 y5 E
- #endif: c( ^5 y) |, J5 l: O ~. b
- $ M0 c4 [6 K1 G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! P, Y0 J6 V+ ` - #define STATIC_SHIFT 3
3 n0 O$ q( o# ^0 Z5 L5 s7 p3 d* w - #define TCINTEN_SHIFT 20
- a2 l% G# g! V5 }, T$ j7 Y7 Y$ D - #define ITCINTEN_SHIFT 21
% B; C4 {4 Z" a, g* E9 Z. q, c+ N - #define TCCHEN_SHIFT 22
$ C5 f, ~( o8 F7 {) F( b - #define ITCCHEN_SHIFT 23/ b h# p- A+ A6 l
1 s# E, p( C1 {! W" `# ]5 e- static volatile int irqraised1 = 0;
: y7 k3 w; T1 T1 A L - static volatile int irqraised2 = 0;
! ?4 k+ k; _* S! A
6 y# N$ ~: } n9 o- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 o6 f9 I7 T4 R* ^4 t; s - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: x( @& J; F9 J9 M - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" y, G1 b* q' `* y! C/ F1 ]8 x7 H - ; f6 |( n: {) b3 ~ ?( p* B
- dma_addr_t dmaphyssrc1 = 0;
, c4 \" b1 b3 p8 v7 h - dma_addr_t dmaphyssrc2 = 0;
9 W5 @; U0 L/ J/ \6 P# |4 n/ ` - dma_addr_t dmaphysdest1 = 0;: a$ B- D2 ?; g: r/ v( {
- dma_addr_t dmaphysdest2 = 0;
3 T8 w$ o' Y& B1 d& `
) }# q7 g! R* r2 B' K: T* v; y- char *dmabufsrc1 = NULL;' k( Y/ o" n; M5 S1 s7 h1 Q* [
- char *dmabufsrc2 = NULL;9 r( a2 E3 E1 w
- char *dmabufdest1 = NULL;/ h- b+ P: S" y5 j
- char *dmabufdest2 = NULL;
# j" ~4 H. [" w. x2 M% X - ) p C _! }7 ?, N2 V
- static int acnt = 512;
9 D; k G6 n8 N( { - static int bcnt = 8;0 w k) t. r ^# C2 ]
- static int ccnt = 8;
" @! o/ {; N* G8 c7 A- O2 o2 S0 x - 1 o: Z7 t+ B# _/ V5 B7 r; m
- module_param(acnt, int, S_IRUGO);
4 n% q: [: ]( W- ?$ D S9 S4 ] - module_param(bcnt, int, S_IRUGO);
0 c5 v4 A$ y! y - module_param(ccnt, int, S_IRUGO);
复制代码 . z: l7 T! N8 h
% e& d( z) \6 v! E4 i6 z/ l 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) `2 U8 Z: `3 B3 l2 l X
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 i A- H3 w3 _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ l" n9 n, ~( s) R
: l) f! {9 O$ q( c. [
5 }) Y. I4 m2 I$ {4 {6 Z. `# w3 {/ Y! {
|
|