|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( D7 w& R. B( L
- [code]EDMA sample test application% |+ i. I: J9 D# _2 r+ a/ m! @
- /*1 ^: y' K" j" O5 e( j+ ]9 _
- * edma_test.c
0 v% {6 q6 R; x7 F; A9 t - *
3 N) _. j; T2 ?7 p& Z! Z, B. h k/ v - * brief EDMA3 Test Application
: u' F* v `5 f3 R0 i9 B - *1 z% Y" Y, ^, v
- * This file contains EDMA3 Test code.5 N Q2 s7 c6 t7 a
- *
: L1 a( t3 A1 H+ G+ S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: x$ d [3 r; I5 X" ^* L
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 M2 y# R8 G: y) G1 p
- * TO CHANGE.
, U' O( S5 X ~4 d `9 k1 i V3 B - *0 G' |* w! `) e+ G8 K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( I. a! u; M/ V. T7 | - *7 w- ~- B1 n; U" W% t, Y6 ?
- * This program is free software; you can redistribute it and/or
* c3 p7 m3 h. F0 }0 A* L - * modify it under the terms of the GNU General Public License as) }/ k- w5 M2 W+ ]6 i0 u W Y
- * published by the Free Software Foundation version 2.
& ^0 `1 h" Z g3 I' K - *
9 s8 [, V- R2 I$ @" I- _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ \$ f4 |, ]- E9 @ o9 \+ k/ O- K( i - * kind, whether express or implied; without even the implied warranty
2 l1 H) u4 ]. W - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: l8 I+ E% h% x0 \% G5 I- q
- * GNU General Public License for more details.
# Q1 d5 T! S9 H& e7 q - */
9 ]; ?+ d& W; s; B, M/ { - 4 ~1 e' E% n9 T K v, p
- #include <linux/module.h>
5 ~" i2 S1 Q# }5 r: r& T - #include <linux/init.h>
3 }' ^/ H2 L6 A7 k - #include <linux/errno.h>+ g3 @# y( @, x$ P+ J- H# h' Q
- #include <linux/types.h>. o( _) W/ o+ D$ f
- #include <linux/interrupt.h>8 W- n! [9 ?$ w. m
- #include <asm/io.h>
. M9 o/ u- S R. o( u! i! Q - #include <linux/moduleparam.h>- Y q. J6 `; \9 Y4 _
- #include <linux/sysctl.h>5 h1 f, Z& l% A8 A) ^8 r$ z
- #include <linux/mm.h>9 F6 y: z; u( g3 z- @: R8 t
- #include <linux/dma-mapping.h>8 E: T v# m2 D/ U
. l: m! O1 ^$ c5 b+ ^& P- #include <mach/memory.h>
4 r% G" H- X V: I" j( w% ` - #include <mach/hardware.h>
7 B0 }0 `# q. g( U% r+ t# n - #include <mach/irqs.h>
! x# p, N7 S6 Z: s" [$ Y - #include <asm/hardware/edma.h>" [; N1 ^4 O4 ~5 B' l) @
- i; W% c6 u2 R( n. Q- #undef EDMA3_DEBUG' D* x( ~& _3 y" Z
- /*#define EDMA3_DEBUG*/ K! M/ _" T. V* \0 U. L7 k
?# i; m/ c1 f s0 e- #ifdef EDMA3_DEBUG& w1 f i: J3 @) l6 J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 R5 [$ q! {( Q( | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' e. _& i8 ?: V( u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 \/ I& ]' i: R$ t
- #else' r5 C) R5 d5 r/ E9 y( f
- #define DMA_PRINTK( x... )
8 {$ P7 w3 x+ f: O5 T) W - #define DMA_FN_IN
! M8 L3 c3 T" R* N+ Q3 I: W. N* j/ D - #define DMA_FN_OUT
1 v) \; @; A _( C+ L: E. u - #endif7 r5 ]* A; @( `/ s1 {
- 0 D3 u" u1 [5 E/ B3 e9 P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 b$ E+ C3 ~9 F8 B - #define STATIC_SHIFT 3/ M7 p, M/ n! n& G- O" u- N6 X8 C
- #define TCINTEN_SHIFT 20
8 i: z/ [4 R2 G, H7 n* q - #define ITCINTEN_SHIFT 217 O& e; m. i3 ^# a6 i. J- ?% L
- #define TCCHEN_SHIFT 22
7 d* } R4 ~; m. |" ^ - #define ITCCHEN_SHIFT 235 {# d; t9 G" s# W9 m) }+ `
8 C9 @! @6 l7 ]' |' e' K" |5 `8 B- static volatile int irqraised1 = 0;! C Q) o- v! ~9 }. R
- static volatile int irqraised2 = 0;; B" b2 \+ E5 v$ C; W+ J
- 5 u. T+ M( U6 U V4 C- X+ e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 u F8 p3 [# f4 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( n0 N4 Q$ t1 `. X7 Q' }' p) L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 l" U- I& c+ w- d! r3 F, ^
- ! J$ L* h. U) B: u6 {
- dma_addr_t dmaphyssrc1 = 0;! W$ X& y7 z( I8 _
- dma_addr_t dmaphyssrc2 = 0;. Z- k' P$ p0 H5 y
- dma_addr_t dmaphysdest1 = 0;
# C8 y2 c5 `4 i$ L$ W2 |5 `. L - dma_addr_t dmaphysdest2 = 0;# V0 I/ z" `4 \ J+ h
- # a1 h# d/ h% x- t+ i
- char *dmabufsrc1 = NULL;
% Y0 W; T& @. C% [ - char *dmabufsrc2 = NULL;( r# j2 I6 L6 C W' d" u+ y. _# j) x
- char *dmabufdest1 = NULL;8 c' g" l$ ~* j# _
- char *dmabufdest2 = NULL;
! g( z0 e, f) [' C1 t - - M5 X* W! c$ }- c4 w3 T
- static int acnt = 512;: ? u) g% W* l8 t
- static int bcnt = 8;
8 Q' q7 _5 W3 V- c* `4 k - static int ccnt = 8;
0 Q$ g1 M, N) e( ~
+ m; e& E) B+ k4 z' b- module_param(acnt, int, S_IRUGO);) d9 V2 m# ~) m* w: V/ ^/ Q
- module_param(bcnt, int, S_IRUGO);
- Z( x- _$ N) X7 z# F. p0 J - module_param(ccnt, int, S_IRUGO);
复制代码
2 a& N6 ~' r. N& T6 B8 F2 F8 \1 C0 v. G c, Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 A# B" [& f* r, H: ?6 A: m0 tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ Y5 w3 ]2 [ _! G$ p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 M! q6 a$ M/ s6 n/ L
. a* x9 Z! P9 o7 r3 Q* M
7 n& f$ \, h' \2 x: v' @4 m2 F/ K8 t0 {
|
|