|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - j1 {8 k- h6 J
- [code]EDMA sample test application
- v5 a# |; H* |' x* h - /*
+ [8 ~8 F/ Q- h5 v - * edma_test.c
, s- n& P0 b$ O5 k3 c - *
1 Y$ ?+ U, ~6 f8 ~ - * brief EDMA3 Test Application/ o2 F" A2 `4 [) Y+ C4 V1 ?9 W
- *
2 C' l0 a0 J" }; ` - * This file contains EDMA3 Test code.7 m0 h$ h- {& J. X/ X7 Q7 q' f
- *3 p7 {4 f% F* V0 w7 o, R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" G. b/ U9 F6 c; i$ A. X - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 G5 v) @' _6 O4 n a: t, z' p7 p - * TO CHANGE.! g" x; ~" c5 M0 C1 I4 X5 z3 e/ Q
- *5 V9 r' m8 K8 \6 @* H7 s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 A7 ~6 g5 ` b/ n - *
. ~3 l( z. ?- O! p7 W s. { - * This program is free software; you can redistribute it and/or
6 Z' G% @" y/ r/ K - * modify it under the terms of the GNU General Public License as; \6 a0 n9 j. Q3 t
- * published by the Free Software Foundation version 2.
3 Y7 i% }6 P! k! w - *
; m1 ?3 N4 X/ H, }% V3 r6 [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 v1 P+ H6 t! X [ - * kind, whether express or implied; without even the implied warranty' r8 e+ S$ Y$ P" k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 r7 G' I; x* w; E) k+ b8 \9 {2 Z) n - * GNU General Public License for more details.5 X& Q5 j0 M0 I& C+ x
- */5 w% c6 B9 Q2 a1 B
- K) ~% v* c V" i
- #include <linux/module.h>
4 x( b% ]9 a# z# @ - #include <linux/init.h>
/ R& i* H% h9 o - #include <linux/errno.h>" X3 c. S5 g, G9 c2 {
- #include <linux/types.h>
0 c5 d X" ? ]0 [: N/ M0 R$ n2 q - #include <linux/interrupt.h>
- R, r8 h. r4 c+ L - #include <asm/io.h>! A9 d! v( b6 [" I8 h4 C! M
- #include <linux/moduleparam.h>
4 G' n2 p6 L; g - #include <linux/sysctl.h>
3 L, l* j% Q* t! t. n - #include <linux/mm.h>1 V$ o/ W$ D2 s, N+ {
- #include <linux/dma-mapping.h>
& W4 z5 |( y @. O' [
3 _7 v# o6 ]: {( n- #include <mach/memory.h>
; N( d' s1 T6 u; M' Y - #include <mach/hardware.h>
2 y8 [2 D1 K& T* G: l - #include <mach/irqs.h>1 @5 w& L9 ?! l; A8 L9 m
- #include <asm/hardware/edma.h>: o3 [1 l3 m4 m
8 L' ?! x+ A' M! L- n- #undef EDMA3_DEBUG- \' P6 N, y, I0 ^& J
- /*#define EDMA3_DEBUG*/. b5 u( v& l/ `$ _! k
- + @. B- W# D8 |1 Z2 m: X
- #ifdef EDMA3_DEBUG
$ r2 A6 H, P2 j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- o6 ~; T4 S% K' ^3 J, ~! z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ _0 R( v0 \* h$ J9 ^$ C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ k: Z7 W0 ^$ t/ Q/ v2 A
- #else0 o3 z+ g( T8 p# u0 r
- #define DMA_PRINTK( x... )- X8 P' U9 F* f) J" _3 {+ f% a6 u0 }
- #define DMA_FN_IN
& G7 x p" v9 r! B: I6 J; c$ N, | - #define DMA_FN_OUT/ E9 [1 ~2 P) h/ D3 d
- #endif
$ U* e6 M; |! i) V - ' u9 s m- a) r# x2 o# ^4 R0 j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ b# C2 _1 D O) L - #define STATIC_SHIFT 30 v C3 u! O; a! ^$ W
- #define TCINTEN_SHIFT 20
# t: @* Z3 o ?0 S - #define ITCINTEN_SHIFT 21) G% B& ~6 i9 j: W# J
- #define TCCHEN_SHIFT 22
, d. ~$ w: N( W+ X! j - #define ITCCHEN_SHIFT 23
& X7 j2 D7 g' B( A9 ?8 K! E - ' J9 j5 d; j' D* p/ }! I
- static volatile int irqraised1 = 0;
7 r" L8 d7 @! d3 Z3 Z" p - static volatile int irqraised2 = 0;' [) ^1 ` c( @4 \6 P z! M) M
' u+ Z: z& X5 O0 X1 s. U4 t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! s! S$ ^0 S) ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 M/ |5 ~1 r6 {) B6 H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 F5 d1 K3 k1 d) D3 z
8 x6 j; C* v2 j& x5 `4 {, e+ @" c- dma_addr_t dmaphyssrc1 = 0;
, I s+ O9 W/ |1 j% g% z. c& D - dma_addr_t dmaphyssrc2 = 0;2 I& S/ N8 |" u0 ~+ y
- dma_addr_t dmaphysdest1 = 0;3 a' g/ ]+ n! Q# e
- dma_addr_t dmaphysdest2 = 0;! `! \+ d e1 w8 B5 O
- 9 ]0 A! o: ^8 I. a, T
- char *dmabufsrc1 = NULL;' i$ Q8 _( l' |, N0 y. t. g, h0 P
- char *dmabufsrc2 = NULL;0 L0 R6 g% P& W4 V0 W* j- F) a
- char *dmabufdest1 = NULL;
8 v) M& J% s9 v2 _9 N% G6 O - char *dmabufdest2 = NULL;
+ z0 n6 Q, {" C6 Z. M3 B% H - 7 t- ?) S, i' U9 H9 z; V3 j) U
- static int acnt = 512;
" H! l- Y' l( ]1 c - static int bcnt = 8;8 m' B: x7 a% M( j" `4 D8 ]& Z
- static int ccnt = 8;0 Y9 O0 ^# x( Z }! T) J. J! @: q
- ]& t: ^; O2 o' y( e- module_param(acnt, int, S_IRUGO);
- ~4 E; o, B% s: D1 c - module_param(bcnt, int, S_IRUGO);
4 ^% r( L7 r% Y9 a8 C( Z - module_param(ccnt, int, S_IRUGO);
复制代码
% t3 N; q q# X6 o7 w: E1 v0 q4 C- Y2 Y1 f- j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 y. P9 n+ r" F9 r0 X/ g" K% p1 {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 Q4 W( B( c5 s7 Z) F9 Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ R7 h4 ?& b7 N6 r( E0 L" `
3 a/ {4 \4 a8 T5 [' c4 e, B( \
7 n# W d. F6 \
|
|