|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% V9 f8 t8 d! H, f: ]- [code]EDMA sample test application
) l2 ]4 J, Y6 f- P. R - /*/ d2 `" c5 z+ _- V, ]$ n% }6 A
- * edma_test.c
8 M6 @+ X0 C- n# f8 y& P+ U: P - ** i* a/ k. I. G; k
- * brief EDMA3 Test Application* ]0 v! M) @+ c' B
- *
2 {" J# ^2 Z5 i5 S4 X8 Y& m1 @5 D; { - * This file contains EDMA3 Test code.
8 M6 v4 J! H) @9 a - *
9 V; ?. W4 K, B+ J1 B4 D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- ]) H$ e& c# w1 b$ e1 @' p/ |1 ^& v' I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 s" R: u; v* }5 I' r- \
- * TO CHANGE.
! \/ o- q# q2 i) r7 \, _( [4 e0 k9 x. A2 { - *
+ K" Z4 Y6 R* A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* `7 b8 b. _/ ^0 l0 W - *
. U) N1 D- y& T - * This program is free software; you can redistribute it and/or" I1 _! k1 O1 }5 r, }
- * modify it under the terms of the GNU General Public License as
@: b$ p$ S( g4 H& Y. B( O - * published by the Free Software Foundation version 2.
% S& v; I h4 P+ U/ | - *# v8 k. F( k1 P- U3 h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 f$ A5 ^* i7 D
- * kind, whether express or implied; without even the implied warranty1 G$ p0 j6 e& V; \! q/ D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* {: Z& h$ I. b8 m' L+ v
- * GNU General Public License for more details.; H$ g/ i l c( _) }+ L0 A/ D
- */$ r3 U6 s1 d' v$ Q' v# n) A- ?
- 4 d! L' h8 Y/ W, Q
- #include <linux/module.h>3 Z, b2 n( z7 z
- #include <linux/init.h>
) d: F* g+ u5 Y- l$ J - #include <linux/errno.h>$ r9 p3 J: F/ Q6 v" ^0 W; C% q
- #include <linux/types.h>4 I* j9 }: D# I& t9 X6 [9 M
- #include <linux/interrupt.h>7 {3 E' ?6 U: o
- #include <asm/io.h>
! j0 J$ n' X1 Z - #include <linux/moduleparam.h># b' [1 d, W$ T8 m4 A
- #include <linux/sysctl.h>1 |& j7 E6 A/ E1 v
- #include <linux/mm.h>3 j) Q7 Z" q5 L
- #include <linux/dma-mapping.h>
1 ]2 D Q; F) z
9 b6 J3 J; P- B3 n- #include <mach/memory.h>
+ {/ j7 R5 ]/ y3 O2 @% c( [ - #include <mach/hardware.h>/ K! m6 m: K5 p
- #include <mach/irqs.h>
, u# q& ` Y3 s$ i - #include <asm/hardware/edma.h>. ?; g( ^ D! r7 G
- 2 \; g h! {% V, K( R
- #undef EDMA3_DEBUG
/ ]5 h5 A8 f# C. { - /*#define EDMA3_DEBUG*/
0 E5 }1 K' L( F! K - " f" b# T! j# q' J+ X
- #ifdef EDMA3_DEBUG( c: U- _- m6 K* T9 Y) i; C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- ?/ m/ Q: L3 O( k! [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 `2 k- x- r$ _# A( Q: h R* b; G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# o1 V( g$ Y$ h; J$ G% }
- #else
( J/ x; M' {- r" ?: I) W } - #define DMA_PRINTK( x... )
7 `2 S: K+ Y( h - #define DMA_FN_IN
( G2 _; j9 C, F - #define DMA_FN_OUT
1 \) [- R8 z. O1 H! a - #endif+ c0 M' ?. j8 ]$ v* [4 ]; V6 O
" W- ]% s0 I0 g+ \ R% v! q$ f. c: J- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 B! L, ]* _, {8 O6 c3 J$ u
- #define STATIC_SHIFT 3, l8 [) P4 k: F$ n
- #define TCINTEN_SHIFT 20# C2 C0 G1 n- r
- #define ITCINTEN_SHIFT 21
- j. ?% r) p" ^& m - #define TCCHEN_SHIFT 22
, J3 F$ M2 t% g/ { - #define ITCCHEN_SHIFT 23/ O: F) B2 p2 r8 I+ A$ M2 c; J
6 {" O# k0 ^- ]/ Y( A- static volatile int irqraised1 = 0;" o* c8 T; J4 m3 V
- static volatile int irqraised2 = 0;' A! B9 J$ {7 Z- w" w
# ]' |& D+ q5 k! g0 S1 v4 U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 p! L _9 W( l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ }3 O6 |: _* ]8 f) ]. ?* G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
n) |- o( B! x6 _8 ^4 q/ ]
' y& K) C; h% R# g- w* m- dma_addr_t dmaphyssrc1 = 0;
7 ?2 s8 B- i+ r) g6 e: i0 O5 U7 f - dma_addr_t dmaphyssrc2 = 0;+ V; E; D. w! n1 M: `2 L, t) [
- dma_addr_t dmaphysdest1 = 0;
" S v) g: k9 v& g: P9 g5 ^ - dma_addr_t dmaphysdest2 = 0;
9 {- {0 I0 p8 G7 `5 l - S+ E6 }) `% F' V4 ]; x
- char *dmabufsrc1 = NULL;2 E( p. N* F' J! y
- char *dmabufsrc2 = NULL;
/ n! X, M' o: C3 t - char *dmabufdest1 = NULL;( F3 X: e1 x) w! _ A9 V
- char *dmabufdest2 = NULL;
( Z) }* l6 G7 v& s - ( v# h6 A" W: m2 N! k
- static int acnt = 512;4 ^3 U5 @/ L. n. z+ d
- static int bcnt = 8;
. N) @) S; A* H" k# ?# N s - static int ccnt = 8;
/ ^1 w) d# ?3 W* h
9 p2 w( z! U- u1 W- module_param(acnt, int, S_IRUGO);
* Y8 c. D1 Z& ~& S - module_param(bcnt, int, S_IRUGO);
2 [# E! [4 Q3 J( Q, c - module_param(ccnt, int, S_IRUGO);
复制代码
8 T* p& o4 h# O, T# u$ g
# D( z s; j: K8 h6 R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 y$ R: T0 h! S8 Z1 @+ j8 C9 l# {
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ I2 y$ e6 t: q. o6 a; m! H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 R4 E0 W: O8 u7 R3 [1 _9 I! M
$ \6 j. x: R' \. k/ \+ ]4 N+ E Y; N: \ U+ G" P2 z' t! o; W7 L
|
|