|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ r4 P- h7 m3 |- [code]EDMA sample test application
3 _- C; @7 R( W' P5 D - /*
/ r. `/ a) K4 [. n% d - * edma_test.c9 H$ @ c. p$ R9 H$ t! a
- *3 P {. q8 _5 `- @* a/ p! m
- * brief EDMA3 Test Application
5 M- p6 U4 u0 h& c5 U% O - *! P! ]1 Y" I( @( E# n
- * This file contains EDMA3 Test code.4 p5 \7 y2 @8 a! n
- *
* ]( j) o! s/ T6 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 ~1 h/ ~0 s# [7 ^3 }! S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 x; X# {, s1 S) {; G- A
- * TO CHANGE.+ h' ]+ O! ]) q* n& D
- *
. @8 |, R: J( A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ I2 h$ A# B5 p. c5 G' y0 g. x - *% j. \ Q# J8 ?/ ~" s7 U3 |
- * This program is free software; you can redistribute it and/or
% k- L) U3 i C6 l$ g/ ` - * modify it under the terms of the GNU General Public License as( D& c, r& a- Y) e# B5 E& n' c# g
- * published by the Free Software Foundation version 2.
: y8 Z0 I; D: t% S/ M- M7 E/ v - *0 Z N" F+ L' H F/ b
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 [- d4 F& r: F$ i- u4 v - * kind, whether express or implied; without even the implied warranty7 h$ V$ l0 b( Z2 g( }3 l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ l; w( [$ j, ~7 @ - * GNU General Public License for more details.) [( C; a& }' a2 D5 N% O% q
- */ t) N$ |& _) B8 [3 W; M+ B
' A7 r% b& p. ?) A4 i6 B- #include <linux/module.h>
3 v) u2 Y" H, w" Y& P* ` - #include <linux/init.h>
4 P" U4 R; [: D% f4 _ - #include <linux/errno.h>+ a; T2 \1 n' L9 O
- #include <linux/types.h># Q3 y8 `( [# S8 f# }' @
- #include <linux/interrupt.h>$ p9 p6 x1 q& @/ U4 I
- #include <asm/io.h>. N0 }* e0 ` E! U, A
- #include <linux/moduleparam.h>2 D* p! E6 c, P$ S: N
- #include <linux/sysctl.h>
/ k- K' X7 y$ g5 i% ^ - #include <linux/mm.h>; U' J# V: B* J C/ ?7 z
- #include <linux/dma-mapping.h>$ L3 e; C) L$ v
. X. n1 d! X, ]$ }( r" B' f- #include <mach/memory.h>, c) J( _8 E+ R, C/ v3 l j
- #include <mach/hardware.h>+ |, O. D1 h/ {: Z
- #include <mach/irqs.h>; c a, N6 @* ]4 P9 o' H
- #include <asm/hardware/edma.h>
/ ^" d8 j1 P( t( `% f, M3 [/ \
0 Q+ i& m' Q1 F) \- #undef EDMA3_DEBUG; Y5 t, B* B/ N- K1 [+ @7 p6 `3 [
- /*#define EDMA3_DEBUG*/
2 N6 H, v6 {- s; _; B8 s0 Z - & O3 P- `4 Z% z$ B/ `: j
- #ifdef EDMA3_DEBUG/ J$ h- `4 }1 A; U7 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ H' W5 D' v9 z* h$ b( p+ r. p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' f! c! y' Z) J& s, E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 i; ], F2 s$ B: p - #else
( R2 S7 i: D* z& `% c - #define DMA_PRINTK( x... )- R* x! U. V8 f* `" p1 S' R# B# `
- #define DMA_FN_IN
" x! Q4 X% g5 o3 z - #define DMA_FN_OUT- ~4 B) T1 _ v* l# k3 l8 C( K
- #endif0 x' W* C4 W* ^) G, X; G
- # u c# j0 W' b% R% y1 H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% w5 O9 }9 h4 d# g! k9 Y
- #define STATIC_SHIFT 3
+ W2 ~! {8 ?9 { - #define TCINTEN_SHIFT 206 b. M& `/ G7 s+ r
- #define ITCINTEN_SHIFT 21
2 S$ m, W/ ?# |' r) D3 a - #define TCCHEN_SHIFT 22
0 n( V& {* a" g. \* W& I - #define ITCCHEN_SHIFT 23% d8 z/ @1 s" X) w# d8 M
- $ C6 r' G r6 }& e; [
- static volatile int irqraised1 = 0;
, @9 E) m0 k3 d" U5 X9 H" v& F - static volatile int irqraised2 = 0;4 M( \; q5 G9 W& e& `
0 B) q. o& T# Z! r L& w( O+ P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- @( v K$ ^# L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ e. N7 T6 p; {2 B$ o" `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; J2 c4 w1 K2 Y6 D* l( v( v5 |
, O% i" y, g0 |6 u5 l- X# ]) v- dma_addr_t dmaphyssrc1 = 0;
2 p, u- c$ f1 Y% E+ e - dma_addr_t dmaphyssrc2 = 0;# b9 J7 r( c3 C4 m" Y# O7 _& |
- dma_addr_t dmaphysdest1 = 0;
# N* p1 ?9 N: y - dma_addr_t dmaphysdest2 = 0;$ {* v: D% T' U3 [
( k" l+ |" e5 Q$ v3 R- char *dmabufsrc1 = NULL;( N* \$ t/ S( }& b( h; V! N% Z; I
- char *dmabufsrc2 = NULL;; i; n' S* ] p9 ?5 ?0 `
- char *dmabufdest1 = NULL;
' C" ?& H$ Z3 C: ^* h - char *dmabufdest2 = NULL;
0 l; L% M" X1 s+ c ?- i8 R! W9 E1 _ - 4 r$ `2 ]$ \3 C4 |+ M, w9 V1 V
- static int acnt = 512;0 |0 w! b1 o/ j: Q3 A; ~
- static int bcnt = 8;. c; M$ D& d+ e5 \$ A% z& c) t
- static int ccnt = 8;
! o6 L' M3 [$ { - ' s1 O% u. c* D
- module_param(acnt, int, S_IRUGO);
8 [8 F7 p/ v% M# g9 r - module_param(bcnt, int, S_IRUGO);
, |3 K0 f& P& F& P3 j - module_param(ccnt, int, S_IRUGO);
复制代码
: F- r% D6 F# Y6 q! F# S' g7 \: e4 O; g1 |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: A6 N/ N7 l6 m7 h" s, e _$ Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. U' j+ J" |: E" @, s, p6 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! l2 g( G1 i* R) `; }7 I! w: q
! w2 Z1 Y9 J2 N% ~# w
) O2 \* j. o/ h7 @ |
|