|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# m1 v6 g4 F L+ T" _- [code]EDMA sample test application8 ]& m o/ i5 _' h( Q5 C
- /*
6 d9 d% _# M$ { V& G" Z- n X - * edma_test.c
2 u: S6 I" e, j* Z1 B% K. D S7 E - *
/ r' J8 n$ e6 I& a( w$ [, J - * brief EDMA3 Test Application
, L1 i4 v# E. L9 W3 K' }2 Q3 w - *
- r k3 Q' X1 v - * This file contains EDMA3 Test code.
8 ]* n/ M p4 {5 x - *
- Z( V( C4 o* M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ \. z: S; V2 r$ U. J' z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( P& B' k3 C# F0 F( c$ l* t - * TO CHANGE.' ~8 Y. a8 U9 V& S, \% }! m6 P. S: j$ S
- *8 N) t8 e# F7 Y) {0 J+ u7 D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. C. i. n' s; j q. u% a. O - *
4 K# X3 [1 \6 z1 ^. h3 q - * This program is free software; you can redistribute it and/or2 U, `4 S8 ?' Z/ _
- * modify it under the terms of the GNU General Public License as
0 ]+ P( a" Y1 N9 [ - * published by the Free Software Foundation version 2.
, B; B; N2 m/ `2 y( c; j - *( J' w* v( T+ P" y: C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ X* `7 D/ r# g
- * kind, whether express or implied; without even the implied warranty
) h* o) w' n7 F) x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! N8 H# C8 I4 s) `5 {9 k - * GNU General Public License for more details.; `1 a5 w$ b) p# T0 Q- i% b
- */
- C {! S# w A, B9 Y
$ O! N3 a3 B+ a1 Q3 U5 Z( z- #include <linux/module.h>
; h* y# t9 D, V; W5 P* k+ ? - #include <linux/init.h>
- G2 S# S- E5 Q) A7 D - #include <linux/errno.h>5 u8 {7 E3 |- F! O, R, U
- #include <linux/types.h>
% X- S, X, e7 p" d - #include <linux/interrupt.h>; c/ T% \4 R6 d5 ?3 D$ _3 P
- #include <asm/io.h>
$ U+ S+ \4 b" @ h; P0 V" ~3 p - #include <linux/moduleparam.h>
! K; {, Q* k" I: U$ ]) m - #include <linux/sysctl.h>
6 n5 ^) B( l+ P0 W; ]+ c - #include <linux/mm.h>( s ^) I! @ `
- #include <linux/dma-mapping.h>' `8 _9 {0 J' \3 [0 Y5 M7 o/ P
Q; V) O7 L/ ~6 r4 E- #include <mach/memory.h>
* U( b* k8 S+ y6 o: d! x7 Z' S. M - #include <mach/hardware.h>/ h/ r# @7 n \5 Q; ^( \% n
- #include <mach/irqs.h>6 ?% v2 V, o2 R+ [9 M g4 P+ Q3 U B
- #include <asm/hardware/edma.h>7 j7 N$ G. x& v) B4 u
- ; ?! F: g- \/ X7 e* j% ]/ b1 `
- #undef EDMA3_DEBUG* R% {7 i$ R" ]$ Q) U3 {9 h
- /*#define EDMA3_DEBUG*/9 J$ e3 z' i) T9 O
- 3 O% q8 B( N# J4 I9 D. A+ w
- #ifdef EDMA3_DEBUG
5 b$ O0 D' m; ?9 n) A2 o& A5 z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): N7 U- w7 u% c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 r& y( {8 w: ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ z# }/ c/ L# P, r2 t* q5 U - #else
# T. u: }8 n5 F# E ~! L9 F, y - #define DMA_PRINTK( x... )" w2 F) M( Z. s2 A& [ f% E& g
- #define DMA_FN_IN
: q1 R* X& T- ^6 e - #define DMA_FN_OUT
% g: t9 W1 a( @3 Y4 X3 k2 x - #endif. P3 P; O/ T9 p1 u
- 6 ^# \: W3 x* W8 g; P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& p( I9 S! h- c) V. ~: i* L$ c - #define STATIC_SHIFT 3, {" T" B/ V1 ]; `+ A' I6 }5 C
- #define TCINTEN_SHIFT 20
4 h7 A- Z; J! m( B - #define ITCINTEN_SHIFT 21
3 }% j8 D8 y! @$ }; b - #define TCCHEN_SHIFT 22" S# N7 u1 j. M, d3 y1 r4 x' q4 ~
- #define ITCCHEN_SHIFT 23
% L. _2 W- s9 z* t0 c. P5 s; r - . M( P+ I0 ]0 \: m+ }: o+ y
- static volatile int irqraised1 = 0;2 L* |) v# m4 h$ [5 o
- static volatile int irqraised2 = 0;
9 P# H3 o- Z# x2 s7 k T. S7 U% D
3 G" v. d; i8 t" g! a# l1 c1 A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' \$ n" m5 F0 t! L3 B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ?4 D# c# o% L2 a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% w0 w% q3 U5 t! _- }# E
8 U$ m5 d; r3 X. D4 ]- dma_addr_t dmaphyssrc1 = 0;
* g+ R4 V+ @% Y; i8 r0 n/ S - dma_addr_t dmaphyssrc2 = 0;; j) Y1 a% S J |8 l7 i
- dma_addr_t dmaphysdest1 = 0;
d" S" y$ b: W - dma_addr_t dmaphysdest2 = 0;; }4 V! Q8 ~7 u$ J+ {1 u9 ~
- ( m/ T4 Y% w4 G5 P2 w1 a' _+ P
- char *dmabufsrc1 = NULL;
- q2 X4 K$ O: c" s8 I: F1 g3 b - char *dmabufsrc2 = NULL;
& Y1 l* _! o' A( |, g - char *dmabufdest1 = NULL;
, Q% ~3 Z; p0 s' R2 y - char *dmabufdest2 = NULL;# R" j+ E0 ?' ?3 q9 e( ]
- ! R* b' f$ K3 W9 n$ g
- static int acnt = 512;
+ s0 g! Q, `2 N& A" `; k - static int bcnt = 8;
: J* k! Z& Y- l5 } - static int ccnt = 8;" z9 S! Y# {6 G4 x0 U7 p- x! W
& { v5 b& G8 Q/ e- module_param(acnt, int, S_IRUGO);# |1 `) t- E5 q7 h4 }" r4 ~3 A: N
- module_param(bcnt, int, S_IRUGO);/ T! p* c, q) T( Q. ~! v" G
- module_param(ccnt, int, S_IRUGO);
复制代码
: t7 } C) B1 E' q" j) f- T7 \; q$ k* d; c! ?3 w# T
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ {: M" f: z3 g0 I. ^6 \
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 r( U$ i" f* a* d5 Z. l1 V% E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ P/ U& Z D1 q8 e
- i% Q$ t6 Q. y! `* p* I4 l+ F! R4 b1 }! Q# O# e1 b! G
|
|