|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 m* Q/ E) U7 S- [code]EDMA sample test application6 v1 r1 P$ Q/ s: A* j% e
- /*9 ~, I2 h# E8 ?) f+ p" `7 k3 k" g7 f2 T
- * edma_test.c
& ^$ X# m1 e2 Y3 | - ** w1 b4 w" t7 L, v0 F0 I9 S
- * brief EDMA3 Test Application7 N4 y& `' }7 u
- *7 }0 \* T3 o) h+ E7 G
- * This file contains EDMA3 Test code.
# h) q- o6 k' \0 m" h" @ - *, a2 S8 _$ h7 ^6 p3 N( z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 A( x% ?8 D; J6 E" f; t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" e, @8 D x1 C( J: R3 ~, ?8 U - * TO CHANGE.1 }/ Q; T5 N: R
- *
4 N3 d6 G; f9 p. {* ^8 e# i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 ]- X; d4 t3 A _
- */ h! h, n W1 g* e: W, R+ }1 ~7 `5 B" p
- * This program is free software; you can redistribute it and/or. V9 K& J% v! p) D# P" |2 i% d5 P
- * modify it under the terms of the GNU General Public License as
$ Z1 w7 I- V# K: [ - * published by the Free Software Foundation version 2.1 I3 h- H; R! h
- *- V4 _$ e& J) T( V" f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' n* Q3 Q+ V# l
- * kind, whether express or implied; without even the implied warranty) x* O, J% x0 U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- M/ J% Z' a9 C; M! v5 O
- * GNU General Public License for more details.
k9 Y- U4 [& {4 h; T' J) _ - */
3 o2 e7 e' v' a+ d
* f5 W+ j# X7 o. y/ V- #include <linux/module.h> E6 N$ t8 W* S* H: ?/ V6 J) Q
- #include <linux/init.h>
' W! t: R4 t2 K" p# P - #include <linux/errno.h>
: F/ [1 s' |. Z, g - #include <linux/types.h>5 ~8 { D# [$ |5 U8 t1 M2 V8 p
- #include <linux/interrupt.h>: ?+ |$ P) R! a/ _+ `
- #include <asm/io.h>$ M/ A1 f j$ n
- #include <linux/moduleparam.h>
" }2 p: ?! [9 b0 h, u4 D s1 s0 M! E$ I - #include <linux/sysctl.h>
. J0 r' w' g' g - #include <linux/mm.h>
+ M0 p% s/ I% `& E" I% _2 U9 Q$ e - #include <linux/dma-mapping.h> Z! ]4 M8 I0 H
- 6 A% t2 \. Z# |. o. J0 b9 v
- #include <mach/memory.h>
- k8 k: f6 {, t9 [- K }+ h - #include <mach/hardware.h>
4 g3 E# G7 c4 S* {2 b! F - #include <mach/irqs.h>
" B2 L F0 a% Z8 W) M9 S5 D2 w - #include <asm/hardware/edma.h>$ _" d8 Q' k2 A
- 2 [3 H6 H% A8 m+ u5 I: ~- N
- #undef EDMA3_DEBUG7 q& p; M9 W5 C# g# z
- /*#define EDMA3_DEBUG*/; K, T! s" Y" W
$ E) n$ w2 N/ R' M e7 @# p- #ifdef EDMA3_DEBUG
. { w; Y/ j- y0 F! f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' N- }4 C: z' B( z9 G0 B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 p* ]: N0 o3 q; r2 q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 H$ ?3 w& H1 V - #else# W7 C& K K, N. ~ C% C, l
- #define DMA_PRINTK( x... )
6 ~/ c; K5 t- l$ t# L% p - #define DMA_FN_IN
, \9 t+ b1 L& [" r, N) a% i - #define DMA_FN_OUT& b$ q1 s8 { c* v" a
- #endif
1 g+ ~& Y" @: G* n
" D( p& n( [: x. p- #define MAX_DMA_TRANSFER_IN_BYTES (32768); G+ k6 _" J) P0 b; P
- #define STATIC_SHIFT 3
4 ^- z7 Z, a4 I - #define TCINTEN_SHIFT 20 G; q/ v8 _. }
- #define ITCINTEN_SHIFT 21
# |# |# r1 ]' J$ j" F6 K - #define TCCHEN_SHIFT 22
" y4 C5 q5 r6 X- O7 a - #define ITCCHEN_SHIFT 23
6 R) ~$ D/ R2 B3 Z: y - $ e' j6 Q0 y% ?" O
- static volatile int irqraised1 = 0;- L" T9 {3 R$ m0 o+ \& z0 H9 G8 n
- static volatile int irqraised2 = 0;! c7 {/ Z: a7 r
- ; s% X6 }/ w+ T) U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; |9 O( _, ?; d: L z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% \/ T& q8 N6 W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, d: x$ |4 t; y1 P; z9 z
$ c( i3 y7 S" d4 M8 l- dma_addr_t dmaphyssrc1 = 0;
& K2 E" A) f. v. F) W - dma_addr_t dmaphyssrc2 = 0;4 z% \! O0 @4 U' P( w* B
- dma_addr_t dmaphysdest1 = 0;
. n6 X, C+ K6 A- y - dma_addr_t dmaphysdest2 = 0;: ~8 ^3 Y1 F' N; G
- 8 R o/ _2 K" t, x+ p
- char *dmabufsrc1 = NULL;
7 `2 Y3 ^' R$ q2 M, i: U - char *dmabufsrc2 = NULL;
. ]% J- s/ e% D* R - char *dmabufdest1 = NULL;! T+ h3 S7 S* r( [' V" V: I3 u
- char *dmabufdest2 = NULL;2 L6 \5 y8 V& P4 S
. O0 U N+ ~& Z2 `- static int acnt = 512;& I/ R# V. Y3 ]# k2 @/ ]
- static int bcnt = 8;/ e) {/ u9 R( Q$ L
- static int ccnt = 8; D1 r7 z: A& ~
- ' L! K; Z/ G, w' V: L4 ~
- module_param(acnt, int, S_IRUGO);
# g7 u2 q7 L2 M4 E1 Y) _2 j+ _ - module_param(bcnt, int, S_IRUGO);
# K4 \" t. n4 h8 p1 C0 ]5 P! }# t5 ` - module_param(ccnt, int, S_IRUGO);
复制代码
! c5 I1 K/ r# |# ^- a) n( c( ]1 A- V8 ^- y) ^( Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ l7 z3 T4 U9 @: G7 P' q5 P* 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 C0 e$ j) f6 F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 G0 Y7 s$ ?, o6 U1 D
2 Q; p3 U: H; @$ `& }
" W4 _- ]0 J+ y( P- y; Y |
|