|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" G' P) `) k1 S5 w/ A- [code]EDMA sample test application* `' ^0 d) P1 g
- /*4 p) K+ g3 |& G. L
- * edma_test.c7 v2 I* S j% g: l5 ^$ x
- *
9 {& B; z6 X3 W- A1 u# X, v - * brief EDMA3 Test Application; N) T- @5 a7 K0 i9 ]
- *
7 P9 S; L% Z8 r( O - * This file contains EDMA3 Test code.7 |/ c% i, W3 g/ V/ H
- *
: I0 I) {2 i% |8 u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ J2 ~1 B0 Q, S. j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! K4 ^. |# p. P z" G- [ - * TO CHANGE." S1 s6 p* S* A+ T
- *
( x, W% R8 Y$ g/ r7 X% r, o1 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 o9 F5 `- Q- P) t - *; t. `- i1 a* B% s6 c% f0 H5 w
- * This program is free software; you can redistribute it and/or
5 E* T& c d- }& h4 } - * modify it under the terms of the GNU General Public License as
& _5 m( y. t; Z4 i/ I W - * published by the Free Software Foundation version 2.
! S% m, \' ? E/ S1 x, N4 {# y - *0 r. I y& Y/ D5 m3 n; |
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ C, C7 m* g6 n/ t9 k - * kind, whether express or implied; without even the implied warranty
, ?/ B- E0 T- P* h2 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, X* |* E1 t4 r9 U! K, z" [3 ?: V: r
- * GNU General Public License for more details./ B; H3 Q/ z0 P1 L8 T3 V
- */3 a& s& q) N) y; @6 [. j! i6 X
1 A: Q& A& V+ I- #include <linux/module.h>' ~* T `6 F& a, g
- #include <linux/init.h>
. O* O. [) j, l# e( l" ^* Q - #include <linux/errno.h>
5 L' m: A3 f7 t4 j - #include <linux/types.h>
$ Y, G/ V. n7 t9 |* v) v) J& [2 U$ i - #include <linux/interrupt.h>" E; K2 e, j7 d; Q @
- #include <asm/io.h>$ u6 ]3 z2 s$ n8 F
- #include <linux/moduleparam.h>
9 v5 {' Z: ?3 y+ F3 ]; B+ d - #include <linux/sysctl.h>
" u, g( z! d8 A$ B c5 N9 t - #include <linux/mm.h>
2 \# s8 p% b% s. m- Q; N/ n! k" b' y - #include <linux/dma-mapping.h>1 I; G) x# ?: h2 Q+ \2 d. P# I! X
/ |5 J% U" J y3 ]4 U' h J- #include <mach/memory.h>' q$ }- e n2 f
- #include <mach/hardware.h>$ r) O! b0 O# s' i' v" v0 S
- #include <mach/irqs.h>" q. v1 G! {% b6 u
- #include <asm/hardware/edma.h>% i$ i; [6 W& X
- ' d- {, m0 o+ u$ ?# `& p
- #undef EDMA3_DEBUG/ B) `' `5 B1 Z, h0 K H9 S+ i, d
- /*#define EDMA3_DEBUG*/
, J& O8 j9 Q) @# x - ) r% F4 A* z1 u; a* j' y. H' G
- #ifdef EDMA3_DEBUG
( i- q% H& G( G4 n4 G7 O5 O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! ~" t, |( f ~ V `- a. K( i; T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" Z0 }* z$ T% K: `7 d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: p x0 r5 U3 k d& u& x# K" M - #else/ L) H6 s% B# H: u+ W! I/ j2 Z
- #define DMA_PRINTK( x... )
8 {, K% y5 C) F: d! E, p: e/ c - #define DMA_FN_IN
5 P. Y/ j5 d0 k - #define DMA_FN_OUT S8 n& E8 i, Y; S. p% D
- #endif
! f5 X) | F' P+ x! }
' _0 f* O+ k# I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 @$ P+ C9 r, j f - #define STATIC_SHIFT 3( j3 C6 T. o1 P
- #define TCINTEN_SHIFT 202 @4 X5 E1 L( [7 |: j
- #define ITCINTEN_SHIFT 21. U. c$ b, N- D" Y+ f
- #define TCCHEN_SHIFT 22
1 e7 l" }& @) I5 u4 V - #define ITCCHEN_SHIFT 23
8 S+ j# m2 B+ H& o2 b4 U; ~ - 3 u- T& ?8 k, y" t$ c
- static volatile int irqraised1 = 0;4 [4 F3 y q6 u6 `; J
- static volatile int irqraised2 = 0;
( b8 G: z# i0 l, j - " H7 P$ R3 m) @7 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% `) N+ S* s4 m5 C6 V! ^0 k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& |! E& a; M; u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 l' b. G3 t* B4 ~( A
0 L; @# Z& u; z6 c: u, m- dma_addr_t dmaphyssrc1 = 0;
8 v) G4 S/ a8 M - dma_addr_t dmaphyssrc2 = 0;& ^( B- h- c2 D) F4 M% h7 q" t
- dma_addr_t dmaphysdest1 = 0;# h( L2 \3 T. k5 W- l; p- R) y
- dma_addr_t dmaphysdest2 = 0;9 U8 P0 J% Z% ?' Q* Z/ r' T, v
- 7 R' n+ P4 R7 B1 `0 c0 c
- char *dmabufsrc1 = NULL;
- T0 y: Z: L/ k4 @/ ^5 x0 \" ^ - char *dmabufsrc2 = NULL;" y+ z$ p3 b$ b
- char *dmabufdest1 = NULL;
8 _7 m, Y2 y6 B1 h3 p1 U4 w: Y - char *dmabufdest2 = NULL;
9 a" J7 p H: v9 }/ g+ V* @& G5 Q/ X
; E6 ?3 ^' Z7 A' _9 f# p! p/ P) y- static int acnt = 512;0 R" y8 ^2 ]3 s, W
- static int bcnt = 8;% c6 k4 ~ G/ ]9 K% b% k3 `
- static int ccnt = 8;
7 D# ?8 h7 F5 ?/ w$ u
+ K; @% b5 F" t% G% j: H+ G) o- module_param(acnt, int, S_IRUGO);
, Q1 n" K3 Y" V' P - module_param(bcnt, int, S_IRUGO);
4 k$ r3 u7 M3 j6 o m - module_param(ccnt, int, S_IRUGO);
复制代码 ! j" I+ r; G& u2 H
[1 R4 K9 ^# U: @- w/ ^. |/ i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 k/ b5 X: O2 I: G+ @, U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: x3 r6 ]- y3 O5 {: |* Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. A: g9 x# b, }$ D, z" ~8 k2 [1 e! T1 w4 x( {) R
4 E# R3 y3 }9 G, v2 V |
|