|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / I9 Q( L' W8 j
- [code]EDMA sample test application3 ?; A0 h# n# U8 q
- /*5 t% j3 L r6 q
- * edma_test.c
( N, P: x) w5 a5 k' B - *
4 q0 D0 x: Y! M( h, X8 i E) l - * brief EDMA3 Test Application
1 K( @7 p; f+ p8 n% o6 c - *( ]" W. G ?1 n! u/ V. s& d
- * This file contains EDMA3 Test code.0 | D4 h; R2 `- |# `
- *
6 k! z9 n3 K: X3 X! a! w! i* c$ d0 E3 P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& Z+ O8 m' C. v- [! ~3 ^* K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' Z- h ]5 t/ O* A- M) E
- * TO CHANGE.# M" Q+ e/ J- J& i, v C( t" ^
- *
4 s6 L' _( x& T1 E% Q8 \3 D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 r' [ b; G$ D- p C" V1 Y
- *) K6 C M7 W# {) f1 c, {5 z
- * This program is free software; you can redistribute it and/or
, ]4 z& g# t$ U3 C- N6 d- S - * modify it under the terms of the GNU General Public License as
( {8 e+ M* K, E1 n - * published by the Free Software Foundation version 2.
2 ?( z% ~- m$ n, u) ]# v - *
* `* u# b6 ?1 a6 x7 h$ w; u$ D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 W* l; ^6 }1 |$ u' Y( v - * kind, whether express or implied; without even the implied warranty
) H3 \8 |" D, H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' c* G* c* |4 }9 ]$ [' q) Y( g. _ - * GNU General Public License for more details.
* ~1 N1 v% ~" ^. N% `% S7 b - */+ ?, Y* u# p/ X6 \6 U& r+ K" E
$ m( E, e0 r6 |$ w' ]- M3 _4 k6 m1 {- #include <linux/module.h>
" R' Z0 E& v- P+ t - #include <linux/init.h>
5 `3 D5 Z B+ E s - #include <linux/errno.h>
% a/ e9 L4 j0 `1 y - #include <linux/types.h>
5 f+ F; t" E! A2 G" L6 T - #include <linux/interrupt.h>3 n( s9 X* k: ?3 }; R
- #include <asm/io.h>
D$ J9 W4 Q7 T - #include <linux/moduleparam.h>
9 B8 n4 Q% H, k - #include <linux/sysctl.h>
; g8 Y" b! r4 \- n7 m - #include <linux/mm.h>
" Q$ V' t, p/ i - #include <linux/dma-mapping.h>
% r5 K1 p' j, s" e- p$ r
0 f: P% a2 ]( l- #include <mach/memory.h>- ?- n* A( ^4 \* a. G
- #include <mach/hardware.h>" l/ `3 r' g" [% e U
- #include <mach/irqs.h>/ r6 q& V4 Y, X o8 i0 ~
- #include <asm/hardware/edma.h>
; \& _ k- L3 h2 R( _& ^. T - + W* q2 B1 H( X2 h/ N5 @+ M- @
- #undef EDMA3_DEBUG# M) _/ d0 U z& z3 y0 Z
- /*#define EDMA3_DEBUG*/7 V' v0 |4 H$ g1 X
- 2 K0 \+ U! k0 n
- #ifdef EDMA3_DEBUG0 P; R1 m, ?( Q# ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 w; \: E1 I% e( _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" b2 ^& q. i' z3 p% y( M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* H) B" u- \. l9 Y( X4 |1 Y. E* Q - #else
" i5 G6 H/ t g. Q2 D - #define DMA_PRINTK( x... )
! |" K, h% u( C" s& |( D - #define DMA_FN_IN
( h5 L6 j; ^1 q' j" ^4 T$ q6 q - #define DMA_FN_OUT
B3 _) }9 ^ P) }- p" r6 Y; A' E! I - #endif4 G3 M4 X2 [& a$ ]
# u+ a6 x' A6 ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 ?: W- u" f W4 o9 I+ |1 \5 u7 s. k
- #define STATIC_SHIFT 3
6 j! f3 s( m+ V5 O2 I - #define TCINTEN_SHIFT 20& ]: j* x/ V6 R. r7 `+ l" w0 T
- #define ITCINTEN_SHIFT 210 k- B& F6 l# S" R8 j+ y1 t
- #define TCCHEN_SHIFT 22* F$ ~- I+ L9 Q ?
- #define ITCCHEN_SHIFT 23
3 E g# {- Q# J [
! T; X A7 J; O K/ W, _- static volatile int irqraised1 = 0;8 I: q& W7 }& S9 e5 X* l. Y
- static volatile int irqraised2 = 0;
5 t8 k0 j% n8 ? - . c( b' `, {8 q* S3 T7 ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) f* J! E$ ~9 B2 f - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- P4 k3 K3 _1 l! ]9 Y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 y2 c6 ]& x7 K3 t9 Q
" n8 T- s# d! \+ @/ p! p( G; M- dma_addr_t dmaphyssrc1 = 0;
; }0 l8 z' A9 {) r - dma_addr_t dmaphyssrc2 = 0;* c- R+ `8 }+ {. O" G5 x
- dma_addr_t dmaphysdest1 = 0;
; V" |. d& R0 Z ?9 B W4 t - dma_addr_t dmaphysdest2 = 0;( W5 [- p# Y. F T( F3 P) n
' k+ q2 K+ v( W! m4 x' [+ h- char *dmabufsrc1 = NULL;% b7 `; k3 D1 s
- char *dmabufsrc2 = NULL;/ t) ^% Z2 y W- g# l! x: ~6 E
- char *dmabufdest1 = NULL;
7 A9 L2 O" }/ G& x& ? - char *dmabufdest2 = NULL;
8 r! M3 P8 p% ~5 o3 x7 o9 \
5 [9 U! k2 R1 l- static int acnt = 512;
# V6 F/ u6 c4 O1 w n2 Q+ P+ r - static int bcnt = 8;
4 |4 u4 j- \- H8 q! | - static int ccnt = 8;
6 I7 p1 Q* a0 A4 s# j! X) h
- y$ |0 m/ [+ Z) ]' G- module_param(acnt, int, S_IRUGO);
! H. q" ~' r! u, ?, v- R - module_param(bcnt, int, S_IRUGO);4 e5 H' v3 o% ^ Z" r
- module_param(ccnt, int, S_IRUGO);
复制代码 / n/ R9 P0 U* e( X4 E. l
$ @0 W. m4 P q8 q6 b1 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& C/ r/ C2 v8 \7 larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! W1 n8 Q8 o% m7 W& `/ v
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
D6 W4 O- w) n5 I/ a# [0 i, m% w W T* o: t4 ^! m
x2 d6 y8 B% i
|
|