|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 g, Y% L% L% F- [code]EDMA sample test application$ h2 V4 l* P$ I$ ^
- /** X2 i, n8 p a3 I8 k
- * edma_test.c
+ h6 @: [2 d; E" }$ T6 P$ ? - *
1 s. F0 E" V! q, v- V# q - * brief EDMA3 Test Application
; b" `( V% H$ l% I5 Y5 ^$ B - *
! X9 p! f8 w. q( k9 ] - * This file contains EDMA3 Test code.
- S$ B E5 f. O) A) P! a - *
2 K8 I" M: @7 R/ z" V' Q6 J K! F - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# O6 J& _( Z/ d3 Q) p- \, f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" V. G9 R, Y9 \/ f* c - * TO CHANGE.) t; z& b9 W @& X& e1 t# V
- *
, \7 c# ]- ~/ _1 l! Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// A8 d* Z4 ~/ x+ q U
- *
! y7 S9 G9 A4 l" j - * This program is free software; you can redistribute it and/or6 R7 t4 z1 I# i2 {: Y/ l
- * modify it under the terms of the GNU General Public License as* p& f p9 U3 J1 ~, c! ~3 [
- * published by the Free Software Foundation version 2.
; M0 @! v1 {0 l4 H6 T) c - *
' c* ~" V* z+ g3 L - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 d m; ~# |& n/ g1 f$ E$ D" |& d. P
- * kind, whether express or implied; without even the implied warranty- O! ?! I# n3 M, x% k; U; u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% M) P* k3 S( Z3 m' s
- * GNU General Public License for more details.
. G" v3 o& g3 t# E - */
$ w& h% P( v0 ]2 ~2 f
- q' \1 h, r, F+ u- #include <linux/module.h>
6 b8 w+ Y) @3 U - #include <linux/init.h>
; n% o9 Z' {$ v; \3 F: _# P9 |. X - #include <linux/errno.h>: @" p. I, D' W+ u
- #include <linux/types.h>
7 h8 b! @, p5 h0 | - #include <linux/interrupt.h> p# p' B, \4 H8 L/ T. A4 b8 K1 i# R# I
- #include <asm/io.h>$ D/ \+ t( G. g. m" r
- #include <linux/moduleparam.h># Y0 J0 `& p; t$ Z9 Q
- #include <linux/sysctl.h>! c7 `9 s' W5 |- l: q8 ~* i2 O
- #include <linux/mm.h>
. K5 D# s* K( x2 C8 w7 d6 ^ - #include <linux/dma-mapping.h>
- k3 k0 W7 n+ @
" t' M8 l" d5 p1 s- #include <mach/memory.h>
/ s' ] `6 [; u9 r" w/ n - #include <mach/hardware.h>
1 G0 |5 @2 c3 b: Q4 c - #include <mach/irqs.h>. @, U- X8 {4 o
- #include <asm/hardware/edma.h>% f) A3 _' J0 m) Z
! l" X R+ r, B1 y- #undef EDMA3_DEBUG$ b% c% u5 J Z: U2 E! P3 s
- /*#define EDMA3_DEBUG*/
! c6 S& c" X" Z" Z - & [2 [9 `* p) f- M& C, x8 o
- #ifdef EDMA3_DEBUG
$ C( k( q9 i& j, B6 j3 K* u/ r& x2 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 i, F! _5 b; E" s# e' U* j1 r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% Q$ t8 Q0 I: y& q* G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% D1 Y4 P2 l* s; \* H. Z - #else
?+ S3 ]5 h# M - #define DMA_PRINTK( x... )0 m% y2 X( o' {, u+ {" _; @! e0 {
- #define DMA_FN_IN
0 i* b$ P( n2 {$ n - #define DMA_FN_OUT$ x% Q4 R* G- T4 G0 h. V
- #endif% N9 O1 ]( c4 j
; O. T6 C& j0 \: Z6 n5 S9 g$ l. B- #define MAX_DMA_TRANSFER_IN_BYTES (32768). |% |9 t/ N! |% Q
- #define STATIC_SHIFT 3& u. j, M+ K u
- #define TCINTEN_SHIFT 20
- M/ I5 F6 H& o! B5 v, d; { - #define ITCINTEN_SHIFT 21" w% d4 t% P" c- q5 T$ M' a
- #define TCCHEN_SHIFT 226 u- z C1 M, p3 j
- #define ITCCHEN_SHIFT 23( w, I: \* p; V" B. @3 x' G/ Y
6 h! J% w8 k" [" ?- static volatile int irqraised1 = 0;
5 H% m. j6 R. Q - static volatile int irqraised2 = 0;0 e p& H7 M1 M7 T( q
$ j, K$ d, U1 `# \& Q# h; C7 b- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 [0 h# E* o" @( k, M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& T: Q/ H m6 Y$ r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) R6 \2 y4 D. I+ F) Y. l
7 ]/ a+ x' G, a5 G5 a- dma_addr_t dmaphyssrc1 = 0;: F, m, s: h% C" }! H) P
- dma_addr_t dmaphyssrc2 = 0;8 _1 _( m3 I/ W. T4 N: h' [
- dma_addr_t dmaphysdest1 = 0;, Q3 ?7 N2 N) } _
- dma_addr_t dmaphysdest2 = 0;: X1 @. N2 y/ W) K1 r l& z) k( b+ y
- & F* B" y5 E l/ e, E- x( K
- char *dmabufsrc1 = NULL;7 Y8 I1 `7 D0 o4 O$ b; s
- char *dmabufsrc2 = NULL;( D* q/ }8 b" g) T
- char *dmabufdest1 = NULL;
7 H( n% L5 a! v7 e$ L2 d! [; i/ Z - char *dmabufdest2 = NULL;% @9 \( C$ f! u8 J# u Q
5 R9 H3 v( ~' E) l2 g- static int acnt = 512;6 c2 l* \% i5 Z; m7 U- m# d/ T
- static int bcnt = 8;; y, W% M4 q* Q
- static int ccnt = 8;' q5 c0 C) ?9 ]. u0 r
- 8 t; N0 l: L" m
- module_param(acnt, int, S_IRUGO);
|4 |. |2 D+ {) q - module_param(bcnt, int, S_IRUGO);
8 g8 k9 |( C# ]8 R - module_param(ccnt, int, S_IRUGO);
复制代码
/ y3 A! i3 s. }0 t: ?; t7 p8 p
% n( [" s4 B3 J1 j& k9 v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: D9 C. h# w& T- }/ S; z" Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ Q8 h% @, A, v) N$ `* c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 N% o/ X" O& ^ ~8 P1 I+ j, k$ Q# w7 \2 M- o* m8 e& l
" G! u0 U% m! }" E: w |
|