|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 t% G2 l- d1 L5 ^, }9 m% B) X: v- [code]EDMA sample test application% X& I* P, u1 @" b, q
- /*- F; x. J$ S/ ~) b6 j7 d; u5 h
- * edma_test.c
. M! t. B3 c# `5 r$ H0 S$ y: H5 z, ~ - *2 |6 z+ [: ]: M
- * brief EDMA3 Test Application
. b2 ^! A3 m( p2 J8 c9 V$ D, a& C - *
: J/ _( I& }( v0 N% w4 y, e - * This file contains EDMA3 Test code.
3 p2 @: J: I# V - *
5 n; D8 }) m6 @* @# t0 q0 l3 ]6 Y' Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 k5 c: U0 l3 b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 r; l$ t- h/ z7 P, K1 F - * TO CHANGE.9 o" i$ l' F) |- K8 d/ n8 }2 F
- *$ u: ~8 f# ` f; T& p/ k/ l1 \7 {5 l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 |+ j/ a6 S, Z! s+ o) _) H& J6 p9 Z
- *
4 K/ l# {/ ?# X$ ]7 O - * This program is free software; you can redistribute it and/or2 Y2 B2 M4 N4 ^, `* Z! j
- * modify it under the terms of the GNU General Public License as
" {! m: x% V% o: }. q - * published by the Free Software Foundation version 2.9 c: l3 @6 R* |0 W- B
- *" r! o( i, J# y+ k$ j i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 @, S& D6 m0 B K - * kind, whether express or implied; without even the implied warranty7 g R: N& R [% z, z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' W' l0 B5 l7 |, E# x6 `
- * GNU General Public License for more details.
/ R. A- ?6 o" H - */
& Q! y/ l% Y6 h' Z - / y: A N& ]9 N; u% J" {
- #include <linux/module.h>
) S- F+ {( u5 |2 }5 e4 N - #include <linux/init.h>/ F j! M% Q7 F) w' x3 |
- #include <linux/errno.h>, o' G! H* H5 ] \$ K5 ~
- #include <linux/types.h>8 i0 e% n Z4 |. ]( \4 Q
- #include <linux/interrupt.h>1 H0 c- H; p8 m1 P
- #include <asm/io.h>0 [ V- p; W3 M, P) P# r
- #include <linux/moduleparam.h>
& y0 c3 ]$ t- e% f& M" @0 U - #include <linux/sysctl.h>
, G* O1 p& f# C: F - #include <linux/mm.h>
( k8 L4 l4 B; Q - #include <linux/dma-mapping.h>
m+ |: L9 q b! v
! ` j# f% y" S. |( t- #include <mach/memory.h>
$ y% G! D: v4 q! t; j5 y; `5 a - #include <mach/hardware.h> ~4 ]4 E" ^5 H" o+ o3 y* Z% X! x2 U% K
- #include <mach/irqs.h>
6 |, S9 t$ T% I6 R1 R3 l - #include <asm/hardware/edma.h>+ I7 n2 ^( A* {
- k- C1 S( F1 u& @" b
- #undef EDMA3_DEBUG
8 J" U) U- K8 W G6 G+ S$ k$ A - /*#define EDMA3_DEBUG*/
) k# |) f* v8 b' |5 _
: [: v! F% E( g4 v8 J- #ifdef EDMA3_DEBUG9 T1 `% f7 ^9 y9 k8 [5 [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; }# J! j" a% x K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ r9 @. E5 ]9 h+ W! n. c& Q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). n9 a. F; s3 @( h! x1 B
- #else+ Z1 }& w' D% Q+ l! g# X* i5 U
- #define DMA_PRINTK( x... ). Z: W I7 J$ m8 n* j
- #define DMA_FN_IN) n! U( R$ F9 E0 L# I
- #define DMA_FN_OUT* |3 J( z+ ^, m/ } x& ?
- #endif4 Z( H+ g6 ^& u( |6 l
# e1 t+ v4 x! q" X* r& K7 U8 [- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 {1 L6 n* [& z {. B2 Q6 w0 l
- #define STATIC_SHIFT 3
9 h( J8 Z+ H5 w/ k6 Q - #define TCINTEN_SHIFT 20, Q: s/ G$ q8 w' u
- #define ITCINTEN_SHIFT 21
" ]5 V5 B n" }3 l - #define TCCHEN_SHIFT 22
) `4 I. b: q- @4 Z9 ^ - #define ITCCHEN_SHIFT 23
& f7 T" J t, d1 B6 o3 M
7 J5 E1 u' E- ` [- static volatile int irqraised1 = 0;/ H; |/ ?$ V' H4 v* q4 L! p
- static volatile int irqraised2 = 0;- b G& g5 A) W% F j- f+ W
- ; i; L$ w) x* G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# g0 c4 ]; N* g& a; l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 i3 A0 k5 K2 G: N9 S% J$ H. B: C9 c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* h5 I8 u0 B7 I0 f! C0 O8 N4 T& V
* f$ v2 j4 X& q, {8 R- dma_addr_t dmaphyssrc1 = 0;: D& c- k6 w' c! d, ^+ N
- dma_addr_t dmaphyssrc2 = 0;
; x; i- X4 H2 O( [6 Q0 M- O4 E8 u) Q - dma_addr_t dmaphysdest1 = 0;" }* q* ~' X% v2 Z6 w, ]3 m
- dma_addr_t dmaphysdest2 = 0;4 U9 S2 }; T9 h1 o: J
- + N7 `; m+ K- _+ k$ e( ?, m
- char *dmabufsrc1 = NULL; x( }1 Z+ H( ^& Y' B# y
- char *dmabufsrc2 = NULL;- }0 P8 ^" e5 W# ?- M
- char *dmabufdest1 = NULL;
/ y. ^6 v8 G) o - char *dmabufdest2 = NULL;
7 A5 G% l2 s8 j4 s2 `0 g& r - 2 T' c! Q5 V2 ]1 Z! F
- static int acnt = 512;4 ~+ D8 |1 c x: ~/ V6 g& v
- static int bcnt = 8;, G! x* U9 A- M1 n
- static int ccnt = 8;
8 x- D4 |/ d3 v6 P O; r
6 @) O6 H' [/ u! ?! {- module_param(acnt, int, S_IRUGO);' x5 |! }% w& k
- module_param(bcnt, int, S_IRUGO);
" i/ p; ^- K5 _5 W9 k - module_param(ccnt, int, S_IRUGO);
复制代码 6 o2 \5 K ^! c* H$ ?
4 ^& P% V+ |* K. w6 U5 h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, I0 i- W$ l* \7 N: ~( |- ?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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! @6 C [4 u: U# O$ B7 T% O! x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, t5 a9 U1 C' [% m* s+ O, q
1 Z7 P1 e, y& X1 I$ R* h6 h* X
/ a0 O6 F0 x4 ~' h7 Z m |
|