|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 P' _% S- P; v' `( V- [code]EDMA sample test application
6 n# ?/ ^. R" X5 a# W% u - /*! K# G' v8 I* u* `
- * edma_test.c
) n% r% k B: i% O$ q2 C% y* O3 ?3 [ - *
4 h9 A4 x: @ s. s2 g! q% v1 s - * brief EDMA3 Test Application# ]1 f% e, ^% [0 b( v
- *
6 f: P$ \) A0 V0 `5 Q" O! D - * This file contains EDMA3 Test code.
( m2 h* `& f# `7 ? - *
; \' ]% }2 N2 V& c' l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 D3 x& n% H- r' ]0 {7 E. l7 R - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 f% d& Q) {" }) a7 ?+ {* L/ @
- * TO CHANGE.% p3 t# m1 [6 z; R6 R
- *. F7 d5 P8 y- i3 `% U4 y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- q, Y6 s8 B" r8 D! t* g$ G
- *7 I& s8 [% Y) p) J) M4 a
- * This program is free software; you can redistribute it and/or6 A; I" u. i- D$ C
- * modify it under the terms of the GNU General Public License as
- I8 f$ b( H m9 O5 L - * published by the Free Software Foundation version 2.
/ @2 v1 c0 D# _7 @. R7 W1 l+ h$ y$ G - *
0 Q: S9 ~8 p/ K) b! ^4 Y% ]* [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" P' L9 F1 T6 Q! r* W, P
- * kind, whether express or implied; without even the implied warranty
, @$ F# `! f+ a0 \& C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& P# x7 A4 @9 q# r
- * GNU General Public License for more details.
; Z# z; q0 i# X# V - */
! d. O" H+ l' U
5 R6 B! x8 z& [ o! e- #include <linux/module.h>
& J4 ^% W7 k! p. p% o6 P3 [" }* ^ Y - #include <linux/init.h>
1 r1 \4 F( m1 `% s; P$ W* F - #include <linux/errno.h>" o# Y9 G0 p. J# {
- #include <linux/types.h>
% S9 B0 G2 |) ]2 ^, p - #include <linux/interrupt.h>
* J, N$ J( t8 {0 R - #include <asm/io.h>7 i5 C) t! w# D8 ?2 @4 Y
- #include <linux/moduleparam.h>$ D' `. G( C; K1 f/ U7 M
- #include <linux/sysctl.h>* h2 Y2 [( N1 ]2 i( |
- #include <linux/mm.h>
5 U$ d* f" X! o6 H2 ~ N; Q - #include <linux/dma-mapping.h>: `) o9 K K, O N2 s! Z. L' G
- : b+ p2 U" K+ V( Q ~
- #include <mach/memory.h>
2 y* p- U, x' t& ? ` - #include <mach/hardware.h>
0 ~8 `: f8 z G% _$ W& S9 } - #include <mach/irqs.h>
! I9 V6 s$ ^* F9 @. e' y - #include <asm/hardware/edma.h>
: ^" J3 ?% t3 q3 d2 Q, o$ ` - D& K/ }! h: ^' r6 m! w) }( H
- #undef EDMA3_DEBUG
" f+ Q0 }# ]- m: v/ }# c _" E - /*#define EDMA3_DEBUG*/% x( u" D+ w3 s' x5 x6 X
- $ d9 ?; R, [/ \ V9 Q
- #ifdef EDMA3_DEBUG
f, I5 @9 w) l& D X! s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 M9 T1 E, F- i H* C" q' H - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 k! p$ X, y0 B3 Q2 B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ P* v5 ?' ?, v5 `% S* I
- #else
+ F6 I1 e2 y6 |# P, G. D - #define DMA_PRINTK( x... )( j0 R' Q; {$ S$ C' v' u4 D4 P7 T
- #define DMA_FN_IN
' f+ b7 t# x, o4 K- u$ ~ - #define DMA_FN_OUT( F" w. x% s' s- }6 `# K
- #endif; H; x$ O1 W* q" p4 v
- " s( o5 g- l1 W
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ }% I/ ?* n; |8 q5 d - #define STATIC_SHIFT 3
6 e# }7 N$ x5 Q - #define TCINTEN_SHIFT 20; N4 K! j. E. D% k8 e0 s. B' s
- #define ITCINTEN_SHIFT 21 p. G! d# K$ ~1 f
- #define TCCHEN_SHIFT 22. D- @7 l3 L2 r( H" u$ s/ H
- #define ITCCHEN_SHIFT 233 o: G, e# K) l- b$ ]4 X
- $ b& c8 A$ E# F9 S. j$ {
- static volatile int irqraised1 = 0;, G4 F: G! l, c3 R
- static volatile int irqraised2 = 0;
* I7 C j+ g9 z$ D( m ]9 B4 X
! R$ T) Q: P: O% @9 L7 Q0 c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
m+ [ `& O# O) ]) \; u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! Z* I# Y$ _. C. Y, p( M
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 Q) o# h; K; d7 g
- ( m4 v$ @8 _! E* c! s% L
- dma_addr_t dmaphyssrc1 = 0;; s: V" U1 m' j2 V( m: W
- dma_addr_t dmaphyssrc2 = 0;6 D% w9 _2 d1 c. J% N9 a
- dma_addr_t dmaphysdest1 = 0;
2 B+ {* ?' S% x/ X; e: b - dma_addr_t dmaphysdest2 = 0;
! `9 ^. A+ K6 T# W9 _+ |9 D
9 w* {5 @) m) X& h I5 Y- C/ @- char *dmabufsrc1 = NULL;
" T& d/ _$ M; o! \ - char *dmabufsrc2 = NULL;+ @6 d1 o/ H4 @: i$ v7 X' e
- char *dmabufdest1 = NULL;9 q; m; L+ w+ q5 ]" I
- char *dmabufdest2 = NULL;
% G+ }% ]& V% w1 F; ~. G# r - 6 j6 g6 ] u9 K8 r
- static int acnt = 512;
" ~7 ?3 B* x) E. ^( Z - static int bcnt = 8;' b$ s4 z9 O4 ~( [! J
- static int ccnt = 8;
/ G/ \6 _- v' B) p - $ I' j. G. i4 K9 _
- module_param(acnt, int, S_IRUGO);9 I& i7 I) I% ~- O) Z6 @ d& ]
- module_param(bcnt, int, S_IRUGO);
{, w" t" s& I Y - module_param(ccnt, int, S_IRUGO);
复制代码
% n+ c e8 Y3 h7 X- X- Q7 j: K2 m
: X4 z9 W5 u$ _: H- f) i" { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 y8 U1 h* g9 D2 x% l3 m$ g- marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 x, t+ Y. H3 ~; Q2 u I8 j: `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# w [; ~* f5 N) W! R4 z3 P$ }( v5 N. t1 B- M
3 s' a: T3 p1 y% I5 J- @* G
|
|