|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' k( r3 W+ F* R! i; q W; |2 Q- [code]EDMA sample test application! G% g1 T, g U) j, L$ @- v$ g. z
- /*) o- J$ {& T( \% Q: ~+ G
- * edma_test.c) O' F. q' L+ b1 C8 h! h
- *. B2 k4 [$ a9 @; f5 V
- * brief EDMA3 Test Application' O" a0 y2 p- f5 E
- *
: q1 v, V3 E1 p, @ - * This file contains EDMA3 Test code.4 U8 ]; w3 F9 P" q/ s* s8 \7 S) p
- *8 U8 r5 k% K- }' L; K( R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; g( V" F% z. K; y$ {5 P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. p: F! u! @9 C) ]+ E; n9 j( a
- * TO CHANGE.' @2 Y! \) x; w z7 D7 ?0 H
- *
% m* X( d' r2 [% n( U$ r5 I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! n; n5 Z/ `6 I% R! E( i1 Z& Y( P - *
2 ?' \$ a1 J# w! a& H - * This program is free software; you can redistribute it and/or
9 |, c2 m0 x. x0 ^0 d - * modify it under the terms of the GNU General Public License as. U3 C, [# S, {( x: |
- * published by the Free Software Foundation version 2.
! W7 c( Q/ Q7 t - *0 N9 w, q* X2 A4 U4 C) _+ F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# U! h/ k( O. p% O. v6 n
- * kind, whether express or implied; without even the implied warranty
0 M6 h2 b& z2 W( [5 ^6 A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 {) u8 d/ k! l. O - * GNU General Public License for more details." X* X* \8 L8 @1 K
- */1 F. M4 A& J( \( n3 L0 K& r5 ?1 I
+ [0 U7 P$ D, @( h1 T7 M; L- #include <linux/module.h>
1 V4 J! ` j1 ]* k' Q/ C0 i - #include <linux/init.h>
y# O5 h5 G% q+ F% }8 w2 D2 y; F - #include <linux/errno.h>9 e* b. a6 r# `9 |
- #include <linux/types.h>2 y1 N; Q, V2 W1 x9 v# h
- #include <linux/interrupt.h>: Q4 Y& \ O, @' a
- #include <asm/io.h>
4 D/ n0 ]' O, C( }4 { - #include <linux/moduleparam.h>( U2 E: h. n# b" s. f! l
- #include <linux/sysctl.h>
: z8 f/ U8 Y: i1 k; o: y, z - #include <linux/mm.h>
8 s2 Y" |: T& o, E. |3 m% Z - #include <linux/dma-mapping.h>- w/ _) ~; n6 U0 t% f
4 Z; y0 S+ {% W- S ?6 L- #include <mach/memory.h>+ C1 Z, g$ o- {/ F5 O
- #include <mach/hardware.h>
8 y/ ?) ?. U9 B+ Y$ X ^ - #include <mach/irqs.h>
! V1 {, s0 T& ^) e - #include <asm/hardware/edma.h>$ e8 Q& ?4 \8 W+ I# l4 t
- 0 _- Q& G; ?4 T8 Q
- #undef EDMA3_DEBUG3 p1 s( [4 N+ I7 b, L& r; ?6 H- @
- /*#define EDMA3_DEBUG*/5 Z. f% n! S! v9 a7 b; r
% B* J6 J; u! T) M- #ifdef EDMA3_DEBUG W9 c% p/ C: x+ K. Y5 W9 [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( {0 k0 K# k3 e* m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( K9 ~% U+ m. t% J, T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 z i! D; q' P( [2 d - #else
/ x8 v* C! u% d3 n - #define DMA_PRINTK( x... ). B7 G* l4 E2 f" y
- #define DMA_FN_IN
3 I) O* v6 P! L$ M0 ^ - #define DMA_FN_OUT
- |: b8 N" n- @: ^) C! v - #endif
9 n* D1 x; X- P) S
G4 @4 g& Z! J' h: p! v8 d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! q! T; Z. s! Z$ D2 D - #define STATIC_SHIFT 3
# n1 m% j+ A R, k6 \: z' W9 Q' } - #define TCINTEN_SHIFT 201 X$ `& K# y; T& b! c4 c# v+ k; h
- #define ITCINTEN_SHIFT 211 r* b, {% l1 \
- #define TCCHEN_SHIFT 22
) t! a4 p6 W D2 E - #define ITCCHEN_SHIFT 23
K& Q, m6 ^7 Y - ! ?" [% A' Z0 k+ F6 |0 j0 a4 |
- static volatile int irqraised1 = 0;! _5 u6 g2 j. u
- static volatile int irqraised2 = 0;! ` z# @, u) F( }' y1 ?
% I D; K# H. x: d6 f* E- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, [2 m/ s; z) M5 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: U& h& T* O1 z l( \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" N$ ?6 W$ Z3 Y4 v7 `
- 1 w) u* _& ` G" Z# U I3 C
- dma_addr_t dmaphyssrc1 = 0;
" A1 z& x" c! A - dma_addr_t dmaphyssrc2 = 0;, g2 Z, S8 p4 R3 t R* @3 e
- dma_addr_t dmaphysdest1 = 0;5 ~* f1 H3 M. x9 a2 F
- dma_addr_t dmaphysdest2 = 0;
' Z. ?" A. T8 s( ?5 z. i* M: S7 o
) R$ C4 R, _. U- k1 r8 H7 ^2 k! t+ g) T L- char *dmabufsrc1 = NULL;
+ @2 q& T9 Z+ V7 [: P2 g9 i - char *dmabufsrc2 = NULL;- L0 e: |4 \% y9 D* T
- char *dmabufdest1 = NULL;0 ^8 U' c, L, Q0 _0 |8 _
- char *dmabufdest2 = NULL;" b9 u. g$ w9 y
- " y# j& t7 Q' o/ G7 H
- static int acnt = 512;
4 L4 ]5 b3 O' L5 t - static int bcnt = 8;
- F3 h- p" W: Q# l - static int ccnt = 8;% n+ N& i! R2 j' p, x; `1 J: e j+ B
$ X+ L4 m2 \/ w! z2 I3 t [' @- module_param(acnt, int, S_IRUGO);$ z" r# q4 N1 W6 ~* O, ^
- module_param(bcnt, int, S_IRUGO);
! H) H3 L# B8 T - module_param(ccnt, int, S_IRUGO);
复制代码 * | O3 x! \4 c0 R% s) |$ M2 U% y
" W: _! B6 J" ~" x& }7 C
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' F* o( U" {) @* T, Z1 X! }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 g5 b/ C7 z) y0 G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( e1 Z t# [; r. }5 y, T6 I
: c! m! w0 Z$ Q# M" t
* Y; j L9 \. |2 g3 X0 `( Q8 E |
|