|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , j9 B2 f8 L! W Q7 K% B
- [code]EDMA sample test application
2 Y" s; v# }8 @1 F+ o - /*
K% c3 C% v% \4 \6 {2 e - * edma_test.c
/ D4 P: ~$ x1 p7 t R y% g( ^ - *5 w( I3 @' v% Q* a/ D
- * brief EDMA3 Test Application
$ i& ~3 |! y. r7 o6 J" u% B - * y& [, U; {7 W% v. d
- * This file contains EDMA3 Test code.- i+ D, B6 P" q [$ B; t
- *- W8 @ y% d7 ~1 z7 ` G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: p$ P. b9 f. b# H& @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 c' a7 C$ o9 i5 O# M3 A6 m2 c6 | - * TO CHANGE.9 \, R; Y3 k- `. l9 d. ~. G @4 c4 n
- *3 ?: \7 e% u1 \3 w( x" V [" T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. T; U) U. l9 t+ r - *& [5 ]' V8 U, N' @; M
- * This program is free software; you can redistribute it and/or
# a% \% |8 v$ S2 x: A P9 k - * modify it under the terms of the GNU General Public License as
8 S4 z; f! H+ v - * published by the Free Software Foundation version 2.( l( E5 D8 G" a; }3 Q
- *. n; G! g+ q) [0 s: K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) A6 ~' @5 V7 o( X0 ]9 e2 ~ - * kind, whether express or implied; without even the implied warranty$ z' J0 V6 o; |+ S8 F* l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ H) D( `: K4 }5 z8 N) T: I
- * GNU General Public License for more details.4 x* X0 w4 }; X* |4 S4 v
- */
$ G* ^- c) U) j# o7 E
5 Z) z M. ?. p: z) G/ w4 R) f+ a. O- #include <linux/module.h>* t$ [( i8 }% q0 U
- #include <linux/init.h>, K+ d6 H) F0 z5 I2 D
- #include <linux/errno.h>+ B3 m$ }. M6 C4 n$ x: v% Y) b
- #include <linux/types.h>) C5 D& s* q( @. Z
- #include <linux/interrupt.h>
, i5 X- G" `* W% z2 T7 R- v7 i- K - #include <asm/io.h>
; w& P3 b3 o) Z, y" A9 K {/ a - #include <linux/moduleparam.h>
( [. V# R' q5 F" J0 I# m - #include <linux/sysctl.h>
% M% C4 E1 B" @2 d G" ~ - #include <linux/mm.h>
0 C7 \6 J* W" b3 n, W& C6 {# m% R - #include <linux/dma-mapping.h>
d$ U5 g2 }- L/ F6 N
1 d, D% Q% M0 W8 ]- #include <mach/memory.h>
0 P4 U) \9 E0 O D' Q/ d& K: ^' z - #include <mach/hardware.h>
& D* z7 t9 b, F r# n( t' H6 @6 ?/ S - #include <mach/irqs.h>
5 z1 n3 k& f) x* u' P - #include <asm/hardware/edma.h>* c6 F- Q. l0 J. P9 f* p. {
- & P4 o ^% K4 l5 H) \( S2 `
- #undef EDMA3_DEBUG+ P$ m. [7 L3 G4 a
- /*#define EDMA3_DEBUG*/7 F% g6 B- v$ n# O" l3 G
, c* j+ M4 t' F4 |- #ifdef EDMA3_DEBUG
1 G; x p" ~3 }& e( W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). L7 k% H$ {4 v6 M o3 T( i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( g6 S n4 p L; X) G. z. a( P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! ^% k# J4 `& L% ^+ {* q - #else
m2 |+ A. V- k. H - #define DMA_PRINTK( x... )6 n, Y l8 y: _1 ]- j
- #define DMA_FN_IN
7 _! y8 a& P6 R( Q8 m, [3 s$ k - #define DMA_FN_OUT
c4 a$ d O5 m- y7 }# D' p+ U3 X - #endif
0 h T. V, A# G# l: j' O - 0 X; |4 l% @5 b! P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ z# {8 M* }1 c- O; s
- #define STATIC_SHIFT 3! p% ~% j i# [' G
- #define TCINTEN_SHIFT 20: {; _! U: u- ^: I x; _; N8 r6 G
- #define ITCINTEN_SHIFT 21
! |) A P7 Q. L+ c - #define TCCHEN_SHIFT 229 w2 u `, c! O2 o. S+ c3 B
- #define ITCCHEN_SHIFT 23" a. T r# Y; ~5 _
' ]* {; W' }- D- static volatile int irqraised1 = 0;
/ ?0 \3 s( I6 p8 n - static volatile int irqraised2 = 0;, y8 s' r2 T, ~9 O2 t% f" _
( q2 O6 ^# _3 ~( c) J7 {+ L, P6 O: q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ ~+ l0 |: q: S( j, e5 |$ ~' q7 B6 o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 y1 }. V+ \$ [0 S" Z
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ ]$ r% I& |9 R
3 ?8 `: Q7 X, G* P _1 D$ S- dma_addr_t dmaphyssrc1 = 0;, {, c4 W6 @5 n8 J
- dma_addr_t dmaphyssrc2 = 0;
8 u4 r$ {0 Y/ z. m9 r! { [ - dma_addr_t dmaphysdest1 = 0;# p! }% T9 N1 V, v2 S
- dma_addr_t dmaphysdest2 = 0;( w4 O5 `2 S7 J' r
- 4 I/ a3 `. x+ A% n0 R9 a
- char *dmabufsrc1 = NULL;0 O3 P* e/ X/ T% z5 n& D7 J( v. M
- char *dmabufsrc2 = NULL;$ i- E: k1 H% T4 C
- char *dmabufdest1 = NULL;! X" {) I- Z) e
- char *dmabufdest2 = NULL;
% C8 g2 r+ q! e3 W, D - ; J2 @& K8 [4 o/ q5 K- d* u4 X
- static int acnt = 512;
1 r" `3 G0 X: f! N - static int bcnt = 8;6 b$ s1 y% Q7 D6 j
- static int ccnt = 8;( t' N, {# I. i9 M# x3 a
- ! h1 P& k. T1 d1 ]& k4 O) a
- module_param(acnt, int, S_IRUGO);2 D1 y; g5 v& U# i! O$ A: T
- module_param(bcnt, int, S_IRUGO);
8 k4 `2 F/ \- S4 j4 P2 g+ J - module_param(ccnt, int, S_IRUGO);
复制代码
$ h! {5 _$ d) j% p) Y6 ?3 M: t/ W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- Z* \: f* W, i* ^% O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ Y$ g8 F1 g4 u) T- Y4 }4 n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: b3 Y; @6 a9 h9 {3 e
% Q( E6 h% K$ r# ~( u; |8 C& U8 J
6 J# d5 y2 H. `
|
|