|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 |% L, e' v1 m4 n- [code]EDMA sample test application
. |6 b# r P7 S& u; ^/ o! R; O - /*
- s/ e" M: p5 n B - * edma_test.c
$ N* V. i" b7 o6 p' `% A4 J8 t - *- ]' G' Q0 H0 D; j8 P1 s
- * brief EDMA3 Test Application
1 \' ]1 |9 | c- h - *! _# k: M9 L/ h% B' R
- * This file contains EDMA3 Test code.! P# Y; `- |: Y
- *
& T0 h! ~% r2 f% b: } - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 b1 g) o3 y* ~- U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 M- ~1 F; c' W7 i4 F. _1 d - * TO CHANGE.& [% Z0 `: P0 Q& s6 H' H
- *
p" g) @8 a" z6 j0 z$ b+ L( {2 q/ f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 [$ S- @1 _; w6 \ F$ G4 H) U
- *% r2 u( x% N/ l0 D6 d, M
- * This program is free software; you can redistribute it and/or
" _, r% m" i* s, w, _ - * modify it under the terms of the GNU General Public License as; x# U" \, v1 G2 h3 C# R0 g
- * published by the Free Software Foundation version 2.
) J. `* Z6 O2 `5 C* n7 P. ` - *
! L% T3 u7 z4 w( `! {7 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ p1 B0 f- e% ]9 j: h% W( | - * kind, whether express or implied; without even the implied warranty o* O" v- g6 T# B' a! O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 u4 C8 n# Y' H9 b% B - * GNU General Public License for more details.
/ f5 X) g: h ^/ B! ? - */
( j( X F, X, ~& @ q/ w( m - 8 z1 l6 Q' {5 |. g5 {8 }
- #include <linux/module.h>0 y5 ~. t8 O2 y! Z* r7 j
- #include <linux/init.h>* ~1 i3 |# u* D, s# z' P6 T1 A
- #include <linux/errno.h>
2 W9 C4 B( \ R, V' k! C9 g - #include <linux/types.h>0 R1 g. ~1 \+ V4 l: e3 w# ]& F0 \- h
- #include <linux/interrupt.h>
7 A& i: @6 Z2 {* S - #include <asm/io.h>
6 G8 i, \) @' ?* T! v) _ - #include <linux/moduleparam.h>
9 j y# y9 U$ W w8 l# s; Z P - #include <linux/sysctl.h>5 q. K- }& K1 A8 p4 w( R
- #include <linux/mm.h>
" c7 [! U0 ?2 F - #include <linux/dma-mapping.h>* m; B! M+ B+ P; M( B9 U9 v5 O8 ?- k
- ' ?- N# W6 o- g+ {- J
- #include <mach/memory.h>. D# X/ ~# ^, Q6 d
- #include <mach/hardware.h>
! U* H/ o2 ~! P) t - #include <mach/irqs.h>6 ^" n) a( p* U v
- #include <asm/hardware/edma.h>: Q0 W4 H, c! e* x- P: r" `" R
0 G# w% |+ u S e+ C3 h: x; p- #undef EDMA3_DEBUG3 P( K: ~2 I G. r: q+ S9 N; o8 u
- /*#define EDMA3_DEBUG*/
# o9 z! ~$ o9 u7 j. [4 l) f, G* W
$ }1 X) s6 Q! p1 j- #ifdef EDMA3_DEBUG
7 _7 O6 B. F% o$ j7 Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& g* |) x$ \! `! c ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). t& X3 f) A% g' c9 a! N. G- Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 J. j. v7 Q# G O4 L& S: q
- #else
; w7 P! N% b8 L; a% j2 A( U& R' a - #define DMA_PRINTK( x... )2 \0 C7 p- P9 n9 L# O
- #define DMA_FN_IN
0 C1 V' f& J" V+ N* \: t% M2 q - #define DMA_FN_OUT
& H, z+ n% }, p/ w1 M - #endif
7 T! Y( b+ z6 R, I
4 m9 {, i8 P. F: O5 F; R8 ^" Z- Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: I2 O9 Z9 i4 o# V - #define STATIC_SHIFT 3
8 e) Y6 L' w* l0 j- Q3 D$ ` - #define TCINTEN_SHIFT 20
* i% S$ e1 D/ z9 K5 L - #define ITCINTEN_SHIFT 21% P, s4 n! ^3 t, z0 C& }! l
- #define TCCHEN_SHIFT 22
! j2 J* H: x# I" Q4 k: F) j$ P - #define ITCCHEN_SHIFT 239 r# [ X7 v2 g1 R7 M; u. D4 S
- $ r$ y3 H" g' N4 l1 b( Q9 y) M
- static volatile int irqraised1 = 0;: d! Z8 {3 k. }7 E: ^
- static volatile int irqraised2 = 0;
) ?5 u8 f, B$ w3 x9 L- g5 k) P; r
0 V: a4 i; p# H4 Z0 ?/ m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; H) J* R& N$ l8 M5 n1 t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: m, s0 g5 w, O1 J4 P; W9 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% `1 O6 x+ u% T
; J0 l1 ^ ^- e! K' u+ H- dma_addr_t dmaphyssrc1 = 0;& p* e1 u$ @5 X& d8 W' F L
- dma_addr_t dmaphyssrc2 = 0;0 O6 ]# j; J6 q
- dma_addr_t dmaphysdest1 = 0;
/ K# z& {+ |% j- G( A( I - dma_addr_t dmaphysdest2 = 0;* \$ p% q6 C) F" c
- $ u& G! }5 z5 e! H' V
- char *dmabufsrc1 = NULL;
* Y8 R9 _6 s& h9 B1 `3 v - char *dmabufsrc2 = NULL;
y7 Z8 r( S+ F% P6 I - char *dmabufdest1 = NULL;( V' x8 f7 p. t
- char *dmabufdest2 = NULL;1 p/ v4 [" ?$ B( j8 V) b
- " L4 U3 R3 y P) G, ?7 C
- static int acnt = 512;% q$ Y7 B. d5 g9 `0 S$ i1 b% M
- static int bcnt = 8;6 u/ K6 S) J- G. w& M) R! `
- static int ccnt = 8;
2 E! G. D1 D2 `4 c
$ a6 ]+ x& q. ^. ?* e- module_param(acnt, int, S_IRUGO);% k [ c" A0 p
- module_param(bcnt, int, S_IRUGO);
8 P( V' h( S8 O# q - module_param(ccnt, int, S_IRUGO);
复制代码
* c1 Z$ w1 `* T* F0 A+ C8 M
( l( O2 g7 a; t l3 k+ q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 e' Q) M4 N @! [- e4 t& d* {& Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' J b1 s+ {2 e4 K1 S4 d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- n6 s- n& E; p' J7 D
! N# a' r8 l2 ~1 E9 X6 e* G
( N6 `, V0 o7 ]+ B) G2 G6 G r |
|