|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( y, P8 Q, W7 M
- [code]EDMA sample test application
3 k/ i# Q, g0 k! W0 Q! V - /*+ L2 l8 k) R. _7 I0 R
- * edma_test.c
, ~6 F7 `& j# I% u - *
1 M5 R( b7 x B - * brief EDMA3 Test Application
% f3 f6 ]1 |+ F/ G+ @' w - *
9 ?3 K* X' U/ ^% {: \' o8 l& _, M - * This file contains EDMA3 Test code.+ r, @! M' o: O( r" \- s
- *
; N4 {3 y k$ a' Y0 i3 h+ @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: ]* }$ l+ f" E- F( _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- i+ j: a: H9 b# m( _
- * TO CHANGE.
$ ^9 d h" J! r5 ]* ^/ W: R* C' g - *
& }: C5 g6 F7 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; ]7 P! V+ }# }& ~$ o+ w
- *1 t: A) n2 R) Z+ s) o2 ?/ p
- * This program is free software; you can redistribute it and/or6 H7 M" A1 U0 W. v( e
- * modify it under the terms of the GNU General Public License as: N* X6 Y# d( I b7 [, c
- * published by the Free Software Foundation version 2.- T* j x6 i, Y% y; M6 s& B
- *& n0 f: M& N0 K, Z1 e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. j( A/ P# m* v- N1 i, }( e - * kind, whether express or implied; without even the implied warranty- d" V; V+ b$ ] ?; K8 I& i; p
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ Q/ |- O4 l, b
- * GNU General Public License for more details.
/ ~4 n8 O, w# A8 p+ o2 h - */
+ W1 R/ i+ ]+ W1 T: q. z( } - 7 g+ L7 @" B6 |6 Y6 b1 L
- #include <linux/module.h>
3 L# \) M/ `% h ] u# U - #include <linux/init.h>
5 W2 K% e: r j1 @5 S# X - #include <linux/errno.h>
8 R7 \0 g" ]6 c$ M& f) ^ - #include <linux/types.h>$ u# |, O" T2 ?( X/ }
- #include <linux/interrupt.h>6 `$ ?, C/ Y: n: ~6 T5 U
- #include <asm/io.h>7 q( m, h: T3 p, `
- #include <linux/moduleparam.h>
4 ^5 N. Z R9 @& r+ ~8 H. u. i! x - #include <linux/sysctl.h>, u& g9 L: n$ i& d
- #include <linux/mm.h>6 l& d1 S$ k. w7 ~! o! h4 T
- #include <linux/dma-mapping.h>1 N* h* ?' `7 J G- g, q
1 r; h. g' k N& h$ q4 ]/ {5 X$ u- #include <mach/memory.h> g$ ^ y9 w/ d$ [: y0 Y
- #include <mach/hardware.h>$ p0 }# U6 W F: |
- #include <mach/irqs.h>, w% C2 \8 c, h2 i J- G0 z$ i
- #include <asm/hardware/edma.h>
# L+ N. h- W1 ^ - 8 Z+ T5 Q2 l0 [0 [
- #undef EDMA3_DEBUG
$ F& ?5 P0 U+ i" E. K - /*#define EDMA3_DEBUG*/. J' N( z6 O' f9 \
- R I: c8 h4 `, ~$ g* U, b1 P$ P
- #ifdef EDMA3_DEBUG F3 m" \- E# t3 ^, ^+ x+ K' ]$ L- t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ M; n- X" D1 J$ f1 } - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( ?! C2 F" R+ I; }! O! Y% E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ O; B+ u' Y3 w, }( s# _7 \+ d( P - #else! ?) ^. U: x# i; d$ k
- #define DMA_PRINTK( x... )( o$ D2 x5 B4 R) t$ S
- #define DMA_FN_IN! L6 A$ E/ a* x; `! R
- #define DMA_FN_OUT [9 ~4 l' U; J+ M: [! Q. D" \
- #endif
" y" T7 u& E- @+ u: T! C! a4 _
& h7 i. d' j3 ~) U+ u z2 U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 V8 J, q$ m+ _ - #define STATIC_SHIFT 3
' i+ M J" `: _" q8 h! y2 h: w - #define TCINTEN_SHIFT 20/ r0 I% L5 P$ E* i
- #define ITCINTEN_SHIFT 21
3 p r2 ^; K6 S2 _* k4 G - #define TCCHEN_SHIFT 22% Q& \- b- M3 |9 e% s" N9 y' ?
- #define ITCCHEN_SHIFT 230 x* z* w/ Z+ z
- ^8 G' o3 f1 w8 ?1 @
- static volatile int irqraised1 = 0;
& K1 l2 ?' ~7 r% i K) B0 W - static volatile int irqraised2 = 0;
8 e4 e5 o$ b$ k, K( a) ~
' z- S B6 b' }2 q: g% f# _- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; O8 W! D! R( y: z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ ~% _) ?. l/ w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) |: h+ Y6 \4 U# }5 @. U5 v* l2 \' R
! T* j" |2 p- d- dma_addr_t dmaphyssrc1 = 0;) Y1 j3 V! w& T5 e! k! R" Y; b
- dma_addr_t dmaphyssrc2 = 0;! K, P7 v. V* O( w' S
- dma_addr_t dmaphysdest1 = 0;. H) i% E) v1 x% y; D& h
- dma_addr_t dmaphysdest2 = 0;
. ]7 c8 j# f+ ^5 E- r- z, I - 7 [- ^" K4 Q5 J
- char *dmabufsrc1 = NULL;! H4 u& K7 u0 a3 o8 {- \
- char *dmabufsrc2 = NULL;. q7 P% ~% i f4 S5 h4 M* \3 Y- p' p
- char *dmabufdest1 = NULL; [% p3 F& t, F2 @
- char *dmabufdest2 = NULL;5 X5 K1 H6 T/ B. S* n' Y" I- }5 [
- , C5 ?/ e- w8 r) Y* V
- static int acnt = 512;( ^# x/ a2 s. ~ \
- static int bcnt = 8;
, D: c2 G3 f5 l4 S/ Z - static int ccnt = 8;! r* A2 a% h* ^8 U" [1 N
4 _/ B/ h" e8 K0 M2 {; u5 [' q! `- module_param(acnt, int, S_IRUGO);: m/ L& B7 d t/ m1 S8 a
- module_param(bcnt, int, S_IRUGO);0 h. b8 e) y" O, O% l
- module_param(ccnt, int, S_IRUGO);
复制代码 3 j' {! q5 v" `' q$ Y/ \
6 z/ }! U5 Y4 H! w) P6 J( F 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% h' j. A1 N# Z& [
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 K' o( G O+ e8 L# k
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 e+ ~7 C( I* Y! v( y
+ t: `! q4 W; Z0 M( S/ O1 Y
4 ~ ]' Q4 I( g' E
|
|