|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / D, T, G" [ k- T3 d. o- B9 H
- [code]EDMA sample test application
4 f5 W; Z% R6 g! v1 l6 V - /*
4 l& p3 I4 @" ?/ }3 _ - * edma_test.c) }- m8 @1 s8 P) W4 R( k8 k' j
- *
% \# \# ?: x' a, d - * brief EDMA3 Test Application
* {* }" O) `2 ?% r - * V5 R" S, Z$ E! k/ L& S! \0 N
- * This file contains EDMA3 Test code.3 n# W( H" j4 f1 i- t
- *, p9 Q; d; t$ N+ I& a' Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 G3 f: @' T9 i" Y" T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ a9 j$ ^* ?& C, O6 M* h0 m+ V" } - * TO CHANGE.
9 h* r* W8 l% e! Z2 ?5 { - *
* S* v/ s) `) T2 s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ o' \ r& p$ v - *" v* ^) k! i: U7 q0 v" E8 B
- * This program is free software; you can redistribute it and/or
& e3 F7 _; A4 n+ Q6 e - * modify it under the terms of the GNU General Public License as
1 o5 L; C- m. o/ o - * published by the Free Software Foundation version 2.
: n6 e+ B/ U/ g* e$ {5 s- \5 B R' l - *$ q/ J g4 _7 F- S, \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 m: T2 t# b- h2 t2 h - * kind, whether express or implied; without even the implied warranty2 }2 K y; ?% i3 s, r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 v4 Y; @& N; S7 b) C+ ^ - * GNU General Public License for more details.% O% H# v. |3 J" Q
- *// }! E1 P( N( t
- 2 Z. w9 B2 ]* n; ]& y) J
- #include <linux/module.h>
/ C5 Q7 r5 s4 r2 V: h - #include <linux/init.h>
, i( X# V3 O. Q8 f! h0 K' b3 f9 f - #include <linux/errno.h>: S1 Q6 c6 i- z
- #include <linux/types.h>
A: D* L4 w" c" v3 D) [! y, Z) Y9 e - #include <linux/interrupt.h>
( E- c7 p. ?/ A - #include <asm/io.h>( D5 s/ M" H+ J3 e( Z
- #include <linux/moduleparam.h>
4 n/ b! r' f, D7 Z ?) y - #include <linux/sysctl.h>0 q- f" c2 k9 `
- #include <linux/mm.h>5 Z# I) I" p2 g! n9 n9 W
- #include <linux/dma-mapping.h>
- L0 B* B8 P8 v: E9 S
( k$ |+ \% t# C. @- #include <mach/memory.h>: N# F4 h* T% r% A1 g: `
- #include <mach/hardware.h>9 U/ B+ V" U: b. K* v" q. F$ A
- #include <mach/irqs.h>
2 E/ ^( M& V/ n - #include <asm/hardware/edma.h>
j6 L f7 N6 ^6 b$ \ - , ^4 {9 y* F) {6 g2 @5 q
- #undef EDMA3_DEBUG; W4 N3 ]4 B; \4 k0 P4 ^/ ~
- /*#define EDMA3_DEBUG*/4 o6 d! A. S7 ^5 @9 _" d! n
- ) C' D6 |+ t$ ?% w+ \
- #ifdef EDMA3_DEBUG
9 d; [" [1 B2 o8 ]0 ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 @0 a% H9 `2 v7 @. s% S' d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 v/ y) e' C: V6 [* ~, n8 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& v: G( f: e- T; B9 H - #else
O3 |3 Q5 U, T, M* N$ T6 {. l: c/ g - #define DMA_PRINTK( x... )8 s6 J, Z4 o) j0 g/ T; O1 z# N! V8 ~
- #define DMA_FN_IN' S6 U) | R* G" M! U* U' i
- #define DMA_FN_OUT! M; y# W: T$ b3 ~* F+ g0 r
- #endif4 @9 t: C& U5 A9 x) |4 _
$ u( B( V8 v) a% v0 h( I: B8 n- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" {3 F' u* e4 i; y# S! O - #define STATIC_SHIFT 3
" j x" c" l; _- k1 h - #define TCINTEN_SHIFT 20& G7 R$ f3 O L7 i( k- G
- #define ITCINTEN_SHIFT 21% ?# Y' }: w( o4 z# X. H
- #define TCCHEN_SHIFT 22
5 b* r: B* y& Z! u& f - #define ITCCHEN_SHIFT 236 P5 S( P8 p/ B7 d7 I1 H8 C. ?, f
- & h/ d# b* }' _" C/ ^& I
- static volatile int irqraised1 = 0;
, f; \8 A9 C" \ }% Z - static volatile int irqraised2 = 0;
8 X8 \7 P: K7 H7 g3 |7 g - 6 z4 z* W: U6 i& F8 l2 h2 Q. I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 Z/ n7 q ?2 W4 A z: t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
E, q d' m) F4 \* S& s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 i) n2 u, n/ v" u3 \
% K) }6 i3 G) Z- dma_addr_t dmaphyssrc1 = 0;8 Y" a! E/ ?1 F& G5 J) z/ P
- dma_addr_t dmaphyssrc2 = 0;
F) Y* T' z: x" l! L - dma_addr_t dmaphysdest1 = 0;- S! B/ ~7 g% M4 b) ?! B
- dma_addr_t dmaphysdest2 = 0;9 E! C' H/ l3 n2 V1 M
5 K; |5 n2 X* g: A) w- char *dmabufsrc1 = NULL;$ ^7 U# n3 b9 y# n" Q M
- char *dmabufsrc2 = NULL;2 q- D4 ?/ j1 [
- char *dmabufdest1 = NULL;
" L' p: @8 D+ s/ Y x* ] - char *dmabufdest2 = NULL;
+ c5 r4 r5 j1 p+ B) u - 0 n7 @( S: ]0 [; X; S' a2 u9 D8 U* s
- static int acnt = 512;* [2 k& q, R9 G; A7 Y
- static int bcnt = 8;$ |; s& I3 U2 D6 O8 @1 X l
- static int ccnt = 8;6 c" A: }' a: S8 W/ |" c6 j$ S
3 G# G" k9 d1 ~* W, z/ z( j- module_param(acnt, int, S_IRUGO);
3 T; ^* ~7 ^; x @ - module_param(bcnt, int, S_IRUGO);
# `0 `( i2 b( ^2 y% U - module_param(ccnt, int, S_IRUGO);
复制代码
+ z t( I1 j' ]: w
6 J `4 s9 k$ ^) c$ R/ } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! s4 Z) i& P5 o- D" U: n' Y+ z) _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: X3 C! l6 L w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
v" e0 ` g. J& d* A9 `- r4 x1 h: b" X4 C
$ K8 {' ?# F8 i# L6 v |
|