|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 [9 n" N: J4 H) @* c! S9 |# t- [code]EDMA sample test application
/ v6 D l2 ?& k& ?2 A% L - /*
' w* E- K; P7 N1 F0 l0 f6 s - * edma_test.c; Z K& a7 G# a, ]. s$ O
- *
9 m2 ~& ^! U$ o0 X, O) ] - * brief EDMA3 Test Application
5 G* V3 f V/ q( e) Z6 c - *
' h! e8 p6 Q& y& q+ m* T+ N - * This file contains EDMA3 Test code.
1 R7 L, k2 ~- n: f! l* F# p - *
/ d E7 ~( _: g+ J9 w @$ S& c - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 ] Q; ?3 ~2 ?' J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ k& T5 J: [( P7 L
- * TO CHANGE.; p3 n4 A( c9 M% {) b
- *
/ ?3 ^& B6 `; l. z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ A# r# y: n7 d; n
- *0 g3 n' Z5 U- A
- * This program is free software; you can redistribute it and/or
5 _( j2 L: P4 L6 C" y. @6 ? - * modify it under the terms of the GNU General Public License as& f3 Z( H) F5 z
- * published by the Free Software Foundation version 2.
1 D4 p; [* y) T0 _9 a - *. t2 ^3 C$ F& `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 V5 j5 |7 l0 T! B! ?1 W/ ]! K - * kind, whether express or implied; without even the implied warranty! h0 }. |8 X7 v9 `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ R8 h, z0 N. W, h+ u9 h( ^! g
- * GNU General Public License for more details., B1 b# ^1 i/ n2 `, `6 U( J
- */
% v T8 O' H- @' J: S: r - ( c$ W6 r" l" t7 g4 m s
- #include <linux/module.h>" @. [3 N. z3 q M
- #include <linux/init.h>0 N" l2 k8 E& c) T' v
- #include <linux/errno.h>
# f7 ^2 Q3 d- H: Q. F - #include <linux/types.h>
6 q- _' n2 E3 Q/ u, z - #include <linux/interrupt.h>
2 m: C* R2 ]2 M g - #include <asm/io.h>
2 V7 R- q: |; K6 ]4 w r - #include <linux/moduleparam.h>! `0 U# s$ i' X# h
- #include <linux/sysctl.h>
* ?' r( r$ x0 o - #include <linux/mm.h>
/ o* Z- S# U8 i! U* x - #include <linux/dma-mapping.h>
+ R: i' z% m' Q7 o) b
/ a, s; s0 G$ U/ `. G- #include <mach/memory.h>
9 s* {1 C" U9 s - #include <mach/hardware.h>0 e* L6 ~; O3 U
- #include <mach/irqs.h>
# Z2 V/ l5 k$ k6 Y" s1 G) p - #include <asm/hardware/edma.h>6 F1 R! _" q) v! Z, G' ?
- % ^+ H/ n# x/ {3 r* x+ O( z) ~2 q
- #undef EDMA3_DEBUG
7 w1 V3 \/ g- ^9 d& L O) W6 i7 ^0 ` - /*#define EDMA3_DEBUG*/% r, J; S: `% S1 }5 a
- 1 `7 y( Y1 H! ]5 X7 o& ?
- #ifdef EDMA3_DEBUG6 i/ j5 w/ b! G4 w# K& T: j3 c' x% @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 v1 u# S! n# R9 R* u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 V) }9 i2 b2 f* n& E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: ?0 ~8 R3 p. G1 c; z" m( n2 R - #else' t7 [6 C3 i. J% c+ h) Z, j
- #define DMA_PRINTK( x... )
0 W( v5 J5 q6 ?3 t - #define DMA_FN_IN: h: k) h1 x6 |' j5 M9 o+ Q8 x% n
- #define DMA_FN_OUT4 t# b6 u% G. @! y
- #endif
; z2 ]4 L6 m3 d$ o
) s( v: _# h/ T; {& M! q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; w8 g1 O# C0 J) e - #define STATIC_SHIFT 3
* _ }, S2 m* y! Z' s9 t/ O }$ z& a - #define TCINTEN_SHIFT 20& N2 J+ o( Y7 K# H2 ?
- #define ITCINTEN_SHIFT 21
4 E7 J1 _/ H5 H - #define TCCHEN_SHIFT 22
, ]" W5 p N; P$ c8 V2 P - #define ITCCHEN_SHIFT 23, f6 K; _3 Y1 T+ k g
. l0 y$ t3 n: p* F3 N- static volatile int irqraised1 = 0;$ u4 k; y. n+ w- }
- static volatile int irqraised2 = 0;3 B F+ o k3 k( r6 h0 x( R( [
8 x; E8 h& [& n* ^! y/ x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 I1 N$ I( Y* W4 m# d8 t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* Z3 [' s' w% N* ?, f9 |9 d+ w$ G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); _' x9 y* d/ ^ x" e6 F. }
- 2 o* y0 n$ X$ [- l
- dma_addr_t dmaphyssrc1 = 0;* H7 L; T7 ]: j% h$ D" L
- dma_addr_t dmaphyssrc2 = 0;
$ q' v* w, E4 x, Q - dma_addr_t dmaphysdest1 = 0;
4 o4 C4 D* o5 h: s; U - dma_addr_t dmaphysdest2 = 0;: }2 f5 W: e; ?4 P4 }
9 G0 L: Y- g! [: u- char *dmabufsrc1 = NULL;/ B* b4 f; g: o! c
- char *dmabufsrc2 = NULL;% b* U2 R) F1 I
- char *dmabufdest1 = NULL;5 H$ c/ S Y! [, L* a7 Z3 t
- char *dmabufdest2 = NULL;
U+ P1 P8 |7 Z8 H - 7 g0 c8 k' h+ O% c- J
- static int acnt = 512;
* M% \. U7 _0 n# x f* O2 r - static int bcnt = 8;2 K# W% x! j3 T- b2 D
- static int ccnt = 8;2 j+ X) A# X. s: s m0 A; o
9 ^5 ^9 r3 r; [9 q* ]- module_param(acnt, int, S_IRUGO);) u4 N Y: c! A' i" g3 I+ L5 _" y
- module_param(bcnt, int, S_IRUGO);( R6 P9 _+ N1 f! i4 X* p7 h
- module_param(ccnt, int, S_IRUGO);
复制代码
$ n4 |8 j! g+ }4 t: t0 t; n: s3 W* F( E/ M% H& q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 c3 @9 f: P0 N" ]' ^5 R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 x4 H$ v. u0 ? 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 m; ]$ O3 y. {* y# [6 n2 B5 o& y
- J8 Y/ ?/ H3 L* q& P8 L7 Y0 J, B1 Y s1 S ^
|
|