|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; @) N1 L6 s6 W- j# ^- [code]EDMA sample test application: V0 y( P! s7 ~* E% b+ }& ?- j
- /*
8 j, R0 P6 q3 K- v - * edma_test.c
. r! M# k% T- \0 @. }& L. ^ - *
5 ]8 ]& ^$ ]4 ?1 z - * brief EDMA3 Test Application
2 y% P8 i! d2 ?5 F2 B/ F& U1 L- r - *+ }& |5 E" Y3 u' f& i+ M! t w
- * This file contains EDMA3 Test code.
4 ^! {3 T+ E1 `) V( J - *
3 N, t) K- D: A) [# Q: U' e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) w1 \; ]' ~# R, t# o. L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* D0 A* ~( M a" U - * TO CHANGE.5 n3 l% d6 O9 W
- *
) B: O" U/ Q1 I* ^& ^( V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) E' j) H2 S; n6 A1 K0 o5 D - *
; n, b1 }9 Y! T+ ?9 | - * This program is free software; you can redistribute it and/or
. _' \# r6 w6 h - * modify it under the terms of the GNU General Public License as
: e+ W$ V( S" d8 Y3 d - * published by the Free Software Foundation version 2.
9 S, g. l0 h6 y - *) C7 X8 n, f' Z# A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ |7 }7 b, H# ?* B$ m
- * kind, whether express or implied; without even the implied warranty
% N1 U( D/ y( c; }' E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- i) }' ~, @. b3 \8 q3 l- M6 D; Z2 n
- * GNU General Public License for more details.0 w6 I! h, |$ N$ y1 }5 T* A
- */! K7 N: I# j2 {( I+ V
+ _; Y( V: l! R7 a$ t j3 r7 E- #include <linux/module.h>
& O: B. H8 [! ?; k - #include <linux/init.h>5 j2 Y+ I2 C+ f
- #include <linux/errno.h>
: `$ J. k0 j# f$ _+ \ - #include <linux/types.h>
. f" z: I5 e: S2 t% D! ` - #include <linux/interrupt.h>
5 C; Y% O( G( ~( v' V/ R" |9 M. B - #include <asm/io.h>5 L' k- q/ m6 ?8 B# W+ d
- #include <linux/moduleparam.h>
; S0 p7 r+ f3 R* z, d8 F - #include <linux/sysctl.h>
9 [$ e5 l- d* t: t# X - #include <linux/mm.h>. q) Z0 s4 I6 y3 f. B
- #include <linux/dma-mapping.h>+ T* d* G# W' c. p; l3 [
- 2 X. S' t ]2 i0 w
- #include <mach/memory.h># I' y" T( g- W( T8 Q8 D$ A
- #include <mach/hardware.h>
; \! U7 Z, X7 k, d; j - #include <mach/irqs.h># V4 i: f# M# D
- #include <asm/hardware/edma.h>
$ g( D/ o6 |, J' C: W7 W b( ]; p
6 J" I* B+ V& O- _" y( Q! _% `: F( ^- #undef EDMA3_DEBUG
% H) y& f7 D( g6 w1 t. \/ { - /*#define EDMA3_DEBUG*/
' m( d$ @! `) z$ y4 f5 s1 I" B0 G - - d- `0 j* T1 Q" L% o
- #ifdef EDMA3_DEBUG. q; N8 s1 o- X2 X9 ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! n3 _' a5 ^# v- e! }0 K
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 R* r# G6 i J0 O" T! @. R1 S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 i+ J# a4 T; t7 @( @ - #else% w6 O- L% D3 t# a3 O3 E
- #define DMA_PRINTK( x... )( B' E7 {4 y& t: ~
- #define DMA_FN_IN
8 G" n* O8 Z9 c/ S& l7 m. ~+ X - #define DMA_FN_OUT
5 [ s$ I' J- W3 U/ L1 v - #endif
8 I6 v j* B$ M2 _ - % Y6 W7 j$ _$ F; |7 W4 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ ^# S2 z3 n( ^4 L3 A$ C% Q2 u
- #define STATIC_SHIFT 3
+ S' C0 } O6 ~9 m9 U- \ - #define TCINTEN_SHIFT 20 w7 X* a/ V$ v. I7 ?
- #define ITCINTEN_SHIFT 21
* A# p: y, [9 f$ }2 {' ~3 \ - #define TCCHEN_SHIFT 22; Y' r' C0 a) ^$ m7 ` ?
- #define ITCCHEN_SHIFT 23* H$ h! W+ D% I! R6 p' m* |
! a! N! n- R: U; z0 }" w- static volatile int irqraised1 = 0;
1 L/ X b9 [7 P/ q- W8 K' O; Y5 R - static volatile int irqraised2 = 0;
3 J% X4 p; L+ D9 W2 g6 T2 J; y
- n- d. p5 s: \! h; Y2 ~; N4 K- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; j7 a" T6 }$ a1 d( t" i - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* ]; M# |' \( S1 \2 p: E" u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& u. n& Z% [% A1 j - * r0 l* h! {" ~5 E. q& G/ h. D) z: ~
- dma_addr_t dmaphyssrc1 = 0;
0 M' G* f0 }! H3 B9 {( Q - dma_addr_t dmaphyssrc2 = 0;9 H( p' m; F8 q X: p& c
- dma_addr_t dmaphysdest1 = 0;1 z6 n4 R( |, j$ V
- dma_addr_t dmaphysdest2 = 0;6 }* g0 q2 Q4 P7 V- L5 i. o
- / x. g9 X; c/ ]" e' B
- char *dmabufsrc1 = NULL;: r7 I# h; @* @! g& X" n) B
- char *dmabufsrc2 = NULL;, P3 z; J) O7 E2 s& c% S# q8 r
- char *dmabufdest1 = NULL;
6 G9 T: F% y* B8 K9 M5 c - char *dmabufdest2 = NULL;" I5 Y! L E8 H4 E+ T E! N" D2 c' ^
& F- C4 y' z6 {9 y3 ?) k8 Z- static int acnt = 512;5 k0 i$ d: P% i) A& r) n3 P
- static int bcnt = 8;
' N7 ?) J- s, J1 a, l1 F: e5 G - static int ccnt = 8;
+ \ C4 ]2 a+ _9 f$ x/ T
+ b& i" y2 z5 W- module_param(acnt, int, S_IRUGO);
|. o+ U0 c a- m* A. x - module_param(bcnt, int, S_IRUGO);7 r6 v$ N2 g8 A& p4 Q$ R" R
- module_param(ccnt, int, S_IRUGO);
复制代码 % E# j6 X- S6 J7 N( v3 r
7 V; [+ L( O9 U7 @% h. ]8 r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: r9 Z# l; j) I" e6 X3 J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% I/ F$ E3 z. @2 p0 n( W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) {& ~+ `* v) b; ?1 y1 l1 P
' A1 X0 y# `: S: P6 m) ], w( ^
. [1 X- a+ [1 U3 r |
|