|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( K6 `& p% O" r% J f0 A! z- [code]EDMA sample test application
' y: H& ]. ]8 {! M - /*
9 o5 \: U7 ~9 r9 ]' \4 v% i - * edma_test.c
: Y) k9 e3 L! u6 N3 v+ G - *) }! _8 n9 k! {/ W
- * brief EDMA3 Test Application
$ ~' C( }# K1 x; p! }8 ? - *
% U( U: t. K3 A# w9 x8 E* f - * This file contains EDMA3 Test code.7 B5 | r" X* l2 P8 g* N# @
- *
( N z `3 H3 a% p' U- y1 x0 M8 o$ t5 p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& n& w; x. P" g3 R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' Y* q, y8 ]+ {+ Q
- * TO CHANGE.
; `& B* W: R2 Z# d) ~' Y6 g: R5 u6 g" N - *
6 @8 k- `0 w5 J6 A* b7 G9 [$ \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, Z* W1 J+ F. X( K, G - *3 b& K4 @. J* {. ^- Z, K
- * This program is free software; you can redistribute it and/or. [8 T* I: E& R7 J, G
- * modify it under the terms of the GNU General Public License as* A8 w* q7 b6 m, j
- * published by the Free Software Foundation version 2.3 i8 p) r4 g* T6 w4 [
- *
" W) u. B! I$ i - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% ~0 o/ D z. Z8 r - * kind, whether express or implied; without even the implied warranty C! u$ Y, c P# \* y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, o/ i* K3 S0 y
- * GNU General Public License for more details.
7 E6 [# ]+ x% |3 p( Z. f - */( [, j' Z$ Q: M5 z1 S
- / G" z# W9 N, M6 U6 V% Y
- #include <linux/module.h>- `' s- k) J: k" A/ x8 }0 m
- #include <linux/init.h>. m' z$ C5 ~1 Q$ G4 }
- #include <linux/errno.h>/ }, v( @8 o4 x) J
- #include <linux/types.h>
2 e+ j* m K0 } l - #include <linux/interrupt.h>( k/ b- W6 H+ J
- #include <asm/io.h>: t( P1 B9 Z5 v
- #include <linux/moduleparam.h>) W0 D" G9 t ?3 n
- #include <linux/sysctl.h>
. p4 X" @5 v2 t - #include <linux/mm.h>
; k. |+ u) E$ _7 h4 T! V - #include <linux/dma-mapping.h>7 A# N( Y# j6 ~) o% T
3 ~! f9 [" k' f$ ~( W, U- #include <mach/memory.h>2 ]% D3 B& \5 f/ o9 g( m4 i: E
- #include <mach/hardware.h>2 K6 z, v2 w: l8 S( B& N
- #include <mach/irqs.h>
9 D/ v0 |$ Z- [7 s4 A8 x8 ~ - #include <asm/hardware/edma.h>( ]% k" U' Q7 _- P* Z
5 c/ J2 w9 p+ u, ~# p$ \2 Z% _- #undef EDMA3_DEBUG* g% l* \3 z: v# c$ i
- /*#define EDMA3_DEBUG*/5 o+ @/ A r" R8 W8 s4 M! H
' Z/ v, t4 Y, {: E6 d5 x/ s- #ifdef EDMA3_DEBUG
+ U8 V. s% i' ^2 w3 X* E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 I E1 I) F2 E) H
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( U# \5 w6 @ s6 o* t6 b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). u0 Q# ?1 s, k0 t& l
- #else
$ n* ?# z( [5 K* Z) h- S R - #define DMA_PRINTK( x... )
7 \ E* H) v8 @, n, s - #define DMA_FN_IN- k2 E, B: h, v' a6 Z
- #define DMA_FN_OUT
2 |" C" y8 h+ y$ \6 }% b5 ~ - #endif* B/ x; v8 y6 Q: v* h7 I$ l
- ; N7 @% R* }$ c# G. v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 ] r8 ^9 v' E1 p
- #define STATIC_SHIFT 3
" j. v) A/ p/ _( i2 ^& F - #define TCINTEN_SHIFT 20. V2 [% e4 h- X) ^; w- P, a0 U
- #define ITCINTEN_SHIFT 21
. Q% T, g1 _. q8 F( \* L - #define TCCHEN_SHIFT 22
# B% u. ?* ] X0 x4 { - #define ITCCHEN_SHIFT 232 q2 z4 I4 U, {, d
- ) S8 W* q. E" S3 H3 m
- static volatile int irqraised1 = 0;0 p4 P, a l' d6 h/ B
- static volatile int irqraised2 = 0;
+ q0 a- a& S7 C+ B7 z+ X/ I
% c8 Q5 s3 Q; T; c8 d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% _/ c; U' h# J) l' H# ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" r1 P9 D( C- K2 \& y3 h; X! r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- c9 t1 A. [- c* {
- ) Z! ]( F; r7 f& [) n# W
- dma_addr_t dmaphyssrc1 = 0;# y; ], z" u: B3 @$ v8 N
- dma_addr_t dmaphyssrc2 = 0;
& h- d0 o: w5 C# B! I0 R) @ - dma_addr_t dmaphysdest1 = 0;
E" i* W/ R4 R5 l$ Y - dma_addr_t dmaphysdest2 = 0;
& u" d% c6 R' F - + P* k) d/ ~0 N4 y2 Z% W& j5 p
- char *dmabufsrc1 = NULL;3 ]8 x* \, T5 f' ~8 k/ ~
- char *dmabufsrc2 = NULL;
$ T- C0 ?( Y+ L - char *dmabufdest1 = NULL;
+ }" |& x6 P: o% K. v: z - char *dmabufdest2 = NULL;
& L6 p! X8 J8 }7 g+ R/ H6 y5 u
' O$ \; u/ y- {: Q- static int acnt = 512;- ]* N$ n* g d$ X3 [. Q: d0 J
- static int bcnt = 8;$ ^6 i* g3 ^% ]7 W+ e9 r/ m. ?
- static int ccnt = 8;
$ N3 Q$ N6 t- f
. X! [! L) W9 q! U/ m" Z- module_param(acnt, int, S_IRUGO);
$ G* [' {/ m( E B; C& Z+ Z% ?, T - module_param(bcnt, int, S_IRUGO);1 M: I% H9 x4 K* a
- module_param(ccnt, int, S_IRUGO);
复制代码
! e+ }7 w1 b8 Z. c, G0 q
: e3 x" q! Y/ N! q) I$ e, ]8 i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 W A+ ~# ^5 r# D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 L& B1 j7 [8 p1 y2 n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 P# l8 }( u5 k) e E E" K, ?
/ P: R- |) ~) r0 Y) U3 I5 D F! I9 Y6 k: O0 N
|
|