|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 u9 y# o' m1 f. `# g0 }- [code]EDMA sample test application3 {- h8 p6 i# r8 O$ U0 N
- /*
, X+ [4 w% l7 L, r - * edma_test.c- E2 U' h3 {4 I) h) t
- *7 c4 o8 Z# `- ^4 A
- * brief EDMA3 Test Application
- I1 C, o1 B5 i2 s - *
/ K2 z4 m; O' q - * This file contains EDMA3 Test code.
: U4 i, P4 u. j# { - *
8 F! f' y! _$ T( Y+ P+ T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ f) W' f: V& f7 x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& l, Q3 B A( h9 U4 v" h% }
- * TO CHANGE.
, r, x$ L2 Q; M v) a' s% H# U4 R - *
4 s1 ?5 |4 g3 E& g" i( m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! O8 l3 b+ i3 J - *5 u+ Z9 @* U) Y
- * This program is free software; you can redistribute it and/or. H5 U3 Z: k0 \- c p
- * modify it under the terms of the GNU General Public License as
8 C1 i$ A' ?5 f+ Z - * published by the Free Software Foundation version 2.5 k; M; ] j; [/ V
- *
$ ^2 p$ _# {8 k, X: V S- Z- W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% Q# ]1 v: S4 Q$ N/ y6 e+ i+ O \ - * kind, whether express or implied; without even the implied warranty
, b- e9 |( p5 o$ J - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- T2 t4 X, h+ b& S' @
- * GNU General Public License for more details.
- J- D1 _) p, J. @, K) k - */
: V# a/ k( j e( k5 j3 O% B2 S - ; L3 O8 J, H# C- ?# r
- #include <linux/module.h>
' Z2 L: W$ x6 Y: o - #include <linux/init.h>; j' z) q8 j3 s/ u; N
- #include <linux/errno.h>% O7 h: Z% {6 _4 Y
- #include <linux/types.h>
% t1 ], L6 `3 J! d8 i" l2 z6 \ - #include <linux/interrupt.h>
6 ], R3 b6 A( w) X8 O2 ]1 F' { - #include <asm/io.h>* I4 O d( o+ W; L7 _ \5 N
- #include <linux/moduleparam.h> y6 [, n2 I5 z2 v+ k
- #include <linux/sysctl.h>
4 Y( O7 g) \* i$ g - #include <linux/mm.h>: ~" b! }% o/ f" L8 d# m: \7 K
- #include <linux/dma-mapping.h>+ G2 |# }, _2 ]+ W! `+ k
- 8 L7 F+ ^6 V5 P
- #include <mach/memory.h>+ l8 E; z5 p2 n( t
- #include <mach/hardware.h>+ W) R* m! ]! H# ^
- #include <mach/irqs.h>
" o5 l+ g$ I) E- w - #include <asm/hardware/edma.h>
* Y) T2 L( q- v8 l% x2 z
1 G7 j5 u) U! V8 u- #undef EDMA3_DEBUG
9 a' {" V% t7 p" V - /*#define EDMA3_DEBUG*/7 ]: Q( K, T: J' L" Q. U
- # Z A# u4 c& F6 t' a! @" R
- #ifdef EDMA3_DEBUG4 M, P! E3 O* l# b5 Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 V# t) \% ]# g4 K/ f* a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 v% R3 I( V. e
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, Y% c# i' s! n; z" ], K; C$ O - #else
+ e% W3 f6 y# L8 h( O: h$ h - #define DMA_PRINTK( x... )& |5 @! q! j) E R( N
- #define DMA_FN_IN) T+ z- m! L* C6 ]- @5 Z& H
- #define DMA_FN_OUT
8 Q b( m+ r9 d J, u - #endif
; q% v7 g, K6 b, T
; `0 |4 o5 x+ |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ |$ r8 s' G- v# Z* |7 ]
- #define STATIC_SHIFT 3
$ F( B5 `- E9 w$ Z - #define TCINTEN_SHIFT 20# \1 K$ e: _' i" ^4 P& k- y" ~0 {
- #define ITCINTEN_SHIFT 210 f4 j, H: O3 h8 F3 D4 w; f
- #define TCCHEN_SHIFT 22$ g3 J: C' L$ n
- #define ITCCHEN_SHIFT 23
( }9 d k1 Z% n0 e0 R - 9 C2 M8 x; K8 u+ f
- static volatile int irqraised1 = 0;
) V- F, u9 E4 _; v8 `) _' g7 m# k - static volatile int irqraised2 = 0;
6 a* E+ R9 f6 D5 C5 \
7 P$ r( M$ ~9 }4 Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 z' T B% b" z8 O# m! k [9 p - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 P% { ?$ U; z$ X& b- Z: f0 D6 N
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. e$ W; c$ \$ a" K: X
( ~0 e z0 Q+ i! } ?! ?- c- dma_addr_t dmaphyssrc1 = 0;* [( {; `% D* I9 N0 S$ `2 q
- dma_addr_t dmaphyssrc2 = 0;
: ~( Q; f% b$ A - dma_addr_t dmaphysdest1 = 0;/ z& {! }8 [& _/ L1 ?
- dma_addr_t dmaphysdest2 = 0;
$ \4 {) J! Z- }8 |
& {5 {' `; o+ A/ {6 W& E- char *dmabufsrc1 = NULL;
5 \& Y% M- c7 v" b9 | - char *dmabufsrc2 = NULL;: q! {$ v) E5 ^, I- y" \
- char *dmabufdest1 = NULL;
! _ i- W8 v- \2 W( x - char *dmabufdest2 = NULL;9 a J8 x: S' b" x4 ^# @. u
4 x U4 W3 Q; N5 `( [* ?- static int acnt = 512;2 G7 D: L# G" i* K+ E7 y5 l
- static int bcnt = 8;( ~6 `. h5 ^% M1 j$ g' n2 Z
- static int ccnt = 8;
) u% P) ?6 z3 p9 l+ H7 Q3 Z - ' T0 L* Q! P- s% _
- module_param(acnt, int, S_IRUGO);! R: D& d: S8 B( P
- module_param(bcnt, int, S_IRUGO);# U+ I; W' `% l/ W/ b) D/ ]
- module_param(ccnt, int, S_IRUGO);
复制代码
4 ^: p) x, |. A* g. P
, C4 g f/ l8 f- T' P8 R3 k9 a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' k# T8 d5 N9 }! O4 Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 D" p! K' b9 t( d- f# \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; r( ?2 }% k: k7 W, O
2 _2 Z+ A5 F/ @0 ]/ h, D7 T! a9 q( @% F% {
|
|