|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& |: ^! d' V( n! c- [code]EDMA sample test application
3 X& G3 \; _+ z( O. a - /*
( o/ [! Z& Z& i" I: h% C - * edma_test.c
: G/ Q4 F0 ~6 a$ `" y& ] - *5 c1 K2 `+ Q8 j2 q; g2 p, V/ D8 b$ y
- * brief EDMA3 Test Application
1 i3 {- M/ N D! i6 f J' K - *8 y" U/ h6 j% ~$ S {1 R5 F
- * This file contains EDMA3 Test code.) [* W. u( b! h& `
- *. X, p/ I& {/ \# {. B) r9 ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 w/ F; h% T; x, n c! l6 @* Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& I1 {8 X3 F& K+ ^; H
- * TO CHANGE.( Q1 I* m4 q! G9 q( f
- *% O( r; M- a' n* j* m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( H k+ x. f4 r/ o - *
2 o1 e% E3 a. x; x: C( f- { - * This program is free software; you can redistribute it and/or6 C$ k7 E: l! D, m- p% `
- * modify it under the terms of the GNU General Public License as
$ K5 X5 f2 U/ l1 o - * published by the Free Software Foundation version 2.
1 @- O3 X$ }( w7 [* L M - *8 s% u5 e- `2 K6 s2 o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any% }; {+ p) s; i' ~7 u$ c
- * kind, whether express or implied; without even the implied warranty
# l, _. D( E! i. I+ B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 k. P* Q9 ~& e9 d. e( _
- * GNU General Public License for more details.
3 }8 j4 c# x' s5 l, H6 Z9 ]3 W" A - */
0 p b( [: E; `5 R
& |1 ^4 } F5 Y$ n8 h) D6 [' t- #include <linux/module.h>/ T) Q! B3 B' T4 E0 `
- #include <linux/init.h>
% i9 S9 b9 s& `+ a; ]8 ?% ~ - #include <linux/errno.h># M0 q( P; l1 `, m& N) n& u: }
- #include <linux/types.h>
# h: k$ ]- z: l+ E6 B% X1 E& \ - #include <linux/interrupt.h>
+ o# e* S1 y2 Y( N! \ - #include <asm/io.h>9 m+ I' \9 q: C- O( m: y
- #include <linux/moduleparam.h>
$ S7 Q2 D) ^2 d1 }7 B: U/ V - #include <linux/sysctl.h>9 h, U( N) z- i# H+ |
- #include <linux/mm.h>
8 m5 P5 C: d% Y( G1 Q - #include <linux/dma-mapping.h>
/ ~8 Z; p' k& {5 o" [7 z! w - " \: j+ m) U* S* [; U: J7 d
- #include <mach/memory.h>
5 o3 u. m3 X3 x4 D1 A9 m; A) y - #include <mach/hardware.h>5 b7 m5 j/ n1 C! S8 @1 c
- #include <mach/irqs.h>
5 B, [# E4 I% a2 u. N1 f1 L - #include <asm/hardware/edma.h>+ v0 o0 h% E. C, v
- 3 f* ~, \; N' F2 R
- #undef EDMA3_DEBUG
9 _$ G5 |0 ?2 a1 u% a; M - /*#define EDMA3_DEBUG*/+ |; @" C0 w- O, H4 d4 n
- , `/ M+ J( C$ W2 E" S
- #ifdef EDMA3_DEBUG
& o. S$ n& J( n0 `$ X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 b8 O) M& r, [- {2 A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- z6 c4 G7 o9 F4 F" ?# P* @2 a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" @* k% S- W5 J- v; G - #else! j- D5 A; _# M4 ~
- #define DMA_PRINTK( x... )" c6 m$ x+ s8 \' _' B3 P9 R
- #define DMA_FN_IN1 `( q5 B. H- R- O" d
- #define DMA_FN_OUT5 k C7 |6 V9 `3 U$ B7 n) f$ q ?4 U
- #endif
1 ]8 ~6 L$ y4 m: C& u: B9 G - 9 z. l; [5 x" d4 h* q- f H( c6 v1 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" L( G$ {5 Q) S
- #define STATIC_SHIFT 3
- j% c2 i& n; Y8 | i - #define TCINTEN_SHIFT 200 x4 n# K2 S7 e; I/ T1 P
- #define ITCINTEN_SHIFT 212 e# P9 M& D2 v& a
- #define TCCHEN_SHIFT 22' N$ Q, \" |8 C
- #define ITCCHEN_SHIFT 23
. H. y6 ?3 v: r- k9 F1 I- v - ; |. r6 U. e( E4 E% u8 Z2 w9 C
- static volatile int irqraised1 = 0;
) d' E8 c! a4 P8 J$ j - static volatile int irqraised2 = 0;
3 t5 D# j* D: w* `4 d& q - * ?+ h, ] S- g" l# G- b+ l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: a `: t' y$ S8 {! f5 R - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); Y+ \1 M* h8 i+ W# n! J4 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: F8 V) r' w/ q
- 1 ]0 {3 j1 B* N* p( I4 w3 f- D3 O) u
- dma_addr_t dmaphyssrc1 = 0;
* {: C. ^ H( P Q$ ?* U - dma_addr_t dmaphyssrc2 = 0;7 C: P3 c+ {) o! S
- dma_addr_t dmaphysdest1 = 0;
: X# V* C; F8 z. ] - dma_addr_t dmaphysdest2 = 0;
: t$ C! D d' d1 n+ l
3 _: y4 J3 Y( ^. T- char *dmabufsrc1 = NULL;
0 s+ ^' D; T# B6 k' u - char *dmabufsrc2 = NULL;
6 y1 Z$ b. s3 M0 u6 l$ e& }; A - char *dmabufdest1 = NULL;
* I5 ^* m3 q' g# p - char *dmabufdest2 = NULL;/ H, e+ @! @( v! ]. y* S+ s% o8 @
% C6 H. k4 n- y6 [0 Y& g/ y- static int acnt = 512;& R7 i; N8 c! x; y
- static int bcnt = 8;/ \0 Z8 s$ I" c- H* `
- static int ccnt = 8;! @, ?& C3 q* Y8 ^
- 5 ~8 U- n f3 C1 Z" Q3 @% Z
- module_param(acnt, int, S_IRUGO);
5 v5 { y4 n0 F' l: U# c - module_param(bcnt, int, S_IRUGO);
2 K5 g5 a- U2 G+ \: p8 Y) @ - module_param(ccnt, int, S_IRUGO);
复制代码 % H7 s \" E) M# W, h3 W% p1 \
& q4 C2 H7 C! M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 I# ]5 t3 e/ yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 o1 O' A. M- {- @ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; v4 n4 g6 V7 G' q& w \; j
" d/ M" k8 u1 b% k6 m7 Q( Q2 ]4 G5 _
( [$ ^( u) D: s |
|