|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 `! W3 ~6 k0 l1 Q! r# v- [code]EDMA sample test application
8 d j ^, w+ K# `5 M$ O - /*; L$ Z" x7 X7 o+ I! ^
- * edma_test.c/ {$ X" n* S6 K0 O1 @$ g# W9 Q1 f& B
- * R# ?4 h* H) w% w# d- A6 }+ x
- * brief EDMA3 Test Application% m: {" _9 Q. E; r) }
- *
( u- \+ a: J% q - * This file contains EDMA3 Test code.( {" l" t. B7 {: z% [* V5 n
- *8 [# J7 m. ~4 }: U3 j3 |" Z4 N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 G" T; i3 Y( Q' p- a' N5 }6 g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 L0 S/ q( F0 O7 U5 ^* L - * TO CHANGE.. M5 I) |# ]( `' [9 Z
- *2 |% g6 W; j0 \: G, K, T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 U& f# u& W' E7 ~2 T7 q
- *
6 x6 E$ a# n0 @. ]1 w" q+ z - * This program is free software; you can redistribute it and/or
) P) Y% I7 l& ?2 ]$ I; p - * modify it under the terms of the GNU General Public License as
1 M5 L! L1 q+ C' | - * published by the Free Software Foundation version 2.
% _$ z) V" ]! e5 w5 o5 W2 h - *. p. }4 ~2 C; L- Z: s* w3 z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' w+ X6 w$ L0 s" `2 I8 S \ - * kind, whether express or implied; without even the implied warranty/ B, p% s; I g/ H! m# N( A: ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* Z- P! j0 {6 Q7 R/ `6 J0 x
- * GNU General Public License for more details.# {; e6 R0 H. A4 a4 N
- */& t: U6 t* O* N2 x! @
- 2 a9 I, }6 i5 C! z1 k
- #include <linux/module.h>
' `+ l9 a5 B- b - #include <linux/init.h>$ }. c- k H. Z: \3 ` _- c& ]
- #include <linux/errno.h>
7 B, z1 R/ Y& a3 y - #include <linux/types.h>. M% Z. O5 Q, _3 f1 e3 _/ U, ~
- #include <linux/interrupt.h>: ]! _# `9 }$ {" z6 R" L
- #include <asm/io.h>
. m- v+ b+ X( x# C- F' U - #include <linux/moduleparam.h>
5 W, Y" G& _# P+ L - #include <linux/sysctl.h>
" y( ?8 j4 d! ], _ - #include <linux/mm.h>
( h: o3 b, d, U# m g2 p K - #include <linux/dma-mapping.h>4 F0 a3 U/ w0 Q! C4 M6 H
# C7 C. k9 p! Q* A; s% E2 ]- #include <mach/memory.h># x" ~+ p$ }. R' K! }
- #include <mach/hardware.h>
2 j( C% z9 E) } - #include <mach/irqs.h>
) @, o7 U) @. M+ J% l5 h$ k - #include <asm/hardware/edma.h>
$ v7 _9 v( J% \9 z - . c) s% z9 F# h" D! F( a& T. s9 Y
- #undef EDMA3_DEBUG
1 o4 A" S% a1 \' p: J' I: G$ ^ - /*#define EDMA3_DEBUG*/
! Y6 A j0 D& i* K/ M4 _
' b9 F! H- @; p) q# `$ d: S- #ifdef EDMA3_DEBUG1 p( S$ y3 H/ {5 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ S0 L+ I8 {$ ]6 F - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* N5 n& E+ f* `0 z, s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* w( |; O* p6 |, {( @8 k8 ?
- #else6 }6 P/ ^7 J1 f7 Z6 N/ }
- #define DMA_PRINTK( x... )
: n( v& Z; x. t2 J - #define DMA_FN_IN
8 Q$ u# s# @; _( ] - #define DMA_FN_OUT
- s a" n5 r) E9 a - #endif
" I- d8 h* D+ E+ {
2 u) c! ]9 b/ y7 G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 N) Z: k. M0 b2 x3 n" u - #define STATIC_SHIFT 3% `. U+ b' G: X' n; C% M! l
- #define TCINTEN_SHIFT 20$ W' p. G# `* j( h% ^- I
- #define ITCINTEN_SHIFT 21: @# a4 N# e! x3 s7 D) q! D7 q
- #define TCCHEN_SHIFT 22- l/ Q# B& p# [- m
- #define ITCCHEN_SHIFT 234 \: u1 i+ o7 W. A/ B5 W V
- 8 u5 b# U: K% p |8 J
- static volatile int irqraised1 = 0;
6 j4 n, u/ z5 y- `, h, D" | - static volatile int irqraised2 = 0;8 \, e' F! p( U6 W! N ~8 L3 S2 v, ~4 _6 C
' ]; S' g/ G0 G- h" v8 B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: S9 c0 _; H/ Q2 A
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) r" |6 h$ j7 m$ X, k- x o# x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: v M7 W, q- \' C" U" k
- - O0 J) F2 q8 H+ Y* i( Q/ R. B: |
- dma_addr_t dmaphyssrc1 = 0;
2 [3 a, Z0 T7 n& c - dma_addr_t dmaphyssrc2 = 0;9 T" j; {- }# {( D
- dma_addr_t dmaphysdest1 = 0;
) R& X+ t8 }8 h; W1 _ - dma_addr_t dmaphysdest2 = 0;
c/ O" V6 [7 _( ~( O, @ - 4 \8 \: V. ]0 j4 ~1 _, ]
- char *dmabufsrc1 = NULL;
# @0 V$ q5 P0 w a' ?8 J - char *dmabufsrc2 = NULL;5 V- U4 R* m( B3 m, P2 { }& U+ W- l
- char *dmabufdest1 = NULL;, e U4 z* v2 K
- char *dmabufdest2 = NULL;
p$ n% I) q P6 ?5 b
6 f- f# X/ f& R. Q: s0 c- static int acnt = 512;
" l- f7 Z/ q. `' l* E - static int bcnt = 8;. W c* L' s: r2 [. N( [2 v: E" {
- static int ccnt = 8;# T6 L& x& i0 Q$ n9 ^. }6 u
- e2 ? V3 x( O" g& o
- module_param(acnt, int, S_IRUGO);: U6 U$ c" n3 G$ g) l
- module_param(bcnt, int, S_IRUGO);
+ m' ~# l! j/ l: Z0 C - module_param(ccnt, int, S_IRUGO);
复制代码
1 x1 X& \) H9 o1 R5 H
6 K& k* _6 b$ p1 y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; U# c: y6 n, {" {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# Y8 K$ B* f+ k" _# t$ I7 a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% ]2 }! p$ N. `( \/ F
$ A+ v' w$ q& h3 q" E% |- ?, B
* Y+ [7 ?, y0 @6 F0 w% ?, n% y |
|