|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& f" R# {3 M! A' j5 R- ^- [code]EDMA sample test application# M% V2 ^; ~# ? \4 C8 \$ @1 ~
- /*1 N, o" ]* V* E# l/ N: S2 S* P
- * edma_test.c
$ I5 {. s2 c- l y |. T0 M- i9 p - *+ v# ?6 T( a/ ]
- * brief EDMA3 Test Application
' J- J4 e& Y/ Q8 ^# S* V$ g - *( q/ i* l; A4 Z0 G( W% Y% r" l
- * This file contains EDMA3 Test code." W2 h( P' I! t) b6 w0 o+ g
- *2 l# u% a1 W; b. I/ d- S
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* [, `) h4 ^% Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 a* p. u0 H8 c# K- k& j
- * TO CHANGE.3 ~4 U3 }9 B# z, @2 `. n
- *
. R) P$ k' t" p. @! D6 `4 K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% F( f. b! V: w9 e
- *% Q/ W o3 _, L0 T
- * This program is free software; you can redistribute it and/or- |( S+ g) g- ]& [9 c( D) l* e9 ]9 R
- * modify it under the terms of the GNU General Public License as! x( @: I7 [: S: p* x4 v
- * published by the Free Software Foundation version 2.2 C6 V% x5 S: D+ p
- *
; t6 ]5 _- _6 \, E- e - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- [* b Q- c( c2 o- r; L3 Q
- * kind, whether express or implied; without even the implied warranty
4 u: v% ]0 M* B G8 I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& i) f; X) `- w8 M+ g/ Y+ s - * GNU General Public License for more details.' j8 [5 @9 B4 }2 s g! J
- */
- \: P& m# H& R! R9 j w6 I. r7 L7 Y - 5 t- N5 m6 P; x" o: ?7 w- g( j( b+ m/ ~
- #include <linux/module.h>9 _. N! C+ F8 l, g/ r$ Q7 ^# M# U
- #include <linux/init.h>
& k. y% g% [- L) | - #include <linux/errno.h>& ^0 n5 f7 Y: x
- #include <linux/types.h> h6 B% l; b: _1 b9 c
- #include <linux/interrupt.h>% b' K9 s$ S3 ?, w1 S
- #include <asm/io.h>8 R2 n* G) R, N
- #include <linux/moduleparam.h>/ f4 }" M" R2 \/ o, ^
- #include <linux/sysctl.h>
+ S# U( u8 v, m - #include <linux/mm.h>+ l" r' J4 O7 C* Q
- #include <linux/dma-mapping.h>( G4 m: k6 q7 m9 ]; X [! r: w; V, u
. c3 k% n1 X5 h- s( Q- #include <mach/memory.h>. a# [5 U* {" F
- #include <mach/hardware.h>
$ c' {/ Q/ q2 R2 _% Z; z! ~5 h0 x1 v - #include <mach/irqs.h>
2 \" x! `1 Q- `% W4 O @4 d - #include <asm/hardware/edma.h>
/ @5 T5 M. N6 i1 m" Q1 j - - D5 D B3 W# }9 u
- #undef EDMA3_DEBUG/ n2 p& G8 C& W6 U, B. z" c
- /*#define EDMA3_DEBUG*/
: O7 s* d) ?$ B" L - % Y/ _8 {$ u3 L' ]
- #ifdef EDMA3_DEBUG
- u% \: b3 e4 [+ j2 }; F - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. T5 g+ j- w6 i( s# z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 @* |: Q0 i! ]$ b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" Z0 s# _, Y H0 a( I5 _3 ?8 X - #else
" Q% i3 P7 Y% O/ W: j: X - #define DMA_PRINTK( x... )
6 Q$ l; \7 @0 `* L1 q5 o1 G/ ]$ X - #define DMA_FN_IN! \" o# F6 R7 s6 d8 v
- #define DMA_FN_OUT0 d# j# k$ |* G K F
- #endif
# x/ i( h. s8 \# \' G& d5 g# X
2 x G, T" h' J" \+ g+ Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( O+ w) t4 J# ^' X* n - #define STATIC_SHIFT 3
$ j1 y! G0 ?! Z8 X: C - #define TCINTEN_SHIFT 20- t. J, l( h9 z+ Y8 n
- #define ITCINTEN_SHIFT 21( L$ [( o& }# V4 }. r
- #define TCCHEN_SHIFT 228 V. y( p8 z+ S) z
- #define ITCCHEN_SHIFT 23
8 C# F8 x/ K% c6 x% t - o$ X- y7 {' C
- static volatile int irqraised1 = 0;, }3 [7 t# b. ^( c1 ~
- static volatile int irqraised2 = 0;
, |. c2 d* k; @6 j9 @ `* C - 3 B( r8 Z9 d; L1 n' e# y) I8 ?
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 e) W6 ?0 }; z w, Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! I3 q% F5 F6 R. T$ M0 G. Z1 C4 p( { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. v7 \2 Y% l0 R% n - C$ Q( Z, k/ P: `' V2 {5 J
- dma_addr_t dmaphyssrc1 = 0;
' C! l8 g' g+ |1 N5 t - dma_addr_t dmaphyssrc2 = 0;
; g$ h7 }; [% L% R2 H - dma_addr_t dmaphysdest1 = 0;" W C+ B0 R3 g6 z+ A
- dma_addr_t dmaphysdest2 = 0;. E- F4 _+ Y1 S: n
- / A7 ]/ v" x9 ~$ J; u, V
- char *dmabufsrc1 = NULL;; r0 ^7 q1 q/ X. d
- char *dmabufsrc2 = NULL;
) v, b* ~$ q1 d) | - char *dmabufdest1 = NULL;: W# S1 ]% x- U3 J
- char *dmabufdest2 = NULL;
$ v3 d. W3 J' v/ L* R; i. {' Q
+ _9 G3 k! H" n% k$ h- static int acnt = 512;
5 b$ W2 r+ X! p3 d6 l4 \ - static int bcnt = 8;
3 K4 k% H. |. [ - static int ccnt = 8;
8 w2 i F3 | w
& _7 d5 x5 [& c! `2 F8 v- module_param(acnt, int, S_IRUGO);( I, k1 x) B: J% U$ r8 [
- module_param(bcnt, int, S_IRUGO);
$ P! V) n5 P0 Q' o( ] - module_param(ccnt, int, S_IRUGO);
复制代码
- x2 R* @" r( a, O8 N {* {+ H- x8 K& k7 g0 Y4 |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 e# D/ K; a. 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# u4 C2 i! ^' J9 c4 v) r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 K2 g# N' h; y
* v6 _# T5 p5 T( C' N1 `
$ p* z; c# R) u1 \ |
|