|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 p# p. Q# [( S* Q* L- [code]EDMA sample test application% W# Q) S- h. _7 V
- /*
) a! m- \& S3 }1 Z6 i5 [( ]$ j0 x - * edma_test.c$ j' U( u% e5 z" F. [- B5 u
- *6 G6 I$ u0 p7 \. i, M- D
- * brief EDMA3 Test Application
7 {( X+ o1 p: ^* \8 c" c! _' }; l) _ - *6 p8 k/ P: a$ i5 o( v; @7 z% r
- * This file contains EDMA3 Test code., e( ~* U! e# `, @) z* t+ F* y/ c* y
- *; N% U1 d9 J4 R* P9 z4 S- r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 @6 W7 c% b! s! A! f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. o6 [; R3 t0 Q$ }3 Z3 M8 V2 v' q" o - * TO CHANGE.
4 \$ y! T$ w4 x$ { - *
3 Q2 |3 P& ~5 O3 M" p9 w* @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 j" F: I& @/ w5 D% }* M/ L9 ?3 ^ - *
! `/ _' x& T. P/ j0 J3 `" K - * This program is free software; you can redistribute it and/or! I/ b3 ?; |; f, ]5 ^; i6 o
- * modify it under the terms of the GNU General Public License as) f( A; y9 F& ~2 m' t, j# x
- * published by the Free Software Foundation version 2.% e8 K7 r7 w. Y( `
- *
* e x/ X6 a* k - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
b7 q# H. O/ g- Z* L; M( {5 _ - * kind, whether express or implied; without even the implied warranty
: r5 b" S! z9 K& W* l- ?) O: C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 N: u2 Z( @( O8 @9 b
- * GNU General Public License for more details.1 d7 Q( ]6 x4 K# y& D' D4 O2 W$ e
- */
; k8 ]& h A5 ]* P
. R4 J" J2 J/ ]7 C- #include <linux/module.h>
! y' N# c9 ^9 x1 x7 u( m1 s - #include <linux/init.h>9 U3 B# ~; v# ^9 i1 W( x
- #include <linux/errno.h>1 K6 }: \/ ?! |( q8 `
- #include <linux/types.h>3 L8 l+ m" W: S# p% N5 R: U+ |
- #include <linux/interrupt.h>$ v, [7 w7 i) b. h
- #include <asm/io.h> v9 I4 `4 p |3 [# Z y
- #include <linux/moduleparam.h>
* q! b6 [. s$ F6 r; z - #include <linux/sysctl.h>
4 Z& `" W1 @; D5 `" Q; w( ]8 x* |8 G - #include <linux/mm.h>
0 \ y, p+ L( y7 d6 c - #include <linux/dma-mapping.h>
0 {' \: M/ V1 u - + P- V- ], d6 S, W9 V2 w: ?! R( ^! a8 ^- T
- #include <mach/memory.h>: s* m0 r9 i# P- I
- #include <mach/hardware.h>
( q" w) S: o! M/ v' d9 h7 |& s4 i1 p - #include <mach/irqs.h>8 `4 e3 r; w2 T* ]# s4 ~- \
- #include <asm/hardware/edma.h>
" H' D7 r. I, j% ^3 S2 f$ `
# C! D" s$ ]7 @$ y, h- #undef EDMA3_DEBUG
$ I% q; L4 N( J( |4 {) s+ i - /*#define EDMA3_DEBUG*/1 Z- q3 D: v( c- m8 y
; ?" W6 ?0 |9 ^+ U" k9 x) o- #ifdef EDMA3_DEBUG
8 s6 d1 j3 J# q( S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ |4 U/ e6 U: B N' V3 _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 i3 A, o2 B% [5 I, O* ]
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 ~- @% z) X3 S! ^5 [( Q
- #else
. `* ~ N* |, Q3 V( s+ _2 ?/ A - #define DMA_PRINTK( x... )3 N+ V! s) `# m* i
- #define DMA_FN_IN; V/ G, G, B) m8 P6 x' ^
- #define DMA_FN_OUT. x2 [" ^! v& d+ [ f4 ^8 k; o7 }
- #endif
" E. H4 P$ C% { - ) m7 L* j: l5 B: g- {& W N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ U9 Q6 w. l, t! o1 d. F0 T& u" x" q
- #define STATIC_SHIFT 3+ f4 S$ \6 h+ C+ }
- #define TCINTEN_SHIFT 20+ M$ x) \4 y. n' K4 S" s5 _" {
- #define ITCINTEN_SHIFT 21
! a# G0 |4 B- \/ b9 Z - #define TCCHEN_SHIFT 226 P0 E! L: a1 D9 m* q# ~
- #define ITCCHEN_SHIFT 23
1 O- f* `$ N" F4 L6 S9 q - 7 P5 [9 G+ i, Z2 x9 ~
- static volatile int irqraised1 = 0;
. Y/ G& ?! D3 m, i - static volatile int irqraised2 = 0;
, m7 J; I* q# E* {# `5 { n1 W0 y) { - 4 O* K$ m9 m/ b7 ?
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( m* v+ `1 |! l! k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- @# {- _% W7 J8 a5 T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 [2 o3 T- e- N1 h% [3 R+ u
- - W+ j# I7 C$ Z8 M
- dma_addr_t dmaphyssrc1 = 0;
% U; k1 t0 ~4 w/ S - dma_addr_t dmaphyssrc2 = 0;# b, f) [* u) ?' @0 W/ @
- dma_addr_t dmaphysdest1 = 0;
5 J% x- {" K1 Y0 ]3 L7 X- Z+ b+ L9 k - dma_addr_t dmaphysdest2 = 0;4 `# R" z* h4 E+ I
- 3 z6 y, P' n; e9 S$ @
- char *dmabufsrc1 = NULL;
; C4 K' q1 W8 a1 ]' i - char *dmabufsrc2 = NULL;& ?6 w$ `4 ]7 b
- char *dmabufdest1 = NULL;8 j: {0 ~% m% ^+ L/ x
- char *dmabufdest2 = NULL;; X1 _0 l' j9 a
- 2 x/ I! L/ v _& g4 a" g
- static int acnt = 512;4 D& p. b2 ^6 D/ o
- static int bcnt = 8;
) X1 i2 I5 u5 e& u4 r! {, L - static int ccnt = 8;
8 s3 o8 ]- H( i6 D
( ~, \8 o L* ~+ D- U# w |8 K1 G2 j- module_param(acnt, int, S_IRUGO);
F& a$ p4 f3 ?0 F - module_param(bcnt, int, S_IRUGO);
# t- v! v2 U7 {) j, y( G3 c - module_param(ccnt, int, S_IRUGO);
复制代码
5 I$ z" G) m* ?
5 ^1 M: f' o3 h" D+ M! i1 k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
w Q1 ?2 L( @' f# i3 m; Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, T, Z+ ~: e. k* M7 D1 j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 M) v, {! b' B# e; Q9 X
* e9 H5 ]/ Y0 w& \: _7 w# }
. |+ Q! l! R2 G/ z% o |
|