|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 d1 w" Z8 A1 a( @0 X- [code]EDMA sample test application
0 Y! D$ f V& E. R) J2 |/ N - /*
: c- J- y" h% t4 I; @# |2 O - * edma_test.c
9 k# U$ y X; ^2 V - *
9 i: s' ~6 V# `9 G4 u - * brief EDMA3 Test Application
; C* \/ e) }$ `) c - */ G E- n! E; U t" U$ |( }. i
- * This file contains EDMA3 Test code.; L5 c9 N: @) h. ?3 i$ G
- *1 d$ E, M) w" X. w {' O5 `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ f. {: J# v7 o( `/ M+ Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 k4 Y$ X1 R! H; I; l4 F" q! N6 J
- * TO CHANGE.5 j, I5 u7 f- Y2 \
- *1 C) z. A$ Z' a& U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 K Z9 e. |' ?6 I - *2 _( H' K+ o# v$ x' P* Z+ L$ _
- * This program is free software; you can redistribute it and/or7 d! l( A9 T4 D! G" s
- * modify it under the terms of the GNU General Public License as
; g- n2 W2 d3 d* t% W0 W8 i - * published by the Free Software Foundation version 2.! s! [8 X2 k( n) f1 d ]: t6 o
- *: d8 o. e/ J8 i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 d$ F$ p# \5 \% ^/ L - * kind, whether express or implied; without even the implied warranty
& j! _) w5 v9 Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 S. ]0 m" u4 ~9 i2 K - * GNU General Public License for more details.: t m; u9 @* B) `% j
- */
7 X1 m6 s+ K' g% L+ Y$ i; M; N" P
% `/ ?7 p! [3 q7 {) Z- #include <linux/module.h>, T! G6 G3 { W) W& B% U: o
- #include <linux/init.h>
& P$ [$ q. \) E# f: @# z- Z - #include <linux/errno.h>
* P$ }; o4 F0 L" ?; s4 T - #include <linux/types.h> O( H/ J1 _6 ^; z0 g4 N
- #include <linux/interrupt.h>) G% v: Z5 T$ ^% J
- #include <asm/io.h>
& n5 B9 u P' `; E8 Q) P: a - #include <linux/moduleparam.h>$ x' a5 O3 C# ~( ?% a
- #include <linux/sysctl.h>
+ D) V+ o: N+ E5 x5 W) i& M) e - #include <linux/mm.h>0 F; z* f( u! t1 C% v* l7 ~
- #include <linux/dma-mapping.h>8 z7 H. E- k6 e! B4 n/ W5 M
) I& X& c: g( {% ]% D" f- #include <mach/memory.h>+ j, E* d, y! V0 y" m7 s* l
- #include <mach/hardware.h>- n4 S" r4 p& t% K" {( S+ g
- #include <mach/irqs.h>
( Q! O" \$ {& j: h - #include <asm/hardware/edma.h>
& C, \4 M8 H# H* h. y - : m- f, M! n4 h8 b, J% H; a
- #undef EDMA3_DEBUG
8 E7 Q: z$ T: F# Y" M# a8 }5 o3 h - /*#define EDMA3_DEBUG*/0 f, Z8 p2 A) }+ p
: T1 m0 Y6 ?4 F' }6 Q- #ifdef EDMA3_DEBUG+ p+ l3 p A3 t. c$ `) B! g. u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); r4 x$ t) R) I+ f1 a! d
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 h6 b! T) Y' d2 e& @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- `! g! w$ f; F$ l2 G" k0 o# H - #else, ]! W% q9 _) T; z* r
- #define DMA_PRINTK( x... ). F f) w8 z9 ^
- #define DMA_FN_IN
6 ?! r: D" x) [6 s; u4 D ` - #define DMA_FN_OUT
* b( z% K5 \3 O; o - #endif
& E1 `& h3 K, v' J' p( h - 8 y/ N" {. U7 D$ _& h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, C, q7 A+ {, Y8 ], T5 `! G - #define STATIC_SHIFT 3
/ u$ T: g$ t( ^" m6 T - #define TCINTEN_SHIFT 20
! ^3 }0 I' q5 d. {& p - #define ITCINTEN_SHIFT 21% h1 z+ C, r' L( z
- #define TCCHEN_SHIFT 22: \% z6 g- L% W8 m- k
- #define ITCCHEN_SHIFT 238 I, P& ~- c) p4 x
' j& L; G4 d! T1 H- static volatile int irqraised1 = 0;# `; _8 H5 W" M* Y$ B# q7 m7 _
- static volatile int irqraised2 = 0;
6 X/ p; V/ |3 z9 l+ G# y
P) [, v) U3 G; @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( p+ l5 i5 k2 R2 N j1 s - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 B% y7 g* o' O. k0 M4 ]: l3 ]9 Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 k7 M3 s8 B/ ]* `- J! T0 @
- 6 e$ h- t8 i9 F. G6 }" B/ {9 \
- dma_addr_t dmaphyssrc1 = 0;3 v0 r. k4 s/ o& q. h+ C) W
- dma_addr_t dmaphyssrc2 = 0;8 G' w/ X/ C3 Z/ ~( }
- dma_addr_t dmaphysdest1 = 0;& V$ Y2 p, x2 l8 P
- dma_addr_t dmaphysdest2 = 0;
, T w, {/ v. G& P0 z - 7 D) _! e, C! a: D- W
- char *dmabufsrc1 = NULL;/ K0 U2 z8 j8 h; L8 O, R8 Q- T
- char *dmabufsrc2 = NULL;. o" \3 q2 L8 P4 h) L; S" p
- char *dmabufdest1 = NULL;
. A4 H! U0 c4 P1 n1 h! m - char *dmabufdest2 = NULL;' Y0 p$ t6 ^. w' s
- % P7 C$ ]. R0 i; L% {7 Z
- static int acnt = 512;9 Q2 Y0 n0 G' y w
- static int bcnt = 8;5 V$ h# \* Z; [2 ]/ J g7 f: A
- static int ccnt = 8;
0 n p/ B3 n1 u6 @
* L1 `# b/ e: ?# H, r+ J: l2 q& V- module_param(acnt, int, S_IRUGO);
( f% q$ K1 O, C9 E/ f; W - module_param(bcnt, int, S_IRUGO);$ T8 d3 _ _8 K% {9 V
- module_param(ccnt, int, S_IRUGO);
复制代码
3 V" F, Z7 {: v
4 Z: d0 |- {- N+ L& e4 v7 \! y7 v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 a" Y6 w5 w, Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 M# `: Y6 U$ ]0 H9 g; X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 V2 J) f& d6 p, _
( B: A' j. s" q, e. b: `- x
3 e7 |# K. u/ L( l |
|