|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% k/ |4 y+ E, ]- [code]EDMA sample test application
9 N3 ?: L4 k' ~3 @- o1 r d; { - /*
, c4 V& H) d. A5 P* z - * edma_test.c2 R" j* N W8 S- C
- *
0 g) K" j" }# z: N% q/ q6 W) } - * brief EDMA3 Test Application
- d# N- a7 \; G5 o# c5 d# e - *
5 s# B0 t: O" |9 {, M1 F - * This file contains EDMA3 Test code.! `$ A" `* Q% x8 p! v( c
- *1 J! @, n9 H) {/ |9 f$ X7 e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) a& p/ e6 S* y0 G: I M; ]* Z% c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, n M2 q1 J. V2 e
- * TO CHANGE.
, l9 Z9 r0 d2 \. z, y- l - *
8 l( ~$ f, @4 f- x5 G+ s) Y' D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 o( x t1 _9 F( ?2 L - *
# s1 t+ I2 _3 C* v- b - * This program is free software; you can redistribute it and/or
6 s( a7 |! {" ^& u; P - * modify it under the terms of the GNU General Public License as! t3 J% N! V0 I/ a0 e/ x2 g
- * published by the Free Software Foundation version 2.
/ E( N( x+ J2 g0 v R; S+ D% ^ - *
4 Q6 j @1 F! } {7 ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any F0 F7 I8 x, t
- * kind, whether express or implied; without even the implied warranty
: q5 E$ v0 W1 v8 M% J# X2 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 t5 j; L: ~' D, b
- * GNU General Public License for more details.
4 L* s( Y0 S i4 S" R: l& A - */
3 H" A8 k& ~" T" e7 }
" J7 N% W! w1 ^, K( ^9 i- #include <linux/module.h>. `9 K. y- R+ s2 B2 s: r. P8 V7 |
- #include <linux/init.h>. k! q. h+ {8 d8 @
- #include <linux/errno.h>
\# ]; S1 T9 H2 M* v4 x% _3 k1 Y - #include <linux/types.h>0 x! a: B; g8 D$ a
- #include <linux/interrupt.h>9 Y9 s( |( h; z3 B
- #include <asm/io.h>
. ]) O# v) s) i! j2 o - #include <linux/moduleparam.h>
5 ]7 y: \: L3 K+ @' m - #include <linux/sysctl.h>! N) x/ A9 R$ e5 V. m1 \% F" }
- #include <linux/mm.h>' Q# i1 z0 ~& b4 {2 k
- #include <linux/dma-mapping.h>2 l4 b9 t4 e2 t. `( m5 ]# ]+ X' T
- 8 I2 G! U, N7 w$ y; ?" U( I
- #include <mach/memory.h>
( p% j# E) p! k4 K j - #include <mach/hardware.h>2 r% }( z- q0 U9 {' R' H9 `" J
- #include <mach/irqs.h>1 ]+ T: i, h( `; {& q
- #include <asm/hardware/edma.h>
& a7 T2 l3 P) Q: x" D, i3 u* l - & c% \' X& ^, x' V3 k1 m# K6 \
- #undef EDMA3_DEBUG
4 z8 N9 ~$ q/ o0 o - /*#define EDMA3_DEBUG*/- _7 d( O/ T& _: Z5 n3 t
- + m8 N1 C9 T) q, x; ?5 w; \
- #ifdef EDMA3_DEBUG5 A: Q' l# g$ l; Z. O
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! K8 i; D# D. a+ A% r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ Y( q9 t* E$ f. ~& y6 I. h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), Q$ m# d4 H f+ v" @( g! z% v
- #else
& m# w$ h. E+ u' C9 ]" Y G ]: H - #define DMA_PRINTK( x... )' N3 x. F2 h! j* n- H3 l0 S" @/ g
- #define DMA_FN_IN: E/ q c/ i+ u- F1 D% p
- #define DMA_FN_OUT
i3 y! `3 V( h. `2 ]. e: a( z, M - #endif
0 f# k5 @, h u - & s5 q3 T/ `3 m8 c, W- }9 B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 @7 P, B# N+ V7 B j4 C
- #define STATIC_SHIFT 3" w2 j) W/ j0 ~9 ?
- #define TCINTEN_SHIFT 20! s2 s% o9 V+ b/ R/ Y" m9 i
- #define ITCINTEN_SHIFT 210 U8 Y3 g* V+ e! T9 a+ s
- #define TCCHEN_SHIFT 22
v) K2 c% Q+ P/ M, y - #define ITCCHEN_SHIFT 23
" d8 Z$ o) q# z$ k
! A, l4 n3 q$ I ]* }# t( G4 \; `- static volatile int irqraised1 = 0;
8 [' N% j$ I r" K U4 h* P - static volatile int irqraised2 = 0;
# f2 } _* Y9 \* A5 }( l8 Q - - v2 N7 Y+ Q8 x8 f! X5 y; c h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 w( `- e' W( F* o; f0 F) Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ c! R9 y. ]& u' u4 F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 G1 L, O; W ]8 f7 O$ Q/ m
, `( `! x4 ^) s3 @( o/ s/ m- dma_addr_t dmaphyssrc1 = 0;
; o$ T$ l+ p% y; N. x - dma_addr_t dmaphyssrc2 = 0;* c( w2 m4 g0 H L
- dma_addr_t dmaphysdest1 = 0;9 a" s+ V2 @" a! q
- dma_addr_t dmaphysdest2 = 0;9 c( x# A+ R+ @7 W- k0 [
- - U: U q/ P6 k
- char *dmabufsrc1 = NULL;
/ k+ }/ A2 D' b3 L V) w' h - char *dmabufsrc2 = NULL;1 K) e/ \% q9 v& Y- _& N, y
- char *dmabufdest1 = NULL;
) {& K& ^5 D4 C4 n/ F; Q, R9 D - char *dmabufdest2 = NULL;" M+ ~7 p/ n$ X% ?' v
7 ]# U- ^3 S) V8 V- static int acnt = 512;8 M- G4 c, ~" M
- static int bcnt = 8;
! D8 H. h i6 M) s3 Y' @3 f3 | - static int ccnt = 8;
# X u/ ]! n9 F, c+ c
, C" B; i/ @$ I ~6 V, C- module_param(acnt, int, S_IRUGO);; r5 p* x8 [/ d9 U
- module_param(bcnt, int, S_IRUGO);
$ r1 W2 F- Y. q+ D' n0 H$ P - module_param(ccnt, int, S_IRUGO);
复制代码 ) D5 J" o, B4 j
6 t6 a+ q1 B+ B$ `. n! |% B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. H( h& G$ F. j! e4 |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 r* s' I# ]9 H, x. m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& @& b, V2 E! w7 n' S9 C. J `
- o8 Q) H) F, s, P+ f
% W2 J; @1 A* ^5 f, H$ g0 b) F |
|