|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 L9 s- H& _$ v2 c5 Y3 a) _- [code]EDMA sample test application
g: ~" ?: r6 j - /*
, m& C0 K; N6 R+ \ - * edma_test.c
1 [9 }# c7 Y: Z4 ^* y - *+ w0 W- W" q7 T( D) g7 W& }
- * brief EDMA3 Test Application
+ ^' C+ C' D2 o# p! T5 F - *% u t& ^. \# A: H
- * This file contains EDMA3 Test code.
& r0 M- p- w2 ^" M0 ~" [ - *# R1 [* ]5 j& ?% Z2 E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& H5 P, O8 q' n; ?% a. Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 F; b. {2 V' D) n. u4 Y8 h& W - * TO CHANGE.
7 U: T# x- |1 l2 \/ R - *! @* p- b3 ~- b4 |: ?/ O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- P1 r6 Z+ k) ?2 [. g) _2 b - *
1 \* N! d! Z) E3 X% O - * This program is free software; you can redistribute it and/or5 a* S% ]0 X+ E6 R5 n/ \
- * modify it under the terms of the GNU General Public License as0 d" ~0 s+ J- `( r
- * published by the Free Software Foundation version 2.! b' K* _) ~# A) e
- *, ~: z8 ]& D/ ]8 m! m7 H# z% B8 B+ H1 A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& O2 F y# i; r. m* A - * kind, whether express or implied; without even the implied warranty* i9 A6 o+ L2 L3 | d( d7 c% q3 f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- j7 {0 w E7 r& ~
- * GNU General Public License for more details.
) {6 l% N5 k& W# B" |2 R6 R0 a - */- u$ F A) F9 W* G5 Z3 W$ E5 o
- 2 [8 p, K$ }& M8 A! [
- #include <linux/module.h>: N" O( l- o$ x, Y2 d7 V. j
- #include <linux/init.h>
0 N8 e; R' i9 y1 L9 C) q - #include <linux/errno.h>, t& G h8 i( e* b, O& U5 n
- #include <linux/types.h>
0 W# Q8 q; w/ ~7 \1 g+ B+ ^ - #include <linux/interrupt.h>
6 |8 ?, ^1 w; ^8 L* R7 G$ e$ | - #include <asm/io.h>
& l9 o# B; R* _ - #include <linux/moduleparam.h>6 }" W. M& R) u/ W% G! D7 w
- #include <linux/sysctl.h>1 S4 j* C; H- m- v7 q7 m
- #include <linux/mm.h>/ j9 U' w6 H; D- @/ J: }
- #include <linux/dma-mapping.h>
5 ?! @5 a) F' P8 {3 W, B4 K4 m - 6 d) Q; ?9 P& z' c9 B" }( S6 t
- #include <mach/memory.h>( `4 Q; c, {. J4 w) D
- #include <mach/hardware.h>
1 g7 B& J$ h/ E& A - #include <mach/irqs.h> b, H; I) v. L; N2 Y4 D) Q" o/ _% j
- #include <asm/hardware/edma.h>' c! A4 ] `! B, `( F* B; B
1 u- B4 t# r; c$ w, G+ x! k" U# A4 p- #undef EDMA3_DEBUG
/ l' a0 U& H) j9 u/ p& V, Q - /*#define EDMA3_DEBUG*/
% `6 G+ H, v4 ?0 H$ b+ X. e0 e
/ P) ~+ ~5 n. e, t- #ifdef EDMA3_DEBUG5 d! Q! c9 n5 Q' _- W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& X3 a" \/ w- J& c% @/ C$ x7 b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" n9 ]- p8 d% N6 ^5 k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 j7 Z& G9 d! ~7 B/ B
- #else
/ O8 {) B T; T4 H - #define DMA_PRINTK( x... ): \# V+ Q8 W) N! P8 N! H
- #define DMA_FN_IN4 P2 F! e/ L/ g* x
- #define DMA_FN_OUT- i$ d& O3 X$ ?7 b, E
- #endif+ c) R5 I& [+ C! g0 [9 Z
- V) r! `, `* a9 _- @
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
}/ Y: |( H& G4 x4 l7 Q - #define STATIC_SHIFT 3
: w* \( Q, k: N5 P0 O6 V# Q - #define TCINTEN_SHIFT 20( l/ o+ [/ }) c: ^, v% Y9 Q6 ]
- #define ITCINTEN_SHIFT 21
. \* O+ V9 P; Q) A& F - #define TCCHEN_SHIFT 223 L( ^1 V# f/ v/ Z
- #define ITCCHEN_SHIFT 23
! v) e* k( ^: l' z - % k) ?4 {# ?" V+ ?; P4 G
- static volatile int irqraised1 = 0;
5 D3 M5 q9 x# x3 t5 s' b - static volatile int irqraised2 = 0;
: V; j1 D" H- X% X: R - * |: [0 M9 d* \ t
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 [, f* T% F; s; g1 k/ ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 Q! _, X" g" Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); v2 R$ \( E# ?" \0 F
- 6 v" y6 X; g" T4 G- @% K3 A
- dma_addr_t dmaphyssrc1 = 0;. R( ^% r! C$ n. X
- dma_addr_t dmaphyssrc2 = 0;0 }) K( d5 `$ I: f4 N
- dma_addr_t dmaphysdest1 = 0;
/ X4 f Y5 P2 w2 q5 B* d" Z+ @ b - dma_addr_t dmaphysdest2 = 0;
, M7 B& j/ {% u0 Z - 8 w. s6 P, @/ D0 M1 L
- char *dmabufsrc1 = NULL;2 q( o$ l; c" g) }4 Y
- char *dmabufsrc2 = NULL;
! j6 E1 K1 _0 Z2 l+ L$ t* e, L1 C - char *dmabufdest1 = NULL;
6 j, F) p/ Z3 p/ p& d! {$ h' f1 r. g. w - char *dmabufdest2 = NULL;. E3 C/ w/ n( s" F2 N+ v; F
- 4 M1 |) b% A6 Y: g2 H( ^0 S* ]
- static int acnt = 512;
, X3 j* ?+ M; B8 A | - static int bcnt = 8; y8 _9 C1 F$ ]5 i, @2 M8 c
- static int ccnt = 8;4 L% S X% @9 [, y0 W! T- x: V" ?$ @
- % N4 ^8 {- T q/ u
- module_param(acnt, int, S_IRUGO);
; {( n1 a9 c6 K% O, i2 [; l/ ] - module_param(bcnt, int, S_IRUGO);/ w9 F+ r& q7 V" Y
- module_param(ccnt, int, S_IRUGO);
复制代码
" G" T, r# Z9 J' C: H* L/ p
, I0 ? B: H6 J: p) S5 v6 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 A# r! L) H( \- q' s! h9 Y( P- ?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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. }& e+ n& @5 u4 \: m1 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 H; [ Y& Q* R; `3 W$ L2 ?, s
% I3 A4 w8 j0 |. X8 E0 \2 V- p' W6 I" F& h
|
|