|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 Q( e- \) f3 G, W8 i. Z( q- [code]EDMA sample test application
; ]* S+ ]- ]- ?% W1 ^ - /*# H& W; M5 S3 j* W& i) d
- * edma_test.c( Y! _7 s+ ^/ k( l( z9 B" X4 f$ g
- *
& f0 Z6 `$ ?5 H0 Y! [ - * brief EDMA3 Test Application
( D( q: }: c: d5 W) C: j" \ - *
/ }. b2 t7 M; [4 B1 t - * This file contains EDMA3 Test code.
6 ]5 N/ G6 H$ t, U9 H8 j1 K - *
' s$ A" b3 j3 { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 Q% F% p; Z# ~9 ^# z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 S- b& a, M. t! m; b; ] - * TO CHANGE.
4 N% B% k# p1 c Y2 P( O - *
9 G8 F x y/ H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 o' `" A; e' b5 [2 }- _$ q - *
' \7 |5 @9 G# j$ _% ^# M - * This program is free software; you can redistribute it and/or5 U$ z2 w# K1 \
- * modify it under the terms of the GNU General Public License as
/ P9 M2 y$ A* L9 o - * published by the Free Software Foundation version 2.
# y& I# R% s( X$ s" D4 m - *
8 ?. `8 v! x8 y! w! a4 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( Y) R7 ?$ m6 a8 a, y+ [
- * kind, whether express or implied; without even the implied warranty
6 b ^ G; B& r, d3 [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ e6 f6 _- V! _2 O$ v
- * GNU General Public License for more details.
! l1 m) f$ X$ P9 X9 S/ m ~ - */# k8 k! B: Q- x8 p2 d
- ) A1 @5 h6 \3 A G% L- p
- #include <linux/module.h>
# Y2 ~7 U9 M7 M+ f% Q( Y - #include <linux/init.h>
2 k# s2 o: I i. e4 z* \" d - #include <linux/errno.h>: D. o6 p, ]$ W8 M1 L
- #include <linux/types.h>
+ |2 Y# K. _: k' Q - #include <linux/interrupt.h>5 D: f. I& Q7 I6 b% b
- #include <asm/io.h>
: a( r- a# g# Y- K9 a& } - #include <linux/moduleparam.h>5 p7 T: W/ |% W) H( v# J9 n* m
- #include <linux/sysctl.h>
v" ]/ J2 E) x# N c& m/ q* m9 X - #include <linux/mm.h>
2 n) e4 m* S. H. K9 }4 y - #include <linux/dma-mapping.h>* J; t U6 ?* [) L
; @1 f7 q9 ^, ~& O- j4 J- #include <mach/memory.h>1 F/ k+ F; G5 @* {" u2 t
- #include <mach/hardware.h>! I4 h; Q% Y( z2 q+ \
- #include <mach/irqs.h># G9 b+ N" f" {0 Y- b/ M$ Z" L
- #include <asm/hardware/edma.h>
( O7 w/ G. @9 g2 y$ W. F - 0 u9 T4 ?. J, B9 r) r) F( _
- #undef EDMA3_DEBUG
( ]- o* M# x/ f/ l - /*#define EDMA3_DEBUG*/
6 J2 x% z: y* F4 U& R" o - 8 Q1 S E! G5 `# o- |
- #ifdef EDMA3_DEBUG! a3 H1 d8 _& v6 s: g# t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ D% V: K1 [2 g, C8 V: P; P, Q6 H - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 v5 k( _: b5 [6 Q2 V1 Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: V9 |* p+ X6 q" w/ D - #else2 v* o3 @, ^ X/ _
- #define DMA_PRINTK( x... ): X) x0 y. A3 i( H5 {' a
- #define DMA_FN_IN/ p0 w% O% u7 }$ r& D2 X5 d! @ ~
- #define DMA_FN_OUT
3 I+ k# v" [: A. J5 Y# J8 O - #endif4 R, _% @$ Z0 D1 h# X2 t+ c
+ |# o' B- K( ^- C- U* ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768): J% F) m0 m6 }0 \) X
- #define STATIC_SHIFT 33 ^( ^& _( u* R
- #define TCINTEN_SHIFT 20 {" `$ M q& G b
- #define ITCINTEN_SHIFT 210 n& g. u" v0 ? ^
- #define TCCHEN_SHIFT 226 Q- U& w* A: [' X7 d: p" s# l
- #define ITCCHEN_SHIFT 23
& a0 T9 E5 k5 |. ^, A' W - 7 ~5 x- u. b0 G. b9 P
- static volatile int irqraised1 = 0;, ^+ ]9 ~1 l( X$ B8 o; P
- static volatile int irqraised2 = 0;5 @, X/ i2 d7 ]4 A0 D: m* t; h$ C
4 b2 Y, \8 _+ X& ]: K" M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" f3 q n! v) P: }
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- ]: w1 T+ m$ o2 K1 n* ]1 m8 M: u$ U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ X; G- [0 x# B9 K3 F8 V( R
- 0 e' l0 Z+ N" H* c7 S2 q, l
- dma_addr_t dmaphyssrc1 = 0;
0 S% I, N3 R0 i4 U t, q! t# g - dma_addr_t dmaphyssrc2 = 0;2 p( I/ i8 S* d! ^8 A' V+ s
- dma_addr_t dmaphysdest1 = 0;" t) H* Z0 y+ g2 I
- dma_addr_t dmaphysdest2 = 0;
- H, g1 } J& s) L' M9 k% r/ r
2 H6 w! u8 h3 ~ D" y+ h+ E- char *dmabufsrc1 = NULL;
; _' w4 e5 y, k& B2 \# l - char *dmabufsrc2 = NULL;
" f/ \7 q/ Z/ H" W b3 G, w9 P - char *dmabufdest1 = NULL;
* R; N7 u- H1 [( g I3 Y - char *dmabufdest2 = NULL;
; B @8 S+ A( X# Y: B0 h+ R
0 L% c3 x. {% H! e( _4 E- static int acnt = 512;( ?, [9 p9 W4 K( H/ y4 a
- static int bcnt = 8;2 ^; D! U: s ^9 T& v
- static int ccnt = 8;9 l% m2 D- J* T) P& l4 J
! E" {7 K5 ?+ e( {- module_param(acnt, int, S_IRUGO);
5 O7 X6 A& G+ _/ k- i1 K b - module_param(bcnt, int, S_IRUGO);
) U5 |# w* A& J( B* }) Q' E# ? - module_param(ccnt, int, S_IRUGO);
复制代码
, n j' M: k5 b; c! Q. E" w/ O: q7 E5 r# J7 h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( K" x. R% Z' j0 Z' q+ D* Tarm-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 i( C8 p: W% K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. v: A9 r% }8 {0 r7 Q/ L7 S2 e0 ]
( T3 d# M) A+ s, I5 }. f
0 q" x7 f2 d9 {5 t% j" q
|
|