|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 p% ?. S2 j" G, ^
- [code]EDMA sample test application
$ m% v$ V4 x$ i: p) }) v. m/ P - /*
2 y; `1 M, E# j/ w - * edma_test.c/ w6 X) r6 \. M. d; k
- *& _5 s" {/ U4 N, ~0 P& f0 [4 q
- * brief EDMA3 Test Application. e J& M0 N( y! M1 T; \* O
- *
; ]3 p* G6 S6 O7 t: K: w, a - * This file contains EDMA3 Test code.4 E2 b0 T, l% J! n1 _7 s
- *# E5 _( _+ h$ [; [' I' P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
U8 k% w% j# v5 V' _5 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- L% E1 l' X' p - * TO CHANGE.
2 _9 B9 f+ e+ U$ F5 d! B0 Y - *
4 O6 N. q) z2 j( a1 H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; ]/ W* p0 R8 n4 l8 z+ J1 s% r - *
' p# ?4 l) ]6 A$ o- J l - * This program is free software; you can redistribute it and/or
0 j+ e9 B# F3 z6 R6 R - * modify it under the terms of the GNU General Public License as
% _4 l, d/ J% P - * published by the Free Software Foundation version 2., Z( O9 d6 N0 \2 d; ^* ~# |8 g0 F
- */ [( \4 R+ a5 z3 X
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% [, i: |2 Q8 M# u8 `- r' G - * kind, whether express or implied; without even the implied warranty5 @8 p1 C2 A$ A9 q4 S# h! O/ O. B* E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. O! {7 i1 O; V - * GNU General Public License for more details.1 j ?' B: |2 ?
- */4 t) A E+ v2 L
- ( |; ^% i: y1 K7 y. I. ?0 G) V# g3 d* R
- #include <linux/module.h># Y+ Q/ Z" s8 ^0 z t* K2 D
- #include <linux/init.h>
* q3 M4 ~; y- c X - #include <linux/errno.h>8 O/ O- f$ k" o. y# u! G
- #include <linux/types.h>2 Q/ q$ [0 ~/ b, R2 X R% n9 T# s3 }
- #include <linux/interrupt.h>* `6 i/ R7 y5 x+ U
- #include <asm/io.h>
' W4 B) G7 G, @4 Z9 p& | - #include <linux/moduleparam.h>
3 {/ F4 i6 B: n9 f8 F - #include <linux/sysctl.h>. Y1 h. x# m- r
- #include <linux/mm.h>
! l+ c' f( _5 G( \8 X; e6 @ - #include <linux/dma-mapping.h>5 x" r8 I; ?0 |$ d$ \8 F: x, R/ q" G" m
* ?) {/ w( x. u w; I% \9 w7 Z- #include <mach/memory.h>4 k( E( @! @' `6 F" a
- #include <mach/hardware.h>
, q4 c( A9 Y4 L4 n - #include <mach/irqs.h>
1 a# l# e+ W8 p% x5 }2 ?8 R9 h y) m - #include <asm/hardware/edma.h>6 o- q7 e# Z2 @1 C$ y. R8 _
5 s9 d \) T/ b5 k2 B4 k8 \0 n) I) l- #undef EDMA3_DEBUG
$ e( W' T0 H& Y6 v5 Z3 P1 l - /*#define EDMA3_DEBUG*/
) k: l5 Y6 f1 z2 N! F) I
; W! P. B/ L) t! |# s( w8 S& R- #ifdef EDMA3_DEBUG
; q- A0 F. A6 H% k. N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ b+ n Q. u' D( v
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) O3 B' x, G$ r, X, }( P9 i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( b) a' L/ D _ }
- #else
% U" A, o# ]+ h/ }( B: Y& }# _7 t - #define DMA_PRINTK( x... ). g5 m: F; H8 Y
- #define DMA_FN_IN3 |! } q+ b5 M9 c8 c. y
- #define DMA_FN_OUT
0 `+ a7 A0 \" S5 d - #endif
7 J; b" q+ p$ f" c
. c$ B+ }: L4 Y; \5 e- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 g9 Z% U$ H2 Z [8 m) s5 q; W# X - #define STATIC_SHIFT 3
/ ?% X# r/ S( y9 L5 ] - #define TCINTEN_SHIFT 20) Y) k8 B* [. p0 w- I t& L
- #define ITCINTEN_SHIFT 21# T9 j" Z) ]9 R8 w \7 z
- #define TCCHEN_SHIFT 22# r r9 l" y% f
- #define ITCCHEN_SHIFT 23- m/ m- U7 S$ t9 e, R& a
- * @1 g5 e, T6 W8 `6 I+ `
- static volatile int irqraised1 = 0;
, ?, E0 `+ H4 y" k! k - static volatile int irqraised2 = 0;
8 ^. |$ |) o. E! i4 T
- B0 F0 k9 ]; W1 ]' o- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% l) x" W8 }, O9 h" M6 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ P) ]( C) x3 J6 p/ m( L) L& S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 j) p s, X8 y, P - ) F) W; y$ F$ [: Z) }# \
- dma_addr_t dmaphyssrc1 = 0;
# {4 r2 T7 c' n- N - dma_addr_t dmaphyssrc2 = 0;/ z$ M Z2 }! R4 y U' Z7 ^# E8 h3 E
- dma_addr_t dmaphysdest1 = 0;
2 E0 J4 v% I+ O' V" Q - dma_addr_t dmaphysdest2 = 0;$ q* |, p( a6 m/ D# _6 s+ R
- 7 o. I; i S. e1 e( }/ l
- char *dmabufsrc1 = NULL;
. P' ] e8 b& L. D- L' G - char *dmabufsrc2 = NULL;
' m+ k2 S5 n4 \# m8 U5 c - char *dmabufdest1 = NULL;
1 K' v* c! h6 l! s3 J - char *dmabufdest2 = NULL;9 A: c/ g4 p E! Z7 E5 M( k/ ]6 y
- : R* `: Z& M* h# i; I+ A9 Q0 x) S" f
- static int acnt = 512;3 l" [5 |5 _! |9 k8 P: `
- static int bcnt = 8;% ^; V6 F" A: h6 @3 s8 [2 F
- static int ccnt = 8;
; t' q; a2 r" @$ H0 y+ U
3 Q8 _ e- G2 R0 ]( u1 ?5 d7 w- module_param(acnt, int, S_IRUGO);5 g% T7 u; h! K* W* F) n' c/ k
- module_param(bcnt, int, S_IRUGO);& }/ Z6 y! ]. @5 ^4 w
- module_param(ccnt, int, S_IRUGO);
复制代码 ( u2 ^# ^ \( g& k8 `
K' G, s% j( f8 C& V0 g- ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 o3 H' L3 [9 L% C: w
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 y$ c/ Z4 G4 l: x& e 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 l. e# Q/ n1 j, j, g8 J# i/ D
8 I7 [' p9 s# j' Y; e
, q2 T5 r5 o0 P7 n4 w/ u! u4 F4 { |
|