|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% u! P9 M1 G8 A3 h% r' ]- [code]EDMA sample test application
1 X: |+ U4 r; ] - /*
0 p* }% S' h2 ]' j - * edma_test.c
& E' R8 l5 B4 W - *
- ]" }# `0 }) K0 G5 i( g- Z - * brief EDMA3 Test Application
: g; s2 A0 {# n8 H0 q0 n0 Y) j - *
3 E* C4 K. H; W/ O+ Y - * This file contains EDMA3 Test code.
' q% y* ?7 H$ s0 [ - *
( t1 g' h3 h( \: N9 ~9 k3 P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. K( H \' o% y5 ^# N1 u( m& F+ f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
`0 e0 t. ]3 @0 V' N s/ Q - * TO CHANGE.& J6 t( }" t2 B
- *
/ }' Z) ?/ X& s& P* Q, i9 b6 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- K/ B+ l0 C, o; \* H* A7 f, [
- *
& C( G& V% i9 } Y" i8 n. x - * This program is free software; you can redistribute it and/or
: C8 {; ~7 A# N @7 C - * modify it under the terms of the GNU General Public License as
' {- A2 v- R) z - * published by the Free Software Foundation version 2.
& _+ y" q( v. B6 q - *
& }+ [- E( Q& ?7 |' w, j2 y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- H) |7 ?' |4 k5 _: d6 J$ N
- * kind, whether express or implied; without even the implied warranty
2 d- ?2 D1 o ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 j# P, h0 l: M+ h( w
- * GNU General Public License for more details.0 |. a! w$ b1 V
- */
. k: m# ]& L* a' p) i) h6 N; P
7 V( E: R. z# ]1 X- #include <linux/module.h>
( b/ k8 N) C1 C3 A6 V" x3 l @ - #include <linux/init.h>, p/ B- I2 F5 g$ G) B" |8 k8 y# P
- #include <linux/errno.h>
5 r; ^2 A0 v( s& D" P. V - #include <linux/types.h>" q# k& \/ @2 W; ~6 A
- #include <linux/interrupt.h>
1 V8 R K9 m- X$ W - #include <asm/io.h>
: D& S; y! e, L - #include <linux/moduleparam.h>
" i: ^6 w" l" Q& X - #include <linux/sysctl.h>
' ?% Z8 h4 A$ [ - #include <linux/mm.h>
0 r" r. t t- v! R0 u2 j - #include <linux/dma-mapping.h>
. ], G; \+ _: B
: W) d2 l1 `* g- #include <mach/memory.h>
# W# A4 j( P) J" c - #include <mach/hardware.h>
& _8 Y! V) P. }. T - #include <mach/irqs.h>
; ^- ~) `3 k0 v, `! ^5 h - #include <asm/hardware/edma.h>" o* ?7 ?+ L. M
1 D6 Z; @* p4 ?" _ d2 S0 o( m- #undef EDMA3_DEBUG
- f5 E1 r4 t$ P - /*#define EDMA3_DEBUG*/
% G6 f; z/ J2 I Y+ B' }
. k4 j& J. q! v0 `5 `- #ifdef EDMA3_DEBUG
: H! p" O* I# t# i! q7 y3 R4 Q+ x. s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 Q$ g& n6 w+ l$ m) }$ l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ {" I* w- y( U6 f3 u* | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 i% i3 ~0 n- z, z% D2 L* C - #else# S3 Y4 K% p4 ~5 w
- #define DMA_PRINTK( x... )
+ w7 x% L, ]' S+ d - #define DMA_FN_IN& p! z& |. ]2 J2 X* F" T( |4 a
- #define DMA_FN_OUT1 n2 s# z# t7 O, h
- #endif
' a) A/ K" @$ j) ?6 H, c
0 k) H' D- K" ~( \- c8 _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
t' m7 w) m, `) B6 O5 e( A/ J' `2 \ - #define STATIC_SHIFT 3
5 V0 H& s+ S2 U& P, x+ q$ }8 x - #define TCINTEN_SHIFT 20
0 U6 q, Y+ m" d* a0 u - #define ITCINTEN_SHIFT 21
2 B9 n) S. i: { - #define TCCHEN_SHIFT 22$ e0 i! c& y: ~- }# L. S' |+ U0 E# Y
- #define ITCCHEN_SHIFT 23) u, T4 G$ {3 {+ T3 P7 ~; o
- - S/ q- b7 t b v7 D; e, U; }" V
- static volatile int irqraised1 = 0;
( i6 f1 R' R5 V8 b2 O) v0 P/ { - static volatile int irqraised2 = 0;7 e* n4 D+ A' A1 J2 U/ b
M7 ^3 b( [. g, G- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ H; E4 h9 J% A1 O& ?" k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); L, H; K8 U' p" L* a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, @# c4 |+ d% f% V5 y( g
8 N3 I7 [ E9 D7 E8 F( c0 g r6 m- dma_addr_t dmaphyssrc1 = 0;9 f. y; o+ b% u6 u* r; E$ `
- dma_addr_t dmaphyssrc2 = 0;
( h# \3 @- y+ L5 i6 C9 M7 d# \% P - dma_addr_t dmaphysdest1 = 0;
. T* ~0 d7 @2 H* @, B. i: ` Z - dma_addr_t dmaphysdest2 = 0;( A, L5 Y4 N6 ?
/ D6 S+ F! l, V0 W G- char *dmabufsrc1 = NULL;
- t$ h$ ^/ T9 D$ p; X* ^ - char *dmabufsrc2 = NULL;
( d$ R. I8 m! L! p/ ^ - char *dmabufdest1 = NULL;
9 ] [& U5 O8 K- t/ e/ @ - char *dmabufdest2 = NULL;
3 |# @( k* Z" J - ' | ]. J; S1 P/ r4 ^
- static int acnt = 512;% _1 j5 |$ |3 v. S7 T$ ^. }5 z
- static int bcnt = 8;" \! v- Z* d, B) N9 m/ @
- static int ccnt = 8;
: ?3 a/ u1 N0 _) E8 J- n, T - \$ Z. N/ [8 M
- module_param(acnt, int, S_IRUGO);
0 m& W9 u& M/ `9 r6 P! T& e - module_param(bcnt, int, S_IRUGO);, D9 {8 {# K# D" l- C
- module_param(ccnt, int, S_IRUGO);
复制代码
$ V/ @; Q$ ^ M$ f" Y4 H. n- ~' N. J7 V: V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ M. Z0 N5 @9 h/ \* H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 I2 n$ C: F/ i; J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( \( t/ y; N& N; }! |4 k8 f
' I/ G" z1 p( C7 p0 X5 ~
, G1 X( w) y1 ?( N |
|