|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( h, n9 e& X& \
- [code]EDMA sample test application
1 K! }; Z$ w0 l" `! l- ^2 E - /*5 e: m/ e& Z0 I, x( Z
- * edma_test.c
6 p! X& {+ D/ Y1 X; H$ ^: k U - *
" {' [" Q/ a) V* e - * brief EDMA3 Test Application
* b% ]/ {" {! b% ]* M - *4 v" n& T+ @6 i& x
- * This file contains EDMA3 Test code.$ ~6 a' H7 w5 ^9 |5 o
- *& M, t0 v0 s; \- J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 \1 |2 y- I$ |8 B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 l4 s' G1 [" y9 }. X - * TO CHANGE.( u9 N. p' v' J. T- \; B
- *; X: f4 B `6 n+ v, ]9 e$ r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( @8 K2 M+ P8 I1 ?6 r - *
6 }: W8 b$ ]* s% x5 n1 P, Y - * This program is free software; you can redistribute it and/or" j ?: B; [, v
- * modify it under the terms of the GNU General Public License as$ u/ _' d x1 V% C" I
- * published by the Free Software Foundation version 2.
) Y6 ^2 Y* o+ p: \; Y1 K" j - *! T, D/ C3 h+ I6 g5 n/ f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 q3 |% E9 F9 D( ~+ L; P - * kind, whether express or implied; without even the implied warranty
7 W+ s+ h V, i# a3 L) G2 v - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; D* U, C9 g# ?9 e3 M - * GNU General Public License for more details.3 }* _6 i4 s; B3 l7 |
- */
. f2 i3 [) }, e( ]( [* X - + `, R% j7 Q2 B4 U2 |6 g2 G. F8 J
- #include <linux/module.h>
' b" x2 A! L' c! i" ]3 M, ] - #include <linux/init.h>9 b. G7 e' @ b6 O6 Z
- #include <linux/errno.h>1 Q4 r5 K Z* y! h( |) }: z: j3 k
- #include <linux/types.h>% _4 A/ @- R) T& g J
- #include <linux/interrupt.h>; n' b' P# O8 D. S3 n6 v9 ^
- #include <asm/io.h>5 x8 n3 Q; U2 l4 N# w9 Z9 j" g) ~. T3 a
- #include <linux/moduleparam.h>& T5 M: q+ R- {, M. e* \$ \7 p4 _
- #include <linux/sysctl.h>4 z6 I/ E9 H. \- {5 P2 A
- #include <linux/mm.h>
/ |0 |: ~, G" ^6 d - #include <linux/dma-mapping.h> J, [7 {- h2 {/ L$ m8 U0 P
! b2 u, e8 b- u) L0 r* y3 t8 z+ U- #include <mach/memory.h>
" i6 f6 u N6 Q% ~5 s5 P w& V - #include <mach/hardware.h>1 P( F2 x. [8 u" r$ C& L2 R4 q" h
- #include <mach/irqs.h> J2 I6 H7 Z8 I! O- e
- #include <asm/hardware/edma.h>, w+ v7 Z& o* I! h7 N8 T
- ; T3 i9 |+ b, Z$ F# F {1 n
- #undef EDMA3_DEBUG
+ e3 J) w' C( P# _* }4 P; _ - /*#define EDMA3_DEBUG*/
: h- o( e4 _: |$ d$ \ - % w- O& @$ V. y4 }, W8 K8 F
- #ifdef EDMA3_DEBUG* y7 Q! Z" u1 ^4 v, m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 F2 ^5 e, x; q; u! ?( |! k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 C, X4 U! t/ l o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 s& _5 s9 g* c, X! E f" V4 V: a) T - #else
: p2 U X& j' ]% x - #define DMA_PRINTK( x... )+ m: ]$ W1 b( C2 w% Z* c; X g
- #define DMA_FN_IN
4 }2 K5 H+ P0 r$ W& ]) I8 @( | - #define DMA_FN_OUT
0 `1 t' i5 w1 }. S - #endif( k0 R4 C& W5 E2 v9 M" h, y7 s: L
- ; p3 R, C& t4 i5 C7 [) Q6 M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: [3 T4 G. I1 {; @! ~" p6 l, E - #define STATIC_SHIFT 3
; N! _- j0 ^+ l# P- P1 A; Y0 G - #define TCINTEN_SHIFT 20
. I: m. b0 i$ y& T" E- a! C - #define ITCINTEN_SHIFT 219 ~# E+ `9 Z! ]8 L
- #define TCCHEN_SHIFT 22
. {5 _" u0 t* H$ v g$ O' i' Y5 ^ p - #define ITCCHEN_SHIFT 23: a6 @: z2 g r5 _1 D! q
- " l" X! l* B/ ?
- static volatile int irqraised1 = 0;) D! e( t6 o- R
- static volatile int irqraised2 = 0;& d3 o! S( w1 t9 h7 \5 b1 a
- % {" m2 w4 `3 I1 K& C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. K) c$ z4 A( V/ V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& c: h6 G5 M" J$ B' ^" W" i3 W" m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 Z9 O2 Z5 w4 I3 q7 N4 `; r7 K
9 y4 k. f' _ c% d! {. K- dma_addr_t dmaphyssrc1 = 0;
5 T, I3 m. c) y$ c- c - dma_addr_t dmaphyssrc2 = 0;
( U1 i y" G& y: S9 F7 q0 M, J: @ - dma_addr_t dmaphysdest1 = 0;
. s; w+ y5 I: e) V5 G/ H - dma_addr_t dmaphysdest2 = 0;
8 c6 M3 ^/ M ~- {7 y
) w# f+ V* J! n- B3 ]- @, ]# S& p- char *dmabufsrc1 = NULL;
0 R' b2 z1 U4 z) j5 T% {* A - char *dmabufsrc2 = NULL;
3 N" g. j5 m5 b/ |: r - char *dmabufdest1 = NULL;6 h# S) u+ Q; w3 R6 t8 n! j; M8 H# k1 t
- char *dmabufdest2 = NULL;: Q% A4 r% {) U N0 I
- g) b3 F; |4 g% j- y5 w5 L6 ~- static int acnt = 512;; V5 S7 Q/ I, B" C/ m; w- k
- static int bcnt = 8;
9 Y' D# c# U7 K6 w- W5 O# @1 ? - static int ccnt = 8;+ v+ ?' ]+ j( v8 V' X% y3 _
- 5 a8 V8 @9 H8 O. B
- module_param(acnt, int, S_IRUGO);
8 O' q s8 P$ n( i2 S2 v7 _" ` - module_param(bcnt, int, S_IRUGO);
' m$ k# u' W2 P5 S+ t% | - module_param(ccnt, int, S_IRUGO);
复制代码 & O1 \" b0 L1 n0 k
$ d5 E4 a5 i# d( _9 U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% ^8 A; {1 ]8 a0 r7 a
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" R' p1 {% N. @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* p6 ?- c- x3 ~
( d# W' ]+ e8 ]) a2 f
9 e& S% T( Y# S1 N
|
|