|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 |- u$ I9 s0 K' h
- [code]EDMA sample test application
) k/ r \9 i" B - /*0 j3 i* J+ G* h
- * edma_test.c
& g* S% ]/ Z- _4 u" j4 V! }* X- ^% V - *
# g: ~# u0 ?7 ~& s* B9 E - * brief EDMA3 Test Application
3 P, ?2 a6 W: i$ ]. d |; z; k - *
# Z& P+ W9 D- ]3 } m - * This file contains EDMA3 Test code.
: b, @! D2 [3 ^/ y8 i( X$ `, d - *
8 o/ V( ? G3 \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! x/ x- |, d/ r5 Z3 ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( w U- e$ z1 B; y: ^ - * TO CHANGE. ]& d# Y# b7 ^" e( ?, T; I) n
- *
" J2 N1 b- l) V3 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* F* n2 a/ W; [8 x - *
( d6 y/ L1 Z, m9 Q' x5 S- D! o) r - * This program is free software; you can redistribute it and/or
% R8 v" h8 @/ u B - * modify it under the terms of the GNU General Public License as! \6 N7 ?& V: i1 {4 U9 T2 }, k- V6 `
- * published by the Free Software Foundation version 2.) E$ {. y- M' r8 Q3 ]+ z" g
- *
7 {% B+ H" K! O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& y% q- I) k5 h4 { - * kind, whether express or implied; without even the implied warranty
( c# r- N+ d, M; f# n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; D5 S9 I3 L# z7 Q - * GNU General Public License for more details.
7 |! |( x1 z5 ?" j - */
! S; Q6 o* }0 h2 N$ M6 n6 A$ I
6 C8 K4 H! U. U) z5 [- #include <linux/module.h>; P0 u# s# B8 c- u# _2 |
- #include <linux/init.h>
% B- u5 w; v7 t/ j$ C5 g6 n0 E- T - #include <linux/errno.h>* n0 F: U5 F! b i/ j4 n7 r
- #include <linux/types.h>
4 Z4 e% M( q% s5 E3 P# b - #include <linux/interrupt.h>+ L5 c( H/ \7 g" c7 p/ B* C
- #include <asm/io.h>; y4 Z/ H" @- B* |6 Z* {/ G
- #include <linux/moduleparam.h>
7 Y4 T9 ~. `7 j- f - #include <linux/sysctl.h>( v9 P) Y2 g: m! F" ]4 N0 G) G
- #include <linux/mm.h>) @4 Z0 b8 M! D
- #include <linux/dma-mapping.h>
& W% Y) h) _: R# |# r M - {' E/ G. i! z5 c3 {: }
- #include <mach/memory.h>9 q4 J4 |9 ]; r8 i' N; b* E$ S
- #include <mach/hardware.h>1 ~0 b7 W$ Q8 K% p0 o
- #include <mach/irqs.h>
r2 E8 |8 I! t# i, U; T1 E) l - #include <asm/hardware/edma.h>2 w& N9 _9 k" ]1 V( R
: L4 a9 E1 [# ]$ W- #undef EDMA3_DEBUG: W/ ~9 e$ e) A% c
- /*#define EDMA3_DEBUG*/2 I8 r o, f2 t. Z' Q) |1 y
" E1 b& {, l5 _! O$ O- #ifdef EDMA3_DEBUG
/ J" @( T% z% B# R2 |8 { - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 h. s& t$ B& }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 H: `7 @. w8 O) f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& U( m& N S/ }/ u5 D - #else" i& S# {9 | h5 e
- #define DMA_PRINTK( x... )
0 r5 Y" D9 j* m) j, _# @ - #define DMA_FN_IN
: e1 R$ ^) i0 G - #define DMA_FN_OUT
6 |5 ~- o8 C$ _4 O. f5 y - #endif% x1 I* ^$ ~6 t4 L* { w
- 8 { d; I0 c! B6 w- q6 {5 U8 b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ a7 g# N: t' B( R' t1 H k% j - #define STATIC_SHIFT 3% W( ? C% K p; p
- #define TCINTEN_SHIFT 20
: P, }' e* u$ p$ k9 d - #define ITCINTEN_SHIFT 21
# w. W8 b9 F K: }# ~: z! ^+ a& h - #define TCCHEN_SHIFT 22
F3 F _0 R2 Z# p' ~2 s - #define ITCCHEN_SHIFT 23
& c# g* B& b4 I - 2 K. p+ L/ g6 p
- static volatile int irqraised1 = 0;- m# h; H6 W8 r; f) n! ?" [4 q
- static volatile int irqraised2 = 0;
6 q1 {( Q. a) k, \' \9 V0 |
" k. I$ Q7 S7 `- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: z' W( g$ V6 _/ ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; M* ~: F& t% m/ ~, Q0 @. S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ A) m# H1 f1 d: X' ?1 C
9 s( X- Q( C h3 C3 L- dma_addr_t dmaphyssrc1 = 0;2 d9 v8 Q. b5 g9 @* H3 M
- dma_addr_t dmaphyssrc2 = 0;
7 D; b. O# F; o& i9 {+ o" ? - dma_addr_t dmaphysdest1 = 0;/ W9 s7 _( m/ w" e
- dma_addr_t dmaphysdest2 = 0;
! U9 X1 r% E" }
' D7 H, G- _% l2 p9 {* h- char *dmabufsrc1 = NULL;. @% B( r. n4 I" t! M/ i- R: S
- char *dmabufsrc2 = NULL;
( `# I3 S! u3 B4 r/ o4 L! ` - char *dmabufdest1 = NULL;
* y( R" u# W. m: Q3 l( g% | - char *dmabufdest2 = NULL;6 m6 Y! A2 ?. h
- 2 Y- @& D' q4 U% m2 N' U. h& H5 \) `
- static int acnt = 512;
6 R* _ r3 P1 r" u& L: z - static int bcnt = 8;
2 i9 Y2 a6 J2 T2 C' r - static int ccnt = 8;
* O: O- a8 v# ^* }9 z - 5 P0 J; o/ y8 T/ c3 N# G# {
- module_param(acnt, int, S_IRUGO);
+ H I# }2 c+ K; r8 q - module_param(bcnt, int, S_IRUGO);! }6 Z- l1 A# [7 ?; O' m# h; U9 X
- module_param(ccnt, int, S_IRUGO);
复制代码 3 S" X" A; v( K+ W# W0 e7 H) m6 l
8 f; s' a% _* l* L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 s& D2 `# B* }/ w0 K6 N" b8 Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! O4 T6 ~4 G+ ?* b6 ~0 y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' z( m; l3 ?$ c! j, O
" K) X* Q3 Y) }: U2 T
8 ]4 i% ~7 H0 q |
|