|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 C1 ~8 j" U H5 f* M7 B- [code]EDMA sample test application
! J: g( ~( Q3 W! k) W7 ? - /*
% q/ Q5 l. }9 p% }' Z0 u4 w5 }1 y - * edma_test.c
' X: q1 v5 g9 S+ {7 m - *# f5 w7 v( y7 t! a0 H% j: k
- * brief EDMA3 Test Application1 b e3 l9 L# r) a! M) f- H- u
- *
4 _7 l+ k+ D; @ - * This file contains EDMA3 Test code.
6 N. h' }' }8 p. X) g8 _: q - *3 o B$ g; s: i+ H8 G5 u
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, c# h. S5 W' Q0 l9 _' N - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" g4 W8 H0 y% n9 e( v
- * TO CHANGE.0 P8 L; H P5 B$ b
- *! Y$ @& X, N" B# a1 W( A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 {! i* D: B; u6 t3 m
- *
' z- f u; B& _# k - * This program is free software; you can redistribute it and/or
& c4 p# h8 L+ b9 n - * modify it under the terms of the GNU General Public License as# `9 Q3 o, W3 ^
- * published by the Free Software Foundation version 2.7 k( _* ]# g, k8 F# X
- *1 q: c& T5 H1 b' `8 p3 D$ r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* }' l h0 F2 M7 y! W2 \2 F0 h8 }
- * kind, whether express or implied; without even the implied warranty
$ i- K* k/ L8 `" c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& V; J( m4 R% s5 t- |
- * GNU General Public License for more details.1 y0 I1 n3 p* O+ F( r5 |
- */
- @: P9 W6 ~ i# H2 U' y - ' h9 `, \! X0 Y6 V9 E
- #include <linux/module.h>
8 s2 R% r$ g, J( d* z. w2 M - #include <linux/init.h>
6 I9 C! n, Y4 I& {0 a6 i& [( B - #include <linux/errno.h>
! v' u/ v, y% j0 z6 |, u* O - #include <linux/types.h>
6 j" w7 Z% I& I$ j& z - #include <linux/interrupt.h># C" J9 z' |* N k- a$ `, A
- #include <asm/io.h>
" p: }' M4 F/ j" O/ Z- u9 M0 R% d* U - #include <linux/moduleparam.h>
$ m: v+ ^. I5 I/ _( O/ x - #include <linux/sysctl.h>
" _3 b! G e; Y5 y - #include <linux/mm.h>
0 Q0 I' }" f9 x+ p' V6 D) Z% U - #include <linux/dma-mapping.h>
/ r H `% [0 T* w - 9 o" z1 P: ^4 M: G
- #include <mach/memory.h>* A: P# R$ g# k. S) @. z0 {
- #include <mach/hardware.h>
/ e0 l5 J& _. | - #include <mach/irqs.h>; o) V: { `: k1 V1 d, F; L
- #include <asm/hardware/edma.h>, Z! |: P" d a( c
! t, B7 m! b' Z y+ r- |- #undef EDMA3_DEBUG) S& ]! y k0 Z6 G/ ~
- /*#define EDMA3_DEBUG*/# V0 o. o/ r' f; d) T- N
0 c& E# V. M" {, M- #ifdef EDMA3_DEBUG+ D9 D* Z1 h+ m& b. b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 Y9 e' I7 V/ @6 k4 I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 t6 h: c6 |/ L/ p2 Q3 |3 W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 w, Q! ^/ \4 i& q7 r - #else
/ e: m9 }. z+ r" K6 K" W - #define DMA_PRINTK( x... )4 h& Y+ V+ G' o# E- B+ D
- #define DMA_FN_IN$ K/ \1 @2 i! u% e7 y! X
- #define DMA_FN_OUT. s8 e. S a: Z" F# n
- #endif
2 M( _! |$ S: f0 s" s
3 z# E. y" y8 \# X- #define MAX_DMA_TRANSFER_IN_BYTES (32768) I; A ^# e4 T
- #define STATIC_SHIFT 3
9 [2 ]' ~. |: G$ O - #define TCINTEN_SHIFT 20
5 H" D) Z* b7 O- }8 n0 G: E+ ? - #define ITCINTEN_SHIFT 21; ]' N N1 R8 ^! P
- #define TCCHEN_SHIFT 22
; Z( C5 ]1 {, a7 ] - #define ITCCHEN_SHIFT 23
* ]; q8 G- I* c- z - : I- }+ H1 u$ F6 f& `3 E
- static volatile int irqraised1 = 0;/ @, y) O3 P8 r. O) s
- static volatile int irqraised2 = 0;! E/ M: _% y9 \. C
- 1 O9 x7 [* ~0 o. x" T6 v3 V3 y2 u
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* o! K% u7 |5 c9 ?% C. }3 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) o; d# \0 B+ b( c7 V6 e8 u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( D2 E, N. C+ r- ` - 8 I( W, `1 T) {. Y( U: o$ E4 _
- dma_addr_t dmaphyssrc1 = 0;
* W5 f6 ?% r; K* Q. \ - dma_addr_t dmaphyssrc2 = 0;
6 z2 d8 D: H- O1 j+ b0 b% n0 ~" { - dma_addr_t dmaphysdest1 = 0;
, o5 \6 E2 Y$ S4 s - dma_addr_t dmaphysdest2 = 0;1 X% z* V+ H# U3 r/ x
: D9 N( ]% E! h- char *dmabufsrc1 = NULL;
: x( i% L7 c3 M: y. ?: O: N/ n - char *dmabufsrc2 = NULL;
3 B+ l- @3 |3 A3 {$ P! V - char *dmabufdest1 = NULL;
- W8 O. M, B% K |5 S) ~* F - char *dmabufdest2 = NULL;& d: r- ~# N. x/ M6 `( u
- O- Q( Q, @1 e( q! B, b1 i
- static int acnt = 512;
7 r; r. o; m/ d; O - static int bcnt = 8;
' M2 e& s& x: j$ w8 n3 M% D/ h - static int ccnt = 8;! M2 h! C" a) _( j7 @
- : [. H3 I4 B; o8 K# W: \
- module_param(acnt, int, S_IRUGO);
2 z& S% n! W. r$ u, \' c - module_param(bcnt, int, S_IRUGO);
; D- B* ~# k: R0 K. f - module_param(ccnt, int, S_IRUGO);
复制代码 - Z- }1 f7 N: \1 \; Y) O' j
# E6 Y6 g h$ O7 S7 x; l h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: p# `4 ~ K' Z, `1 Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! t& A% {3 A" }/ I; U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 G, v2 `) S: g5 _1 H4 t
Z+ B# Q$ o$ M
* _7 p8 g3 _, O6 W) r1 G9 J4 r+ S! v |
|