|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 o7 C1 q9 I" G8 S# f- [code]EDMA sample test application
1 u1 D+ J& g6 N7 W& G* q+ H5 E' T - /*
/ _- l, ?$ H; D: m; S+ ^ - * edma_test.c+ l, T% X; l: p
- * H: S$ A* K, s4 l1 r9 b
- * brief EDMA3 Test Application
z& h5 `" k: G" k; Z - *
( g+ U8 |) F! D! l1 w- T( A - * This file contains EDMA3 Test code.
3 s q: y% H2 M+ Y - *
3 t0 j5 O: a% M+ M- e) f9 X" w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% [0 @# \) W" b- M' J4 R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# z, W/ Y1 T1 ?- K - * TO CHANGE.
) d, g# v7 e6 N% i0 ^& X4 f" D- a - *2 O# Q8 X8 s7 R$ d( y% g. k1 z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; T) f! A5 n3 T - *# h' V! M& O) n( D6 _3 Z7 } w, w
- * This program is free software; you can redistribute it and/or8 C" L: m/ F8 P( e; j O7 `
- * modify it under the terms of the GNU General Public License as
6 \( c" T0 a9 x; Q6 P2 V9 g - * published by the Free Software Foundation version 2.
$ l# Q7 v& K% A4 s, m, B - *
: Q/ f9 m+ M0 e' r5 E1 w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
R" Q7 ~" \2 W; E" W - * kind, whether express or implied; without even the implied warranty p2 ` @7 ?8 W6 U( @$ }' g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% L$ _0 \2 H# I# n& g1 s P! }6 S
- * GNU General Public License for more details.
; r+ }. t1 I5 w; q$ Y* q$ s9 E a& `" c - */7 L* i; j$ i: y& m, U0 z
. i7 ]- H$ j% z* q1 k- #include <linux/module.h>' S& y( N0 _+ ]+ s. r, S( m* c/ X
- #include <linux/init.h>
- ^% b) S+ |$ @' \% {3 F - #include <linux/errno.h>
8 E- z) U- C8 x7 y - #include <linux/types.h>
0 ?, }! s- u4 I- {0 s* T - #include <linux/interrupt.h>9 U' t/ z6 I# H: X0 S
- #include <asm/io.h>
" a' d. U2 W/ O( D3 c2 O. b3 ? - #include <linux/moduleparam.h>
E( n" Z7 y* d/ |' U - #include <linux/sysctl.h>0 r% ]5 i) r& A$ C6 b
- #include <linux/mm.h>
3 j3 ~: k' U6 _ N7 r; X - #include <linux/dma-mapping.h>* Q# d+ u3 h& e) t8 r9 I
3 ?8 N" M+ L' F) j$ X- #include <mach/memory.h>
4 ?6 C4 r" B8 r7 k; J( p j: ~. } - #include <mach/hardware.h>
+ ~' R$ R$ _2 D# g$ q& o$ ?8 C - #include <mach/irqs.h>3 |7 | x7 G/ a# ~" k
- #include <asm/hardware/edma.h>
: d# d) c$ t" s9 b& ] ^4 A - * N7 o" f: j0 y I5 f' N( j& o$ m5 b4 W
- #undef EDMA3_DEBUG
% h' u( Z, f! D) `9 X - /*#define EDMA3_DEBUG*/
2 W) C; K- S* X9 p( f0 T7 R - , H; q( V, ?' f0 W$ K) j4 v
- #ifdef EDMA3_DEBUG
, D1 ]& I$ |! @- ^7 f6 t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ O6 f0 k6 R5 h/ d/ ?9 N - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ E/ I2 M% r* s' K
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 p6 o4 D8 u1 C! S* s9 F3 L - #else
! C( R# v+ y$ ^# r$ j' u0 \ - #define DMA_PRINTK( x... )
: r( Z3 U3 d4 |: a# @9 K& J+ a9 S7 p7 [ - #define DMA_FN_IN
, o# ]% _7 `; H8 M% j4 ` - #define DMA_FN_OUT7 b2 V2 _+ {( _: y
- #endif, \" T H# v) Z+ R
- % k* k7 X2 U' V0 R% w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" u5 H, a' W! R# w( f) u - #define STATIC_SHIFT 3
0 o5 O6 ?7 ]+ z& J' g - #define TCINTEN_SHIFT 20+ S8 x+ w# R% l. m) }3 |" \5 @! S
- #define ITCINTEN_SHIFT 21
7 j" r4 b! E2 E! M9 }; \ - #define TCCHEN_SHIFT 22+ R, E$ b+ P1 w
- #define ITCCHEN_SHIFT 23" V) S( r6 K8 e6 ]' l1 N$ O6 v
- , `2 Z3 v- L4 P" s6 s. `; |
- static volatile int irqraised1 = 0;
! W- {; L/ @; g( S1 s2 f, S$ c - static volatile int irqraised2 = 0;
; a- ?# a; E% G$ A
3 ^. W3 v" w: r) L: S; r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
W+ |% \, E/ v# b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 r: |3 ]! I. z, o9 I' [& W - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; U O8 R! A" J4 i9 `
- * e0 O5 Z9 N( w9 ?7 q1 y# D5 E0 a
- dma_addr_t dmaphyssrc1 = 0;
" O' c6 U+ i' l7 }/ u) A+ R - dma_addr_t dmaphyssrc2 = 0;
1 @* ~; s D' G - dma_addr_t dmaphysdest1 = 0;& o+ p% Q0 z5 A( D
- dma_addr_t dmaphysdest2 = 0;) w: L: X$ h% Y
( h$ U% j8 x1 U/ E- S0 l5 H- char *dmabufsrc1 = NULL;9 T4 p( U5 ]3 o3 t2 T% } ?
- char *dmabufsrc2 = NULL;* O7 |( D' W f, P; v
- char *dmabufdest1 = NULL; ]. g6 E9 E; w% W" G& U3 L
- char *dmabufdest2 = NULL;
2 G2 O) U- ^6 q2 R1 @ - # P$ R6 S7 e' |% |! F e
- static int acnt = 512;
# z* m/ ~2 w4 n. \8 y8 ~" N8 w1 v - static int bcnt = 8;# _% j, T a. A; M- m
- static int ccnt = 8;2 K: h0 [% R3 D* v! N; N
V1 v' n7 G- x& Y4 W: \- ^: f2 T3 e% `- module_param(acnt, int, S_IRUGO);4 A8 j" |, Y2 k) \: L, W# _
- module_param(bcnt, int, S_IRUGO);( t$ P8 O- s9 `" X" f
- module_param(ccnt, int, S_IRUGO);
复制代码
8 Z$ G8 z1 y9 D! Q. l! T6 o$ f! @. e: _7 q3 {4 Y3 t1 m; t' V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- S( K1 Y" n5 b- q) s# O+ V+ Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ B* {2 u$ {5 N/ g) b: ~. F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ ^# T. _+ w9 C
. s+ f: X G) y
8 m) n# K6 J f. i5 A0 m |
|