|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 \+ F# w0 P8 W ~* a V6 q8 M
- [code]EDMA sample test application
! M. d3 E x: s8 \' j) q - /** ]; Q- S6 C1 y0 e
- * edma_test.c0 I+ U8 H2 O/ M+ J% k
- *; S9 h& @5 L% b+ ^1 U. k: f2 e
- * brief EDMA3 Test Application
2 j! f: _! U! v) H4 }! s - *
' v6 y0 V7 @* X& k# S( ]+ n - * This file contains EDMA3 Test code.
1 ?1 Z/ i- X# p3 | - */ G* L9 W0 X; v& r \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& G9 [5 \9 P6 q+ Q1 ?# u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 X1 H4 ]: F- |0 I) {9 u/ v) n
- * TO CHANGE.9 V4 i) o1 s% A" e7 f3 w1 u5 M
- *
7 o0 |3 D2 x2 R$ w2 ~9 z0 v1 z& P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' b$ h. C1 n' ^/ z4 R* \" \2 D
- *4 E' ]) F" ]; d% }
- * This program is free software; you can redistribute it and/or% z, y( `$ J% @0 n( S
- * modify it under the terms of the GNU General Public License as | d! K7 A2 m( e
- * published by the Free Software Foundation version 2. H7 ]% I& H: N! V4 g5 E) W
- *
8 P8 ^% V+ I7 V% y/ |/ S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ a, \5 {* ^; ~4 C X/ l - * kind, whether express or implied; without even the implied warranty( `! x7 ~; k6 s/ Q" \* A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, x# L% U. Y# E5 D3 w& d - * GNU General Public License for more details.
5 G/ x4 y! Y* L3 f+ e! U F9 L - */% ] }2 J% w% J5 z
- 0 L7 A% e6 X* U
- #include <linux/module.h>+ N! o7 N! l5 X8 }: r
- #include <linux/init.h>: z/ h' y& `* I4 Q$ C/ Y3 t% q2 ?+ k
- #include <linux/errno.h>
4 |. e1 v/ s% ?: N% O - #include <linux/types.h>
* m" W% D+ L9 ]' l, r! C$ t8 q - #include <linux/interrupt.h>$ G( [7 a+ @7 c6 c) v
- #include <asm/io.h>% r; Q$ T6 Y* L4 {9 C/ j
- #include <linux/moduleparam.h>3 O o( g" S7 D) v6 W& q* e1 B
- #include <linux/sysctl.h>
- c/ r* s9 V2 E# u - #include <linux/mm.h>
* h |2 q$ _3 S6 N - #include <linux/dma-mapping.h>* b! {+ C( s; I( r( ~
- ; L3 p% K2 x5 i" s% s# j- f+ w3 `
- #include <mach/memory.h>! w; i8 K' Y+ }7 F
- #include <mach/hardware.h>
8 ?) |4 _' w4 k - #include <mach/irqs.h>( U/ V4 r# ^2 P$ }# s; @
- #include <asm/hardware/edma.h>
6 X& b) p/ D; v1 ~1 i- q
+ u, l3 n& C1 k I- #undef EDMA3_DEBUG
( R1 d' x; r3 t3 X - /*#define EDMA3_DEBUG*/
3 I/ Y: U. B* Z
. h) Y. f |' t- #ifdef EDMA3_DEBUG
L4 T) V/ x; [, i' d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& A3 W) w$ m) |( S- y) t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 ^ ]& [/ a1 K3 }) t, u
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 w& G- d. S3 A& y$ r. S
- #else
/ L+ ^+ h8 [+ J; G" q# g1 U - #define DMA_PRINTK( x... )
9 k: k$ a1 B! P" x. P: [6 W - #define DMA_FN_IN
6 T- s, l9 H- L( m& w - #define DMA_FN_OUT
k6 A8 G& T: a- G: u8 O( P& q - #endif
4 A5 F1 g# d$ F* b* h+ S W - 1 J4 @/ y: y! v! @
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). ]3 K: A2 ]$ ]1 F
- #define STATIC_SHIFT 35 v7 P. R& \) |% ^/ C% x
- #define TCINTEN_SHIFT 20& k0 ^' D+ }) q' R; ?1 x6 g
- #define ITCINTEN_SHIFT 213 \' \7 c* a8 h0 G! X: f- I
- #define TCCHEN_SHIFT 22
2 T1 V l5 k0 T" m! ]: V1 z- k U1 ] - #define ITCCHEN_SHIFT 23
, o! `* M7 k1 F! X q7 }4 n - 6 C I4 V8 [" U0 }) u5 L
- static volatile int irqraised1 = 0;8 A4 X% E0 q: q6 x6 w L2 `" m9 ^0 \
- static volatile int irqraised2 = 0;7 n; D9 ~, `( }9 d( E# }1 W
+ h' A6 |* }6 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 L, X. h* P' c) S+ u8 H7 [6 d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ A4 q- v+ V2 X6 S0 V% m" {& Y$ d3 ]5 ?3 a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ M$ r0 C2 w2 e# b; x - * U9 p2 \3 C, ?1 ^* k
- dma_addr_t dmaphyssrc1 = 0;
& h5 X/ p |8 U P1 m0 I1 a _/ A9 t6 e - dma_addr_t dmaphyssrc2 = 0;' a* P S( G0 Z- \- I
- dma_addr_t dmaphysdest1 = 0;8 L8 D6 X. ?& N, m
- dma_addr_t dmaphysdest2 = 0;" z0 ^8 y i- ]% @# L: |0 C
- 6 m/ |0 Z; G ?0 A7 Q
- char *dmabufsrc1 = NULL;! W4 ?; v1 Q/ Y
- char *dmabufsrc2 = NULL;
9 h7 C/ o- J: y5 q - char *dmabufdest1 = NULL;. A7 I% t8 N4 i8 a: \( i) h3 n
- char *dmabufdest2 = NULL;* d9 _- j* O6 z
/ E5 z3 ?& k4 d/ L+ S$ G- static int acnt = 512; w# j# f; I" q
- static int bcnt = 8;! W! C, e5 J' W* V
- static int ccnt = 8;
2 j6 r" I- X- M/ A - & W# ~4 W( O$ I1 u/ i
- module_param(acnt, int, S_IRUGO);
1 q. M G$ }9 y; I5 ^6 J* R( k - module_param(bcnt, int, S_IRUGO);9 f6 w0 G; R8 C8 x! _
- module_param(ccnt, int, S_IRUGO);
复制代码 7 a$ A% g0 ^$ h/ ?$ C
6 u+ T# P _" _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 @7 u- m. V# I5 m F) ]0 Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. o+ h/ ]( A* y& D3 } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# c/ o& `8 p, }! k
4 `( I& D/ ]- }, B4 G
* Z7 `' t5 x5 A" {1 _$ U l |
|