|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . Y0 r9 M7 n4 L8 v: x0 k* t5 z! T/ x9 c
- [code]EDMA sample test application
( K1 Z7 j9 ^. H% v) ]( K% ~/ S& b - /*
: q5 I, t9 n+ i2 V+ y% O - * edma_test.c" K2 T$ B8 W, D
- *
, E1 M- E% }7 q( ^ - * brief EDMA3 Test Application8 Q% c0 g! g H3 q9 q
- *! d# e7 O& D" T) a' y
- * This file contains EDMA3 Test code.
6 p6 B- b8 q, f* u l& o - *+ B% [ v% b" {* I5 |0 |1 B* [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
y4 {( k6 X. V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ ^, v! I$ M/ K
- * TO CHANGE.3 C& G+ C' K% @' k4 e3 l# _+ {' ^. ^
- *; y# Y2 h z: d" @! A8 S; r; h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 J- D+ z4 ~, z7 g( a4 v/ }( i+ ~: ?( I
- *
- ~) x- }$ H" V$ Y# ?# q' N - * This program is free software; you can redistribute it and/or
% M8 [3 S2 [8 s" w - * modify it under the terms of the GNU General Public License as& I+ N. H2 Y5 ?0 n4 p, o
- * published by the Free Software Foundation version 2.
+ M1 D# n5 Q, H4 A. x+ W" v - *
- P4 N1 Q& z" l4 D' P2 h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any# G8 `: j- m+ h* r; D6 X& O' ^
- * kind, whether express or implied; without even the implied warranty! M0 Q6 L0 s( m7 c! a! b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 b0 G7 A) A1 g. F6 [3 V
- * GNU General Public License for more details.
2 x+ G' K" u# g3 V# o+ } - */
5 I9 [ c, H% Z* c/ {' x6 d - 3 w; N2 L4 U1 N, R
- #include <linux/module.h>* s8 K% D0 _8 l2 }8 ?
- #include <linux/init.h>9 c. ~% _+ i& |: x
- #include <linux/errno.h>
5 n/ K; i& p! k2 N5 q - #include <linux/types.h>+ b: L/ w- B7 t3 ?: S6 _
- #include <linux/interrupt.h>! y; w# `; s# A/ P
- #include <asm/io.h>9 ]( x8 l) D) L) S4 [% C: r
- #include <linux/moduleparam.h>
1 V7 ~0 [* g, I/ S& f9 M - #include <linux/sysctl.h>) @- M0 T# E$ _! R( r3 w0 I9 b
- #include <linux/mm.h>
7 }! _: h( C& n# ^ c/ Y) h - #include <linux/dma-mapping.h>: ]8 s% i( L, l. b0 {% d7 [
- " r% k" O% U' U' J/ R0 p M
- #include <mach/memory.h>
# j6 [0 j3 u7 }% }/ T9 m - #include <mach/hardware.h>* {+ Z0 t& n1 O; K V
- #include <mach/irqs.h>
* z* Z, l& }/ L# f# F# P) E% p7 ?) C - #include <asm/hardware/edma.h>' F5 L- u" ~* w: ?. o
5 n8 [; o/ o* j0 i+ g- #undef EDMA3_DEBUG0 y/ c( m2 j$ _, w
- /*#define EDMA3_DEBUG*// E0 p! d3 k c! p$ |: E: p; ~" ^
- / P" [; W( x; n* ^8 q$ ^
- #ifdef EDMA3_DEBUG8 l8 A N" k, `# c' f- s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
h2 @+ _; U* @% [4 Y$ m2 b% t! w& Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' S, Z. |" {' X
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 a$ t% |: @8 `
- #else4 ]5 j9 X0 _3 G% A' [+ L9 u# C
- #define DMA_PRINTK( x... ). s/ x4 o7 U0 ?" p: b
- #define DMA_FN_IN
, r" U0 A# t) y3 J% @. g7 Y- z, @ j - #define DMA_FN_OUT
, O' o! e$ e( z% z4 K! E2 }5 I4 z: G - #endif& @- P7 N# y3 v
5 p( [4 t1 R, H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 T- ?7 h) S% e5 B4 X
- #define STATIC_SHIFT 3
, _) a: Y9 N$ h5 s* n; O9 r - #define TCINTEN_SHIFT 20
. ~7 ], ?( K8 w: o/ O& | - #define ITCINTEN_SHIFT 21
, b/ K) B, j7 d! E6 i; e7 l0 [! F - #define TCCHEN_SHIFT 22
$ v$ F) m3 Y8 ^1 v! m - #define ITCCHEN_SHIFT 23
7 V! n1 W( d( N8 A" d6 f; J( u - + K. s3 {/ X2 O2 l" h i- w
- static volatile int irqraised1 = 0;4 P. m K" r% O! _8 L
- static volatile int irqraised2 = 0;2 J5 b$ x$ [* U
9 A+ ~* W8 a, {, I* i6 O: ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- _. q5 C& h8 C* a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ M: L. t `4 g9 {3 v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- B+ K+ I. A1 \, T
- ' q7 e, [3 j* S
- dma_addr_t dmaphyssrc1 = 0; ]2 D5 s2 t) g2 H( W) R" \- y! D
- dma_addr_t dmaphyssrc2 = 0;, M; U$ N( g, D
- dma_addr_t dmaphysdest1 = 0;
4 Q3 K! t2 H# i - dma_addr_t dmaphysdest2 = 0;0 S" O% w" \! q+ p+ P+ I5 p1 t
- ' f9 r+ }! Z' E' W2 z0 A; g
- char *dmabufsrc1 = NULL;% F7 H* e. {$ ]. a, ]7 R4 c
- char *dmabufsrc2 = NULL;
& K# S5 }: [) i, e, I - char *dmabufdest1 = NULL;
" Y; G7 }3 `" ~+ T4 O- m - char *dmabufdest2 = NULL;8 n/ }: f" q! d% n& t y H$ @1 s
! ~/ r- u: I3 w- N5 S- static int acnt = 512;2 r: c4 p" B. Z" `% x
- static int bcnt = 8;$ b7 Z9 ^6 C; D6 J. U* l) b
- static int ccnt = 8;
$ f% Y& f9 q8 b& b - ) d9 J7 _. w c! {7 }0 A
- module_param(acnt, int, S_IRUGO);8 ]% @: Z7 R$ B4 o- G
- module_param(bcnt, int, S_IRUGO);( J0 p- t4 M- l) m. v3 _
- module_param(ccnt, int, S_IRUGO);
复制代码 ( }$ q' p' t" J# b0 A' u8 L
8 r% `0 q8 x+ F7 u$ |, C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ u- c; R, E* R2 t5 c
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 H1 A9 U9 b$ f! M# B+ C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 C+ o( L+ p C. Y
( w, l" x1 k3 V
, n, q7 l2 ^- | |
|