|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 F5 }% E, j2 F- [code]EDMA sample test application
* k- r p, B5 i; T0 a - /*
) B+ r7 d2 s! O0 F - * edma_test.c+ ?1 ~% Y1 f9 G* ^( G% B; [" y
- *
) c [3 ]5 M# B3 d - * brief EDMA3 Test Application' n5 ]0 p& x* F" p+ J, c9 M4 B
- *
, V$ X7 p( c: v1 e( t7 ]+ }- D - * This file contains EDMA3 Test code.: u3 P3 U3 M. x& k* ~) }. S, ~, c
- *
% i4 _- a3 ]8 \) x- ~! N& y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& L, Y* |+ \) q( j& ]+ L" e, P: v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 V0 Y, A. ]1 h% L' `( Z V
- * TO CHANGE.7 |; e+ V8 k: @
- *8 Q% s. Y* X2 t% N) Y" U9 K0 G! \( g
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! O& u @, ~( D2 r5 [0 p
- *5 O, G, B4 x' l; {. E
- * This program is free software; you can redistribute it and/or2 I3 x, J! ^! U
- * modify it under the terms of the GNU General Public License as2 w; y6 f, W4 ]; i+ R
- * published by the Free Software Foundation version 2." o( W$ {- R# \4 I( q; A
- *2 }: z: c* ?5 h* w8 j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 w. n, y% p x/ C* J$ w
- * kind, whether express or implied; without even the implied warranty
6 ^, B W9 Z' A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 t% d2 L6 H: F$ Y i9 D: S1 o" P
- * GNU General Public License for more details.3 A+ p! t/ ?3 b1 O& d; ?
- */
7 N; U7 V) K' G# e# D- I
% l* ^. w$ q! e$ z& k- Q* j5 S& P- #include <linux/module.h>6 j) e" S/ T$ K+ T- l+ n4 p, v: h# e
- #include <linux/init.h>" n5 e1 P5 L' P. V' M
- #include <linux/errno.h>
9 Z: Q) A. N8 y \# r% G" d - #include <linux/types.h>2 G7 \* B+ A8 `+ }: ]
- #include <linux/interrupt.h>
* h% J* x/ r( v: g9 p - #include <asm/io.h>. ^9 J: ]1 d/ n) t2 K, t
- #include <linux/moduleparam.h>: `2 h. e1 C( K& ^7 G" w4 ~
- #include <linux/sysctl.h>
+ E0 Y- b& x1 V* P - #include <linux/mm.h>
( \, L* f* b4 j - #include <linux/dma-mapping.h>
8 o9 r# [7 h5 ^- V1 ^! `, M7 V$ Y) j - 4 w2 @# Z C/ {& @0 Z
- #include <mach/memory.h>
# l {+ [6 u6 U - #include <mach/hardware.h>7 ~& K/ P" D" J# u7 E3 ^
- #include <mach/irqs.h>8 ]( R% `- L4 _9 F/ z X, f
- #include <asm/hardware/edma.h>' x0 `/ _3 B, m6 x
- % J0 Z; \! T: H0 p
- #undef EDMA3_DEBUG
$ Y( i$ l4 _! E - /*#define EDMA3_DEBUG*/
5 C% V) c/ m; G$ ?4 S, R Q* Y
/ I9 A. N- P; G* f/ a' w- #ifdef EDMA3_DEBUG3 m0 I' \/ v3 s% z5 N7 ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). N6 b0 }& g( C2 ~$ M
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! n: D5 H. _. A; |$ r - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) K& i5 U# A( S" W# [/ g - #else- ]! N- k* u1 u/ g9 z% H, B
- #define DMA_PRINTK( x... )8 n- a6 K6 o. l, w( ^' ^1 Q4 y
- #define DMA_FN_IN
* c6 V) q4 ?- x' Y - #define DMA_FN_OUT
( _, @. V$ @) M" ^7 [; J' F - #endif" w4 I5 t" M, {
* G6 E9 d; T$ ]# l+ o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% }$ c) O) o4 T$ q+ [ - #define STATIC_SHIFT 3
0 _' h( z# G; n3 w, {( q - #define TCINTEN_SHIFT 209 V4 w- L& g* b* F) I n3 i' U; w
- #define ITCINTEN_SHIFT 21/ M2 w& Y3 F/ s3 }! C
- #define TCCHEN_SHIFT 22
. n3 ]1 P! Y* |' n - #define ITCCHEN_SHIFT 23" ?5 k! f+ F% }8 T8 ?9 {! g
0 ~# ]) { m, b- static volatile int irqraised1 = 0;$ o; a+ i7 L& N. A
- static volatile int irqraised2 = 0;
6 d8 v9 \" _9 ~% ~ - / W3 F9 `, S# y- z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' e' ^7 N9 x) O2 D; G6 s) E! w" _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 W' [; S! R9 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* H# O3 ~* }5 U/ }2 _8 k$ {& ~/ B" x - , V9 w' f0 ~( O+ h3 G: a. m, p0 J6 j
- dma_addr_t dmaphyssrc1 = 0;/ F9 c' K7 X$ Z/ {! |4 ]+ y
- dma_addr_t dmaphyssrc2 = 0;7 c3 ?# w) j" C# Q7 c! i
- dma_addr_t dmaphysdest1 = 0;5 ~, l: V( j& L2 P, A! v
- dma_addr_t dmaphysdest2 = 0;
6 l4 f8 E+ [. P1 L1 N5 w2 m
1 r) ^; x6 t/ o- char *dmabufsrc1 = NULL;
3 m9 Y* I: D7 M, i - char *dmabufsrc2 = NULL;
, I/ L; ~# v0 j8 G - char *dmabufdest1 = NULL;7 w6 R* D$ Y1 ^# q9 m
- char *dmabufdest2 = NULL;+ d0 s* B9 g' ]1 G
- 7 E( s Y0 ]# z1 e
- static int acnt = 512;
) @' z: n* E @! B! K8 X$ G - static int bcnt = 8;# C3 Z4 H3 u$ N8 d9 Z7 M( u
- static int ccnt = 8;. O i- [( V' J- h$ K, R$ ~
- * C' N, e' ]8 m; ^/ K6 T- J" x
- module_param(acnt, int, S_IRUGO);# Z# m, `! n n# x3 e# V e4 z! w
- module_param(bcnt, int, S_IRUGO);
8 v! S! U5 q$ N6 L& _8 Q; c - module_param(ccnt, int, S_IRUGO);
复制代码
# S1 J0 C$ W* `/ V/ d! Q, M$ e) G/ h: [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 h5 d" c% p( U v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 `; h5 `+ j3 R- Q. {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 l5 @' s. l: S/ a! X5 L: x0 i) N" h
4 L5 {4 U* b" |* u: T; v* b; @ |
|