|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- M z4 [5 M' o; ?0 y( o/ W9 K: M" |5 q- [code]EDMA sample test application; G- h6 h! e. g& C
- /*
" F/ u( ]3 S$ N8 k& P- U5 C% s v1 Z - * edma_test.c
; Y, ^. v5 f1 m" g \* D - *
, C& A6 T& S: B* }0 v6 @ - * brief EDMA3 Test Application
9 g; U. T8 p! C! U/ G+ q - *2 Z8 K+ ~6 B; j) A1 G% i& S
- * This file contains EDMA3 Test code.
3 I/ C! o3 \2 d8 w4 i i* B - *
; U5 @1 t( E! \3 ^ R/ t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 F4 L- ~& k- q7 p# G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ Z' |' y( u( b) ~ D - * TO CHANGE.
! `: L: A4 o. E0 d: M4 x - *9 q( g Z. g9 A8 n# U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' K4 U9 I- _) \; b' M6 J" m
- *: e' W+ X$ Q3 `: C( ]
- * This program is free software; you can redistribute it and/or
* h& ]2 ?* Y) O& X+ Z9 ~" u$ p - * modify it under the terms of the GNU General Public License as
+ H% T- `, x+ P0 f Z9 F( t - * published by the Free Software Foundation version 2.6 E5 c z( Y4 \0 c K7 _6 u6 C# m1 A
- *6 O/ x2 o1 t0 u/ M& d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ f& a- O: w0 m. V4 _4 V
- * kind, whether express or implied; without even the implied warranty0 G& Y1 m6 L0 ?( x
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! j0 O4 R) B G4 |
- * GNU General Public License for more details.
) a' |$ L( {; P% ?5 l6 }% q - */2 T3 D& L/ d: h& F; A" Y
- $ x: |4 M; G( G! ^1 R
- #include <linux/module.h>
^& F' `, r) C8 a: ] - #include <linux/init.h>
) u+ P! Q1 [+ r - #include <linux/errno.h>
0 U7 h. C( E7 ?8 h) ]/ k/ `/ \ - #include <linux/types.h>
7 h+ n# ]4 t5 q+ H$ }8 e - #include <linux/interrupt.h>% F) e, C+ K0 A; w' |
- #include <asm/io.h>3 u* A1 t: }: T' z+ {4 H' Z1 M* t
- #include <linux/moduleparam.h>
# `- c4 g2 t$ `. j4 }7 ?! K, I - #include <linux/sysctl.h>
- O) y e7 D5 w/ O- s - #include <linux/mm.h>
; }5 t; w6 E, e- G+ ?2 d - #include <linux/dma-mapping.h>
8 h! h( {, M7 b: K: q( M2 x" U - 9 K& s6 V$ a7 ^ o3 p
- #include <mach/memory.h>
; z" S) s" b/ z% u) j - #include <mach/hardware.h>& |& ~# b7 m+ `' B4 I9 v
- #include <mach/irqs.h>
' y1 ? Z' d0 @: e2 S - #include <asm/hardware/edma.h>8 m& i, J! E- q1 m8 ^! W3 m" U
" \* r8 c+ r$ j2 u. h) @- #undef EDMA3_DEBUG
0 J/ L5 j& N" ^! _; l# v8 e* {/ R - /*#define EDMA3_DEBUG*// |3 w O; F& o1 a: m/ O. c) ?
- 4 q& x6 S$ i) T$ |
- #ifdef EDMA3_DEBUG: y* {! n0 M; I$ @! B! `4 Y( z8 F) _. }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ u! r" ^, \9 t- ]- F% K q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ D% J7 `1 u) f$ N7 l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 K+ [: L2 p) ~
- #else' i' W+ H6 F* v _# X
- #define DMA_PRINTK( x... )
6 T* R) _" C: U6 J1 c6 s- Z - #define DMA_FN_IN
- G8 A# u, G/ R6 m9 X - #define DMA_FN_OUT
+ j3 ~* {# s1 [% g' ^ - #endif% ?0 ~% j4 `3 B
- 2 v7 P0 `, u4 P6 i& M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ o8 A x) m8 y8 Z - #define STATIC_SHIFT 31 B" U( W N6 z, n' K1 J! l
- #define TCINTEN_SHIFT 20
9 ?( A2 I/ l3 C N1 U - #define ITCINTEN_SHIFT 21
" y+ e+ L+ m! Z - #define TCCHEN_SHIFT 22
& T' f+ z7 E/ e; } - #define ITCCHEN_SHIFT 23# K) {7 M# z) n
- Q/ v x; J# D* i( h' t m
- static volatile int irqraised1 = 0;* i: s S2 c/ D( z3 P* d
- static volatile int irqraised2 = 0;
7 Y. d2 Z8 p( M" T( q. h
& j" {# V1 ~0 i- E1 a: o$ [$ ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* v0 {5 I8 {, @+ x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! W6 X! c. V7 r( A& A4 i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' Y9 r! C" q& d9 u5 @& U - ; G( ]. S1 H! @* G/ i# S( `' t
- dma_addr_t dmaphyssrc1 = 0;
7 }7 t. W' h% x2 x - dma_addr_t dmaphyssrc2 = 0;
* |, {. }% Z3 P! F - dma_addr_t dmaphysdest1 = 0;7 i% l% U3 A7 d; C- W& e
- dma_addr_t dmaphysdest2 = 0;; X7 S% O- H9 v }! l5 V
- 5 y o1 i8 M/ W; ?6 L+ F& Z9 u
- char *dmabufsrc1 = NULL;
: ~7 r5 h$ F& m' Z1 a; R - char *dmabufsrc2 = NULL;2 y. b! t R4 p3 L3 P0 V& H5 K3 i' r
- char *dmabufdest1 = NULL;+ |- w7 {" E3 ~' `5 Y! Z1 x2 a
- char *dmabufdest2 = NULL;
# J" K! `7 _/ A9 R9 a. z; j+ b
9 C! V3 _* y* i' v; {+ o \3 E4 ?1 K- static int acnt = 512;$ ^& s9 l+ v, f2 F. M7 V: n1 ~
- static int bcnt = 8;
6 P) d4 n8 Z( T8 I - static int ccnt = 8;
5 r9 K F; H" r, ]- S$ _- F
# C, l. J( k8 Z) ~- module_param(acnt, int, S_IRUGO);
/ n3 ]7 Y2 }9 k! B - module_param(bcnt, int, S_IRUGO);
) h" n" ] W# t: z e - module_param(ccnt, int, S_IRUGO);
复制代码
: X3 K4 t7 R( d7 E1 H: }4 ]4 T
9 Y' d9 @' }9 a+ N% a2 d. a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, p3 o6 t& `" R$ a, ]0 P* U4 i( farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* X6 |% f4 y. L2 A5 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ Z; y+ y9 h; v3 W5 R2 y( V
" B$ K8 f, g: V3 N& q- B0 ^ z
# c& C. p0 r! ]! f, { |
|