|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 |: ^) Z4 W4 P8 A/ b; _7 f3 P- [code]EDMA sample test application
$ |' a% H3 [. | - /* q& s9 M! _3 T+ s0 Y6 B
- * edma_test.c
# G# o8 d P/ I! n* M t - *
" a. r$ V9 r, `2 u7 Y2 O - * brief EDMA3 Test Application
: x. s6 Q* H: y6 ^0 @" J/ s - *
* X$ \, _' d6 I0 O' q) J% C- T6 ~ - * This file contains EDMA3 Test code.
* r! S1 U: T( a/ b1 R- }) t, W# Y4 W9 R - */ B* B) H; b4 K( ]8 S( Y" R+ W) v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) H/ o4 H' r$ M5 E% M) f2 Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT t6 r! F% c) I h' J- m+ f
- * TO CHANGE.
$ L# ^2 Y5 B7 f x - *' i! ]. l* j3 a3 h9 ^. `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* c' m# P, \; d- c - *
8 l4 J% O+ g5 T$ |& x+ U7 O2 R - * This program is free software; you can redistribute it and/or
* b0 P7 o7 x* P6 x l- ?) C) _ - * modify it under the terms of the GNU General Public License as9 P& W8 I+ ~# b, @" |! F, M# r
- * published by the Free Software Foundation version 2.1 E J! `1 ` o0 ?* ?; P' C( Q
- *
3 r1 u0 d2 m6 _3 |% H- \ B# Q& E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) o% [! d5 \, N$ Q: Z - * kind, whether express or implied; without even the implied warranty
* w( i% _1 b0 G, B: m' m9 I. R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( P& M" l. S" n: o) d% R! b& Q - * GNU General Public License for more details.
/ J2 \6 z0 i0 d1 j* Z% V - */
4 B) v* a1 p6 W! q R: e; n
5 c+ Z# e9 Z& Q8 S) F& e- #include <linux/module.h>: F% P- K/ y$ d1 P
- #include <linux/init.h>) ?+ U5 ]$ D# m8 H( f' l& G
- #include <linux/errno.h>+ f. r7 @# [. J
- #include <linux/types.h>3 { M, `) T0 `) L4 B+ r) U
- #include <linux/interrupt.h>
- }1 G4 |; B) ? W" ~ - #include <asm/io.h>
4 ~8 }* P! R1 [5 `9 r* `6 p' w - #include <linux/moduleparam.h>
. Q( }% J; ]* v- y - #include <linux/sysctl.h>
; H6 H9 H) S, b# x3 @ - #include <linux/mm.h>
( }' d9 J$ O) b, F" |% m5 J4 b - #include <linux/dma-mapping.h>% y3 n5 E$ O" \0 T: P @. B
- ( F7 P( U5 g( W
- #include <mach/memory.h>) G# p' s5 K0 c1 k, D
- #include <mach/hardware.h>
6 n& a0 k1 G$ F+ ?4 O9 n) b& e% @# ? - #include <mach/irqs.h>5 I7 P6 R, x0 y+ l1 n* p3 D
- #include <asm/hardware/edma.h>
' `! O8 y2 g1 y, Y
F I) ?- }. F1 q; C5 Y+ j- #undef EDMA3_DEBUG
5 p3 G6 e, |/ G f - /*#define EDMA3_DEBUG*/. n7 i* |4 B* j4 a1 G
9 k( g; K: J$ ]+ N/ W% ~- #ifdef EDMA3_DEBUG
$ H7 U2 i' W8 ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- E4 A5 [- X% Z. B3 ]* _2 m& t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ m1 N2 }3 |! y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 H' `7 E) _" i% w9 `+ q: o5 a - #else
1 q6 j1 E5 {. V" t( K7 c) c- a/ J - #define DMA_PRINTK( x... )
u& @/ I' k1 p* R - #define DMA_FN_IN; G! C# F [: v5 L, q! k" M
- #define DMA_FN_OUT( I- V9 v$ O. y9 v+ }+ W
- #endif1 i6 F n5 Y3 B( z6 ^2 v
$ W/ \2 W" L; s+ W6 e3 A4 \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( s$ a2 w3 S& V - #define STATIC_SHIFT 3' d- T7 ^4 J L8 L
- #define TCINTEN_SHIFT 20
6 X* ?% ~7 E1 G/ O - #define ITCINTEN_SHIFT 21
& R$ ~7 J) z, r r. b5 ^- g - #define TCCHEN_SHIFT 22
# {3 O3 t8 B/ @3 s - #define ITCCHEN_SHIFT 23, g! i3 G0 a& o( a J6 D z- Q
% i5 s7 J2 G7 e/ J7 J1 K" X5 M8 g- static volatile int irqraised1 = 0;
) z1 C3 T0 E& C: ]0 r% b& W - static volatile int irqraised2 = 0;: k( e- m* ^/ u1 X2 z: r
2 w! C s u" g' F# v U0 ~ i& b3 ]: u2 ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 b ^* g/ k7 p$ i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ C/ M4 ~8 R' k r( n6 J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( O2 K) b& G( M/ v- j/ q, |
+ o c& X& @1 W- Z! y3 ]$ J- dma_addr_t dmaphyssrc1 = 0;3 z5 e( f8 V/ ~# O. X) y
- dma_addr_t dmaphyssrc2 = 0;- X& r) c8 L3 W: U- L
- dma_addr_t dmaphysdest1 = 0;8 N& {! o- |& k3 y9 r8 P
- dma_addr_t dmaphysdest2 = 0;9 W; A0 f' S* Y f+ |2 X6 l
" l9 L: k& c) ?; t) v/ t4 R- char *dmabufsrc1 = NULL;5 v& v/ G, r, ? e3 m; u
- char *dmabufsrc2 = NULL;
2 g: t) F/ x' L - char *dmabufdest1 = NULL;
5 D, F9 Y& ]. K1 t - char *dmabufdest2 = NULL;
9 }# o, N% ? A5 v/ ?# f - # {4 m* X i9 Y- F6 _
- static int acnt = 512;/ q6 d" U2 C I
- static int bcnt = 8;
/ c+ r5 N( ]+ E; w9 `4 B g. I# g7 f, u( k( ^ - static int ccnt = 8;" k# K$ T" q& c5 V5 u% b. [( X3 a
9 _ @# t" L7 K9 ` a- module_param(acnt, int, S_IRUGO);9 |( Z: H, m2 Z4 [: F
- module_param(bcnt, int, S_IRUGO);
: e1 o6 o5 I4 S. W/ M# A. x$ j - module_param(ccnt, int, S_IRUGO);
复制代码
# p, G. M7 ?8 f. {$ W
4 |, v, P& A5 _4 Y. X0 t3 m+ } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- W. M4 `+ E' Varm-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 b- n& T0 |8 M5 x, M5 l) S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. m! o# l% \0 L- v4 c$ t
9 R! z [. V- Y( o1 X' J9 _
5 X, G9 z& V* p$ c. N |
|