|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% N* v: I( O/ l0 z" H/ A- [code]EDMA sample test application3 ^0 B: y9 B2 E( P; w* G
- /*3 P6 d7 d. _& s
- * edma_test.c! P7 o# F4 g7 I+ Z0 \
- *
) h5 ^% v3 i7 b! z8 ]) O - * brief EDMA3 Test Application
8 h7 H8 Z5 X& K+ |9 q% Y - *
3 t1 z, F* `) O; ?! ^; p - * This file contains EDMA3 Test code.
! C0 @ E8 t! j) N3 _ - ** B, ]9 ]- V& L, A1 s
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" C, M% s" |5 x4 e" I, D/ z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. c/ l! w9 R# E/ _) j7 @6 \: y' V - * TO CHANGE.5 ~- b, j* ~* B8 o6 E
- *
1 x+ l2 [( t- j/ ^9 ?: E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' `. Z Z/ `" s! R2 T" E
- * j: {# g. e% k5 K; R2 \
- * This program is free software; you can redistribute it and/or1 x2 F5 p; }8 ?! ^! ^
- * modify it under the terms of the GNU General Public License as& L$ I# V& A% @7 r5 F& v
- * published by the Free Software Foundation version 2.5 s6 E0 M% O3 G- Y2 d% y- c; [0 Z
- *
1 ^' K" H8 `4 @3 s - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( @3 `. n$ x ?% I* A' ~( H1 q - * kind, whether express or implied; without even the implied warranty
) m# w+ @ n: g5 e" Y3 E4 P - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% h5 M# O7 W: Y2 A9 p1 `4 }9 G
- * GNU General Public License for more details.9 n7 t+ A3 b9 W
- */
! x7 y M9 n% v - 3 \7 i; _$ h; P$ q" _+ {
- #include <linux/module.h>
: U: H; o @* Y+ N5 B | - #include <linux/init.h>; O4 Z+ ?0 l5 E' Y7 u
- #include <linux/errno.h>
4 _7 B- ]8 C/ g% R! J6 \ - #include <linux/types.h>( b, j: a% Y, `) j$ z
- #include <linux/interrupt.h>: E! `4 b0 ^" j. n
- #include <asm/io.h>7 ]0 a0 i' J7 l" K0 ~( d
- #include <linux/moduleparam.h>
6 g, m( _* A* I* v - #include <linux/sysctl.h>
# F; c0 b0 k( z - #include <linux/mm.h>
F$ v+ W$ K% s r) j- `# c3 ] - #include <linux/dma-mapping.h>
+ D; _! [. Q6 `# a - ! J; y+ h6 p4 Z
- #include <mach/memory.h>; G( h* u! p5 g' O3 G! R
- #include <mach/hardware.h>
, ?3 b7 }. ]8 L- |4 V6 n - #include <mach/irqs.h>
% r. N: z+ N) H3 Q4 F - #include <asm/hardware/edma.h>
# x: M( K h# f
& S4 k5 Y1 |0 G( o* o0 o- #undef EDMA3_DEBUG
/ X4 f! j* W2 X6 W5 ?% r - /*#define EDMA3_DEBUG*/0 Y% t$ p7 L) H; q W
/ a" [; [2 [- ~5 ~$ L Y- #ifdef EDMA3_DEBUG
" z, r J# z* U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 x$ Y) K [! c' m8 o; B' x8 F
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); O% j' Y. f& S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 A5 X% g& ? l8 ~ - #else
0 D* Q h5 A+ k v6 G, Q( | - #define DMA_PRINTK( x... )
! ^/ I5 ^0 w+ {: F - #define DMA_FN_IN
|- h- Z! x- M: N3 r8 `4 ^ - #define DMA_FN_OUT) i# `. `6 z8 Z2 A0 e' ^
- #endif h9 U* g5 g) \. G( ]
& F2 j7 O1 l5 U! C3 f- Y% L* u, j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 l, \8 i h- i0 {+ K; \ - #define STATIC_SHIFT 3* j y/ @ O. {
- #define TCINTEN_SHIFT 20
0 ?0 i' f& Q3 b7 }% P - #define ITCINTEN_SHIFT 21
! G3 r) W% u3 C( b, c - #define TCCHEN_SHIFT 226 O9 J' r b# h+ g! J; x! {
- #define ITCCHEN_SHIFT 23
4 {) C7 `* w% J1 g5 h; Z' U1 n2 R - / ~! C1 b2 y2 ~. s& g
- static volatile int irqraised1 = 0;
0 n! N8 z- C, J$ G& c" h - static volatile int irqraised2 = 0;
1 {+ z, l- L: T3 s
6 n" t4 W$ \7 \; F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* K4 c! z0 F7 W1 x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) ]" M; Q3 {. o" q0 d+ D! s
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 j* N( `: f' t, g2 j5 N
- 1 l& y# }/ h% T r3 E
- dma_addr_t dmaphyssrc1 = 0;0 D' D4 F/ w7 n, ^9 l
- dma_addr_t dmaphyssrc2 = 0;# v5 w( P$ P+ \' s' _5 U
- dma_addr_t dmaphysdest1 = 0;
) N' _# o' ]4 o' c( l' }7 S7 R. g6 d - dma_addr_t dmaphysdest2 = 0;
o! a1 U7 M; p2 Y1 ]! { - $ G# m, T: n/ A: ]
- char *dmabufsrc1 = NULL;0 ?- d# c) u' e" @1 }
- char *dmabufsrc2 = NULL;: ]# \# C( r. C$ |
- char *dmabufdest1 = NULL;
. S W" c6 G0 F6 [0 _" k3 K' ~ - char *dmabufdest2 = NULL;2 T- v5 E8 @# T& s6 X' J. s. G
- D2 n- F; _" A! Z( g- N8 _7 O% V/ j
- static int acnt = 512; ~. {# T- a' R6 a
- static int bcnt = 8;! o: C0 C8 g0 Z
- static int ccnt = 8;
5 l I$ p0 u" a1 I5 s0 K
& l, ^5 L9 A( o( `: t, x) K- module_param(acnt, int, S_IRUGO);) I2 A+ B, X; s; l! u. q7 D! G* C
- module_param(bcnt, int, S_IRUGO);
7 o& }5 ], k7 s1 E! g8 W - module_param(ccnt, int, S_IRUGO);
复制代码 , A) v0 y& h' P2 E
$ r% F X. Y5 K8 u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* p2 f6 c8 Y9 G' I" Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- F: G& S8 {* \( V! t7 \$ z8 p2 m 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' o) s* {1 g5 F% l7 g4 ]
* h" J+ z& ^; o$ L9 y5 w+ @/ x0 ]$ S! F1 p- F
|
|