|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 ?4 l; [5 g \" z) Q- [code]EDMA sample test application
# c' l; A4 }( M9 }9 G; X7 |: I- C - /*
* u+ K4 H. W9 z/ F: A3 g - * edma_test.c( B9 ^7 y: A* H! O1 w+ j+ e
- *
; @3 R5 ?7 g, k( Q/ ? - * brief EDMA3 Test Application
# L7 S, i0 H4 Y" G, A" c - *, R6 r# S/ @$ k$ ]- d
- * This file contains EDMA3 Test code.
7 R* [5 a4 I5 [1 V( u - *
6 T# ] T% x& e7 y5 A! k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" i! j6 X* Q$ H) J" t7 n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- r' g: s, x! n7 ]; J4 T4 X! l
- * TO CHANGE.$ e) E6 p& z6 m! q- X
- *! g8 A0 a/ l7 ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! B ?, N3 c" n- M0 O - *, Z- j4 [* F/ q2 z
- * This program is free software; you can redistribute it and/or, M; ]* x! H3 H5 Q9 T
- * modify it under the terms of the GNU General Public License as- ~" T; ~% \: m w" n; T2 {
- * published by the Free Software Foundation version 2.- m& d! b" K( q* ~" C" F
- *
. F; k- s+ x1 {, j" K% b3 k# h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; W* a- H) {+ D1 s
- * kind, whether express or implied; without even the implied warranty" A" n( x& [8 _1 d% ^& q9 B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% x1 d# p& N$ C; c: K - * GNU General Public License for more details.7 M ^! D/ \4 @7 O& J
- */
% e2 Z: D! f _2 h- n - : L1 B* M7 M! }) ^+ N
- #include <linux/module.h>! y% c4 z5 C7 v2 _) k/ o. O
- #include <linux/init.h>) \0 L' D) n: y8 Y' f6 U
- #include <linux/errno.h>$ R x$ v) ?$ X, {- [! ?
- #include <linux/types.h>+ V. X3 c! j l& Z
- #include <linux/interrupt.h>1 H I( R+ u5 V6 A
- #include <asm/io.h>
0 p- O3 u G; `" [+ M - #include <linux/moduleparam.h>
3 M7 c1 B! W3 v6 t7 A5 b - #include <linux/sysctl.h>7 |2 B7 f# z) O
- #include <linux/mm.h>
/ w4 ^4 q) `4 t* R N; g - #include <linux/dma-mapping.h>
0 |4 \5 s* }' ~9 r/ c
3 B# i% B1 I& t5 B: r/ c: k: k @! ?- #include <mach/memory.h>
2 o, D! ~. G$ c* Y1 [ - #include <mach/hardware.h>
, l7 @. l: \. X% O- i+ X) y) _ - #include <mach/irqs.h>5 k& `8 h: z# s. a7 ?5 r
- #include <asm/hardware/edma.h>
$ y6 H! X4 Q8 U( i$ G- F6 m) x - ( A/ v5 X) M' E- h/ v1 K
- #undef EDMA3_DEBUG
% \% W" x. ~9 }) A, Q9 k - /*#define EDMA3_DEBUG*/
- |7 c5 Q' V( n! y7 _; v
3 Z3 ?; w5 T% Z4 s2 _- #ifdef EDMA3_DEBUG! b% D; k2 m" e1 r @2 n0 A$ ?+ e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# J+ E0 t' C+ D5 J$ D. q6 Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). N2 r4 W X: ^
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: A( g) X# e3 P3 p: n7 H: g1 { - #else
. l2 t) Z( N+ \4 l6 G0 C# N; ^$ c" Z" P - #define DMA_PRINTK( x... )" _' M! L& {3 S
- #define DMA_FN_IN
, v7 \7 v' C' t1 q; J$ h4 e, V - #define DMA_FN_OUT
0 N8 I) a) ?+ }- b% P1 @2 J K - #endif
6 V# r$ H8 _7 ^* z - 3 i, G0 M0 W& Q3 V8 q S% D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" h O) O- U& J* u: W( { - #define STATIC_SHIFT 3
# V7 u" ?; I( Z) E% I; R% e# n( X! r - #define TCINTEN_SHIFT 20
e* | I3 I+ m - #define ITCINTEN_SHIFT 21/ F _$ B* Y0 p# \, v1 F
- #define TCCHEN_SHIFT 22& z2 h- d! u* V* A0 [' R
- #define ITCCHEN_SHIFT 23
- U, B) ]* v" O - & B1 ~! c5 A. b* _7 t0 F
- static volatile int irqraised1 = 0;
: e8 ~4 I9 O% U6 G3 a( ~ - static volatile int irqraised2 = 0;/ c, f# c& o+ H4 U0 D4 ^! P s9 c, E
- $ E& q, h: r+ ~- @4 _5 k
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* u% o1 b1 c1 C# a. S& S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 H! y! E F! f7 q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- m9 t4 ?' G& k( ?
% I; f) t0 p7 p# x; {. m: A- dma_addr_t dmaphyssrc1 = 0;- {( z8 B/ n" Q& A7 n( M1 K: R
- dma_addr_t dmaphyssrc2 = 0;
! n0 A2 C3 O& g- {5 h. x - dma_addr_t dmaphysdest1 = 0;
# [) @$ w. ~# B5 i- _. { - dma_addr_t dmaphysdest2 = 0;
2 o" n& Z9 a7 t- F - / \" H& f# p2 o5 B+ \
- char *dmabufsrc1 = NULL;6 r! a+ s( \! s' A( M
- char *dmabufsrc2 = NULL;
$ t4 Z1 Q9 x& U/ {3 D - char *dmabufdest1 = NULL;9 D- f; q& i6 `" c
- char *dmabufdest2 = NULL;& [: j& I( v( y1 g, s
. Y7 |: d4 D+ Q' S( N- static int acnt = 512;! \" v5 n0 T2 J7 \5 E
- static int bcnt = 8;
' T9 H' w3 m8 a9 w - static int ccnt = 8;
+ Z% y6 B. N# G# ]7 N' Y& P - % s3 D) N/ x- K& p( \ B+ q
- module_param(acnt, int, S_IRUGO);
4 V: C, c' d; Y - module_param(bcnt, int, S_IRUGO);, k" N0 V- O8 F9 B6 \
- module_param(ccnt, int, S_IRUGO);
复制代码
" M$ a( p, P, y! Z9 Y& X4 n' r3 ~: f3 }7 o: j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 c; k) ?# u7 p3 [$ m' e
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
U# n: ]4 ~# W+ P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 ?+ P+ Z b, n: r; |. T+ x; i
! K* U6 |1 S5 {( L( J
. a0 y* I% F* U. Y
|
|