|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 r; H8 ?5 d# C q( d- [code]EDMA sample test application
* j0 W- N |# \ H& U1 u! C4 p - /*- I" L; }# H, z5 X( ^/ e* M
- * edma_test.c& b5 ~! j6 X8 j# E; Q, f* v
- *
, }! K; U9 a) C. K) P3 e - * brief EDMA3 Test Application
* Q/ n5 E( E" u5 f4 ~) c* p0 J" | - *
5 i/ _; `0 w- F - * This file contains EDMA3 Test code.
2 ~7 D0 Z% H+ z3 I" E/ e - *$ E! w* ^* X6 C4 N$ W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; b( N/ B" D X% B8 _7 E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 a2 G; g: R, [/ M3 V# x P
- * TO CHANGE.; u6 H- ~8 h" t4 r( x. s ~ S
- *
: m) {* ^/ ~( B3 ^" x- j+ | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" G) D* @( K, a. d( j
- *
( F# J. N4 F8 \9 g/ I% \& c' _ - * This program is free software; you can redistribute it and/or
% m& ~* _: j$ I: D6 f% w - * modify it under the terms of the GNU General Public License as
# D* r% c! z- t: U7 n - * published by the Free Software Foundation version 2.6 H' N) h6 N; s; H
- *
) G1 w1 D& J1 [" P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 r! a& R* M2 M( |0 { B
- * kind, whether express or implied; without even the implied warranty, o% q, B" g7 U5 D# C' p$ r! j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 C, {6 \% U( h2 ^ - * GNU General Public License for more details.
! Y, e2 h; Y9 I, o2 H' f7 a - */
$ m2 Q2 t4 @9 p& F
6 j( _4 l* N I I2 |1 f" W$ o( d- #include <linux/module.h>
5 Y1 G, N0 z3 v - #include <linux/init.h>
( G* B x4 Y, t- j* h: s, P - #include <linux/errno.h>
! t. u1 r! d! e" R% G5 O - #include <linux/types.h>
' z4 u; Q, z( e - #include <linux/interrupt.h>& }* ~; I, ~& a5 ~8 F$ n* f2 E
- #include <asm/io.h>7 n: c2 G6 Z t' u
- #include <linux/moduleparam.h>
' h+ P; ~" K; W7 u" K5 i" f - #include <linux/sysctl.h>
1 Q6 Q0 `' `: c$ R+ ~* g - #include <linux/mm.h>
; O+ `, A& B; b7 ^1 t - #include <linux/dma-mapping.h>; B7 h" Q! J( ^' p% o) E6 c
* ?- t! [6 P, i. n' O( U8 R. j- #include <mach/memory.h>
' i' u1 M5 o H2 c6 p" i - #include <mach/hardware.h>
; f' y3 V/ {. S! j# l - #include <mach/irqs.h>6 S( D) \ y r7 h
- #include <asm/hardware/edma.h>) s+ p4 K% {4 J# E$ e* G8 |
- + `0 p, D$ K Q2 b" J5 \5 K# d
- #undef EDMA3_DEBUG) T4 t; o+ ~0 w' ~/ l" \* z
- /*#define EDMA3_DEBUG*/3 W& [8 @1 B3 ?" K. i
- & {. j" r3 u& M
- #ifdef EDMA3_DEBUG1 H* ] y- p- q5 W$ D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 G$ w: S5 e O6 G- |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# @1 T- k w/ n0 Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) R" w4 F) I% U; | - #else
- N: u; [- h! b6 \( B! t2 w - #define DMA_PRINTK( x... ) z7 ]% U' r. E M" t& i, J
- #define DMA_FN_IN4 }5 T! E( b/ [ P/ M: Z
- #define DMA_FN_OUT. V8 ~+ X( \- y
- #endif
; f$ x8 s! K/ A
5 g5 d9 n% p2 {- #define MAX_DMA_TRANSFER_IN_BYTES (32768): @) u7 K7 u7 H; S- U& P
- #define STATIC_SHIFT 3
- j+ \; M$ f4 `. \$ c# ~ s - #define TCINTEN_SHIFT 20
$ M: R3 F" P# f) i - #define ITCINTEN_SHIFT 21# O+ O/ T) Y2 B' Q4 K% ?! Z
- #define TCCHEN_SHIFT 22 D1 v% e2 c# ~4 C C, E1 G J+ M
- #define ITCCHEN_SHIFT 23
' Q- Q0 B) X/ I: a
4 ]4 ]1 [3 ?+ i3 t: }3 h% h# r- static volatile int irqraised1 = 0;
7 i3 S" H% D2 J+ s8 F+ f - static volatile int irqraised2 = 0;
# k3 N# ?9 k/ M. O& ]
2 q. A6 g8 M8 c! K& D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- R8 o1 q0 W* n- t M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 W' A; M( R4 S' Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) C0 y% ?& W C6 N; I+ `9 G - . `7 q; j- g! \
- dma_addr_t dmaphyssrc1 = 0;/ r6 B4 H3 M$ G" x
- dma_addr_t dmaphyssrc2 = 0;
4 K( n7 v8 T* n+ H" ` - dma_addr_t dmaphysdest1 = 0;
9 X0 M7 J5 i- R' Y D! ~7 n! ^' U - dma_addr_t dmaphysdest2 = 0;3 B3 K7 |# V3 P# `
- 8 a/ v9 T, d+ S' ]+ e
- char *dmabufsrc1 = NULL;
! Q4 ~" M5 U$ V8 u# C - char *dmabufsrc2 = NULL;
* O2 g$ R$ v/ R H7 j - char *dmabufdest1 = NULL;1 n3 I* o2 v9 w% y
- char *dmabufdest2 = NULL;# E; f/ J. u6 B( a/ o/ v( B
- ~; u- H- M7 M9 Q1 `; f5 q
- static int acnt = 512;
/ h' D$ X! i. f - static int bcnt = 8;2 Z% m4 v& \. Y$ \ @/ p: H* Y6 Z- J
- static int ccnt = 8;
7 ?" f5 J/ E: q" n3 C4 v# X- C - 2 P1 g7 L# x4 k5 B8 P- p/ S
- module_param(acnt, int, S_IRUGO);2 G2 o6 R1 s% A, q8 V
- module_param(bcnt, int, S_IRUGO);
% v$ X2 W2 I( j7 D3 T8 b5 m. P - module_param(ccnt, int, S_IRUGO);
复制代码 - f- Z8 R+ R/ n8 B ]$ R
; Z2 A4 ]. J0 C% y7 ?" |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 \2 t& o* ?( Q2 }8 L. 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; Z! Q" [. n# b/ L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 h+ O2 r6 s$ K2 F) ^, w3 q# I
1 Q, t& L+ b. a' C& D- [
/ o7 H% \0 ]( H6 Q! F0 c6 I |
|