|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - m' {; ~5 j/ {
- [code]EDMA sample test application
G( O2 S# {9 X" t8 p& S* N4 m - /*
9 G) z }. B* p; M" [' p) B8 T - * edma_test.c( A1 O8 G. e& g5 ?9 p
- *5 W/ l; v3 j4 ?5 O4 d# _6 |
- * brief EDMA3 Test Application
& X, v |# B2 C" w. h+ o8 } - *
# ` o8 `* p; k# K+ t0 H - * This file contains EDMA3 Test code.& L$ F! x8 G& F3 _
- *4 w' ` L) G7 l& G; o- Q2 @" T5 ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 j9 `: U' ]- @* O v( |* `. u3 B- d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 p6 Z& B2 Q+ e/ R. F/ W
- * TO CHANGE.4 t& D7 [' k" X8 }0 w7 Y
- *
6 e7 P3 N) S0 s) Q* f( ]5 h1 H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' b7 R6 y* X& ?1 H" | b4 x2 r* y - *
; ~6 E3 k; M9 Z2 Q5 D3 @ - * This program is free software; you can redistribute it and/or
+ E* v! }3 y2 H2 a. R: m! p% x. G' s - * modify it under the terms of the GNU General Public License as
% I6 [9 x: E' S - * published by the Free Software Foundation version 2.
) x( B7 r( g% Z' r0 H# B - *
4 ~5 N: _. @" _3 e f0 _* R z3 m# j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% R* t0 K9 ]+ z' P, m6 u1 U
- * kind, whether express or implied; without even the implied warranty$ X7 t# u Z2 N% {5 t8 y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( g+ m5 R; {/ c& _ K - * GNU General Public License for more details.
0 i% D8 I5 A/ ]* F$ W - */
- b2 c" ?+ ~) g$ ?. c, r - ! `( r( `8 A4 e, D& I
- #include <linux/module.h>
- |4 b, S3 t; p; P- {( i: k - #include <linux/init.h>
' V( l2 W6 |' i0 z9 k3 Q - #include <linux/errno.h>' N8 h% k0 h$ |% I$ a7 V% Z! ~# F; |
- #include <linux/types.h>
% y. F p- N) n0 N* q1 O3 y - #include <linux/interrupt.h>
! r h( z3 G& A2 `5 C" z - #include <asm/io.h>" r) Y& g& s1 ?
- #include <linux/moduleparam.h>
8 c$ g2 V, f: g* n) x - #include <linux/sysctl.h>
* N* J6 d: m, I - #include <linux/mm.h>. j+ L& D9 X" }; S# n- p- t; Y- `
- #include <linux/dma-mapping.h>( o) Y* i& P; Q
6 o+ Y) t p0 ?5 E4 s; }8 B% i- #include <mach/memory.h>1 w; Q. I5 I# N# }" _0 L6 C
- #include <mach/hardware.h>6 e t- |$ W: V" b" E% |
- #include <mach/irqs.h>) ]: B, H; P2 f
- #include <asm/hardware/edma.h>
+ H: o2 R q9 s, H
9 z1 J+ W+ l' ]% J% j* _# f- #undef EDMA3_DEBUG
; v3 ?+ M' d: z% t- `2 t - /*#define EDMA3_DEBUG*/
& t7 b% A5 }) x# ~+ b - ' h. O* C, w0 H
- #ifdef EDMA3_DEBUG. M8 g" Q+ ^! c7 p% [+ n' y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 g/ I( ^: } t* h: J* o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
O; a$ M* x( x7 R/ W( ]0 ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- O4 x$ G- d7 f) n - #else
& T4 i' j1 [; }% g+ b! r) t& @ - #define DMA_PRINTK( x... )7 j% ^/ f" H& k/ n$ @4 c3 A
- #define DMA_FN_IN
; H* E- c5 r; X. e - #define DMA_FN_OUT% u4 U' H3 l7 S, y
- #endif6 c" a i0 y- \- |. {
* O, b4 }, V" J5 |' z$ Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# e$ m( y) w" E0 B4 w) g2 Q
- #define STATIC_SHIFT 32 f7 i- j1 j; v
- #define TCINTEN_SHIFT 20: k$ Y/ y4 S8 C, S/ O
- #define ITCINTEN_SHIFT 21
- k$ h, _; i; q9 \: K - #define TCCHEN_SHIFT 22
( i% ?, i* }5 f5 Q5 q$ A - #define ITCCHEN_SHIFT 23; M9 O: S) u1 S: A. ? [/ [
& T, d. h$ Y; ]- static volatile int irqraised1 = 0;$ N5 a/ ?* j" z9 Y8 C+ U* R
- static volatile int irqraised2 = 0;
& T8 |9 x: s8 f
0 b* j+ Y' Y9 d6 P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, w {, D! p: E- V5 K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ D; j4 a) H( l5 Z) M
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& U0 [! v& u+ M$ {, T/ M# [
/ \' ~! U2 t3 D6 f1 D0 s9 `- dma_addr_t dmaphyssrc1 = 0;
1 k9 @9 d$ H i+ i) n - dma_addr_t dmaphyssrc2 = 0;( Z" t& X& P6 `7 q
- dma_addr_t dmaphysdest1 = 0;& p$ N0 I% C; b8 H5 i) @. O1 J5 W, r
- dma_addr_t dmaphysdest2 = 0;" ~2 }' `- g0 w* f( \
- " i2 X0 e: w( c7 V
- char *dmabufsrc1 = NULL;
4 ^% G( O3 a# p0 l+ \ - char *dmabufsrc2 = NULL;0 E9 k, Q- f# p/ [. L
- char *dmabufdest1 = NULL;
# u0 C n8 f# ~- M l8 Q7 r - char *dmabufdest2 = NULL;
. S! v# S& V$ O' w7 e+ A
- y4 J* }( a0 m' R V, X- static int acnt = 512;2 s/ L! C' j" `3 J& o/ D) l, N: L
- static int bcnt = 8;
* {, v5 v" l: X [2 { - static int ccnt = 8;
( D: v$ H+ Z+ z! L; j- j" j4 y - / C) d: Y# t( M9 R
- module_param(acnt, int, S_IRUGO);( |+ {3 V9 L5 J
- module_param(bcnt, int, S_IRUGO);8 `- s, `9 W7 E U, `
- module_param(ccnt, int, S_IRUGO);
复制代码
}/ v0 ]' x. G, D9 E6 J) q( M( _4 r/ [( c# |: r& d* i. }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 P1 M: j" F% m8 x4 Q/ S6 U4 {6 d
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" U4 ~$ O* o2 |0 {3 P7 z6 q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
\1 |+ F8 }. Y4 p
2 N/ z! t a2 ?- K$ _) u' h X6 f8 J% ?! F
|
|