|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & w. Q3 A+ Y* \# V: j0 C
- [code]EDMA sample test application
K4 ]+ Y9 b' X3 h2 q+ u - /*
. M8 Y( M9 k. e8 y3 B8 R3 F/ H - * edma_test.c2 F( r9 q& }, }. N# C- d* c
- *3 ]$ t% h! p$ ~, T/ o
- * brief EDMA3 Test Application
' D* G! E; ^, L - *
- V. D, d5 o! J( s) J* o1 o - * This file contains EDMA3 Test code.3 ?( r. g9 `- n0 E! F
- *
2 i J" Z0 b/ O, r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) v, w* q9 I7 M6 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 y3 D O _; n3 y3 ` - * TO CHANGE.6 V; E2 G+ w* p+ q; R" t
- *# T% A& y7 C/ m; {: i9 Z4 A# |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; q) s& S2 I A8 w - *8 U7 s" G. {& K1 p! u
- * This program is free software; you can redistribute it and/or
: T+ w, R5 W8 Z8 M: | - * modify it under the terms of the GNU General Public License as
. h( D6 p6 {3 o7 c( W! {, b - * published by the Free Software Foundation version 2.
1 _- C- ?* E* z/ M - *+ C s+ Y9 I m4 r. Z6 a: Q) D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ w; K9 o3 W- I- |( A! d - * kind, whether express or implied; without even the implied warranty# w3 d# P' ]7 S8 |0 ]. ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the i/ d! _5 h5 ^! i8 i# L
- * GNU General Public License for more details.
" a3 M# f: l) U: o: Q4 w( B* `( o - *// ?' x' |6 o* U6 V W
- - S6 A. F B* R9 m
- #include <linux/module.h>. M% w4 C- U( V, h* c( I5 C
- #include <linux/init.h>$ F3 z* L! @9 E% m% `" T1 m& j
- #include <linux/errno.h>3 ]* \3 y2 \. m( C
- #include <linux/types.h># q4 C5 F# ]8 |0 N L
- #include <linux/interrupt.h>
) ~$ c% w' m I; t& c) b - #include <asm/io.h>
; ~7 L5 ~8 C- \* m5 @ - #include <linux/moduleparam.h>( e- {' I+ U# k' u5 H& {! c
- #include <linux/sysctl.h>
- d7 J6 s& D1 x' F. F6 s$ R - #include <linux/mm.h>
7 ~4 W; O& ^ i; V, ^ - #include <linux/dma-mapping.h>
+ Y* _7 u: j; n - - q3 n, D/ S8 `
- #include <mach/memory.h>
# ~! X7 p {% J& \ - #include <mach/hardware.h>. J5 x3 h7 f- S7 I$ s" X( A
- #include <mach/irqs.h>
+ l7 B4 N4 p) R$ ^# _. w - #include <asm/hardware/edma.h>
1 z. V! W5 V* J! ` - ! u0 {! t& I1 q- p9 h1 g
- #undef EDMA3_DEBUG
3 w. ~4 D x+ P4 N6 B3 Z! L* b - /*#define EDMA3_DEBUG*/" S/ N, [4 `$ g* `$ B7 }3 ?; H
8 M7 I. B0 K' f7 B; c5 R1 E) m, c- #ifdef EDMA3_DEBUG2 ~+ S! C+ b0 N8 z& {! ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 O/ }5 x. R* @; D0 g0 ^6 t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ ]8 P1 b7 [3 {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 g0 z, M& g! P/ O9 x
- #else
' n$ B- }" b5 G" j; A! C - #define DMA_PRINTK( x... )
' }* s4 `9 a1 N) `/ R4 C6 ^ - #define DMA_FN_IN
; x- X% t4 N+ X6 j$ Y( t - #define DMA_FN_OUT
( {4 D- b* T% K5 o$ N - #endif2 m) V8 i( T2 O7 P4 s9 n; h0 n
" Z ~2 P' e1 L+ ~% L- #define MAX_DMA_TRANSFER_IN_BYTES (32768): }7 b' M2 S: Q) B) A
- #define STATIC_SHIFT 3
$ s! H( A6 q, [" K2 x4 J - #define TCINTEN_SHIFT 20
' B4 c x: v# m0 E- O - #define ITCINTEN_SHIFT 21: s- z8 S+ _1 h4 E1 A& A+ x
- #define TCCHEN_SHIFT 22
& z) h7 x: t# S( `7 i! @' } - #define ITCCHEN_SHIFT 23
* d) J8 h% t3 v: u! C7 W' {3 K
# \# _& l. w! [' m% V: q, Q" U- static volatile int irqraised1 = 0;& J w, \) q8 }: x f
- static volatile int irqraised2 = 0;
# L- A# N$ R2 A- F* T - ; S) Z$ m, P9 q. K0 B J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 J1 N$ _* t& X/ K! e: l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 e" l& r! r7 s9 i$ h$ u. H6 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) v1 N* M2 I% Q L' J8 @
) j3 h+ A& t) p1 ~* i# m7 t- dma_addr_t dmaphyssrc1 = 0;
$ p: ]& [/ W& ?6 R - dma_addr_t dmaphyssrc2 = 0;- ^* M+ t( m6 z; w
- dma_addr_t dmaphysdest1 = 0;* i8 n5 H3 @0 G- G/ B8 c
- dma_addr_t dmaphysdest2 = 0;1 x& L, }6 s0 m! J4 T- q
- " l) M( B8 k) @$ t
- char *dmabufsrc1 = NULL;# h6 y9 r, @6 n- ]
- char *dmabufsrc2 = NULL;* d( h: j" r c8 _+ p
- char *dmabufdest1 = NULL;( |( S( D. D# x: q9 y
- char *dmabufdest2 = NULL;
/ r' _4 }! p+ |) E' B
! ]0 s# E# z( N, j9 ?8 T' ~- static int acnt = 512;% ]; n2 n* }7 A% s$ ]5 J
- static int bcnt = 8;% V, J( z+ y0 s1 ]) k# {- l$ \2 F
- static int ccnt = 8;4 _9 L2 C9 e; M7 `/ z; x7 K
- % R2 R3 J t( k @& I( H+ u
- module_param(acnt, int, S_IRUGO);
) u: p% \* y9 {! i; ]- L - module_param(bcnt, int, S_IRUGO);
9 v, B% ^* c) Y I: W - module_param(ccnt, int, S_IRUGO);
复制代码
! Y# o- m. d( s& Z N [* H1 {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 Q @& m& `* W, {1 z& _
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ a$ F" u6 u* v) y: M" ?3 V. x" e- r* F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% }/ Q- ?- ]' h. \3 ]3 J0 Q4 R/ y. [: S" E# E" W; X' C
: f( m8 @5 J- G
|
|