|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( x1 p2 b* |: l+ n- [code]EDMA sample test application* z0 J3 Y% l* G
- /** m0 M& Q2 U6 K9 f. ]
- * edma_test.c
4 [ S) {. v& I& v& g% |6 }5 @9 ~3 m - *. D! M( m- x6 R3 g6 ^% a, d8 \, z3 K
- * brief EDMA3 Test Application
$ X% q2 E4 {/ i! v; {3 Y - *
# ]" E- |* I6 U- m6 M* P - * This file contains EDMA3 Test code.# S8 U. [4 d6 J4 l
- *
9 M! {3 l/ E/ Q9 V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 v* f3 u$ @% ]/ Y2 t+ e( D) ?5 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 O; ?8 [. R7 j/ q3 @- W
- * TO CHANGE.
d7 J9 b9 [4 Z - *
! i" g- A2 ^9 r/ m6 d - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 I3 }) ?* w3 c( q8 S - *
" i" X' G; ^) Y }* B9 Y - * This program is free software; you can redistribute it and/or6 @8 v |, P1 p6 n1 Q/ q
- * modify it under the terms of the GNU General Public License as
& e% q( l9 W& | - * published by the Free Software Foundation version 2.; R$ f% c* t7 U) L8 E
- *
9 @7 z- }0 V9 r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 y5 o) [/ U% c4 H- B* a7 s - * kind, whether express or implied; without even the implied warranty
+ q8 N6 s- t, R" X& i1 _" h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! Z/ @5 o# i: X; ]( c$ I; r
- * GNU General Public License for more details.
1 C- `7 ]$ h, K5 k - */
" i6 z, F, J3 U% W
' W. T. o% U% V/ Q _% R T- #include <linux/module.h>
2 y5 O% e. {8 G - #include <linux/init.h>/ ^6 @9 G5 W4 D) U6 c; E
- #include <linux/errno.h>- G0 M3 o- Z( S8 P
- #include <linux/types.h>
: M X% e6 ]2 ]6 h - #include <linux/interrupt.h># I0 Z& e1 Q* N& P! o" ~" X# |+ i
- #include <asm/io.h>: q6 h; G1 |9 N3 @
- #include <linux/moduleparam.h>
5 R* [& q# n) n, D - #include <linux/sysctl.h>
4 r5 p& S8 ^: f# e/ S4 x' i - #include <linux/mm.h>
& b% n9 G* Z5 L8 y$ t0 c6 i - #include <linux/dma-mapping.h>
k+ o, G4 \2 Q3 l7 e$ S - ' [0 b. k$ u$ _6 I% v
- #include <mach/memory.h>. z, L- s1 x! l& c# T* S* t
- #include <mach/hardware.h>* t1 T% e' I! K0 u
- #include <mach/irqs.h>: p; M A* P( u# z( Q2 D! a
- #include <asm/hardware/edma.h>; q0 |% _+ b0 M0 L
- + T3 v. ^; z0 p5 Y% c- v
- #undef EDMA3_DEBUG
5 c. W, H3 {5 S* q& a% l/ k; h - /*#define EDMA3_DEBUG*/2 w% r8 a5 Y1 Q5 G8 \( q
- : C1 q6 [, M3 {$ O+ Y6 B* H# f0 B
- #ifdef EDMA3_DEBUG' Z$ N5 o5 ^ g# s+ b4 c! G2 O4 ~# S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 w W1 n g% R) H. N. o$ ^0 M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 h p" B" x" S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ \( m) j, S8 G; ? - #else7 I* \' d w$ f3 ~, P
- #define DMA_PRINTK( x... )% j3 w1 y' ]+ ]: F+ C/ h
- #define DMA_FN_IN& P$ G2 P, M3 G& H4 K
- #define DMA_FN_OUT, P* H) |8 ?+ u
- #endif
# C& T7 R4 l# ?! n' D: z: C
5 ~) s" F; _! [. ]6 w. A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* F3 H: I- Z$ ^
- #define STATIC_SHIFT 3% ]/ |- Z9 h" _0 t2 b! |
- #define TCINTEN_SHIFT 20
. b# `, W* ] Q, S' \, B# s - #define ITCINTEN_SHIFT 21( h9 j% k$ E9 i
- #define TCCHEN_SHIFT 22' X: e! T W1 A2 q) p% }5 |0 Q
- #define ITCCHEN_SHIFT 23
0 T$ N+ y l5 B, o - , ?7 p: q- C9 @/ \
- static volatile int irqraised1 = 0;
" k- ^) G2 n2 U - static volatile int irqraised2 = 0;, Y/ y4 ~% t; ]4 r
- ; H! Y$ p5 M* q' c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' S. K8 i, `7 O( x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( Q. `; L' k, k7 d" {; [4 Z- v" a u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- F- H9 I1 `: U" b4 y6 W( z - 7 p: ?+ ^, r( B) Z, p& K0 A2 y& S
- dma_addr_t dmaphyssrc1 = 0;
7 S' Q! a; d7 ^. ^6 a. B - dma_addr_t dmaphyssrc2 = 0;
9 N4 A* o4 g, ]' E7 z+ F. V - dma_addr_t dmaphysdest1 = 0;
& r- V F9 l* \5 s7 l. _ - dma_addr_t dmaphysdest2 = 0;
: B9 _. Q$ D+ K) w" h - x+ _' t# I+ j/ W% Q2 g% }
- char *dmabufsrc1 = NULL;
5 |( q/ f% u: d4 ?( ` - char *dmabufsrc2 = NULL;
9 C: J+ |$ V* T - char *dmabufdest1 = NULL;
* L% P- G. k2 i; x- O- n - char *dmabufdest2 = NULL;
. d; Y; F% `. U# @2 f( K0 o9 z- v9 G - ( _% o# v' I4 K" f
- static int acnt = 512;& |( g6 A: o: ^: S; M, x/ k5 m. l
- static int bcnt = 8;; ^" i! f m) j7 g
- static int ccnt = 8;
! i" @! w- z5 w9 Y& Y
. @* R# e" k, j; c- module_param(acnt, int, S_IRUGO);
( L& Y! h. P h7 s* h8 U% l - module_param(bcnt, int, S_IRUGO);
# S! _. x) p! W - module_param(ccnt, int, S_IRUGO);
复制代码 % S" e n+ l! u# P5 @ o" a
! D( i% c/ p' A7 V) R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 t( T2 l6 g: O1 C, y: z9 @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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
w" ~- A V' I% k" y7 ~/ g) O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 e" {1 `+ Z/ l7 F6 W
2 Y9 s* R5 s/ V+ ]' `
1 {: F2 c% o; S! e3 o5 F, | |
|