|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ ^* k; V* g2 O' R7 O- [code]EDMA sample test application
/ l$ j7 ]5 L5 z& c) x3 A% b- [# p - /*
. i9 j* l: y3 g4 E - * edma_test.c
9 B5 D c& J. ~( z, \ - *
; f& |1 ]( O% O+ Z - * brief EDMA3 Test Application
3 k: e5 A) X5 x( b$ Q - *
" y/ Y" y1 O: X- G - * This file contains EDMA3 Test code.( i: J0 a) I3 V6 f
- *
, u% H; b9 @# T7 \ R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
]( }& t: K9 y! n z' d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" t3 }3 D3 x, ?$ r, W- i - * TO CHANGE.5 |' j4 s' g7 G& d2 T f
- *% y: l6 w$ O! e; I; Q/ B+ ^. v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- D1 j0 E" B3 U9 r$ k/ ^. C4 o - *6 L* D, k- E/ @5 H5 u3 k4 r4 {, Q
- * This program is free software; you can redistribute it and/or3 F! e2 }( J$ \7 w
- * modify it under the terms of the GNU General Public License as
s1 G2 b+ a: `2 H, p! E) m; C( l4 v - * published by the Free Software Foundation version 2.$ `0 ^( Q# [! D" A/ A# q* m
- *6 ?0 w; k) @2 k; n
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 O6 A2 Z- {7 S0 y" _ - * kind, whether express or implied; without even the implied warranty/ m' l/ m" a! x
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' w" S$ M& W1 ?( J' K) ^% k6 V) H - * GNU General Public License for more details.
4 }- C7 M, e$ |) {5 U5 Q - */. Q5 X( l+ |" c* K$ l0 w& @
- # Z2 ~- l0 g, V5 U
- #include <linux/module.h> E1 o) E$ ], O% p4 C6 W/ z" |& r: g1 |
- #include <linux/init.h>
3 _& J8 K+ X/ p, t6 _7 p - #include <linux/errno.h> n" o9 [8 a& {" ^
- #include <linux/types.h>- G' n! N6 k0 A1 ?
- #include <linux/interrupt.h>
9 W# }3 j5 `& t: l9 A) O# R - #include <asm/io.h>
" V2 t( D W/ u. b - #include <linux/moduleparam.h>( y; {, m/ x/ l# m1 ?6 H9 x
- #include <linux/sysctl.h>
" l, S3 S" P& E( j* j1 L L! w - #include <linux/mm.h>1 S* D8 ~/ a4 D5 e
- #include <linux/dma-mapping.h>3 ]# k8 T2 t4 ^7 Z, Y! H1 ~) |. _! \
1 H+ `* C6 E) M2 u6 T) ^) [9 w- #include <mach/memory.h>7 m+ w C; z$ q+ n2 `
- #include <mach/hardware.h>
/ \0 C' I% h$ [4 h& x - #include <mach/irqs.h>
; i0 Q$ G4 O+ a! S- @ - #include <asm/hardware/edma.h>- W. I, X( x2 C
& ~2 r6 }+ O& ]* b- #undef EDMA3_DEBUG; P0 ?( ?. `# i4 ]2 u
- /*#define EDMA3_DEBUG*/
1 d; L' y" _0 l$ b! C* m t - : q# S8 b- k- i3 ]
- #ifdef EDMA3_DEBUG9 m7 W- s& J! X+ }& W2 J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! [# l0 u* H) S- r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# k+ e! @- U7 ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): ]" D& o0 i" s6 U
- #else
* h; S+ [9 S' [4 ^ - #define DMA_PRINTK( x... )6 e, H- w: _/ e$ }7 p) ]: t
- #define DMA_FN_IN6 D ~9 o9 E5 |4 B9 @
- #define DMA_FN_OUT
2 C$ ~. [* a: @+ {2 C1 _# K - #endif9 ~* t& ]% N: S9 U8 r: s4 e( W$ ]: s
( d5 U4 c( y0 Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' e/ T/ Z( K6 L$ @+ F
- #define STATIC_SHIFT 3* I9 |9 p8 V2 C5 Z4 U$ u
- #define TCINTEN_SHIFT 20( i |( q. ~+ @2 k
- #define ITCINTEN_SHIFT 21
. [& g# d P9 e - #define TCCHEN_SHIFT 22
+ o0 c$ f" W* F - #define ITCCHEN_SHIFT 23
1 y W% C! |5 s0 t# Z
, t9 B# `1 I+ }" `* G4 H- static volatile int irqraised1 = 0;2 f/ ` f6 E" J J# `, g+ V
- static volatile int irqraised2 = 0;
# q7 ~) r2 P% I" N9 p6 V4 b4 L/ ~, h - * w) b" N6 H+ R! l7 y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: v( M* P( t9 d - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 k' ~; w( M* K0 {8 ~& ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& ^$ M) z6 K9 u; I
- 1 |" l" c3 h5 k8 f6 i8 o: _" \ _9 t
- dma_addr_t dmaphyssrc1 = 0;9 u; u. X; ^( L( C" o5 F
- dma_addr_t dmaphyssrc2 = 0;
* u# W$ `+ [4 Z6 }4 g - dma_addr_t dmaphysdest1 = 0;0 i5 O# J2 K& ~$ C1 O1 G+ T6 k
- dma_addr_t dmaphysdest2 = 0;9 q* \. Q1 R* k) H0 x+ @
- ! X. u" K. Y) a k4 E3 D. n
- char *dmabufsrc1 = NULL;: K8 N! s. [! ?
- char *dmabufsrc2 = NULL;
; }: ]* F& r1 T3 A' W: X8 t - char *dmabufdest1 = NULL;
/ K7 q$ w# o' W - char *dmabufdest2 = NULL;/ o* X) ]( y: X( b) @
- 7 S) [7 y: H; O, i" X
- static int acnt = 512;
9 D8 @2 W( N! K! |, x8 R - static int bcnt = 8;
) u& }& f5 E# f) A - static int ccnt = 8;
1 a7 [- m) K! A+ N& k4 \( T
. M% m4 M* w: Y: |6 Y ?- module_param(acnt, int, S_IRUGO);
b8 j/ k) d9 o - module_param(bcnt, int, S_IRUGO);
: ]7 o G. [7 e/ i5 w$ N - module_param(ccnt, int, S_IRUGO);
复制代码
, B, n g5 k$ ]% m8 I+ R4 y ~' B2 _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 }) ?3 f* E7 b; V$ M9 ?& v6 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ k ~# O7 N& s+ X; f* R+ W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 L- p5 O3 t3 q. i* T# {& z4 Q: x: \
8 z( J7 R# t$ g, c4 a1 v1 I; c
% b( R6 _8 O$ l6 U |
|