|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # S( y$ l5 H6 O& e6 i* T$ ?
- [code]EDMA sample test application
# F* K+ N0 }1 w; R4 Z$ d - /*. b ]4 @# |1 n7 d" M
- * edma_test.c
, X w$ F2 `; z6 s; m - *& {4 t. g* F1 j `* U
- * brief EDMA3 Test Application
) Q% m4 }! }5 [, z$ R: q7 _1 V7 I - * x$ X' c1 L5 A6 h0 M+ ?" J( T" b) w
- * This file contains EDMA3 Test code.
& V+ M" K9 Z) ~. n0 m3 `3 G; ~ - *
5 U; f: I4 d6 X0 b2 |# S5 A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; A' A% h6 j7 C8 w7 G) ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 A) H% q. _3 A O' V, {# K - * TO CHANGE.
8 D4 {% f! d6 `+ X& D5 } - *
( ^9 j8 m9 u/ g2 W5 U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ }0 ~$ @3 q2 {, Z7 ^# V
- *
' F. }& }/ M& g - * This program is free software; you can redistribute it and/or- D, F! x/ l. g/ T6 ?- y
- * modify it under the terms of the GNU General Public License as
! e4 ^3 j0 p$ d# H6 x) b& ?8 H - * published by the Free Software Foundation version 2.
3 I( y) g% d; o' M2 Q; V; ~ - *
o/ M% k( t, q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% E8 V' t( n4 D! {6 b6 | - * kind, whether express or implied; without even the implied warranty' W" T3 A- ~9 S" F9 G' d9 {
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 V7 }0 Z2 f- z, h8 B+ ?3 P( S! V - * GNU General Public License for more details.& D$ I8 b* {# {% w& ~9 O6 @! b
- */8 s" h9 M' e& |8 T1 h% m' z+ l
3 ^2 j$ _) `, m; }- #include <linux/module.h>( S1 E( D# W- N f8 p
- #include <linux/init.h>" ?; h/ S3 S/ @
- #include <linux/errno.h>
& q! J7 I5 _$ g9 g& W% M - #include <linux/types.h>
* z* ]* \ L2 @; j* x% ], f - #include <linux/interrupt.h>
D/ h" ]7 u* L( t1 O! o d; e( K - #include <asm/io.h>
# ]0 u n/ v' ? Z, F; b2 F A - #include <linux/moduleparam.h>
3 G9 w# ~( @( V - #include <linux/sysctl.h>& L* z* V# y; v5 ]' O
- #include <linux/mm.h>3 g" d9 g- ~9 L+ {6 o
- #include <linux/dma-mapping.h>
) X8 t2 c. Q+ S - ! w: m+ J8 ^- w, s( g" b
- #include <mach/memory.h>( l1 b7 t+ L" B# q" t- E7 E
- #include <mach/hardware.h>
, x/ q: f. O a3 h - #include <mach/irqs.h>* n3 ^8 j: x- u2 U) `
- #include <asm/hardware/edma.h>
, r2 u1 n0 M# Y
/ i2 C- V1 J3 e: `4 U# m- #undef EDMA3_DEBUG
6 o2 z9 K" V R6 G - /*#define EDMA3_DEBUG*/. ^! S! h4 G- K( T
- 2 k' h. z$ ^1 q
- #ifdef EDMA3_DEBUG
& |( r5 n. i( `: m7 B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 ^- W8 ]5 }! l3 o- [( T* U6 ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 w) `# B3 k# d- k
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 i7 ?4 H: m j" `7 N - #else
' z0 d# U: e1 N- D% `; E9 N2 h! B I - #define DMA_PRINTK( x... )
" ~ v/ X: M4 U0 j8 E - #define DMA_FN_IN
4 _. b- e- `# p# i7 Y$ w! c0 d8 \ - #define DMA_FN_OUT& p" n" P. d# ]" M6 `3 n6 x
- #endif
+ f; t9 z0 X* Z$ h7 b; c. Q0 ~ - ( l$ X. G! n& O5 z8 k" _" R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 M- l T9 n. ~; U5 n - #define STATIC_SHIFT 3( Z! V( l. a# p! s5 T/ V
- #define TCINTEN_SHIFT 20) o: g D. S2 a4 R5 Z
- #define ITCINTEN_SHIFT 21
N$ ~9 z7 _2 f) h; t! P/ M: i - #define TCCHEN_SHIFT 22: S, k" R+ n. H
- #define ITCCHEN_SHIFT 23
5 j+ y( \3 y% O& z! i
2 D) p: T5 g4 c& C- static volatile int irqraised1 = 0;
& c6 N" Z$ N+ K7 T& L - static volatile int irqraised2 = 0;
4 S3 I4 a3 m0 M; A$ v% f
~/ r5 _. r, M' V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 L4 X/ Y" A4 B$ C1 \4 J: Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% y ]0 ^7 ~2 F; P4 Z1 P+ e9 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* d; i+ ]) l `# _4 {
# Y7 Y9 H5 K& P9 l) W- dma_addr_t dmaphyssrc1 = 0;4 O% v; ^( W" C6 R3 S
- dma_addr_t dmaphyssrc2 = 0;
* ]! R" T. B( e# e1 m1 u; a - dma_addr_t dmaphysdest1 = 0;
0 ?: o0 @9 @! ?% d4 e2 J - dma_addr_t dmaphysdest2 = 0;
8 ]* r) G+ n9 [: A& z/ r n+ A
- b% Q6 G3 L7 N. i* Q2 b% { Z- char *dmabufsrc1 = NULL;
* Q! _3 W% @1 \! S - char *dmabufsrc2 = NULL;4 Z$ [! z- y4 Z
- char *dmabufdest1 = NULL;
( i$ e( h5 R4 w - char *dmabufdest2 = NULL;
& F4 \3 c+ m6 I3 @4 ~$ L n& e - ; h) s+ H; `' h6 i
- static int acnt = 512;
: w1 b7 K) x( P. f9 q+ a3 ^) [7 I - static int bcnt = 8;9 [9 ]4 K& J& N
- static int ccnt = 8;
4 z; _* k; _+ W - 4 V6 e2 O& k- U v3 V- g
- module_param(acnt, int, S_IRUGO);/ x% {2 H7 Q' A( D1 h, q
- module_param(bcnt, int, S_IRUGO);8 T. |- J8 L8 B: Z6 `
- module_param(ccnt, int, S_IRUGO);
复制代码
( b% W& q" n: y' A# U' y5 l! `7 [+ ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- r" C0 t* P$ ^# Q/ z6 P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 \3 O Y% @) d3 I9 S. c9 w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 h) C5 v3 G' |: K/ e
; A G- ]& E4 ^% c% f) l
3 p! q1 ^1 r, f+ E# o |
|