|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' U/ ?( W4 j) P: t. ?. U7 v; }- [code]EDMA sample test application$ e* k" R, h9 j* |, ]4 v. t
- /*2 a e, S, s$ s4 g) C4 t3 z
- * edma_test.c
- L2 b4 w$ v. L5 n6 U x; _9 \2 s - *
, ], i3 h) H. b/ x; g' ]5 g i - * brief EDMA3 Test Application4 p) d# q5 B$ r- |$ _; n- f4 J
- *
3 \9 I$ d0 S7 q0 E- F5 q - * This file contains EDMA3 Test code.& {, i5 Q( G# E+ W& A4 ?
- *- Z* K% l# f! C' q; m% [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! L3 ^" ~. C* j* ]% D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 V1 T* j- ^9 J6 H* @ - * TO CHANGE., @) u$ r- q5 r. o
- *
( B8 e, L: `/ X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" ~" J! C( F5 b/ a+ }0 u) U - *8 p9 K. h9 C4 n$ E4 l$ [ k2 l% `
- * This program is free software; you can redistribute it and/or# Q" x* p4 u s! m) I( X
- * modify it under the terms of the GNU General Public License as$ y: v j/ s# m; s
- * published by the Free Software Foundation version 2.
. u( d6 Q( t, z+ G - *2 Z( Y' Y/ K+ l! n7 J
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ E, n; |% I" R5 y0 x
- * kind, whether express or implied; without even the implied warranty
) n6 V3 V1 [) v6 l/ } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) S4 | V. f v# m4 p+ F+ q - * GNU General Public License for more details.2 X! z' ?4 b {+ R. M# Z0 I. O
- */: U [( ]. R: x, E! Q: A
6 F% m4 p1 B9 n( d$ B2 e- #include <linux/module.h>
5 X7 L9 S2 I6 y2 E2 C3 U/ |1 D - #include <linux/init.h>$ V2 U+ D% \0 c8 D5 o
- #include <linux/errno.h>
! ~4 ]) V; k; {1 j - #include <linux/types.h>& U* d& R- @; [$ N
- #include <linux/interrupt.h>6 ~5 y1 f& W6 ~: S: n
- #include <asm/io.h>$ e2 P+ `- p1 X9 e0 O
- #include <linux/moduleparam.h>
+ |5 G* t! {$ T) }$ ^6 t- F - #include <linux/sysctl.h>9 E# o' F( Q" w- t# _
- #include <linux/mm.h>
. N. J5 _: p; B+ I - #include <linux/dma-mapping.h>
# v* U# m7 \; v" `+ t - + G. t4 z% E& u( R. F
- #include <mach/memory.h>/ Y! k' X' z7 {, y1 c, v) q. c7 m
- #include <mach/hardware.h>; U% j# @ R, Z* @* r
- #include <mach/irqs.h>
& X+ d* L2 g: O6 c% E' R; }: [ - #include <asm/hardware/edma.h>
6 m& F5 d) \( D9 a; S& q
! N/ D7 J6 u X9 g! t- #undef EDMA3_DEBUG; N$ I7 z3 `, d, M) R0 Q" q
- /*#define EDMA3_DEBUG*/
; R4 s( U. ?3 s2 }7 R
- O j4 }! j D2 E- #ifdef EDMA3_DEBUG! @6 W. C. M$ \! ~, Q/ V$ o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 h* S7 J/ m/ [0 J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! N8 d! O9 O( s) d7 [; Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 ]1 R0 k. u3 E1 P
- #else
@0 L& W; F7 m: L( b - #define DMA_PRINTK( x... )! P5 L! @) G. ?" @( L) w0 B1 W
- #define DMA_FN_IN/ N' y) F y; j0 a. h3 F1 d
- #define DMA_FN_OUT
5 u1 X1 X4 z. a5 M5 k; C8 k2 T - #endif
& O6 p6 k+ n, [8 _ - . b) F. F* r" }* K0 w+ d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' b( Z3 L& U% U$ ]4 _% H8 r* W
- #define STATIC_SHIFT 3/ x! ^5 |9 T6 ?, T% ]# \
- #define TCINTEN_SHIFT 202 R- B! M% X, [0 j3 N& z7 |) |
- #define ITCINTEN_SHIFT 21
- g, e0 |! N0 l0 B A# f- d - #define TCCHEN_SHIFT 22
4 j3 s. D$ W) V$ y - #define ITCCHEN_SHIFT 23: ~2 ]# s0 s7 Q5 {9 f
8 p0 F% D+ W d& I3 b( q- static volatile int irqraised1 = 0;
! `& J% c4 `: |6 N - static volatile int irqraised2 = 0;$ J# [/ E, C. p4 k0 V( I
- ' g2 I: `3 @, |; j" \% }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) [( `$ g* o" m0 m; a( I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* P. G. [' l5 r/ ?2 C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ t+ @0 Z' y9 Z- d! f. K9 G
% h+ G' S }6 M- dma_addr_t dmaphyssrc1 = 0;
- n2 S( S3 Y3 _, N - dma_addr_t dmaphyssrc2 = 0;2 Q: \* H0 R1 V$ N
- dma_addr_t dmaphysdest1 = 0;& u5 x( d m: _# q: @
- dma_addr_t dmaphysdest2 = 0;
- o6 @. l! r- m5 U% H9 W6 f& B - & `4 q" ^' i6 x* T( ^, I: {
- char *dmabufsrc1 = NULL;
, U+ |( O5 y" X+ V: J+ G - char *dmabufsrc2 = NULL;. S4 v- ?! G& J& S5 p. A
- char *dmabufdest1 = NULL;$ D$ \' j+ g! }9 X$ ^. N; ^
- char *dmabufdest2 = NULL;
8 ^. H0 z; p4 _% B# O - ; P& Y# A6 g4 b* e2 x
- static int acnt = 512;, u( I$ ]3 ]! t7 ^
- static int bcnt = 8;
9 r) j5 @5 z+ C+ M4 r - static int ccnt = 8;/ D+ S- s8 m( s w9 V6 w
f8 x Z4 \! q2 q% G- module_param(acnt, int, S_IRUGO);
5 v1 `* S9 ~6 l - module_param(bcnt, int, S_IRUGO);# c5 _* U9 \' \. a3 e: J, F0 i. t7 j8 d
- module_param(ccnt, int, S_IRUGO);
复制代码
* f8 U3 U$ h* ~6 P) W6 T. y! t1 q
$ J; V/ V, m" h2 I0 C8 ~ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ H9 o2 p( j$ V4 K" S, farm-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 S; N o% }0 L3 K5 \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, K8 i- n* P; f! A4 `& H
1 G- N% y" J/ D+ B! O% T6 t. d4 F0 W9 y3 v- d' ^2 U: F, \
|
|