|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 C: T9 F- }% D4 Y7 y
- [code]EDMA sample test application7 B4 [: x- H9 R4 j
- /*
; M* A. E Z4 c ]) ? - * edma_test.c
& W9 R) k9 N ], ?" j" r - *3 S- ~, Y7 m+ B, K# k
- * brief EDMA3 Test Application
p" o9 e/ T" S* o- v+ } - *3 _3 f! l4 M; \ ?8 }+ T- `
- * This file contains EDMA3 Test code.& l( b# d; d1 a1 w, y
- *1 s) i4 ~, X5 t: K" [4 X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 O% ^7 C2 W6 o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% Z+ |+ [7 C! V' t* H: z5 M6 v6 t
- * TO CHANGE.
H, j+ J) h% j - */ S8 Y9 D: h. R: ]9 `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ o j- E: w/ X2 \0 B+ z. f
- *' f3 S9 \) v' e9 j [* L
- * This program is free software; you can redistribute it and/or
3 F" ?: q- u/ i4 j) R - * modify it under the terms of the GNU General Public License as* ?+ i% `% N7 c' ]9 p8 X) p
- * published by the Free Software Foundation version 2.
- b% F% t8 l* u: k3 o5 A) n - *" W; Z7 j' N5 J- M5 C: K# @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any; @1 d. j q4 s5 N
- * kind, whether express or implied; without even the implied warranty7 j( s/ w$ Q! W' M7 J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 ^6 R' ^7 u3 h2 T+ P$ X2 c- b - * GNU General Public License for more details.8 I/ D( @# ~, Z& w2 w
- */
* N% y4 ]5 _$ W* G4 N+ l( S - " o) q1 |* q% f
- #include <linux/module.h>0 I0 G* w; K9 p' s" @8 e
- #include <linux/init.h>
. ^% T/ s8 @, v, Z - #include <linux/errno.h>
1 ~# _* ?, P5 h9 q0 p$ D8 ^8 A - #include <linux/types.h>
- b# p4 @1 x; j - #include <linux/interrupt.h>8 d0 M0 Y: f, M1 T/ x# S9 G* R2 X
- #include <asm/io.h>
) Q* ?9 f( N& a& |2 V - #include <linux/moduleparam.h>
% j! V+ |+ L- O3 ^% n - #include <linux/sysctl.h>
. M/ x( r8 k5 r9 G - #include <linux/mm.h>- H* J3 d. x8 k4 r! P
- #include <linux/dma-mapping.h>, {& i- U# ^- z7 ~- C. @
! d# A d& ~ K) m7 |% t. z- #include <mach/memory.h>' N p! `2 F0 L& F( u m
- #include <mach/hardware.h>4 \: y4 S% l# h% P# U
- #include <mach/irqs.h>- {/ Y* P) S0 U
- #include <asm/hardware/edma.h>/ K/ J0 k* e5 Z- L. ]% I: V/ {& [0 A5 e
- D3 p9 q \& @; D- A- #undef EDMA3_DEBUG4 ?) y! x: y2 o9 u
- /*#define EDMA3_DEBUG*/
. G$ j4 h2 j" _2 Z4 t& Z' v
$ g1 f2 x$ i( c% @+ k) G7 |- #ifdef EDMA3_DEBUG
$ f3 p K5 v* p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 U' A& v. k0 W. y' g6 l6 G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# r2 ` t$ a2 B; K1 B+ M0 | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) r: x; x0 R L7 r1 i
- #else5 X2 c; ^7 t/ V
- #define DMA_PRINTK( x... )
% P% m) J! l) W) e( B4 f2 B, \6 E5 q - #define DMA_FN_IN
/ }+ a4 k4 r# V/ a: J - #define DMA_FN_OUT8 h# A9 x+ H' t: i5 [6 U
- #endif2 l; h W9 m5 b$ ~
- ) X$ }! t+ i \; e; E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): R- Z9 a% H" [: y% S
- #define STATIC_SHIFT 3
+ o1 q& Y0 ~* W9 I( T - #define TCINTEN_SHIFT 20
! u, D0 u! y2 Y L' r3 F - #define ITCINTEN_SHIFT 21
7 S) U8 [ I% T; S8 E* ? - #define TCCHEN_SHIFT 22
, f4 T. J6 p6 }- {1 C8 k - #define ITCCHEN_SHIFT 23, m# }/ ^" g* `2 }; g0 r6 E
: q: M, i1 ?( V7 W& @3 K- static volatile int irqraised1 = 0;. x2 [, G' ?4 F2 P+ C
- static volatile int irqraised2 = 0;* t$ V7 z$ e9 q7 _
- ! S2 o$ w3 E/ M7 h/ `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 l( c' a. z" D" a9 q8 v2 D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ a0 ]" {- d; h4 w' j+ k& k5 p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, J7 w( \4 z# ?' R
- . ^. V% j4 U9 n1 Z4 h3 D
- dma_addr_t dmaphyssrc1 = 0;5 t# u+ j& _- _4 ?* N) a
- dma_addr_t dmaphyssrc2 = 0;
8 V8 I0 l7 ?% g - dma_addr_t dmaphysdest1 = 0;
6 m$ M% u9 C! w2 V j, ` - dma_addr_t dmaphysdest2 = 0;
1 G# \" z1 W( L4 u$ n* }# T - 1 d' ]0 |5 W' r$ V4 s+ `
- char *dmabufsrc1 = NULL;2 f. j; N9 q. L9 Q D5 e+ W7 x9 O
- char *dmabufsrc2 = NULL; M) ]+ M$ ?) K
- char *dmabufdest1 = NULL;
) ~" s2 R' a1 d3 G* N8 Z - char *dmabufdest2 = NULL;6 M# n4 M$ S7 W1 a7 _6 t3 l1 I7 l$ Q
6 M" M. o7 r0 h- static int acnt = 512;
/ ^. i$ n4 L6 J% U5 ^- C- R/ [ - static int bcnt = 8;( q/ m: N% I- `; R. _2 |+ Y; G
- static int ccnt = 8;
% I& `5 _8 L _) [ - % y. Q1 |/ T5 Y5 j
- module_param(acnt, int, S_IRUGO);
/ m% `! Z; X5 T2 I5 T2 b, i - module_param(bcnt, int, S_IRUGO);2 i0 k8 |0 I9 O0 C/ D
- module_param(ccnt, int, S_IRUGO);
复制代码 ! C- Y) P4 n' C0 y. }, K8 g; c
3 ?, I9 V# t( w7 m% R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# ?+ u E/ p1 D0 `2 M
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" O, P/ w) ]* B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) N9 z1 R" z+ G4 O- o: B
! \) H/ y# j: m/ Z
_) C% n) ?' l1 C) p9 W1 `& j |
|