|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* ^4 M8 q7 f! p; \/ F$ u4 N- [code]EDMA sample test application, E2 a8 m2 D# @" b% H
- /*& q8 V# n, e9 Y% Z8 c
- * edma_test.c
' Q' ^( a" Q. n. O1 X7 F% h - *
% [# G+ R) @7 w; w - * brief EDMA3 Test Application
5 l! s* ?2 u) W/ j/ t: E" t- U - *
! w$ k$ E; G- T+ D7 Q - * This file contains EDMA3 Test code.
5 L2 I( _4 @* F7 w3 @ - *% N- s& M4 R+ z3 J0 H2 r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 }, s2 Y% t1 o$ `5 @# S4 Y6 H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' x6 `/ g) X) p" N% f% N7 ?
- * TO CHANGE.2 B+ K: e! c7 \, f* x
- * J4 a" k$ l- I& G* C# [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ Z$ N' K* t8 _% E9 r. X8 _ - */ } n7 x6 c5 M/ Z3 B, X: X
- * This program is free software; you can redistribute it and/or5 ?! u& S# y& ?- q0 I& `; J; G3 K
- * modify it under the terms of the GNU General Public License as/ m U6 U; s7 \: C O7 M
- * published by the Free Software Foundation version 2.
; {4 A7 \6 v# m, Y) z - *
& h7 v/ W( y: l- y3 R5 _, l - * This program is distributed "as is" WITHOUT ANY WARRANTY of any* z1 G( X& L% O
- * kind, whether express or implied; without even the implied warranty, K( R0 O. }. c- Z+ O- ?' H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 r8 |8 t8 A; u5 L" S' E% T - * GNU General Public License for more details.
, Z7 ^2 [( U& W% [ - */2 n' V p, x: c7 x: e
- $ y/ A" i) z, n) q
- #include <linux/module.h>0 K( @' ^& d# J5 t% ?
- #include <linux/init.h>
' o. J: |5 Z; j: S" p - #include <linux/errno.h>
- n3 m+ n8 a, U - #include <linux/types.h>
! f$ O/ F, o/ ` W0 N/ O - #include <linux/interrupt.h>; }, h- ]9 N. v$ |0 h0 B9 t* h/ c
- #include <asm/io.h>
/ r: w5 p: A8 l' `, q6 q. ~0 A! S - #include <linux/moduleparam.h>
+ W3 i- T7 |- j$ [% d$ r - #include <linux/sysctl.h>
! x, H) R2 ]' }' s# _: [9 c3 V O6 E - #include <linux/mm.h> K" _5 M6 I) i# i+ a& `3 J+ X
- #include <linux/dma-mapping.h>/ `# C& k+ ^# w) R) K% C
# j1 X- e" G2 s8 a- #include <mach/memory.h>7 m1 p) A N4 i/ T/ L
- #include <mach/hardware.h>
! E2 w2 M9 T G - #include <mach/irqs.h>
% q, T9 \, l5 i# M& [9 U - #include <asm/hardware/edma.h>7 {% F) a1 B4 I& z2 i0 a1 ^/ f
6 e) b) t2 C4 r ?8 J, }' }- #undef EDMA3_DEBUG
2 U$ [# A4 u R5 s - /*#define EDMA3_DEBUG*/& C! B6 S; ~. b" n. j$ _
- |0 R$ H' w' f
- #ifdef EDMA3_DEBUG
( f% A7 Y7 o2 H. O; t# x/ A2 A7 n& V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 c& Y6 n) Y. u% E4 Y$ ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 V: x' S. G' C9 e! M) r; W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 n9 Y% R1 z: ^: z& \
- #else
$ x! t5 y7 N/ _/ Z - #define DMA_PRINTK( x... )
3 A* A6 ?- \0 b- t$ F4 ` ~4 y, \# g - #define DMA_FN_IN( c5 n" P' o1 a3 x- q1 Z; j
- #define DMA_FN_OUT
% j* s- i, i; a6 z1 Z: k4 v9 d - #endif" m- c. p/ n/ K4 ~9 r
5 D. w* H. _# t. [9 J. [( x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" l S4 w. j" }5 W3 M$ {- h! t - #define STATIC_SHIFT 3+ o+ R! {0 w8 G3 W, j8 C, ?
- #define TCINTEN_SHIFT 20
3 l; k; a" p. R - #define ITCINTEN_SHIFT 21. C0 M( A* T4 k4 H
- #define TCCHEN_SHIFT 22
" ^4 _5 n4 N9 c; T+ V - #define ITCCHEN_SHIFT 233 _8 \! G7 h/ `8 U' }/ [6 P, }# i
- . ~2 ~6 H# H# V! S- i
- static volatile int irqraised1 = 0;3 q. N# S, C- Q5 m5 r$ d& ?2 \
- static volatile int irqraised2 = 0;
; q5 l# W# h. {. o, b0 w
% A- g$ |, u" C7 F# z& v+ N5 s) ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 O5 ?1 ~' p; @' g; W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 k# j! {* b2 s6 K( w, A ?5 n - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* X# `9 d' S/ G) y6 z! R+ [! O
# s6 M& N& @. G* q" v* S: [" }- dma_addr_t dmaphyssrc1 = 0;0 h) h! d y& c
- dma_addr_t dmaphyssrc2 = 0;
" s0 ?7 D W2 \* C/ Z3 s - dma_addr_t dmaphysdest1 = 0;
: H( G$ U3 r9 D- C, T) Z+ A - dma_addr_t dmaphysdest2 = 0;4 ^2 T$ k3 o$ a
- ; N/ ~. L2 x5 f4 b0 ~2 v1 s w( \
- char *dmabufsrc1 = NULL;* k" n' m3 r- H
- char *dmabufsrc2 = NULL;, I5 O7 b7 [3 e: E5 U/ G& ^% A7 i
- char *dmabufdest1 = NULL;
, U% s9 v: ?, T* i - char *dmabufdest2 = NULL;
) [# ~6 S7 H% v5 d7 s- H - $ j. q1 D% T1 \5 R- n' i6 V7 M
- static int acnt = 512;
' ]& L: ?) E4 t& L9 D& r- P& G - static int bcnt = 8;
: J3 u5 b8 U) U( N* g9 c - static int ccnt = 8;
) z2 [# J% a! E* i: F0 O
! ?1 H* a1 [* y* t- module_param(acnt, int, S_IRUGO);; w' ~" c' D) x6 X9 J) ` v
- module_param(bcnt, int, S_IRUGO);
$ {" } p. h4 K! [3 F - module_param(ccnt, int, S_IRUGO);
复制代码
6 h# ?% V9 |: d/ g M+ m; f* I+ c$ l1 P2 L' {" F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) m+ A1 Q5 x) e* {; a. y& K' ?# [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% K0 e7 m' `- O5 ]8 H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 z ?) a$ m5 T, z
/ Z& J/ [( @1 I, ?3 g/ g
4 y( C/ S, }; X# T |
|