|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & U8 W/ y; r/ U9 `/ o
- [code]EDMA sample test application; X4 j5 }$ s. s2 E, `) [% v# W! C
- /*
I% T+ E' C- ^* M: a, f! Z6 O - * edma_test.c _- b/ ?( V& D
- *& L8 a% s! r0 p" H2 Q& Z
- * brief EDMA3 Test Application
( F g8 M5 r0 p" @ ~5 y' ` - *5 B/ E6 Z: g+ A' v* T9 D# S
- * This file contains EDMA3 Test code.* k1 q4 |0 y$ X* n& U6 g* w$ x
- *3 [/ ]3 L2 e7 P7 i8 H0 n1 R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 Y8 Q" V2 C* s: f% Z4 r, ?5 N: e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; X0 H5 _; Y: z# n7 ~7 J - * TO CHANGE.
; ?# c H8 i. m% r" h - *
( ?8 o. V5 r+ B! l. C" ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! C3 Y! h0 r6 x C! t. N& c
- *
3 h- I+ x6 Q% `$ T3 o - * This program is free software; you can redistribute it and/or7 h9 f0 j' j" D# T) q) _
- * modify it under the terms of the GNU General Public License as# U' p/ r5 T1 J2 G
- * published by the Free Software Foundation version 2.
+ c* z1 p9 h( a) V2 m) } - *7 R9 Z5 Q$ J( e* a- t# u, \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 F! O- B1 h: h$ c& q% @
- * kind, whether express or implied; without even the implied warranty
+ A2 L( n7 T3 `: M0 V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& U7 }) n) ~. l* {6 | - * GNU General Public License for more details.
# `" L& M3 ^% S5 a& D, g t) D - */
0 y5 Z' \' ?& h$ p, X - / h+ ^2 T# R+ Z/ N2 h
- #include <linux/module.h>6 L8 U- j% V r$ u! u
- #include <linux/init.h>- \; W9 s# c. D0 m: R
- #include <linux/errno.h>
* t5 E$ Q4 K" m' \ - #include <linux/types.h>+ }7 A8 P. v; p) U; E! Q
- #include <linux/interrupt.h>! T# X M4 `, V1 M( o+ h
- #include <asm/io.h>! {3 o4 n/ ^) y1 L9 ?
- #include <linux/moduleparam.h>
& v. d! F. s/ E- s% M0 `/ p; v - #include <linux/sysctl.h>
! w; e% y; `( {. }2 D7 b/ t1 N( O - #include <linux/mm.h>5 F1 U, E2 I( E" G4 `. R
- #include <linux/dma-mapping.h>
" E% y; b; y4 E2 X
9 T% G8 l X- ~; {$ [# |- #include <mach/memory.h>
; L* R% z! z' v- f: ]* m$ Z - #include <mach/hardware.h>7 y8 M( g; l5 `& ]- }3 |
- #include <mach/irqs.h>3 @0 V& P' B# |
- #include <asm/hardware/edma.h>3 U" J% F0 i1 H8 {( q9 E
- / t. e8 `! v) Y5 o+ i
- #undef EDMA3_DEBUG, C b' V9 v# _" X1 m0 o
- /*#define EDMA3_DEBUG*/% Y8 F5 k) I7 A! F, `
- ; h+ K: B" D! Z- m, h; P
- #ifdef EDMA3_DEBUG
2 \5 t1 e) G# L+ P( o% J8 y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# ?; s; i% R$ E2 {, V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- C/ a9 ]/ {. o. R. ?- h# E0 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: h. c: |# t" A; ]+ _! H - #else
2 h) b& j; {# k8 `* j' x - #define DMA_PRINTK( x... )
1 I2 _2 h2 b% S$ Z: G( m - #define DMA_FN_IN% U( u9 O0 C* u. L
- #define DMA_FN_OUT9 [9 M5 V9 j% k( m7 O4 V
- #endif& ]2 V5 e7 z/ y
- : \! s' K# [) ~2 j# s$ ]6 E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 v4 K; `( e: Y' C: J7 H - #define STATIC_SHIFT 3/ e7 N) h) e/ O! N4 ?
- #define TCINTEN_SHIFT 20
. d: x* o! ^6 `, P( V, D f - #define ITCINTEN_SHIFT 21
' @- _2 | u3 S, ? - #define TCCHEN_SHIFT 22
- I6 E! Q$ m* l: w1 r, A% l - #define ITCCHEN_SHIFT 23( M1 ]1 i# q/ { b2 a+ |
- 2 G2 w7 N3 r. `
- static volatile int irqraised1 = 0;' T. z7 r+ g4 y* M% F5 _
- static volatile int irqraised2 = 0;+ L1 P; j! z3 s8 m
# O+ X+ C! x& a8 ~0 N5 y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% h- J m# f% S. H& g0 j4 | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 v' K6 q+ s9 m" g& }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 E; A, N, f& a3 m3 A
- ! w0 q! m) Z$ s! i0 ?
- dma_addr_t dmaphyssrc1 = 0;
, N/ [1 H1 @& W2 ~* Q - dma_addr_t dmaphyssrc2 = 0;( t0 h# `" x. v, }
- dma_addr_t dmaphysdest1 = 0;
# l) w. a& V* W' @ - dma_addr_t dmaphysdest2 = 0;4 f! e6 ~/ x& {
- % o2 y4 @0 L; E2 Y" V! @
- char *dmabufsrc1 = NULL;2 n0 n- L0 V% s! m
- char *dmabufsrc2 = NULL;/ E6 [. O) r, L$ c
- char *dmabufdest1 = NULL;2 g8 J" q, N* E1 }; ^
- char *dmabufdest2 = NULL;* c/ s) M2 i% e
6 P9 I* T- b4 B; R( }- static int acnt = 512;
* Y" O* @8 r/ r' f" s( { - static int bcnt = 8;/ ^" a* ^! Z% L; M# d
- static int ccnt = 8;
6 Q% j$ F9 s$ S* ]* ~; s* ? - 3 ?' i1 X2 K1 Y- f9 W6 X: l; j1 f
- module_param(acnt, int, S_IRUGO);% V$ f: H9 O$ E, j
- module_param(bcnt, int, S_IRUGO);; L( Z9 R; g, o3 g9 h8 O* o& v
- module_param(ccnt, int, S_IRUGO);
复制代码
; P: b) s" Z" `. w0 z# f' _7 i& f) {7 ]5 F; L0 d+ u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 m& U2 E9 r( D( h- l) D0 marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: [' Y- u% v7 m& M" h. D' j; ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 [8 i e9 }6 W. i% J( ^0 l1 b* X# J& v# ~3 I ?
|- z- _5 w2 Q
|
|