|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: i$ ~* @ |" u6 C( h: Q4 o- [code]EDMA sample test application
. B+ e. ]- \0 E5 b6 W4 F6 U - /*1 U, T% b. \, B4 X8 F! ?5 e4 j
- * edma_test.c
, n) W' P [3 T7 C - *
( c# U( K9 ]( H4 n! V3 q - * brief EDMA3 Test Application
- B9 b, u6 u7 y- G( k n! m# u8 } - *
/ t5 B# i, Q5 s! U7 y* \) p - * This file contains EDMA3 Test code.
& F* N5 A: I W8 @" @4 Y% e - *
c/ r) Y7 }0 T5 _! e7 R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE `7 k$ ^/ Z# m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ f* z6 Q0 S7 X) R" h! I - * TO CHANGE.
) D0 P% i" g2 D* C; G1 \ - *" L6 b* R% {# Y# Z" T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 G# N S% g; D6 E9 ^- Z3 V
- *
. ~. `8 m4 C7 T( ?/ P - * This program is free software; you can redistribute it and/or
4 t( C9 Q4 R# @: U - * modify it under the terms of the GNU General Public License as
# ?! u2 u2 M$ T) m- v- ^, { - * published by the Free Software Foundation version 2.: |9 ]3 {" X8 q- m+ f3 A
- *+ K+ ^# {' J2 d9 W$ s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 P, i% P& Q5 Z, F" ~+ N! [
- * kind, whether express or implied; without even the implied warranty5 e9 h) o0 |7 p2 z- d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- `7 V6 {* T; u. p/ z - * GNU General Public License for more details.
" k% V2 @5 @0 U2 f% Z9 s - */5 m" Q u. L2 C, P# [
- ( ?8 t# [7 o7 P1 ?
- #include <linux/module.h>" S% K3 M3 A# ^/ O! F
- #include <linux/init.h>
7 k" X9 N3 n1 L: \, I: u$ L - #include <linux/errno.h>
1 O. \+ H2 Q' S7 ?, t0 F/ } - #include <linux/types.h>& V- W9 c6 m: k+ N! ]9 a
- #include <linux/interrupt.h>
9 G* X K ^" i: A6 ]( B+ [3 ` - #include <asm/io.h>
. y n% E' ?+ M; h( l3 u7 v - #include <linux/moduleparam.h>& | I0 d- U' s5 z7 `7 o0 Z
- #include <linux/sysctl.h>; c- c+ ~/ }* m
- #include <linux/mm.h>
; d" B) Q5 C: H; C5 E - #include <linux/dma-mapping.h># r& I# w, ~ d" q; `; o' T
- 1 V+ y% [! y- A% v7 E D4 d
- #include <mach/memory.h>
7 Z5 Z: y& k; N B& F+ D/ R6 N! { - #include <mach/hardware.h>3 _' {! A9 }: d4 f. O6 x( A m
- #include <mach/irqs.h>+ K2 r. N- O4 x0 T# ?- O; R% T
- #include <asm/hardware/edma.h>
+ F( g- [* Z5 ^! H; w& O
' g$ L g: t5 a" R; T% t8 D, C- #undef EDMA3_DEBUG* \& X9 `- d' @* q. ]
- /*#define EDMA3_DEBUG*/
8 Y5 W( n8 f5 k6 `8 Z - 7 p4 S! X& h) {. _
- #ifdef EDMA3_DEBUG* e0 o; H* [9 A: }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( B. n% H+ \$ h' \: i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 h: H6 n, g' V( d( R! U* U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 M6 V4 j. c9 T- ]
- #else
: v1 M9 W) u: u - #define DMA_PRINTK( x... )
. A" ]% P6 G. W" R) d, M0 i - #define DMA_FN_IN& P$ U( j4 ^6 o4 t2 Z& d, d
- #define DMA_FN_OUT
|: x" z* [! |" q' n' I0 S: e. t - #endif
5 X, Q" \( a4 B% c- c+ c - % S& P# N# H+ _: ^5 _8 `+ m8 c' r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 P. S* L. E( u% \+ {7 K
- #define STATIC_SHIFT 3
/ ^1 t) m1 }; u9 E: ?" E: r - #define TCINTEN_SHIFT 20
9 ?3 u2 R. ~% O$ M, g$ y; M - #define ITCINTEN_SHIFT 21
" w. f8 {& l/ t4 B& B$ S3 Q - #define TCCHEN_SHIFT 220 v# }% o0 z6 y
- #define ITCCHEN_SHIFT 23
( P B1 W3 }; x- E
( P4 e" ~2 f5 y& F7 {3 a- j5 {' O* g3 u- static volatile int irqraised1 = 0;- a: \! g, g. ?/ r4 a8 F1 P' e. X7 P! N
- static volatile int irqraised2 = 0;; V. }) C6 Z; N0 K" { d
6 I! r# f% N8 r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# l H0 a& t% K! @) }) w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 p( `) h4 @& ]/ n! D& z( I; ^ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); W* _" R, G8 P1 i7 ^
- , R* z( j, n$ O7 R; ^
- dma_addr_t dmaphyssrc1 = 0;! w: L+ b- F$ t0 e1 ?% V
- dma_addr_t dmaphyssrc2 = 0;* \6 i: z# P) k- ~; e# ~ p
- dma_addr_t dmaphysdest1 = 0;
. W! ]* w' s/ u+ n1 V; a9 w - dma_addr_t dmaphysdest2 = 0;
6 _5 E* l. S# W6 c2 r - % D! y. E' f- L0 }
- char *dmabufsrc1 = NULL;
: H6 H a/ U+ G0 ^7 C; ` - char *dmabufsrc2 = NULL;% }8 P2 l. F9 v5 f2 ~
- char *dmabufdest1 = NULL;& r3 Q) F5 d: D8 V5 X, A% ]# O
- char *dmabufdest2 = NULL;
0 b& w& r+ `0 L& M* D2 Y4 X7 f - ' \: l4 ^* ?: I5 `
- static int acnt = 512;% Y1 o0 n& ?5 e1 x
- static int bcnt = 8;. D# d4 K6 I4 |5 S1 [# f3 ~
- static int ccnt = 8;5 ? u5 k9 ?0 p; P; U
- 0 w$ e: N8 ], g4 {; y1 x
- module_param(acnt, int, S_IRUGO);
) N4 i: H1 h7 p- i - module_param(bcnt, int, S_IRUGO);+ @+ ?; s0 [8 }2 u
- module_param(ccnt, int, S_IRUGO);
复制代码 9 Q( y% F' B) y8 C
! U7 [' U D. t% ~0 h, H7 B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ {) k8 s9 T6 j- y8 W- m. 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; o6 d: f4 H$ A y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* [( p1 I7 a. U0 q8 t" b2 l; j
# X0 M; \; T& J* l& A6 [7 {0 V& W3 D2 S) Z7 ^& A
|
|