|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 T) Y4 @6 O2 r- [code]EDMA sample test application
" m' k' ^. C+ ?7 y A% o - /*
+ @, Z! N2 h( I: V9 L5 q5 Z5 I - * edma_test.c& f5 t! R% Q. X2 g4 H% K" v6 ^
- *
4 e5 d* F1 r; @ - * brief EDMA3 Test Application
- n7 H! V; a/ j: `9 w) [ - *8 `& a: Q$ I6 a. ~% d
- * This file contains EDMA3 Test code.: L9 d* n3 G) ^1 O1 R; J
- *
, h: U! G) W4 w$ j5 B* n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- a; `# r5 b( v3 |* e: N% V6 R+ A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, h7 ~0 A! X* O" y8 Z. ~ - * TO CHANGE.
' {4 p9 o0 C3 c( N - *6 Q" W0 W+ B* m8 h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 w5 o) j# T( h8 J
- *& ?* L- X/ }7 C5 m b4 m4 S& F1 `
- * This program is free software; you can redistribute it and/or# d3 ~7 J; w8 X! o. l7 J
- * modify it under the terms of the GNU General Public License as
7 M0 ]& z. N" x& H9 g7 }' O6 ^ - * published by the Free Software Foundation version 2.# ^( e( }- t# M# E- w& E
- *
: L' T! h. i: Z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 x- G. D! ~) U. A, h
- * kind, whether express or implied; without even the implied warranty
; S: e. @+ L& p9 Z* g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 _, P1 z: \ Z# c9 |# P7 w& d) k$ ^ - * GNU General Public License for more details.! q- n) j/ i8 T5 o
- */, ~% Y* R$ o/ L1 O' _: ~$ r
( r/ c6 T q9 g8 c- #include <linux/module.h>
$ J% B! E9 `7 V. j) b- o - #include <linux/init.h>
, ^6 W; k0 m9 o% Y4 E% \ - #include <linux/errno.h>- e' {% O0 m' d3 y1 Z5 d. M
- #include <linux/types.h>6 x6 e U- Y: E& w2 o) u. @; `
- #include <linux/interrupt.h>" {" J; B; _9 \+ z0 V8 d
- #include <asm/io.h>
8 h. P3 P- d8 a3 i2 S1 n - #include <linux/moduleparam.h>
3 _6 c* [- u$ M1 n - #include <linux/sysctl.h>
* r% E5 [8 t/ L) E% ^9 e - #include <linux/mm.h>
4 Y) v/ C* y* _: y! Y - #include <linux/dma-mapping.h>
1 [# E( W6 Z9 {: e i4 B5 x - ) I$ T! _2 H1 t# q$ r$ W9 y+ _
- #include <mach/memory.h>0 _& B' k( i. Y5 h
- #include <mach/hardware.h>1 P9 N. {' n N
- #include <mach/irqs.h>4 f4 o8 l2 f1 r7 V I! D5 `5 o# Q
- #include <asm/hardware/edma.h>$ O3 m) Y8 u: a2 L) c4 G& ^7 G+ `
- * C3 s* U2 j0 {2 K5 v
- #undef EDMA3_DEBUG4 ]8 k6 d/ r- }# }+ x9 R
- /*#define EDMA3_DEBUG*/+ O' l5 Y- b! ^+ q7 [7 ` C( ?
5 {2 q+ t9 [+ Z6 N) a9 I- #ifdef EDMA3_DEBUG* n# O9 O5 d: m, g
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 ?( M& J* x9 I7 {6 } B# A0 W& B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): b, E/ f* f$ f' U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 p& G7 q# \7 b; [6 N, T - #else
! d/ \$ X( t2 m+ }( b - #define DMA_PRINTK( x... )
1 I7 Q1 w7 L z - #define DMA_FN_IN! L, ]* e- q B }* o; @
- #define DMA_FN_OUT
! a t$ Q: j5 `7 t4 l' J( B - #endif: h+ D9 p. D" N+ {& f, r$ r8 D
& U! U2 q. [! z( ^ F, z5 Q$ E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; ?" e/ q9 C% E' A. y - #define STATIC_SHIFT 3: O8 _( N; V( c) @; B
- #define TCINTEN_SHIFT 202 _9 X/ a& ~) d9 v
- #define ITCINTEN_SHIFT 21
; l0 Y* c N' Z0 Q8 I - #define TCCHEN_SHIFT 22
A0 g$ Y$ s; m- |5 G& E - #define ITCCHEN_SHIFT 23
3 D- B S; ]+ b+ O0 O# X# Q8 U - 9 J2 m) k2 x* K7 m/ S* c$ e
- static volatile int irqraised1 = 0;
4 n* C' n" l3 b9 c' e# i- ]1 Z - static volatile int irqraised2 = 0;4 h: D- K# K4 L+ l1 @4 M) _7 n( G
- / l' { E7 k# q8 f, H( W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 w" j7 C8 |) H7 g# N1 T( P( C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( a( {, M9 T2 e; A& f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; m! s$ a' S- ?7 o
, G" N" s) r7 Q+ |. E, v* I8 M. B" I- dma_addr_t dmaphyssrc1 = 0;4 t" ?* `! z$ r' q* W+ `6 ^3 d2 Y
- dma_addr_t dmaphyssrc2 = 0;
5 V: D6 e, R( a' w- u; ]4 h, p - dma_addr_t dmaphysdest1 = 0;/ x1 {+ F: y: j
- dma_addr_t dmaphysdest2 = 0;
/ E3 G) d+ j* D4 h$ c( P) K - " N( `3 P, e0 j+ V+ w0 D) ^
- char *dmabufsrc1 = NULL;
+ T7 i& _8 d# K2 W - char *dmabufsrc2 = NULL;
5 f0 o: P! I* L1 I& N& j+ Y - char *dmabufdest1 = NULL;
: p8 I2 M# a+ n2 ` - char *dmabufdest2 = NULL;+ |+ X3 l2 k% d; N/ u/ g
- / e3 W7 E. ~% z3 d; A
- static int acnt = 512;& d: D* D0 @( }$ I7 w' E
- static int bcnt = 8;
* |! C& u' }. `% D9 S k - static int ccnt = 8;& v" w$ b) h6 G1 G ^& ]8 W' X5 F
5 z+ e, {; C8 l8 k- module_param(acnt, int, S_IRUGO);3 a4 F1 i# C+ j5 t: Q$ m" e
- module_param(bcnt, int, S_IRUGO);. A7 l5 {/ X1 z4 A, P( ]
- module_param(ccnt, int, S_IRUGO);
复制代码 / V1 O/ g6 q) C w' b& K# g
4 h" F5 g4 K4 [) j) y' Y9 b5 `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" ^0 F; T6 b! N) x+ k4 g8 T, s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 ]4 `0 h& ~5 T& K
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ D$ K# V0 l& q
/ ]. d. T8 [! s1 o( I& j, w
2 R& u0 Y& Q" v# @% \, Y2 ~
|
|