|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; n3 {. x; _2 R: s3 q. O! y- [code]EDMA sample test application
# v+ F3 K! W& f- l - /*
, Q1 V/ @5 ?6 b - * edma_test.c
- W% E S5 p; f) P+ E! w% ^4 t - *
& ~9 s1 W. u5 [. G& N, w - * brief EDMA3 Test Application
1 p0 ]- S3 W. Q2 e' l1 _ - *
! B' X% i; c, f9 B: I; S# Y# v - * This file contains EDMA3 Test code.
( f' k5 @8 B3 |$ N5 K! p - *( G" p/ z- C* J$ }8 b. h$ a
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 ~' B8 L7 F+ }2 o4 D* k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 I% u6 I' i( z- n - * TO CHANGE.2 \' d& `* F3 X' p# e1 J& S. ?
- *& _2 i6 q4 A W- L. N! v( r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ \; V7 d9 }% J! Y
- *
6 q( X+ |8 X: A. n& @ - * This program is free software; you can redistribute it and/or0 T: i. _! Y$ k: `) P4 y) m
- * modify it under the terms of the GNU General Public License as
8 ]4 e" |* c0 h6 E8 Y1 n - * published by the Free Software Foundation version 2." L8 P9 D' g3 N* E( Z3 A" T
- *
% J! t& s0 F. D8 B0 j& t# A- R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 N N2 [6 F, T# G
- * kind, whether express or implied; without even the implied warranty+ C2 R4 |7 _9 z" j, a7 ?; B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# b5 t7 O* s0 y9 e4 `2 a
- * GNU General Public License for more details.$ i7 k5 Z6 b" T" X) B) {
- */+ C5 }3 |5 _) A+ ]3 X
! F2 `& r0 Z+ h v- #include <linux/module.h>2 Z" y S+ H5 q3 {' e3 m
- #include <linux/init.h>8 A [0 y; X |: L1 [
- #include <linux/errno.h>1 U! [6 |* v+ {& N
- #include <linux/types.h>8 R& j! P& a; ?" B# Y1 c
- #include <linux/interrupt.h>: M, f$ |# L; t( e2 T3 J
- #include <asm/io.h>
) \1 }# P6 U9 k) r3 O! P. O! D - #include <linux/moduleparam.h>9 p. L4 u$ \+ i+ @- y2 C& A% t- s
- #include <linux/sysctl.h>
& M( T7 F& z0 {9 D - #include <linux/mm.h>
: U# X) I+ K" Q4 _% [ - #include <linux/dma-mapping.h>1 C5 b: ^: z. U: e" _7 ~
- " [6 W0 |0 g6 c6 X( H5 }
- #include <mach/memory.h># P' B& N3 Q+ R2 v% d5 I9 p0 J
- #include <mach/hardware.h>
3 L* d- c D9 u* P$ Z6 ` - #include <mach/irqs.h>
( b* |- u1 t" o" Q* ^9 p - #include <asm/hardware/edma.h>9 Q+ \; v) A r& S5 j
/ ^( q: e* W) d p; i# h- #undef EDMA3_DEBUG" m% I; J0 L* V% y3 K
- /*#define EDMA3_DEBUG*/) @( L( I8 t" I a0 j9 ^" S P; Y; \
- - }' ~+ k+ N+ w# A6 \" W! k
- #ifdef EDMA3_DEBUG
' L5 P' R2 P4 Q+ s1 I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" K: o' E) k- v/ d. k% Z: `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# X9 t; P, o( S* B - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): W) s# X5 K" d% G' _, g) ]
- #else1 }8 N: w; U! O7 M' J8 K
- #define DMA_PRINTK( x... )
2 K' h- c: p8 M - #define DMA_FN_IN! [: {1 V; ?' E' k" J
- #define DMA_FN_OUT
2 `/ L4 M7 C6 f8 `7 O4 r* g - #endif
; g6 @7 o$ J9 U8 R* d, p2 D
0 V7 |9 Q! N: o. s4 N& k) A0 |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 K$ u8 X* B2 ]6 Z - #define STATIC_SHIFT 3 p- J( n; y0 z6 ]) g" o/ j
- #define TCINTEN_SHIFT 20% @- [2 y* o2 f- D/ S
- #define ITCINTEN_SHIFT 21
3 c6 U) P3 ~- h7 } - #define TCCHEN_SHIFT 22) u" Q+ A) l" K }0 R7 @
- #define ITCCHEN_SHIFT 23/ K5 K) B2 P C( G+ S
, H0 `& f; u$ Z3 A- @) E- static volatile int irqraised1 = 0;0 k3 B8 z) X5 o( m, Q& S
- static volatile int irqraised2 = 0;
2 _7 r7 L+ r9 Z - 1 l" G/ R# n8 _: l1 j0 [5 M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 c8 j1 r/ V& N% V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ E) W& c Z4 a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ [9 v) _7 j9 U. M
2 ?' f0 E- q" C9 Q2 G- dma_addr_t dmaphyssrc1 = 0;
# l8 t5 W* n7 J* w( c - dma_addr_t dmaphyssrc2 = 0;
8 Z4 P- w4 Y! q+ a0 `- F - dma_addr_t dmaphysdest1 = 0;$ R9 H' Q1 j* t- Q* K! ^7 q; c0 l
- dma_addr_t dmaphysdest2 = 0;5 z3 K# {+ v7 T1 u
- 5 Y. _. c; F$ b9 @
- char *dmabufsrc1 = NULL;
5 ?* e/ ~# M r) [1 B) p - char *dmabufsrc2 = NULL;! V( S. E, Z- z' p* z7 P2 v; Z
- char *dmabufdest1 = NULL;
5 t- v( {. G% D/ J - char *dmabufdest2 = NULL;( O) F0 ~- m9 f1 j; |! G
$ B4 M6 n: T7 s: K; j" {- static int acnt = 512;& X' n+ J0 n E6 m4 J
- static int bcnt = 8;! H1 b1 Z/ x& P2 {
- static int ccnt = 8;
& d/ t! }) A0 I: g: O% H - . `2 l* ~8 M W+ W# e0 N7 x
- module_param(acnt, int, S_IRUGO);
5 `6 V; }& i* Y - module_param(bcnt, int, S_IRUGO);
, p) q8 _8 |$ a5 k - module_param(ccnt, int, S_IRUGO);
复制代码 ; K; m8 a, q( a8 V/ ?3 e+ j! o/ |
T/ h P/ B4 u c/ g/ q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& k8 }* @$ o' ^; v& L: D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 g4 {& r* g' b: ?. Q' W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 x& d6 G; u8 S3 J3 \/ F/ t' A
# s9 x( ^% o6 Z _/ f+ Q' i/ g' ^, H! @' {
|
|