|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. V s" L! m. K9 [2 H$ C- [code]EDMA sample test application
9 `# _. f# h1 ^: C - /*
* m% F' o. j0 W- c& W - * edma_test.c
U! M$ a! @4 e6 m( L' ~ - *
+ h9 S% {. r/ A2 E' V1 o. w - * brief EDMA3 Test Application! z1 r# x2 e5 k, B/ h
- *+ }0 |0 O! p( F7 B7 h. \ T, R! V
- * This file contains EDMA3 Test code.
9 n0 q8 I8 S" p9 @% f - *
4 U) D ]/ h! D1 @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 K. ^6 i, H, b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! h3 p) L6 Z& u+ N* J7 _3 U
- * TO CHANGE.* L& C, Y# G. ?
- *: k E) F: @6 @/ E2 }3 o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 a0 {4 K- p+ {+ ?1 F - *; T# ]+ k2 g& X9 e" {5 a/ @
- * This program is free software; you can redistribute it and/or
& }1 @6 o1 }/ ^) A4 g" b - * modify it under the terms of the GNU General Public License as
/ {( g" e) ?9 a$ z1 Q - * published by the Free Software Foundation version 2.6 u8 c, d/ y( T
- *4 E4 v' Y9 o' a7 x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ w' s( ^; J5 O7 u: A' h5 ^* ]1 I& ]
- * kind, whether express or implied; without even the implied warranty
3 J& u7 O- S" \1 d! q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) V v6 v' H. d6 P }7 A$ g - * GNU General Public License for more details.* _$ o" c0 T, G$ N/ t2 Y
- */' I& [( k; m* A, W3 q4 U
' V; S" d: H6 K9 x4 Y, w9 `( ~- #include <linux/module.h>" a# r1 [- h& k* K
- #include <linux/init.h>8 g. x$ O# C2 k% H% l! c. ~9 h+ F
- #include <linux/errno.h>6 Y. p' \* V9 `" C( b
- #include <linux/types.h>
$ ^: M0 d: Q: s - #include <linux/interrupt.h>% @8 l& L& Z. M
- #include <asm/io.h>8 \) G5 m: ?) }5 @. y4 I* P
- #include <linux/moduleparam.h>
- P; i# Z4 X. J) t! |( d5 m6 B( l - #include <linux/sysctl.h>
! V/ \3 |" A5 V2 l7 n3 ~ P - #include <linux/mm.h>
]7 C! C# p$ o9 s- j; M$ f - #include <linux/dma-mapping.h>
5 j, g9 q1 n! C k - ( p9 n( A% F6 G7 }! Z/ }
- #include <mach/memory.h>* S+ e& _% D' ]) T& g- f6 N
- #include <mach/hardware.h>) A p# @" J% f' N6 }, V% t' L- j
- #include <mach/irqs.h>( r+ T. [- A) @0 j' e9 V2 e
- #include <asm/hardware/edma.h>
- \- a/ b+ w' G' Z- K G: Z( {) n* `1 w
* X0 j* J* j O7 S& k1 }- #undef EDMA3_DEBUG4 @* j( C7 K: s6 m% \
- /*#define EDMA3_DEBUG*/
. @* r% J' e2 C - " j8 u7 C& I Y
- #ifdef EDMA3_DEBUG$ }5 z1 ~8 O* o) v0 ^7 {7 c# u/ x
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. Y5 E' Z( S( W4 K, j2 K9 K5 w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ `7 W o8 P! l; e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" o' _+ z5 Y3 W$ i5 I# P" \# O - #else
4 L2 m: U: w9 F8 W- X - #define DMA_PRINTK( x... )$ c! w& h! b/ o% v$ o
- #define DMA_FN_IN' X% ^0 o- U P- S1 ]
- #define DMA_FN_OUT
$ R9 o3 R1 t U' w* S1 d, O - #endif' M+ j/ {# l7 [* k' d6 t+ s
1 Y4 m& y" @, `$ x1 i5 a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: t5 {8 ^# r' j# P - #define STATIC_SHIFT 3
0 E; s3 ?2 ]* ]" C - #define TCINTEN_SHIFT 20
- d$ Y P& z1 V8 Y/ n% U - #define ITCINTEN_SHIFT 212 Y. V& E7 Z2 N! P N7 v- B$ r3 l
- #define TCCHEN_SHIFT 227 I1 r5 \% L1 Q
- #define ITCCHEN_SHIFT 23% P6 A+ R- P" s% I V/ q) H
$ e! }& \2 E! w5 ~0 h- static volatile int irqraised1 = 0;
- P" J* u: p1 N/ Y- l - static volatile int irqraised2 = 0;
3 A" K: ^0 |5 V7 l4 F
0 N) N6 h {( ?7 | M7 p% K2 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* {3 ~7 A0 l$ Y9 f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 W$ G' z; x! g/ t1 o4 U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* F: k ?, U9 ?% ~ - 1 _1 v# T/ p) P9 o3 F
- dma_addr_t dmaphyssrc1 = 0;
7 ?' K& \" f' A2 p c - dma_addr_t dmaphyssrc2 = 0;
$ s% f9 ?/ `8 n4 F3 w7 I - dma_addr_t dmaphysdest1 = 0;9 ]& l" Q) S [2 t5 u5 S& n2 O
- dma_addr_t dmaphysdest2 = 0;
$ }8 Y7 {. w% ?4 s8 W N" P - 1 b) l1 f/ ?' y4 L, e- D, {; t
- char *dmabufsrc1 = NULL;* Z' I" j `: I
- char *dmabufsrc2 = NULL;: z" B- G9 I% s+ `1 K! }) \% H
- char *dmabufdest1 = NULL;' F' r$ u3 I$ I1 @+ M
- char *dmabufdest2 = NULL;3 q0 K8 r* U8 f, G5 O
) y0 y3 Z3 D; ^4 J' V9 x+ g- static int acnt = 512;, p3 {+ F/ S7 R( z2 @. Q" n1 J
- static int bcnt = 8;
* [( w! N$ X" Y. A0 d! N1 H! G - static int ccnt = 8;
9 Y6 y- I# J; }2 u6 ~ - 9 r x$ h6 Z4 H: d' U. l
- module_param(acnt, int, S_IRUGO);$ w' r3 l0 K3 P f0 y
- module_param(bcnt, int, S_IRUGO); I. j/ x, n/ R9 \% M9 n
- module_param(ccnt, int, S_IRUGO);
复制代码 - j$ } r" M! v1 q9 y
) i- P+ p& M- x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% T# s+ g; A! j- I$ W9 p1 h
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
P: h. q3 k6 h8 c( v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. u( e2 R+ p. Z2 \! F
& s3 o N) ^: u! i# ^1 \
$ L R9 n$ M/ K* o |
|