|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ m. U& n6 f& q6 x& b- [code]EDMA sample test application5 T7 o0 B! J7 a/ E- h7 t
- /*
# J% o. }4 u* j - * edma_test.c
0 [& C# j) L! F4 [( W0 P - *# K: Z8 p& u7 F3 e$ p' V$ }8 i/ @( z
- * brief EDMA3 Test Application
& u: {1 A+ {8 d$ h; T) V - *
# U+ m0 ^* k) m: [) Q: P ^ - * This file contains EDMA3 Test code.( L! b# d& k+ Q5 R+ m/ {% g& d4 O* a
- *
! u9 Z, P6 U7 w9 {- g& P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- h( I) q& ~! B! X: `9 ~( \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% I4 k% D5 l: i - * TO CHANGE.: P4 B3 |) k P7 m9 W7 l
- *
0 z# `$ B9 G% n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. S& A! g4 s0 A8 b5 m5 H
- *
0 y' n' G4 T) X2 Q6 _6 J2 U, P - * This program is free software; you can redistribute it and/or1 ]' L4 X% q/ m" M) n
- * modify it under the terms of the GNU General Public License as5 b, }0 e: f# {
- * published by the Free Software Foundation version 2.! {1 ^, d5 C& Q
- *4 h. h9 \5 W; w" r; P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 @; D- |' |0 t - * kind, whether express or implied; without even the implied warranty
9 \9 G. Z% H' X5 X - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. k! x2 P& Z% H - * GNU General Public License for more details.: x7 f( _- P3 v3 j+ j
- */
% E ]+ H; {4 h- `* I6 z$ |4 { - + |$ _6 s. F* u% L1 v3 j: V
- #include <linux/module.h>( l4 ^1 {0 L" _ ~; l
- #include <linux/init.h>) d0 m; l8 f9 k# H
- #include <linux/errno.h>
4 T+ q; u4 B3 y1 W: J - #include <linux/types.h>' ~2 I1 k! F. C% o, }4 ~2 c1 q
- #include <linux/interrupt.h>
8 D" h9 a }9 u V: c, N7 F: O - #include <asm/io.h>
( I& A; s' ]) z, I0 S& O9 m; V - #include <linux/moduleparam.h>, V% l6 {' \+ Y1 j: C0 y: o( K
- #include <linux/sysctl.h>( z; }; C% L( O6 K9 T
- #include <linux/mm.h>! t2 p- ^, f2 q
- #include <linux/dma-mapping.h>4 C3 k: G" l' T' ] x9 ]. f. x* D
- x4 N' l: Z, ]+ G/ f- #include <mach/memory.h>4 ~% D# b" C3 j; w1 f& k8 @4 s
- #include <mach/hardware.h>2 P% A# p, P7 a* y7 Z, U7 N
- #include <mach/irqs.h>
& X- o$ M2 o" S l0 }: ^ T - #include <asm/hardware/edma.h>! }+ C9 V) ^. l- x+ [0 d) B
% h' g* W2 d9 n4 }* H U" Q- #undef EDMA3_DEBUG' o' s# P/ x2 g; l
- /*#define EDMA3_DEBUG*/
" l, u6 U( _* z' W
( D2 y5 l, s1 w5 m7 ]3 N5 V- #ifdef EDMA3_DEBUG0 s3 {+ f/ n4 z) m+ E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 [! X: ]* y4 Z2 `& a% p' h
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 G, {2 x9 Q5 V9 ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! t& S# M5 R; X# U+ _$ J& W& J$ o0 G Z - #else
- j o: s% @3 | - #define DMA_PRINTK( x... )
3 `* o6 f6 F2 F* ], x9 i/ Q - #define DMA_FN_IN3 N, \* W; } ?" e
- #define DMA_FN_OUT
2 a, T# {: m- S7 {" p4 n - #endif+ w# p7 K! d3 y- z
+ Y! }$ J/ F) l' t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 I7 Z, v9 [0 ?8 E4 }7 ^/ i
- #define STATIC_SHIFT 3
3 ~8 ^% f3 k) i! Z - #define TCINTEN_SHIFT 20
* f) L- Z/ l7 i+ q; c a2 B - #define ITCINTEN_SHIFT 21
0 \* A5 A* M/ u - #define TCCHEN_SHIFT 22
" q% | }$ T! ?2 v - #define ITCCHEN_SHIFT 23
( J, W q2 F m' y - , e4 y2 j. x2 v5 Z! [
- static volatile int irqraised1 = 0;
1 z1 u0 P( W7 ? - static volatile int irqraised2 = 0;7 {3 q! h6 o W1 r2 q
( {# j F7 K- e% W! e; a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# r8 w/ g3 H; t' _7 I, o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ N( i) o8 W$ ^9 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, l" {. z( e3 x) y
% F! g9 ^4 V6 r" w- dma_addr_t dmaphyssrc1 = 0;6 z( N$ W" c; k' q
- dma_addr_t dmaphyssrc2 = 0;: d7 x; x2 A+ U' J% m8 M
- dma_addr_t dmaphysdest1 = 0;" w( q( ?2 m6 Z, T7 i
- dma_addr_t dmaphysdest2 = 0;
+ Q. Y% E7 x$ H1 E - . _( R9 k) z* j* n/ U
- char *dmabufsrc1 = NULL;' U" K) I3 E, W, ~' K( j& @& U5 k1 F
- char *dmabufsrc2 = NULL;$ H( y! s0 S+ b* z$ g/ l. ?
- char *dmabufdest1 = NULL;
* K0 x/ ~5 T* u- F; ~9 _ - char *dmabufdest2 = NULL;: O3 y1 W5 z. v5 a( ?
) Y' g2 [/ M v& S7 d; {% Y- static int acnt = 512;
+ _. n" ?: m' c* z - static int bcnt = 8;1 ?6 |6 s9 T* o# X, b: z" \9 }
- static int ccnt = 8;
2 a0 W" m$ J% O2 s. f4 R
6 [" E& ]: e1 w: B, v% {& T" \ }- module_param(acnt, int, S_IRUGO);
; V; {' r$ T; F5 K% v f$ c - module_param(bcnt, int, S_IRUGO);+ `! Z5 g+ j: H z4 T
- module_param(ccnt, int, S_IRUGO);
复制代码
, j+ H' U. M1 K$ k: S Y) f+ @. e: o. n4 h- q! K
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 a/ u6 h0 ~9 w$ k, 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% E! A' x; x, y6 S, q: x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 _* [% @! C' j! ^/ h
7 h/ K" f8 [8 A6 L5 @
- k; c* t, P; H9 p# b9 p |
|