|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . O7 b' |7 ^; n' H/ F2 g
- [code]EDMA sample test application. r( D! o/ Y! L- g
- /*
6 s( _1 L6 x! @ h$ Z$ G- c - * edma_test.c, y7 g+ c" U+ K
- *) U2 @. @7 ~, }! R2 D+ M, z
- * brief EDMA3 Test Application, q" @# ~4 s, ~$ j- }' @
- *- S5 b6 G1 y* A, a" b1 b; K2 Z
- * This file contains EDMA3 Test code.
$ i( ]# O) a( o# u - *
2 {: i2 Y& N6 y5 d9 T& t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ z5 E2 e9 s. M2 K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: c: c/ S; |! O - * TO CHANGE.: w6 O2 U" J9 B3 O# n* t
- *! h* ]* ]+ n4 W# Q* r- x# n) t3 H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' }% Q' J" R) y - * o1 Q4 t6 a! k+ O
- * This program is free software; you can redistribute it and/or
/ E1 g9 r6 o6 s - * modify it under the terms of the GNU General Public License as3 f$ f, S* J2 i) R, @6 }' B; u4 @1 }
- * published by the Free Software Foundation version 2.- E9 u- p L1 \1 X
- ** U7 @( M) Z- m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any _% M6 ?8 V/ ~
- * kind, whether express or implied; without even the implied warranty1 e5 l9 @" V. l, z$ s; n. q; z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& ~& X) A ]9 H: j/ V9 h6 N h
- * GNU General Public License for more details.
* U- X$ N, ^; g9 }: c9 [ - */4 ^ Q1 S4 _' l9 a
- . |, c# F; f! m1 }$ M: B! U, n/ O' M( `
- #include <linux/module.h>6 Z! y2 v) Q; \$ V
- #include <linux/init.h>
) T# N. C4 r" s - #include <linux/errno.h>
& I U4 r5 g1 {- q2 j4 a - #include <linux/types.h>
5 E* k# @7 T2 F4 O3 C& r' S. h) n - #include <linux/interrupt.h>
; g. S4 N2 z) s* [+ j) Q - #include <asm/io.h>+ T1 P' V( i) @8 ~5 B3 u0 w
- #include <linux/moduleparam.h>* S- N r: y5 K9 @2 I$ @0 S
- #include <linux/sysctl.h>
3 _9 v/ ~5 Y9 c* [5 Q& S/ K - #include <linux/mm.h>% Z8 z* y8 U+ W @- I6 U
- #include <linux/dma-mapping.h>
) H3 h9 x8 q L4 X$ t
$ Q. B* v/ v* b0 ] T: c- #include <mach/memory.h>$ x& Q: J9 P6 c. Q2 u
- #include <mach/hardware.h>
! x$ `8 N. V8 B) n0 [* L - #include <mach/irqs.h>
# z# r/ y6 Q( W+ S - #include <asm/hardware/edma.h>8 H& d$ W5 s& y+ x" |0 ~( Y. [, I
- 4 {& A, {* U" Z7 z [
- #undef EDMA3_DEBUG
& K* z0 I, F- a - /*#define EDMA3_DEBUG*/
8 c- \4 g7 g& e - 9 l$ |9 t3 o/ c- \4 b; X' P4 M
- #ifdef EDMA3_DEBUG
& u4 Q6 M6 N, U. A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- o7 T x3 w9 f; p' @- A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). q6 N3 h; M R% F0 m) H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ U' P1 V: V J$ q, c- j
- #else
; @+ m9 D* x2 j# u! W P R/ F - #define DMA_PRINTK( x... )
4 g- R; W0 D( i8 V+ a. H - #define DMA_FN_IN
' X* a- }# J! a! p/ f6 { - #define DMA_FN_OUT
2 C8 A/ [8 U# d. \$ V/ [ - #endif1 F. T9 J' W+ V; v* k# ]+ o
- q# u( b1 {2 i# t! g- #define MAX_DMA_TRANSFER_IN_BYTES (32768), K, k0 R0 N- L# a4 S
- #define STATIC_SHIFT 3
- x! H3 [+ f3 o' E4 z - #define TCINTEN_SHIFT 208 I Z$ K# `; P- O H1 M
- #define ITCINTEN_SHIFT 216 V" j' O( f5 `: _
- #define TCCHEN_SHIFT 22
# X# E- f0 N, A+ Q3 k3 C - #define ITCCHEN_SHIFT 23
7 \! b! O* g1 s, K6 a& i
5 ^* Z3 N' y2 `- static volatile int irqraised1 = 0;- z, N3 o. {, `9 P' \# ^
- static volatile int irqraised2 = 0;
' N( y6 \& Z6 m7 O
6 x/ M: {8 y& B' e' \& @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# k, {; b' y9 I* u9 g! B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' ?! k' \# _7 r. e; S% s6 B - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); M3 c0 Y8 o% K; D# u# J! L
- 8 g$ k0 q; T9 ]6 o5 S
- dma_addr_t dmaphyssrc1 = 0;
/ [1 y7 U0 p* C& u - dma_addr_t dmaphyssrc2 = 0;) F' L# Y- w8 T9 `
- dma_addr_t dmaphysdest1 = 0;
! i" Z4 C5 a( F) R# Z! w - dma_addr_t dmaphysdest2 = 0;* Z( d8 F& }3 d
- , x6 z" @& k5 D% E# z
- char *dmabufsrc1 = NULL;
$ o1 M% { o$ X1 p/ a - char *dmabufsrc2 = NULL;
0 A5 f J$ K: c3 X. v - char *dmabufdest1 = NULL;
}& T. q5 E3 B: g - char *dmabufdest2 = NULL;
8 z X u% T. G+ ]4 Y
- `% V, {# j1 [) ?7 {- static int acnt = 512;
8 d( c$ S y, T1 }6 V7 E$ y$ _$ K - static int bcnt = 8;
4 q" I/ K9 A- K& S9 D! X - static int ccnt = 8;
) ~# W) r3 ]: E- U4 w0 X& u& ~6 m. p - 2 b, }2 X9 O3 _% q {
- module_param(acnt, int, S_IRUGO);9 A9 d2 Y! V6 A- ^1 l
- module_param(bcnt, int, S_IRUGO);
1 _$ D0 W& W+ x1 s; [7 Q - module_param(ccnt, int, S_IRUGO);
复制代码
+ U8 l7 J9 T6 p8 u+ R4 Y3 X3 u1 j1 d0 O1 U9 H* E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& l4 ?* {. @4 u. ^6 K1 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# r T8 T! p$ j K N* E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, L; w/ `# N5 c+ U1 `3 a
: }5 _8 G M6 M) W
, M9 U* I2 f$ K3 p! t3 D |
|