|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: _7 b, g5 ^+ D, l- [code]EDMA sample test application
' R- u/ \2 m) h9 ]# n5 j2 ^5 c0 r- L - /*
! x4 r% Q) r9 V( N( l& Y$ a - * edma_test.c. L6 u5 ~ {0 X6 z: J/ F9 \
- *5 ^" r) q: {& o8 _& Q
- * brief EDMA3 Test Application/ M U* i7 J1 ?3 }9 Z
- *6 }4 V; N( W4 E' ^0 `) g
- * This file contains EDMA3 Test code.
4 K: z7 s& h& F, g7 [8 a1 U - *: r/ z' W: s& @+ k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# S% {6 W7 X$ m5 u2 j$ w+ R. F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% A W" m R. j$ N! g+ A3 U
- * TO CHANGE.4 R* t# Q1 v6 ~# W( k- b. |
- *
- S; M$ o% R9 _; Z7 H' v) j - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, D b- p: |" n8 k ? - *
7 R: C$ ?) n0 J4 W" B8 Z8 T# t - * This program is free software; you can redistribute it and/or4 ]. B9 |8 }8 b. G( l+ `
- * modify it under the terms of the GNU General Public License as6 [- A7 z ~0 t3 B9 G3 O, k
- * published by the Free Software Foundation version 2.8 L) `1 ]1 J4 o: g% h( P/ o+ a
- *0 r3 ^) k7 N0 `% }/ H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% J; @9 O" K/ j6 v5 K - * kind, whether express or implied; without even the implied warranty
( a$ l- a) g2 R% Y* }! F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ Z! k$ \1 d: N W5 T3 p- ?$ O
- * GNU General Public License for more details.* X- G% `# i$ G) K, E3 U$ [
- */
f, ^# w& k3 r: E. F3 B/ }3 |. E
+ Q- T Y$ x. h" K5 _3 ], T- #include <linux/module.h>
! c1 s: t) C& t. U - #include <linux/init.h>, r+ L3 ?; ]- g, ?* n( k
- #include <linux/errno.h>
3 f% ^' o4 e* S- }# P7 z- b: H" R - #include <linux/types.h>0 w) q( k: O$ g1 i8 B
- #include <linux/interrupt.h>& v9 V" G+ M& x: o: M5 P
- #include <asm/io.h>% A! C! x* v0 C& ^6 ^2 f- }2 `
- #include <linux/moduleparam.h>
) W/ s/ C+ V. v - #include <linux/sysctl.h>, M, \: C9 C- O; |* j
- #include <linux/mm.h>
2 d2 I. a9 V6 u- l2 A - #include <linux/dma-mapping.h>
6 L: w6 t! F% Y4 v( E - & F* q% o* ~8 `1 C' M' w
- #include <mach/memory.h>
' u }9 p8 ^& V! S - #include <mach/hardware.h>
3 \" a$ w! j5 A, w$ T - #include <mach/irqs.h>
, ?6 _7 [# `4 k - #include <asm/hardware/edma.h>
{& T9 G3 b0 J
$ J4 d" ?1 x$ c4 J6 x- #undef EDMA3_DEBUG
1 n5 V9 N; Q' @0 I" O - /*#define EDMA3_DEBUG*/5 ^+ t* w+ b3 t
% `, K: |9 j a+ v% b# d- #ifdef EDMA3_DEBUG
+ F6 v$ j8 g* v5 e8 G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 B1 E2 m Z7 l" {- R" s& l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 u" Z9 L* u, X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 {3 s7 P0 {% T/ v - #else' t+ R& l& W. k6 W
- #define DMA_PRINTK( x... )& F$ g$ z" L5 ?4 v$ T
- #define DMA_FN_IN/ R+ v0 d T, e( L2 a2 e+ Z
- #define DMA_FN_OUT
$ e2 D6 B$ y8 W$ v q - #endif, U4 |; i& s1 w' f( S1 W, Z
- ) d! r; E( a/ d+ d% T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) b' X0 q" T1 Y - #define STATIC_SHIFT 3' a, V7 ?. Q. `/ g7 D
- #define TCINTEN_SHIFT 203 B$ K# W; N, \0 ]" K
- #define ITCINTEN_SHIFT 21
! }' x& @3 t: t* u$ R, m - #define TCCHEN_SHIFT 22
. J5 N; P4 k3 J. e- i2 z - #define ITCCHEN_SHIFT 23
( v5 C( r1 w8 M
7 J1 a. r p- U- static volatile int irqraised1 = 0;
: N: B1 {. [% f2 y$ V. ? - static volatile int irqraised2 = 0;9 P& ]9 g- G: G6 o! t0 x' O
- : y" O0 e: n% @/ |' R8 P) W" \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 G4 c4 z! B3 q" [' }& e! m7 D
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; `3 P) @7 m4 N3 Y2 C8 i' A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
U" ^6 c3 v K. Z - 3 d# v# }, e( i3 E1 }# k2 w- q
- dma_addr_t dmaphyssrc1 = 0;
4 G1 r Q/ F& X1 o6 n3 o - dma_addr_t dmaphyssrc2 = 0;4 e0 ]$ D2 @9 R+ N" {+ K
- dma_addr_t dmaphysdest1 = 0;* Y4 l8 y3 ^ t. ^) D
- dma_addr_t dmaphysdest2 = 0;6 X& t. n, F" a. U: w. [
- ' R. H- W6 F; R: q3 `8 X. K
- char *dmabufsrc1 = NULL;1 d8 ^% s' c4 N! Q6 U
- char *dmabufsrc2 = NULL;
/ C! L. Y1 c0 j6 k$ b! a& U/ ]9 j4 P - char *dmabufdest1 = NULL;; G" x1 y' R. n" R& v
- char *dmabufdest2 = NULL;% O& n2 \0 S4 p; A# e
- + g4 \4 {+ \7 E+ Y
- static int acnt = 512;5 I0 ]: x2 B" X* c0 |
- static int bcnt = 8;
& J( T2 X0 {9 e' {7 X - static int ccnt = 8;
) x, d, m7 Y. i+ ?6 H0 Y" ` F0 y
+ p4 A" f# _2 Z- module_param(acnt, int, S_IRUGO);$ O! G2 o9 a0 n( ~" S; L% o- t
- module_param(bcnt, int, S_IRUGO);
( v- `% |# w: u& z - module_param(ccnt, int, S_IRUGO);
复制代码 2 q" y3 e# y- p; @% j' P
2 d& }$ D8 W7 K5 [8 q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 h& B6 ^; v7 d& `+ [7 m1 W/ Iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 F! |: j- B8 x4 t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* Z' L9 q) }9 P1 h0 x! I% T$ `
3 |3 r. X2 F/ V- ~* @; v, i
) J" w. X5 ^8 S9 N |
|