|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / C% N: D3 T; t Y7 {) E
- [code]EDMA sample test application
8 Q8 }+ q# t- N5 p( I: T3 w. h - /*
& P! x" v5 S6 o% ?+ X x - * edma_test.c
& E8 i4 m R2 {# ^# [. T+ I - *8 n0 A- D' h' K* j3 @2 ^
- * brief EDMA3 Test Application& m) Y' W9 r& @" e
- *% t \' O4 s/ h
- * This file contains EDMA3 Test code.! w& G$ o4 {& f+ X- M! o) |
- *
V/ D: r; {) U# O5 ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. O! s f# o Q5 Q( s1 e( ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 q/ \, N D$ u. i* R5 S; D* O
- * TO CHANGE.
' f; u0 Q: B' L4 P$ [ - *- ~ M, j4 h7 M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 _: E3 ^% W; q: y2 y# y/ ] - *
% a) E2 n, d4 Q. C5 C - * This program is free software; you can redistribute it and/or
/ ^) L4 A5 R. ]# ]: P( a4 c& A+ R: F - * modify it under the terms of the GNU General Public License as
$ _7 B: y7 H, t" d, M' j$ C L* d5 t/ ] - * published by the Free Software Foundation version 2.
' U% t3 i# R( e - *
0 q( d# u. a0 t% F, o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 |! O) ~( Z# C9 L! S
- * kind, whether express or implied; without even the implied warranty
/ t& J7 `/ t- R1 ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 M5 H* E& @% g; Z - * GNU General Public License for more details.: U- n" A8 i! }7 f
- */6 @: F' w" K! L3 J8 E" I/ i
- - L% {- R* o G4 E4 a/ o# U& c
- #include <linux/module.h>5 J7 Q7 J: [& u& M
- #include <linux/init.h>
# T! `2 E; \0 O* f. i- M - #include <linux/errno.h># B6 M% {7 [9 E# z7 e# F6 ]
- #include <linux/types.h>
P4 g& j* T+ n5 U6 R - #include <linux/interrupt.h>
+ p: _; j- @8 r7 i3 ? - #include <asm/io.h>
- H t4 e$ o4 d2 c - #include <linux/moduleparam.h>
- b$ y8 r5 m: E - #include <linux/sysctl.h>( E3 I9 c. G. i& X% ~0 G
- #include <linux/mm.h>. j0 E C; s+ i' B9 y! a" r
- #include <linux/dma-mapping.h>! r# P! k0 {9 I6 I/ Z, j
$ u( Q3 f3 r6 F& F: ?- [7 Y, W9 v- #include <mach/memory.h>
1 r1 Z& v% ^! S1 m7 u+ a - #include <mach/hardware.h>
& w) E3 E* M1 g' Y. q9 U - #include <mach/irqs.h>
! }; O+ B: x4 _3 c" _ - #include <asm/hardware/edma.h>; H# H0 a& o+ N! c
! W0 E% i9 N) w4 a5 D. ?. J2 X9 J$ s- #undef EDMA3_DEBUG
+ z+ r: M% V' y9 h' d - /*#define EDMA3_DEBUG*/# X. z4 o, }" V( E* ^ r4 R1 \7 v
- " i: e7 R7 p7 F$ D# `; L3 S
- #ifdef EDMA3_DEBUG$ f1 ~5 o7 [" |1 w K
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ b5 \. x' q- e. e6 v2 r9 {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- I/ d2 X/ R' S2 o8 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: R9 `1 D- M: ?% @, F( l5 I - #else
" L7 e7 ]* i6 G, A! ] - #define DMA_PRINTK( x... )
$ n3 C4 n- H0 {/ c5 R) S6 M( H' H - #define DMA_FN_IN1 z! V# u& a$ H$ n% a1 R
- #define DMA_FN_OUT$ N7 O% ]! f9 o$ t! U
- #endif3 O6 s/ e& E- \$ g/ a- m$ U
- $ h4 Y2 B- E; c# w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" g a _8 I& I: z( M) B
- #define STATIC_SHIFT 31 i, B3 H. h: X! _( Y& {* w
- #define TCINTEN_SHIFT 20+ a5 {5 ^7 _$ T- B) c N
- #define ITCINTEN_SHIFT 21* `: I. a) x) H& `, w! A
- #define TCCHEN_SHIFT 221 ?7 c s/ J* [, D
- #define ITCCHEN_SHIFT 23
8 Q% R# b% ?/ ?5 P0 o1 m7 M7 K7 _ - 6 O0 J8 Z( M) ]) \" {% a
- static volatile int irqraised1 = 0;; O# b7 X8 q1 {0 ]& a2 g! x+ R V
- static volatile int irqraised2 = 0;! e& y3 N& @4 U* ^/ N' L
( R# O6 F$ \, ~' {: v) v- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 F( o) P' F0 \- p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 Y6 F# Q# y E! E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 P' Y- [$ d0 {/ M5 @7 B, J) d
- : t1 Q6 y. w/ _ {, R1 ^3 {
- dma_addr_t dmaphyssrc1 = 0;
7 s3 R6 m$ c- r7 [% K* O l - dma_addr_t dmaphyssrc2 = 0;
G/ C; r2 r7 X# h( y) }, P9 P - dma_addr_t dmaphysdest1 = 0;
8 s; |: \/ d0 }5 t: J( N3 c - dma_addr_t dmaphysdest2 = 0;
3 ?/ t' C2 Z! g* s; d' }$ } - 3 X) y& U. ~" J( w
- char *dmabufsrc1 = NULL;! r9 |7 U9 r$ u! A9 J; g* z
- char *dmabufsrc2 = NULL;
4 T# a% F3 {/ W8 [& d% | - char *dmabufdest1 = NULL;' E/ `; r$ ?; ?; e
- char *dmabufdest2 = NULL;& e& u/ l' E( p" i: r
0 g# i' E, x! \9 T5 N) i$ p1 ]% m- static int acnt = 512;
/ J* F) C; F: N& Z( J' G/ v9 G - static int bcnt = 8;% `$ V2 ^$ E/ t1 ^8 G1 b
- static int ccnt = 8;) R( f" V+ Q: _
- ' f$ A. d' F; E0 |4 `' u
- module_param(acnt, int, S_IRUGO);
5 d2 ^; t! m, G( W. r$ b3 I( c - module_param(bcnt, int, S_IRUGO);
: A {. c! x2 m% k' H - module_param(ccnt, int, S_IRUGO);
复制代码 : Y$ v" J/ R7 D6 C! U
~5 B& G/ M; B( ^' c% p E, i. `# U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- a8 t- m- `; ^* O. }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' m7 t/ o1 @1 s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 T( F7 _0 P1 a
: S( O. }, |+ R& p( ^- l- {! ?! V% @3 e) ~3 i7 |) r; E( Q, f
|
|