|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : `6 x: G$ d# v! L: h) ]7 \
- [code]EDMA sample test application! F" E7 n" F9 X
- /*& p+ c' ]- t C- j
- * edma_test.c
8 A5 B* j5 _, s! o* P8 z% }3 D - *) `1 ?) w: |# w: |0 L1 g1 s) ?9 B! o
- * brief EDMA3 Test Application X! Z0 B; n- {/ ~" C
- *
' G% _3 N9 Q Z k7 A - * This file contains EDMA3 Test code.
* g2 G1 r% z* o2 `2 H - *
$ w6 \$ ^# T. J. m' e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 ?: J- L3 Y, p
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' e' l x1 b% N& B
- * TO CHANGE.
8 I/ L3 `& ]7 f$ H - *. m; k* W9 f6 G Y+ q5 U: v- w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ A4 Y) |4 f" U6 _( R1 k3 W+ P - *8 ]8 R/ x5 V; m o2 T( M" r8 E a; W
- * This program is free software; you can redistribute it and/or
' N( \& R5 e+ ?7 R$ i+ N - * modify it under the terms of the GNU General Public License as+ p D! x/ T8 t6 u
- * published by the Free Software Foundation version 2.0 a. i+ u0 x! F+ \" B( C
- *
% Q" \) G7 s' R5 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 Z$ y; Y- x4 v! P' }& ?4 {
- * kind, whether express or implied; without even the implied warranty
# N. g( I* G" M - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" V8 _8 r6 ~% B/ a2 I - * GNU General Public License for more details.
7 ~$ J7 X0 D) H) L' s+ l+ F - */8 J) v# X) {7 \$ |9 C
- # T0 v. _1 p& w: f# I1 T* }. @
- #include <linux/module.h>7 { A# |& h; P. e* w
- #include <linux/init.h>
( P3 Y+ ^& O- n/ g: ]% q) r - #include <linux/errno.h>
( j. `( V) S) }; ?! p - #include <linux/types.h>+ X" ?/ {0 B: i" V
- #include <linux/interrupt.h>, z1 ` i" b1 @' g0 O" ?
- #include <asm/io.h>& d6 \; f( J; l+ M+ t
- #include <linux/moduleparam.h>* f* j! k1 I# Z% s `) k: l
- #include <linux/sysctl.h>
9 `$ S4 [" W: [ - #include <linux/mm.h>
( M* T7 w' ~! l& f) j8 f3 E ~ - #include <linux/dma-mapping.h>, R5 T' Y) |6 v% M1 Y
/ A9 e( R! W& R. M- #include <mach/memory.h>
1 h- n1 E4 [$ u( p) P! B1 P - #include <mach/hardware.h>
$ |! t1 D: N. Y |( Z! H - #include <mach/irqs.h>0 z) u5 [9 a" s7 q) \% R
- #include <asm/hardware/edma.h># K$ U- z7 b5 A7 z
- ; P+ D* i0 H# f3 j0 j1 |8 R
- #undef EDMA3_DEBUG
5 _% \- n9 t2 U9 B - /*#define EDMA3_DEBUG*/
6 c) b8 f9 a5 t7 [ ]
* W3 Q: f' F* [- #ifdef EDMA3_DEBUG- {7 c) H. L, F3 ^* H$ L/ ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
Q. I0 s6 T7 ]" s3 \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 W! W' K5 k y' v8 t7 p- A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% P" x' P; S; T# |% A. S# y# k - #else
- Y6 m( ^6 J8 e; |0 {# v, U - #define DMA_PRINTK( x... )
- {5 ?/ u; e# e& T4 R; Z/ D - #define DMA_FN_IN w, r4 k7 T; i u ~7 J7 f
- #define DMA_FN_OUT E* Y! Q$ G' E- {
- #endif% P3 |/ ^, N4 j$ Y7 N. U# _- U
- 3 r; A* M+ G, a9 u/ @: a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 d2 L9 i2 Z6 k0 G6 U3 a8 W - #define STATIC_SHIFT 3- G( B& q+ q: V w
- #define TCINTEN_SHIFT 202 C9 K, _! P. M6 Z2 G$ F" g" E) J$ ~# F
- #define ITCINTEN_SHIFT 21# q4 U) H k& R6 T3 D" T- B
- #define TCCHEN_SHIFT 22
o, {, K9 d) i w* U! {& ] - #define ITCCHEN_SHIFT 23! b: V/ e: |+ _/ |
" W# d4 f2 t% C _7 @- static volatile int irqraised1 = 0;
* n z0 V" q) F- X$ T: J4 C - static volatile int irqraised2 = 0;
% p, i! c2 ^; H7 i2 v6 d& {
7 K b* I' w* n4 N/ B/ x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); x4 _; q$ \7 H* }4 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 N4 V/ ], j/ l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, m- u/ L4 g' K
- & B+ Z6 ]! G/ ~9 b3 t' N( Q( R
- dma_addr_t dmaphyssrc1 = 0;& X- E' p# Q# K. x
- dma_addr_t dmaphyssrc2 = 0;( a8 O& f5 ^# e1 G+ m
- dma_addr_t dmaphysdest1 = 0;9 v2 h. t. B: ]; e0 `) N R; u
- dma_addr_t dmaphysdest2 = 0;
/ H0 _* v) Q2 A; R! v0 { - 7 I0 L+ P' C- J M' y* q3 _
- char *dmabufsrc1 = NULL;
3 o( h7 B, u, h1 b - char *dmabufsrc2 = NULL;
" Y: Z6 _0 Q6 ?2 `; \& n3 E - char *dmabufdest1 = NULL;- g9 I* G. f% M+ l
- char *dmabufdest2 = NULL;
# v. ]+ f0 w- x4 x" O( k' h - ' A1 ?" I& C1 r5 k: d
- static int acnt = 512;; ~6 E+ O) J8 C9 b8 Y3 s4 ^
- static int bcnt = 8;6 m: ^8 \5 R) Y2 L
- static int ccnt = 8;$ ~, e$ }& c6 I1 _
z+ [" A& T( j0 T- module_param(acnt, int, S_IRUGO);2 U u. \! {5 ], F8 R
- module_param(bcnt, int, S_IRUGO);
: g% x5 G& e9 a' ^7 N3 n8 K - module_param(ccnt, int, S_IRUGO);
复制代码
8 d' n6 R6 c% o5 g, C" \& U& V9 S# C+ s! q T" Q8 _1 A4 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ x& a5 _$ v# ]# H2 l; 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 F/ |! Q+ D2 c1 F2 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. R: c/ r. @2 A3 @5 d3 h/ h
7 x0 L+ m+ _( l3 T& D* k" ^
p) e. ]& L/ f. t! J3 P, E |
|