|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 e- h% M( `5 ~+ X- [code]EDMA sample test application
, Z. k$ n( o! E" f* e% L6 V2 } - /*
# l9 D6 W7 O3 ^) G - * edma_test.c
! X& l( t4 T1 u' }+ H/ R' F; _: Q - *8 @6 E5 {* j! s2 u$ N
- * brief EDMA3 Test Application
! z5 Y; _+ r* r9 b, L: L - *
6 ^: J7 M4 C8 n5 t& b! `0 S$ x - * This file contains EDMA3 Test code.5 i* w( @ c& u/ ]8 @ {
- *
, U+ ?( e! P5 e- [6 p; z) j' B& Q! a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) _- R( k: q; ~0 M! L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 ^+ `6 S+ I% J/ i
- * TO CHANGE.1 e5 l( \7 }; F
- *
`- M+ w- z& H. h( @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 l# a- D& R6 m% B2 B- l$ ~
- *
. C4 t) {. m9 B, `' Y - * This program is free software; you can redistribute it and/or
4 f! L. x/ H) h2 h' D. H. j - * modify it under the terms of the GNU General Public License as
& H6 v% A" P/ ^) }4 ^/ H - * published by the Free Software Foundation version 2.: e |1 r& `' S" |" X1 G
- *
5 D! e, Z3 G5 O% C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ B |4 N$ W w& k: g$ ^ - * kind, whether express or implied; without even the implied warranty! b4 ]0 G& d" g O) s- e5 _' B1 L- q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ j) |- S0 h5 b# B9 o
- * GNU General Public License for more details.! P E$ e" l, |, o( K- ?5 R; |6 n
- */% N. W+ ]/ K5 Z1 y
- 3 \1 U7 B7 H% X. t& ~+ d
- #include <linux/module.h>
# H$ M* @" b5 u) @ - #include <linux/init.h>
) d' D& \1 J2 k8 F0 u$ f - #include <linux/errno.h>5 W, n7 {; t1 M7 W
- #include <linux/types.h> @$ Y! D5 O/ n' ?- L
- #include <linux/interrupt.h>5 P1 K1 n, s* @( ]1 X: h, v
- #include <asm/io.h>
( @ R' A o I8 {# U7 N! d8 x - #include <linux/moduleparam.h>2 [/ Z F: V' J( Y0 k
- #include <linux/sysctl.h>
7 d% v7 B, u, \6 o2 L - #include <linux/mm.h>
% _" T+ o, Q2 }& U" s - #include <linux/dma-mapping.h>! n$ Z$ x* A3 z1 O4 a2 r+ d: |3 {
- ( @7 P# _$ l: d U; g, A
- #include <mach/memory.h>5 |/ J! H' v6 c% n8 S3 w/ f
- #include <mach/hardware.h>
- \- j6 ~& E/ n7 R - #include <mach/irqs.h>+ h K, H& z$ N% w1 C, C
- #include <asm/hardware/edma.h>
6 M2 F& m" p; k$ O* q - : u- ]# b5 Q; M0 y3 ]
- #undef EDMA3_DEBUG: e, x5 j: {$ n
- /*#define EDMA3_DEBUG*/4 v( U: d# T( @% G3 r" j8 E
2 I" C, y2 ^; \. Z6 f- #ifdef EDMA3_DEBUG& m5 L5 R& W* s4 ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" y4 c H5 c% A2 F( ?( X" ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). g$ c% Z" v% D( G1 a! g) [9 A( X
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); u& c7 _. u$ N# @! F4 [) y- C
- #else
' i! k; V* C: p% S! ] - #define DMA_PRINTK( x... )4 O1 ?( S& J+ G2 N6 ~3 E0 Y
- #define DMA_FN_IN
1 j/ G% \! {* [( c! M+ I - #define DMA_FN_OUT) v2 t# @% N4 e: m
- #endif" m: K( F% g! f8 U7 E T
9 L( C* a; g, I( `; R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 D) o9 B3 x; D1 M- b2 q9 z
- #define STATIC_SHIFT 3
9 ^ \) v* L9 Y% J) n - #define TCINTEN_SHIFT 200 k2 E: m' X% O6 ]# t/ |
- #define ITCINTEN_SHIFT 21
) ~( k( s, S: ` - #define TCCHEN_SHIFT 22
+ o7 \ U$ S# Y - #define ITCCHEN_SHIFT 23& z6 y1 S( @1 A; d7 q# G+ d
2 S$ ]$ y& [! Y. c% ~# e0 H- static volatile int irqraised1 = 0; z% }$ s! V0 V' B- g1 S* ]7 W, y
- static volatile int irqraised2 = 0;
+ a; F' Z l& s6 I$ t9 I: i - 1 L( g$ g9 p$ ~- g0 B1 k
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 [6 E3 J1 f: g7 K2 f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 R( x" l" Q1 y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 @3 Q' L! Y; W, L- [" `* g# _
9 m) H" ^8 B" [: N) a1 T. }- dma_addr_t dmaphyssrc1 = 0;' w% ]! c2 w% \& C# F
- dma_addr_t dmaphyssrc2 = 0;
! G. C+ \1 L5 u+ Q- j - dma_addr_t dmaphysdest1 = 0;
; B; {" x( \" Y% T - dma_addr_t dmaphysdest2 = 0;
% D+ v; r2 q; W
$ Y y+ {! }8 g: Y! h) x% E- char *dmabufsrc1 = NULL;
# ~. D- Y, I; M$ y% O - char *dmabufsrc2 = NULL;. q% ~$ z5 c! a* |4 }
- char *dmabufdest1 = NULL;& D- N0 X; v8 n
- char *dmabufdest2 = NULL;
0 Q+ m" E" ~. p3 j, }" \
I! ^* s: F5 q" A6 S% `2 f1 F' v- static int acnt = 512; i; d9 o; s5 e- K1 J" E
- static int bcnt = 8;3 @; m0 V# U Y/ ?9 W1 P
- static int ccnt = 8;
2 k0 e$ c6 y# a - 2 o/ e3 v" f: |. i+ W7 z. r
- module_param(acnt, int, S_IRUGO);
! R0 I3 S9 K- r: v - module_param(bcnt, int, S_IRUGO);
. C! K5 \; C) A% I& L& R9 \+ T - module_param(ccnt, int, S_IRUGO);
复制代码 . v0 P% c# j* m- Y
5 |" m2 o: \4 n9 n2 `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& @+ t6 A4 b* W6 r! E+ R3 r( ?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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% g% K+ o5 z" F* Q0 ^, `9 T6 K' L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 r7 E5 f9 s+ x% ]" X
; N) f) ?0 ^" u+ q9 _' y8 l e
: m% O' \& Y' f9 O; c' }" C) t |
|