|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" h& X* O1 x7 [2 U- [code]EDMA sample test application
$ w/ {( k( [5 m9 J- z- g - /*
) l& I0 y4 G$ R; N - * edma_test.c
, Z& X. [! W' r! C - *
. d9 x: E' P1 h; V - * brief EDMA3 Test Application* i; w- s. i2 f& Q% l
- *
`* J$ a ?- P, a* ]2 F - * This file contains EDMA3 Test code.
/ T9 Z/ A5 i: m. s% j - *# I, f! W! g, M- I2 ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 d4 J0 h0 w0 t# p4 H: a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 a( V- G) Z. o" }- [; m - * TO CHANGE.
, U+ q/ p# e9 W, S% J z) ] - *
( U& x' `" H6 S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; C8 b$ h f: \7 L* v+ c. e
- *
/ k2 s$ G8 n. s. T, g/ k) h - * This program is free software; you can redistribute it and/or
! H4 D1 H4 K s, C0 W - * modify it under the terms of the GNU General Public License as4 t; L: p2 u+ @8 _6 C
- * published by the Free Software Foundation version 2./ L V5 i* F2 E# H+ ]$ E" D: ~% e
- *
1 _" |7 h0 m: E9 D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 ^0 p( W8 w9 U/ q9 D& d) Q3 K - * kind, whether express or implied; without even the implied warranty) ~+ P% `. ]" b: q2 J+ R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 V9 |) f( x7 _& R5 V/ d
- * GNU General Public License for more details.
9 `* q- j1 Z: I - */
3 [3 D) G# k( v6 o# @9 L4 H - 9 B% T3 ~, G7 c$ B% M
- #include <linux/module.h>
_7 c) {2 F5 p6 G$ @$ j0 G- B/ n - #include <linux/init.h>8 F A d1 A9 q. _
- #include <linux/errno.h> G( l4 _, g! x, r! k8 ~/ H
- #include <linux/types.h>. d9 m2 l L4 {: \7 Q: j* A; j
- #include <linux/interrupt.h>
! h# D9 P5 G& ^: L9 o - #include <asm/io.h>* ~% c, W1 q4 f. e3 f
- #include <linux/moduleparam.h>6 S4 D& m; z! b7 _+ i* U& d! b
- #include <linux/sysctl.h>2 y2 ]! B5 r/ o: \5 _- L, x* {
- #include <linux/mm.h>
# x6 c2 s: w6 M# O- ~ - #include <linux/dma-mapping.h>
! G1 Z3 t) O/ `+ ]* k - . r9 H9 G- e; \, O3 ]9 ~8 k
- #include <mach/memory.h>
0 P: P9 m! E& T/ W - #include <mach/hardware.h>% X% k" p' a- x* `
- #include <mach/irqs.h>
) B P9 B6 ]# }7 H% n. ~$ o9 ~( F - #include <asm/hardware/edma.h>% e+ M( c! j# r# d
- : b4 m) A3 n5 w- b- o; @+ h" q
- #undef EDMA3_DEBUG
3 _; @, ` m- g9 M c5 A! ] - /*#define EDMA3_DEBUG*/& v' y8 K6 F* _( @8 C
- 3 m: ~. Z" R( j5 u9 l+ e' T* J
- #ifdef EDMA3_DEBUG7 E2 o8 L8 u& j% Y) t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 {7 U4 s6 k: B% `, s0 @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 }5 m5 c( ]1 H* p$ L3 v9 z/ k: {9 _$ P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, m& y+ ~" {9 C$ u- o) C' T - #else i/ e+ L1 g( S; {, i; r9 J* w
- #define DMA_PRINTK( x... )
* R7 { P4 I( ^# m( i0 K - #define DMA_FN_IN
: w* l! S2 ?& c- N$ [% [ - #define DMA_FN_OUT
! \7 {5 }" a2 _0 f - #endif4 Y$ g* }) t( w9 O, Q" g
" H9 O+ c2 P7 J6 F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 I/ `" U* `3 V6 T& C
- #define STATIC_SHIFT 3: n- a6 J H9 f6 l* W! \9 Y r
- #define TCINTEN_SHIFT 206 u1 `: E$ c' L j7 ^+ y
- #define ITCINTEN_SHIFT 21
! ^2 |! m! E% u - #define TCCHEN_SHIFT 22
0 ~0 c" Q- B$ d! s' G- Q - #define ITCCHEN_SHIFT 23
( u) {& ~4 {. _: f' {
9 D3 X8 h; |. o- static volatile int irqraised1 = 0;; a1 K" X; a' X+ j
- static volatile int irqraised2 = 0;
$ E* X! \: \ u9 R9 F& F0 L
, {; v5 j7 F( N9 w& }) i1 c5 W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ }+ e# w8 q$ j4 [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, H0 ~* ?/ y; |: a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* @+ S& W: A5 E4 W
Y7 h) _+ z2 v- D- dma_addr_t dmaphyssrc1 = 0;
5 }7 P% }; r9 H" J2 K" g6 E# } - dma_addr_t dmaphyssrc2 = 0;) Y% n8 ~* C O. V
- dma_addr_t dmaphysdest1 = 0;) ?+ H, B0 @! \, G1 {6 L
- dma_addr_t dmaphysdest2 = 0;# O( B) C6 d1 v5 e' `
- 4 `# w" m) C. S# P& \, B9 `
- char *dmabufsrc1 = NULL;
6 ?! ~6 C, c; a9 N2 N - char *dmabufsrc2 = NULL;
2 w' C. Z" N9 c/ | - char *dmabufdest1 = NULL;; m8 w5 K, w" S. e9 _" [
- char *dmabufdest2 = NULL;3 q8 q9 y* ?5 {9 `
- {) k- ^1 o: q- static int acnt = 512;- Q$ c! Z; V& l- ~6 D' m
- static int bcnt = 8;1 x* H0 _) ^. A! J- y' ]
- static int ccnt = 8;2 l+ j: u* G9 B5 T6 U; b' J9 w5 f2 J
- & V7 d6 d6 x8 z
- module_param(acnt, int, S_IRUGO);
2 w$ \: j; A& k) k - module_param(bcnt, int, S_IRUGO);
' z7 {! [4 Q4 _9 b# o - module_param(ccnt, int, S_IRUGO);
复制代码
" C0 l) s) u! J' y0 e
% W" |( Z! n, q5 z: G) | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( {$ c0 J( A3 Q1 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 k& D/ K/ r8 o/ k* n/ k: g, |3 s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ f1 J9 b4 E% R8 a
9 N# A; f% W+ k. I# `8 j
, h! }! ?3 D5 @8 ?% e2 x |
|