|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # J* u# W- w4 d; }) J- k
- [code]EDMA sample test application0 U/ u7 M: Y' u
- /*+ a c$ y" o/ z" G; c
- * edma_test.c
n- z8 ?, j, C8 p: k) J, i; t - *1 W' l) _& G% v: W7 v0 N. @7 v( }
- * brief EDMA3 Test Application! {) N% g; d, M& k# L6 d# b
- * d0 ~6 n$ X/ D0 `- C$ E3 M k
- * This file contains EDMA3 Test code.! c1 D& d4 P5 r! D) d
- *
6 D6 n4 _5 T0 H6 i7 Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, E* e7 O5 u& y. G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 v! {4 C9 W7 G3 N9 h
- * TO CHANGE." Y0 a1 j, l; {% X3 ~7 w! P$ Q
- *
, L. W" }1 m/ z0 H- M4 Y/ C - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, B: U& E( \9 g( H: m
- *
6 T' q9 _6 S" D h# X - * This program is free software; you can redistribute it and/or: p1 |5 h4 }, ] T
- * modify it under the terms of the GNU General Public License as
/ O6 E5 V7 I6 @+ B7 H0 O9 X: H - * published by the Free Software Foundation version 2.
) g0 N, W* b+ E6 h. E' |7 m - *
' Z/ m0 o; p( {) M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" v* h( J5 r- c- f8 o& h" k' a' a - * kind, whether express or implied; without even the implied warranty
5 I) P4 @! v7 x8 s: D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. \" x+ b" [: Q* `" ^' l
- * GNU General Public License for more details.
: ]5 ^" c$ R% |* r9 ~4 o - */
9 {; `" N! @, i. h
* j" u! I! W; p Y$ U4 k- #include <linux/module.h>
& i& S7 _# P/ ?# X* e2 E - #include <linux/init.h>/ G+ B |' n+ {! l$ l n4 h- {
- #include <linux/errno.h>
" Y4 g5 B. L. Q3 s1 H - #include <linux/types.h>
# ?" Q8 p$ }- W% ? - #include <linux/interrupt.h>
0 G4 K; I+ I7 X; F9 { - #include <asm/io.h>7 j" H. M4 s/ ~8 K/ E. H
- #include <linux/moduleparam.h>" z9 u$ P- Q4 q0 u
- #include <linux/sysctl.h>
% c n3 J1 B3 \! L. X - #include <linux/mm.h>
+ q. M/ I3 \# c4 K f; T" M - #include <linux/dma-mapping.h>
?2 d% @9 K# ~! u& d - 0 e$ j' e- R. H& G
- #include <mach/memory.h>
# `6 R2 t4 C8 C8 q3 n - #include <mach/hardware.h>
) G, N8 F; h0 M4 ^9 T - #include <mach/irqs.h>
& R: J) p t* x) J - #include <asm/hardware/edma.h>
+ x1 Q) p3 E( r H
" J7 c# E/ c" ]/ Q; Q- #undef EDMA3_DEBUG
- ~ x2 ~# J! i - /*#define EDMA3_DEBUG*/0 ?& F' F) \5 \9 _/ S$ g/ ^# o
- 8 W6 R% p5 f/ C' z( ^
- #ifdef EDMA3_DEBUG
, v1 V$ L- v& R5 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 r1 t2 |+ w( b8 ?- C: c: \
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); k9 U! ^+ u' F& ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" a6 ~2 o y7 }
- #else
& ^# I7 ~7 ]$ U/ e% K9 H - #define DMA_PRINTK( x... )/ V' n+ C; X8 B+ v5 ?' E1 H
- #define DMA_FN_IN; S2 L, {! c2 ^3 D% S$ z' O. g
- #define DMA_FN_OUT+ r5 P! r6 ^8 M0 L5 k# a
- #endif, u4 V1 p/ O& D8 q
; ?. r: p8 A! n1 F7 H- #define MAX_DMA_TRANSFER_IN_BYTES (32768) X' [* v$ b8 ?" n$ q6 I( ^
- #define STATIC_SHIFT 36 r% F5 W+ ~ d; a+ g
- #define TCINTEN_SHIFT 200 Z" |* e2 _; t7 B* v
- #define ITCINTEN_SHIFT 21
; D9 f/ a( V" x - #define TCCHEN_SHIFT 22
5 ^9 `" ~6 s5 K1 i \0 Y& p - #define ITCCHEN_SHIFT 23; d. h% k* W7 i
- 6 C: t8 x% _0 C, Q6 f
- static volatile int irqraised1 = 0;
7 P ~% d( L& k# r9 I' C - static volatile int irqraised2 = 0;6 e, M( ^- A0 D' |% n' j O; I3 q
- & V' M! I: ?; b* g; n6 R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 F- E5 ^. g3 @* E- [& F' S5 X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& J" Y+ p' ~$ U; y' n6 p) y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 E9 M" ~ _7 R: j$ y. P
/ {% P$ @ a7 M5 J* x1 a. O8 A- dma_addr_t dmaphyssrc1 = 0;- X; [+ a7 R: |& o3 f: v
- dma_addr_t dmaphyssrc2 = 0;
% R4 q" M- X$ Y% K$ L - dma_addr_t dmaphysdest1 = 0;1 W `: J5 m w8 D- e: O
- dma_addr_t dmaphysdest2 = 0;
' Q, C0 q. }7 i5 A7 K - ! m1 f/ g" s* q2 l- B) C
- char *dmabufsrc1 = NULL;
! w& b& H8 d4 p - char *dmabufsrc2 = NULL;
0 S! B. o4 ?/ R F- s - char *dmabufdest1 = NULL;- S4 b2 x8 E# {& h! i" F
- char *dmabufdest2 = NULL;
8 j. o+ i" i* A7 n/ f3 K# U' S9 c
9 y! _' P5 Q. k) M& A- static int acnt = 512;
$ t' Z2 A) f8 x - static int bcnt = 8;) A9 L Y) D% h1 {3 |. t
- static int ccnt = 8;
/ ?4 |' v7 R4 T' f! m! E& e - ( |4 H3 D8 R0 U5 {* S
- module_param(acnt, int, S_IRUGO);
( p! K& s; Z/ Y) P; g! L$ D) U - module_param(bcnt, int, S_IRUGO);
( a2 G6 k& D% l3 o' H& p. i4 r - module_param(ccnt, int, S_IRUGO);
复制代码
; Z; E% {1 g- m$ ]$ L1 }3 w& Q
( L3 i, n# u) y ]* j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 N W" a' q% k1 Y: uarm-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 M& u6 L, K+ }; i z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 l& M Q- l% D
8 l9 V$ ?# ?+ R% f
! W6 _5 K2 I0 _/ U! |, i+ C' |0 U |
|