|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, a5 f3 B2 W9 X" \/ |) f- [code]EDMA sample test application- b# ]+ X5 I! r
- /** I! l: r; A6 i8 q' u, T
- * edma_test.c
, N( t. [% z" ?1 q& i/ k - *
# O2 b' Z* G0 ? G2 G) @) V - * brief EDMA3 Test Application3 @" U4 {+ D' {
- *0 Y* H+ ^ ~; k7 R+ \7 l/ V6 c9 p+ K
- * This file contains EDMA3 Test code.: ^; {; z) f) l* A1 v6 P" X& e8 [
- *
: r8 s) |/ u0 V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ M, t+ L! L7 N2 D6 y: {/ K0 b8 R% m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 Z l6 L. W u - * TO CHANGE.
+ Z B1 j0 A# T& g$ M" V7 R - *! s4 g; n7 a4 q! g/ i/ v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" U/ k8 b5 f* X% j+ [1 \& H - *2 ?; r. `( i( j, ]! R, L. l/ F
- * This program is free software; you can redistribute it and/or
8 m4 ^1 N8 L6 {# J( R+ J7 h3 i - * modify it under the terms of the GNU General Public License as
# f/ O2 Z2 r( j1 k& U - * published by the Free Software Foundation version 2.9 y) g+ c7 H4 h$ W; S6 R9 O
- *
8 A; o# c) M) m% _' [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any# c$ B4 `2 E5 ]( t
- * kind, whether express or implied; without even the implied warranty
& ]. ~' \4 {2 p/ y/ f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 d. @' u+ { V4 i
- * GNU General Public License for more details.3 ?5 \: W2 H$ N3 r0 D' }0 I
- */) B P! P! `7 i
- : m% `6 g- g B0 }
- #include <linux/module.h>
! w$ R2 V/ C- y) x1 o: f - #include <linux/init.h>
' [0 V2 ]: Y1 X5 j - #include <linux/errno.h>. D: u1 _$ g7 M+ e+ k! r6 H( p
- #include <linux/types.h>
A/ v8 j4 v9 Y - #include <linux/interrupt.h>
. D. k, u! B, ~( q" z! e - #include <asm/io.h>% {8 {( W3 U: o8 U0 s9 E6 |
- #include <linux/moduleparam.h># ^7 P7 a9 D( K% S7 x* p- P
- #include <linux/sysctl.h>
) y: u9 X" K+ B+ W$ Q- x - #include <linux/mm.h> U% {, |5 |2 D) x& `+ m% r! H
- #include <linux/dma-mapping.h>
1 z: H3 }0 z: G, ]. _: X - ' C# A0 L C c: u
- #include <mach/memory.h>& r5 e* `" x6 V0 T
- #include <mach/hardware.h>
9 e/ a! T& H1 B. I4 [ - #include <mach/irqs.h>% r5 q1 `( d3 s4 L
- #include <asm/hardware/edma.h>% u0 V3 @2 B8 L ^7 `, E, |
- " y) [/ h- k3 b, }5 @2 W! }
- #undef EDMA3_DEBUG
% q# H) m4 t2 U# Y; y0 }& i! I& v - /*#define EDMA3_DEBUG*/4 `7 O; r9 Q9 s7 r
5 O0 O+ m4 q. {! E! E- #ifdef EDMA3_DEBUG
- }( D- t% e: b# V# j7 D( c7 J - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% Z2 m- K6 i& v- \9 @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* \+ |. C. O5 s6 H+ u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 D. P7 c# o/ ]
- #else
# I/ \9 q) ]# a1 [$ Z# K - #define DMA_PRINTK( x... )
+ X$ c$ K$ a! c" v; t( _+ T - #define DMA_FN_IN; i3 B1 D- F2 R* g' |
- #define DMA_FN_OUT
; M& R1 H1 I7 [ - #endif
/ q4 K9 N: J1 x# g& n1 W - ' ~3 T \/ r2 Z6 s/ |5 P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* C7 k! g: P% `0 i - #define STATIC_SHIFT 3
# e1 Y: k7 a' i# A- X/ d4 S - #define TCINTEN_SHIFT 20: u. r1 l% x+ k( |4 \! R
- #define ITCINTEN_SHIFT 21
* }8 x$ @1 W0 g8 U( k+ `( A - #define TCCHEN_SHIFT 22
+ f E* G" ~5 w) X" W) c - #define ITCCHEN_SHIFT 23: d0 ~# Q- G9 A" Z: t9 q
, U, o8 p4 P7 @1 N' T- static volatile int irqraised1 = 0;+ j7 I0 g- Z) ]% e* f
- static volatile int irqraised2 = 0;! V& ]& L. m& f4 x) U9 J+ G9 Q
- 7 m" l9 \1 }$ O* A, G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# F! o0 Y3 G% w/ ~6 Q& t: i: @2 u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* C! r: n" |. E# Z+ e3 @9 r. X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, e7 G' k' k% b' ]7 V+ P4 M9 R - 1 o, j; L% T9 d6 S1 u+ Q
- dma_addr_t dmaphyssrc1 = 0;# ~6 _" ?, O) a2 @
- dma_addr_t dmaphyssrc2 = 0;
' Z i5 K) `( Z2 y; B4 ^% T' ^ - dma_addr_t dmaphysdest1 = 0;
; _4 N1 c4 @4 f: u3 k; A+ M, y - dma_addr_t dmaphysdest2 = 0;
. f5 T0 ^ h& H/ [ - * R9 x# b" {9 ~3 B7 s7 B6 |
- char *dmabufsrc1 = NULL;
; D4 f* b/ t' }6 k! m/ W+ B$ n - char *dmabufsrc2 = NULL;
5 d! p: R! m3 x, C - char *dmabufdest1 = NULL;
2 z! B* a) s/ j: K5 n - char *dmabufdest2 = NULL;
# Y( [1 N) h: P0 B
/ X/ J" E: g7 Q; m5 b% h( ]- static int acnt = 512;: R0 z5 Y' v, D4 ?% ?4 O, D
- static int bcnt = 8;
6 n& [* o( J3 ~( c0 h% W$ S( w - static int ccnt = 8;
" Y; n/ y% I4 `1 ? [$ g. N
9 f5 Z& O& D* n- module_param(acnt, int, S_IRUGO);
) }$ T* F7 D$ b$ R: Z - module_param(bcnt, int, S_IRUGO);9 X! l6 T' V! Q9 v7 M8 v5 m Y
- module_param(ccnt, int, S_IRUGO);
复制代码
0 o# U* ]4 O4 e5 f& ~0 G7 ?8 U% |: ?7 w( A9 @* O( \7 j; r* R
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 T) t* m7 b. o/ T/ z0 g; |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' n& x! A* s, F& _5 K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 ~. B+ j/ D' N
4 D+ E& q- Z2 b$ o% r
- } v, `) z, B, X* t$ T( P- ^# r! A6 l' ? |
|