|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + R6 m& B1 B) @3 v
- [code]EDMA sample test application# b9 F# Y9 p2 Y, K: T
- /*# V; ?7 x0 ` K3 k/ W
- * edma_test.c
* o. m$ ]+ b H, g4 c* v' C } - *
1 s* {: O9 s2 W( w3 z; D h - * brief EDMA3 Test Application
. x0 m5 F! F+ v& v$ v, V - *4 D' z4 K- ]& @; I& A: T7 y
- * This file contains EDMA3 Test code.
9 z( k& x. X6 N& Y - ** P) b6 j. V2 e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: N7 `7 u8 {) {: ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 w4 [$ [- W& \ i) n# H# P
- * TO CHANGE.
' r6 g+ r4 j4 |; r O, s: k9 ~ - *" ]7 R) C* a3 Q' S- Y% Q5 o# v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
t: ~8 s$ R& n( S, ] - *$ }1 {" |+ B4 g
- * This program is free software; you can redistribute it and/or
( ]0 S; z1 T! C0 [7 D - * modify it under the terms of the GNU General Public License as* R% W2 n% U% g7 [
- * published by the Free Software Foundation version 2.
' T+ _- Q# ^, n9 C - *
) k3 g( U- [! ]# }+ B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 u% C/ v2 @% q7 Y' T2 V6 y - * kind, whether express or implied; without even the implied warranty- E1 `% c. c* d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) r; S: x9 \$ a5 T! u2 u3 m# m
- * GNU General Public License for more details.- G' E( A8 i2 e Z4 t7 [& A% |- b
- */5 T6 E% U' b) r; v3 Z
8 S4 {. z9 W6 ^- #include <linux/module.h>( m* p4 {+ a8 z$ |
- #include <linux/init.h>1 Y5 Y! R2 q. j1 a
- #include <linux/errno.h>2 }! U/ \! n" d1 M3 L* p
- #include <linux/types.h>7 K' L1 {" c0 _8 w
- #include <linux/interrupt.h>
" Q, g3 }9 E0 C3 o - #include <asm/io.h>
; O, B' J+ ?% b6 w# A - #include <linux/moduleparam.h>
: t& q+ o! C/ s. F" N9 v - #include <linux/sysctl.h>+ N# u" ^7 J) A; @" l I4 U5 G
- #include <linux/mm.h>0 ^7 t9 h" G, v* X
- #include <linux/dma-mapping.h>
" w2 W/ i; o' M" Y7 c - + n7 I; D) s$ @. U
- #include <mach/memory.h>
4 Z- H- O+ |) ^& r+ q J - #include <mach/hardware.h>) X" w F# m7 J9 V, _
- #include <mach/irqs.h>
6 k/ e4 M, {* E" g5 X/ D" ~% N8 Q - #include <asm/hardware/edma.h>$ Y% n7 ]) M) }6 e3 Z& |. e
9 H" c6 Q( F! @5 e' Y( s0 R& H- #undef EDMA3_DEBUG$ O; W K1 I4 v* r+ _4 a
- /*#define EDMA3_DEBUG*/& i( v3 c6 z! O% \
- * y& V8 ?7 w8 I6 {! O9 h |
- #ifdef EDMA3_DEBUG' D) P$ \! m- ~( K$ k" s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). T* E) R: ]1 l* W( O; S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- f/ q/ e) ?7 j( ?. H4 c. L5 q3 d% P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ z: R1 Q$ J" V! Q6 R
- #else
2 s7 s5 l1 [% m - #define DMA_PRINTK( x... )
( Q- t8 l( w4 {. Y7 } - #define DMA_FN_IN
, t1 L; ~: j3 u. U - #define DMA_FN_OUT
8 o1 S3 j! Q9 l - #endif2 G* D) o' d" a6 ~5 y
- # l4 h) v3 v" ~7 O. S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# s+ G$ d; f, e& ^8 M4 x* T - #define STATIC_SHIFT 3( f j% I2 x; q! s3 n
- #define TCINTEN_SHIFT 20
: i3 g1 O- u+ [* f1 a& Z+ q$ Y4 { - #define ITCINTEN_SHIFT 21
) ^8 w$ }$ x3 T8 T3 ^% r - #define TCCHEN_SHIFT 22
: E0 A) p; Y/ s Y- ~ - #define ITCCHEN_SHIFT 23
: h- B/ U1 Y) e/ j8 a8 K - 5 \% k# n7 ^! F+ `) g; }
- static volatile int irqraised1 = 0;
' J+ D2 D) d1 W3 E- K$ p$ Q - static volatile int irqraised2 = 0;
/ @! k$ B0 M& d7 W: v - ; X( E0 X% R4 E6 K; m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) G# f/ M% B7 X; t% N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% t. q+ V$ E8 @7 o8 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 a4 G' y) v. P/ U - , v' B E1 i# m, W
- dma_addr_t dmaphyssrc1 = 0;% D! l/ E& S) }* ?
- dma_addr_t dmaphyssrc2 = 0;$ Z, }$ Q( O* R
- dma_addr_t dmaphysdest1 = 0;+ s# @9 s% N [3 {, N5 x
- dma_addr_t dmaphysdest2 = 0;
0 z+ w6 L5 ?3 A
7 L/ ]) D+ K, P- char *dmabufsrc1 = NULL;; N1 t; |9 ~2 G4 H% B( D/ C
- char *dmabufsrc2 = NULL;1 |- t. y4 m: |, q, |$ |/ t) ^
- char *dmabufdest1 = NULL;
, J( b& [- `! z6 C$ S/ o# x - char *dmabufdest2 = NULL;5 d! o X0 y4 ^* R( l5 r
- t6 K* ^$ a" a4 N# E
- static int acnt = 512;
2 r! F9 |* [# T# A$ J# ]/ U" \9 T& Z - static int bcnt = 8;
' b8 S* m$ }( U: y. @: y - static int ccnt = 8;! m& a$ | B& } e- _
' D2 J! t1 u- ?8 o# M9 \+ p" d- module_param(acnt, int, S_IRUGO);
4 Y$ E% T8 K; D1 H3 P+ R. y - module_param(bcnt, int, S_IRUGO);
5 w4 N7 c+ ?; e! Y+ x5 H7 x - module_param(ccnt, int, S_IRUGO);
复制代码 ' ^; H- f, @+ x9 }
1 v; A* s, i v8 n* f7 ^& a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. }" C, H' d9 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- i1 U: z! r$ q3 J9 W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 o' M1 a& f5 K* \9 h x
' v2 I3 y# n5 f, P6 p
0 b4 \ V. o) I0 m |
|