|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 c+ ]: k' H0 F u" E7 y
- [code]EDMA sample test application% B- a. j! j8 Y1 G9 g- o+ g
- /*% A' T8 r5 K& v- @/ Z- Y+ d. j
- * edma_test.c
. O4 L2 ]+ q! A- a0 i: y6 |1 \ - *2 H' E6 ~4 k7 k3 l! F% m3 v$ ?
- * brief EDMA3 Test Application
- Y% e( T' J& a ? - *
) q; m8 m) w6 E) Y2 f, | - * This file contains EDMA3 Test code.; `: z1 t- j9 A# w
- *
/ P5 f/ m x3 g( j+ s/ I' H" h3 Y7 X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: P3 N6 \' a; \2 r, L' g# l1 L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 S4 f4 _5 i0 F; a: I4 q - * TO CHANGE." Z& X; X7 D8 Q4 f/ E
- *
5 b# Z6 d. [$ J ?7 W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 t$ i+ K8 f8 J& b7 ]
- *
! n4 o" ]/ C5 m. ~) K - * This program is free software; you can redistribute it and/or
9 C i) h% W) y( c7 D - * modify it under the terms of the GNU General Public License as6 h9 S9 l1 U+ @* Y) I3 c$ T1 r
- * published by the Free Software Foundation version 2.' x# _$ b3 L- z* M
- *
: r" r5 i; Y# X$ A" S! m$ Z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 @' H- b4 M ~0 J3 d
- * kind, whether express or implied; without even the implied warranty
; o1 G7 d& y. T$ D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 U1 L2 u( O# J9 D7 n; Q
- * GNU General Public License for more details.
5 d$ B' I! t; L9 e6 [ - */
/ U7 m8 r) {7 \/ T - 7 b) a/ [- n% ` B, }
- #include <linux/module.h>2 y7 N! X8 G: K' I7 J
- #include <linux/init.h>6 Z) A! u: a: k( B
- #include <linux/errno.h>; W% F8 n2 f& R3 N! a* z8 c8 Q
- #include <linux/types.h>
6 Y' k4 o" E2 _, T# ? - #include <linux/interrupt.h>
- w: L. ]. R" X) S' F$ N( o5 n+ ? - #include <asm/io.h>
! m7 t: P) i2 f - #include <linux/moduleparam.h>
+ o6 L$ D3 Y& x7 d - #include <linux/sysctl.h>/ D" |9 q; t% b% O
- #include <linux/mm.h>& @- a* q- z! H0 V7 H2 N3 [
- #include <linux/dma-mapping.h>8 p8 t6 Q# P) n, K$ T1 u+ A
- , h: Z" @# ~% s
- #include <mach/memory.h>
! ^" M+ [8 n9 L - #include <mach/hardware.h>1 e- H- Q, Q' d0 O% y3 y& W
- #include <mach/irqs.h>% A/ j6 B/ v/ P" U8 }# i1 Z1 W
- #include <asm/hardware/edma.h>( O$ Y C: m i. \
1 _/ _7 j8 i5 Q: J* ^6 n& v3 d& |- #undef EDMA3_DEBUG
o0 `& q: r6 C - /*#define EDMA3_DEBUG*/9 r0 K7 W: K8 k. W8 T) {
- / C, D- V1 q" a, X% E
- #ifdef EDMA3_DEBUG
$ w% m( j2 i4 A5 u; y8 ?8 i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# U8 _5 E S: z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% @* Z) w+ N" ]" G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 r+ d' \6 j; q# U1 k e0 l4 A
- #else
3 `( L4 o# w; }, K - #define DMA_PRINTK( x... )
& [# Q% }0 ]& k# _ v - #define DMA_FN_IN
# {; k8 l- V: _& y$ Q" j k0 l# L! I - #define DMA_FN_OUT
q4 R' e; y* g! T: @ - #endif
/ L* P: G# G) C: S. a
, i' K2 p; y$ U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' I7 W+ R- f2 {/ \7 T - #define STATIC_SHIFT 3. t* e* F. r' V. D r7 R* O
- #define TCINTEN_SHIFT 20
n) u/ ~8 U1 H$ D - #define ITCINTEN_SHIFT 21, P5 x& d0 [, R5 g# w/ h4 x# v6 e
- #define TCCHEN_SHIFT 22! z; s( |" x' L" n
- #define ITCCHEN_SHIFT 23: i( N+ S/ v& ^3 M
- 3 c5 r2 A: M8 B: H
- static volatile int irqraised1 = 0;% f L! F7 G) ]6 i, r
- static volatile int irqraised2 = 0;
3 l9 ]2 O( b2 k3 |0 ^% S+ | - ) F: { \2 |! V" u4 I% O7 Z/ H9 I4 z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 M w5 {8 F7 s @0 z- Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Z1 E* {- `1 ~ _5 I: d+ A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 {6 J: o0 c# I$ Y$ {
! {- q {0 R; s( u# \. a+ n- dma_addr_t dmaphyssrc1 = 0;5 ~3 t! W- c. ?+ Z, H2 W( u
- dma_addr_t dmaphyssrc2 = 0;% K# u' q1 H( `8 \
- dma_addr_t dmaphysdest1 = 0;2 X5 j) ]% S$ g. G
- dma_addr_t dmaphysdest2 = 0;
5 d0 y4 g0 S) t! W5 n9 O1 |
9 y% z3 y6 I: n: a) I9 X- char *dmabufsrc1 = NULL;
9 G' |# s1 f/ r Y8 i5 q: D% h - char *dmabufsrc2 = NULL;1 w! o1 Z0 u2 K2 {- p l/ G) k( k
- char *dmabufdest1 = NULL;, U+ f+ m0 Z& D8 M
- char *dmabufdest2 = NULL;
" i1 U% d/ l# I( k, \ - % T' W, M: D* u @9 y! L$ ]: F) `
- static int acnt = 512;
a7 ?2 {$ K! n/ S. ~ g8 w/ g - static int bcnt = 8;; [! `8 [4 e+ }: k2 x! U- ?
- static int ccnt = 8;; e7 {! E5 ~% G' n; z% `& B
; [! v n, L3 c9 c) r6 S' T! }- module_param(acnt, int, S_IRUGO);4 b+ `0 D1 f: R& X4 q2 p5 w, \& A
- module_param(bcnt, int, S_IRUGO);1 @9 Q8 j D, {& }1 K4 b
- module_param(ccnt, int, S_IRUGO);
复制代码 , B- V+ {3 O- f* |) h
O9 r9 L1 t" P9 R B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# w; u8 e" i/ F7 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 r5 H- m& D1 t, T! h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. g* O7 z9 q' ^3 g6 L
. O# B7 }$ o$ _
4 E( n& N: g, f2 d8 F( i |
|