|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 L; [/ Z+ E- \( p0 V- [code]EDMA sample test application
5 H; X. I* D) ~( `1 K K - /*
8 Z& I$ \4 J3 T# n, A0 M - * edma_test.c
. X6 j c! ]: q/ y) L - *! L4 X6 ~( K: D
- * brief EDMA3 Test Application+ g( d9 [/ ~8 q$ u0 q6 e1 a* y8 `
- *2 o8 u. D ]# n6 |
- * This file contains EDMA3 Test code.
6 p3 H" q9 J0 T% M8 ^ - *
! ?+ k3 ?# M1 j1 P. M" }" _( y9 R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) j( I. [% e! c; Y% ~+ [; E
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: ]9 Q9 @! g7 j$ y1 \( }) M! M - * TO CHANGE.; D7 p- s* t' h6 K- a6 D- [
- *
+ f6 k% Z! o* @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ L& H, A: d# s" Q1 i C
- *9 f! {6 _; Y( w3 _
- * This program is free software; you can redistribute it and/or6 M' s! ^) u) i r! @
- * modify it under the terms of the GNU General Public License as7 {5 X% A( J5 {8 z* ]9 Q, Z
- * published by the Free Software Foundation version 2.( W- X' L( I% y, {1 G$ n) h
- *4 l! e9 e1 {" F# |
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 ^7 }$ ]3 N" i" @
- * kind, whether express or implied; without even the implied warranty! u/ U- U5 z0 W, ]0 E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. y0 k5 Y) ?: |. D5 n - * GNU General Public License for more details.$ @* |9 q) F7 ]2 x$ u" x+ k9 l3 u
- */0 U+ K0 E3 V" Z9 K- H: L
# E, R$ H' f+ K# P- #include <linux/module.h>
5 j( E L o I - #include <linux/init.h>
) ]/ r6 M Y; o* A' N6 x6 r# G3 F - #include <linux/errno.h>% X4 q- { {- |* x; K# L5 t) c; k
- #include <linux/types.h>5 `. B, Y! }' ?: U( u Q" x
- #include <linux/interrupt.h>
- E' U3 [& R4 A5 u, d - #include <asm/io.h>
7 x3 P# e6 U2 @+ @7 q% M2 O# c* c - #include <linux/moduleparam.h>% ?; p- J4 I1 ?8 S
- #include <linux/sysctl.h>8 O4 L# N9 n3 K9 l
- #include <linux/mm.h>
: M: ^& T2 i% A: ^+ w9 `" ?; @ - #include <linux/dma-mapping.h>9 H" H+ t1 Q3 o- E" Y& P
- 3 z4 Y# P# e7 `7 f: j% b! W+ q
- #include <mach/memory.h>: a2 `0 M- w- J3 t+ o
- #include <mach/hardware.h>+ ^& d, Q2 \$ |+ e2 A( i
- #include <mach/irqs.h> K; N1 k2 n- D! l
- #include <asm/hardware/edma.h>8 T9 x6 ~6 c( a7 d
( {6 S0 R! a/ T* h$ P# U: U7 o- #undef EDMA3_DEBUG
. q, o E* k! C/ f4 j* n$ e - /*#define EDMA3_DEBUG*/$ A( D9 w: a# \" z( j1 ?
4 e! t3 u, L2 J" q; F% l- #ifdef EDMA3_DEBUG
3 E) w9 C8 z1 N3 l: k - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ i( c- I: w' O) O Z( g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ R2 A& l4 |* r2 `6 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
k* K |! z* r' K - #else
. D! G% K( H' q% d - #define DMA_PRINTK( x... )" M' A7 a6 U) p j- ~6 r
- #define DMA_FN_IN: w, X$ o% J6 \+ E7 }
- #define DMA_FN_OUT. q7 i3 k2 |- ]3 a* h# _6 W
- #endif
& Q" ]1 t1 Z1 I# L, H0 F/ ]. s - ! x/ a' l: D1 G* v& J0 B, } ~+ r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' Q8 y8 W- l$ d - #define STATIC_SHIFT 30 J! [! Z( p, I7 O1 }
- #define TCINTEN_SHIFT 20
% ]% u6 { u" j$ P1 Y* H8 L: m - #define ITCINTEN_SHIFT 215 L# X: ^* P2 e7 j
- #define TCCHEN_SHIFT 22
' S# h' f4 B5 `( G - #define ITCCHEN_SHIFT 23+ y2 s* ?- X C( q4 N' K) `
- 4 f6 M% F& c# [, `# Q
- static volatile int irqraised1 = 0;+ X( `8 ?, z! i) m) |4 L
- static volatile int irqraised2 = 0;) g h! P/ ^ v6 R
/ w: Y' M( A! q( A* i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 S' s6 d7 o) U5 V/ ]# z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 U' @( z4 p8 Y' H( U! u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. P( P5 \$ j8 [. J+ p
/ t# [- ]$ m: k: m' [% D0 c, f. ]- p- dma_addr_t dmaphyssrc1 = 0;
2 ^7 o; ? V3 Z1 R' y2 L( o - dma_addr_t dmaphyssrc2 = 0;
6 V6 t; J$ T) Q( X - dma_addr_t dmaphysdest1 = 0;
: `; E9 J' f. L - dma_addr_t dmaphysdest2 = 0;3 p, j/ G3 `: L) |/ `: l
. M4 I1 ~) o$ U0 q- char *dmabufsrc1 = NULL;# E/ V2 z6 q5 f S5 U2 G0 R2 a
- char *dmabufsrc2 = NULL;
3 P" s, S n3 a7 l& g u0 m - char *dmabufdest1 = NULL;3 y, @9 u0 r% T4 f% ~( {
- char *dmabufdest2 = NULL;, [9 k% p, q" Q- z# r$ i
1 ?7 H3 Z# h1 [0 A5 Q; p- static int acnt = 512; L) A' m. C3 ?/ }! v" Q8 N2 Q( k
- static int bcnt = 8;% E5 j, X, o* g
- static int ccnt = 8;
. l5 z0 W* m, B" A5 w" K. f" i0 T - / r% z8 N r6 K( c' G$ P* T( `7 s
- module_param(acnt, int, S_IRUGO);/ M+ @# M$ j- W3 `2 w" I
- module_param(bcnt, int, S_IRUGO);
9 w0 V" o: y3 V4 C7 [' T/ D1 x, v. {# ]7 S- p - module_param(ccnt, int, S_IRUGO);
复制代码
7 U! g9 o' {7 r
: y4 {& |) P, u2 q, c1 @3 f' B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 C5 c1 J8 d9 C+ p2 m+ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) s% V5 }4 v, {# |: v
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' H! h! L* Y" n3 }/ F3 o
7 _. ~' E4 x* c. m: j
, l' L# L" K7 y, R# O2 |% W |
|