|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 d. Y! V% W( x$ E7 a2 _ o
- [code]EDMA sample test application
) V# J& K% g) K# [1 x9 n9 i - /*
+ K6 `6 b6 U8 P+ b& H+ u+ U - * edma_test.c
5 L* t2 \( V' G# t - *# c( {. i2 s" \/ Q- E* f" [
- * brief EDMA3 Test Application
5 @- C; _" U* c0 [5 ?0 } - *
& t: S W- K" ^' ?$ ] - * This file contains EDMA3 Test code.! s; Z& @; {8 Z( }5 n
- * M9 g2 g5 X1 H: A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* k1 J4 `& }# f* t! f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 a0 u0 g9 G( T$ f5 _4 P9 G: d1 L
- * TO CHANGE.$ M4 d+ S, S8 R4 j! }
- *
h, s$ o3 D+ H) M1 r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! t5 U' A* M ?. F0 C& F, x; k - *! E& f7 M0 [- A
- * This program is free software; you can redistribute it and/or
( t8 L \; I, d, ~ - * modify it under the terms of the GNU General Public License as
( n2 p7 c6 a( n6 j* j - * published by the Free Software Foundation version 2.1 Q: z2 N1 ]( R- x( N3 q+ ^ T( i
- *
# y; o# y9 y% z& I0 {- a0 h5 O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# ]3 N2 C# h' R8 j- A( g3 y - * kind, whether express or implied; without even the implied warranty
$ \3 k4 `7 I" `' r) T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& D) p" ^/ ~+ Y9 p4 A) M. W% x
- * GNU General Public License for more details.
0 h- b: f0 C6 O. L& V; }& ]/ q - */) m- }7 Q; x3 [- S* Q8 a7 J, ?2 T* V
- , [8 r- E3 ?5 T: A) _6 ^
- #include <linux/module.h>, H, W1 Q' K) S5 }+ E- U
- #include <linux/init.h>
$ G5 e5 m$ @- ~- J" c! G) j - #include <linux/errno.h>( Z; z$ n7 V5 |: S
- #include <linux/types.h>
( U9 o3 y5 V! p5 T9 F - #include <linux/interrupt.h>$ t# f' y" y2 y2 B
- #include <asm/io.h>
4 Z$ E3 o2 t' U* X4 m - #include <linux/moduleparam.h>( g j5 A/ j9 g {1 a
- #include <linux/sysctl.h>& N5 J: E: g- G0 _. v( M2 j) ~* o
- #include <linux/mm.h>
6 } Q3 J( z- i9 l k! t - #include <linux/dma-mapping.h>, k6 x& g* o5 l: X8 p' Z3 H' v7 E
- / {5 E, }6 c' N( O1 b; Z% }
- #include <mach/memory.h>
8 B) v# U7 k0 V( @- ? - #include <mach/hardware.h>; j1 a( R, E! q( w" M* _
- #include <mach/irqs.h>
% f/ P. ~' Y- l W" d6 n - #include <asm/hardware/edma.h>
1 n$ a; ?# Z' o$ {3 l# S6 m' g - 3 ]7 q4 I5 m) H- R, n9 r$ R
- #undef EDMA3_DEBUG& c; _* @$ _# k. v# t# t8 p# r8 O
- /*#define EDMA3_DEBUG*/. r5 F1 _# J, _. V6 p" m
- ' Y# ~: [0 N9 S
- #ifdef EDMA3_DEBUG _: C, ?5 M& K2 z& o5 R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 c2 B6 [+ ]5 Q- m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 K7 B C; t% {/ N8 g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; X% [+ U; B0 H. ~ - #else
' ^8 _8 H+ N/ k: a - #define DMA_PRINTK( x... )0 T* W$ \0 ?/ p$ I" H
- #define DMA_FN_IN
?/ e2 ^: a1 ^8 O" ~. | - #define DMA_FN_OUT
' R% Q; ]# B8 g) @ - #endif
6 Q( f. c" J: Q" y! K - $ H( z" R8 m9 L9 c4 ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! X0 @# k; _+ v+ `' i- N - #define STATIC_SHIFT 3
0 ]; r- U7 C* [% j: J - #define TCINTEN_SHIFT 20
$ {# _6 z2 L U: W/ O% }! D - #define ITCINTEN_SHIFT 21
3 q8 S' E k" {$ m& d; ?' T - #define TCCHEN_SHIFT 22& l+ H7 v$ W. q
- #define ITCCHEN_SHIFT 232 |1 @& E" b* i! P/ S& \9 d
/ j% a2 C8 Z n& }% |- o1 s3 l% I- static volatile int irqraised1 = 0;
& l) w) K, q; g* q( _& p - static volatile int irqraised2 = 0;2 A4 j) O p' ~) q w% j. e
# S+ K# z" N. x3 e [3 |/ o; b- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- Y: |7 H% x$ Q/ y& x" K - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' a4 d2 }' S/ v; B/ L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# u# V: u, J# _8 e# O2 N& h - , B3 P4 H" T5 {* |' I1 W
- dma_addr_t dmaphyssrc1 = 0;
$ @' Q+ s6 t( W3 P' h - dma_addr_t dmaphyssrc2 = 0;, z* _2 ^: f" W+ ]$ v! {1 z- w3 F
- dma_addr_t dmaphysdest1 = 0;
' a0 c1 \. C( J+ |/ X9 G - dma_addr_t dmaphysdest2 = 0;
% P2 V! q+ g, z
& h t$ C# n9 P- char *dmabufsrc1 = NULL;' }/ d7 ^" d) f' t1 g( |5 Y& u
- char *dmabufsrc2 = NULL;
) z& U& z A2 V% r3 o: Y/ h5 v6 _- Z& g - char *dmabufdest1 = NULL;
# `: h5 f- `0 Q! x" z( X - char *dmabufdest2 = NULL;$ h% I& N+ D# Z! T" S$ U
; n" E$ n4 V8 _3 H- static int acnt = 512;
- c3 o7 M$ U# }5 V - static int bcnt = 8;2 S" \: T# U8 f0 @, Z3 I
- static int ccnt = 8;1 F/ ~) t$ D" m
- 7 k" a1 E3 R. B; Z
- module_param(acnt, int, S_IRUGO);
3 u6 L F' C8 b b - module_param(bcnt, int, S_IRUGO);
5 U$ Z( l7 g2 S6 k8 R/ I# P; q' _ - module_param(ccnt, int, S_IRUGO);
复制代码 . A; D% w5 p! R0 A; ]
- [! x/ F0 \# ^0 g6 H0 B; P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 J3 C5 ^5 r/ g, z1 B [" b f8 p
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 L2 R3 {' H1 ^ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) ^( I: d/ V5 T3 X. h3 U. D& G" G
3 p% g9 p% v) T; P1 d# p
& K% j$ j. V* m( g* z |
|