|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! ^# I6 {) }$ \3 S8 O7 m1 F
- [code]EDMA sample test application7 ~8 s. y) d: |: ~# M3 D# o5 D
- /*
6 o) J& I+ P* v) G+ ~4 N+ _+ N - * edma_test.c
6 z' S0 T3 O- @$ n- G - *- n. I8 |9 s2 R7 B- J+ B5 T7 z
- * brief EDMA3 Test Application e3 X( b( s2 u3 J6 E- `4 B
- *
& O) S m! c# K. D: c2 Y& U# d - * This file contains EDMA3 Test code.
$ R( p) q' x4 z5 R - *
7 V& \( U* }7 E4 a0 H6 ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* W& _5 A! p+ M- V; H. G& I& C: W" b6 R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) u. ]0 q( \4 _: `! ?1 ^
- * TO CHANGE.
9 ?! y! Z s! @, T0 L% Q - *9 I2 W9 j1 k" ]* k
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; R) B1 l0 z* d( } - *
) k3 f; h9 a. r& ~2 j - * This program is free software; you can redistribute it and/or# F) R# T- {+ A" _. _
- * modify it under the terms of the GNU General Public License as
- n: z( H* F8 E. _) i - * published by the Free Software Foundation version 2.3 C& O& ^ n3 x7 ^4 q9 o3 n% q
- *0 ]: ?3 f: m+ i9 v# O; [# v) M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ T% p% k/ X. c' d* @7 H - * kind, whether express or implied; without even the implied warranty
I4 h) V: q/ W1 E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' D- J0 {; Z, J9 p4 H. M
- * GNU General Public License for more details.
" h& Y; R1 E# x8 c$ `$ H g0 Q, I - *// _) ~- p5 A/ l1 s$ V
- # s. Y: x# N/ K' A$ h( Z# {* w
- #include <linux/module.h>
2 B e3 c* b) j* S- m6 H+ t - #include <linux/init.h>
8 v. Y" L0 v' g, N$ q - #include <linux/errno.h>5 i3 K0 P3 z) f
- #include <linux/types.h>" m' H- s- z) g
- #include <linux/interrupt.h>! I9 E5 P$ z- ]+ ^2 [
- #include <asm/io.h>
0 x7 A" { r* T! k4 g* ? - #include <linux/moduleparam.h>7 I% B; t' F/ b+ h- w
- #include <linux/sysctl.h># B) G" Z) b* b9 m/ Z& Z5 y
- #include <linux/mm.h>
2 k0 o4 p6 r! t& W2 C4 c) Q. q# u - #include <linux/dma-mapping.h>' _; V) V8 d4 w, g. l
, k7 H$ ~1 ~( P/ u- #include <mach/memory.h>
2 L2 A0 A) e* c/ M" \& | - #include <mach/hardware.h>
. Y, ~2 g8 O2 A& g - #include <mach/irqs.h>1 N, A- A! Z5 O$ y) M) ~' v: k
- #include <asm/hardware/edma.h>
4 l/ ?/ u& v, ?* m, `0 L6 f - 3 C9 L9 H& C% p2 L. d5 `
- #undef EDMA3_DEBUG
+ X& ^; Y4 ^4 F: {" T( s" J - /*#define EDMA3_DEBUG*/4 Q/ E1 N- b9 s; K g
- 6 l% z# N& ^, ^$ U6 ~9 O+ p* C& h. p
- #ifdef EDMA3_DEBUG
* ?! _5 e3 C9 E: Z, j7 a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ {/ D$ s/ p% V0 S4 | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): R" k' p! h% D. F& Q+ l/ {* X/ D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): V9 \7 w2 P( O0 X! r& g- N
- #else- f" `5 s7 s3 R9 o. l( j4 ?
- #define DMA_PRINTK( x... ), r+ h/ z' t, w$ H
- #define DMA_FN_IN) s, Y4 [% s/ k# W" |
- #define DMA_FN_OUT
. S( l6 G; O+ I - #endif: N g$ I) ~% v/ p' m6 r
6 o) c; ]5 m6 u0 m4 Y; _- g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" F9 b1 I1 c3 G - #define STATIC_SHIFT 3
2 d% }6 f$ |- _9 B - #define TCINTEN_SHIFT 20 t7 A$ y5 t6 ^- L! X
- #define ITCINTEN_SHIFT 21
- ]6 f# w, h' {. H7 N; R - #define TCCHEN_SHIFT 22! Q7 e6 ]# u7 s* e, S9 E" A
- #define ITCCHEN_SHIFT 23
" v- ?6 d( j+ {6 L! D; _ b - 2 S" b" U# o' ~# k! [
- static volatile int irqraised1 = 0;; E6 B; x8 u3 e
- static volatile int irqraised2 = 0;
' F: z4 O* b0 |/ ~8 D - / _7 e- s; C% V3 G8 J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ^2 b/ h6 x5 V' Z2 G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. l. P" b& O! Z5 `- [8 e4 ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 [7 w p% L7 [9 t
+ [6 G9 U( e% J6 b- dma_addr_t dmaphyssrc1 = 0;
, b+ ?* Z$ J& P _# [ - dma_addr_t dmaphyssrc2 = 0;
3 p* g' B$ D4 l9 E, p0 k - dma_addr_t dmaphysdest1 = 0;6 ^; z3 t0 p6 y) \4 o1 @3 `
- dma_addr_t dmaphysdest2 = 0;
: x# e0 w' l, H: _' l( y0 }% g8 R! p
# X; q9 ]& b1 K- char *dmabufsrc1 = NULL;
7 C; I7 A" s) u: P) b" c* w - char *dmabufsrc2 = NULL;
" V& F! f1 I( ^, t% A |/ L0 O - char *dmabufdest1 = NULL;* h) M- U2 p" z/ M6 k
- char *dmabufdest2 = NULL;' C1 Y) _3 F) S+ B9 X
. \9 p( S! m e( Y8 D% }0 W. x* b- static int acnt = 512;& a* j9 y4 b8 @& W# ?$ p
- static int bcnt = 8;, Y5 z- e- i, A# q
- static int ccnt = 8;9 x W- ~- Y; o) L4 k
- 5 T: t/ E# B. M8 g2 v. p7 p
- module_param(acnt, int, S_IRUGO);! x, o( ~2 ^$ p7 |" L* y# H5 {
- module_param(bcnt, int, S_IRUGO);/ h6 b" u) u$ ?& z+ R4 t; p
- module_param(ccnt, int, S_IRUGO);
复制代码
: X. P% _' l, Y4 y6 s l
$ h: B/ g% ~# U, N" D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 d# }) I- H# K3 S M: s$ c+ c. Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* e6 m3 t' e0 m w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 b" t4 |, P, i" S/ u; T9 @, `) X% Y
1 P+ k4 R3 l9 e1 P! a' ?# L
|
|