|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & {; o2 j+ T# l. y
- [code]EDMA sample test application
; E! O# D, m. H3 B- ?7 J4 v - /*% B: o# \8 \2 Q/ L& C
- * edma_test.c* P! D6 s' {( t" e2 X
- *
& z S e, p1 O0 u - * brief EDMA3 Test Application
$ C& g$ V* T6 Z7 H" Q4 z6 { - *
9 Z; k- _0 r% s% g4 D - * This file contains EDMA3 Test code.
# e! }- H" i/ m( L& J0 _( s - *$ t7 D+ F8 [0 F/ s2 ]( M; W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 `2 Y* L. D# {6 @
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% H/ Q6 ?) U% d |! e5 A - * TO CHANGE.
! p( e) E. d8 X: w' M5 {7 |4 [/ E8 y - *# n+ a0 V3 q5 X: b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 s; ~% U3 ?. C5 t! d
- * V1 ~1 h, r2 z5 R' l9 X# T2 h) H( q
- * This program is free software; you can redistribute it and/or
* M3 l! H$ c+ j7 G& k - * modify it under the terms of the GNU General Public License as) q P5 E9 G4 ?4 t2 Y
- * published by the Free Software Foundation version 2.
) f I" r W) a& x* B1 [- j: c- P" k - *+ x3 @+ ~# i+ |& Q2 r4 K3 D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 r+ k- e W3 P! r. w
- * kind, whether express or implied; without even the implied warranty
4 |' ~6 E9 G1 V- E' y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 c4 ]+ U( q o. v; F$ C: J1 C - * GNU General Public License for more details.1 E) _; O6 }. H h$ W2 g
- */
% J0 B' g) R+ C/ @- H5 s6 |
0 C! a1 ]( R- m" }0 n# `- #include <linux/module.h>
, u' Z% ^" ?# K; k3 K* N" r - #include <linux/init.h>
5 c" ~5 Q" y3 l" c5 k - #include <linux/errno.h>
1 j$ Z8 X6 p+ O I) Z) o - #include <linux/types.h>
& k8 [/ E3 J4 E3 E" d - #include <linux/interrupt.h>) U( o* l5 \2 d$ {; n% n; m5 u
- #include <asm/io.h>
% c1 Y. w5 X c" I1 M' o - #include <linux/moduleparam.h>, k8 t% Y$ N" V% }. R
- #include <linux/sysctl.h>
! ~* K$ e9 n. U - #include <linux/mm.h>) m, M8 {+ ]% s, B" k% h
- #include <linux/dma-mapping.h>: i5 ]- ~9 M5 @- M+ S: b
- , w9 m4 a. ~$ _8 B9 F% f1 ?
- #include <mach/memory.h>- Z: n. S0 W4 C
- #include <mach/hardware.h>
4 O3 ~9 y' z1 O1 ]8 s - #include <mach/irqs.h>
/ n. ^- ~& F1 {9 a - #include <asm/hardware/edma.h>
- N& G, G) F0 w7 g. E4 c - / G+ s+ V0 Q4 ?8 q
- #undef EDMA3_DEBUG
6 \& V W9 y* H, m$ y1 _ - /*#define EDMA3_DEBUG*/
; E" h5 |; G9 s4 Y - . \) K1 r' q$ s( W7 T
- #ifdef EDMA3_DEBUG
$ N2 O8 i) i! q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 K8 Y* m; T$ N5 }8 r! W2 f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; E! E$ J$ ~5 y# M: ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 _! D+ o( A4 O3 @2 n - #else! I, Z6 n6 r5 {
- #define DMA_PRINTK( x... )
) ]# [4 A3 X" O8 q) j - #define DMA_FN_IN
" Z/ N% W$ d2 m2 U - #define DMA_FN_OUT
, B5 D2 ^3 f: o; g+ m - #endif, Q8 P0 ?% y. z6 J, U" x) Y
- / W+ y/ Q a5 |! {2 G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 H; W& f! A( X8 L X, ^+ J# l) S2 G - #define STATIC_SHIFT 3
: X2 Z- _ k1 h6 L: y4 n& J - #define TCINTEN_SHIFT 20
. k6 i7 _) b% v9 ~0 A - #define ITCINTEN_SHIFT 21! x# y. ~: v! q9 ]) {3 Z7 K K) s! o
- #define TCCHEN_SHIFT 22
8 |& ?- {# ^8 ]# u: I - #define ITCCHEN_SHIFT 23
2 e) E1 M) z' c, B L - 9 O: u% Z; A8 u. c7 A# w; U/ I+ H4 p
- static volatile int irqraised1 = 0;$ g' E) Z" F! q4 W+ V
- static volatile int irqraised2 = 0;8 d& d" U2 s+ i. J
1 z$ ~2 K& R2 _& A8 t) j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 I. T5 [" ?) b8 [" @5 ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( S+ _9 _' v9 |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) T/ T6 H4 l& A2 ~
! B: p& ?; W/ U2 C- dma_addr_t dmaphyssrc1 = 0;3 y8 a9 V$ ~, T- t/ g
- dma_addr_t dmaphyssrc2 = 0;/ _' e }# G8 E% a3 \, B
- dma_addr_t dmaphysdest1 = 0;
+ a- _+ V. a& z2 T - dma_addr_t dmaphysdest2 = 0;
! [. h4 P3 n6 t Q3 ?2 } - 7 Y! ^# |* s8 F* O; J* Z k) w
- char *dmabufsrc1 = NULL;) t, u' ` Y2 D0 a$ f2 Y9 P
- char *dmabufsrc2 = NULL;
2 x( D* R) u/ y) l& E - char *dmabufdest1 = NULL;
9 Z8 e$ ^4 z. ]# M" h - char *dmabufdest2 = NULL;
2 {* a# Z$ `8 Z- g
{7 S' m2 ]4 u x- static int acnt = 512;. L3 @. M% f+ ^8 Z7 M @; N
- static int bcnt = 8;$ t( u/ E, |7 A" r$ ?: N# i* S1 d
- static int ccnt = 8;* G( p% u4 O& W, C5 \$ Q
! X/ b! M$ h7 S( A: s- module_param(acnt, int, S_IRUGO);0 {$ u% o" |( J" \' N
- module_param(bcnt, int, S_IRUGO);
* b; _. |& j0 E - module_param(ccnt, int, S_IRUGO);
复制代码 0 U' m2 D8 H( z/ G+ [5 X+ {
; }' s- K$ f+ O0 `4 k2 h) E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& T; g, q/ v; [- {7 u* D, T4 Q4 {/ _ Farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& I4 W& Q5 k$ b$ x" j& E+ } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 q6 F2 p' W% e
8 H. |! ~$ C. e4 Q- O$ f& F
; i0 h* M+ O! [9 Q# a |
|