|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# [' \! Z: y" s: Z' n- [code]EDMA sample test application
- x+ F& P3 d3 P - /*' {- @( h( }* t! G( m% t. N6 S; j1 C
- * edma_test.c
+ R( t7 p$ }- w6 Q - *
6 S7 e2 }! q! a. J# K9 w/ A - * brief EDMA3 Test Application
/ a8 m- v* u) n3 R& v8 j - *0 y9 y: ^; H" m& Y4 Q! L: ~# L
- * This file contains EDMA3 Test code.
7 k* w, A: x# [2 l, Q/ t# R; ]/ W - *+ c( ^: G; e% H9 O$ M6 v2 @
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! c' y6 {7 c0 U6 e) F! N& Z7 {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& u8 \6 T1 J1 e" e5 R4 E - * TO CHANGE.
1 [/ X( k4 k# s - *
% L) u- N/ K: K+ M/ X o9 O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, x" x) D& |( X7 s
- *
, O: b" L4 r! g5 X5 m - * This program is free software; you can redistribute it and/or
2 I9 N/ Y- ^* P0 Z- Q3 z& g - * modify it under the terms of the GNU General Public License as
* N$ T: v% O) l+ g9 I9 n4 i - * published by the Free Software Foundation version 2.7 I$ n7 l) K. f
- *. `+ L: h* z6 n1 p# y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: |/ l2 z- k8 K - * kind, whether express or implied; without even the implied warranty
/ U$ Q( Q/ W8 G! G9 z+ s& ` - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) g; k- N- f; o& q$ D# L6 N - * GNU General Public License for more details.6 Z& f: u% g7 D, [
- */' q3 C& v3 ?- `8 ^& F
- 8 K" v1 N4 M5 j
- #include <linux/module.h>2 m& x6 q0 j7 [: z* |2 z
- #include <linux/init.h>, A$ t- I" K( C- G
- #include <linux/errno.h>3 | H; X% v* @! ]. A% @/ }) w
- #include <linux/types.h>
$ n/ @- ]7 v! n5 p - #include <linux/interrupt.h>
1 J, [4 G5 w1 ?- f8 v - #include <asm/io.h>+ i! R4 P7 C Y3 w+ W6 B
- #include <linux/moduleparam.h>- ]6 E5 y- @# w3 O/ H0 q* X
- #include <linux/sysctl.h>! v, {8 g- N. H" R; Y; Y5 U! s
- #include <linux/mm.h>
- s$ {& x% Z Y! y$ L# t+ S - #include <linux/dma-mapping.h>
7 J8 Q& t! d" |( F0 L8 m) r - 4 B' d4 o- r" m, _- E
- #include <mach/memory.h>
; {1 O1 R" C3 \1 X9 X i5 v - #include <mach/hardware.h>8 v# E: @: P' {& a5 o0 N9 I$ u7 N. z
- #include <mach/irqs.h>5 T" T' L8 g7 W9 V
- #include <asm/hardware/edma.h>
- |# g. r7 V$ K3 A - - K, j/ X6 P) o A1 t' I, P
- #undef EDMA3_DEBUG
! R8 s8 @; c9 A: p% v# y; N# B9 T - /*#define EDMA3_DEBUG*/7 l2 r }6 S' x% o' U2 _
- " _# F( v; g4 B0 |9 H) w- V& D8 }; ?
- #ifdef EDMA3_DEBUG, E( p; |: W0 E: ]5 o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). R, N5 j2 E- R: x: @! r3 ~& [; R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ o5 a/ L4 q6 D, a; u7 V4 \% R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 p+ M `% q3 |0 G( ^1 o" S - #else
, Y* E+ ?* l, k2 n$ E. @) q" @3 P% P - #define DMA_PRINTK( x... ); ?2 O& W$ z" |4 P7 |
- #define DMA_FN_IN
: a& X, ~1 E9 J' f4 ^ - #define DMA_FN_OUT
% f; e. V8 k0 L2 R( g) D+ T - #endif Z% P8 w3 g9 @" _( |6 G! {5 v
! e. F4 h& j: k x! ^: }$ U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- y K ^8 L' [$ [8 l- R
- #define STATIC_SHIFT 3. ~$ E' F, ]4 M) }
- #define TCINTEN_SHIFT 20
* `+ ] V5 ^$ O( G( H, ~/ U. X - #define ITCINTEN_SHIFT 21
% Y K* F! ]" [ - #define TCCHEN_SHIFT 22( B! Z0 a; t/ ]+ [
- #define ITCCHEN_SHIFT 23
- o! @, y. |0 T* I1 s* _7 J - ! V, ]4 x( m8 R i/ _
- static volatile int irqraised1 = 0;
8 X6 O( ]2 ^" m# \7 q# N - static volatile int irqraised2 = 0;" A) G- R, [: ^9 y$ b8 n% g9 m
- # ?4 F* M- c2 u; m } l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& P+ w, B3 j n; H% j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; }1 m$ e* s2 i/ K: u/ \1 S0 S0 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) r2 |8 W: A" Y0 {9 _& C" ~
7 d$ R& q& l0 X- dma_addr_t dmaphyssrc1 = 0;& ]7 ^2 j: n- b$ {: m2 i
- dma_addr_t dmaphyssrc2 = 0;& \, c1 J3 T1 @5 Z* n! D- l
- dma_addr_t dmaphysdest1 = 0;
* a) u6 g% L, v3 w* s, O - dma_addr_t dmaphysdest2 = 0;
# }7 Z, u& a2 c9 D
4 ]9 W2 e: M H- char *dmabufsrc1 = NULL;
! U+ \1 ?! p# e - char *dmabufsrc2 = NULL;
8 A6 G" W7 t* `: ? A. ~. L - char *dmabufdest1 = NULL;; b4 s# |' x$ D( K/ j
- char *dmabufdest2 = NULL;
/ E& T2 D; O! g) `- Y3 A - : J1 c5 n. b8 |) B; i# y/ K
- static int acnt = 512;% \- P* \0 h- ^; x* Q/ Y8 F% y# C" R
- static int bcnt = 8;
6 ?" H J: M" O9 n" K - static int ccnt = 8;( |, D% G% y4 B4 l/ X
& {: g: F& x* p. l9 n' V p" L$ N- module_param(acnt, int, S_IRUGO);5 J R% |! l v# ~ o9 _: R# x
- module_param(bcnt, int, S_IRUGO);0 B0 x: D! J; t; [
- module_param(ccnt, int, S_IRUGO);
复制代码
+ {/ n: m: ~( C2 ?' e3 I# x- o1 t- I, K& _2 P1 D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ l" S0 _2 w' @! X, Larm-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 Q7 c C( Z; N: R, o
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ~$ U2 E4 Z; R; F6 k$ @: _
: A: o) \ S, a$ X0 L
8 r1 \" U0 q. ]' k
|
|