|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 Z% M3 y/ K) U6 V, S
- [code]EDMA sample test application
, ^! S" e: W. A8 e8 c" E- K5 M - /*
/ U m) J1 F g) {. } - * edma_test.c
: N, t8 X2 J) p% f" }! C - *0 E! h# w, k! l; T1 r' {
- * brief EDMA3 Test Application# k" c) R% Y- t! W( M
- *' R) l4 d% m: c% e
- * This file contains EDMA3 Test code.! }6 k" j# u: {& U' U1 Y
- *$ I' |3 \( h5 P# @
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" f* M' l, r. \: ?7 W: o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 c# ~* q8 l+ V) {7 `0 q0 z( _- n
- * TO CHANGE.
2 m% }5 {5 u' F5 r6 o. y - *
! | N+ l5 z- @9 a5 W" g4 o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# m( D. P) _5 G! U' Y! d: c - *
" s/ X, Q4 K$ U/ w2 g! L% ` - * This program is free software; you can redistribute it and/or
4 X2 U$ u: ?- [* r' J - * modify it under the terms of the GNU General Public License as
5 l% x' _4 v4 A6 C/ F# K - * published by the Free Software Foundation version 2.) l8 Y: k2 v' L' P9 ]5 j
- *# u# O( M1 `# B" C3 g7 g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: y2 c, L7 v! h: u - * kind, whether express or implied; without even the implied warranty
' X$ G6 N8 M4 q D9 |7 Z K9 x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; b5 l/ P& u, n- T4 q! Q" o - * GNU General Public License for more details.
! W( F" T) H8 t; r - */
+ g$ q' N1 O [8 S3 t - 3 T. b" _! K% I% |; b
- #include <linux/module.h>: y% _1 M/ ?! Y6 Q( o7 n
- #include <linux/init.h>6 h6 a/ e; V6 x: d* l
- #include <linux/errno.h>. u7 H, O: C9 ~9 ]- z
- #include <linux/types.h>
H m7 f; m" o$ V( H k/ H' F - #include <linux/interrupt.h>
! S8 E O0 A$ B8 F, [! [& K - #include <asm/io.h># O& ]: Q' a3 r2 M
- #include <linux/moduleparam.h> {* r8 g2 |5 t
- #include <linux/sysctl.h>2 ^* k; k2 j5 h% a
- #include <linux/mm.h>& P+ B9 E0 u; m
- #include <linux/dma-mapping.h>
& y: N: Q9 s# D( N. z& _. J t2 L
! ~ A; K/ s4 w: W, A8 M- #include <mach/memory.h>
. \9 z: l; ?" w: r* s8 v - #include <mach/hardware.h>
6 h! U' R' [9 \0 p% b - #include <mach/irqs.h>4 k. x- w4 e3 U( r3 h+ S
- #include <asm/hardware/edma.h>
: O% g' e( r I8 g# E
/ C3 U/ H v# F% K9 M; X. I0 W- #undef EDMA3_DEBUG9 _3 ]* X$ ?; n# `1 Q8 c
- /*#define EDMA3_DEBUG*/) b8 W' ^* D6 w. }% k, P$ A% Q
! k A6 G( V! {* r; P) t6 l- #ifdef EDMA3_DEBUG
0 I. m' G3 w Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 ?5 N$ i, i k5 `6 g* ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. |1 L/ o1 A& Q/ `; O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: b2 m; J2 q5 K5 A6 h9 L, K - #else# d n+ G' g7 j1 H6 G! @
- #define DMA_PRINTK( x... )! ]8 w7 V- r( g e
- #define DMA_FN_IN
: A! O! I7 ] W# K/ n- n9 F - #define DMA_FN_OUT C5 Z3 |$ f5 N" [8 P2 T3 I2 j
- #endif7 @" X/ h: y' W
$ b+ }! r4 y; |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; O1 j+ ]9 ?2 N1 R, K8 O6 j - #define STATIC_SHIFT 3
; u+ \9 {1 R1 A! u - #define TCINTEN_SHIFT 20 J, D) X. Y9 \4 k( [. ~
- #define ITCINTEN_SHIFT 219 q, I- w* b- F1 c: O7 \* g/ v
- #define TCCHEN_SHIFT 22
' d! B$ ]' n. s7 s - #define ITCCHEN_SHIFT 23
: ^+ C7 b4 G( f
( m4 r' u" _! H4 N) w- static volatile int irqraised1 = 0;# B6 S0 b* `& u! x+ S- A" c, W
- static volatile int irqraised2 = 0;8 C- G4 r% j" i' ~4 Z
$ O0 w C& T2 T- ~4 E; b! O/ c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* d! I9 ~( ~2 C0 Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' B& v2 R6 s9 w$ C8 k, { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" `6 i, Y+ {) P
- ; M0 p- n- z- d# v, a
- dma_addr_t dmaphyssrc1 = 0;5 @0 [4 B% T9 i) H8 a
- dma_addr_t dmaphyssrc2 = 0;
* i& ?- Q! g: V/ C6 e T3 F. G - dma_addr_t dmaphysdest1 = 0;$ R8 Y6 Q3 s1 w+ A
- dma_addr_t dmaphysdest2 = 0;2 g5 f# J: H: b3 _( L! T- o1 J% Q
3 ~ Z; A: ~; A" l w& m- char *dmabufsrc1 = NULL;
+ d4 W. o C) {0 |0 ~( ]- V9 V3 { - char *dmabufsrc2 = NULL;
* l- G. q: d% u# ], v - char *dmabufdest1 = NULL;; H# |, z% n4 ?! j: Q. ^
- char *dmabufdest2 = NULL;
9 g1 p% k& F, l1 t
8 z4 U" e8 u, s' S) D6 i. o- static int acnt = 512;
5 T. ], Z/ p1 I; R! U0 B - static int bcnt = 8;$ C. K+ T4 d f0 Z6 t- a- X$ n+ d
- static int ccnt = 8;0 Z& U; Q1 ?; b8 `. P. ^' H4 P( n
- ' a& f8 f: M9 w5 F7 w
- module_param(acnt, int, S_IRUGO);# g. L# z$ `. i3 x
- module_param(bcnt, int, S_IRUGO);6 F9 s& k6 ? M) s" _& \2 C: O! w
- module_param(ccnt, int, S_IRUGO);
复制代码 8 }2 v$ D3 j1 b; V
2 F" l Y( T8 \1 G- y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 V4 m5 N; k4 d2 u ]( o
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* R/ J0 p. f& i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 D# }4 t7 _# T/ T& j- n
Q; d2 A0 D+ D1 |! L: f0 j) k
; ^2 p, L( n% g- e2 e1 }9 V
|
|