|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 C% Y6 H+ F7 C4 A2 s- [code]EDMA sample test application
) J4 _1 d$ O0 B, E: R2 e5 T6 R - /*
$ \+ S6 C& ] r/ j - * edma_test.c
$ D/ }( g6 ?, J8 b - *
* l9 L- T( y7 v" i6 l - * brief EDMA3 Test Application
6 {8 m3 x2 c1 @1 N& D: H, | - *
, N( Q6 M6 L7 G4 E3 ?; A# Q - * This file contains EDMA3 Test code.
* k+ a0 R9 n; N' ~- f8 ?! M# w) | - *
8 i/ d* t% _+ z$ N6 [- l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 m! s& ~% Z* D& y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 n# @, m3 B- z* O7 G; @3 ]1 l - * TO CHANGE.
8 X1 R* n) ^( y4 f' | - *' P6 W' N' D$ Z* h1 W
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) X P! ^7 b C2 V
- *8 q. V V; l) U/ Z9 J
- * This program is free software; you can redistribute it and/or- C- E9 m7 Z+ i W# _
- * modify it under the terms of the GNU General Public License as! V7 k' H J+ I) B9 U6 E8 C
- * published by the Free Software Foundation version 2.9 ^ @8 D. @6 K9 P. [: h
- *
" V1 @1 l. F* E7 [" b - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# o5 T% N1 k+ c, k+ o6 ~# s i& M - * kind, whether express or implied; without even the implied warranty4 n6 n, v: M# D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 d7 v6 T' {# B2 z8 ~. ^( l, ~. o: U - * GNU General Public License for more details.
/ S0 B+ I" I6 b1 d7 z - */
, T4 v: g! G+ E I
) w6 r- P' I% X% X- #include <linux/module.h>$ m( k0 b2 l* \5 a5 g
- #include <linux/init.h>
1 ^0 @; A6 S* V" V1 P; M - #include <linux/errno.h>
, a3 M6 |: {" g- }7 M3 t - #include <linux/types.h>% l2 n' e3 ^: @. ] a
- #include <linux/interrupt.h>6 J8 E6 ]8 t! i) | p' t# a
- #include <asm/io.h>
/ j! ]2 f7 d; H" w: j6 p - #include <linux/moduleparam.h>
+ j* ? C3 j0 @7 _0 n - #include <linux/sysctl.h>
7 O9 x6 p4 t( b! E5 z - #include <linux/mm.h>0 T' x7 X7 p) V: O: ^
- #include <linux/dma-mapping.h>1 F6 m. l7 _: K6 e; s; a1 `# S
- - N: I8 @ Q5 g _0 O0 C
- #include <mach/memory.h>
7 R/ ^$ \; x @- O2 |- m/ @ - #include <mach/hardware.h>3 i5 ^& j* n Q
- #include <mach/irqs.h>, ^! _2 C! V' A+ H6 }* T4 n' ]* g
- #include <asm/hardware/edma.h>
- Z1 Z! w0 j; \
* Q4 L6 R/ s4 I) `8 R- #undef EDMA3_DEBUG1 O) M) _5 X8 A
- /*#define EDMA3_DEBUG*/
# }% G( l! q1 l6 L
8 A, S( f5 N5 j6 t$ h% o4 F- #ifdef EDMA3_DEBUG4 ?4 ^9 w2 ~ ?2 ~% ^1 q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: b+ O: ]2 B) u+ z# g, y" ]$ b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 R9 ?! K3 d. ~7 E1 D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): [8 x" a- R0 y5 W& Y. ~
- #else9 d1 d, I+ U! D1 a
- #define DMA_PRINTK( x... ). E8 T9 s. e- M# w1 {
- #define DMA_FN_IN
_5 x0 k: h q h* `0 b - #define DMA_FN_OUT
) t' `4 A" m# {3 x. F$ b! L0 _ - #endif! N9 c+ Q, o# z4 ]
- $ ^* L5 s8 t+ o2 A2 }
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ C0 b6 G& a/ I& L" M# W7 X! w- J# Z - #define STATIC_SHIFT 3
" R3 O) P8 k# w9 m: ~ - #define TCINTEN_SHIFT 205 D% S& o7 r0 Z2 o' R
- #define ITCINTEN_SHIFT 21
& ^3 [" `% X( x- ` - #define TCCHEN_SHIFT 22. ?6 Q- K( i& a! p/ D
- #define ITCCHEN_SHIFT 23
4 Y. m H" j/ H+ z
8 j p" B& b# ^5 d& Y- G- L5 C0 g- static volatile int irqraised1 = 0;
5 N( s2 a+ E" s- K5 @ - static volatile int irqraised2 = 0;" B$ V$ e" {8 T1 D7 l, e1 R- X9 f
/ o: D2 H, ^9 H" y9 r( i8 [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 O: r: u8 t! J$ ^7 o" F - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: C" ~# G% l9 D4 o1 h' n/ | ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 C& ?4 P* h7 b( z - ) T/ j. ]& Z# b- X
- dma_addr_t dmaphyssrc1 = 0;
7 `; ~5 @. q( x* w - dma_addr_t dmaphyssrc2 = 0;
6 ]% ]2 f" |5 s* K - dma_addr_t dmaphysdest1 = 0;
" s/ w: t6 _9 C J/ `# ^% `5 ]) { - dma_addr_t dmaphysdest2 = 0;
4 f& q: E" k7 I - 6 y# |4 O8 u( p% o+ B( V' j! U
- char *dmabufsrc1 = NULL;
0 Y* X! n s9 L& M - char *dmabufsrc2 = NULL;
- }% U) h( K; q - char *dmabufdest1 = NULL;, c' U7 s# v& N& z: F* ~
- char *dmabufdest2 = NULL;
0 ]' p& i5 j9 v' `8 [6 E0 Y
" v2 v T; G0 `: j5 p# M( w& u' v- static int acnt = 512;3 W1 H+ P; f3 Q( y! i, B' h
- static int bcnt = 8;0 q/ ^7 x6 i: k; p6 N$ Y) h& x# ?! X
- static int ccnt = 8;+ n/ ~- E; l2 T+ O
3 ?) s* H: K: p4 m9 G% j- Z# }- module_param(acnt, int, S_IRUGO);5 K7 n# V) m/ R( d% G9 h1 y8 h; X
- module_param(bcnt, int, S_IRUGO);6 V0 C7 h2 M4 x% w4 H! E
- module_param(ccnt, int, S_IRUGO);
复制代码
7 p! J ^, \0 f: m8 n: I/ c/ f3 y7 z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 f. e) o+ Z* Y. f; B6 ]2 M
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 y% |0 M: A* N! a: Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, c; c' B% E/ U* D! |6 h/ [0 I4 t" n7 [# P) Y: ?( y) w
8 S% w3 D3 D+ o5 ~1 B1 Z& U$ \- H
|
|