|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 @; \0 ?4 [. l7 h1 B
- [code]EDMA sample test application
/ A; R5 g9 ]+ ~, f0 v& l2 ~ - /*
: K, _- s6 c2 K4 W! W e - * edma_test.c
& W* a# A& D: O& [; m$ z - *
3 K8 I4 e! x5 r" f1 J; G, q* b5 w - * brief EDMA3 Test Application
/ v2 c4 ]0 m# n - *
0 K4 w- ]5 U: u. i' e - * This file contains EDMA3 Test code.
+ g1 a! a+ }: D, t i X+ W - *
1 k \7 ~* I+ m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 j9 b3 O2 x* T. ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 P, K Z* s7 f: r - * TO CHANGE.
5 V: z9 H4 c! `( T! G; Y - *
* s" s5 G8 p9 C7 J) I6 F9 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 O9 J7 e' s) ]! l1 y - *
" s. \; K( w7 I2 j) z* k6 q - * This program is free software; you can redistribute it and/or' ]3 b1 d. ]/ o1 H
- * modify it under the terms of the GNU General Public License as3 k4 N2 ~4 `2 X# t/ U9 a6 _) C' x0 ~
- * published by the Free Software Foundation version 2.
' Z/ c( X: [6 ^+ ?) W4 K - *
: g" F7 C# p3 x1 \4 U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& Y; S# z0 Z$ q4 J, k; _) \% D - * kind, whether express or implied; without even the implied warranty
( n5 `& W) W0 l: j9 }7 ] - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ ?# l4 ~. l+ G, w4 g$ F4 U3 r - * GNU General Public License for more details.
) C" j$ K8 H8 l. b& S3 T - */
; B; j1 A8 l2 G. P4 \ - 4 A; k* S* N6 A% C5 ~4 ]* `8 A* P/ c
- #include <linux/module.h>
/ ]" @8 I3 x0 F w F4 \ - #include <linux/init.h>
3 v# X3 [8 O+ t! Z8 E - #include <linux/errno.h>0 J+ |( V! s1 B: e4 Q
- #include <linux/types.h>
# u7 S0 @# n% d" l, g9 ~ - #include <linux/interrupt.h>" D" y9 f8 B, l) {% k- s. _
- #include <asm/io.h>" l" Y5 A" V4 D
- #include <linux/moduleparam.h>
5 y. ?4 E5 A3 `: I9 R - #include <linux/sysctl.h>/ k! E; R/ R# K4 Z+ @ l5 ]
- #include <linux/mm.h>
" L& m+ d( j5 w2 N# S - #include <linux/dma-mapping.h>1 z: p* I; I g# i" C; \* s
- ! J8 V# Q; e& p) M$ y6 H3 W
- #include <mach/memory.h>
8 u- A" F" K0 B( b' E; ~- A4 S& B4 N - #include <mach/hardware.h>! M$ V+ `- d, f8 V! b
- #include <mach/irqs.h>
1 k& X* ^" i! }: D - #include <asm/hardware/edma.h>' w: f& V0 `( [# d) B
+ A; ?+ C( y% ~8 I8 G" M z- #undef EDMA3_DEBUG
H3 @! i6 A3 M - /*#define EDMA3_DEBUG*/
" x. e% n; z( Z, t" Y+ f6 D
/ R9 f% Y& B' P0 D7 _' V) l- #ifdef EDMA3_DEBUG
" ?) T5 n9 o( S1 r5 R# [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* ]2 _* U0 p2 [/ n$ ~$ b' Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). }0 u4 B$ Q' g' _ W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 y& C6 g: K- _ p0 r4 h$ V/ c - #else( U0 k6 M* [8 c0 a
- #define DMA_PRINTK( x... )$ q3 E! V2 V2 L+ _. h
- #define DMA_FN_IN
$ I- h4 B9 O B2 X1 a - #define DMA_FN_OUT
4 z) [4 {1 n/ N) } - #endif7 |! [) U1 U1 k
# T7 e8 ]8 a7 \# I: _! R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 {+ k1 c, {3 q- M: W - #define STATIC_SHIFT 3
; X+ p; v- p0 ~+ F) w - #define TCINTEN_SHIFT 20
8 z3 j5 H2 Y0 {6 b4 w8 h' P - #define ITCINTEN_SHIFT 216 T: f% m, F, F" Y* c
- #define TCCHEN_SHIFT 22% ?1 G# N# H, n
- #define ITCCHEN_SHIFT 23
& {6 h# t, s! K9 e - . w4 A8 ~# L% ` C" C# J j/ {
- static volatile int irqraised1 = 0;
1 d/ D1 I5 A' |9 G( M6 B/ q - static volatile int irqraised2 = 0;' L! \* K: R7 A+ B, R1 a4 I p
- 4 `! q9 z; D. F% Q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- j" @* x: G0 ]; W6 S2 R/ g- m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 ?' T8 {- ^# {9 A" f3 j& \6 d - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 C# H3 v' s' l9 @1 X- @1 ]
- & A* k5 c& J6 v$ S8 o# V* O
- dma_addr_t dmaphyssrc1 = 0;! M/ ?6 W6 G# f; C- o5 G) d
- dma_addr_t dmaphyssrc2 = 0;! a4 J* d3 Y% U- i: l. M: e5 ^
- dma_addr_t dmaphysdest1 = 0;
. j9 k, j: L3 i - dma_addr_t dmaphysdest2 = 0;' F% G5 z" H* M7 n6 j+ F$ o
, s. W: N' l) C6 T7 R3 Q- char *dmabufsrc1 = NULL;
/ h9 \/ Y+ k0 F7 g0 k - char *dmabufsrc2 = NULL;
; J7 N6 j- L/ t4 b9 N - char *dmabufdest1 = NULL;
: n) g, N, g0 k+ U! s: R& l8 \ - char *dmabufdest2 = NULL;8 A) p- l8 V' V' ^8 q: X
; e6 C2 N# Q* @" u( S- static int acnt = 512;
4 \# X- I5 S- R& H4 M: ^ - static int bcnt = 8;1 l) G/ y3 u# _
- static int ccnt = 8;
/ B3 ^8 Q6 C! i0 z - ' w$ T1 h! \9 b' D/ z* ?
- module_param(acnt, int, S_IRUGO);! `6 A) Z7 C8 ]! H. S& }
- module_param(bcnt, int, S_IRUGO);
7 D8 S) t: R; \% G% q - module_param(ccnt, int, S_IRUGO);
复制代码 3 |$ C8 w! Q8 e- v, A! K
o8 @6 Y& `- k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ V5 M( z5 q2 uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! x& A6 X) G6 }8 C$ e1 Q( M$ B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 B! D8 L: y; G# T: G
, x8 F' W3 _: l. o1 c! v' G" x
9 I+ Z) g; t$ }4 C5 |4 } |
|