|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ @( A8 C" ~$ E: c* a1 t( ]- [code]EDMA sample test application# K7 y- y& |7 P8 U5 T
- /*- X1 C! R; ~9 e5 ~: J0 F9 L' Y
- * edma_test.c+ K/ s4 h D1 A8 _
- *
) A! r. t+ p, F# q1 C' t - * brief EDMA3 Test Application. O* j; j1 a [& r6 i/ [
- *. X6 }/ l N% x9 i, q4 k
- * This file contains EDMA3 Test code.6 b( H9 |8 _$ | I3 @9 g" a1 ~6 {+ Z
- * I- O' j9 W0 y. c2 C, O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 R) R: q& z I( Y- k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 m% g, Y6 q1 F/ W% n4 H& ?
- * TO CHANGE.5 T6 O! A+ l5 V6 l
- *0 D. V' ]) K: b7 h4 |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# c% u8 L0 ?4 B! {4 C
- *
, J5 O) R4 D: z2 P1 T - * This program is free software; you can redistribute it and/or
! D+ u( A) [- U- U! v7 M4 e$ a+ ]9 p - * modify it under the terms of the GNU General Public License as
3 y' D& J: m5 ]; ~' L. B - * published by the Free Software Foundation version 2.
# |' r! X8 l R1 _( r( b8 z" `" m - *( K; L: ~) R( c* p9 q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 s5 K' L+ w. u2 [7 h - * kind, whether express or implied; without even the implied warranty$ y; b7 z6 g! J+ b$ a) T7 B: `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ q7 o/ j1 o$ a! {6 R2 r* o - * GNU General Public License for more details.- x! U8 ?# u3 U, E1 N2 ~
- */! H0 E8 ]! b6 p$ [- P$ O
- : ]; w1 X" r' F _# Z
- #include <linux/module.h>
* ]/ @0 l- S8 I. g9 z0 n: N - #include <linux/init.h>
- S1 Y6 z/ a2 f( g" ^: A0 C! F. N+ } - #include <linux/errno.h> h( T1 v3 \, I& Z% E
- #include <linux/types.h>0 Q& {/ ^/ h( v8 W8 _+ ]
- #include <linux/interrupt.h>
# }4 X$ P* `5 H2 D- Y# o1 O - #include <asm/io.h>
- C1 T& U" w W1 }& O - #include <linux/moduleparam.h>& u# S' V( a1 g6 r" x1 K4 E
- #include <linux/sysctl.h>* n- ]9 P0 b l' X2 w
- #include <linux/mm.h>8 J6 f( w; u, D2 o9 A
- #include <linux/dma-mapping.h>
( h2 q5 E, {* u. v& ?4 ^/ ^
: ^4 H, S7 Y# a0 g" z- #include <mach/memory.h>
0 Q8 H! Q6 t6 v+ l% B3 s - #include <mach/hardware.h>
5 N7 y m" ^/ h2 N - #include <mach/irqs.h>( g! R5 V8 {( K+ L' T. O4 z, D
- #include <asm/hardware/edma.h>8 S3 n; C" d0 S- q; f
( M0 J8 u$ B) J9 Q l, u! h S- #undef EDMA3_DEBUG
3 j+ K& e( X) P - /*#define EDMA3_DEBUG*/
2 J# F$ k1 d- c, f& |
4 c; p2 n+ ]" n# {- #ifdef EDMA3_DEBUG/ t/ J- X3 J; ?% Q6 a* H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 d) m# M& U! L- _" Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' A1 v9 h2 d9 W. K: v4 D7 J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 n8 M8 w& A6 b
- #else
5 F3 O, F% C4 ^% u4 u. y$ p - #define DMA_PRINTK( x... )
# J. X$ s! O: a: p7 F - #define DMA_FN_IN
3 B: |( s" P5 i8 j* F - #define DMA_FN_OUT
" k1 o) m% o) `% i8 Q5 x- c - #endif
) z$ u5 \- s& [/ b
! b# i8 j1 N' |1 K, A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 [6 b4 m/ t* ~8 f5 P5 p1 S
- #define STATIC_SHIFT 3
2 k1 f1 D1 ?6 ] - #define TCINTEN_SHIFT 20
8 m. ^3 Z$ [ J" V4 @* N1 T - #define ITCINTEN_SHIFT 21
" M% t3 r. R8 r* q6 y - #define TCCHEN_SHIFT 22
5 n6 N; E% t7 A+ M) G - #define ITCCHEN_SHIFT 23/ a9 J7 L$ y) {; R+ N
0 q) q/ S( y+ @3 j+ \- static volatile int irqraised1 = 0;- G% K0 G5 F& X# r# p: Q- T
- static volatile int irqraised2 = 0;
, L5 Z M: `: x# u
7 _! ~, b! v6 w8 a, A- U$ ^4 f0 X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 @% W0 h4 R8 k% F* c
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 f- t9 E: X3 j4 l5 j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: ^+ \5 X% K; q& A) a' e& c% a& Q
# Q0 U+ [ \; N+ m/ G, s$ r- dma_addr_t dmaphyssrc1 = 0;1 u( A3 l; M, @' p
- dma_addr_t dmaphyssrc2 = 0;
2 ^8 @( G4 H. r/ L/ d: S - dma_addr_t dmaphysdest1 = 0;" i1 l+ {! B: Z0 o: W
- dma_addr_t dmaphysdest2 = 0;
6 [8 u! V: r$ ~! B' N - ; ^' ]; c6 H. R) ~% j
- char *dmabufsrc1 = NULL;0 [ M: l) z: P, m
- char *dmabufsrc2 = NULL;
; X( Q! |8 F5 e/ {, Q/ P - char *dmabufdest1 = NULL;; u7 ?* T7 s- e: N
- char *dmabufdest2 = NULL;3 @: R/ a; ~3 ^) G, O
- 5 f4 n9 S7 J% j! R- x) p# Y
- static int acnt = 512;' z- N% `, e: m" w. e
- static int bcnt = 8;4 f8 ~ F9 G8 |
- static int ccnt = 8;3 w+ ?. U% j$ B1 \
- & e) E* @& o! G; x- T% o! P9 _2 M5 f
- module_param(acnt, int, S_IRUGO);, |1 ]2 v4 g$ S9 ]9 X# S3 ]
- module_param(bcnt, int, S_IRUGO);+ y6 n& s# {: M/ n; b# u
- module_param(ccnt, int, S_IRUGO);
复制代码
2 c2 m U; C% h. |, N8 F: |( U& Y1 M0 [$ V2 M+ \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ |/ ~$ C$ {7 J" m. {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 L3 i. i4 r. f k; q$ ?) j- @ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 k. Q: n! @/ P3 W
' X) G3 M: w+ ?/ W4 c' a4 T
- k4 E* d( e" ` |
|