|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' W3 m: I1 x8 S) G* I1 B& Q- [code]EDMA sample test application. r" X1 Z! e8 L/ l7 z+ o9 X
- /*0 v* N$ D, b! i2 C- s: N
- * edma_test.c
3 Y; j/ o" `1 m) ^5 q r0 \ S4 H4 o4 E - */ N+ U/ O9 e) W/ F @
- * brief EDMA3 Test Application
4 z$ y m3 ]7 J! I2 h) v ]8 S - *
8 k) t# j; R0 n Y7 z - * This file contains EDMA3 Test code.
' S; N7 ]: T \* [ - *
) R1 K+ {9 E+ {( c" B( i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ y( Y% Q$ I/ X* j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, p& Z' L+ m" Y7 n: Z+ `
- * TO CHANGE.) T6 H( @5 r% r- t+ @* P
- *
, x- y z7 s! \# p - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 W- ~. M6 s* {- f. [4 w7 q - *
5 |7 D7 h- V/ h - * This program is free software; you can redistribute it and/or
) A& X4 \$ o& {& F" Z - * modify it under the terms of the GNU General Public License as5 @4 d, o+ {5 G$ k
- * published by the Free Software Foundation version 2.3 E6 Z7 r0 [4 D) O( O5 s+ S
- *
5 ~$ E( C% z5 ?/ B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 j D) p2 G- i" h - * kind, whether express or implied; without even the implied warranty
- ~9 N( x( K1 Y: W* [' p0 j& [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" I% C/ N. `/ P) M$ L1 V - * GNU General Public License for more details. I4 F' h# R; {* P# V
- */; Y7 z; d2 o o' I! b% c# p" [
- ( E2 @. l3 `/ D8 u6 b% m# ^
- #include <linux/module.h>
; V) b: E8 R8 H8 X - #include <linux/init.h>
% P. M7 r; ~" f' o m2 t - #include <linux/errno.h>6 {& S2 T' Q8 G$ g3 [+ x( m
- #include <linux/types.h>
4 A1 l8 A: m0 V2 c6 d( } - #include <linux/interrupt.h>
5 n/ i6 M( o* g, \ - #include <asm/io.h>6 Q; t( u: ]0 k9 f8 L! t. p4 ~0 Q2 z
- #include <linux/moduleparam.h>
2 `+ a4 o+ Y5 l9 }6 U! E7 [3 u - #include <linux/sysctl.h>) p: k% L! c4 \9 m% I& o2 X
- #include <linux/mm.h>* j/ C/ }* M3 E% P& @* O7 Q" K' J
- #include <linux/dma-mapping.h>
' P* s; w `, q - 5 M+ C& k! c/ [
- #include <mach/memory.h>
( S5 b' k) u, a: T2 e; o1 L - #include <mach/hardware.h>
* t* L3 j' X7 P( q1 _ - #include <mach/irqs.h>
* i- y$ p. F# K% |7 r& k - #include <asm/hardware/edma.h>
1 \$ L& N, r& y& R. A7 @ - " }5 S# t+ o5 @1 c. o
- #undef EDMA3_DEBUG
. L# N, D/ V4 V$ E! @! b+ C1 [' W - /*#define EDMA3_DEBUG*/
# c/ Q) p! L, M+ c$ e, w: b
0 c$ ]7 T9 j+ M% n! T6 I- #ifdef EDMA3_DEBUG
0 o* F2 j3 \7 U; J* }, H+ Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 A8 b+ t+ p1 t3 O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 w. S6 ~6 V1 J7 ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# N- {8 l/ b; @; P& q - #else
0 _7 W2 |1 C4 f! B - #define DMA_PRINTK( x... )5 Q; s' I5 z: {: `0 N/ K
- #define DMA_FN_IN
& T2 l( F/ V0 K8 @& ~* ?3 f$ a - #define DMA_FN_OUT
6 i: J6 h) o5 b) p - #endif
0 Z; W3 I* d4 i2 @
/ N6 B4 C! Y2 f) N ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# \$ P/ U9 J- H
- #define STATIC_SHIFT 3
7 Q! R) M) l# U4 v - #define TCINTEN_SHIFT 204 T- m t& P' T' Z0 u4 S& f, L7 Q
- #define ITCINTEN_SHIFT 21: C& o/ [! c! Y0 N3 C
- #define TCCHEN_SHIFT 22+ ?, W' Z% u) }6 ]# a; O$ C
- #define ITCCHEN_SHIFT 23
: S$ e# g1 N9 M4 H; L" a
9 `: q/ y" {: H; b( L/ b- static volatile int irqraised1 = 0;7 ~) y! |+ E* z1 {
- static volatile int irqraised2 = 0;* M( w; ?$ m$ w6 v+ i
# }5 Y2 }) t/ N6 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' w6 M# l1 e' V8 A- t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 i# Y( s. h. J$ d9 N1 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& }" i' O, C8 c, V4 e9 [3 t8 d4 K, K
- 3 v7 z, m* l, {: \
- dma_addr_t dmaphyssrc1 = 0;/ S) O4 f& u6 X$ Y# s8 t6 D; I
- dma_addr_t dmaphyssrc2 = 0;0 ~6 M% X* }6 Z5 h' `% G
- dma_addr_t dmaphysdest1 = 0;$ P* Y' R& {% f4 y( B2 P6 R
- dma_addr_t dmaphysdest2 = 0;5 U# v: v7 j# I% s
- ! b6 f0 M% F3 [" l% f$ q
- char *dmabufsrc1 = NULL;# W, r0 I' p l8 V- E
- char *dmabufsrc2 = NULL;
- x& e! h0 `( g) T" N+ _ - char *dmabufdest1 = NULL;
) F3 P& n" o% F: E' ^! R% P0 b - char *dmabufdest2 = NULL;
8 Q0 u. v! h- v
3 C/ k: m0 Z' ?7 u& u6 O3 r- static int acnt = 512;
5 O: @) V: Y# L3 z9 R& o; S - static int bcnt = 8;
+ I2 v8 c+ T9 S - static int ccnt = 8;
( R* _- j' T5 K! p: T; ^2 b
. {9 x0 Z7 O& F8 u- module_param(acnt, int, S_IRUGO);1 G/ [( V1 W) G/ ~3 x
- module_param(bcnt, int, S_IRUGO);; S0 W! k# c* H' _
- module_param(ccnt, int, S_IRUGO);
复制代码 0 G# G, x% y3 u
9 J- @* f* L- C' h( J/ Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 p) ^5 Y% v7 Z7 a7 ?& g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 Q& @! \$ v; `3 D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: P9 r6 F3 m+ I5 b
* t, L1 r- R% _6 d
: {, H) o+ U9 ~ |
|