|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 }; S3 ~- i4 S1 y/ f( ~; J. F& W
- [code]EDMA sample test application) C( B3 u/ C$ U# ~- q) G- F
- /*6 R& a( ~5 v, h W3 `+ h f# J1 _
- * edma_test.c: G9 X7 R1 _7 O7 @3 N7 X' f
- *# a) n0 C7 N7 ^- \5 y& w `
- * brief EDMA3 Test Application0 T$ z2 C* j. d
- *8 X8 L8 F% Z8 ^) t; a5 W
- * This file contains EDMA3 Test code.
. l6 n( M# e# Q; C1 G7 b - *+ U$ O4 v8 a- W2 a# \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" Y- q5 ?; R& |. n& g6 @1 A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; d$ U. o. a# R: v& P
- * TO CHANGE.
1 b! M! P6 m4 {$ v( K- W- A - *
( W& V, m5 T2 u2 r; B" ?: L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, T5 n& O7 _% z. ]2 b7 l4 f - * p$ L, ^; s; {* x7 |* r, B
- * This program is free software; you can redistribute it and/or
* g6 b1 o7 O- k1 y" J% H( l - * modify it under the terms of the GNU General Public License as
' X% E3 f5 ?8 C$ g" {% p - * published by the Free Software Foundation version 2.1 y5 U. L) l( \* P
- *) I8 O5 h- Z! O b9 k
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& F, A k* W x; m, {
- * kind, whether express or implied; without even the implied warranty1 h- J$ P+ v! D5 j! O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ |: S# I! f. a2 o i0 i* r - * GNU General Public License for more details.6 G" i# ~7 y! [4 O
- */
- |4 Z R8 o. W1 V1 k% u - * i7 M h) r. w5 r' |* a# W( u
- #include <linux/module.h>
' {5 T: O2 F* X1 ` - #include <linux/init.h>% i' t+ @; H7 S& W" ]9 M
- #include <linux/errno.h>: G5 ]5 f0 M! ?: w \$ d9 S; L
- #include <linux/types.h>3 W: V; O$ k; g1 ]4 f5 G) J
- #include <linux/interrupt.h>
/ D1 e9 n5 ^" l% Z( |# f3 ? - #include <asm/io.h>
3 X" p7 k: s3 U# `+ Q - #include <linux/moduleparam.h>
4 ~( C s7 @6 q; N6 N, M9 z - #include <linux/sysctl.h>
- J( E% ]- {9 T1 { - #include <linux/mm.h>
/ [- x: k, G+ b( U# l- K - #include <linux/dma-mapping.h>
$ Q7 e8 X* N2 m( r) j5 a' C - ! |% J- U M( A7 C( c7 B) n
- #include <mach/memory.h>
5 z8 s- z" ]* S$ Y. O" a9 E - #include <mach/hardware.h>4 l8 V, U+ x, J7 j3 |' s- N. b
- #include <mach/irqs.h>' c: G* X% k9 W
- #include <asm/hardware/edma.h>2 s* I9 z' k8 U# h
4 l' J+ F5 S( ]. B/ s1 f" D3 k8 g- #undef EDMA3_DEBUG3 P: V. J1 ^- e8 s/ h- s+ V
- /*#define EDMA3_DEBUG*/
' X' r( b+ Z; N$ @
! m( q8 i- E' T" s$ c0 B8 ^- #ifdef EDMA3_DEBUG+ ^- F: S! `- a- |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 `2 N; S1 ]0 V# M
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# k) G4 b! n6 }- b& [
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& z0 }$ A) p3 C* \ m - #else
, R/ K$ s9 j( v9 ~ - #define DMA_PRINTK( x... )& M& z' r% l4 h/ r
- #define DMA_FN_IN
$ c" o6 {9 j+ Z1 {, p( ~; P+ C! p1 \- H - #define DMA_FN_OUT
. ~% L3 k! j g: t& ] - #endif: L- B& p! O ?, p
- - V: r3 V' S1 Z0 ?6 c9 c+ E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, S% h: g' A0 J g1 d - #define STATIC_SHIFT 3+ F6 \6 T9 Z/ _, t7 ?
- #define TCINTEN_SHIFT 206 Q/ A. i4 q0 }: P2 y G
- #define ITCINTEN_SHIFT 21
+ \+ W: D2 B6 p- }) E3 L - #define TCCHEN_SHIFT 22
, }6 `, r. L9 G' A - #define ITCCHEN_SHIFT 23
( ]- S1 A8 }1 G! d9 O3 k - + B& O, x# [5 k+ S. o3 V+ {0 X
- static volatile int irqraised1 = 0;3 n/ t5 |3 q( w; S
- static volatile int irqraised2 = 0;
- I6 {4 C4 {3 n+ |: w2 t& B - 1 U' v& p3 h6 O' l; I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 A0 Q! r! q `6 ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 q% y, \% O% j, y* V3 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 d: X; t4 O0 g# ~* x - ) {% A" x2 i, `) q0 |# n9 W
- dma_addr_t dmaphyssrc1 = 0;
* O+ ~) O; z' |; S! r, |$ |9 o - dma_addr_t dmaphyssrc2 = 0;
" t, W0 N2 T$ i) J" O - dma_addr_t dmaphysdest1 = 0;
( K; L) |" Z, v/ n2 C. M. c% Y - dma_addr_t dmaphysdest2 = 0;
# ]. x9 K" [" h! C. S5 g ~
. b" O+ S. S9 v8 ]5 |0 L- char *dmabufsrc1 = NULL;
( q! T i" [! m3 P# f - char *dmabufsrc2 = NULL;* h6 g5 R" `2 ~/ C. a, D- S
- char *dmabufdest1 = NULL;
0 U3 h; t D ]& w4 `0 O1 R - char *dmabufdest2 = NULL;
/ g6 j) H0 a+ R4 b - 8 ~5 B' _# Y$ H" m
- static int acnt = 512;, ]' W) Z$ }, }: D0 _2 ]& ]" Q
- static int bcnt = 8;
3 H9 V, C: i" w1 G9 P& o - static int ccnt = 8;
) g7 {6 I, U1 W2 f0 K; y& t
7 ~- f6 ^/ j6 X) T4 h- module_param(acnt, int, S_IRUGO);' H) ^5 v; q' G3 d- `3 `, w" V! ?+ Q7 W$ P
- module_param(bcnt, int, S_IRUGO);& D2 p! m: ~; h1 y+ k" x( K6 s
- module_param(ccnt, int, S_IRUGO);
复制代码 t$ U/ D. p) g, t
2 @; o. O$ f( H, _5 O3 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ g' X8 b6 T: O2 _7 barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% f1 m' E% G& u1 B2 X a. K" s& f% M 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 G. L; s n2 ?, f2 s
/ [" G# g' Z& Z- a0 E8 Z9 E; y6 J$ c+ J2 S- R3 `; P& [
|
|