|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) t3 p, T1 T# c' S# `0 p8 w- [code]EDMA sample test application
% D5 C) V% j7 C: D9 f) B - /*
3 j" z# {% }$ s* q+ z: b1 J - * edma_test.c( g( y. R8 M1 z
- *
" x+ L" k# z7 y% o, F3 U6 R# o- ^ - * brief EDMA3 Test Application5 a" u# r0 V G
- *9 C1 g! u' x. d7 c0 _
- * This file contains EDMA3 Test code.
7 I* B( ?& _( J6 Y% ]" J% c - *% G- I2 \* K B" w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* w: x. u3 U+ _% X8 t, x& x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 F% C M9 m' a k+ B$ s8 h - * TO CHANGE.+ K; a: H% {" E* f% n
- *( Q- ^$ l/ c1 W9 |# z( \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' N( l5 [5 P( [& p - *
+ R. C+ q. [% f* Y5 a - * This program is free software; you can redistribute it and/or
) O$ f# W r' ]7 `, l - * modify it under the terms of the GNU General Public License as5 k6 Y' P7 D7 I% M, M2 D
- * published by the Free Software Foundation version 2.1 o& Z3 v* B: E0 n1 l f" e
- *
4 ?0 x8 B7 Y- f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& D- D1 z2 T+ n I
- * kind, whether express or implied; without even the implied warranty
/ v( G2 L" C0 I! u! W' }& K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ^' ~6 J; I7 {4 k. {4 r
- * GNU General Public License for more details.
/ D# N, ?% G5 I* l9 R2 @! H F - */" X! M. ^4 A, Q5 P$ Z" B
2 ?! _ [2 s7 F- #include <linux/module.h>
1 ~ H9 d) H- I# M - #include <linux/init.h>
" D @2 b7 t2 P3 G+ e( e' d - #include <linux/errno.h> b! k4 t! s, ^5 i* ?4 {
- #include <linux/types.h>7 L& c: q7 r( J
- #include <linux/interrupt.h>
$ b. l* K* k9 ?( K: _- o' K - #include <asm/io.h>
- y: P+ l+ F( Q: O# v - #include <linux/moduleparam.h>
9 J! y! L5 c; [% n" S - #include <linux/sysctl.h>7 I# E5 n: b. o5 A+ q3 t8 d3 |0 ?
- #include <linux/mm.h>; `2 p' @! j" W% H6 h+ y: @
- #include <linux/dma-mapping.h>
2 j9 ~+ _5 C( ?3 ~
1 o; h( N. S* G1 n2 k. D" _- #include <mach/memory.h>
' P+ v0 Z7 O- G3 J1 g0 E T - #include <mach/hardware.h>6 K- h9 J8 Z0 T% j$ Y/ Q6 J
- #include <mach/irqs.h> K! k: S4 h) j7 I$ v1 z2 S) b
- #include <asm/hardware/edma.h># P L8 A8 I6 w9 X. K: E# |
- / N7 u" Z/ _0 _" q! }/ q
- #undef EDMA3_DEBUG
6 A. E* z$ `. l% c0 t - /*#define EDMA3_DEBUG*/
; {3 S+ E$ ~* O
' L5 {; q* j0 y/ P+ y- #ifdef EDMA3_DEBUG
. E; R! ]3 e! w% B: |; G* D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" ^* b+ g7 l* K
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) r. J+ Z) h, E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" U0 S$ A d% U7 U
- #else4 u6 A4 i; n3 m0 Y2 d3 ~4 Q
- #define DMA_PRINTK( x... )3 k0 L; K5 O' I8 t
- #define DMA_FN_IN
2 Q: T0 N; [7 g% W: Q2 L8 e - #define DMA_FN_OUT
$ c$ k3 l5 V9 F+ H4 n$ U - #endif' R4 f g8 j1 n, T
- ! D# _- z: ?# r" m3 Q$ ~5 k8 G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 f$ M$ S& b7 K - #define STATIC_SHIFT 3
d! s1 V, B8 U5 P8 L - #define TCINTEN_SHIFT 20
# z) v' X: n) n; u, d K- j/ i6 s - #define ITCINTEN_SHIFT 210 z- t) G& R/ R+ D. G% H
- #define TCCHEN_SHIFT 22, t. p! B+ F* E: W
- #define ITCCHEN_SHIFT 23
@6 q0 U7 t" H. h B
2 G) ~; L# j1 @- ?1 C( H- static volatile int irqraised1 = 0;
0 o( Z3 E( A5 d( b - static volatile int irqraised2 = 0;2 U6 l* ]- D* m. I/ e4 ^/ H
- 2 J+ V6 \+ R9 I% U3 n4 O
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 I7 i5 o' f# n- D6 {7 F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 b, ~5 k+ l: C* B' b8 _+ V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ b+ p! h$ e1 X7 h5 b) V
9 H2 k& J F" W5 f6 |7 e: Z- dma_addr_t dmaphyssrc1 = 0;) d" Y- u1 a: Z2 \( b( h. r+ l$ z
- dma_addr_t dmaphyssrc2 = 0;
. G. o1 I9 n/ l8 B) L$ a - dma_addr_t dmaphysdest1 = 0;$ Z0 b/ H3 V$ h- A) d
- dma_addr_t dmaphysdest2 = 0;
7 A4 O& R, m2 c7 ~8 U" U8 g - 9 C; B: |& ?" A
- char *dmabufsrc1 = NULL;
# s" q" A0 n% \" | - char *dmabufsrc2 = NULL;
* W2 e) h0 f1 p4 Q1 P% j - char *dmabufdest1 = NULL;
' r: z7 K& v. p5 O - char *dmabufdest2 = NULL;
- o3 G9 z. e3 f8 m - 1 Q3 `2 ~' [* }! S# \1 X
- static int acnt = 512;# y* y( h; l4 o/ v% ~7 T+ V' q
- static int bcnt = 8;# O8 G+ \2 _! G E
- static int ccnt = 8;3 F! j" {* D1 v+ d& ?1 W) f
- # a! o p; _& K( a/ b/ F
- module_param(acnt, int, S_IRUGO);
* s" c+ A" y/ ~* k - module_param(bcnt, int, S_IRUGO);
6 o: c& y% N6 {5 [' B3 V$ g - module_param(ccnt, int, S_IRUGO);
复制代码
; n# N/ z( \0 L5 e. G& k# G2 P9 K d4 ?, r0 J4 W. u+ `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% a3 q# f1 ~/ S6 K# O: ^' c+ tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) M% ~; s' L. _, S! G% e9 [6 f2 @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 u: D& q- t$ |6 Q5 k
; {( y0 ~) q- ?7 X) s% k# ^2 \+ ~
% g$ M; H3 c1 { |
|