|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ m Q* }* |+ ~) Q- [code]EDMA sample test application
4 y: Y; M# q9 P/ E x) c$ ^, ^5 _ - /*
5 P5 H1 O! M; \' D - * edma_test.c
3 |* c7 ]4 @1 {) ]+ s, n0 k - *; g1 i2 v1 Q" Y4 b0 m1 T
- * brief EDMA3 Test Application; g" H2 y4 q2 v3 l. ]: l
- *9 j# f# n M9 \" y1 B* h" q Z
- * This file contains EDMA3 Test code.
7 z: }7 i) _6 L1 Z/ A/ v$ S4 M - ** s2 }) M4 S7 e1 A8 Q/ t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 }7 w, J L& g% `3 y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ ^) m2 o r- D6 V - * TO CHANGE.
d! I! |& z7 I% g8 D; n - *# [2 Q f* q1 l; j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 H0 H# W0 D2 S - *
1 i3 S" k8 P' J& x - * This program is free software; you can redistribute it and/or0 l! d0 g1 s0 @5 b
- * modify it under the terms of the GNU General Public License as k& m. q$ s L1 I- C
- * published by the Free Software Foundation version 2.- d0 F+ N# i3 H! m! r- a3 z
- *5 W; i! V3 ~, q% O f+ _/ D) Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 m1 l% E% ?& q% C- N/ T9 B2 D - * kind, whether express or implied; without even the implied warranty
; q+ L5 e5 x( P& _) ]! e7 Q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 \! P- Y! r4 n
- * GNU General Public License for more details.
. `$ ^" @; y( O! S7 s( I. @: w2 O4 Q - */* |2 S- d4 }- F# ]& c) Y
$ P7 o- q6 K' P, v- #include <linux/module.h>$ O% R. c/ D+ k. b3 w: W
- #include <linux/init.h>" A6 x# _1 o6 v
- #include <linux/errno.h>
/ B+ d3 B- `( d# }- A - #include <linux/types.h>
& q7 `1 j$ c! r5 `" M - #include <linux/interrupt.h>5 Q- C% }; f: U% X
- #include <asm/io.h>% a! J: t, J7 l+ l/ O
- #include <linux/moduleparam.h>
- S' I/ I6 |0 v* |/ U1 E - #include <linux/sysctl.h>' I# m- e e. D2 v6 s
- #include <linux/mm.h>
# S4 U4 W6 W* z - #include <linux/dma-mapping.h>* S% @0 p8 Y' K- `* M I' u$ P& l
" N0 Y: e- _1 ~( M- #include <mach/memory.h>' i/ q/ n5 l$ l3 p- ~
- #include <mach/hardware.h>
9 C, M" m7 v& C6 t% e - #include <mach/irqs.h>
' B! B9 \' _/ @8 ]$ S, d - #include <asm/hardware/edma.h>
8 Q3 \2 H: e+ _6 V2 ?5 i$ q - 9 r% c) M$ g: B# E' ?6 T4 |2 [- m
- #undef EDMA3_DEBUG" Q: z" a' o' E/ D4 z3 f
- /*#define EDMA3_DEBUG*/
: s& M5 A, C7 _( v8 V6 z - , {3 S# Z9 z; }% |* V
- #ifdef EDMA3_DEBUG+ k6 H8 p9 t' c( D! F' s: f8 @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( [; @& r* A: s/ v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% P' @8 U5 c- X3 `$ a6 D5 Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ x0 r0 t7 g3 p" r ^4 p
- #else
( o7 Z1 R9 l! s2 T, Q) H - #define DMA_PRINTK( x... )
! u) w$ {3 j/ q6 X - #define DMA_FN_IN4 k9 s9 L) E* W) r6 B9 j' C
- #define DMA_FN_OUT
2 A0 \/ ?+ l, {" ^4 J' j - #endif: E& M. u7 b( t( T/ ]1 w; E7 |
; E* A$ ^! Y ]% I d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" Q8 @" Y; \& V7 }+ N5 ^9 j - #define STATIC_SHIFT 3
% b; w. S0 Z( f4 y+ w( T - #define TCINTEN_SHIFT 20. r2 k; G, L+ ^# B# w
- #define ITCINTEN_SHIFT 210 c2 T7 x9 z9 J0 T3 V9 `& t' G
- #define TCCHEN_SHIFT 223 G" C; w, m' }% i
- #define ITCCHEN_SHIFT 23
/ `/ U; e7 i5 O$ `) {8 D, V - , E9 R0 d7 ]. @3 f% h
- static volatile int irqraised1 = 0;
; [" _# O' @- u9 r2 v7 K# h( U2 H - static volatile int irqraised2 = 0;8 m6 d B0 w% Y1 L J- h6 f
- " |$ L8 U6 U0 S7 H( M2 o
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* _: f6 _0 G8 w5 C( K; G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 T& J$ p7 N! D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" d2 e5 q8 h- A& A
- 2 T, B- p' f2 v& u
- dma_addr_t dmaphyssrc1 = 0;
" V x% ?/ y" a% ^ - dma_addr_t dmaphyssrc2 = 0;
# D( w) i1 ~6 Z9 b0 u - dma_addr_t dmaphysdest1 = 0;
; S! l& M# w8 K - dma_addr_t dmaphysdest2 = 0;7 ]* f+ ?+ K+ [, G+ J" f
- , V1 G6 ], Y! x/ i: Z! f
- char *dmabufsrc1 = NULL;2 j( Q0 J" z! G1 r) \; d
- char *dmabufsrc2 = NULL;
: N# _7 B) v* D5 z, G! | - char *dmabufdest1 = NULL; [, N, B7 P: H/ l7 @
- char *dmabufdest2 = NULL;
, F9 q% r4 x. A- } - % M+ Y5 E8 O& r& Q4 v8 l2 {
- static int acnt = 512;4 m3 V0 P8 ]( P. P% D: j9 j& I
- static int bcnt = 8;
) @7 }0 y# C; Z# E2 e Q - static int ccnt = 8;
8 @. e7 ~$ q' x3 R: S9 O4 N
+ |$ @% A# A% a! n- module_param(acnt, int, S_IRUGO);
0 Y. ?, G0 g- L - module_param(bcnt, int, S_IRUGO);
3 D( C3 K( U! K/ t: [' [7 d* V# Z - module_param(ccnt, int, S_IRUGO);
复制代码 7 }# a( h) z( E9 y* b; H, Y6 k! [
D& R% \3 k& f% @0 C0 l4 L2 Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 \' l& G' V9 k. `* l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" t( F+ S# ^/ h0 Q1 u5 d" B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ q9 F* ^3 v; ]; C! F$ C
' M4 m; O V9 t' [' W% l1 R% c
! ~! ^. s- ^/ U; s6 g0 m |
|