|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% I9 Z. x9 V6 ~1 u" S3 R1 J- [code]EDMA sample test application
`; A" v& s" c L! c% G - /*6 c& P1 |6 ~& k
- * edma_test.c
4 D a3 P2 \4 o! X/ H: T/ M3 h - *& O6 `( b) B3 N* A4 _! H
- * brief EDMA3 Test Application5 t' P# r; h$ o' c `* ^
- *) }; W9 s1 J& ]
- * This file contains EDMA3 Test code.
" W! ?' A. y% e7 b/ |8 T: B - *+ Q% }# _: O" E- p' ~5 W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 C# D9 m, z4 y4 j: f) h2 u* P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& g5 N- i1 z' ^ - * TO CHANGE.7 m, u; H% w- `. Z
- *
5 z& a8 e- n4 R7 b" `; x, z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 w3 w: @/ j' W$ A- U: \ - *) R" B8 L' y! i
- * This program is free software; you can redistribute it and/or
8 j& R3 U" |1 i' G! x - * modify it under the terms of the GNU General Public License as
5 m& \& u" w% A8 J# V6 m5 m - * published by the Free Software Foundation version 2.8 c+ b( ?* B4 B& l- w
- *
% p7 e5 \* c. a$ X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' x1 a6 R4 C0 M# n$ E( Y/ A0 L$ v
- * kind, whether express or implied; without even the implied warranty
* K" {/ V# n" ^6 ?' U# `& e# Q) _0 N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 N4 D: |5 c5 S( a4 W/ I
- * GNU General Public License for more details.
% G0 f- `9 V5 ]! P$ g" l- D9 d - */* u, _7 K; @/ U
- 1 ^* Z" o% y+ }* X8 n, W0 [
- #include <linux/module.h># X! b8 L5 E3 I/ [% i! o+ d7 T' z9 ?
- #include <linux/init.h>
- \" K4 F- O, T- ^! j, E - #include <linux/errno.h>' E8 L* A2 g. v. f. ?4 o* A5 A" P
- #include <linux/types.h>; s i0 d& Y/ a: A" U3 s
- #include <linux/interrupt.h>' e9 C5 ?5 M( _
- #include <asm/io.h>* _7 c! }# m& u) ]# s; T3 ]
- #include <linux/moduleparam.h>, [1 \9 }! I: s4 M8 J; @
- #include <linux/sysctl.h>
' e6 e0 r. s6 U+ R - #include <linux/mm.h>
9 i4 M1 R: e @* D- ]; I - #include <linux/dma-mapping.h>
( M( s/ \/ L% S4 D - 9 e9 P- c0 Y7 ^& Y9 B' v% ?3 c+ l+ p
- #include <mach/memory.h># t( U* i3 X5 V7 \, O( c4 A
- #include <mach/hardware.h>* r- q! d' ?, K# v: U X3 [; n
- #include <mach/irqs.h>
+ M, ]* `3 W# f% y - #include <asm/hardware/edma.h>
4 Z k6 v, h H! S4 M
, `6 F- v0 T3 T- #undef EDMA3_DEBUG9 H Q. U/ Z) H* H
- /*#define EDMA3_DEBUG*/
% g7 d' a& e: J7 M) u" b( {1 s+ F: z
# I4 J" y) C* K) K% s- w; T- #ifdef EDMA3_DEBUG
* ]# r" {8 Q | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" B- q! P4 s N7 n8 D8 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; g2 R% h: ?) j& n1 M% a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); G$ Z) K9 j" N/ G5 G# n
- #else& r) z- p/ j; I* I4 c2 W
- #define DMA_PRINTK( x... )" e& l( g K+ ?$ @) f
- #define DMA_FN_IN& i& g( q, B* |, D( L v/ q! `1 y
- #define DMA_FN_OUT
, j' ?' x# z9 V+ p0 E1 l9 }* O% [ - #endif2 b r- X' J" z: l6 c
& q) q& x3 M+ u2 o2 J+ w- #define MAX_DMA_TRANSFER_IN_BYTES (32768): t$ q( N3 j) N0 A7 A5 p8 V
- #define STATIC_SHIFT 3
6 L- R+ q% f7 V' s! V# T - #define TCINTEN_SHIFT 20
! \" `7 L$ i9 C8 Z2 r. ? - #define ITCINTEN_SHIFT 21
9 G& \8 F/ y* t9 g& o - #define TCCHEN_SHIFT 22: w, _: r3 R3 q& |* L8 X2 ?
- #define ITCCHEN_SHIFT 23
% h4 l0 p, x. D0 D% _ - . u' d# F! ?- p5 E: p9 R1 W
- static volatile int irqraised1 = 0;
6 F. v4 Y) _7 L - static volatile int irqraised2 = 0;& v# B1 a+ }8 k* s5 C+ d. \
: b/ i, c* ?& t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ S S: R5 V/ A X1 s7 L$ |6 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 Q0 `" R5 d( `- V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 s3 J/ M0 E p9 F( K$ r - 7 P7 k6 q2 j( F. ~+ ]
- dma_addr_t dmaphyssrc1 = 0;
- w; d$ D; E$ a3 [& m9 m) V - dma_addr_t dmaphyssrc2 = 0;
: I+ K- ^* |# W! x' S" \2 l - dma_addr_t dmaphysdest1 = 0;; O2 x' b/ m5 F( r' I& R3 H
- dma_addr_t dmaphysdest2 = 0;
, j9 i9 ~1 d! g4 N+ F y7 J
4 [$ r* s: O! J( }7 s- char *dmabufsrc1 = NULL;
# L9 @$ v8 Q) r! y - char *dmabufsrc2 = NULL;
8 R* e( B3 j/ j - char *dmabufdest1 = NULL;
& e( o) \ i' D4 {8 l4 h m - char *dmabufdest2 = NULL;
( n9 D! [: z! I - ( R' u, R2 m, z& t2 e9 v
- static int acnt = 512;
8 f+ x! p; o$ D4 B* s( U- a( e - static int bcnt = 8;% i& x/ ~* B5 K9 ^! ^
- static int ccnt = 8;
! Y% k, P9 E7 P0 S4 d+ C- F: B - : T7 N G5 c# q; D+ X* x
- module_param(acnt, int, S_IRUGO);& O2 ~( ]7 N# W
- module_param(bcnt, int, S_IRUGO);
; j1 q/ Y8 T# \! _( V9 D0 | - module_param(ccnt, int, S_IRUGO);
复制代码
1 J, z: T- {8 B& F' D5 m( c
- f! ] G3 D0 J( v' w- X6 S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- V4 p: l t. [5 a' z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ q' P3 W' L B9 m8 X; R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 q8 l5 g* _7 g! Y {; m
9 O% U% G( s" u* J' l4 X
/ x# s/ K6 m/ W. ]& x/ U |
|