|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + S9 l% }, W1 [9 |, h/ o8 `
- [code]EDMA sample test application. B' P0 x7 _9 I) M+ c7 a
- /*: j9 Y. c; A& k F' z4 Y4 L
- * edma_test.c6 l+ g8 @& H2 t; Z6 E7 P$ t
- *
, |' F% i9 _ ?, ^4 @+ j - * brief EDMA3 Test Application
K* f! ~% }) M- A- n( n- H - *
, G2 ?4 _0 ^/ {0 D - * This file contains EDMA3 Test code.
+ m; F# W$ u, K: I% Z - *! N* `* x# t$ S9 J' U4 O! Z' C- l, ?
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 Z' v0 b7 @' b) O6 o6 O7 U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ f, P/ s6 {/ ]
- * TO CHANGE.
- C1 \* F+ z7 M6 B% i; H1 y* s - *
+ H6 w3 [$ y" y. `" D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// t3 k2 M2 p6 M1 ?* S( X
- ** J) ^6 O' T6 J
- * This program is free software; you can redistribute it and/or
5 F! g5 x4 c$ V - * modify it under the terms of the GNU General Public License as! M7 y+ q( G6 X( d+ N9 e0 U' z
- * published by the Free Software Foundation version 2.
. o! \, b1 ]8 C& X' W - *
: L6 ?" y! Q9 I: a# D0 ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' c/ u4 f$ a! j5 P' G6 ~ - * kind, whether express or implied; without even the implied warranty d3 U \! H6 N' I5 x/ B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: c3 k7 s! h% Q1 q/ X - * GNU General Public License for more details.8 S! p( Q! i3 @0 ]" {, N; l3 B
- */
% }( j/ M: m; \+ v, u
6 R( b! o Y% G, U) T- #include <linux/module.h>* \; t) E l7 ^+ l* Z& A' ~2 S4 N
- #include <linux/init.h>3 x: ?1 E" l$ G
- #include <linux/errno.h> l! B, d3 n* Z5 U; P5 K4 ~
- #include <linux/types.h>" Z# Y; [, B0 ?4 ^1 |$ M
- #include <linux/interrupt.h>
; }3 ^1 B+ c! ~* l! w - #include <asm/io.h>" O+ m0 d M! T- ?
- #include <linux/moduleparam.h>+ l; {4 k& o( i i' g U. m
- #include <linux/sysctl.h>
4 ]( [, S) y5 ] - #include <linux/mm.h>& {, s$ p# }. m& m$ o8 [; t5 _7 D/ L
- #include <linux/dma-mapping.h>
4 k/ i+ }7 A4 v: L! H- t7 i0 t
( g2 p/ m8 m4 m u- ^* h: T$ R3 t l- #include <mach/memory.h>
: S2 L5 A) k2 Y0 `, |/ f9 M. c6 z - #include <mach/hardware.h>, e4 L& k m0 A4 v
- #include <mach/irqs.h>2 u2 `; W3 v4 v m0 P5 ~$ [
- #include <asm/hardware/edma.h>
2 n+ |/ ~) [: C/ I' G+ \ - 7 P _8 [1 s; `" h+ A8 G( b- m* p
- #undef EDMA3_DEBUG
# U' x( L) A5 E: [, k - /*#define EDMA3_DEBUG*/% H ?8 y) |4 B' `2 T& E+ ~
- , s4 P0 H8 y' ^+ `
- #ifdef EDMA3_DEBUG
1 m# {5 i" f! v$ }1 h- P# n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* p0 k/ _! h) W! @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 D& z7 H' z) U; h/ |: a& }/ {3 K - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); W" I" m. P5 O. {( @
- #else
2 F @) I! ^0 Q7 n4 U. J9 B4 F - #define DMA_PRINTK( x... )
! y0 L$ T/ J% V0 S4 A5 H; |+ N - #define DMA_FN_IN. X* d( S/ x) p7 A
- #define DMA_FN_OUT$ e5 Q2 K* z0 y
- #endif9 U! w% ~! A8 w5 ^
- 1 \5 Y4 {/ d. b/ _. r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 O& y7 I6 S$ J1 \+ c! A- I
- #define STATIC_SHIFT 3
6 ] d0 a% n$ h2 g- b' B - #define TCINTEN_SHIFT 20
7 F0 _2 b- F; E: n" b4 x! B: o - #define ITCINTEN_SHIFT 21; u# P' X3 W; r
- #define TCCHEN_SHIFT 22! V- A/ N1 D5 k& A
- #define ITCCHEN_SHIFT 234 J# g0 i( ~6 Q- f) ?
- / J6 ]/ l7 N. ^% F9 D+ \6 J' j
- static volatile int irqraised1 = 0;3 `7 z5 I1 Q# v
- static volatile int irqraised2 = 0;, z0 p7 w. h! j5 z9 k6 ]- ?
- $ Q3 d2 S: R+ l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 [6 k# _4 Y3 o9 | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' O0 k! ?% Y- c1 |& [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' j" t! D! c2 a! g2 ?
" s# B, h! c6 E; n3 ?0 J. E- dma_addr_t dmaphyssrc1 = 0;
2 w7 h# u' B- o( b! J5 _* s - dma_addr_t dmaphyssrc2 = 0;
; {- C) u1 v0 K! _! O% I - dma_addr_t dmaphysdest1 = 0;
' n& \/ u- k0 F; O - dma_addr_t dmaphysdest2 = 0;; M0 @ U) g) X, A( s3 b
- u0 j! ]2 A0 X1 T$ \8 e: G- char *dmabufsrc1 = NULL;
3 |7 R% |& A: N$ b" \ - char *dmabufsrc2 = NULL;
; @' v6 S' T7 |0 [ ? - char *dmabufdest1 = NULL;7 G( ]+ @, k5 w* J3 v' i
- char *dmabufdest2 = NULL;
' [: G9 _ q7 ?* o. z; ^ l1 G, P
- L! g0 W5 j l% H, P! j3 u. t- static int acnt = 512;
7 P4 t- ?5 O1 _! c) V - static int bcnt = 8;+ J$ |, p9 r! x7 c' }
- static int ccnt = 8;# r) }: s- u7 ]! ~" s/ e6 N
- 2 w8 A# Y1 G6 |' q
- module_param(acnt, int, S_IRUGO);
# z* c* I& |$ ~# }: Y; `, j - module_param(bcnt, int, S_IRUGO); A+ Q+ w' M V8 y- j
- module_param(ccnt, int, S_IRUGO);
复制代码
! h! p) ?2 ^% F; E5 i) D6 F6 N* I7 y. e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- U$ r1 r6 c- X6 d, v) Garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 W# ?: T* Z! u4 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; z+ s5 p. g# r
u9 e0 f8 Z1 a( S A! P" I3 \% v' U# F* N
|
|