|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. j8 I4 a3 e, b% }- [code]EDMA sample test application
7 R# L B: V9 L( E$ m - /*
( O- v ]+ ]. @$ T0 B; D, B9 U - * edma_test.c
( p+ L/ P7 U+ Z1 J( q5 z - *) z7 O2 Q3 _0 u1 p" z+ G
- * brief EDMA3 Test Application
. D% r7 [- c% f8 J) }- E - *3 Q7 o t9 \8 F0 B$ P
- * This file contains EDMA3 Test code.2 W8 H6 |! e+ B/ Q1 {) q3 w
- *; j( w' e; Z4 V N. S Y& b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 b3 @5 V- N! d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 ~# v: s8 I9 i ~1 a
- * TO CHANGE.
# y0 ?& n6 ~; T1 l/ y- u - *
! q p0 T; S( y$ t: s/ _1 L; \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. I* }. ]7 ~- G1 h
- * z" |# V4 Q* Z6 B2 J' `
- * This program is free software; you can redistribute it and/or1 f' M. p K: ~* C, l- I
- * modify it under the terms of the GNU General Public License as. z& F$ G( e5 K* D8 c, T6 T$ F
- * published by the Free Software Foundation version 2.' k; N, J( }5 w- P- n( w+ U
- ** _% E2 B6 s/ \2 ?; t0 s! ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ b% M* [( g6 q( T
- * kind, whether express or implied; without even the implied warranty
0 [& h2 J, C5 E( \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' r; m0 A2 f0 n2 Q% C9 |
- * GNU General Public License for more details.
' i w3 X4 H# B; E+ L - */
) k9 n9 `, Q: d" W9 o9 K, u I+ J
0 N4 x) ]& _0 X7 t W- #include <linux/module.h> N" R5 h( E+ r
- #include <linux/init.h>6 H# d& X% ~& o( c
- #include <linux/errno.h>6 [! I0 t% L: a4 t q
- #include <linux/types.h>0 v3 [& ~& g, }' G- x. ~8 P
- #include <linux/interrupt.h>
% R9 }* I! T4 X8 @6 e( x - #include <asm/io.h>
' S/ F9 T( x+ i9 H# |$ }8 T4 s - #include <linux/moduleparam.h>7 r' N# T" _6 r0 N" W
- #include <linux/sysctl.h>8 ~' I( { p- B, t
- #include <linux/mm.h>$ l& j5 E1 D8 _+ T- P
- #include <linux/dma-mapping.h>( K: k" T8 ^' e2 i: n) C
- # ~) n t4 U: ^* j) s1 }# D! v1 q* }
- #include <mach/memory.h>: B) L$ [# q& \* `5 U
- #include <mach/hardware.h>' C$ }7 }$ g, v2 s8 U
- #include <mach/irqs.h>
( F* @- ]! l3 c; i" P7 J! j - #include <asm/hardware/edma.h>
4 V! d- g9 i# [, x- R5 i( S - 3 P o) g6 B; b \9 ~, w
- #undef EDMA3_DEBUG
! |! r+ I3 D8 a U% { - /*#define EDMA3_DEBUG*/( \5 a) Y! p8 {7 S" k
- ( P9 K9 p, _" n
- #ifdef EDMA3_DEBUG
% C C, |$ K8 p7 k' O/ T+ c/ Z. q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) \1 _: u8 t+ T& R/ Y- k6 e" x$ M1 ^7 F
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" ~+ M1 w3 X1 ~+ E7 q1 t1 r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: p! G: a- t! i* O* q: O d - #else
- w* T# _' V7 F: s8 M% F& t @& y - #define DMA_PRINTK( x... )& S6 ]$ m$ _; `2 d2 _' a
- #define DMA_FN_IN
+ |8 Q$ N: F8 f& e; b/ E - #define DMA_FN_OUT
; w& d0 L# B& F% e7 V4 y+ _: g - #endif
% G" T8 j7 l/ _% r8 [) J+ G+ \6 @8 E - - K9 O1 a/ t7 m6 m9 |& Q+ s( u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- D* \0 U5 z0 K# m. ^& S' A - #define STATIC_SHIFT 3- m& z% P. n/ |# N- b/ {$ C
- #define TCINTEN_SHIFT 201 O L* m9 i- i1 ^' W4 Q& T
- #define ITCINTEN_SHIFT 21
. W! R: B/ {4 V, S' Z/ K - #define TCCHEN_SHIFT 22
% X% C' n' P+ M8 Z; H: r4 K - #define ITCCHEN_SHIFT 23
! k6 C6 Q6 F6 H% B6 d* X- M
" [/ n" ]8 v: B( K% u* G5 C- static volatile int irqraised1 = 0;# V8 U- A7 o; M" _
- static volatile int irqraised2 = 0;% Y0 r- i0 {2 w1 }$ m
" r( `+ A! S0 N P |6 \& D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& N5 g! Y0 R0 ]6 i0 ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ U- ~( S, F+ m& ]$ r0 ?0 j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& ]/ D1 Q6 z( c, q. V8 V4 R
- ( W6 d) P$ e' U; j# E
- dma_addr_t dmaphyssrc1 = 0;- j0 q6 l7 P0 O% h, Z4 O$ H. t( u- @
- dma_addr_t dmaphyssrc2 = 0;
& L' w0 L. R' k% d) E. W - dma_addr_t dmaphysdest1 = 0;
7 X8 |. F- V+ E5 R/ d* E4 g! z6 x$ L - dma_addr_t dmaphysdest2 = 0;3 F# n* M- a# _% f
4 w0 @/ {6 @5 m5 F4 R8 B M0 C6 T- char *dmabufsrc1 = NULL;; g2 C4 v% m- l e
- char *dmabufsrc2 = NULL;
# O+ r* f5 i, h& T& n - char *dmabufdest1 = NULL;/ [9 Y) y5 Q( e) O' N
- char *dmabufdest2 = NULL;
! v# T- h0 B1 W& x* K0 U
% m% I: r* |$ c, ], f8 t- static int acnt = 512;3 E9 z5 H/ b/ k4 r: H
- static int bcnt = 8;
( C- K* ` M7 G2 T - static int ccnt = 8;9 F$ ?6 B9 X! y& g' A/ Y5 D
- 2 @2 A# A& F+ R; S- I2 { K& _4 w! e
- module_param(acnt, int, S_IRUGO);! n! N8 p& X- N3 r `5 G
- module_param(bcnt, int, S_IRUGO);
5 J* k9 q" o9 o' [ - module_param(ccnt, int, S_IRUGO);
复制代码 ) `2 K- S' m; T! l
( C' e' F& z9 m! ^9 B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- E( d% W; o! r) {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 i& g0 t6 [2 Q7 C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" L4 t% c J5 W y9 t. Q7 s9 k: x
/ W1 d. q& p" a9 v
9 R4 k1 |+ @. ^$ I) X# B/ m* T |
|