|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' k) c/ R3 D% ]2 Y- [code]EDMA sample test application
2 j- |* X0 H; r* k - /*
6 P* ~/ K) q" b1 M2 h$ s5 I - * edma_test.c
. X$ [$ X( j7 d. P7 {9 ?( A" s. K# | - ** |$ A9 S- d& r+ P& B
- * brief EDMA3 Test Application4 H6 ?8 B% n8 H! b& s6 F' Z0 F: W
- *' Q/ i5 H1 f8 c2 h! u$ ?+ h
- * This file contains EDMA3 Test code.3 e+ x% m- ^6 y9 E& q. u% N4 i
- *
+ v' B8 y, ^9 w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 ^$ K3 [: ^. w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. R1 e5 y* j2 v - * TO CHANGE.. p/ L5 Q! f: n
- *
. b4 j3 x! J* S7 L$ m1 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( q- s) u5 B( z+ n9 y - *
, }2 u2 S' o6 P1 Y - * This program is free software; you can redistribute it and/or
: _6 E/ q4 y5 w o! U - * modify it under the terms of the GNU General Public License as
) e1 Q. D; ~. c$ R# Z3 ]: B - * published by the Free Software Foundation version 2.) R) J$ H; O$ u
- *2 \" p* T+ |- w% ?" u @+ g$ }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, a. I4 `9 M1 v( [
- * kind, whether express or implied; without even the implied warranty: ]# n9 H5 u# R ]& C; U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* G( w+ n' H: Y8 S. u2 o6 f9 i) b - * GNU General Public License for more details.; l9 g: a4 x$ v- z0 Y9 _& D- `
- */
! ~) T, a ^2 V* h) k& b - # f- u$ j! T3 `$ |4 \
- #include <linux/module.h>
* I% ?* {6 B4 A; {- r - #include <linux/init.h> N$ K; Y6 {4 |# Y8 f
- #include <linux/errno.h>
4 H0 Z" C# }- X( j0 R% f9 g5 J - #include <linux/types.h>
4 T- q- a; U7 n9 V: a% L# L - #include <linux/interrupt.h>
. e8 ~* v* q9 r( i5 c+ v* X - #include <asm/io.h>) ~) J5 k2 C3 W0 B$ r! f4 p. o k
- #include <linux/moduleparam.h>% b/ j$ a( \0 y4 h ^7 F
- #include <linux/sysctl.h>" s% C0 f4 W1 h5 u8 A( w
- #include <linux/mm.h>4 P& `- T! L0 W* O; N- F8 R5 {
- #include <linux/dma-mapping.h>( } h: Q% q9 f* M5 m% g8 {/ ~
7 u2 @" m5 Q& k5 i- #include <mach/memory.h>7 V& D0 O9 M9 S# i: ~
- #include <mach/hardware.h>
' Z+ m/ i3 |8 ~3 N - #include <mach/irqs.h>
x# o4 m* B6 Z. d3 c+ I - #include <asm/hardware/edma.h>: K# [2 T5 ]6 g9 S- y
! b+ `7 f2 [$ O5 J! s# m- #undef EDMA3_DEBUG
' C, O% ]2 P* n' R4 Q2 ` - /*#define EDMA3_DEBUG*/1 k& h3 L S8 N% U+ ^
- ]5 |/ y+ H) b& Y/ q- #ifdef EDMA3_DEBUG
$ M$ I& L+ c) {0 c' ? - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- ?1 h y) |+ T( a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 ?( v6 c# P* ]' v
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ R* L9 D# [8 M0 l
- #else
3 b3 c, }- G% Q - #define DMA_PRINTK( x... )
* ]. C8 }( b. Y4 g - #define DMA_FN_IN
w' l% y; v9 @ - #define DMA_FN_OUT3 I& ^ k# t$ j$ Y$ x+ }- V
- #endif8 {; H, J) o+ N. E& B l) T
- ' {. q4 U+ o) X5 Y) H) P1 F$ L4 x1 V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# e8 d& d$ v" p9 C) o; B
- #define STATIC_SHIFT 3
6 L# L6 m. H( v6 `& @; f - #define TCINTEN_SHIFT 203 t8 |$ U* z7 S1 n
- #define ITCINTEN_SHIFT 21
" R- x: ?1 b, U. a3 m5 t! h$ \ - #define TCCHEN_SHIFT 22
: ~7 U* N( f) R/ q. ^ - #define ITCCHEN_SHIFT 23+ a! i+ u K, T1 O2 m
- " R" ~1 n) l: J: o
- static volatile int irqraised1 = 0;
: P8 w5 a7 p) z. u9 m$ q p - static volatile int irqraised2 = 0;3 s" ]! t+ p$ s; K
- 3 D; k: O- k" @% o2 m4 y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ E/ j+ z! Z& `' ]- y- ^" b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, M5 O" Q8 g9 B. J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% i3 k: ]* g. D& l! H
/ g% v5 r; Q0 C- dma_addr_t dmaphyssrc1 = 0;
% k1 I V6 M- T1 q5 s$ g - dma_addr_t dmaphyssrc2 = 0;
* V. k! x5 {8 F" ?1 z - dma_addr_t dmaphysdest1 = 0;: M- V* Q) ~0 y2 R
- dma_addr_t dmaphysdest2 = 0;: q2 U$ m# C9 i4 z, M: k0 f7 \$ T: s
- " F3 |5 G' y9 g1 X w
- char *dmabufsrc1 = NULL;
& p% X8 Z5 Z4 j: f' N/ D - char *dmabufsrc2 = NULL;+ L5 |5 U1 }5 |$ c' ]6 x( ?
- char *dmabufdest1 = NULL;
8 o1 ?' r. _% ]3 p9 O$ m5 [ - char *dmabufdest2 = NULL;
9 @/ U5 `; p6 F0 r9 `
1 P7 @& X N3 ^. i- static int acnt = 512;- e8 b8 N1 g% g) `$ \
- static int bcnt = 8;
' S t0 i/ O5 F1 Q0 ] - static int ccnt = 8;, i+ o3 D4 F3 j- d! V( t
0 p' Z) p' O7 \ Z; N3 |- module_param(acnt, int, S_IRUGO);
" Y/ u2 q1 a6 a( d- q; p, N - module_param(bcnt, int, S_IRUGO);9 p3 j1 I2 |$ e4 l8 O
- module_param(ccnt, int, S_IRUGO);
复制代码 4 E- Y9 r/ B6 J( d: k/ X' ]
3 f F% r+ {& w& H" Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ n' w8 `4 Q7 ^. 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 L/ a3 `+ J) X7 y! C1 `6 y1 z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 c R5 m6 a; d! w4 D
8 D* u6 O9 T: C: d" N. L$ }& S. ]$ G2 u4 S1 a( k
|
|