|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* o. p" e% b& k7 y. w7 O- [code]EDMA sample test application
6 X# L/ \( S# r; I$ z/ I - /*3 Z6 O; D% d; s
- * edma_test.c
$ U5 H& k, l) y( C2 `; Q - *2 \0 d3 B9 _$ q% I+ v8 M
- * brief EDMA3 Test Application
1 g/ }7 L: v6 i" N2 o3 F' V - *
4 c( O# W/ q- w4 o9 a& {& N, Y - * This file contains EDMA3 Test code.) b& h1 p4 |8 E. t' B; j
- *4 e! \6 B+ `( r" n$ h" A- p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( Y$ Q" M3 x' { K- `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ J4 L$ K! C! a3 K7 f
- * TO CHANGE.- O9 H- e. u3 G
- *
- V5 y% q- X0 m/ S N4 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' D; q3 L; Y* [
- *( {9 Q9 b0 n6 S3 R+ G
- * This program is free software; you can redistribute it and/or
# g' S7 ^1 M4 u! g8 ~ \ - * modify it under the terms of the GNU General Public License as
Y9 ^* U+ r4 q; C6 N - * published by the Free Software Foundation version 2.
7 {: t9 H4 Z, A1 `9 _ - *! B8 i6 n& Y; E- ]6 }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, r& [" X7 U7 v2 d+ C, k& u1 S - * kind, whether express or implied; without even the implied warranty I, N$ a/ x8 j0 ?5 ?' b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% m3 T" ^: e) ^; i6 |4 ]5 C+ Q2 l9 M
- * GNU General Public License for more details.
6 a9 ]: `, V9 J0 J% `5 p' a6 \6 _( k - */
, M% u! q; p& c) M) l' m! O; v
7 q* n' U; T: I% Z; I7 P. ?- #include <linux/module.h>
$ |" b% s. R1 Y; O7 w; o - #include <linux/init.h>& z2 G A$ B5 P; \
- #include <linux/errno.h>
3 ?# C; a C. J - #include <linux/types.h>$ V5 o+ m: L2 ~, S3 @4 ^* j. w
- #include <linux/interrupt.h>' Z( _ B. q9 {2 a
- #include <asm/io.h>1 ~3 Q7 W' |. }" ] u6 b
- #include <linux/moduleparam.h>
% \) `0 k$ B5 h+ h7 s+ N - #include <linux/sysctl.h>8 O- \2 Q \8 b3 v; T' F. x
- #include <linux/mm.h>
% C. `& u3 P: |; i4 a2 }4 { - #include <linux/dma-mapping.h>
5 m* Y; R8 ?* P9 R - + Z n$ p& U" c7 i" Z7 w* l q
- #include <mach/memory.h>
; s9 Z1 a# a* j - #include <mach/hardware.h>9 V# _1 B2 e- w5 r( ^! Y
- #include <mach/irqs.h># I. m/ v5 Y* z
- #include <asm/hardware/edma.h>$ R; Y# N6 D" s- Z. V8 k
6 |, d6 g" p: R5 v3 L6 k3 B& c: g* H- #undef EDMA3_DEBUG6 z- F1 ?' G& B K9 y2 q. u4 V$ y
- /*#define EDMA3_DEBUG*/
h& i4 c% {0 S- r9 e9 u - # J! i1 r( ?6 a- X
- #ifdef EDMA3_DEBUG
4 B1 Y& p$ P' u0 x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 Z* n) G$ @" G' ^6 U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 P" K0 R* y$ r! E3 M8 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
Z4 L2 V; J6 W& U - #else
1 {6 \- ~! {7 B - #define DMA_PRINTK( x... ), J, q; K: f% b
- #define DMA_FN_IN
5 S8 Z9 P; j! a/ [% r# V( B - #define DMA_FN_OUT
" ~6 T/ `- e& A1 x - #endif
+ N/ A4 Z+ L6 w - 7 [( ~, w) X$ s9 R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 w7 ?8 f4 N: j% G* @# R( R - #define STATIC_SHIFT 32 g9 e; T4 S A) i2 c/ z7 p( {! \
- #define TCINTEN_SHIFT 20! e# p+ @! x1 M% `+ P$ E
- #define ITCINTEN_SHIFT 21, O1 x0 G) d' C ]
- #define TCCHEN_SHIFT 22! }- W6 b8 ]- j- C( Q
- #define ITCCHEN_SHIFT 23
% B# z+ b' e3 X7 p B" l - - ?4 i9 {2 p4 X# w( ]! \
- static volatile int irqraised1 = 0;/ C" j: m0 a# {* I
- static volatile int irqraised2 = 0;1 g) _. r" \& t
- 1 C5 R' u+ E, ?# m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 j' W( r9 W# E8 { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
k& v* q+ P$ U0 Z8 C4 h, s1 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; o/ h& ^) Q2 ] O. {6 `7 C# A
- 5 A& m" ?3 V! X) ~- l& u
- dma_addr_t dmaphyssrc1 = 0;8 X- I# a) N8 |; [/ g
- dma_addr_t dmaphyssrc2 = 0;2 ?3 F& c' K1 B' ^: m
- dma_addr_t dmaphysdest1 = 0;) `: U# T- _. N/ R( P; F5 q
- dma_addr_t dmaphysdest2 = 0;
! @0 K& y! l/ g" C; S
& W! q3 ?( W" x5 f9 _. g; ~- char *dmabufsrc1 = NULL;% s/ B: P) Q6 D8 ^
- char *dmabufsrc2 = NULL;1 T6 V1 D: r7 u, t4 I
- char *dmabufdest1 = NULL;
2 D) g/ O i8 O& X, } - char *dmabufdest2 = NULL;
3 f* \( g c W& @& s$ q4 t - , K* A% v- ^* V/ Z3 D
- static int acnt = 512;
7 [% n" {4 F6 P/ d" p# ]! Q - static int bcnt = 8;" l m, P+ p/ p2 L0 m1 _
- static int ccnt = 8; T# Y9 j- o% h1 X5 D: T& U
6 l5 U' a9 Y: X2 K- module_param(acnt, int, S_IRUGO);" N( Q3 C9 P' o6 z; j) y, }3 r9 T
- module_param(bcnt, int, S_IRUGO);
- ^3 `2 `6 g. I' }" r8 n - module_param(ccnt, int, S_IRUGO);
复制代码
4 p$ ~ H; g4 i4 |0 Z1 R; f+ P
/ ]% h, o: w1 I1 s2 k" X- q, S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 B6 ^: B9 `% j
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 `9 U1 O/ C+ E3 d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" o. a/ t1 ~# G) U- q* R- P
+ M+ P0 I% E( m( `
; n/ H. G1 A5 d% @* P( G |
|