|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # b% b) S) j1 w, K
- [code]EDMA sample test application
' C6 n% k) x" s% Y4 r - /*( t7 ? i4 @/ P6 v( J
- * edma_test.c4 A6 G9 q' A& c- }5 M. v5 D9 {+ U
- *
' Q0 f/ C# Z5 w0 L% F, v% C - * brief EDMA3 Test Application
; l2 ]& F9 X- |, Z5 { - *
5 p2 h0 z( ?+ b" R2 ]3 ^. S, |5 I - * This file contains EDMA3 Test code./ n: X: c6 b& x4 u3 V$ M' \! X
- *: N$ ?) A* q- p) O/ q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" ] Z7 f2 a2 R! c+ W* v, k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% M- j6 L% @$ \6 ]& @ - * TO CHANGE.8 R C% e4 R: k
- *
2 s' F4 K- I3 m, o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: L+ p: Y8 X4 k3 `: f9 q
- *
' ^) A- O0 x7 X' f# u5 C2 [ - * This program is free software; you can redistribute it and/or
' N0 o `+ v* i c* Y P - * modify it under the terms of the GNU General Public License as
+ W. }! o! i7 l2 [2 {: M - * published by the Free Software Foundation version 2.
2 J9 V5 L/ h' ] - *
% n! P+ V7 e1 V5 v. ~0 { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; M% y- u' G0 j4 D- ?
- * kind, whether express or implied; without even the implied warranty
4 B& D6 \. N# S4 }* T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" \5 P) H1 J4 r$ S5 D
- * GNU General Public License for more details.) Q$ C; R6 {5 z9 D1 y) a' h, d5 E
- */: O# ]( h; A [% x; T
- ' l; e% ?/ l5 }+ j7 `% @
- #include <linux/module.h>7 l6 e3 A3 Y# }! W8 `- g6 ?; i, u
- #include <linux/init.h>9 p7 q! ^1 f' x/ U
- #include <linux/errno.h>/ Q: ]& m- D9 a. y- [
- #include <linux/types.h>+ c" t3 z* ^, a; {4 Y
- #include <linux/interrupt.h>
; w0 d! F. L7 j1 J% R7 W - #include <asm/io.h> L& ]. X& P) [3 T4 N9 Q
- #include <linux/moduleparam.h>
8 R3 w N3 v3 |# v - #include <linux/sysctl.h># T" ?1 ]8 G% ~& A0 a
- #include <linux/mm.h>
0 \( e( o$ g0 J9 ^/ W) I# C, C - #include <linux/dma-mapping.h>& o/ \, g) g3 h* O7 _1 p0 i
8 F" b1 Q0 n% d4 `+ }. B* s( x- #include <mach/memory.h>
/ s1 l3 O, s. \9 W- v) z1 h - #include <mach/hardware.h>
5 N# A3 `3 F8 g# B! ]1 n - #include <mach/irqs.h>
3 n! ~) q7 ]' a" w* L - #include <asm/hardware/edma.h>
/ S/ r2 E" E: B9 ^ k2 x - ! D, t1 _- l, s" u5 ]) w
- #undef EDMA3_DEBUG3 d6 V0 h1 F7 X) d, w
- /*#define EDMA3_DEBUG*/
" ~2 J) h! w9 |/ `1 X4 i1 c5 f
$ ^- G. i2 v' |+ h+ t7 c! `; I. Y, ~- #ifdef EDMA3_DEBUG2 B& z: {( b7 s5 B4 D. P# r$ {$ N) W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! o0 K& t f+ W3 G- M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* w; t+ L) i4 G/ i2 c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( ~$ e9 Y4 i2 S7 [ _: G1 ` - #else5 o- Y6 Z& ]' ~; Z
- #define DMA_PRINTK( x... )& ~9 X8 s5 ~( X1 C5 Z! L7 G
- #define DMA_FN_IN
& d2 h- a9 H3 v# k* r - #define DMA_FN_OUT! H; [2 g b8 ~
- #endif, S+ P# Z' l; }
% I% B3 y, }, w5 M) v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 u: m0 O$ O. k4 G5 V
- #define STATIC_SHIFT 3
& K+ E m' _ g x - #define TCINTEN_SHIFT 203 R# Y/ H$ |) k$ _/ u R
- #define ITCINTEN_SHIFT 21- U' K" B, O- q v3 Z
- #define TCCHEN_SHIFT 227 |/ r8 h9 N* [# m' S' }
- #define ITCCHEN_SHIFT 231 b' G1 P* Y! e( D, r
! U0 T( }) z5 d$ |$ n2 H0 Z- static volatile int irqraised1 = 0;! f$ M3 _' U+ x) F: c. ^0 i
- static volatile int irqraised2 = 0;0 z% v6 R1 o q G" h/ J
" _6 P3 s, w' Y, U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% x4 }# ]; ^7 k$ V* s8 }8 a5 _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! [+ o1 S) E5 k9 s3 O1 x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 V: h; z3 I5 z( I) i& |
- % A6 ?( m8 g8 [+ ]0 p3 G
- dma_addr_t dmaphyssrc1 = 0;
- f9 V, g: L7 h3 S& d - dma_addr_t dmaphyssrc2 = 0;2 o `# v, G8 \, \
- dma_addr_t dmaphysdest1 = 0;$ w1 ^' w. a) I1 c0 X& A: H
- dma_addr_t dmaphysdest2 = 0;
7 y" m' Y7 ?+ e/ c2 I0 [
% ]: d8 T" C% D- I8 V0 i- char *dmabufsrc1 = NULL;
. w" O: g. F# E" o - char *dmabufsrc2 = NULL;
1 F! a. f, X" q) ` Q; A - char *dmabufdest1 = NULL;4 `4 b* {1 [$ L$ `
- char *dmabufdest2 = NULL;
s0 N, R+ @2 k9 N9 b: p$ G - ; Q! a* M7 Q4 Q
- static int acnt = 512;* z; k2 _ ~9 Z- l4 t; _
- static int bcnt = 8;" Q4 b& S" X. d* Q$ ?
- static int ccnt = 8;
0 O1 d3 n' y* _7 g1 b3 Y1 A
% @. h! t/ ^4 Y4 m- _( [. i8 {- module_param(acnt, int, S_IRUGO);8 n0 I$ @/ ]( @5 J b
- module_param(bcnt, int, S_IRUGO);) y d& r1 m1 {2 V; H/ ?) [6 o3 z' l
- module_param(ccnt, int, S_IRUGO);
复制代码 * v' d6 C4 ]9 n; X4 b
' w( a" s8 D2 m* M8 v! q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 U) }# m0 s& h2 \; n, Farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( D; q; F9 ~, R 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! D# G+ S3 ]. |! Q, a, e, o% s
8 `' M5 f( B9 ?8 p
* A9 [ I' i. u- O8 i |
|