|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / I" O r* i) h w
- [code]EDMA sample test application
% M9 ]) @! V/ U - /*8 K1 k9 j4 n. U8 u
- * edma_test.c
) r4 ?$ a& J/ F5 n8 l2 R, i - *5 j c, q0 R( t5 t
- * brief EDMA3 Test Application
- G* i2 R+ }7 a( k/ r b, i5 X - *7 D# I5 P* o Y5 r6 g8 j2 K
- * This file contains EDMA3 Test code.
: T3 Y% u2 f2 e* n6 c! n* l6 I" w - *+ M# z5 y2 j; E; q" _4 K( G3 a3 l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ Z3 t- i% H. B5 @
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" e* E' @" {; v
- * TO CHANGE.
# M9 b) t$ j+ a. u4 @- e" M( v7 w - *
/ M4 z* ]( e6 u7 r" l$ q1 U6 ]8 W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- B+ ^. |& ^, _) e - *
; s1 u1 z4 y) D% X" P$ [& @( Y" Y - * This program is free software; you can redistribute it and/or( M [ p5 E7 `& s, y
- * modify it under the terms of the GNU General Public License as6 x$ w4 H, _- T6 i# S( R7 M% {# g5 U0 ?
- * published by the Free Software Foundation version 2.
! y$ J& r+ Y7 O5 f - *) M- O$ C4 f' t3 e" r, A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' Z- W3 h1 Y/ r. {. H. m+ }/ D
- * kind, whether express or implied; without even the implied warranty
7 M' h W- F- F2 g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" g$ Q( N! P" a( U8 w, B; ]
- * GNU General Public License for more details.; r l6 x4 A) _0 L6 V3 W! E
- */: ]8 L7 Y. O( x2 I' T! p3 J% c
- 0 r0 G+ i t+ s
- #include <linux/module.h>
6 Y1 Q( D" }+ g - #include <linux/init.h>
* D+ }/ `& D2 o1 ~ - #include <linux/errno.h>
- o$ l% X- y# X" l7 j5 A& n1 q - #include <linux/types.h>
/ a2 o2 J* I* V( ^ d% |9 L - #include <linux/interrupt.h>& F! J2 @) S; \) C5 m
- #include <asm/io.h>
3 m% o5 J5 _2 @- f, W& j* v+ N+ h - #include <linux/moduleparam.h>/ P$ G3 P- s' N2 D' ?# k5 G
- #include <linux/sysctl.h>7 x2 u: X4 c) L* E) M4 Z. p; `
- #include <linux/mm.h># z5 h9 @% e8 z' J
- #include <linux/dma-mapping.h>2 j! u7 y' p& [( H* {* c0 M* S3 Q: j
- 1 }1 U) r$ P1 P2 ?! p; S/ W" _
- #include <mach/memory.h>
' i! t9 U% Q) A4 s* K/ p: p. o - #include <mach/hardware.h>. {2 [& v' G$ o5 R
- #include <mach/irqs.h>: v$ D6 K/ N4 E- |+ {' |
- #include <asm/hardware/edma.h># o2 `7 [9 M; h: I8 M, v# o
- ) W1 {9 J. Z0 M" w
- #undef EDMA3_DEBUG
) F+ [3 h+ a# g4 w3 g6 i8 b4 I - /*#define EDMA3_DEBUG*/
! T$ E3 [% o0 @6 z+ z" X
* x3 @1 {* Z" @1 k/ k: C0 s' ^- #ifdef EDMA3_DEBUG
, J3 a0 C2 h6 j A- z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ x+ H! P2 B; N8 w" S, H. z2 H4 r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- [ S1 k4 W& a- B9 } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). M8 n& \, r* ]9 {- _" V
- #else
. F) U4 u7 j4 {- J* ^ U) W! I - #define DMA_PRINTK( x... )3 M- G) T4 v" }' D1 G$ j
- #define DMA_FN_IN. C3 M! _2 B+ B b
- #define DMA_FN_OUT
: |; y4 m& B! N/ v9 p5 O: W. m7 m - #endif
0 E6 M7 E Q4 Z1 ^! q! @ - 0 N+ h( A# h2 D" c& L0 A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
Y, g5 p1 k/ [1 g - #define STATIC_SHIFT 3
1 N: l- p) {( s - #define TCINTEN_SHIFT 206 P/ O+ a) U3 r- F9 q
- #define ITCINTEN_SHIFT 21
; j4 Z' {! N/ p2 s0 j - #define TCCHEN_SHIFT 22
' o+ z: R9 N& z. S - #define ITCCHEN_SHIFT 23/ ~ L* Q4 N7 `8 j
- % M, C7 ~6 P9 G3 g/ u
- static volatile int irqraised1 = 0;
7 f6 j4 G$ }% p6 j6 F' w6 v& _ - static volatile int irqraised2 = 0;
+ [0 n: |, A. n# K$ L4 t
/ z( k" x0 l6 s" K) i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& ^5 W. h8 [& D! W8 z) j" z) p - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, Y& ^! b1 \+ h) { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 n3 M6 b8 w3 F; q9 Y- i9 x- M! H - 1 v: U& o0 P9 ?/ I- Y+ c% Y
- dma_addr_t dmaphyssrc1 = 0;
* r k9 g/ R, @' V) H) f2 J% [+ Z4 N0 C - dma_addr_t dmaphyssrc2 = 0;
7 f2 r2 L6 \+ o( h - dma_addr_t dmaphysdest1 = 0;
5 X& c. ^+ V# y% z - dma_addr_t dmaphysdest2 = 0;
9 [7 \% f' B9 { - 3 B7 ]: p4 l3 m% [* Z6 B0 @0 x) t% ]. C/ w
- char *dmabufsrc1 = NULL;% H1 x3 e( N+ ?8 j) T# C5 a. s: I
- char *dmabufsrc2 = NULL;; s, S# ^- Z2 Y- m6 M' @
- char *dmabufdest1 = NULL;
9 Y3 Z4 Q3 h2 Y/ k - char *dmabufdest2 = NULL;
# W5 |, k: B$ [& g2 Z) z - ; |! a. m) t# |6 w5 [
- static int acnt = 512;
" B( c' E1 ]4 t3 m# t$ ` - static int bcnt = 8;
. ]" }8 u$ S9 R2 {1 V - static int ccnt = 8;' {8 C- ]2 s( J2 M/ k8 |6 Z* Y
& F3 X6 Q& V1 S% z0 e- module_param(acnt, int, S_IRUGO);+ a$ C* u; L) P8 O5 T3 b
- module_param(bcnt, int, S_IRUGO);
( z4 h- U+ \ _( U6 I9 E/ _: k8 Q - module_param(ccnt, int, S_IRUGO);
复制代码 7 D' |7 `- z- w. j# n+ t" J
3 `; ?3 ?- N+ d* m, F$ h x) L3 y0 n. K$ Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ w6 ^* R z4 v2 E$ R. I! e/ 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 ~$ c. K* O' ~# B a5 G) |4 Q) s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* S8 z9 B; D# K& P- M8 @5 J
/ H( l' h9 i ^3 B- ]8 }2 H
V- Y* _6 ~. O8 B: T |
|