|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' w! I5 z' ~. P1 m+ |- w+ f) ?0 w
- [code]EDMA sample test application5 t5 X. G( P& t3 F$ ]. } T' s" ~
- /*
6 _0 i! Q2 R' r3 J( G P - * edma_test.c& q) r2 j7 v! }! h! d8 B# r
- *8 K7 _6 ]0 ^+ C# s2 W4 m5 A$ W5 f5 X
- * brief EDMA3 Test Application: [6 B+ j' R% I7 n% q! e
- *
0 Y4 S1 V& j# T( f. ~ - * This file contains EDMA3 Test code.
1 P% Y Z. f3 L3 I8 ]* z# f# v - *
; P+ B4 b: r& a5 | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; `$ C5 E+ |! i, J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: h9 G8 P4 f/ A( Y - * TO CHANGE.
# }9 j" G0 |- C+ q P- {. S( N - *
& ?. x5 r% J" a. ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' r( G/ z' G+ s/ e, } l) d' j - *3 O* d8 @( `# m7 z& S
- * This program is free software; you can redistribute it and/or
9 X1 K+ U- I8 g - * modify it under the terms of the GNU General Public License as/ z' @' b4 o0 y0 j
- * published by the Free Software Foundation version 2.
2 K0 Z* _: o. r5 T2 G" i& n: ` - *; p# E. Z8 T: M! Z" n* _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" ^) M% l3 n- r1 o5 K) w G - * kind, whether express or implied; without even the implied warranty r! D. T% x. b# R% b- ]- s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# C$ `: L# t- _5 B4 b2 z% w - * GNU General Public License for more details., f1 d) }; E0 v' [
- */
# T- X$ c5 J' C
! z6 H" U8 L: M V7 T* U- #include <linux/module.h>5 f4 O d9 p9 W: }3 w" \
- #include <linux/init.h> D% c* F; W+ P" A4 u% i6 e3 T
- #include <linux/errno.h>4 t3 {$ V; V' N. [4 g$ \ F+ d
- #include <linux/types.h>
Q1 X% q+ C2 J' D' ^3 u/ @4 E - #include <linux/interrupt.h>- d1 X8 O3 r- }& y9 w) I2 E+ P
- #include <asm/io.h>
3 O/ p' {+ o$ v# y - #include <linux/moduleparam.h>
+ S: O' U! T ^6 u8 \ - #include <linux/sysctl.h>
! }6 K5 O8 s; t% m - #include <linux/mm.h>
2 g5 k: L% M1 p! V: ~! Z - #include <linux/dma-mapping.h>
, J' ~& Z7 N# A0 O, }) g* w' Z
4 @, d7 [5 T' L- #include <mach/memory.h>. \& _$ h" D% z) H4 m# W) H0 ?
- #include <mach/hardware.h> ~( D+ J0 _4 [. m
- #include <mach/irqs.h>
( R0 E6 Z$ C$ H0 b1 u: V L - #include <asm/hardware/edma.h>
8 m% z9 ^7 l3 F - / M( t& ]! U) b: m( l) v
- #undef EDMA3_DEBUG
; k% {: u9 \* u - /*#define EDMA3_DEBUG*/4 X R2 ]1 N; \4 e2 n0 D, a
- + }" n9 z) M4 x: f5 F+ i, Q X4 y( ?
- #ifdef EDMA3_DEBUG
. N. P$ M1 V" D; D! u2 y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* k7 i9 w5 _3 |# }( K& u. _, q4 S, P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 N! p! L ?2 m6 }1 w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 ]) S) z& J8 W
- #else
1 @1 y9 P9 f3 u: S4 l5 x6 @0 c9 h+ A - #define DMA_PRINTK( x... )
) q# R6 b5 \+ B' h( I - #define DMA_FN_IN4 P8 v! P/ N8 [' x- S6 P( @
- #define DMA_FN_OUT
, A/ k! H" C9 |+ z% c - #endif
3 Y+ ^# G" J' A1 ^9 ^* S - ( a& j" x/ o; `3 B& V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), M D/ J+ D) [4 W, a
- #define STATIC_SHIFT 3
! ?, k6 [6 J# u1 Y - #define TCINTEN_SHIFT 20
6 v' k; f6 l$ I0 J, c2 }) v - #define ITCINTEN_SHIFT 21
' M' e- Y* b( K% e. k4 j - #define TCCHEN_SHIFT 22& g1 [! d t: O* g) b2 ]( H
- #define ITCCHEN_SHIFT 23
5 \5 p3 ]7 g _' O4 P( i - 1 B# a6 z# J* z: j/ J3 o: @) R
- static volatile int irqraised1 = 0;6 e. n S- w9 M' t, D6 q
- static volatile int irqraised2 = 0;2 q+ r; ^! j/ w$ e
- 9 ]4 C7 B; j1 p2 u# a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% p# c0 Q7 P. {/ [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; b8 q" r7 M4 c3 {8 z' W6 w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 ~5 z' A4 `) R2 m6 \% n$ a - " N# P* b2 }7 \5 t, V1 l H
- dma_addr_t dmaphyssrc1 = 0;
) o" S w* V' W' U - dma_addr_t dmaphyssrc2 = 0;
( v1 T/ P o, r9 m. d5 Y - dma_addr_t dmaphysdest1 = 0;
2 ~6 U$ @/ {9 L2 Y1 r - dma_addr_t dmaphysdest2 = 0;
$ z4 F2 H, ]; A, R - & s* n+ }, f/ j# S
- char *dmabufsrc1 = NULL;( z$ V2 N( d2 B" W" \* `
- char *dmabufsrc2 = NULL;# c' P- {5 k) N
- char *dmabufdest1 = NULL;( l; J! w7 S/ e3 E9 O
- char *dmabufdest2 = NULL;
! y" R6 U" {$ n! A/ f
4 p0 L: p& I; n! a$ r7 d+ x0 v- static int acnt = 512;! ?" z) ~( P1 h" i0 U
- static int bcnt = 8;
8 V% [; G l; e) h - static int ccnt = 8;
) o' ]2 A5 s, v+ }/ h
* s' F9 w; B, k- module_param(acnt, int, S_IRUGO);) \# S0 ], K% [+ Z
- module_param(bcnt, int, S_IRUGO);0 o5 T3 V) w h
- module_param(ccnt, int, S_IRUGO);
复制代码
- m1 x' v" z5 @ J' h7 p/ d2 W P7 H( A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, g8 o" [9 b9 ?+ n1 q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' c* q, Q6 o) ^- q/ C T0 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 e. v7 w% x m0 p: {
) r9 A" V2 Y6 O
" m( E+ i0 G" |3 p# V |
|