|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 U2 L% K: i- q, x( R- [code]EDMA sample test application
$ R" l) {% d) c% k" x5 ?# @, H - /*
: v5 t) y/ g& t% I - * edma_test.c$ @# @9 [, R5 D0 x6 V, i
- *
- g, X' P- X& R5 s' q - * brief EDMA3 Test Application/ E \7 d! ]/ _/ G' R
- *
! b- o- c) v$ s* X y" ^% _8 | - * This file contains EDMA3 Test code.# j, e5 z5 C6 G& v, V0 F0 E3 M
- ** w2 @ z! M( Y. Q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 \8 N( v& E8 u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% {5 k6 z; T4 U - * TO CHANGE.
& b; j! n( @& ^ - *
7 e1 ]* G: T# q5 c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. a9 \9 N$ i7 v1 S/ [" c - *9 [& W* H( Q5 Q- e
- * This program is free software; you can redistribute it and/or ^; S! R8 J( ~) P6 Y, I
- * modify it under the terms of the GNU General Public License as+ J! |6 ]+ G [' l: u
- * published by the Free Software Foundation version 2.
' T: n4 _& o4 K5 v5 z - *2 j0 g2 e8 z! W' v5 L2 A3 A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 ^) T& L- q: | I' {5 D - * kind, whether express or implied; without even the implied warranty
8 v2 k* R0 i+ R% G. [( E7 L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& m5 t2 I! L i* e J& _ - * GNU General Public License for more details.
1 g7 ?# w W) e U1 c! t# ~! I" B - */
1 a8 x+ ?& |& v2 B6 g# C5 s
x" ~4 ?- Y7 J% b- #include <linux/module.h>
9 v5 g# P3 D6 j( Z; b' v6 E" V - #include <linux/init.h>
( K$ W+ L# T! Z7 W - #include <linux/errno.h>2 k2 i* K# W( z% z) n/ ~1 Q @9 N/ Z
- #include <linux/types.h>
8 T8 y$ ~' W2 f V - #include <linux/interrupt.h>
0 X+ d- n, B: ^! s6 b ? - #include <asm/io.h>
/ I1 {7 Q2 O, D( m) y - #include <linux/moduleparam.h>
* X1 ~6 C* `0 ~% N1 u9 P - #include <linux/sysctl.h>
6 i2 K6 P' b8 Z; D - #include <linux/mm.h>
% t( s; M5 Q( ^! p - #include <linux/dma-mapping.h>, X3 x6 c4 |- s; T) L1 Q
- ' j4 M% {3 l, A4 q
- #include <mach/memory.h>
: o7 \6 X6 y. V2 n( o. G. U - #include <mach/hardware.h>$ t5 W' \+ q4 o0 x& {$ ]
- #include <mach/irqs.h>6 ?$ y4 T: A- S+ ~! G
- #include <asm/hardware/edma.h>
9 K3 @% a& p3 Z: b! J$ \
+ J, s5 a0 V( K& m: h- #undef EDMA3_DEBUG8 {9 Y8 H5 q! R5 X; m# f. y
- /*#define EDMA3_DEBUG*/
" ?4 A& O8 s( r p - 5 t9 V' h0 _0 x
- #ifdef EDMA3_DEBUG
2 K; t4 T0 a9 E* d" [1 z" y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
^! ^6 j/ a2 Q, T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) o6 x( j3 X# v8 }5 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ X- t" |/ ~7 L - #else$ g K, J* a J$ C- k
- #define DMA_PRINTK( x... )3 P) o9 a' b, z4 i# V8 n$ i; A, P
- #define DMA_FN_IN
) q( C: {, m" b- s" l" \5 m2 ~ - #define DMA_FN_OUT/ T b! e; r, N7 |2 {, m
- #endif0 l! Y7 X( h R5 P6 N
: Z2 _9 x5 h+ C& b! l% ^- c B# E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ z% a! w S( S3 P0 i
- #define STATIC_SHIFT 3+ J, n3 ~, E+ ]+ E
- #define TCINTEN_SHIFT 20
% n4 V! G2 @$ e" ?! \1 W - #define ITCINTEN_SHIFT 21( N" H' V/ D' p+ u$ y
- #define TCCHEN_SHIFT 22$ {7 M) v+ l) t( s9 u8 l* i8 p8 R
- #define ITCCHEN_SHIFT 23
' E, q4 q7 l! |/ e' U z- Q5 y
# d$ |3 H# W9 o9 \& R/ v Z+ P- static volatile int irqraised1 = 0;
# F4 N; S0 z& t+ z; I7 z - static volatile int irqraised2 = 0;
4 J+ g, {7 Z; i u" n
. _- j% r5 n) J5 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% s- ~; E0 ?5 Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) N8 P% G' h, w/ d i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 S. M6 w. H' m: y* x6 M: R
1 X$ J9 n( F1 B+ P3 D- dma_addr_t dmaphyssrc1 = 0;9 q0 D; \ W. O Q
- dma_addr_t dmaphyssrc2 = 0;
* j: y# {' R4 ` `" w- A - dma_addr_t dmaphysdest1 = 0;
! ?) @5 \. B$ A: Q8 d5 d - dma_addr_t dmaphysdest2 = 0;
. q6 q, \) i: d) F2 Y6 v; ~. V+ V7 s3 D
5 [; M+ H! x" o: {2 A- char *dmabufsrc1 = NULL;: ^. l: u) k9 g* i! O
- char *dmabufsrc2 = NULL;! b: c5 R6 i/ w5 q0 P% u7 x
- char *dmabufdest1 = NULL;
6 ]1 {: Z+ s7 O - char *dmabufdest2 = NULL;
6 o; |# x& [2 t" F" d4 N Q
/ v7 K/ F+ }" w& ~- static int acnt = 512;
: P8 M% n r4 E3 G5 D5 M - static int bcnt = 8;: Z: {! T" q* T# q2 C
- static int ccnt = 8;4 O6 {, b% Y6 f7 {- T
- ; j; G M1 S g3 e+ I
- module_param(acnt, int, S_IRUGO);
8 c& Y: D5 m, n2 S4 a" w9 c" i - module_param(bcnt, int, S_IRUGO);
8 F5 A9 z+ y2 Z8 H; Z; ~8 b - module_param(ccnt, int, S_IRUGO);
复制代码
- J: \ n6 {9 M" }% v1 _3 ^. g' d6 W' I/ O4 H% k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: e: A+ a4 ~ E8 G1 x* W5 R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 J$ N( r; \3 Y$ V e5 ^ h- V5 C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 a' w( a' }* {5 \( L. t
6 I8 K! s& H9 p" k# K
/ J t( }! `) p7 d m+ \ d
|
|