|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 o) c8 b$ S/ d, Y, L
- [code]EDMA sample test application
1 `4 B# f: V7 C6 t7 y - /*$ e7 o6 s' `0 x3 y, X' E) @
- * edma_test.c
- H- [2 `9 x( `5 ?4 }: p* |# U - *# z$ d# f, Y2 n. x" [
- * brief EDMA3 Test Application$ F7 o, X& d! y* X' P4 d: [
- *9 O) l: H1 E7 _2 K& B. m
- * This file contains EDMA3 Test code.* V c0 `/ k9 T' m( r" ~
- *
: ?3 n8 V& {9 V+ d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( A! B R, n' j2 v - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% G# Q" v" L4 `0 K! u
- * TO CHANGE.7 e9 w% h$ f8 @. w9 i, m7 X8 N
- *6 s' @$ P1 d6 d. v6 H+ u" j& y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 F5 {& | H/ L i7 D
- *) _* t t- f8 x) O
- * This program is free software; you can redistribute it and/or
5 d- [8 t* {- O0 Z+ s+ T - * modify it under the terms of the GNU General Public License as
" q$ w7 X F: ^ l- |6 q - * published by the Free Software Foundation version 2.
7 y/ H7 R5 S1 B, @% I - *
" t4 @5 {# l; d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) A/ W4 x& E' z7 O4 ?- i! `* B- x( Q
- * kind, whether express or implied; without even the implied warranty
3 p$ X8 W! g6 J- F& ^0 g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% D, R+ J1 q. o2 s - * GNU General Public License for more details.
! V) g7 F9 s' q - */
" o/ Q6 e9 c7 Y! \% Z9 F8 V
; J) i4 i7 W* z3 ^4 m8 e* d5 T- #include <linux/module.h>
5 T9 @3 g$ N# b: j$ V. p, d - #include <linux/init.h>/ ^4 a; e& G m) c: B" _7 S
- #include <linux/errno.h>8 J+ s$ _' l% i
- #include <linux/types.h>
4 M7 d0 p! r9 W8 x2 d2 e - #include <linux/interrupt.h> v8 j2 R. p' l H6 K9 @. U
- #include <asm/io.h>
1 J& ^, G2 |# ^& k' F/ l0 o - #include <linux/moduleparam.h> R0 r/ o3 g& c2 S. M
- #include <linux/sysctl.h>
. }: z5 t- k: E - #include <linux/mm.h>: b! s1 H! l% I
- #include <linux/dma-mapping.h>
: T& ]' D/ ^4 t; r - T# i- ]7 m3 B( ]" L; F
- #include <mach/memory.h>, |2 l9 y: U7 h0 X
- #include <mach/hardware.h>7 |& f$ B- F! I4 V# K9 ?* ?0 b8 b
- #include <mach/irqs.h>
3 R* I! ~, D" _# N* w" S: o - #include <asm/hardware/edma.h>8 x$ w* W2 D5 N& W' |
: | Z7 E. B& P0 O3 l- #undef EDMA3_DEBUG$ K. @ H, b- w) i; \* V: L
- /*#define EDMA3_DEBUG*/* N+ L: |. u ^8 i
% R7 r6 d7 a# {0 v, o- #ifdef EDMA3_DEBUG
# ?' V1 j" m. t9 z) b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 p L! u9 Z, C5 a" @' P: { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 B8 |/ u8 T; s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 J0 F& g7 ~. r8 T" D - #else
/ \- b% e& u! _5 H8 m) o - #define DMA_PRINTK( x... )
6 u8 E: d8 U( _1 Z# K! n - #define DMA_FN_IN) c9 `5 \& z- H h/ ~& `% c, ^. V- X# {
- #define DMA_FN_OUT
" z4 d( v8 |0 ?# Z0 ~% G& R& d8 o# ]8 J( ^ - #endif) r( [9 C( Q3 U% s: v
- 6 w, x4 t! n8 Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# G* B1 M7 p9 A
- #define STATIC_SHIFT 34 ]. o; J% [1 s# |" `0 {
- #define TCINTEN_SHIFT 20
" D! n. ~- C# _ - #define ITCINTEN_SHIFT 21$ d$ u; A5 V- G B1 Y9 E) K$ B
- #define TCCHEN_SHIFT 22
8 j. H% q+ H0 e9 r# d, T; { - #define ITCCHEN_SHIFT 23
, V$ p: K4 R' c+ g+ A" [ - 7 E6 ^ Z. o! I
- static volatile int irqraised1 = 0;
+ g/ _7 v) c& C/ P7 F4 j x - static volatile int irqraised2 = 0;
+ ^# l" w9 C9 U |* p P; d - & C' q/ H2 \- G3 M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, \1 a: p, m1 l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 n5 t8 v1 O; m7 e/ b5 n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- Y% S% [( S J2 b - 8 {9 M" I8 l3 H X; U
- dma_addr_t dmaphyssrc1 = 0;
1 a3 r0 M1 ]' b6 v - dma_addr_t dmaphyssrc2 = 0;; f- N' t* Z+ I6 `( d% v
- dma_addr_t dmaphysdest1 = 0;* R- C8 Y7 N1 W+ Q& m
- dma_addr_t dmaphysdest2 = 0;" U, d5 v" S& \# f, j- W# l- O
# J/ l2 q! A: G! k4 o3 q- char *dmabufsrc1 = NULL;) W# ]) F8 ?3 ]. J
- char *dmabufsrc2 = NULL;- R; @2 E! S4 L- S
- char *dmabufdest1 = NULL;
4 u3 D6 `; k' w7 X1 F1 w# p' @$ ] - char *dmabufdest2 = NULL;" N- `% ^9 M* Y5 d5 \7 i
" R6 n; F! @2 W- static int acnt = 512;8 m7 O! J( P& v) o, g4 ?- ]! g" r8 t* q
- static int bcnt = 8;
J, }, ^% \) }0 ~% ]3 c! t( A$ E - static int ccnt = 8;
. }9 K6 n/ x, _7 P# L# H3 N - 1 i' x g" ]! \/ T I
- module_param(acnt, int, S_IRUGO);
* X, ?/ } O0 s& V* s - module_param(bcnt, int, S_IRUGO);
2 \2 w" T g- c1 V, _ - module_param(ccnt, int, S_IRUGO);
复制代码
- }# B% K$ O* b$ m+ b1 @
m3 b' A) g- z, R% n4 | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 v* o+ @( `7 g) d h6 M% ?: Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- F1 \( B6 ^( P% }8 B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; y B8 B2 b2 x& c5 s5 _6 v( b
8 m$ l2 l9 Q" X0 h, }) _
0 c( i+ p$ r# f( K1 H; o" R
|
|