|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % D& B& z9 K+ [ f0 F) [* f# z
- [code]EDMA sample test application
4 C$ G* ]( V: c/ {0 i0 e+ f. O& ` - /*
6 n; ]8 B! d$ v/ D. J* R- A7 ^8 k3 n - * edma_test.c' k/ \6 q5 P) L9 g, S" }! p+ q
- *
& \. Y: ]' s* h, l% N - * brief EDMA3 Test Application+ t: W' W* \- B
- *7 w8 g+ h( S; A) [0 q
- * This file contains EDMA3 Test code.
4 [- S% C3 I$ ]8 H - *
, [0 U/ l1 u# U5 H# Q8 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 w5 l T7 p i- H; f& G
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 W8 }4 m$ \$ g1 \* {4 h
- * TO CHANGE.
7 @' r; E. _+ ]$ u+ B6 ~ - *, j: w. d2 E2 O& ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 |6 k! n7 a* ~6 A; R - *
4 D/ F% c6 L; r% }. D - * This program is free software; you can redistribute it and/or8 A' v- Q# N6 a( Z& ^. A
- * modify it under the terms of the GNU General Public License as( W9 r3 H3 @% f" C6 v7 x
- * published by the Free Software Foundation version 2.
7 @7 [1 i9 Q" l4 l - *6 K0 y4 Z+ A* y) f: M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 T9 g2 G, s0 t" c
- * kind, whether express or implied; without even the implied warranty; R3 {3 ]% N5 x2 D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 f0 m1 |" V: h+ U; U" ]* u0 ^
- * GNU General Public License for more details.9 p- D) {" _) _ M/ t0 j
- */9 H5 {0 U1 X: A$ p% |
- ( j% _1 [; L4 L, a1 x
- #include <linux/module.h>5 y1 F3 T( D# B
- #include <linux/init.h> u- H' Y6 W4 t( i& q" D1 U
- #include <linux/errno.h>2 ?8 A/ h- o" E* A' X# t. A5 r
- #include <linux/types.h>: x2 B* Q9 W) a) k1 G# m
- #include <linux/interrupt.h>
' R3 o* h( y z. C9 Z$ e" B; \3 a - #include <asm/io.h>6 Y0 x( k. h" l0 s; {
- #include <linux/moduleparam.h>
* S3 D2 h# a1 Q* h+ G+ i6 H - #include <linux/sysctl.h>& i7 S \1 b, M9 Z" ~6 {
- #include <linux/mm.h>
3 q: k& ?! s3 ~! ] - #include <linux/dma-mapping.h>3 S7 [6 S: K2 u
- ) P4 Q8 D8 v' k8 O+ ]8 g2 H
- #include <mach/memory.h>
. R, o! ?# Y; F4 H; i9 {7 | - #include <mach/hardware.h>, B. Z8 T/ ^7 h# Z; r
- #include <mach/irqs.h>2 ?8 a. h# E# J* m3 `- L* y
- #include <asm/hardware/edma.h>
# H# H' e) B k9 H- } l - : g5 l% U! ~$ ?
- #undef EDMA3_DEBUG
& o( v8 O% t- ?" F$ K - /*#define EDMA3_DEBUG*/
: F- c/ \: Z7 M: R8 L, r
@+ g3 @) Q# v- #ifdef EDMA3_DEBUG D7 V g. M6 _6 V6 k+ x7 o& }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# P M4 _. A0 L0 ?; ^0 x+ w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- K7 Y) O0 z9 u, _$ s2 S9 s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; F6 z+ [$ b% w* [, x - #else# m. e( O% {7 j' w0 K) j8 I
- #define DMA_PRINTK( x... )
8 e v/ C9 A# i" g9 V - #define DMA_FN_IN' q+ u5 c, W( l3 b" u, V' [$ }
- #define DMA_FN_OUT
. b& E' _, N/ E/ c; X - #endif
; k( q4 r. c, K0 B. v( s. N% Y - # c+ d, C) r. x+ a6 f# O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 t1 P3 {# ^# z }: O; R3 q - #define STATIC_SHIFT 39 \; d/ X& v( K; J( ]
- #define TCINTEN_SHIFT 20 X, r, m4 I/ ]( K
- #define ITCINTEN_SHIFT 213 u, y$ \( L z* |
- #define TCCHEN_SHIFT 22: U1 R8 D) d1 i4 N6 }, K5 _
- #define ITCCHEN_SHIFT 23
8 i2 F9 o7 ^; i! A5 W1 d - 9 B# ?3 X. |9 J. R
- static volatile int irqraised1 = 0;" h" c! d, ~" U+ w$ h
- static volatile int irqraised2 = 0;& _7 u. G7 E8 Y
- / j+ g+ K7 I. o t+ _+ m! U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) v. F. f8 T5 \. v - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ Z$ k9 k) i- Q2 j3 D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 m1 P# i% @8 G8 [6 V& c& Z( j
( i! M# c* m% ]- dma_addr_t dmaphyssrc1 = 0;& y- [- f2 _/ E" W, \7 B( `8 E
- dma_addr_t dmaphyssrc2 = 0;- z, v" x7 a9 O6 u1 S
- dma_addr_t dmaphysdest1 = 0;
' _/ L9 W8 }' X- T6 r' Z+ |# s2 H - dma_addr_t dmaphysdest2 = 0;7 L2 [ u$ Y' @# {1 M& }* n. T
2 T/ z( T+ u2 r+ R" Z: W- char *dmabufsrc1 = NULL;" [& |/ w0 t2 V a- {5 L& P& N& i& G
- char *dmabufsrc2 = NULL;
6 x* X, s. M3 i; P0 e. o - char *dmabufdest1 = NULL;' V. k- ]# K! P2 O8 T5 c2 x/ f8 e
- char *dmabufdest2 = NULL;2 _7 J2 X7 e, s) E9 M
/ C( h/ ?3 V0 D: \2 j" }- static int acnt = 512;. V, N" ~/ w* q1 F# x
- static int bcnt = 8;+ K+ F: g0 E" Y5 L
- static int ccnt = 8;, o0 ?+ `% F1 @" S" O. O
- % Q: [1 w- `4 @
- module_param(acnt, int, S_IRUGO);3 g9 k8 [9 V- Z* Y' |* [0 o
- module_param(bcnt, int, S_IRUGO);# j, p- m1 [& a2 g4 ^$ {$ ~, T
- module_param(ccnt, int, S_IRUGO);
复制代码
: O* K( |- P" u. e# N
% c9 P0 \* v7 k- e 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" ?' B( Y! Q* \" t varm-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 S }% t8 f8 M# \% R6 m( X5 U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 V! G0 @ L% C y6 L
: O' d- e H( M
7 ^3 d; Z4 a$ a. X, k
|
|