|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 d& X( P d" K; C5 d. s- [code]EDMA sample test application
( V! Y \0 T u+ F - /*
2 Y* g. l9 B. Z. H F3 Z, w - * edma_test.c+ l( H1 K* J' p3 j; L
- *
' K/ T. h: U& B5 c7 W - * brief EDMA3 Test Application
, w" C" Q" R* o$ f7 [6 H# i8 z - *- W B- V: g& e0 V
- * This file contains EDMA3 Test code.; [- t9 N* X3 o0 D) v' m5 }1 J
- *
, m8 J ^6 G N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ L: s7 z8 ?' K& z; E# C& I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: _: L. e: G% k7 Q4 d& i
- * TO CHANGE.
+ i2 G; O, ~4 u - *
9 A0 L& z4 D+ U8 A3 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' h) D6 v8 `+ L% O0 h
- *4 x' [# R* B2 D. n, t# \
- * This program is free software; you can redistribute it and/or
+ b8 j. @* W; W& J6 J* y/ b - * modify it under the terms of the GNU General Public License as: l% G+ Y; a3 J- j
- * published by the Free Software Foundation version 2.
4 r5 j' f+ U0 ]( k - ** F/ U" D; f' }2 O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 o, j- H2 h! i/ C$ a
- * kind, whether express or implied; without even the implied warranty
* Q8 x& D; p1 Y7 a2 b& V5 `& l/ B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ r- l0 g" c% }+ f: w+ ^ - * GNU General Public License for more details.0 |" ?( n% ^9 V
- */9 F/ ], f; Z# K$ o7 J
- ; P5 X3 b" s, ?4 a% L
- #include <linux/module.h>) d, d- I& Z# j- Z+ W7 w8 @
- #include <linux/init.h>* i6 [2 G8 ~+ }
- #include <linux/errno.h>
: J x3 V6 [$ W1 u6 `" T - #include <linux/types.h>
3 h6 W. w0 [/ y6 X# f - #include <linux/interrupt.h>: o$ S' t! @ N( d) Y
- #include <asm/io.h>. l* D* C7 u; r
- #include <linux/moduleparam.h>
- b$ b2 V( v# A" ?2 M* f; M7 b7 F4 ~ T - #include <linux/sysctl.h>
9 a4 S6 V0 r/ U - #include <linux/mm.h>
5 f3 q( ^) `! x; {8 R+ p; w - #include <linux/dma-mapping.h>' n2 p; D6 y) H2 z: Q8 R* R
- 7 b; _, G J: k6 W/ x
- #include <mach/memory.h>
) f0 D: Y1 G* f1 Z - #include <mach/hardware.h>
, Z+ [; Y- a$ b. V2 ]5 j' R1 V - #include <mach/irqs.h>+ w2 i7 t+ i& h9 p# F7 C0 j2 f
- #include <asm/hardware/edma.h>
) [, |3 J p2 Z- t' }- }4 h
: |1 [& D' a' F- #undef EDMA3_DEBUG/ w. p; o; m2 j
- /*#define EDMA3_DEBUG*/
# s% Y8 H" l4 `7 ?# D( y, X) J
2 w4 x8 F% v: E7 y& A! L+ K2 B- ]) N4 p- #ifdef EDMA3_DEBUG0 k- ?) @3 c+ r$ q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 [; r" u. b* C: I3 Q: w6 R$ m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 Z# s& D1 a3 c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 r/ s8 w( o8 h9 P$ C( d% u2 X - #else
* w: {( h! ~, k$ P - #define DMA_PRINTK( x... )" F. }) i" S f i1 O
- #define DMA_FN_IN4 ?& o% L& b7 O. n% X* J
- #define DMA_FN_OUT5 A& \0 D# R% Y1 d
- #endif4 s( e( P8 j- `
- X, @2 q6 }+ b$ K5 c- #define MAX_DMA_TRANSFER_IN_BYTES (32768); j6 b1 ~) R- ]4 N% S0 c2 N
- #define STATIC_SHIFT 3
0 [8 E3 [" p3 \* E - #define TCINTEN_SHIFT 20
* f- w% I1 A7 y) O! Y - #define ITCINTEN_SHIFT 21: L/ K0 `0 o" w# ^) ?+ G
- #define TCCHEN_SHIFT 22
g* ]; ^2 a$ U7 t5 y - #define ITCCHEN_SHIFT 23
" I' ]1 A( b$ n$ Q
2 ?1 G7 F( d( @$ t5 J0 H( G) w- static volatile int irqraised1 = 0;! G: P2 s/ j- g; k
- static volatile int irqraised2 = 0;& R" r6 p5 ]. Z' \2 Z/ C& @
- 9 L- [+ s0 u6 Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 M" ~0 E: u7 V g) m& W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' g" Z' F, G; L1 P# C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 F5 {/ `: g. e
- ; K% j# _: k" F7 _$ S E$ o
- dma_addr_t dmaphyssrc1 = 0;
N- |+ u) C! f4 H7 L, }) X& z3 v - dma_addr_t dmaphyssrc2 = 0;
: h( F' D8 Q8 ]9 A. ?6 @+ n - dma_addr_t dmaphysdest1 = 0;4 n8 O( K7 L; Q2 u# G, ]$ _
- dma_addr_t dmaphysdest2 = 0;- E& h: [" I {: y! R7 b/ H( E
6 g8 [- S1 i! A4 e0 D2 s- char *dmabufsrc1 = NULL;2 f4 F/ i# f2 g. ^( s
- char *dmabufsrc2 = NULL;
2 t0 k& G3 |4 M - char *dmabufdest1 = NULL;
2 G% h; ^) t" t& M j. V) e+ k - char *dmabufdest2 = NULL;
, }- _4 J# O v0 l - 4 y6 C5 I/ `5 j x
- static int acnt = 512;
6 c0 Y/ H' s1 ~/ k- ?& f2 c - static int bcnt = 8;
6 g" n4 e# S* E7 o7 D! f - static int ccnt = 8;% e2 a; R, W% D& ~5 G1 E9 \* n
- / a) V" s# Q* ^$ G5 M
- module_param(acnt, int, S_IRUGO);
: k) O" L& G6 L4 }% h# j5 | - module_param(bcnt, int, S_IRUGO);* e. y3 M( a1 q3 z8 w" t, \
- module_param(ccnt, int, S_IRUGO);
复制代码
; B2 p$ h( B, o+ F3 f) L6 V P: G1 ?7 ?1 D6 _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, E( W; W: _0 g/ z0 ]( t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 G9 C5 e) L. Z- V# | C3 s7 f% A/ V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- X8 U/ D; e" O! M$ ]- [
& T( W9 f: D# {: n" W# D* z
% J: @ v* K( X- ]6 `4 z1 f0 m |
|