|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! @' _0 ?. v5 E- [code]EDMA sample test application
! H4 W; s8 [; F& ` - /*
# {5 V5 \1 w1 a8 n% g& V0 _ - * edma_test.c" a6 w A. ?6 Y2 I4 O
- *9 B3 M$ e$ y% ~! v) _, P
- * brief EDMA3 Test Application8 [6 Z* G9 z8 H8 O ^1 m
- *. N# x0 _1 a) N1 Q, ]- J% w
- * This file contains EDMA3 Test code.1 x- O, L( {- X; W" K; e0 g
- *
! F7 U6 ?; C2 z6 ^1 T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, L a4 R/ H2 {- S: \. K8 ~ ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 {( h0 _ S4 x/ c
- * TO CHANGE.7 Q( Q. z5 R7 G) I, W* u
- *& p$ a- {' |+ G' L8 U: P# [/ P9 O y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' G1 {5 d: t& F K, f - *
9 E7 f9 c2 \2 L2 q - * This program is free software; you can redistribute it and/or2 E# T0 j' j3 y- m* G# C/ m; d
- * modify it under the terms of the GNU General Public License as. G& g/ m% @6 v. f1 |' @
- * published by the Free Software Foundation version 2.
! d1 r. h- ^/ W/ n0 M/ @- h - *. S, a8 a. r; W' ~+ n/ k4 z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 R7 I R0 Z3 l* ?3 D - * kind, whether express or implied; without even the implied warranty
& N6 ~' r" I n! q2 G1 J - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: |6 x+ p% J/ W4 ]) G* g5 d# _
- * GNU General Public License for more details., \! c; O$ \% A( v
- */% y/ L+ u, l9 a( B, u4 g5 x
- ( G9 z- k# ^4 z' ]! ~2 E5 W( i
- #include <linux/module.h>
& M) Z0 l" M$ n0 z- G, p - #include <linux/init.h># `/ ^* O3 z0 x9 x3 y7 c% @
- #include <linux/errno.h># U1 o$ X; N, [# g+ j
- #include <linux/types.h>
! |. K& m9 H/ a' J3 @ - #include <linux/interrupt.h>( l3 {7 T% T/ E% H) ]
- #include <asm/io.h>
( m i/ ~8 n: k7 H - #include <linux/moduleparam.h>0 _# w( W5 B) `1 i0 g4 g9 m6 q
- #include <linux/sysctl.h>
& a" A$ }, p2 \1 x - #include <linux/mm.h>! w/ J& D3 b! |; O2 V: E
- #include <linux/dma-mapping.h>
& M9 u2 M% `( d5 ] - % \2 } k6 b- C2 w9 p
- #include <mach/memory.h>
( D8 n1 m3 L* n: J: ?. M) R: B - #include <mach/hardware.h>
; ^1 q( V. K# V" S# y* p8 o3 ^ - #include <mach/irqs.h>
: o4 r e4 A0 s* t, O+ P - #include <asm/hardware/edma.h>7 W- J0 Q0 @. S
: ~# W: r4 c# }! g- S- #undef EDMA3_DEBUG$ t2 @9 y: I9 ~& _2 Q7 O
- /*#define EDMA3_DEBUG*/
, d3 C9 H/ `2 n" P: v, s6 s
0 U# O+ s: }! b" o, A: v( s: }3 Y- #ifdef EDMA3_DEBUG
2 W. [3 u! F" r8 `' a! G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ r& ~) K i4 q, Q5 U7 o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) `5 `: ~4 z$ Y5 D, a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( x @. G9 n2 K7 d6 a) N, x
- #else
4 J& Y: O6 h6 m. d - #define DMA_PRINTK( x... )
2 B' U1 V9 s# b" N3 Q; P% J - #define DMA_FN_IN
# U. `/ N, q1 L% o: j0 j7 V - #define DMA_FN_OUT4 ]3 ~7 q# V7 {# d
- #endif) a8 G7 \" a, ~
- ' k* h6 |* t* Q( g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: {; S. p1 R; O9 X# L - #define STATIC_SHIFT 3! h- }* O' @+ [& O* V4 P' J+ v* m
- #define TCINTEN_SHIFT 20+ O. i6 Q6 y9 ]; y% E% }
- #define ITCINTEN_SHIFT 21
/ F k7 Q5 e: D8 O7 P - #define TCCHEN_SHIFT 22, v+ _$ ~9 F0 w/ V
- #define ITCCHEN_SHIFT 233 |2 L. P% X( U, B
8 H) T) M% Y: Q0 r1 Z) H0 Z- static volatile int irqraised1 = 0;- _' F3 w4 U e( v9 K4 V) f2 l. [
- static volatile int irqraised2 = 0;
* N0 a. Q2 Z, B6 _/ o3 S7 @6 ]
h: e) _5 Y" R( l5 m6 |; L- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# w) s6 o% X4 }2 ]4 T% ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 L" `3 C( u' K: W9 j" v& ^ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( t$ V! y& ~ e
+ ~/ R7 w* V- B2 F( x- dma_addr_t dmaphyssrc1 = 0;
6 w( L; d, n+ w& g0 M$ b - dma_addr_t dmaphyssrc2 = 0;% K' j+ f7 @/ k. L y
- dma_addr_t dmaphysdest1 = 0;5 o" G1 b( W$ f! m3 u2 h5 W
- dma_addr_t dmaphysdest2 = 0;
; Q0 Z4 n+ O+ ^4 n. Z Y! D' r
' U! G0 m- J; Q2 S5 a0 ~. k& F. U$ L- char *dmabufsrc1 = NULL;# M$ w/ _! o& M# M; L* c
- char *dmabufsrc2 = NULL;8 a' C1 V; f9 d/ @' C, w
- char *dmabufdest1 = NULL;1 _8 i1 Y. p; H! ^3 ]8 d: H
- char *dmabufdest2 = NULL;8 Q- C8 w1 [- F3 k9 d
- 7 ^* a% H7 u0 ~, M
- static int acnt = 512;2 p: c: U: d$ s0 `; d# R
- static int bcnt = 8;
8 p* ~+ N z. }* b% Q% v( E - static int ccnt = 8;
# j' j% T- p9 x - : w& @: [2 T. z8 C; t' Z! l# [
- module_param(acnt, int, S_IRUGO);2 J$ y9 @6 L, u3 Y" J
- module_param(bcnt, int, S_IRUGO);
: w4 d! x& q; L6 k" A - module_param(ccnt, int, S_IRUGO);
复制代码 0 _7 x) a. E% B n; P
' H8 B$ t7 z/ U" u4 S* l9 |: A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ ^; |; X# ^: ]$ ^( darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 O2 F7 v5 K: I0 ]: V; I4 a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ n0 F; G5 s' u
: [! b7 G4 F2 p; I7 V$ k
& C. |9 p ^9 U t8 k" {5 b) L |
|