|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 X( }9 i. N4 G3 T6 q7 {7 Y
- [code]EDMA sample test application
5 e5 I: ?' {3 ?+ u - /*/ u) [( r6 Z! [; y
- * edma_test.c
8 x: n6 d4 f1 N% A0 A9 [ - *; D6 n& F6 a" G4 D
- * brief EDMA3 Test Application
) Q2 ?1 }$ y5 y* @2 q3 S Z! Y% Q4 [ - *1 Z9 b& ~, s9 i( s5 z
- * This file contains EDMA3 Test code.
, m% s, R, @$ y Q: @# m1 W - *
" ^2 S6 `+ }1 i! J/ |. B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% z5 t; H/ y& O; G# ?1 S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 V7 e! G( d$ l$ h7 H! s
- * TO CHANGE.+ c! X+ h* I0 A% K/ o( D
- *
6 v( ~0 \; g4 ` C( l5 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; z) l+ [9 @( `# p. f+ m
- *# R# V, _# c \% w; J, D+ O1 D+ `
- * This program is free software; you can redistribute it and/or; b2 {3 I& V/ Q$ N+ H& L
- * modify it under the terms of the GNU General Public License as2 L' x5 {# J+ k+ e2 e3 r* M
- * published by the Free Software Foundation version 2.
! P7 \9 J6 j% E% b3 J K - *" W$ S( @3 G1 F S$ n( @3 u* U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" m) h: Z* n* V! t/ b; [' F - * kind, whether express or implied; without even the implied warranty# l9 h+ b, Y; m' X) `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. K3 u! J/ q }" u+ I
- * GNU General Public License for more details.
8 Q; L6 i0 {& a9 Q3 B* D# C - */
! x* a( S) U/ b: W( s0 Y9 Z" x
3 `5 X8 D. I9 K+ s1 S/ L- #include <linux/module.h>6 S8 N5 m+ u) G m6 Y. v7 U
- #include <linux/init.h>9 D/ x$ g+ C' B6 F9 ]4 B
- #include <linux/errno.h>
: T7 X% ?1 P% n) D - #include <linux/types.h>
( w. N, d o& C7 v- l - #include <linux/interrupt.h>; T& n. I" A- J2 T# G# Z
- #include <asm/io.h>+ {% o5 R8 ~ y
- #include <linux/moduleparam.h>
+ J! L* n" }3 S - #include <linux/sysctl.h>
7 |' {- H3 h* _7 N6 ~ - #include <linux/mm.h>* j h2 d1 q5 A# _- r6 E: w; e; n
- #include <linux/dma-mapping.h>
0 {, W8 x! k2 Z% C2 N4 N - 2 p& L* g4 M" {& i" @
- #include <mach/memory.h># p, j0 M) w1 ~% W
- #include <mach/hardware.h>
( g; {" o' ~7 J: b - #include <mach/irqs.h>
( @8 g* T8 z# ?7 m( _% F - #include <asm/hardware/edma.h>
7 {/ E6 ~5 z6 I0 S' ~+ a - % T# f; ]6 a/ ?7 A( Z& _1 P" F. [
- #undef EDMA3_DEBUG
5 a/ L) B3 E6 ]. a. _5 P( ?, w - /*#define EDMA3_DEBUG*/5 p$ W) m1 o9 {9 M! V; o; [
1 b# x4 \$ O- R* v$ y2 `# c% v- #ifdef EDMA3_DEBUG
! \+ M6 {" ?) @9 ?. @3 r# l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' V. X7 a0 r6 O) ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" f% ?( T7 t/ |* l- M! \$ B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 ]+ S6 H) m( q/ Z: V0 ^ - #else
$ Z2 A; z! i3 Y& X( X i - #define DMA_PRINTK( x... )5 x" X, t# r) Q! e! r/ b
- #define DMA_FN_IN
4 }+ ]) k) w5 ` - #define DMA_FN_OUT
3 Y3 A) m4 \" {! y' [2 @ W: S; D3 w - #endif7 [) E, Y8 H( c G1 p& ^
k( H$ J$ m: }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 {9 H+ a, }8 F/ n' t - #define STATIC_SHIFT 3
; `9 q# y5 r: d, j - #define TCINTEN_SHIFT 20
* ?) t* ]) F/ i - #define ITCINTEN_SHIFT 21
+ _( N; | X4 e% D2 e6 ~: z - #define TCCHEN_SHIFT 22' b- p7 W0 Y+ Z6 y& P
- #define ITCCHEN_SHIFT 23
8 d* O3 y5 V3 R! C! q; R, X5 C - 0 m& E5 a' q r/ f5 r3 x
- static volatile int irqraised1 = 0;
4 i) @# W. U: Z2 M6 y4 V6 x S - static volatile int irqraised2 = 0;1 V" L4 p8 l- ^0 a4 O( E
- ' |' t: e; B3 C! l4 c5 a( J4 j
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- m" [ g, m7 v) b2 J
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: N4 V. y, A+ d8 E2 J! X/ g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 i( ~" Z x8 B; F
- 5 }' q) W$ F- ^1 m' U: \9 Z! D
- dma_addr_t dmaphyssrc1 = 0;
' u2 ?/ X l4 `- ~, d5 G8 N - dma_addr_t dmaphyssrc2 = 0;8 ]7 z3 a$ \( r, W: n
- dma_addr_t dmaphysdest1 = 0;
! q& o/ I/ t f% `7 N6 V - dma_addr_t dmaphysdest2 = 0;
j; R$ F5 q! s1 S
1 w3 b. I& p+ ]. X. m% [7 o/ [- char *dmabufsrc1 = NULL;4 {! f* y. z8 X( B0 k
- char *dmabufsrc2 = NULL;
' A* v9 w. b3 o( c' ^ - char *dmabufdest1 = NULL;
3 |: [5 H" \6 k5 q# P; |4 t - char *dmabufdest2 = NULL;* a; Y# B* O( } c S; T
- ; m0 G- D+ b, R# L: t8 c+ ?8 V
- static int acnt = 512;
% [2 X# l2 M' J. P - static int bcnt = 8;% [6 k9 @( r- P" {6 [1 c
- static int ccnt = 8;% ^8 q9 ^& h! d( X3 S
- 3 } v* f- y. A1 `/ A5 n
- module_param(acnt, int, S_IRUGO);
! L" l7 j; V! R( q% y) C3 N! p - module_param(bcnt, int, S_IRUGO);& P7 B$ l8 b. \, ]! M! N
- module_param(ccnt, int, S_IRUGO);
复制代码 ) [- c M7 \7 V& N, w* @1 w
C J- R2 ]' [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, S6 q3 ?$ c; M" F. d) H" Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 f$ |1 r/ O/ t: T+ \1 \; x! ]* }; g, O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 d" ^) u1 j+ B( q) Y
% T5 w3 g5 B5 S$ D3 L# I1 d* U, V, ?) _7 e
|
|