|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( z9 E }( O) Z- h& b. ?8 p i- [code]EDMA sample test application
. x* @4 ^* X+ [/ Z - /*
3 B; \6 h4 C1 W - * edma_test.c
' L9 V$ ^6 n% L - *
+ o! d, C# S) C2 J g - * brief EDMA3 Test Application- K* N9 U5 R# C$ ?: U& q
- *
% M- m9 m; a9 M" r3 o - * This file contains EDMA3 Test code.; }2 b3 s9 A6 ~2 x
- *
- j$ F2 Z, S7 p, x- w6 o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% g0 A; \+ F! _3 B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" s" C0 U- O6 T+ @! t3 A7 \3 ^8 j - * TO CHANGE.
3 ?3 ?0 k" D) h" d- ^ - *
' ?9 m7 d: k# l' u4 U" E: q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) R- V( y) m! Z. W& U- \
- *, \0 X5 `" x* m; x: x
- * This program is free software; you can redistribute it and/or
2 {; p$ j- n) J* z - * modify it under the terms of the GNU General Public License as
' ~$ N, [4 I6 u# Q( ?% U+ b - * published by the Free Software Foundation version 2.* E4 f+ Y- Y' Y7 \4 j6 d7 ^
- *& B3 T! V h& ]+ h& ?& Y: o/ `; L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- g6 O) _2 Z4 ^4 u - * kind, whether express or implied; without even the implied warranty
8 b4 K. v. Z3 h. K% C: ?" w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 I$ p7 R3 V1 N7 E( I4 E) M
- * GNU General Public License for more details.% @ O4 a/ V9 E" F% n+ L
- */0 @2 |+ U* ?6 e) v6 o1 y
- % i) [8 @8 }, Y7 i
- #include <linux/module.h>6 E0 u" g9 G1 U4 l3 w
- #include <linux/init.h>; G- O2 E& V: r" \
- #include <linux/errno.h>
) M: V. @; c4 Q, _ - #include <linux/types.h>
v1 V b9 |% u - #include <linux/interrupt.h>$ p) O2 L; V2 F0 I& N
- #include <asm/io.h>' P! h' z2 E) p z* F) m% O7 k# v) [
- #include <linux/moduleparam.h>
_: Y8 }0 b3 ~* k! o - #include <linux/sysctl.h>
0 u9 A1 P. a. G$ C - #include <linux/mm.h>, a( S! y! G: m; Y' n* ?0 M
- #include <linux/dma-mapping.h>
1 H0 C% O# r) V - ' F' Z0 I+ i$ h. J. x* h
- #include <mach/memory.h>
y1 ~" Q8 ~, R$ f* E8 i - #include <mach/hardware.h>6 g& p0 W; W; I5 \5 n( ~
- #include <mach/irqs.h>" p$ y/ O1 o3 v# \, \1 z3 _
- #include <asm/hardware/edma.h>
@0 e$ `0 f/ N( ?+ Q+ w - V" V% ?' w- l: h0 i
- #undef EDMA3_DEBUG
: ` _! c: M3 j- i4 g2 b" w3 D - /*#define EDMA3_DEBUG*/
5 D$ n2 Q7 G' u, g' K7 l4 s% q
7 C3 q: x" \3 j6 l* O. z( d, E- #ifdef EDMA3_DEBUG
, j! {* N2 v; I( W! Q# i$ v. c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- f1 s" X# o% N( ?1 Q3 \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, j/ e' j0 p9 ^0 D$ n m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' t# _% X" U5 I) Z+ f - #else
3 I; q) d6 R/ g% @ - #define DMA_PRINTK( x... )$ I2 I/ F9 O. t' Q5 J& L
- #define DMA_FN_IN/ W: K& G U) O4 z
- #define DMA_FN_OUT
; L) ?$ P, a' Y R+ d7 S0 | - #endif6 T- P8 B0 k, T/ y' S! A
- ?2 \: Y3 q, Y, `0 b- q- #define MAX_DMA_TRANSFER_IN_BYTES (32768). }5 k8 ?. @% N! e( t
- #define STATIC_SHIFT 3- v$ }) ^4 o+ R' x
- #define TCINTEN_SHIFT 20( O( k5 V0 Q5 E/ { A
- #define ITCINTEN_SHIFT 21
+ g3 |, \2 l- M! m! T$ _, H0 y( s" D - #define TCCHEN_SHIFT 227 N# K- ]. x: m8 o
- #define ITCCHEN_SHIFT 234 O) R/ r$ K' D4 J
- ) e# s# R1 p4 {4 D% _9 [
- static volatile int irqraised1 = 0;& b9 m L0 k2 ]
- static volatile int irqraised2 = 0;
3 k) y# A0 t% L8 N: T7 y - 9 I- K% H Y4 I# v, p* t% g3 p0 f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% g6 J5 R5 p- a, l$ ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 _$ n K& p S; _( f0 ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 ?( ^2 X. X+ M5 \5 T2 Q
) w' H, z! }9 N ^" _& s0 x- dma_addr_t dmaphyssrc1 = 0;
+ g9 X; h! }: D. _6 R - dma_addr_t dmaphyssrc2 = 0;
+ F! p* E$ Z. ` - dma_addr_t dmaphysdest1 = 0;+ ~3 r2 ^! p2 o3 t* @0 I
- dma_addr_t dmaphysdest2 = 0;" H' _! w& N" L/ Q0 R- F
, X* G0 q; h M; `- char *dmabufsrc1 = NULL;
3 C. [' k# j! { - char *dmabufsrc2 = NULL;! d1 k5 ?: y, y
- char *dmabufdest1 = NULL;5 y; j! u. t; J, B# P# n
- char *dmabufdest2 = NULL;
% t2 s7 s( U$ A& M - $ m' w$ q( D$ v: o3 v6 Q3 y
- static int acnt = 512;
4 _" d( v" `- v6 V1 r6 i5 r) k - static int bcnt = 8;
+ L z. H# W, x( p% ` - static int ccnt = 8;$ ^* {/ F) e. }
/ ]! k6 g F0 h( h- module_param(acnt, int, S_IRUGO);, U7 d6 v' J1 j
- module_param(bcnt, int, S_IRUGO);
0 d) M+ B6 `2 _" r$ Y5 q [ - module_param(ccnt, int, S_IRUGO);
复制代码
0 D z- [4 M1 @+ H) O" b# m
7 E0 Q; d, v, p" d* z# e B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 q# A6 Y! i+ w9 @1 V0 ^
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 u+ H& u. G# J1 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& H! W9 e7 N# {7 i( m/ W
% e1 V2 g8 o5 H# a" {
3 Y! A: W; E- Q: b2 N |
|