|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% y; K3 y: c, b+ D, V- [code]EDMA sample test application
r8 I! K# H3 I$ _* W+ Y - /*" M/ \" z5 D5 p
- * edma_test.c
4 z u8 B- y7 W7 H ?( E) H - *# |3 u7 |+ Z' X4 p$ S
- * brief EDMA3 Test Application$ W6 d8 x* r' j& e
- *
' s& i4 c( S1 l! }6 P - * This file contains EDMA3 Test code.1 i# X( C% h9 p% q4 W
- *
I! }: Z& q8 f% v6 e- O5 h8 {/ a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% S1 ~. G$ c& |$ ]# o% c - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. d: X; b: }4 z- y
- * TO CHANGE.
3 Z* E" A/ l' _7 } - *
6 j: q ?3 F& ~6 M- K6 F5 X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) n: Z( v- C. C2 F1 X
- *$ ^5 ~" j2 j; q6 v' Z
- * This program is free software; you can redistribute it and/or
) v: B, q+ ^( v, w - * modify it under the terms of the GNU General Public License as
& J2 C2 D7 s9 J, X# M# F/ L - * published by the Free Software Foundation version 2.
& i) V. H& A$ [8 s! \& i; u - ** n# i' a1 [) y3 w$ |1 H# v
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 r- e0 E0 i% R3 z2 l3 q
- * kind, whether express or implied; without even the implied warranty
6 `( }* c" t/ O3 V2 d+ G8 C: X; v - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" [* e. o+ B6 s3 C$ {% _ - * GNU General Public License for more details.
+ x. b1 [8 G8 L+ y8 V6 B - */
% L3 x# c0 R `% y! j
- K+ M/ F4 U# [& |) E- #include <linux/module.h>" F, x" L/ }7 R" T( w! Q
- #include <linux/init.h>2 `$ R5 Y/ g+ c2 ?7 J) Z! D4 ~
- #include <linux/errno.h>% D$ d2 T4 j% s2 Y$ s: b! c
- #include <linux/types.h>
) |, ?8 F1 V1 r - #include <linux/interrupt.h>3 X, s2 C' r) I
- #include <asm/io.h>) p* F+ f8 f: b( c6 A' [) x" g
- #include <linux/moduleparam.h>
) e/ v& ^1 y- m6 m - #include <linux/sysctl.h>& _) I8 C. M& _2 u2 u( b
- #include <linux/mm.h>
3 M& T! W. E% P: }* a% ]2 v - #include <linux/dma-mapping.h>
2 E& B) q" q0 B7 x' m - + S z; ]" x6 Z6 Z2 y6 g5 }
- #include <mach/memory.h>& U) W2 C9 h8 x
- #include <mach/hardware.h>4 \* e# K; o8 H" F% n% P/ K$ W
- #include <mach/irqs.h>2 s6 p. n: K! x; y# Q8 {
- #include <asm/hardware/edma.h>: A# ^7 N* F) f* j" f
3 v( Z9 h; k/ f- #undef EDMA3_DEBUG
4 J6 G, J2 ?9 {2 s - /*#define EDMA3_DEBUG*/
6 S* ~! X# N: `8 _6 I
8 _; a7 I, Y% |" @& g! m- #ifdef EDMA3_DEBUG
& R. G a" f- Q1 j) H - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! w6 H) N, Z3 [- G$ `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 j/ @+ T" l0 Y/ g# Q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) `3 Z s* z% w- N( S& T% Y6 \
- #else
" M+ t: T3 i9 S# ^; M9 V - #define DMA_PRINTK( x... )
* E. m& H# T: G - #define DMA_FN_IN' v. w+ t# M. P: s9 {8 E; P
- #define DMA_FN_OUT$ J0 @8 D$ I# B H2 P
- #endif6 ^! C0 B. D. V0 B* k* h
6 \- g8 M" S( F, ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; [3 D! l |+ s0 _3 @8 j% H" P - #define STATIC_SHIFT 3
# R2 z# t- @0 l* |* z* J$ ] - #define TCINTEN_SHIFT 20
3 }; Z+ k" z, } - #define ITCINTEN_SHIFT 21- w: ] ]* A5 B7 G
- #define TCCHEN_SHIFT 22
7 {: c8 h. B1 N7 n$ A5 K - #define ITCCHEN_SHIFT 234 L8 G3 `( c6 n; P& R! M
% f, U+ z, z# c: }8 K6 N; t- static volatile int irqraised1 = 0;+ m9 b7 ?4 ]3 F* x0 i' l
- static volatile int irqraised2 = 0;, q) [- k6 Z/ I7 D8 y: d4 O
- 9 ]: o: v: n! ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 N2 o, E. V( z, q8 y, n' l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 T" B8 w+ C7 E% @0 }% d! b. V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ d! u# p9 }% B+ a) ~8 f
, u- M! g5 l% V- ~* |& W* Y- dma_addr_t dmaphyssrc1 = 0;
f+ t O# L- R" d - dma_addr_t dmaphyssrc2 = 0;4 R F8 j, r: _: J
- dma_addr_t dmaphysdest1 = 0;7 B( J) [/ K) O6 m5 S
- dma_addr_t dmaphysdest2 = 0;( W+ H% Y" |; K% g/ K0 v
k4 P7 L) ~! f7 J* e4 c- char *dmabufsrc1 = NULL;2 Z: @6 }* k( r( @
- char *dmabufsrc2 = NULL;" T) s* l! r2 P
- char *dmabufdest1 = NULL;4 F7 I! O( f% K% c
- char *dmabufdest2 = NULL;7 S! ^2 C U5 L1 t/ c [! P
- ' ~) ^- B, g2 R# |
- static int acnt = 512;
% d' K: B/ u6 S - static int bcnt = 8;; n# d/ |; I4 t
- static int ccnt = 8;/ G: t# K% I( H
! U* ^ x. R7 b- c: R- module_param(acnt, int, S_IRUGO);
: |2 ?- T4 T" Q4 Z8 f4 S - module_param(bcnt, int, S_IRUGO);# G, c6 L1 n& R* D
- module_param(ccnt, int, S_IRUGO);
复制代码
1 L/ S+ @. @9 N6 U$ T2 C/ }: q" H' T( O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% U; c2 F5 F* V. R0 [$ V; N, 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 j* f+ {5 r* B0 z- d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! v; s* E) }6 z( H& t
: P6 z e! X3 s7 t
/ b; b0 B* F+ A9 z6 J |
|