|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 _. w3 h2 d0 E
- [code]EDMA sample test application
$ Y) O8 p+ b4 C/ c: r - /*/ N& a* l) o) D( u; `
- * edma_test.c }) p$ v* P3 I
- */ ~( v. j( N1 u" [& v; C9 b
- * brief EDMA3 Test Application
+ O/ O; M/ w1 f - *& `1 @' r3 U4 U' @# Q+ O
- * This file contains EDMA3 Test code.+ Q9 i2 R. X7 [4 [
- *9 c3 o' @ j: y: o% B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( B8 Z5 B* c' j* K: @0 { - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
u/ G9 g+ ]2 q4 O" z - * TO CHANGE.
4 ~$ i; P; [% A0 u5 C1 i - *( I3 \" Q0 ?0 `+ Y' S6 b& u- I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 [7 c" [. q0 _' O6 o$ P
- *6 U) _ O; v5 ~( {2 K
- * This program is free software; you can redistribute it and/or
h* ~1 M2 a& p: [ - * modify it under the terms of the GNU General Public License as& Y: d5 F- A8 Z& x( ]7 I8 U! R
- * published by the Free Software Foundation version 2.; ~+ S5 f) Z3 \- d
- *( P4 ^+ T/ E# g* Y: E: u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
F! ^) R8 n4 Q6 n) r' l A8 R0 r - * kind, whether express or implied; without even the implied warranty
y% @1 R3 h+ G$ q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* I) {% A, t. X+ O - * GNU General Public License for more details.; W- F5 ]# |. T# g/ ^- [% v
- */: |: x( W B+ D+ O6 V) [
' F' S; \2 P+ ]! {$ X- #include <linux/module.h>- f3 N& U8 M0 G4 E7 P
- #include <linux/init.h>% q: ~ ?- I9 h1 Z& q
- #include <linux/errno.h>7 O/ O; o% @4 l/ C3 f+ q8 B0 j- B
- #include <linux/types.h>
8 B5 j. b# i3 C% w: v4 Q% M3 ^ - #include <linux/interrupt.h>8 q8 G% V4 h- A- O& V1 u8 H
- #include <asm/io.h>0 G( a& g2 O2 }: _
- #include <linux/moduleparam.h>
% b! [; Y- p, o7 [2 {( W - #include <linux/sysctl.h>% R H" N* V& @# ~2 A2 J
- #include <linux/mm.h># w7 A" V: c6 q, q# G
- #include <linux/dma-mapping.h>
* e3 x9 M/ s3 O, a8 V" h! U - 6 e% A# H- b) E6 i# m
- #include <mach/memory.h>
% E6 y1 C, B- I4 D9 I - #include <mach/hardware.h>
- E9 G% ]# s$ @, T, w$ U - #include <mach/irqs.h>
; E" Y! o# [) X4 I( t - #include <asm/hardware/edma.h>+ B6 ` b! n6 D$ D9 u" S$ \
$ ?! X J; j0 v) T% V+ d- #undef EDMA3_DEBUG
' ~1 l. j Y( x9 D+ W% g - /*#define EDMA3_DEBUG*/
) M/ T* |/ X9 B- a3 { `, k - & J/ e0 q' q+ |' F! X j* S
- #ifdef EDMA3_DEBUG' E2 A$ U1 i& M" W* ?9 a6 [7 [! D2 M
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 p* |( b+ b) i% h
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 l7 F+ N: X: G7 ~$ s, Q- Q. j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) y' W3 b+ j! p3 T/ t5 b7 D. L
- #else$ ~+ f, Y. d4 y' w
- #define DMA_PRINTK( x... )
. `$ A% N7 s1 N( n8 S - #define DMA_FN_IN) h p* A& |/ H. |% l/ ~* Q0 d8 A
- #define DMA_FN_OUT
1 H; h* {1 G4 V) n/ P+ f - #endif
! v, Y9 L; s' b' j4 a
, i! _2 h; v, t; _% }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 S5 e9 Q8 U' f. g9 G
- #define STATIC_SHIFT 3! ]; G+ K7 r9 t. ]; o! h7 n7 h
- #define TCINTEN_SHIFT 20
) X9 t0 C! f# |6 o% f" a8 F3 E - #define ITCINTEN_SHIFT 21
1 ?" J; p9 S3 E - #define TCCHEN_SHIFT 22
3 p1 N Q: c* b' P$ _ - #define ITCCHEN_SHIFT 23" L8 H" A" [; E( `& m4 G' T9 R+ E2 A
- / f& X) d" b, B' x: }
- static volatile int irqraised1 = 0;8 ]# w7 F: j# B8 N3 i N
- static volatile int irqraised2 = 0;1 h; r; ?/ x" N8 K
- l2 F. B* }0 u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% I- ^" g5 D3 x8 o6 a+ F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 {* S3 m# Q4 n+ Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: h* w' X4 q- {6 c
. g" {; P3 y) p: L- dma_addr_t dmaphyssrc1 = 0;
% `5 W$ u: z! S) }/ t4 @# x2 X - dma_addr_t dmaphyssrc2 = 0;6 Z4 w+ L( ~+ Z7 B- F
- dma_addr_t dmaphysdest1 = 0;
. n+ s9 N) ^! N4 S5 _ - dma_addr_t dmaphysdest2 = 0;
8 y4 O" ^8 F( h! w1 g - 4 f1 m3 d7 u0 A8 t
- char *dmabufsrc1 = NULL;
7 q7 k; t; f$ S: f5 u+ `8 O5 n* B4 L - char *dmabufsrc2 = NULL;
" Y& I3 l7 [8 Z9 K - char *dmabufdest1 = NULL;
4 { S* x" f G; N9 s - char *dmabufdest2 = NULL;% G! F' e6 X* p+ Y' P2 Z9 e0 h
- ' F) {: A1 n. F' R
- static int acnt = 512;
% l$ c! k. O- s) A f' F/ k - static int bcnt = 8;
! n L* _& l. L; V - static int ccnt = 8;( v5 `, T7 a* _6 [3 u2 t8 f
3 G+ @! {8 l$ N+ G& A- module_param(acnt, int, S_IRUGO);+ \( S# d$ O; Q2 n% d. j- o
- module_param(bcnt, int, S_IRUGO);
' W) R' U' p. k, Q1 a! Y - module_param(ccnt, int, S_IRUGO);
复制代码
% N# ` S% Y {6 f* s) x! u
( P# C1 d3 S+ H3 E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ w- I V* n. w1 {4 Z# S0 warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
t- g7 l$ S0 U9 x/ P- [) Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 U2 C. k) m1 b6 f) f2 f. U: j9 }( ?
: s1 Q/ b6 R+ L
6 z$ |7 h* B; G, M* \# w |
|