|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( X. t, t- {9 C6 d& ^- [code]EDMA sample test application
- U, w: r! j4 d - /*! z4 `2 K4 a; h" m
- * edma_test.c+ B/ _. S( r; `* T" k: p3 c. G$ p& a
- *
$ l& e8 T9 j& n" R - * brief EDMA3 Test Application
% k: d0 s0 B/ G+ M* M+ n+ } - *) m- ?9 B/ V$ Y2 c n5 P5 [6 B; `
- * This file contains EDMA3 Test code./ V; y1 i# W+ x& m& ~
- *- c) w2 n- }; _. t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% p' v3 e3 ?7 R, q5 k$ U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" s. k( o3 p7 ^" A" C( T: {' W - * TO CHANGE.% O' ?8 z% |( i& ^( E I7 \: H
- *3 D& Y( i' S' {2 s& m. O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 K$ ?3 |" ]! b3 u' s. _. j' ] - ** J4 k5 c2 K2 d `& M" W- R* y$ d; e
- * This program is free software; you can redistribute it and/or2 K" i$ y. z8 V! U! ^0 g! m! ^
- * modify it under the terms of the GNU General Public License as+ b- Z& M5 n) s- D, @
- * published by the Free Software Foundation version 2., c7 o% N7 n" R% t7 X
- *; |+ U4 v. h6 b$ a# e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: n/ X; B: L9 j! p0 o$ A
- * kind, whether express or implied; without even the implied warranty
: p0 Y9 N9 d1 d& q; L/ T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ i. Z/ C$ `! `/ f% ~) ^/ D/ | - * GNU General Public License for more details.
8 L+ a) b9 G; o9 c2 D, g - *// M# n% z9 q$ X% a* S4 N+ F
- . y6 K" v+ |" ^6 n7 E4 ^% V
- #include <linux/module.h>
' n9 g% w. [; T3 v - #include <linux/init.h># m" y' q( @* n% E; f" G X9 p
- #include <linux/errno.h>
0 G& H J# t; d7 T) V6 j - #include <linux/types.h>. T* q; K( X7 O( @
- #include <linux/interrupt.h>4 [$ H6 }& H0 J- ~5 z" B6 p
- #include <asm/io.h>
+ L5 m5 y, i! s3 |+ A& {! M" x - #include <linux/moduleparam.h>
( \$ ^, _. ~- ]2 |% p0 [ - #include <linux/sysctl.h>
6 k1 ?% Q/ F2 R8 C. r6 G3 _( I - #include <linux/mm.h>
& k$ Q" k6 p, K! q7 T - #include <linux/dma-mapping.h>
- y. J) r6 L& I4 ^" I9 v
- _9 U+ W0 U x+ D2 V1 ^- #include <mach/memory.h>
3 S# w) l; w, @4 V0 q7 `1 j - #include <mach/hardware.h>$ l( |0 D+ u! O- z
- #include <mach/irqs.h>
4 b9 d8 q# a b$ R" A6 s; | - #include <asm/hardware/edma.h>" t+ J% n+ \' H* ]
+ d/ y8 P) H8 E% K4 @. @2 P- #undef EDMA3_DEBUG
$ U; Z% j9 b. F5 v: v - /*#define EDMA3_DEBUG*/# O9 Y3 ^3 @! N& Y
) F [# B% f: g: N: m7 b* }- #ifdef EDMA3_DEBUG
" d! D% r& v0 Y/ z/ u, c: B1 D( C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 B. T0 W/ Z! v7 `; y# S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 c2 ^7 i$ n- A8 o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, H' y3 w' w" m# d: x4 o- x - #else( Y# d1 |/ R# }. n& n$ I
- #define DMA_PRINTK( x... )+ s" W" I+ _5 C5 h9 R
- #define DMA_FN_IN
% J3 l+ \' ^9 f - #define DMA_FN_OUT
6 C6 I5 d6 k5 j1 E' l2 p - #endif
* l0 Q' T& H5 B% Q' ` - 7 i/ {- a( p4 P! y( ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" h" H1 H) s+ P$ p( A
- #define STATIC_SHIFT 3- y& L- H8 ~' E% _5 y( o
- #define TCINTEN_SHIFT 20
$ E. b, p; z2 W" P! ]( B - #define ITCINTEN_SHIFT 21
2 N5 h1 u) b. ?" e | - #define TCCHEN_SHIFT 226 w/ N( J/ C; b: Q
- #define ITCCHEN_SHIFT 232 g H% p5 s# m4 g6 H0 v* g1 q
- " g8 T/ B# i/ n) O% N. N/ N7 [, K+ P
- static volatile int irqraised1 = 0;( E5 R& Q! Y4 P
- static volatile int irqraised2 = 0;" R! c: l) M! h2 y" m3 e
- 0 R- O; H+ ^# Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 t" @- h. ? X5 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 y; N# B' z8 b6 @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' ~/ H& V$ n4 {2 Y2 i7 k
+ Q, z5 ]# m% L- dma_addr_t dmaphyssrc1 = 0;: i) K, \( Z$ U, `: W. ]
- dma_addr_t dmaphyssrc2 = 0;
& _5 j# N" w3 Q& p7 v0 B4 n - dma_addr_t dmaphysdest1 = 0;/ ]: I# e3 ~9 u( e4 q
- dma_addr_t dmaphysdest2 = 0;( r' ^0 o1 G( s1 f s
- 1 b: Z% H; H# d* ]
- char *dmabufsrc1 = NULL;
, R$ I3 S% m0 F! y) e6 P - char *dmabufsrc2 = NULL;
' i; R8 B9 {; o- D8 r$ s0 X; d( W' M - char *dmabufdest1 = NULL;
* ^8 z T. K% O. q) n2 Z - char *dmabufdest2 = NULL;
1 ~# R8 K1 @6 V, Z
# x, E; [: Z+ {+ [4 i8 \9 \* G- static int acnt = 512;: h! Y* M' K# U B
- static int bcnt = 8;# T0 U* X4 t( v8 N% a6 n- j
- static int ccnt = 8;
( T, @- |, d. k/ w& y - / M+ }) \9 s" P9 u, a% o
- module_param(acnt, int, S_IRUGO);
& Z- j: ]5 ]$ e) c0 l7 k3 p. u - module_param(bcnt, int, S_IRUGO);& N/ M# |2 X* S% n% u% r& K
- module_param(ccnt, int, S_IRUGO);
复制代码
1 x; o$ V6 ]8 Z
9 N$ U3 m* N: K8 ?* q p1 Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( r8 ]4 R. E/ u; {7 U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* a Z. a P! V: u8 ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ G8 \$ O8 O1 K) W1 c' y& C, r9 y
, Y1 j& ~9 D) ]* X: h5 X |
|