|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 ^$ \% w# R- v9 D3 U# C
- [code]EDMA sample test application8 K8 ?4 s: a( E5 J7 t
- /*
$ A. D9 a7 W& |8 k - * edma_test.c' Q% p4 ~) T( C$ W+ N
- *
- v" |! N' A3 z% l - * brief EDMA3 Test Application( s+ k3 f9 |& j; `: Z& S; X
- *# l/ h, s7 D4 c8 l% e2 W% H
- * This file contains EDMA3 Test code.7 a3 s; S+ a% s1 O L
- *
7 ^4 y' p7 A& y% g( N$ G' \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ x5 F# F7 t; w( q5 y/ e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; U1 ~! z9 Y6 B N$ B
- * TO CHANGE. B+ ~' i, w8 q [. q
- *$ t+ E' K4 H% o- _2 \$ C3 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) o4 n9 H' A' H' d/ y - *
% [6 i- o8 y7 @& Y - * This program is free software; you can redistribute it and/or
X; C3 K. J" x% ]8 b9 |1 e3 P2 k - * modify it under the terms of the GNU General Public License as3 e L2 O: Z* M2 s
- * published by the Free Software Foundation version 2.0 i4 I: h. h' n F6 J; I
- *
& @1 G& ~# h8 L - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ j( z$ h- y0 e, Y$ h+ u0 `. D' f
- * kind, whether express or implied; without even the implied warranty
- d7 r$ G# ^( z7 i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ D8 w+ \/ V: }7 v+ ^! e, e$ W - * GNU General Public License for more details.
! |7 s+ k% s; s# J/ B - */
! i0 N; q9 Z( ]$ c. F$ Q5 B M - / n4 x) Z. J- z" l
- #include <linux/module.h>9 x# _* M' H/ u. G j3 f; ^+ f5 j5 o
- #include <linux/init.h>
9 G: r0 P1 a8 _3 z, Q1 ~# _; K" h - #include <linux/errno.h>
3 k: n! C2 g, ^ - #include <linux/types.h>8 @" R- q, K/ R, F
- #include <linux/interrupt.h>
# d# H8 L4 V* N- a% d$ D - #include <asm/io.h>
; K5 O' w3 D0 s/ ~8 v+ A; D - #include <linux/moduleparam.h>
' @; U. l7 M/ X5 A8 A - #include <linux/sysctl.h>- _/ v0 ?( n) J
- #include <linux/mm.h>
j$ ^, L0 ^, k1 v - #include <linux/dma-mapping.h>
2 s5 C) H3 ?& y8 F k7 y i; t) u
* b* S2 H- [8 L# E- #include <mach/memory.h>
8 H7 U) ?7 C1 a9 E5 X- q - #include <mach/hardware.h>
/ H5 ]1 }4 z- O4 d" Q k' I - #include <mach/irqs.h>
6 @! g, @# _' L' A ^, \& V - #include <asm/hardware/edma.h># f7 h! [& x; B$ R2 O# C
/ f8 Y6 b* z; [9 N1 ], D2 E- q9 K# X- #undef EDMA3_DEBUG
g- c# Q4 p" ~+ d; A" ~ - /*#define EDMA3_DEBUG*/
* W. L) g' D- y- R! O5 \- e
8 v% q) H6 A# t# j5 j8 c+ |# c& a4 T- #ifdef EDMA3_DEBUG
! P% p% j' {7 F3 V: v3 C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 |& j6 I" W# x* |' T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* Y% _* E3 L9 p- ]
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 _% D {: o5 ] - #else$ L+ V/ E0 t7 L3 X. {7 _, I0 S0 f
- #define DMA_PRINTK( x... )/ H8 ?* k, m2 P3 p; b
- #define DMA_FN_IN/ [+ p* ?: ?( `/ R
- #define DMA_FN_OUT
) U" j. c8 b" e8 m0 O0 K' M - #endif
9 k( |7 ?; g1 b( s! c9 C
8 a8 L9 G$ d: @& @* c$ s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 A8 z' t% n' t! l; |$ Q
- #define STATIC_SHIFT 3
8 n0 v3 {! E! s, i6 M7 B0 J - #define TCINTEN_SHIFT 20
* I% Q* l5 O# K& W9 X5 L- N - #define ITCINTEN_SHIFT 21
7 i" I( y5 Q4 o& @, Q - #define TCCHEN_SHIFT 22# l5 @0 _9 X/ e4 [5 @
- #define ITCCHEN_SHIFT 23
: v3 F1 I I& L$ o7 C# \ - 4 m4 e$ f# J+ X# f1 j
- static volatile int irqraised1 = 0;
) ]$ Z g1 \+ t6 t( ~! @ - static volatile int irqraised2 = 0;
" W1 }; R# `* l - 7 o6 G" M9 h$ [9 e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 A9 U6 S( N( z/ a' G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( O; ]3 F) h7 B! O1 w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& r8 `# e' y% d# G8 k: Z
) X4 K8 o, Z Q2 I3 M- dma_addr_t dmaphyssrc1 = 0;7 ~0 N$ X+ l8 R0 R
- dma_addr_t dmaphyssrc2 = 0;; j. _+ ]6 P, U1 G
- dma_addr_t dmaphysdest1 = 0;
5 j; Z* z7 T4 _) z" S% ^& Y - dma_addr_t dmaphysdest2 = 0;/ O/ ?. C; l' O
' D' k7 O% P3 E* Y0 p- char *dmabufsrc1 = NULL;
: w6 j. Y3 H( l3 m& t" ` - char *dmabufsrc2 = NULL;
) |) T( P7 p/ {0 p1 c+ L - char *dmabufdest1 = NULL;: q/ P t1 F, w a/ ~
- char *dmabufdest2 = NULL;
/ ?' }: H+ R- ]2 n# O; V# r2 k, j - ; u9 X# P; _4 g
- static int acnt = 512;
# s6 |7 h, `0 T% @6 x/ n' W, | - static int bcnt = 8;- {( O, X1 p* Q1 Y' Q' s
- static int ccnt = 8;$ }, E4 Z0 Q* x, F
* b2 |2 q$ g8 @7 O: K3 `* o- module_param(acnt, int, S_IRUGO);+ }/ `# W4 N, X; L8 f
- module_param(bcnt, int, S_IRUGO);
" Q8 w3 g( p+ N6 J' G5 C - module_param(ccnt, int, S_IRUGO);
复制代码
% T2 V. n6 I' p: x) c8 D$ A# f; O6 [% ~* Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" m% N& j C# T4 }3 O# K9 x& ~
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; }) g9 m$ Y \ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ n* u# | v+ }) v6 G9 f/ {
1 w9 _. \& O4 Z& B. P. r8 L3 ?0 j: c0 A& ?
|
|