|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% Z( u/ m( x% \+ Y$ L5 B/ K- [code]EDMA sample test application
. d/ U) D1 t q% F- N/ b - /*
: m8 z: Z; Z2 m" R) w - * edma_test.c
$ g) E" r$ Y# Q0 U5 g/ d - *9 e1 z) {5 p, y0 y6 j X$ l
- * brief EDMA3 Test Application7 ~0 m. d) q) |. _" Z
- *
4 W( p9 K8 J/ Z0 H. D; M' O# ^4 @ - * This file contains EDMA3 Test code.
, |2 A' B4 @9 L - *
/ J( b5 k9 ^+ C: o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& R% o6 ` k7 p& s8 g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. |4 J- k5 R# C5 V) x
- * TO CHANGE.; Q1 j$ [$ i& |5 }
- *
6 }! u' G" a) m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 n% F3 l, b: A b - *- O6 D8 Z' J( v1 V+ n
- * This program is free software; you can redistribute it and/or
6 V$ l+ ]- m$ \) O6 v- c9 x - * modify it under the terms of the GNU General Public License as
" b' B+ ^& G# U5 y' s! d - * published by the Free Software Foundation version 2.! d" i$ E/ F$ q
- *
$ w& z' f1 Y) f8 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( e/ K! K2 ~" u) e% Z _8 k$ y - * kind, whether express or implied; without even the implied warranty5 g H3 W p7 x7 g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 l. A: h/ f. q9 D3 m, Y' b6 z. P - * GNU General Public License for more details." ]* x6 v( ]( x. q
- */
! C B1 D6 d) @
' l- N' O# O& _/ [. `- #include <linux/module.h>
: \! I# x% q- j- y4 W5 B - #include <linux/init.h>
+ h+ R. ~# ?4 p3 ` - #include <linux/errno.h>& Y& P$ i3 S! X
- #include <linux/types.h>
, y' A* B) {; P$ ^' A4 l - #include <linux/interrupt.h>4 d8 P: G9 c. j8 J& g( b
- #include <asm/io.h>
2 o8 R1 N; \9 u. [9 U4 ` - #include <linux/moduleparam.h>! k3 Y( a6 `8 Q+ _, e8 t+ m
- #include <linux/sysctl.h>
4 r; J' f5 m$ g( V - #include <linux/mm.h>" Z/ p. \$ X0 u, n; B9 M9 c# N7 _
- #include <linux/dma-mapping.h>
, V: o* w7 N$ d4 n }
7 p1 A9 d$ H% @- #include <mach/memory.h>8 x* g; G6 \+ D
- #include <mach/hardware.h>2 i2 y. {, a$ t/ \+ j2 P' |
- #include <mach/irqs.h>
+ z/ z0 v6 Z. b - #include <asm/hardware/edma.h>
) O" b. Z) \0 x' g2 B, m - + H9 X2 |! p) Z* h% ^& q
- #undef EDMA3_DEBUG1 R0 }! h2 O$ r. e* {
- /*#define EDMA3_DEBUG*/8 v% q `9 T- [, \: N6 m
2 S. Y/ V& @; D2 o- #ifdef EDMA3_DEBUG4 l& @. _" P' X0 @; y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ B4 K9 e7 U* a1 \) O. l% M& h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 o# r' Z2 n3 t' I4 X% o) [ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% `6 s7 q. k+ k" s a- Q1 _6 v6 {% O - #else
6 c0 }3 x' K! P - #define DMA_PRINTK( x... )5 N- F( o5 w, k1 q3 y8 \
- #define DMA_FN_IN
: U3 v% m! a& d( L - #define DMA_FN_OUT* a# L: J) | I5 Z" w, g
- #endif7 t; O' |4 i* S
- 2 ^7 r Y+ r. [8 Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 ~( [5 ?2 g. k4 Q' F - #define STATIC_SHIFT 3
6 _2 _6 f' C; Z: I - #define TCINTEN_SHIFT 20+ F" W* t: i; q# r0 F
- #define ITCINTEN_SHIFT 21
; `) _ l8 }) i0 L - #define TCCHEN_SHIFT 22
# u1 ^/ Z" M5 w% t( k6 f" J - #define ITCCHEN_SHIFT 235 \/ E2 Z- y( v
" O, F; Y# {/ c+ X7 c6 ^4 b- static volatile int irqraised1 = 0;" K8 G! Q2 Q& Z% g1 y
- static volatile int irqraised2 = 0;
! l+ w) h# G6 y
8 f8 t: Q; S9 h5 L" J1 w2 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 O" o+ t; x, T2 b& R8 p' C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* C& P8 g) D/ d0 G2 t0 i: s2 P; g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 `1 \; @( i7 a/ \4 k
8 _2 o4 d. o6 }" G1 a9 |5 ]- dma_addr_t dmaphyssrc1 = 0;
: H n% D8 r9 z( A0 Q1 [ - dma_addr_t dmaphyssrc2 = 0;
; o2 y+ k4 j% x/ s) d4 Z - dma_addr_t dmaphysdest1 = 0;' i" `8 V9 |0 h: C! B) d) J
- dma_addr_t dmaphysdest2 = 0;
: P! F! x4 E: G5 s$ t - 0 P4 P, C6 N% J
- char *dmabufsrc1 = NULL;
$ E' p# g$ P3 G8 w% T1 ^ - char *dmabufsrc2 = NULL;+ L+ z0 I& N9 z0 {, H$ ^
- char *dmabufdest1 = NULL;
4 {, p+ m4 y j( i$ |( p" ? - char *dmabufdest2 = NULL;7 w. X5 U# l& I) l& }- H
* q) I) N$ H' w" S' k( s" [0 B- static int acnt = 512;
2 a! c& e" ]- h' I - static int bcnt = 8;
7 j% w6 {; e6 J0 q9 y# A: u - static int ccnt = 8;
6 F: {- w' y. E1 ~. ]) S3 }
. L7 V3 {6 Y8 L# o- module_param(acnt, int, S_IRUGO);/ _/ {1 D1 f# d) Y2 R( ^
- module_param(bcnt, int, S_IRUGO);4 H u' z) L6 i0 j( K+ v
- module_param(ccnt, int, S_IRUGO);
复制代码
$ x1 G' R) M! N
3 U/ {( f% T3 I; @8 T* T: b. H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# E( {' H/ |0 W! l$ Zarm-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 u+ ?7 d9 {$ {' Z$ f5 _; V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, e# {- R9 k1 g/ i! O3 ^% H3 S/ d; x5 m" w8 E4 d1 r
0 l9 M+ p9 ]7 T7 F0 I5 [ z3 V
|
|