|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 K; k! E1 h: L" x( k- [code]EDMA sample test application
. j9 A8 ?0 H/ M2 d. ~ - /*
( H E/ p6 N3 U9 X' x* N/ D$ r - * edma_test.c8 I+ s: v) ?( \4 I5 u
- *
: E) o7 F) r5 |0 z) h - * brief EDMA3 Test Application, S3 T4 l* H7 [! D& e
- *" M$ `. w+ M5 E/ C
- * This file contains EDMA3 Test code.! x2 Z/ |* N3 s% U, B& p: k! _
- *: W. x; f# X. }2 ]3 D: o
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 |0 ?2 Y# [) S- F8 Q5 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" a6 c8 v" Z5 y( F - * TO CHANGE.0 `- \' _& u% J
- *
8 R, b. ^' Z/ i2 l1 h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" W& _. t% i6 w1 a
- *
) m1 v6 K5 F1 y' g9 u1 Z7 U5 L - * This program is free software; you can redistribute it and/or
0 L( A# E# B. R1 E9 b7 m2 j) V - * modify it under the terms of the GNU General Public License as5 |' m) p8 q, Z3 o. F; _$ B
- * published by the Free Software Foundation version 2.3 Z* J; Y9 z; |' n8 n0 e) Y4 f: b
- *
5 M$ p! v: c9 ?* N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; B* d. N9 h( T# J# R - * kind, whether express or implied; without even the implied warranty( N5 n; F$ R% ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% N+ H& J- n- B2 p. s
- * GNU General Public License for more details.' D0 s* i) w" i, z
- */
0 ]: z- e) J" N* u - 3 u% z+ K8 ` w- h- ?' e: @
- #include <linux/module.h>
5 E, n, k4 K' L - #include <linux/init.h>; U/ D2 C8 [/ [0 j( h! m" g
- #include <linux/errno.h>
3 W8 Q, O: h1 a - #include <linux/types.h>
" { N+ S/ {/ H" `, |7 l - #include <linux/interrupt.h>& K( V* E# M4 A( ~
- #include <asm/io.h>" ?2 T5 Q! r2 \; P3 _6 Q. O
- #include <linux/moduleparam.h>& J: t- P/ _. n6 W
- #include <linux/sysctl.h>
/ Y1 x+ Q- x6 t. ~3 k, }+ N: ? - #include <linux/mm.h>/ H" K8 p& J* F5 ]4 T
- #include <linux/dma-mapping.h>, t) m B! ]' W: }, |
) a; b" j9 G r" ]* j, F0 b {- #include <mach/memory.h>
! F7 S; ]( `2 o4 {- \$ q/ u - #include <mach/hardware.h>
8 T& S* z% ]# Y) |7 w - #include <mach/irqs.h>
' b/ W" {8 }1 w( R - #include <asm/hardware/edma.h>
0 v, w% j4 }/ r5 q Q7 M; x
- H- B, s2 d- ~# ]- #undef EDMA3_DEBUG& c+ N# U) t2 o. D4 U
- /*#define EDMA3_DEBUG*/
# }1 x$ \" F) f7 W - & I# f/ W" R" u3 P4 q2 W2 T, F
- #ifdef EDMA3_DEBUG
8 |4 H9 l! [) t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 `7 {" x( }, l0 ^# c$ A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! n' ~- f7 T' ^; s, V. e" N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) o- b9 f6 E3 @9 b0 q
- #else
% _; q; ?, V4 }: F K - #define DMA_PRINTK( x... )
K: A9 }6 a) }$ k3 q% t* e4 F - #define DMA_FN_IN
; w2 D' r3 {: K8 J - #define DMA_FN_OUT- v1 g" ]: t: M+ n: M& X# Y
- #endif
7 F/ r+ G0 N# E; n - 6 D0 o8 j: p+ Z/ O- Z: M; q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 o5 M$ R w! h/ |# z
- #define STATIC_SHIFT 3% l( h& E: F1 V* t
- #define TCINTEN_SHIFT 20, Y- i+ @( K. b
- #define ITCINTEN_SHIFT 21
@' w1 s4 ?# ^2 e4 s6 j+ H - #define TCCHEN_SHIFT 22
& R# p7 k: W' r* |# L" R - #define ITCCHEN_SHIFT 23
4 P/ k0 p' H( R J6 i# p - 2 y) F+ t) c% ]) @5 y
- static volatile int irqraised1 = 0;
# V7 t' J' K$ V( A - static volatile int irqraised2 = 0;7 k$ t, Z# r) _5 ~6 _) t
# W# `5 V9 V- }( I2 I" ~* N; J3 F6 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 G+ K5 l3 a/ a# a( j! T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ p0 a: n/ Q+ g% g - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); R) C0 X" n- q" S
- : F f# A& G! {6 x" F6 d; m. s
- dma_addr_t dmaphyssrc1 = 0;
: b: X( p, a; h) [0 g+ I! Y - dma_addr_t dmaphyssrc2 = 0;/ s+ E4 @; V; l6 Z$ l7 I- Q
- dma_addr_t dmaphysdest1 = 0;
) l1 k7 }" W5 N7 H; d - dma_addr_t dmaphysdest2 = 0;9 W9 I9 L; Z( G+ f/ o
- & {. t' a7 s- F3 K3 ~9 i, m
- char *dmabufsrc1 = NULL;4 V) K" v1 \& O7 k$ v
- char *dmabufsrc2 = NULL;
7 N% o5 E4 C$ I$ B' ~" X: e3 G - char *dmabufdest1 = NULL;+ A: ?2 O& z( Q# B3 `( w) M
- char *dmabufdest2 = NULL;$ i% _! M8 Z9 G
( {0 p. c1 S7 Y- static int acnt = 512;
8 D; P, m3 x( d ? - static int bcnt = 8;+ O& [: h: ^2 [
- static int ccnt = 8;' J" B9 u2 G+ ^
7 a: h% h, |6 i4 S8 u- module_param(acnt, int, S_IRUGO);: r- B0 t+ H; M, |
- module_param(bcnt, int, S_IRUGO);, M+ f) K: S- r
- module_param(ccnt, int, S_IRUGO);
复制代码
, {: I+ L. s( v2 B4 A# N: o: d6 s2 b9 ]3 z0 J+ o8 T, D w8 k2 M5 d7 u" M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, `, k: s8 ~+ E! rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, H8 E% J' Z) ]- T8 I8 f4 `& |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 L5 b3 D, F7 ?9 O
# v% M7 H1 B6 a- A) N
1 N+ Y! Y. C: e d# K* m' a0 r |
|