|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& s1 W% [& K2 j( z3 R5 y- [code]EDMA sample test application! G5 y8 p/ Q, R+ w* {0 m
- /*
" a( \5 a- M0 h5 N# u" a, { - * edma_test.c0 B) D; w) d# Z7 k3 H5 o6 {
- *
( Z+ }# H2 P" O9 Q- ?3 b - * brief EDMA3 Test Application
4 W2 z. ?6 a1 s, N - *4 t; y! z! }! h
- * This file contains EDMA3 Test code.
) \: Q Z; J" a- X6 q0 A0 k( a$ x - *# }8 ?1 t7 y# e( w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 Z8 n0 K! G4 B3 [9 e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 U$ a$ S+ k+ ~* f, W" Q
- * TO CHANGE.
; Q o9 h8 |" ? - *
5 A5 h8 [0 ~5 A0 ]! G2 M% w1 S! G - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" l ?. e2 u/ k, [& J1 a' j) i
- *
* L* C" b& l) O* k& n% f. [ - * This program is free software; you can redistribute it and/or
- B3 y! ^( R+ q2 ]$ | - * modify it under the terms of the GNU General Public License as
9 {1 I. }7 T0 \. O. ^ - * published by the Free Software Foundation version 2.
n8 | G* E* q6 @5 b1 ?. _& N! w - *" m0 T% G, U& E' E$ j6 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" a) t* f7 P0 S1 i2 e2 v0 L: c - * kind, whether express or implied; without even the implied warranty
y! [3 l6 o3 \0 w% Q0 D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 \, |+ k$ Q+ g" d
- * GNU General Public License for more details.
' u4 [/ O- u. i0 y% N3 y) P - */ [ |( q" n6 V+ v' n
- 3 ]# z$ m) q8 Y4 O
- #include <linux/module.h>
$ M. a$ \1 V- W- q' i - #include <linux/init.h>
& E2 Z8 y! Q1 A! z/ v0 S8 ` - #include <linux/errno.h># m6 \' u& b" b% ^/ K
- #include <linux/types.h>, O, z; J1 w/ V) ?$ G1 r
- #include <linux/interrupt.h>
( j8 B1 i2 E0 x+ D - #include <asm/io.h>: b6 h& I1 @: c& m
- #include <linux/moduleparam.h>+ A9 U$ e# [& b3 Y9 M- ~
- #include <linux/sysctl.h>
3 I5 H% |; [) @- [ - #include <linux/mm.h>
8 P0 P0 H- l, q! x8 @7 W - #include <linux/dma-mapping.h>
. J! Q X0 l1 I! }3 N k8 v. @5 H! I# {
) l& G' }4 t( M' r' V- #include <mach/memory.h>8 b& W ^0 |, U2 J
- #include <mach/hardware.h>1 A: I" l" H! @/ t
- #include <mach/irqs.h>
. a. y) |( p4 ^2 ^6 Z - #include <asm/hardware/edma.h>/ {# ?9 I6 y" X: P
& B( w) H% O2 G0 `) x: y; |- #undef EDMA3_DEBUG+ S _) k u; @7 y$ }
- /*#define EDMA3_DEBUG*/
* H4 @6 s+ J0 U3 ^ - $ m; Q; k6 `% u# ]5 J
- #ifdef EDMA3_DEBUG p( {* e/ P# }/ I- v
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 s( A. r% b1 L$ g' l7 D4 B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 d7 F# r3 I- V6 b4 ~9 D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): B' V8 W" C N0 T2 C: H; c0 |
- #else) I: a1 y5 J* B6 Q) y/ Y7 k
- #define DMA_PRINTK( x... )2 _6 u1 B1 `% i* W% F5 w
- #define DMA_FN_IN6 }( F/ z" G# y) {/ @6 L
- #define DMA_FN_OUT6 w- T* R" O7 C+ D' _' p3 B3 Q
- #endif% X9 i; l5 I. h1 j0 C) |
- ' s' k% V! ?: u1 I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): U* [0 a/ o. u
- #define STATIC_SHIFT 3$ q8 S3 \8 x" Y1 g$ l# |$ y
- #define TCINTEN_SHIFT 20! e, R2 m# f) Y8 ^: B8 ?; Y! z# @
- #define ITCINTEN_SHIFT 21% c, m2 ~ P. h5 y8 }8 D
- #define TCCHEN_SHIFT 22* l# L+ ^0 H. B4 n: d& X
- #define ITCCHEN_SHIFT 23
7 w- v( `0 |3 q8 \* u/ D+ f4 e# c - 6 O F! g- L9 i$ V5 a5 e1 H. f2 q& y
- static volatile int irqraised1 = 0;0 I( \# A8 N. k; R7 Z
- static volatile int irqraised2 = 0;3 D: R! j* n. ~# b3 ?
- / N& _0 F E& f4 L1 q0 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ]! r5 G4 L: N# u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 ?. b- T7 j6 {6 K1 L' Y3 ~ x6 p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* E2 X3 e7 g; z) y1 G& R
1 z) L4 a1 t" L4 ^( ^$ N- dma_addr_t dmaphyssrc1 = 0;7 f" L! L3 N/ O+ C+ P
- dma_addr_t dmaphyssrc2 = 0;
+ L; y9 }3 t( |' \ - dma_addr_t dmaphysdest1 = 0;
: n" m" T1 s+ R; \: S - dma_addr_t dmaphysdest2 = 0;$ R! j) _/ E, \$ t
- 5 A5 b# C( a9 E" K
- char *dmabufsrc1 = NULL;
: W, e" ~- h; W! I* s - char *dmabufsrc2 = NULL;8 B" m8 O" A ~' A
- char *dmabufdest1 = NULL;
U: B K) Y5 \0 u) E. C0 D - char *dmabufdest2 = NULL;
- R7 U$ V% g% k' w( ? - ) O% f# z( j e. V. s/ ]
- static int acnt = 512;# }) J& ?! M; p
- static int bcnt = 8;
9 B; ]+ L7 N" q* f4 ^ - static int ccnt = 8;
. m |( w+ g% q - 8 P0 u( ^7 p1 X4 }: g; d6 F6 w
- module_param(acnt, int, S_IRUGO);
+ }" q5 H. ^$ W h3 f - module_param(bcnt, int, S_IRUGO);/ o4 N7 ^. b9 Q+ y! [
- module_param(ccnt, int, S_IRUGO);
复制代码
: h5 w; B# q4 G; G! ~' p
7 Z2 k4 g& o8 N, p: k$ M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 d y3 m2 A/ Z* \9 i% carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 {7 A% j% e/ Y# [/ ?) i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 x9 {( [0 v4 ~: u4 d
) b D3 }3 N g. a' }0 C
; J6 g" ], ~+ p/ p" Q! u |
|