|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& F, H- R5 {, V- [code]EDMA sample test application
; }/ x6 @# D5 E0 U, Y8 o - /*% C3 V( i2 [+ Z( n) S- m6 D7 x
- * edma_test.c. z( H5 K5 e8 `$ M4 u
- *
- P: u& `. [5 l# U3 s2 s - * brief EDMA3 Test Application
" s! q* D' _2 y, n - *
: I5 i6 o1 C# }2 G/ V - * This file contains EDMA3 Test code.
5 A8 l' d2 T2 @ - *
5 e( `; v1 G9 a2 M) q+ H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# C4 W/ {9 V& K, H( c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 q* {5 m7 q( i5 }+ \
- * TO CHANGE.
( A: _$ r, M4 y4 e - *0 P' k* L+ W% L' p0 N0 \: h) [+ {- w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, v8 d- w: W6 x- G; ~ - *
6 B5 N x, v" B9 e' f, d, I6 F - * This program is free software; you can redistribute it and/or
& z" t0 a9 B ^, T( _) e9 T - * modify it under the terms of the GNU General Public License as+ H. X6 \" |) H7 `3 n; H
- * published by the Free Software Foundation version 2.
" x0 {3 T3 y8 ^( R - *
6 l) ~3 R* q- {/ e! v7 v. _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ m/ d$ k% `; C0 ]; l% b - * kind, whether express or implied; without even the implied warranty m. c) S( K! P" q% `8 C @8 Y$ e
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 i/ Q" m/ S" e
- * GNU General Public License for more details.
1 ^" _9 F. U" U# Q& V+ p - */: _6 u" E# J1 h( _2 P$ f: h
- ' ~/ v2 R4 n2 h8 w* |: F3 D
- #include <linux/module.h>
9 ]. S+ g% D) J; d% n B7 c9 A) } - #include <linux/init.h>
- U1 i% ?& q ^. W( P& S0 K* x - #include <linux/errno.h>
6 `# W; O7 b# \% [" a! _ - #include <linux/types.h>
N# H% Z/ G: k, J9 i0 [% q8 U0 G - #include <linux/interrupt.h>
3 k- T) E1 Z. e2 T* f1 E7 L - #include <asm/io.h>
, @3 ^( N1 ?) [" D$ a: Z9 a - #include <linux/moduleparam.h>
0 U6 R, c( G+ n: P' [1 j9 b - #include <linux/sysctl.h>* a1 X3 C' R' @. B" N
- #include <linux/mm.h>
6 l# {' l+ T4 P/ t) W - #include <linux/dma-mapping.h> Q {2 n9 C2 C& ?. i9 E: [, L' {
" u0 m# y" b+ w6 o1 y3 Y7 @! e- #include <mach/memory.h>
" v6 h# s7 w5 ]( j7 \ - #include <mach/hardware.h>% u" ?0 t$ d! b: e
- #include <mach/irqs.h>
" V; q+ p* c2 H4 w; R9 ?2 h! [0 ~ - #include <asm/hardware/edma.h>
+ L1 t1 C1 w+ U - O3 Y) `1 M9 O) F' b
- #undef EDMA3_DEBUG
3 O1 h* m# H; t' g0 i1 O% ~ - /*#define EDMA3_DEBUG*/
( ^3 p% o9 p% L8 G4 l2 U N - 7 q; _* X' `5 ~2 Q1 S2 K9 Q
- #ifdef EDMA3_DEBUG+ @8 M% E4 H$ W$ }5 ?% Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, Q" R8 |+ o8 T1 R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), u$ t5 L u. u, `5 g( M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 ^4 E3 }- ]# T# z6 o) y r
- #else; A; y( m$ | `
- #define DMA_PRINTK( x... )
2 X# t( W: P% Y: }0 q - #define DMA_FN_IN2 p& F2 k$ T, R4 f, ^
- #define DMA_FN_OUT; X ]4 T. I+ m: Y7 _' ?) k* J' o
- #endif' G P; B1 x' V6 s; l* N
7 z% W# |' K B' H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 N) L) S0 x: n- u, U* h$ |
- #define STATIC_SHIFT 3! [1 t7 k& P3 }& q. X% Q& D
- #define TCINTEN_SHIFT 20( |: n; ^& B+ d
- #define ITCINTEN_SHIFT 21: @- v6 b& I3 r6 O2 l3 g' w
- #define TCCHEN_SHIFT 22, L. d' O3 ~# F# L' Q9 ]& i; N0 H3 F
- #define ITCCHEN_SHIFT 233 G4 C* @. p; F# N
. ~& X" J' r; ]8 K) G1 L- static volatile int irqraised1 = 0;' R" P$ ]& n3 c6 h
- static volatile int irqraised2 = 0;+ F' r8 \. B+ R! X
- : A5 v0 P3 n; }+ n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Z1 F# P! l; m+ h1 i& ^, n" M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ C! d% H2 e- I+ ?5 q: ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% \) c0 q' B0 m2 m
, d2 `+ ~6 |2 q" u- dma_addr_t dmaphyssrc1 = 0;
m1 ]- I" s# ~! A3 ]+ Q$ L4 }, M- A - dma_addr_t dmaphyssrc2 = 0;
3 a. m- X3 g* o2 E - dma_addr_t dmaphysdest1 = 0;! m% @# k, }, b3 i" K" Z; I- ^
- dma_addr_t dmaphysdest2 = 0;
& O9 @8 K) I9 i8 l! n
8 j9 k! L& j( X2 ~1 v, Z0 s- char *dmabufsrc1 = NULL;) D" N% h' V- L
- char *dmabufsrc2 = NULL;$ L5 |, K F# s* e- |: r
- char *dmabufdest1 = NULL;
* w+ ~3 G8 D G5 c7 Q) d - char *dmabufdest2 = NULL;( Q3 ?* ^( n1 ?
% h& S: y6 ~3 S2 E% s+ W: L, {- static int acnt = 512;( B6 h U, r8 y; G
- static int bcnt = 8;
' U; e2 n) X6 w/ E - static int ccnt = 8;
1 D, z0 H9 ]# } g. T! M+ ~5 x - 8 O+ O( [2 b/ @" `* a# X
- module_param(acnt, int, S_IRUGO);
( I- T$ J& ^* x( t, x/ U - module_param(bcnt, int, S_IRUGO);% \7 T, f, d5 c
- module_param(ccnt, int, S_IRUGO);
复制代码 , T; S p; p( E2 L
5 w' i' K5 @8 D m
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" M4 s8 l( P7 l( w, ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# }8 X: n" I" M' ~% N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 P* v$ E) Q5 }6 S
' c, \2 t* Y5 @6 u+ P: s" ~& Y
|
|