|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ R! @# C0 L9 C! x- [code]EDMA sample test application" x% m) {/ Z+ p; j
- /*
6 \& ^+ X6 b* M1 c% ` - * edma_test.c+ o) u2 |3 F5 y+ h) k. l; S) p+ W- Z- i
- *( o% o8 n8 _& `( P9 e" c
- * brief EDMA3 Test Application
$ M8 Q8 N j7 k# m/ E7 _0 l - *
7 I, i7 M- ?0 h7 \ - * This file contains EDMA3 Test code.: V0 O0 ?( h2 C9 f2 J
- * \" n, n/ z/ F, y+ p' g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 b4 h0 P! m2 }0 d! O6 D! ^' z G/ } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 v1 t* O# o! z$ t! T/ n7 ]
- * TO CHANGE.
0 u; |7 \5 Y9 P0 G, v9 T - ** M2 m1 }) `8 a, R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 `0 D% I: U5 l5 p: C
- *
6 t, p" ?, V; x: q1 Q% F# H0 X - * This program is free software; you can redistribute it and/or
$ S: t% g7 F6 v - * modify it under the terms of the GNU General Public License as
" u) i# M0 f+ j* E3 o0 ?0 `, N - * published by the Free Software Foundation version 2.& T! C# [/ K, P* [$ o
- *
0 V+ Q) p" B$ [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 p! K% n' t* G; |- [ - * kind, whether express or implied; without even the implied warranty
/ I/ O' q, R6 h8 k2 [; @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' l, L* f3 s. X - * GNU General Public License for more details.
: q& |6 w5 e8 r3 x$ Z - */: d2 q: c' c: q) x, z2 ?
) F8 I9 O9 W" y9 E4 }3 w5 |, G: \, Q- #include <linux/module.h>% g0 E% B, A8 l( z& J
- #include <linux/init.h>
9 N, U! i2 [; a0 r8 j1 l - #include <linux/errno.h>+ l4 `/ n) {4 R4 Y3 M5 b3 q
- #include <linux/types.h>
+ \& v7 @5 E9 u" p$ e - #include <linux/interrupt.h>
- Y' Z: \5 f8 q# U - #include <asm/io.h>
8 t9 R1 |% P6 d _ - #include <linux/moduleparam.h>
$ r& a6 L4 o$ c7 y - #include <linux/sysctl.h>
" O0 p; A; M' F: g* A! J - #include <linux/mm.h>0 i9 k/ N3 }! S8 z# A7 K
- #include <linux/dma-mapping.h>+ M! L( `; J' U: U0 Z
- 6 k/ Q) ~: M" z( Q, D/ {0 X' |
- #include <mach/memory.h>" i9 j$ |- t" ^4 f
- #include <mach/hardware.h>% J3 H4 B/ y$ s
- #include <mach/irqs.h>
$ j7 m4 E5 c6 @, X+ } - #include <asm/hardware/edma.h>
5 ]9 n5 ^7 X% v/ U7 p1 Z7 z( Z - 2 _' v* g3 ^: A$ U
- #undef EDMA3_DEBUG$ W4 ~% _3 |% K, y
- /*#define EDMA3_DEBUG*/
: y2 X- H+ ?# |# `* f
. F7 [1 B, q5 X- #ifdef EDMA3_DEBUG2 V( E8 j: b4 B8 Z" @6 d
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& `- a7 j/ _4 b" k( G3 r7 y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; x' i* L; b* b; {* M! e( g( f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 e* K* [2 ]- W- f8 E* N - #else
9 I! f [" M! n% U# d - #define DMA_PRINTK( x... )) h/ z2 I% \( i" ?& B% V" S6 y" ^
- #define DMA_FN_IN
# ~5 j, U2 u7 s' h. q - #define DMA_FN_OUT
0 |( A+ l- x, C4 Q. {+ B - #endif! u! v. s8 d2 t& u3 G# |/ V
- , o9 q5 ?* ~. D0 ?+ j* s) ]: @4 o
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( Z* e n7 ~; k7 _! q) K
- #define STATIC_SHIFT 3 w+ H5 X1 a0 v; f3 N4 ^+ f1 w. j- q
- #define TCINTEN_SHIFT 20( b$ O. G2 O$ G3 y
- #define ITCINTEN_SHIFT 21
) e% P/ f3 S, C0 @& K1 [ - #define TCCHEN_SHIFT 22
4 T2 k+ |( O! _) |8 ~ - #define ITCCHEN_SHIFT 23
0 X8 `) S4 d+ {" l0 Z* U - ; Q' b6 ^ V- [7 R$ x* `8 p
- static volatile int irqraised1 = 0;* r) e" f& \- F, Z/ d
- static volatile int irqraised2 = 0;1 B- R H1 Q7 R0 V& W! J$ b" o+ J! z
, S$ |5 Z& ~4 Q% `3 `- B& h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- c- o. ^& x( v1 P - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 `. A. g) B7 _* t2 ?+ L0 \0 J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& V! t4 H3 e5 ^/ O4 m& Q! x
4 L4 m+ V+ h! Y- r0 S2 p2 k1 y- dma_addr_t dmaphyssrc1 = 0;, i. k( \# N7 V
- dma_addr_t dmaphyssrc2 = 0;" ?4 U! D3 [/ k1 i( K& i( C
- dma_addr_t dmaphysdest1 = 0;
: I& e* l# f- s2 ]1 y - dma_addr_t dmaphysdest2 = 0;
/ U( @7 b- [6 R
+ w5 }) h O6 }% |- char *dmabufsrc1 = NULL;
2 Y M5 _5 A3 `7 | y - char *dmabufsrc2 = NULL;
4 g/ u0 T; V7 z - char *dmabufdest1 = NULL;
+ Z4 U" J1 ], @; J% W- { - char *dmabufdest2 = NULL;1 A& y/ h9 x. o4 N% P( G# i2 f
5 r: q$ {$ K+ l! ^: E- static int acnt = 512;
8 z: |. o3 R% E" E - static int bcnt = 8;
7 h$ h6 L- o1 }2 s - static int ccnt = 8;
6 E& R& A: B5 j0 w. l+ X D4 c4 ^ - . \" l5 J3 Z$ e$ I$ T
- module_param(acnt, int, S_IRUGO);0 k# e3 o9 N% b
- module_param(bcnt, int, S_IRUGO);: j3 c: A, l. U3 ?$ ?
- module_param(ccnt, int, S_IRUGO);
复制代码
" R2 t3 m% W6 S, N) y1 i8 b( b5 O% S: s' |& y! @. S
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! E4 E" B* Y1 o zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 E: P# ]3 S8 R8 q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 `5 D1 L- v2 Y7 w ^
% b0 W$ }. ^: y1 O* B6 {. |/ x0 G; `; k
|
|