|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 n/ _7 `* }* @4 ]4 h0 c- [code]EDMA sample test application
8 r- j* |" [2 M8 Q - /*
$ ~1 { {* a# t0 k0 A - * edma_test.c
- ~+ s, b$ I+ ?- ?: U - *8 t; F, j4 k! y4 B" P
- * brief EDMA3 Test Application
$ D( a# Q6 r% R+ {) K$ ? - *
: P: G# _( Y% w& Y - * This file contains EDMA3 Test code.
( j0 O {/ B B) c4 L" G - *
5 _3 Z. J! r( l6 v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: f: p! D, y" m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! O) r' Z- \1 X8 J9 N( m W& m - * TO CHANGE.
6 e: m$ x" @, P+ h0 | - *
8 j$ \0 I& K% l8 L& J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& \5 y7 V' _% D u9 v% b( P1 P - *
6 m! g, J( H3 D' `7 S3 p - * This program is free software; you can redistribute it and/or
( Q" J8 i: e/ d$ U6 h- V$ E+ H% L9 F( J - * modify it under the terms of the GNU General Public License as$ F$ F& Q) u! D, ?( o
- * published by the Free Software Foundation version 2.
( H. I/ u9 S; ~ - *
& B5 L8 A, m7 k8 { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, f% u3 r- \. E& J/ C, o z8 B2 X - * kind, whether express or implied; without even the implied warranty
5 J( B/ Z; w- u6 O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 |) D1 \( Y. S; k& f - * GNU General Public License for more details.2 C0 c( `& ^. d2 ]* T
- */
, @8 y6 h+ b2 [ a
$ u. ]1 E# t2 L1 H- #include <linux/module.h>
; {& x' T: j1 y* u - #include <linux/init.h>* Y1 q; b1 D- c' J! z" k
- #include <linux/errno.h>
9 p: \+ n* s7 b. R$ I - #include <linux/types.h>
5 F$ d: p$ `& @* }" s. J# ]/ m - #include <linux/interrupt.h>
- S( ^! r9 L% U - #include <asm/io.h>
( c5 i* p6 p; N; D# X% f - #include <linux/moduleparam.h>$ }+ R+ q! e6 A, y4 i( {' O$ B
- #include <linux/sysctl.h>) T4 u1 F$ M6 `# B- q: B& H0 E
- #include <linux/mm.h>! l# c9 O( P, Z9 b4 N m/ v- g
- #include <linux/dma-mapping.h>3 b& l8 J7 ]; U- w- h
- % y- y" W, K1 k+ h5 s
- #include <mach/memory.h>
' j4 B: b3 `3 [7 j2 O7 a! o1 y - #include <mach/hardware.h>
. A7 K( G$ I' u! M- o7 c" x - #include <mach/irqs.h>
' [8 n d8 W! h+ `* o - #include <asm/hardware/edma.h>
# P8 N( K' V( `+ |2 v$ J+ Z1 [6 R
, o1 B& B- _# |4 d$ i( H1 T- #undef EDMA3_DEBUG- J2 [! Z) j2 K+ I: q; C
- /*#define EDMA3_DEBUG*/; a3 {- U9 U, s8 v% m9 A" M7 d% M
- 0 J+ m. e; S2 z" a
- #ifdef EDMA3_DEBUG
, X% A, L5 C0 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 Z2 j* k% |. h( E/ D! m# } - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 g$ b5 B( M' G1 |( \2 d, Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! h3 w0 J1 u8 u e7 ~% |
- #else
h3 U. O3 g0 q/ P" \3 c: c3 H - #define DMA_PRINTK( x... )5 C: T; i2 P1 g' y
- #define DMA_FN_IN. l7 w$ C0 B9 c$ U
- #define DMA_FN_OUT7 l( D& @3 B' K8 _( O8 O0 t
- #endif
' ]; r* _, S( L: ] - ( q( ]& v2 w, m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, Z. s5 Q* t& h- W - #define STATIC_SHIFT 3
1 r6 a* W) _8 J2 A0 a9 D - #define TCINTEN_SHIFT 20
9 J+ z( p2 [7 n+ b% D - #define ITCINTEN_SHIFT 21
: a6 Y( A9 X9 s1 ~' e. o6 x) a - #define TCCHEN_SHIFT 22
; C' N( V7 e7 Z9 [ U - #define ITCCHEN_SHIFT 23
, v5 u3 w' y. {& n: j2 T( I
- z# }: Y- P7 D( Y( o; k3 l% O) I- static volatile int irqraised1 = 0;
0 l+ p/ T7 |& c - static volatile int irqraised2 = 0;
" v, o/ N" v7 P# l
" O. l1 [: f, J: R" S- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 v5 u! [* d6 M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. @! ^3 f; m: ?8 H/ W3 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 T3 p( J8 v; ^+ N& s9 I: M
; X1 c; e+ `8 G2 X3 G0 b- dma_addr_t dmaphyssrc1 = 0;
8 \1 c; }) w5 M( h/ k1 y - dma_addr_t dmaphyssrc2 = 0;" i: e5 Z6 k* F" j5 A0 b, ?1 G) N
- dma_addr_t dmaphysdest1 = 0;
4 R/ A, V( B1 F2 n [ - dma_addr_t dmaphysdest2 = 0;
7 H, ?7 I8 W* ]& t/ | - % n a/ q' ^+ O0 D: @; b
- char *dmabufsrc1 = NULL;6 _; b$ P5 d1 M6 s' v+ V1 z
- char *dmabufsrc2 = NULL;; w$ f( w) N# F; ?, R
- char *dmabufdest1 = NULL;
+ R' T$ _" L: m/ V: E3 y1 I' J+ D: A - char *dmabufdest2 = NULL;
( y! @4 y8 Y* D( M - # U9 \: k7 D* S1 L: ^8 ^& X
- static int acnt = 512;
. \5 [4 j& u- V& h( t3 R - static int bcnt = 8;
" w9 h2 i- b M+ \- s1 S - static int ccnt = 8;0 Q8 c& m1 g# U
! y* x1 Z) A5 f$ O; \- module_param(acnt, int, S_IRUGO);
4 _# s. r2 f* Y5 I - module_param(bcnt, int, S_IRUGO);1 j7 i, R7 }+ c
- module_param(ccnt, int, S_IRUGO);
复制代码 3 p8 X1 L$ p+ g/ x& P1 M8 U
& J& O9 F5 a$ ~: T' Q. m
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" A4 x2 C; }! _ k q$ w& _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 s' `/ c+ \8 t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 R9 i: }( [5 G
4 ]' l( w1 z6 E
$ H( p+ {$ h7 _; R* ^
|
|