|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) U" q) `7 n6 e4 L& p. P; H
- [code]EDMA sample test application
& y8 e3 h q" C' ^* u8 W) Z3 j - /*6 w7 f- u: ?8 Q
- * edma_test.c
/ H7 r; {* R8 y- I - *
2 p7 T' ]. K$ _ Y. E) R! g - * brief EDMA3 Test Application
; x' y* Y8 R/ a, E% E8 h$ p1 T - *
% s1 m- V( }9 e+ e" {& n - * This file contains EDMA3 Test code.
; h+ i) A/ g0 B+ f b - *- K* \# ~$ A. ~) t3 |- \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 z$ o9 Z# g4 {7 w0 \8 l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: l5 k6 S8 {" s
- * TO CHANGE. o0 O' Y8 Z( T
- *
) _0 i$ q9 i; |! F/ w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 P: R. f* i* S% { - *
/ G, U X8 ?/ v6 j* k - * This program is free software; you can redistribute it and/or8 _( a l8 y/ k1 @* ^" h; |/ }
- * modify it under the terms of the GNU General Public License as7 f- D& C4 }7 ^2 y
- * published by the Free Software Foundation version 2.
' f! d- _; i) o) s4 Q - *( h1 C6 j2 H% h6 p! C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* P s' |2 G9 F1 r9 w
- * kind, whether express or implied; without even the implied warranty. I* G" j0 J- T1 V
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- ]4 H9 h% H8 G4 ]9 `
- * GNU General Public License for more details.
! k0 x5 g2 f5 ~& W - */
0 S2 [+ v/ }, A
/ V6 q4 k& B" Y g- #include <linux/module.h>
6 D/ O, h$ x, h( T( v" j e - #include <linux/init.h>% U" t0 ]- K, e9 m9 i) }
- #include <linux/errno.h>
& l* s8 e6 p" s; Y/ ?# o - #include <linux/types.h>
2 y* e' }: R6 R8 N; D' Q7 P - #include <linux/interrupt.h>! r0 x# B$ Y2 Y1 Q/ d% v; b& Y% f* P
- #include <asm/io.h>% x8 n- G# ?1 Q9 H5 p: U4 E
- #include <linux/moduleparam.h>
5 B& T8 I- Y/ ~0 w( g! e# C& f - #include <linux/sysctl.h>
, S3 X6 I9 r, B9 I$ i3 H. l( j/ d& { - #include <linux/mm.h>5 `. ?9 B, [: @. Q; w" Q/ V4 _5 l
- #include <linux/dma-mapping.h>
! Q% s& B/ m+ U; i: R) L
4 M8 D7 Q0 z* k- A! h3 I- #include <mach/memory.h>* V$ m7 x7 g2 ]8 N
- #include <mach/hardware.h>+ H+ j# X% N- _' s+ g( q0 M$ M
- #include <mach/irqs.h>* Q8 {9 ?& N7 r: a q- I
- #include <asm/hardware/edma.h>. }: A8 N: V+ P' m6 Q& B
- # |/ ?- T3 r2 B9 K* ~, E8 o
- #undef EDMA3_DEBUG
" c9 o N7 P; \" m s) ~1 L - /*#define EDMA3_DEBUG*/
! v( k2 ~+ `0 {+ P: f2 _4 M
5 A' q1 C! d+ t, f5 n1 q- #ifdef EDMA3_DEBUG
5 o, U. j- {* U' G9 k% v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ l2 Y( I& s1 F$ V5 f1 k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" t3 V. L2 k1 L4 s# b$ i) P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 x: C7 M7 O) }
- #else2 P& R$ w' f. t' i
- #define DMA_PRINTK( x... )
# d' s' B/ O5 Z - #define DMA_FN_IN
% Y; C2 T( O7 z: L2 N - #define DMA_FN_OUT8 C6 L2 ]: u8 \: s3 O, [) n6 i
- #endif6 [3 u" F5 Q' }6 W$ |7 f- F8 }
- ; r. | v7 E" s0 s; Y6 L* Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- a b# l/ f; |5 {4 F - #define STATIC_SHIFT 32 J5 w: m3 a- x" f. I! I
- #define TCINTEN_SHIFT 20
7 }# {% ?( s" Z& |4 _6 O) |$ A - #define ITCINTEN_SHIFT 21! x# r3 E# P9 ?# u" z
- #define TCCHEN_SHIFT 22& q6 V8 |* A4 s* O' d. k
- #define ITCCHEN_SHIFT 23" V7 p+ ?$ s9 t0 S3 U0 n. V) v) S; e
- 1 v+ Y3 _) V# r" i+ g" A$ k1 }$ E
- static volatile int irqraised1 = 0;
" O6 \% O, S, x) U6 J( o - static volatile int irqraised2 = 0;
8 F2 y% G1 W& `3 J8 }% m2 l* i
. E# K) H5 m/ x' X% J `" T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 {8 G+ h1 B& E) j n% ?( B4 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 a3 J6 g+ _* ^* B% w$ b7 c* k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, ~0 k& z& v. [* s5 _
3 t! V: F- K- [$ g/ ? y ]- dma_addr_t dmaphyssrc1 = 0; U1 H0 i3 g6 m
- dma_addr_t dmaphyssrc2 = 0;
$ O. K# [5 X8 `. ~! ?" j - dma_addr_t dmaphysdest1 = 0;4 Z, j7 W& \, Q' q* ], F$ \3 C$ i
- dma_addr_t dmaphysdest2 = 0;9 v" o- A( ?1 C- e
- ! }' |. X0 [6 F( p. C) c
- char *dmabufsrc1 = NULL;
3 _, w( q+ j! w. x8 i: g' Z - char *dmabufsrc2 = NULL;
& n g* e& ?6 m - char *dmabufdest1 = NULL;: f) Z9 _7 g' b S; e5 i% |
- char *dmabufdest2 = NULL;
- P2 z; e. Q. b8 q. E) ~: t - & R) }- z3 J& Z* T; K, m$ Q
- static int acnt = 512;
- c6 h1 j$ a, s; Q - static int bcnt = 8;
9 ?& O' V- d: Z, O; l6 M0 n - static int ccnt = 8;
2 ]! n$ B0 D. i# u% D" U/ { - ' m1 ]7 [* G) G9 q' }/ L
- module_param(acnt, int, S_IRUGO);# n6 o5 o% u; X% W! |
- module_param(bcnt, int, S_IRUGO);( u/ h1 `# ^9 w" a
- module_param(ccnt, int, S_IRUGO);
复制代码 6 Z/ P3 p# c6 d" R; ]
; k% Y" v3 y! _: o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 @) n1 \* f+ d$ e6 C0 o
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ e. f0 }* v( K3 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 s1 r/ B+ W7 v2 A1 y( w4 n9 w
. e9 p4 D. @! Y1 j/ H6 J* K" P6 h3 F1 y8 j* [
|
|