|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 \' D3 e' U% C" W/ E- [code]EDMA sample test application: f$ w. m; c0 v! D' Z, ^
- /*
" K* u$ q$ s5 [4 ] - * edma_test.c ~& f8 v, J6 d' u- c
- *
- L3 Z* f, L( i6 ` - * brief EDMA3 Test Application. h' |4 v% p8 h* B4 L0 h
- *: |) n9 m2 ^9 K5 ?( H1 n9 k. R
- * This file contains EDMA3 Test code.
& o% P& G* P6 y& \! n2 Q: m - *: @ z' A( g: j& S% S" e1 |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 ]! U4 i: k4 ?- S7 ]. |" _+ c - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) N" E7 y. r: l& H: i( H' q
- * TO CHANGE.
+ H3 A& T: c$ n; [2 I0 ]0 j - *1 `* s. G. n! t8 n3 h4 y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; }4 H4 Y; d% U$ X
- *- |2 w+ b' Q# ^% m
- * This program is free software; you can redistribute it and/or+ O+ t# H% Z# ]
- * modify it under the terms of the GNU General Public License as0 B; @" V! L( g2 T2 n9 J# J7 d
- * published by the Free Software Foundation version 2.
* W+ ?. I" {. {% ?1 [( Y - *
1 h8 |8 W# j3 I U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ v& n5 W& q2 C8 Z" ~" y! h% D
- * kind, whether express or implied; without even the implied warranty
; ~2 \: q0 U% E& w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# s' W0 U3 K0 A$ d9 O S* i
- * GNU General Public License for more details.! n3 |0 t+ } f/ Z9 k2 ?. h C5 U! r9 n
- */
, \8 u: V; c1 { L) S4 y - ! e( x a; J; i3 d) G9 E" O' m
- #include <linux/module.h>
' X& Y9 e. I7 z6 g, g9 m% s - #include <linux/init.h>
; a5 P7 Y6 G' ?) K - #include <linux/errno.h>
$ j, f9 P$ N1 i9 E - #include <linux/types.h>; P6 Z7 }. ~6 ~9 c" f
- #include <linux/interrupt.h>5 m9 }& ]% E+ z' `7 O/ A. V( J
- #include <asm/io.h>
' u, v! `% ?8 |% Z' d2 z. \ - #include <linux/moduleparam.h>
- H* Z" }$ {0 i' n" P - #include <linux/sysctl.h>8 }8 X, Q' U6 t( [
- #include <linux/mm.h>
0 j8 e& g/ c3 @; E& B4 g - #include <linux/dma-mapping.h>% v' ?$ ?/ H( ~* F N; R7 Q
- 3 ?* G! q0 E7 G
- #include <mach/memory.h>
" J* q" i( H) R: @7 H" M- v, E - #include <mach/hardware.h>- u; C' B- |' j5 Z5 \
- #include <mach/irqs.h>' H0 S# r$ y) g
- #include <asm/hardware/edma.h>3 @3 U! q- @2 p8 w+ w d" w
1 H; a: T7 Q7 @: C- #undef EDMA3_DEBUG3 R [) Z4 b+ H0 c, W1 I2 l/ j
- /*#define EDMA3_DEBUG*/
' |% F6 ^' {+ b8 P& L+ _& F8 } - . c1 ^7 l* u; I2 p9 s* O5 H
- #ifdef EDMA3_DEBUG, m# d8 k6 m2 x7 M) T) ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) ^" l1 ?) O+ F1 \6 b$ t5 { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- D/ O; \% O+ z2 P( h b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- }3 X( K# _8 k
- #else
5 h- x8 Q5 a2 O" j6 R - #define DMA_PRINTK( x... )& T) o8 L* P" M& W) f
- #define DMA_FN_IN1 e' e1 H. I0 M' E J* z* L
- #define DMA_FN_OUT$ Q# O9 O) x! t; T: q& p
- #endif
9 {; j9 X( \" r' H7 ~0 N* a) m
) l% ]3 l! n: w6 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( v" o7 _6 }( H6 { - #define STATIC_SHIFT 35 |# y. l0 J6 u8 o; ]' }4 y8 P
- #define TCINTEN_SHIFT 201 U5 W+ [) _( [5 s6 D
- #define ITCINTEN_SHIFT 21/ H) j% R# H+ Q8 t B1 }
- #define TCCHEN_SHIFT 22
* `) K% g2 }9 D w - #define ITCCHEN_SHIFT 231 U5 m/ k3 y! I0 [. ^3 `
- 3 j1 b, S) U" y4 @' t! D& q
- static volatile int irqraised1 = 0;* ^+ ?) [ o j2 E! z
- static volatile int irqraised2 = 0;2 b1 |7 E8 ]) }* o( n
- V1 H+ P" Y6 m* {+ S/ ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 D) t# Z" e) d) O- `9 J; } - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ `7 h$ f: l6 e. Y/ {4 ~$ D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ~7 r0 s! _/ o+ Q; L
: P8 r# z) _; o3 X- dma_addr_t dmaphyssrc1 = 0;5 R( r! b/ k7 n
- dma_addr_t dmaphyssrc2 = 0;
) u9 j E3 \ a% `. [( z' i* C - dma_addr_t dmaphysdest1 = 0;
- P/ @* u# Y. u2 y5 G% S( S - dma_addr_t dmaphysdest2 = 0;7 C/ @! l- y0 z4 x
8 o4 U x: c$ o- char *dmabufsrc1 = NULL;
$ c4 v, H! a/ Y - char *dmabufsrc2 = NULL;6 Q8 O7 l" \1 K* S2 a" f
- char *dmabufdest1 = NULL;) T- N( p$ K) R" g( X. f
- char *dmabufdest2 = NULL;8 c, `3 z9 j2 u) a% \" X0 I0 g
2 r( d1 n' A3 l) M- static int acnt = 512;
* j8 O% a8 R( y( i* Z& \ - static int bcnt = 8;
9 h; X- [5 Z9 W* r$ ~ - static int ccnt = 8;
, | c& c X9 O# e( k - ! _0 _4 ~7 C" [1 I% a4 `
- module_param(acnt, int, S_IRUGO);
1 X- v3 C7 D" T - module_param(bcnt, int, S_IRUGO);8 Y' z0 P# l5 c" B& c8 m
- module_param(ccnt, int, S_IRUGO);
复制代码 $ g- d' l& ^3 X1 @# Y$ b; O
; Y2 `0 g0 L' o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 }+ E# A% y% j& 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) r" R/ h3 z% f+ s U; A* L. Q0 L* A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 B, z# F) l* I* }1 I& g0 V4 y5 M8 I6 Q4 H& I( L: P
" d7 A8 H2 z/ O9 K( P
|
|