|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & K2 x4 G- Z {, \8 \; N. H
- [code]EDMA sample test application
4 d9 Q; K7 `. S' l - /*! K( f | {! }; h. g6 ]; ~8 N( H
- * edma_test.c
) w6 O$ x8 P% ~ - *4 P6 R: k, l& e) b) n+ F
- * brief EDMA3 Test Application4 w8 U$ I! S! L5 g
- *2 m' u) u w, d* Z, A- I( p
- * This file contains EDMA3 Test code.
; [. I1 S9 w) x1 r. [ - *! K4 o! B; Y% Q$ u
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- n2 S }7 ]6 d) Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 o9 N' j1 M3 G* G. U/ E - * TO CHANGE.3 }; U8 \+ y' q5 ? X8 v" s
- *) R$ v( g5 s7 D. W# @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 Z6 o. I1 B! L: M - *% v g' H7 A7 {8 E1 |
- * This program is free software; you can redistribute it and/or0 r7 |: V( N( x1 K
- * modify it under the terms of the GNU General Public License as
4 G) i) S7 A# I - * published by the Free Software Foundation version 2.! u/ ?) s f& ?
- *; Z) B) b/ O$ ^6 ^8 K7 [$ F% _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 f% A3 M! u J' J: Z' n - * kind, whether express or implied; without even the implied warranty
+ M$ \( I2 w0 Y; o7 x. s" t0 ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) d8 g" P2 ~1 L& H3 F. v! }5 W7 i9 ?
- * GNU General Public License for more details.3 D' \" ~6 c, i7 R# m& W# ?: k
- */1 p6 i8 B& N7 [" Z* S
) [9 H: x5 i) X3 }! R- #include <linux/module.h>
$ ]! `+ c7 V( u; c6 { - #include <linux/init.h>
+ k$ T: W% |( X* ^ }2 M - #include <linux/errno.h>; p' ?( S) V) f8 [- g6 K8 `
- #include <linux/types.h>( v `3 N( T2 N
- #include <linux/interrupt.h>
+ w% E: \6 |0 }% \! r1 s3 g% w - #include <asm/io.h>& f8 Y/ `" f' t3 i( X% e
- #include <linux/moduleparam.h>
! C9 @" V( ]! U* l5 ~& s - #include <linux/sysctl.h> d$ t5 C& p# p" f$ L
- #include <linux/mm.h>9 q0 R5 \$ f7 [( o y
- #include <linux/dma-mapping.h>
% D$ i4 l$ L9 Q3 F" ?' n, n8 p - " d" z' O/ k/ a5 y
- #include <mach/memory.h>6 [9 U1 S: Q2 C" j- k) ]4 i
- #include <mach/hardware.h>6 z7 o$ L% Q( e4 M/ d4 S
- #include <mach/irqs.h>8 t7 k5 r& Z0 Q6 g" ~$ m; ?
- #include <asm/hardware/edma.h>
. R9 o8 E! c' d4 z. l - # E/ `1 G1 r) b9 O& N2 _
- #undef EDMA3_DEBUG" B, k, E Y8 ^; _( @
- /*#define EDMA3_DEBUG*/
& k, Q5 F$ X% ]3 k1 o- c - & w/ S7 G% i4 m
- #ifdef EDMA3_DEBUG! V9 a! v( I; q, b- }, w
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- |2 Q8 w4 }% q+ f- l1 |, M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 x: m. Y7 |8 {1 m, d1 `1 `3 l9 z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 y7 h# w7 |) I0 q2 ?
- #else
8 K* t O& G4 k& B* ^* a - #define DMA_PRINTK( x... )& w& D9 d+ m4 A6 B; `0 f5 u% ~# O. Z
- #define DMA_FN_IN
9 B; V% E! l% H2 r j! v! r+ }4 { - #define DMA_FN_OUT5 F& u% p8 s: L* g5 L' p% z8 k
- #endif M) K* l) t: w. h
) z# Y; i0 z, y L4 g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 [/ H5 ?6 i$ ?+ @; e - #define STATIC_SHIFT 3
' n) x% ?0 L3 s! S/ w - #define TCINTEN_SHIFT 20( h4 b2 I9 O% d& }
- #define ITCINTEN_SHIFT 21
. o! S8 y' V5 ] - #define TCCHEN_SHIFT 22
, a! H8 Q; P( a$ [) N) g - #define ITCCHEN_SHIFT 23 x: E) m: y: \* ?7 R$ b
- 1 M2 G/ h2 E7 B* C8 W% L$ Z$ i$ W( _. q
- static volatile int irqraised1 = 0;
$ `0 L4 i. |9 ~3 z8 a* @% ^ - static volatile int irqraised2 = 0;2 d+ f, t+ `7 V9 e- R1 t
; s3 b+ d+ F7 F! |+ I, y7 `- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" [6 g( _3 }2 j9 B* X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" z3 ^0 i: k, H0 F( V/ O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ L! c4 [# y. m4 A4 V
8 _& \' i7 m3 R I9 a4 L- dma_addr_t dmaphyssrc1 = 0;
- v! A/ \- d% h/ q2 v) I; h) p - dma_addr_t dmaphyssrc2 = 0;
9 U P& R6 L$ {# k D' W8 @' E3 n v - dma_addr_t dmaphysdest1 = 0;1 c( l& Z/ @% G$ j
- dma_addr_t dmaphysdest2 = 0;
, c y4 c+ \% I8 Y; ?
]7 ?( N' @; [& @+ N( D- char *dmabufsrc1 = NULL;
( S; D8 A- M: p; K$ r - char *dmabufsrc2 = NULL;
9 X2 O ~ K3 R7 f5 k1 f- }- @ - char *dmabufdest1 = NULL;2 _1 N+ W$ `" T( j* f$ u
- char *dmabufdest2 = NULL;
/ B$ O- k# g* R
- I5 d4 X& B# @- static int acnt = 512;
6 t0 m: I9 Z8 M0 o8 b9 E' Z( n2 A$ { - static int bcnt = 8;
5 s- z3 P( D1 q1 ~, L7 { - static int ccnt = 8;
6 U5 }, N: V& m- p2 K
' l5 b; o- n9 {+ E7 T/ l, \- module_param(acnt, int, S_IRUGO);1 a* h- m& ]0 ^% X! x
- module_param(bcnt, int, S_IRUGO);
* Q; T9 s, t/ x ]8 q( X. | - module_param(ccnt, int, S_IRUGO);
复制代码 " G$ {5 v* J* O" J# ^' F/ [
6 Z+ ?' j- }/ d
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) F: @& \# z5 M7 @ p1 O3 c6 z$ P* |arm-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 N1 g' a4 z. D" U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) O9 f8 f8 x. |8 e
" P5 w1 h$ u5 ], P; R0 T# p: l# c
|
|