|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# ?$ @2 v' `7 ~: X' P- [code]EDMA sample test application
" p) N( b. G" }: l3 k8 F4 ~ - /*
+ P8 k, Q4 O% U - * edma_test.c5 _9 o w9 M) T" p& t& M
- *
) e6 \. [5 Q9 w* @ - * brief EDMA3 Test Application8 g" o( o/ V& e- C i; o
- *
* P/ O* ?8 z3 M7 |5 `" P - * This file contains EDMA3 Test code.5 p' c% R) B0 P) |
- *
7 u* U+ [& Z8 a7 ~, F - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, V2 E2 H: `; ~, o8 r - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. O7 l# I" F5 F( E
- * TO CHANGE." p4 {+ i% C- y) }
- *
6 y( Q" y: n7 t$ c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" R, f! J9 y$ u/ J1 b$ Y! b - *+ o: c- N# ` N1 {! L& |- J
- * This program is free software; you can redistribute it and/or* r, B& O! i2 A) @- L2 A* ~- ~
- * modify it under the terms of the GNU General Public License as
& _) ?: w3 w7 {6 W: a$ g - * published by the Free Software Foundation version 2.3 \& L$ {6 Y) }" [* g; X
- *
- t! q" |' ~6 [1 h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ I7 e0 w6 P9 s - * kind, whether express or implied; without even the implied warranty
( o" K* P4 p `# m/ l# p9 F: @! r - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& d5 b% b4 Y; ?7 ]; @9 b - * GNU General Public License for more details.- E) x4 t9 P+ N; l
- */
' H: i, ^* Q6 q% a& \! b
9 ~6 w4 ^. z( o( r& l- m( r* g% I- #include <linux/module.h>6 L* n) l Z/ p2 \$ p* I$ v- [ W3 v, M
- #include <linux/init.h>
% n( C; x. O' Z - #include <linux/errno.h>5 P3 M: a/ Z, E% y
- #include <linux/types.h>' Y: g! \0 E7 }' t5 _+ b
- #include <linux/interrupt.h>
% B8 B) @7 _; s. Y( m( Y- q: ^& i% w - #include <asm/io.h>
0 x/ e1 i0 N; E2 H% o - #include <linux/moduleparam.h>: w E1 ]# |0 Q# ^3 R- | b6 Y
- #include <linux/sysctl.h>
" @, V" H6 Y, T8 f, S1 M - #include <linux/mm.h>
* U- c# w. W5 Z5 h& D" f - #include <linux/dma-mapping.h>
6 W. ^" P5 X) o, s) O" n; L - $ }! `. u& d0 o# e: C
- #include <mach/memory.h>4 m, W' |. B/ q5 G2 N% A1 Z" Q
- #include <mach/hardware.h>* u% w! t" D: o( P5 ]* Z
- #include <mach/irqs.h>
$ X* D/ b2 T) P ?# F. Z5 ^- C - #include <asm/hardware/edma.h>
7 U( k1 W; W0 O3 C& a5 W" ^, C* A
& X6 \5 o/ X4 K" _5 i7 G/ Q" b3 F* k2 U- #undef EDMA3_DEBUG
' a0 m. N5 n# C' u# I8 g& G# `) z - /*#define EDMA3_DEBUG*/
1 J$ D0 R) l0 i V
7 W4 `8 N! s% B0 Q" c- #ifdef EDMA3_DEBUG; o7 ?# }5 N1 N/ U) R/ Z) k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; {4 ~: j; L1 Z0 ]4 s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 F5 T* q- _$ A* I
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); F1 E9 i, N, ~( B# C# |1 c. s, O) l
- #else/ K# z1 G: |/ T7 K+ q
- #define DMA_PRINTK( x... )7 x/ R8 G9 ~0 {( H
- #define DMA_FN_IN
, Q+ A. n* J# o! Q, \, S - #define DMA_FN_OUT
8 j2 q% E- n P7 @ - #endif4 Q3 ]9 x% {. _* ?3 {
+ ?9 `8 ]6 ]7 m. S9 F- #define MAX_DMA_TRANSFER_IN_BYTES (32768) g1 I' \5 P$ |
- #define STATIC_SHIFT 3) k e" z( s9 j( S
- #define TCINTEN_SHIFT 20
" C$ X( b! V4 l7 U6 S - #define ITCINTEN_SHIFT 21
- L6 m2 K( Y; s7 I5 K& b - #define TCCHEN_SHIFT 22
3 W% n4 O3 Q: o( }; O. |9 c - #define ITCCHEN_SHIFT 23
' E+ h& j- P T# @' k+ A - 3 z$ J' Y! `4 i. Q! m4 O1 _8 _
- static volatile int irqraised1 = 0;; `+ e) X% ]# K% q
- static volatile int irqraised2 = 0;
; t9 I& x5 T# ^( C7 ]# n& E) o- z2 ?1 ` - " M: Q! j. I4 K+ \: `5 r' ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, d9 L" n* {- T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" ^+ F. G. \8 H) W4 }' f7 r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 s' [) F' r0 c- R" v. S. {
- . n# P+ u; O/ b6 q+ ]- |
- dma_addr_t dmaphyssrc1 = 0;
4 m; l% f2 w# I - dma_addr_t dmaphyssrc2 = 0;
* f: B/ _( D7 b& x, H* s - dma_addr_t dmaphysdest1 = 0; V. ~3 |% n$ }- S: f
- dma_addr_t dmaphysdest2 = 0;8 C4 o0 x1 L6 I
( L7 C* b, R9 i& Q8 [9 u( @6 |- char *dmabufsrc1 = NULL;- d+ p9 F* l. N8 f
- char *dmabufsrc2 = NULL;( F7 |8 Y. O, u; m5 p! u5 @4 m; j
- char *dmabufdest1 = NULL;+ Q/ h5 }6 D, s" F- @# \
- char *dmabufdest2 = NULL;
' e# T) h! ^9 i$ ^* C0 b1 G - * `* c" \. a- ?) C4 m
- static int acnt = 512;
6 f! s1 [6 z) a: \ - static int bcnt = 8;
# e$ q3 k; _- V - static int ccnt = 8;2 z4 P) O7 T9 U2 J# p% P; U0 d
$ {( Y2 k" ~4 e* f# W3 i$ W; C- module_param(acnt, int, S_IRUGO);
; T8 u5 ]( c s5 S( V: q p - module_param(bcnt, int, S_IRUGO);/ X* b, g4 @) r- {" U
- module_param(ccnt, int, S_IRUGO);
复制代码
; w: Q/ c0 N2 H( d1 f
6 {& P6 a& G6 L3 k4 s" O! Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" k) T' D6 ]. r4 c1 K) l6 @1 V# {
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* C8 O! S3 ~* L- z ]5 p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 i) a9 e6 D( k5 Q' ]4 I
) k$ A! j4 D2 G% R" ]; |- e u8 C
2 n. U* H: U7 `; p( ` |
|