|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) k( R0 e% ?& V2 K- m- [code]EDMA sample test application
2 n3 k& Z ^# n1 u) g! |# { - /*
$ t! j+ p6 ^ Z3 v4 F4 U - * edma_test.c
0 T1 h' p( C, ~% q - *, p1 @# u5 o( e+ z1 U
- * brief EDMA3 Test Application7 H! b! `( y# i
- *& j& K" l$ n+ I
- * This file contains EDMA3 Test code.
, h4 V/ u) p F6 v/ A& Z* A2 Y - *
1 L9 O t \( g3 x. j" | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 Z3 w: V$ W% c9 N0 Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT p& d4 l$ l' h- m; f: K! B
- * TO CHANGE.7 e3 t8 O; t6 i ^$ R/ m: N4 B4 }
- *
5 T2 j5 J6 |8 o3 z+ o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; N @; y* ]6 ]8 ^3 _& j - *- D% w6 j5 w8 D
- * This program is free software; you can redistribute it and/or
7 ]6 o+ G0 J |: I& G/ k" p7 o3 k - * modify it under the terms of the GNU General Public License as* T3 h7 H3 _& E/ B
- * published by the Free Software Foundation version 2./ C2 z( t% A( ~, s. E1 j
- *! N, F c# ?& x. L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 o, b. k8 q I3 D
- * kind, whether express or implied; without even the implied warranty
% y: q, h' i3 O: G0 `/ D+ n2 W( T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ R) k+ I5 N" O7 { - * GNU General Public License for more details.
/ a! Y+ G2 T; ~6 z2 Z' g: M - */
/ `, B5 L. }4 N g( z6 q( ` - - ` V4 J" S+ e
- #include <linux/module.h>1 r P3 i- P* S' J
- #include <linux/init.h>% D0 M/ o; G) S8 \) k# q0 [0 L
- #include <linux/errno.h>
4 D% a' B1 I9 p - #include <linux/types.h>
: P3 ]7 c# _8 h* V7 Y" T - #include <linux/interrupt.h>3 Y7 |5 A2 [6 c3 E) J3 l6 k
- #include <asm/io.h>/ k$ d' Y: L1 G4 W3 z$ A, X
- #include <linux/moduleparam.h>/ G# a( l6 [" o) D1 [! ^4 r: ~
- #include <linux/sysctl.h>' t7 C1 `. v4 p; d) N4 g/ ^
- #include <linux/mm.h>! B4 `" n4 m/ b+ K
- #include <linux/dma-mapping.h>$ q5 r8 u# V1 }' ]. n( P
- ; |8 H" R5 r( d/ k. P
- #include <mach/memory.h>
0 t8 P% ^. _5 ^& p& v/ s0 D/ K - #include <mach/hardware.h>
2 B3 ^. _ Q- g! Q" c; G# h - #include <mach/irqs.h>$ J( h+ z; F" U5 @
- #include <asm/hardware/edma.h>& |+ b9 g/ l* X0 i5 o$ M# c
- 2 i) |) R( h2 P. s
- #undef EDMA3_DEBUG
7 H' F$ [# c5 V) T5 I( [0 p3 L - /*#define EDMA3_DEBUG*/9 \, P& r- Q3 [" q$ `
* Q+ @2 m2 M/ _- #ifdef EDMA3_DEBUG
, q0 B" A. P/ h# | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' }8 [; v3 m7 Q5 Y `8 G- t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): V: ~1 k) X9 ^2 \. k/ H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 J6 h1 T8 Y1 B9 Q8 K/ k2 s - #else* L( \0 u4 `0 A( L% s% N
- #define DMA_PRINTK( x... ) {) l9 r/ ~/ O. }' n5 Q
- #define DMA_FN_IN
3 s( B/ J9 K) Z, V6 k1 r/ c - #define DMA_FN_OUT" I5 y* W0 e3 F* a5 Q4 q- J3 S
- #endif6 g. m' Q6 h4 l3 x
- " }+ f$ o) k/ C" V4 \% v/ t. j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ Q1 S4 n7 u& v8 i/ @ E - #define STATIC_SHIFT 3
+ Z; ~. ~! E% G1 h* N5 h - #define TCINTEN_SHIFT 20/ n; Q7 [ U) ^' I9 W- z1 f& N
- #define ITCINTEN_SHIFT 21 w- h0 o& A. }+ [% Z$ G
- #define TCCHEN_SHIFT 220 h7 ?- g" {2 T7 _3 O
- #define ITCCHEN_SHIFT 23# L1 T6 ~/ J$ I1 h
- , w' L# n/ x O4 r/ U& ?- ~
- static volatile int irqraised1 = 0;
, Z: i X0 L3 w" r0 y - static volatile int irqraised2 = 0;4 x3 o! o5 o; m4 ~8 B" C8 l& I# u! G
9 t6 _' y; l @0 P" ?8 }6 z. p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 C2 a% b2 x6 Q4 P( a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( ?2 Z' F7 |1 |" E J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" }" g% [+ F5 j7 V: Y5 n2 @
- 0 B G2 b' U' R! i+ @
- dma_addr_t dmaphyssrc1 = 0;( ]) B; \7 O$ P9 q; V( n
- dma_addr_t dmaphyssrc2 = 0;
- ~$ `% Q; e5 X* h: H$ f: S4 E& x - dma_addr_t dmaphysdest1 = 0;
& X- U S% \1 X - dma_addr_t dmaphysdest2 = 0;
5 M. ^5 n( R V& J( J: [ - , d6 j! @0 l- W
- char *dmabufsrc1 = NULL;
* v9 q. c3 [: r! G- d9 M# ? - char *dmabufsrc2 = NULL;
|% R' P( n+ N - char *dmabufdest1 = NULL;
% L( ?. ^( X' G. `* s - char *dmabufdest2 = NULL;8 S) T; H; |/ t M9 {6 f
* n% B6 n# P6 Y; H' F- static int acnt = 512;' R6 s% P. s |- s, F, l
- static int bcnt = 8;- k7 `) A6 `5 Q% g! q; S
- static int ccnt = 8;0 w) e, [2 l0 N- F+ R
- ; Z5 R. U6 o7 o5 H- N& B
- module_param(acnt, int, S_IRUGO);
, z* F$ i3 c, q* r# V - module_param(bcnt, int, S_IRUGO);
# R0 B, a& l% u+ B- X, s @ - module_param(ccnt, int, S_IRUGO);
复制代码 " J* L3 s+ ~. y0 b# T- M( b8 i
, ~3 e; c; @3 H7 j7 g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: }! Q1 z" U W2 C7 p) |2 M4 {& g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ d4 j+ n M, [; I3 h( G: O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 [$ G" A) D4 l1 Y( g
% E$ A) V6 r9 c; B/ T. M
$ I( A) a$ a7 N, X) G9 _ |
|