|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 d; ? C. f+ o4 Y/ h' ~- [code]EDMA sample test application0 D* K8 a- H2 k* o
- /*
4 i! ?! }7 K$ f6 I+ m - * edma_test.c6 i* w3 [0 p6 ~9 c! t
- *( f/ }- d8 K- U+ t1 g
- * brief EDMA3 Test Application$ e1 s2 Q6 _' v6 j2 p' i6 m' O. s
- *) b# n$ @- y" m0 L0 I7 w
- * This file contains EDMA3 Test code., [/ w) Z" M5 u
- *
, U# ]4 H. B# j9 @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* A- d. ^# D3 e8 }
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; C3 U' i* a" Z' m
- * TO CHANGE./ G. T& k; j% x! H5 Q) z I. J
- *
9 J& m5 `+ S% v3 y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" k2 g& a$ h) p0 b/ c2 n0 \1 O5 ]! j: ? - *
' j! u4 ]6 u' m5 y. b - * This program is free software; you can redistribute it and/or0 c0 Y8 b6 a# t: o. a4 u
- * modify it under the terms of the GNU General Public License as
7 c1 W+ r; R0 Y5 ]2 }# l - * published by the Free Software Foundation version 2.1 y4 U+ ]1 E9 c
- *
* h/ u: W/ B8 I' I8 c" K - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) \% y) Q& v; g2 G
- * kind, whether express or implied; without even the implied warranty; J) _8 F5 o+ p% [6 O5 l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) {8 E1 W: ^% i+ ?/ }
- * GNU General Public License for more details.1 C) h- Y% f) w
- */5 a4 l. P0 W1 c) R# [6 `3 K
+ O/ T" Z, f6 l- #include <linux/module.h>
! Y! u: \0 @% P5 l( w - #include <linux/init.h>
/ {! I1 \: q8 B$ M* D - #include <linux/errno.h>
6 X. \ i3 q: V# c( R+ m2 s5 i7 S - #include <linux/types.h>
" O) b0 g6 _7 A - #include <linux/interrupt.h>% S! g N4 J m+ r/ k
- #include <asm/io.h>
) \7 h8 E" }% _) k0 W O - #include <linux/moduleparam.h>0 N X7 T9 B& \" P l% ^3 Y
- #include <linux/sysctl.h>3 \- ~" p8 d9 ^6 B
- #include <linux/mm.h># k2 q2 x0 G' K) F
- #include <linux/dma-mapping.h>2 t* M; y+ ?6 t0 X% c# W( g3 T) J1 D
( C* e: A1 d9 W- #include <mach/memory.h>
9 V) {. i/ D9 _9 ^9 [ - #include <mach/hardware.h>
, f v5 A! _- l/ `) u - #include <mach/irqs.h>
; Z2 B1 {. r( k I: Z - #include <asm/hardware/edma.h>% q6 t; p0 ^, G$ G: \
- : g ~9 {3 d# W* y5 p
- #undef EDMA3_DEBUG
" C$ r- b' X, C - /*#define EDMA3_DEBUG*/
, b# W/ q8 M9 W: I- Z - * j1 f8 A! H- N9 C6 c% q
- #ifdef EDMA3_DEBUG
: s. x( A- |4 _9 N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( x' r1 a! O5 W$ t' L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 O/ r; B8 H3 H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 T7 m T" R5 j - #else
1 q9 }! Q+ @" I* x) l1 e, T - #define DMA_PRINTK( x... )
1 t) w7 U" P2 s \9 Q - #define DMA_FN_IN8 j. W) ?, d, U" G
- #define DMA_FN_OUT7 U g) |2 i, [% [" e
- #endif$ f+ Z9 j. }# i6 h2 k
+ \$ F2 D) @; S0 \4 X5 ~% P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! |4 N! Q. |* ^4 w& z( a! l - #define STATIC_SHIFT 3/ f+ ]6 Y4 |9 y! H! `
- #define TCINTEN_SHIFT 20$ @. Y. S/ h3 z$ _$ F; ^' a: l& Y7 q& T
- #define ITCINTEN_SHIFT 21- r. T! ~" Q' J# r" R6 S" Q9 O2 N
- #define TCCHEN_SHIFT 22 R) ~- K# b, w3 n( ~# [ b2 a+ p
- #define ITCCHEN_SHIFT 23/ }1 v$ ~ [8 g- W1 b q( f
- ! Y1 C! @9 B, S6 r
- static volatile int irqraised1 = 0;2 _0 Q! W6 d4 U Y. B7 C& E
- static volatile int irqraised2 = 0;
; T4 F" `8 k; D4 K! g+ _6 V% S3 | - % w0 k: r# v. }# @' l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! O5 l) f! m# p2 I - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 {) @% H8 n5 ?5 v5 v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 Z8 s7 x" U9 K3 I9 `4 k3 o
- 4 E( \+ x9 u* p; h* l; m8 u1 Z
- dma_addr_t dmaphyssrc1 = 0;+ R% y5 O# @* ~0 b/ k- O w
- dma_addr_t dmaphyssrc2 = 0;
3 M7 L( c+ _. E - dma_addr_t dmaphysdest1 = 0;* Y3 T- {4 j; `3 c
- dma_addr_t dmaphysdest2 = 0;% Y1 j$ i% D3 w, Z y
- * |6 r" R4 r3 U/ M
- char *dmabufsrc1 = NULL;
7 {5 C- @, k4 y1 r6 B$ E - char *dmabufsrc2 = NULL;
" F6 t" f, }' P( H' d( w4 G9 ]8 j - char *dmabufdest1 = NULL;
4 l9 W/ n9 F1 w4 {1 \ - char *dmabufdest2 = NULL;% j3 S) t8 _! y. u5 F" a0 F; S
% O; G) G$ E4 H; c% d( g7 n- m, M$ n- static int acnt = 512;
) Q% A7 w9 I1 r' l - static int bcnt = 8;
" n: `; q( _6 Z6 P- _) R2 J - static int ccnt = 8;$ l8 Y, u4 U( b8 C7 a$ ~3 v
) C0 B, T! p! Y' T- module_param(acnt, int, S_IRUGO);3 V! M2 i L b
- module_param(bcnt, int, S_IRUGO);
! _: J! K L- q# V9 x& Y - module_param(ccnt, int, S_IRUGO);
复制代码 ( K8 x! v1 a. r* k+ @ z
; i' s2 k) r3 f1 Y4 \8 o 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 j$ C% v- d5 ~% ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 p4 C3 I' j0 b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( g7 b$ D* h: M0 [0 p. y @* n/ e, i- G9 r: R# Z
6 I$ K! R' |" z$ R$ E |
|