|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: f4 A/ m6 e. f$ f$ y- [code]EDMA sample test application
6 t( ^, g ?. h - /*
( E! d3 J& W e - * edma_test.c
# c. u" S* J# X3 F% v; v - *! L6 E' }/ O% X4 O9 C+ N! k' n+ l. \" K
- * brief EDMA3 Test Application. n: @( O O1 f, u* Z
- *
3 c5 R% S8 R) y - * This file contains EDMA3 Test code.% p) L. x* r0 g0 p; Y' G- t: q I
- *3 E! N, _& D- ^ I6 d, U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 {9 `3 N [7 O! L' X( t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 | N% E3 S' s8 [; V+ e% } - * TO CHANGE.& W2 O( _ U/ G* R) X: [
- *
/ r* r# z* e; A1 W- x0 v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ {# e* T9 r# Q( o - *
6 i6 o2 [6 ]- ?! g# I# U7 u - * This program is free software; you can redistribute it and/or
) Y/ s0 |/ f" {' @- C" U. i - * modify it under the terms of the GNU General Public License as7 M" n7 y( K: e! w- V) b
- * published by the Free Software Foundation version 2./ t# a ?# ]' v, |$ v1 k
- *
$ \ h; Q8 `0 b6 [ }2 y g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" }6 z/ Q7 I! S, Q1 M. |6 ^
- * kind, whether express or implied; without even the implied warranty
0 d8 c. V/ r7 L8 Z6 L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the a# A6 @# q$ M2 G
- * GNU General Public License for more details.
4 \1 p1 h% ]3 d4 x% Z% S* W - */
, W2 p$ R: U2 e
5 U% B8 G5 b) X$ b9 u$ F- #include <linux/module.h>
! W+ O, q0 h4 @' l. s - #include <linux/init.h>( O o1 L) G Q% t
- #include <linux/errno.h>
( F5 I( q% C: g8 K A/ T - #include <linux/types.h>* G' r% X" I+ H
- #include <linux/interrupt.h>
' r4 N# I: f$ V% k1 w2 _ - #include <asm/io.h>$ x9 o. U/ f6 I* r* g
- #include <linux/moduleparam.h>
: ^# k4 w0 Y* l* l6 J9 P - #include <linux/sysctl.h>( ?+ [' n2 l. J/ {" \ Z& ~
- #include <linux/mm.h>
' }7 t% j; B" W- z8 O) C" j - #include <linux/dma-mapping.h>
, }* \4 A8 D* E' U6 m- O) U - $ e, ^/ Q7 [) I4 B
- #include <mach/memory.h>7 K4 O$ s2 k; C2 V0 h4 A
- #include <mach/hardware.h>3 x) Q9 n1 U% k; D7 l% I/ f
- #include <mach/irqs.h>& q. X. W' W2 t8 e7 {
- #include <asm/hardware/edma.h>
5 `$ R" V6 j5 \- ?* {
* M( G- O' U: {2 g1 @( |( @; e- #undef EDMA3_DEBUG
8 ?3 x. Z' v, j' o8 [7 O - /*#define EDMA3_DEBUG*/
- l0 L$ D& L7 V7 H - 9 r1 r( H: Z4 b% s. M
- #ifdef EDMA3_DEBUG
1 ~3 C* l: O$ o% U4 ]; | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% h( \# C0 K5 W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) A/ C( D$ ~" b2 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) @! e6 r4 ^6 p% K0 C3 v7 Y/ q9 Q& E
- #else$ s+ f- p* j% Y- E$ |, P
- #define DMA_PRINTK( x... )7 u3 p/ P c7 w) U" @8 x
- #define DMA_FN_IN& |# d2 b f& j3 b6 ^" @
- #define DMA_FN_OUT6 H5 Y6 n4 J) T7 t& K1 c( o; c8 ?: {
- #endif2 U$ T, H: w m& c1 n- T5 G# J
- 5 {7 b; o/ |+ I' K' W+ K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. X$ b9 o0 `2 n) c, m2 S4 c - #define STATIC_SHIFT 33 e$ R. o: w2 w" ~. Q
- #define TCINTEN_SHIFT 20
s0 x' ?6 a4 g8 ] - #define ITCINTEN_SHIFT 212 ^, I S3 e# J# E* r; q& ]& ~) m
- #define TCCHEN_SHIFT 22
W- Z/ r- |/ H/ T5 ~ - #define ITCCHEN_SHIFT 23; `) U+ n3 D4 Q3 {0 b+ c
- - W0 R& r9 `7 |9 f( w5 Q
- static volatile int irqraised1 = 0;
: R8 I6 P/ V b - static volatile int irqraised2 = 0;
& _$ a0 H# g5 H ]
! p/ w; x9 F; W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* ], J; S( k' d( i' W - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); p! b/ _% j) O' a( i! c- y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 |7 h3 j1 k# W& y - . @: w' [+ ~( k5 J
- dma_addr_t dmaphyssrc1 = 0;
6 J$ H! E- g0 J3 h - dma_addr_t dmaphyssrc2 = 0;
* l, k ^$ D! ] - dma_addr_t dmaphysdest1 = 0;( G2 B/ c- k( @# |% g8 @2 X. h" m, ?
- dma_addr_t dmaphysdest2 = 0;/ y0 R& ]0 T/ a) Y h+ Q. {- |' v
1 z- M1 `1 `- U I2 C% |- char *dmabufsrc1 = NULL;
6 c+ @* w5 b" a- Y, y( q5 T, b - char *dmabufsrc2 = NULL;' k. ?9 l5 D/ X
- char *dmabufdest1 = NULL;# [6 u& T2 Q" A0 N) {" ?1 e$ ], O
- char *dmabufdest2 = NULL;" D- c. X/ r4 t) | P8 f! G$ P
3 H- |4 a- D& K6 p/ O- static int acnt = 512;; L* D5 [: p; J0 ?7 j: |/ N
- static int bcnt = 8;+ ~0 n# T) ~9 H( N1 n, L3 w- V
- static int ccnt = 8;
- g. a4 G3 F- l2 b6 y - - I/ F0 l9 V- }: K7 f: P v
- module_param(acnt, int, S_IRUGO);
. B; ]# y7 a8 V( V$ w - module_param(bcnt, int, S_IRUGO);5 ~; s$ P6 Q. y6 l/ W! C: H
- module_param(ccnt, int, S_IRUGO);
复制代码
- O1 r$ W z, M- i
9 U: h4 |3 `9 z3 a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% h9 x- y4 j! ~5 R6 karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' _4 f5 ? C# j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 G+ k0 V& y+ h; Z# F! c
) m3 A, P! ?+ |9 P2 B4 Z |0 F1 p6 ^
|
|