|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . l. ~: U# A+ O. W- V
- [code]EDMA sample test application m* \7 p% J5 P1 d
- /*
& l/ ?6 L' R1 k. C; q8 I2 `) Z: ]; g4 v - * edma_test.c
, A4 p. x* u# _/ x+ ? - *$ g# y2 F0 q* ]" K
- * brief EDMA3 Test Application: q5 T5 ]. Y$ }1 j X- q
- *
7 F, w, q' M$ J N( V! s- C - * This file contains EDMA3 Test code.
; G# [/ L6 A. u7 r6 x - *
: Z7 W8 B2 O, I0 b8 U( ]( u3 e" U/ p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ |3 z6 R! X+ f( e% J8 n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' Q3 v2 T0 z) m: k& y- h
- * TO CHANGE., c1 t& W* ]( [
- *6 N% s/ L/ h4 x1 F) q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) F+ C0 E! J' m% } q) `
- *
4 w y& m# P1 R5 q0 x+ @ - * This program is free software; you can redistribute it and/or) V3 `) o; ^+ B
- * modify it under the terms of the GNU General Public License as+ @$ z G& C8 {0 l* [! H7 U
- * published by the Free Software Foundation version 2.
, j5 {/ p: p. f. C - *
/ w; s; o- w$ ?1 l7 G9 ?7 n; b3 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ B6 R2 s, N$ H. V
- * kind, whether express or implied; without even the implied warranty+ l3 _7 a+ n) y' Q. r) P
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# g7 s$ q3 U3 O$ f/ Z$ [
- * GNU General Public License for more details.
9 b( B$ K7 h: ~! w7 B3 b$ E - */8 M6 S9 x' A" D6 Y0 }+ u
! s/ r& ?: d/ I7 E; B& M6 ]- #include <linux/module.h>
- n1 {* D* b& }' p( K8 p1 R - #include <linux/init.h>
* w6 ?2 ?) _' n1 R - #include <linux/errno.h>
- a ]6 g8 ~' j! Q - #include <linux/types.h>
3 z1 j9 k# [6 q5 H" ^& r - #include <linux/interrupt.h>5 s% F) Z, I8 x8 }
- #include <asm/io.h>9 @& j- j* E. q# c
- #include <linux/moduleparam.h>" e% l4 C+ X9 `0 V' ]/ @1 j& C
- #include <linux/sysctl.h>
" p/ E: b: ]% |$ v4 k6 h - #include <linux/mm.h>
d: b; W6 Z( P - #include <linux/dma-mapping.h>0 I4 Z& e {5 z0 J
- 2 K, {; U1 u" Z; ?2 T0 q
- #include <mach/memory.h>
" V; O. j: U4 h8 X - #include <mach/hardware.h>
1 c( t3 \* z# J$ H8 @0 |7 ]* k - #include <mach/irqs.h>
) o* r% n) t7 u7 k - #include <asm/hardware/edma.h>
% u3 X7 e& f7 H; u3 K) q - - k* N& j' ~4 E2 y
- #undef EDMA3_DEBUG# T T' a( T8 d+ c1 s9 k6 C
- /*#define EDMA3_DEBUG*/9 M, |/ ` B; C7 J% c
8 [* r* o8 ^/ u% J0 X& }" a- #ifdef EDMA3_DEBUG) Q- G |. ]3 n3 V7 h/ Q7 @ | Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) V: Z0 P7 s# I- ]3 s+ ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); P4 z/ i# ^ w2 s$ x8 ^
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; V2 K }+ Z! h+ X2 M8 a - #else
4 p! v! e* J G - #define DMA_PRINTK( x... )
7 ?# Q G& T' Y# f - #define DMA_FN_IN
0 }) t0 _ L4 y - #define DMA_FN_OUT
9 t( a8 j* ~/ B* ?. M4 J9 q% o - #endif1 Z$ g4 ^7 U# H
) b) j0 m ]* Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% i$ X% D- k- r0 y
- #define STATIC_SHIFT 3) q: I0 z- c6 K5 t O4 ]
- #define TCINTEN_SHIFT 20$ V1 N* ~9 J4 n/ z' U, [
- #define ITCINTEN_SHIFT 21( X1 ?% L( u9 b$ m/ X: e9 k
- #define TCCHEN_SHIFT 22
8 j. v( y5 t+ i0 E8 s - #define ITCCHEN_SHIFT 23: u% E: j" q# a# e% F
- 1 }0 v" W, q8 s4 t$ |# Q
- static volatile int irqraised1 = 0; f+ n. [0 b/ E
- static volatile int irqraised2 = 0;
* N( H% C8 A7 g5 O% Z- \3 ] - 9 d3 A5 B' V: o
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) \& T& L& A' Y, R8 C4 W; E K$ V/ {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 U/ T+ K0 g d5 e p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 S+ u4 w7 F& k1 n
* q7 v6 @& S4 e* v( q/ T- F- dma_addr_t dmaphyssrc1 = 0;
* x3 ^' ]: W. \" m( N: U7 k% K - dma_addr_t dmaphyssrc2 = 0;! ~4 r/ a+ u- F$ z+ T+ j* G
- dma_addr_t dmaphysdest1 = 0;+ P$ a, z9 p6 @8 k9 M
- dma_addr_t dmaphysdest2 = 0;
; P% v Q* ^. j9 y7 B* L
. L+ ]$ i$ L V+ N5 O- char *dmabufsrc1 = NULL;# y" h$ a2 L! K5 U- ^: W' G% {
- char *dmabufsrc2 = NULL;( V) f: s, \3 s2 e" H. T
- char *dmabufdest1 = NULL;
8 k K5 L0 ^) H2 {+ z- o' ] - char *dmabufdest2 = NULL;# t' H3 S' | h1 d
- - d5 u+ e) F. ?& f1 i
- static int acnt = 512;
6 M$ l* ^) m: E( \ - static int bcnt = 8;
, C. [5 N% o- u+ K; m( c8 c - static int ccnt = 8;( y, \* c; q% e: U
- V: I5 M$ a0 ?; G) ^! u
- module_param(acnt, int, S_IRUGO);
! i; u4 I0 V/ X# n9 M& m4 n: B - module_param(bcnt, int, S_IRUGO);2 k3 I! M) A! x- D8 H3 E! |
- module_param(ccnt, int, S_IRUGO);
复制代码
/ b% G' O2 ^' I. G3 V4 d0 ]) O$ ]* p/ J. @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 k$ H' r4 I, ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, ^# e/ w ]0 I# [ F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% h( ~! x) Q1 K) e
7 c( `/ V5 j6 Z2 ?/ z5 J) Y( {% t$ e+ b8 |
|
|