|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 P* R( O0 \- }1 s5 @* \, q/ X( V4 b! q- [code]EDMA sample test application
+ [$ U" ` W2 }9 I; f - /*
1 X/ `4 b# i; K: c$ f& _ - * edma_test.c
8 l+ p! ~2 l- P- E9 W" A! h - *
K' Y% I& W2 _7 ? - * brief EDMA3 Test Application
5 b5 ~, Y& }% }3 G' V, U - *# @, e0 o4 m8 J/ E/ u$ Z# I" o
- * This file contains EDMA3 Test code.
6 H) Q+ g- a- \* ]7 A - */ n |$ r3 U0 L+ O) V# b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* D$ U7 [; ~) U4 s1 z7 | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( c+ u5 F1 H7 R3 d$ V% B0 W
- * TO CHANGE.% K/ t8 X9 }, ^0 v6 u1 f" ^
- *
! B' V1 z" ^+ C0 }3 T$ ?4 u' d) E5 h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: T1 A' f L7 h, \! N - *
# \, u1 I5 v D# M h2 j - * This program is free software; you can redistribute it and/or
+ S2 ?# d- H4 I' d - * modify it under the terms of the GNU General Public License as
; D, S1 @$ P% T0 A- q - * published by the Free Software Foundation version 2.
+ J7 q0 i# c% o. n8 v1 F- ^' j6 C - *
! U. l' b4 n6 H, y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 \% i7 Q' @) G6 j6 P
- * kind, whether express or implied; without even the implied warranty7 @, \! R% y! b% s% ~' j& {* R' L' L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; y5 e& W: R5 F1 f ~6 K4 i - * GNU General Public License for more details.7 |6 G% I5 n7 }! [' k
- */) |1 Y# P: b" f8 O( g/ m
- & F3 Y& |/ @- i% M) {
- #include <linux/module.h>
# [! \3 S: N8 z - #include <linux/init.h>
: T' m! N$ H/ E4 P$ @ - #include <linux/errno.h>
) U0 f6 S& I' q1 b7 ]7 o( A - #include <linux/types.h>( z" O, Z. y/ z& M$ T8 h
- #include <linux/interrupt.h>% B/ P) ~) x/ g1 W
- #include <asm/io.h>! R- A% n* t) [# A# M5 s
- #include <linux/moduleparam.h>
& e' V* ]$ B( h$ D7 O% A8 i - #include <linux/sysctl.h>% H7 H; M" K# O
- #include <linux/mm.h>
% O- W% s4 r# o' E - #include <linux/dma-mapping.h>, D9 J6 @5 o$ g8 ]6 p! t0 p
$ k# C; @% V3 ]& C- #include <mach/memory.h>
2 K! A1 |& k) d5 x0 o - #include <mach/hardware.h>5 M2 x3 f2 \* T# @5 {. H
- #include <mach/irqs.h>
$ z3 f! a; K0 c' W" h$ {2 k1 ? - #include <asm/hardware/edma.h>) S4 {2 F* e* u/ P6 s1 e
- * C; N( {$ n5 ]9 K" `) |5 Q& L
- #undef EDMA3_DEBUG$ Y# Z1 _! r0 T6 u) r, Z5 a2 {
- /*#define EDMA3_DEBUG*/' ^4 T4 L2 W0 ~1 C& Y0 \7 `4 e
- ( y- X. |5 R% ~' [+ L' k
- #ifdef EDMA3_DEBUG7 W; C. Y! L+ K$ N4 Q) G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 p5 q3 H4 {0 u# \; F9 @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 N& b4 D5 m7 E: E9 r, { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 }3 a1 [8 h- C I1 |2 G - #else& Z& ?' I" ^0 i( ~9 I' |7 q/ m& I
- #define DMA_PRINTK( x... )
^6 r0 ^6 Y( v) G* R - #define DMA_FN_IN- G% c& r' U( G h. \4 _1 a
- #define DMA_FN_OUT% m ^9 X, \0 {# s: W4 e
- #endif. h1 Q% ^9 S$ [ b6 @ _
4 F0 f6 r u& c! y4 V& V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' W* t% S- f( F. T
- #define STATIC_SHIFT 36 L& ^9 ^$ R) W7 \/ A# m
- #define TCINTEN_SHIFT 20! s3 G. c# f& d1 X2 K
- #define ITCINTEN_SHIFT 21- Z$ V/ ^" A5 R( ~. X/ s8 n/ o3 P
- #define TCCHEN_SHIFT 22$ y) V" a7 l2 k0 V+ o c
- #define ITCCHEN_SHIFT 23
7 Y2 s" s' u, V/ J. w+ X0 l' ? - - P% a# m/ n9 k# v: z, F- ]6 n, c
- static volatile int irqraised1 = 0;8 E2 `- J9 l' M
- static volatile int irqraised2 = 0;
/ Q; A6 w0 d9 h5 J5 E* W
- w# L! q; p2 C1 s4 M7 ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! M3 P! g5 n+ H3 U7 @) R
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 W' B7 }! \; ^! u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% T' b2 s" u" z' @+ c - # V4 N5 N) ^; Y# a
- dma_addr_t dmaphyssrc1 = 0;" W# ~* c( |1 _( |
- dma_addr_t dmaphyssrc2 = 0;
& ~! Z, `2 X8 ~6 r4 x, _$ j - dma_addr_t dmaphysdest1 = 0;
j5 @( I. k3 V+ U - dma_addr_t dmaphysdest2 = 0;1 T, u* {+ l8 V0 G' _
- % P s. K- ]* [5 \/ y- |
- char *dmabufsrc1 = NULL;
$ b$ Y. L! c1 L7 n- A - char *dmabufsrc2 = NULL;+ O6 m: K# e( u, i/ B r7 Y
- char *dmabufdest1 = NULL;
! b2 W/ `9 R1 m) u+ A7 d7 j - char *dmabufdest2 = NULL;( d5 h+ u/ }$ L5 e
; Y$ Q4 g* e# w- b: B- static int acnt = 512;
[( h& p0 L. S+ c( x: y - static int bcnt = 8;
2 C5 ^( ]6 c+ y, x+ y+ I6 f - static int ccnt = 8;' l+ k/ M, N1 X4 K* T; E
: l- c7 L- B* @* }' O. x- module_param(acnt, int, S_IRUGO);
' i! h2 E6 w2 l7 b - module_param(bcnt, int, S_IRUGO);3 `8 ~- Z2 ^& V& O
- module_param(ccnt, int, S_IRUGO);
复制代码
, E+ y ~/ l7 W+ r! U, z, G7 S% E: O! ~2 p; w" f, B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: M8 K M2 h @+ H$ V1 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" e6 J4 U; [+ E7 C, V6 h; |& \& ?" q4 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; D4 f0 q# B3 J6 H f5 W5 }2 Z
6 m9 p4 |3 Y$ V" O9 m5 @6 Y7 J' a7 X: I
|
|