|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 w+ ?$ Z+ M! ^ R9 C) o& f e) s- [code]EDMA sample test application" s z4 Q% ^& U
- /*
! A: l& b1 B( Q! |4 K8 r( S - * edma_test.c6 R# E# k1 c! c
- *: W- \4 C: ]! U" ~/ r n& e0 V
- * brief EDMA3 Test Application
* a4 e- l0 T/ {/ I. m* L* e+ d - *8 T1 U& ^7 {: M( `$ o
- * This file contains EDMA3 Test code.3 z8 v; @! F R( L
- *
) w3 a- W P2 _- I* H! ~. f0 K: v6 e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# X+ t/ ~# H/ p* {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' s9 U5 w7 U [" Z - * TO CHANGE.
7 D M. _' x+ j5 n - *
$ e( l5 F4 Q2 R: ?9 j/ L4 z# k8 E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; _! p/ J0 l. A* q9 V - *
4 s$ O( Y0 D2 u' z7 V7 b - * This program is free software; you can redistribute it and/or
; \6 m+ f i& o: a n H3 O - * modify it under the terms of the GNU General Public License as
7 e& Q, Z" w0 x - * published by the Free Software Foundation version 2.
6 M% q1 c- S9 S7 B- E6 X: J" K - *
5 N O! s2 @0 j2 G6 }5 R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 [: e7 K5 E+ [8 C
- * kind, whether express or implied; without even the implied warranty
5 R, j" e2 Y& R; \9 o! x2 n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 {4 B: {' G1 o7 u: i0 {
- * GNU General Public License for more details.0 \; f; M, W8 {. a# Q9 o
- */
3 W. |- \ M$ C' c: X w/ _5 s
+ T+ I$ n6 Y8 ~7 p- #include <linux/module.h>
6 R, R5 r7 k; P. U* c - #include <linux/init.h>' v, m1 U/ t% U
- #include <linux/errno.h>
0 a" ^. ~! {* o s - #include <linux/types.h># e6 J! \5 y3 C$ a) f
- #include <linux/interrupt.h>6 D$ R7 w0 Q; u
- #include <asm/io.h>- J6 i3 c& Z0 f- l
- #include <linux/moduleparam.h>$ c! a* Q9 W" e# W& J! @% R
- #include <linux/sysctl.h>
* h' l( h+ A4 ?* G# \) A - #include <linux/mm.h>; k; `( j' C+ C) m
- #include <linux/dma-mapping.h>) O5 D" T8 `6 H
- ( }- i( i* l5 e9 [
- #include <mach/memory.h>
6 n7 c$ ^% U3 K - #include <mach/hardware.h>
/ w8 d% A7 N1 ?8 c5 D - #include <mach/irqs.h>
: \' k; l, a/ L5 d; H, P- V - #include <asm/hardware/edma.h>. z. a$ C l4 M- U8 | ]. G
# u/ O. c8 s3 }0 h% | ?1 }8 g- #undef EDMA3_DEBUG. b; z7 b% R8 U1 C
- /*#define EDMA3_DEBUG*/1 B% N/ L" J0 m8 G6 k- y5 h
2 A6 g3 Q; P# f5 z- #ifdef EDMA3_DEBUG
* L& d3 t- a0 t% Y4 b! T$ } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); j! u' i* y' b% X9 F: X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" z a: R* t2 ]' h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" \7 n7 G: k/ C8 [9 D" i - #else
) ^% f- O. g8 _3 J - #define DMA_PRINTK( x... )
: S) ~- J2 [8 O* } - #define DMA_FN_IN! t7 u; Y4 ]: I+ N+ c! d2 p8 ?# o
- #define DMA_FN_OUT
; O+ M$ Y- _( V, h G6 V" ~ - #endif+ j% V+ ~& r! b
- 4 b) N! ?% ~5 `
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( F8 E( _& D$ T& d0 `3 Y - #define STATIC_SHIFT 3
! w2 K$ ]+ [! g; Y - #define TCINTEN_SHIFT 209 q. e1 [# t# d0 P: J
- #define ITCINTEN_SHIFT 21
$ P: G8 o4 G$ t3 p2 K5 } - #define TCCHEN_SHIFT 22/ B4 Y2 F: ~$ N: q3 C- ?1 p! N
- #define ITCCHEN_SHIFT 23
2 ^2 S U6 `* ~. B: P - / d6 s# \% n- s" H7 k5 D. P0 ~
- static volatile int irqraised1 = 0;
+ g# c# E2 J1 L) m4 _4 O9 L - static volatile int irqraised2 = 0;
+ D! [6 a7 z9 l2 a& A
! i5 P1 F8 ~ J6 I" J* B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% f' `7 B4 ~1 u! T, o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, P, ]8 `: w0 N9 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 K7 a8 y" }2 n/ h4 w6 r
, Y9 ]4 H$ ]% e* ~! f- ]. X- dma_addr_t dmaphyssrc1 = 0;8 g4 j3 T% H2 v ?1 A+ L
- dma_addr_t dmaphyssrc2 = 0;
0 ]8 p8 M( S7 X5 `; D- U - dma_addr_t dmaphysdest1 = 0;5 W9 l( \, z7 F0 O# v# J
- dma_addr_t dmaphysdest2 = 0;
2 J! K' C5 u; H; ~ - 8 \9 h& H% d8 G) ?2 w9 B
- char *dmabufsrc1 = NULL;
, v/ S4 y. U0 O7 W! K - char *dmabufsrc2 = NULL;
- ^1 b/ ^8 t, W$ i+ n p, j - char *dmabufdest1 = NULL;0 ~$ e! M* G2 |. j8 o
- char *dmabufdest2 = NULL;
s& ?1 |- Y1 b
, o, D: Q; F. i# ~; {) H! O, B' ^- static int acnt = 512;* @1 u, p8 B; Y
- static int bcnt = 8;6 [6 x8 m4 @8 L% r; q
- static int ccnt = 8;8 a, R5 O2 T# X2 G( f
- ?- c) E0 b9 @' _- L5 I
- module_param(acnt, int, S_IRUGO);/ z) S- V, f- ^5 E2 F, c7 _/ v _1 A
- module_param(bcnt, int, S_IRUGO);
" x5 M9 R2 w6 z7 H; n6 s - module_param(ccnt, int, S_IRUGO);
复制代码 ' ~0 t, T+ r) B& ?
; q' \3 S" l$ H! t1 p9 l# H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 U7 O9 Z$ X, H/ ]. A8 M* [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" \/ N6 }3 |" X3 }' B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. C& M% _# l/ T5 n( a
( P5 g4 U/ F* F4 O o, B! C9 \% d/ L6 F
|
|