|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( @% v: B4 L. F' c$ j7 [+ N e- [code]EDMA sample test application
, r) ]9 q O0 {* ]+ b$ M - /*3 E S7 g* c0 ~2 `* i
- * edma_test.c
- Q! I& _6 g/ j3 S - *
0 h2 | ]7 X/ T9 P - * brief EDMA3 Test Application7 |0 p" g- J2 o- j
- *
; s5 r! K) `/ j - * This file contains EDMA3 Test code.( \& t1 ~4 O5 {, g
- *
5 f6 {( Q6 s9 B/ Q3 H* w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: p9 O( h7 S! Z' Q0 c" K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 q J0 o, B: f/ b+ A$ ?, _ - * TO CHANGE.0 ]2 V( P, B2 a: N! F
- *
3 R. F! E/ }3 n( a$ c& g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% _( B) k0 x! ^7 ?$ Q: G7 i( l - *
4 b# I! n" ^; Y4 _/ ?2 ]# @# [ - * This program is free software; you can redistribute it and/or4 W: {3 D, a$ B
- * modify it under the terms of the GNU General Public License as
% B3 u, |) k/ {0 Y3 c" a' s - * published by the Free Software Foundation version 2.
# |/ G- e2 t( j! M8 E2 }0 a - *9 h: V9 Q6 \: l# v* N4 q$ I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; @6 z5 K6 }+ i$ K% a; ~; [ - * kind, whether express or implied; without even the implied warranty
# G8 b0 H( F$ E# b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 V% k7 O) Q" J. V9 @ - * GNU General Public License for more details.
% Q( l7 i) A$ v* G" t# n - */3 _8 n( o3 _) }( I; d
- / P8 s* y6 @# e6 \4 ~
- #include <linux/module.h>
1 a1 t4 _9 k6 L8 Y) ` - #include <linux/init.h>% @" @0 D- L7 U# ~- d2 \
- #include <linux/errno.h>9 I" S1 e% W+ q
- #include <linux/types.h>% `; X: X3 L& t' L
- #include <linux/interrupt.h> Z+ h6 Z* O; N
- #include <asm/io.h>
$ P* U/ n! F; r% C - #include <linux/moduleparam.h>
6 }) v% l4 W- v+ v& @5 [ - #include <linux/sysctl.h>4 f. t3 d: @! A# y& x' F, `
- #include <linux/mm.h>. D6 Q8 ^) g4 L" U3 }# A: ?/ H
- #include <linux/dma-mapping.h>
9 S- i% l, C2 o1 I( p - / Q. i# O, ^4 S0 i
- #include <mach/memory.h>5 S+ _9 j Y |% `
- #include <mach/hardware.h>$ N, P+ \0 t4 U3 K. k. X+ Y* r
- #include <mach/irqs.h>
' b, R, {) g/ U; J$ g - #include <asm/hardware/edma.h>
) e7 a y, x0 Y7 _/ G: `5 ^4 O1 l f
4 S U' m i1 d7 r- #undef EDMA3_DEBUG
& _6 d9 t* [$ N6 q - /*#define EDMA3_DEBUG*/. H; s+ t! B- r% _0 V- q$ x, Z
7 d+ m3 C' G9 G/ _% q' }( q s* v7 ]0 P- #ifdef EDMA3_DEBUG
8 {3 `: I# G. s& ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 M! V7 { K1 y& t% c% Z+ L2 S: ]0 A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 {. [$ ]8 r2 Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 s9 J. \; w" o% E0 c& U
- #else0 X4 Y9 }4 C' i2 @3 m
- #define DMA_PRINTK( x... )& X& S) t8 q d0 h
- #define DMA_FN_IN$ \6 I8 @3 O: o N. U+ T
- #define DMA_FN_OUT& H, J1 l) m& {/ m& S9 T
- #endif; y/ q. T$ j0 ~& v
' G( B. D- T' r2 Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( m# J. n0 q: x; f# f - #define STATIC_SHIFT 3+ h2 t" S/ ], U( \1 r0 |6 X
- #define TCINTEN_SHIFT 20
& {( @! |1 g& }0 Z. Q! ^ - #define ITCINTEN_SHIFT 21# t* f( N# G; P
- #define TCCHEN_SHIFT 221 c i* Q' O; r- I1 ` `1 g
- #define ITCCHEN_SHIFT 23
2 {5 k7 }3 U" `$ y! J& y9 z - 5 v1 Z2 i) @' M% d- V$ H
- static volatile int irqraised1 = 0;
- o+ y2 J* F' \$ ^( E2 c - static volatile int irqraised2 = 0;2 u0 X2 E2 x9 D: L2 o" } U
+ k2 c. J6 `. m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; ^% }* m, K* U/ F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 B3 l8 Z, [' D4 u: w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 k: s7 W$ B3 q- D7 p# x0 ?4 k
1 r7 r+ W% f q; Y. K! L- dma_addr_t dmaphyssrc1 = 0;( f4 {) c5 N! O6 @0 Y9 D2 d
- dma_addr_t dmaphyssrc2 = 0;" E5 a. B' m6 l& n& E/ ]
- dma_addr_t dmaphysdest1 = 0;0 r/ S4 Y9 G+ k# _/ L* V. @
- dma_addr_t dmaphysdest2 = 0;# ] b5 i8 ~4 H) V$ q
- I: j& R$ Z) _9 j. o( ?! T
- char *dmabufsrc1 = NULL;
% i1 o9 c U+ i - char *dmabufsrc2 = NULL;( n% q5 g u4 ~4 F4 v0 w& A
- char *dmabufdest1 = NULL;8 F. j( A# \1 E0 Q
- char *dmabufdest2 = NULL;5 c. b* g1 w; }! I4 b# `; J
- 7 c! h+ z# j3 K; I, b0 m( r
- static int acnt = 512;8 C* Q6 \& p) a1 {' j# w( j: J
- static int bcnt = 8;) y; t" i) `$ D+ Y3 p5 z5 X
- static int ccnt = 8;
# Y# _2 W' U8 ^4 y9 F# R1 ^9 D
+ ?1 @. Z& `) N1 _! P D$ M, ^- module_param(acnt, int, S_IRUGO);6 u+ E* n7 ~- R% n" s0 n& z! G
- module_param(bcnt, int, S_IRUGO);
0 f5 l7 e& u; u" }* y3 a2 P - module_param(ccnt, int, S_IRUGO);
复制代码
[ c$ I6 c w7 n2 s7 X0 g% S3 y9 `, d' s4 U% T c2 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, y( }, R4 N0 H/ F ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
w' y j( V3 R. w$ r 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ E" d' w* j8 E( J. k
6 Q" P% p% O4 g- x5 u$ V4 ~
3 n% E9 }1 b" m2 b |
|