|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : M! H- l0 F y6 b& W2 o$ o
- [code]EDMA sample test application5 O" z1 r* y( J9 S( h( E B, g
- /*- W1 p( A, M0 ~1 [
- * edma_test.c8 y" |0 p) N, G
- *8 O/ c; h1 L* J) c3 `
- * brief EDMA3 Test Application; k0 }4 S- u1 G2 S4 _
- *
, t% `" k' }3 E/ L - * This file contains EDMA3 Test code." U% n* @7 [: L+ S6 f8 t
- *
% F& r5 s$ m- c0 p$ U7 @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. e7 n/ h2 d" v) C - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 C! `0 o( E1 o+ n Q) S
- * TO CHANGE.
+ C- y: H( M' p2 X1 Q+ Q' U - *
) G' I7 K: a9 D+ {' b( o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 e: q- [$ M4 p' S5 c4 s- j
- *" L/ J. B4 T8 o9 b! R
- * This program is free software; you can redistribute it and/or
* K- @" g5 l, t - * modify it under the terms of the GNU General Public License as. w, f* Z6 D% ?; x; h0 n6 P
- * published by the Free Software Foundation version 2.
$ \& D& ~# _# K( \ - *$ R; h7 r) y; ~+ h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& j0 B: S" U3 U9 B& ^
- * kind, whether express or implied; without even the implied warranty
6 M4 i; ~: g8 G- D$ I2 C2 J- J - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' I# o. g5 c& p# A! u - * GNU General Public License for more details.( i, \* a# Q" Y6 c: ^2 J
- */# [+ C1 w( d" a# ?7 w
8 c! Q N) [6 U; Q6 B; U- #include <linux/module.h>
5 r, {: z: F$ l, }( r( d - #include <linux/init.h>
' n- d( e# x% h, T3 M- N" ]& W - #include <linux/errno.h>
8 b: A! ~5 G m& w# `9 _& ~7 P - #include <linux/types.h>
2 P9 `# i; ^! g5 M0 ]3 b - #include <linux/interrupt.h>. g6 Z) m" Y# b/ e
- #include <asm/io.h>
5 A) P* d! c B+ S. R0 ]0 |4 d - #include <linux/moduleparam.h>
" r% T7 [8 V q: I1 m9 U - #include <linux/sysctl.h>- w4 N* E- K9 { g0 y
- #include <linux/mm.h>
& M6 E Y6 [. X: [. n! ]7 r - #include <linux/dma-mapping.h>: L* v; P1 f0 W3 u4 d# V
- 3 S" E# o. d/ t, \
- #include <mach/memory.h>8 b+ ^, u$ Z! G
- #include <mach/hardware.h>$ K' q; g! `% f J3 [+ Z" Z5 `
- #include <mach/irqs.h>: r9 {, Q( `5 F9 T# x
- #include <asm/hardware/edma.h>
0 h, Z/ {0 u3 Q& i6 L0 G
4 Z; l9 B' u5 j$ j6 r, ^- #undef EDMA3_DEBUG
# c! E9 b; {; y4 r$ a - /*#define EDMA3_DEBUG*/+ `4 P/ _- y% l, x& ^# F, @; E
- , Z' W0 f+ ?3 v5 L
- #ifdef EDMA3_DEBUG
7 l' Z; L- V( K6 a4 e" z; Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) Z e( d' ]! W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- a" Q: E" V4 j H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! T# z# q, Q4 O- q1 c
- #else7 r5 e) x+ F$ V7 q8 F1 J+ j
- #define DMA_PRINTK( x... )( h7 a6 K2 `" ^! ?+ C4 V/ ^
- #define DMA_FN_IN
* r) _+ Z: H0 U1 i" a5 a. o7 B - #define DMA_FN_OUT
# f% D- s9 D: S, q, f9 c - #endif+ n1 l" z" T( d k G' m( U8 L- k- O
- / q4 c* x3 K9 \- B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- G: j4 o, u7 R
- #define STATIC_SHIFT 3% X. [" r x i- B4 U! `
- #define TCINTEN_SHIFT 202 b9 {$ ?3 \5 d. v9 E- D
- #define ITCINTEN_SHIFT 21, j# L! e5 k7 r5 z
- #define TCCHEN_SHIFT 22
8 ^& m D0 g) L& _- j+ n8 ` - #define ITCCHEN_SHIFT 23
2 v5 F5 i! W. `4 W4 g
# B" S+ L3 q+ ], B7 `3 W8 m- static volatile int irqraised1 = 0;# T2 v! O6 l% a% b& j! y
- static volatile int irqraised2 = 0;3 N5 q5 a: M4 t6 E6 t4 K
: S. u/ w5 p$ B7 g0 I! ~: s- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% W6 T4 } {, V' u a; |* G F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ S% X B' H" |% k2 `# k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' x0 K y# P" L2 M+ Z3 E
# l+ P/ U1 z( C0 u4 S) G- dma_addr_t dmaphyssrc1 = 0;9 }7 _5 N; J$ P F% I. ]6 Q- T
- dma_addr_t dmaphyssrc2 = 0;
* \( ]% j7 J% E: Y/ h' h - dma_addr_t dmaphysdest1 = 0;# W; N/ ]7 W* ?% t6 y3 A6 X
- dma_addr_t dmaphysdest2 = 0;! c2 e2 g* c3 A3 \# {
+ U1 G0 B9 O+ D* s+ z" @- char *dmabufsrc1 = NULL;
P k3 D) g; f- i - char *dmabufsrc2 = NULL;( y: @8 R# k* j5 J$ ~4 a* U# W
- char *dmabufdest1 = NULL;
* ?7 L5 m/ I, N- v6 {& b - char *dmabufdest2 = NULL;
6 I8 |4 b" ~4 z - * I" Z0 G$ s" c
- static int acnt = 512;# [' Q0 Z9 v7 P+ W
- static int bcnt = 8;! P& c0 O, m8 z4 B' _1 i
- static int ccnt = 8;
4 \3 h1 H7 ^9 _8 q$ r0 x0 [; \
3 `6 U4 G3 Z; Z$ v' k- module_param(acnt, int, S_IRUGO);
8 W* ?1 s C F) H- f/ { - module_param(bcnt, int, S_IRUGO);
$ }* I7 l. {5 N1 s4 i - module_param(ccnt, int, S_IRUGO);
复制代码 * K; G/ w5 l3 ~- Z0 O. Q& B7 s
5 }' r0 }7 A& e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ X2 o( m- `5 E4 r3 N0 J m( Y, oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 M) w6 T7 m' q- T. {4 i& Y2 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& W0 j' J8 h" \" ^
4 g s0 e8 s" q+ P
9 e, M! f' ?+ C7 L8 f- W' \, T |
|