|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) v& r2 Z7 Y9 P2 A9 k7 L- [code]EDMA sample test application
9 H7 l, N" v& P: m: R - /*4 H W% J J- F0 J! Q+ N
- * edma_test.c
5 ~& {! |5 }9 f0 g3 f9 { - *
! k- ]4 T. y1 T% Y - * brief EDMA3 Test Application& V3 n8 E0 J7 U( W* ^9 T
- *
' V# o1 ^0 V! M) q - * This file contains EDMA3 Test code.
7 y$ c+ G4 I5 b0 E% O$ i - *# b; W# k3 C% j6 f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
L. R2 [# ]1 Z1 E9 i- _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" C5 t- {3 a, [
- * TO CHANGE.' u) i% o) I* s" M/ g" G7 {
- *
) K2 {# H3 @- u) | \3 [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& r$ N Q. ^. e+ p& E, I2 ] - *
9 G3 J- R+ W2 K3 t* b+ B1 D - * This program is free software; you can redistribute it and/or
" A$ B( M3 P' M - * modify it under the terms of the GNU General Public License as) ]$ A) F1 f0 \( U" L X
- * published by the Free Software Foundation version 2.7 x6 y- n5 g# i, J
- *3 |# ~& H4 f$ V7 E# R/ a, l# m: I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) ~4 Q' @: r. m+ Z5 v( k( N' Q - * kind, whether express or implied; without even the implied warranty5 x8 R8 W; s/ M1 Y) R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 F9 H. r* I6 g. s7 ?2 B+ F' N/ {
- * GNU General Public License for more details.4 N! S6 p0 `, ^" z0 J9 C4 s
- */
- [; f- @- j1 q' u7 H* Q; D - 3 u( @! D- y' z# a
- #include <linux/module.h>- H* e8 w4 a/ z D' B$ q* R
- #include <linux/init.h>& d) ?6 A. G8 ?8 [4 \: n& i/ ~
- #include <linux/errno.h>
: w! Q! |0 \% G1 C' o0 M4 B - #include <linux/types.h>
- o. A8 [! O4 n, p- q' D' v - #include <linux/interrupt.h>
: o. B c6 g3 W6 a, c0 J! {; w6 |9 s - #include <asm/io.h>
' d e* R) l; k+ I* ^( G' V/ _; J - #include <linux/moduleparam.h>
7 p) c; i* o6 r% D; Y( A3 }( ] - #include <linux/sysctl.h> N( ^( F! g7 u7 t, Z, o
- #include <linux/mm.h>/ w' m- t1 x3 [, C& A8 O
- #include <linux/dma-mapping.h>
" [6 I/ A' u" `- ?( V - 7 [) E3 v0 r* c' `6 O( m1 `
- #include <mach/memory.h>( G* v* `7 r" _0 I
- #include <mach/hardware.h>1 Y$ w! t4 J) C Z1 e
- #include <mach/irqs.h>
5 @' B+ j; M' m0 g$ l9 i - #include <asm/hardware/edma.h>4 h A6 D% }. R$ h' \1 V: B, v
- 0 C" M9 y" F% x5 y
- #undef EDMA3_DEBUG
& `7 p! i. e2 R# W4 n - /*#define EDMA3_DEBUG*/
$ b0 Y0 L9 z8 X3 l2 [& O" r
! x- w$ d* r+ K% V l- #ifdef EDMA3_DEBUG
, f( W9 V# @: _# D, D4 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) [1 s# j; d2 v) u) R+ U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 D3 q7 J$ s2 J& x8 {& u: _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ R6 W. o/ @3 g" u7 n/ ~ - #else2 D5 e; s' i8 N
- #define DMA_PRINTK( x... )
) U6 L: j! ~- t5 o/ N - #define DMA_FN_IN" {3 t6 F& f1 R5 i
- #define DMA_FN_OUT$ t( M! E: P; W1 \; d0 ]8 H0 W
- #endif' X" v1 l2 E2 Z$ k: J7 i
- ; O0 O- |! o5 l
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 G: |5 Z" ]9 ]$ f: y# g- k! X - #define STATIC_SHIFT 3# e# t9 R. _3 D1 R; ]. B/ D
- #define TCINTEN_SHIFT 20
# M1 ~ q" m3 Q" y - #define ITCINTEN_SHIFT 21
* r/ U% C, x+ Y# y - #define TCCHEN_SHIFT 22
. X/ } S) G! S$ S/ {9 B L - #define ITCCHEN_SHIFT 23" h: D) n& w) e* y1 v. Q- C
- 7 @1 y3 s& o) m
- static volatile int irqraised1 = 0;
! x7 S# |. U. M. Z/ ]' y - static volatile int irqraised2 = 0;
% ~& n, Z, o. v6 g) E6 n0 T
- n! O. u- H) R# \: b7 a5 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 N" x# h$ q. t. ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: [/ a+ I( ^( C8 N% y6 x( ]& v7 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" e& x, C% ?4 \6 a4 ?1 \; z% D - * w# f- j+ l1 i( T! y6 A7 G8 t# b& o
- dma_addr_t dmaphyssrc1 = 0;; N6 X# A# [( y$ b, u
- dma_addr_t dmaphyssrc2 = 0;2 q, d5 D" ?% s
- dma_addr_t dmaphysdest1 = 0;
2 m/ y6 n: P3 g N - dma_addr_t dmaphysdest2 = 0; [( G. }) z5 p" t2 q
- 7 q% L# `, K- @* }. c+ N" D
- char *dmabufsrc1 = NULL;
2 ^1 z7 D) V6 P: c( ? - char *dmabufsrc2 = NULL;
7 M# f7 q$ w. m, g - char *dmabufdest1 = NULL;
7 {5 W+ f# ?0 i - char *dmabufdest2 = NULL;
' S b4 K% s- c" q% L& l+ {" D - % U7 p" O* ]7 l" F3 v4 X* I
- static int acnt = 512;
[4 H; \) W: k n: l0 k - static int bcnt = 8;$ p E" ?! U, w% X. }2 r y6 M9 \
- static int ccnt = 8;4 | L" j/ b* a
- # }/ _. e. u+ y; s: i) k/ W4 A
- module_param(acnt, int, S_IRUGO);
$ B3 q0 Y6 l2 _2 g$ K - module_param(bcnt, int, S_IRUGO);
$ Y9 ^, I* I# ]( P2 E. [ - module_param(ccnt, int, S_IRUGO);
复制代码
1 b7 M: f5 T( ^3 }1 B, s" i+ f' @: N. _- g. J) h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& i$ l- p* j Q& K5 aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 e+ x# D7 |2 X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, L7 q; E( x4 }3 @5 h
( I% P: T" T( I) g7 @
* @0 O( k; K- x1 h9 V* ] |
|