|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + G9 v1 C4 L- A5 K3 U; z
- [code]EDMA sample test application$ w c: E" H" x- @
- /*
/ E' D4 H! r8 q$ O - * edma_test.c t; k2 i" d( P! g! R# Y/ f
- *5 E# e E! v) B- e
- * brief EDMA3 Test Application
5 w6 P* D0 G# l1 R2 T0 [ - *
8 f" O" [1 m0 Z7 [ G1 d - * This file contains EDMA3 Test code.
$ i$ I3 R- L* Z# o* I% d+ d - */ Y2 _9 n. ~+ a& D/ o+ {: _ r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' Z; z4 Z6 h2 Q9 ?5 C7 m$ A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" t2 b: z7 w& F7 ?: Y - * TO CHANGE.5 o& X, I. T, W) M- r; A
- *
* {5 S# h p& _# _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 J% Q9 T0 L# v# I8 h0 j k; i
- *
" L4 l1 z, g4 \9 K' Q4 z& q - * This program is free software; you can redistribute it and/or
+ W! d7 K' J: o g6 T - * modify it under the terms of the GNU General Public License as
6 C9 r% J7 F4 k3 ] - * published by the Free Software Foundation version 2.
3 H" N( z) P; S - *
/ ^; D* U* ~0 k/ r. C% r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 T- {* B: C) `$ R) V - * kind, whether express or implied; without even the implied warranty. ?+ }6 p3 b5 q, _6 I3 b6 ?9 k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; `% G2 \" R( l9 |( d2 { - * GNU General Public License for more details.8 w4 Q7 b3 t* j$ I0 n3 O
- */
5 M& g1 ]4 J, [* \% d - , M7 g' o2 ^6 X4 {( u0 D# g
- #include <linux/module.h>& E- a5 M2 u, @
- #include <linux/init.h>
+ u! `$ E4 p- [$ U( A6 k5 S8 N2 |, @0 I - #include <linux/errno.h>
! B3 v2 J! g& @. C* W) n - #include <linux/types.h>
5 ]+ P7 l+ N& B" J, p: D - #include <linux/interrupt.h>
- P! E+ k" Q) V. U: ]2 F. L - #include <asm/io.h>
9 R$ |1 H; F9 j) o9 o5 f! T - #include <linux/moduleparam.h>
: l; u$ w" H" N2 a5 C5 K( x2 j - #include <linux/sysctl.h>
3 c* e3 Q" {, U# a! Z- @ - #include <linux/mm.h>2 `9 T0 r* \6 o: y* i2 `
- #include <linux/dma-mapping.h>; f! S9 ~3 g e: I2 e3 N
- 9 P/ e$ ?* K1 }( k( {" V# m/ [
- #include <mach/memory.h>+ i7 N* H& ^& p6 c! ]* p
- #include <mach/hardware.h>
& N% d+ t- Y$ @, W: W* h/ s" i - #include <mach/irqs.h>" ]9 k" G t. G: e& A8 M I7 g
- #include <asm/hardware/edma.h>3 p P& J. k$ i8 X4 d; m6 K& O
3 G, K1 R9 y' H' w/ W( t' i- #undef EDMA3_DEBUG
: ~# q1 o% u0 C1 q7 B1 o$ \2 \. A - /*#define EDMA3_DEBUG*/
' n ~2 |6 D1 `( ]" x/ n
1 L7 L3 P, R' \) P1 N: V. p: M$ }- #ifdef EDMA3_DEBUG2 d3 Y3 _' C* C7 F- z6 X
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): R3 F$ K, [3 }; J' ^5 _. y/ L' {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& m; c/ z. B& z+ \2 S% b4 i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ B+ p# k* u! ^- u! I
- #else
$ b2 A; [ P/ l6 r6 ~& ^( w0 v - #define DMA_PRINTK( x... )
U5 }' Y3 S& J! v- V. i1 w; z - #define DMA_FN_IN
. @6 W) H: Z& {) } - #define DMA_FN_OUT% Z8 h$ r- \$ u
- #endif
3 s* Y+ s8 C0 u$ U, V - 8 s. X0 z0 `, R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! d# X9 N7 G5 ]" w: N - #define STATIC_SHIFT 3+ | w% v5 f8 h3 Z9 s
- #define TCINTEN_SHIFT 20+ ?$ H/ x& H& o4 `6 R5 k" i, X
- #define ITCINTEN_SHIFT 21" [5 E9 s( r$ j# |) V5 d4 C8 z
- #define TCCHEN_SHIFT 224 p6 y$ E8 V0 b
- #define ITCCHEN_SHIFT 23
; G* i7 g5 w3 i+ Z( M - ) Z O6 B7 Y* y) P% u
- static volatile int irqraised1 = 0;/ z. T- T2 n+ b+ v' G2 J: l0 | O
- static volatile int irqraised2 = 0;$ ]. `" z+ j/ }4 n, C
- , j. d! X1 D& f2 m2 E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# B F! Z/ m& X- i% D. `* I - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; A1 I* H: t! _7 S/ e" U4 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. l* i0 ]. B' l0 |" e7 Y
- / G1 P* v: i9 I7 i& z# \& M
- dma_addr_t dmaphyssrc1 = 0;3 F. G P0 w& e4 l3 Z" M7 o4 `
- dma_addr_t dmaphyssrc2 = 0;4 g! a/ ~7 u$ ]/ Q) I
- dma_addr_t dmaphysdest1 = 0;
& j; l; k$ f8 u5 b - dma_addr_t dmaphysdest2 = 0;: p% V; n# k+ t" W, _; ~3 ?8 R; ^
- 4 R8 A4 E3 ~) K) C, _
- char *dmabufsrc1 = NULL;- S4 _0 n3 |* @$ r" u/ {
- char *dmabufsrc2 = NULL;% S* O) k1 n d: f) @6 N
- char *dmabufdest1 = NULL;
i/ ]' c7 i' ]# [: O. g5 D+ k$ _ - char *dmabufdest2 = NULL;
; V1 m# o5 i/ X. v7 j0 p1 E; K. n
, a& D5 D G B2 I( p2 D- static int acnt = 512;
6 b# }4 q( W, X! A% w+ q2 ? - static int bcnt = 8; {6 E+ t$ m: _) N* t% G2 ^
- static int ccnt = 8;
/ m* t: U4 `2 [+ r - # _4 H7 r8 k+ `' k
- module_param(acnt, int, S_IRUGO);
5 W/ s$ g$ Z% Q - module_param(bcnt, int, S_IRUGO);
- O1 T, L; X. f- E/ \) ?% s4 E - module_param(ccnt, int, S_IRUGO);
复制代码 - Z9 x" i( d8 H6 h2 I
: O' W+ \6 C. s& _. }" C
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 v( F5 D( C/ U x1 F/ `" Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, Y) q& r4 |8 a5 g9 E3 x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 A* p6 p, K* z% s1 u, }0 i* D+ ~9 B
. B- M/ m ?4 R6 E1 U# M( j7 a$ J
8 i$ ^1 J/ [1 `4 `- x1 ? |
|