|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 _: {0 {3 H$ R- [code]EDMA sample test application
9 Y3 Q! h' {: P1 A; _ - /*
. `6 k6 x& Y& r' C - * edma_test.c- T+ A0 X- `/ C. a8 l. J& I3 I
- *$ A& |, }, F2 t1 ]" N( U
- * brief EDMA3 Test Application
4 J$ m( K, t6 ` - *" T6 \% V' R3 b% I% I6 j
- * This file contains EDMA3 Test code.' C/ w" t) ^# c! u" A
- *" n, t, M& }9 Q: z+ J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 S- p1 G/ l) A- J. h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" q- Z7 H$ p( f& q/ O' v - * TO CHANGE.5 |" @! L# @, Y# ]
- *' _1 q4 k0 D" K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 h+ ?) u7 e. t. a- N - *
& K1 N- ]' I2 L9 {3 Q - * This program is free software; you can redistribute it and/or
+ U2 {9 c9 {. D& n# F - * modify it under the terms of the GNU General Public License as/ U" R2 I5 b9 Z: g
- * published by the Free Software Foundation version 2.
2 Y+ h6 N$ M" \7 [. A6 W - *
0 b) v4 _8 R7 w# F) ~* q5 Y& `5 ~ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ k5 U! z. b4 [0 O( P - * kind, whether express or implied; without even the implied warranty
3 n) d) F- d+ ]4 v- T K, D5 o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' ]: ]! @2 `- U5 _1 q8 Z& L
- * GNU General Public License for more details.
# Y i4 _8 t) g; V' A - */
) ~) z. ?, [! G0 z2 H; n
' _3 b0 D& p0 c5 q+ ?- #include <linux/module.h>6 r; N7 f) }0 [
- #include <linux/init.h>
, h7 s2 u: h/ w# p; R$ T! S - #include <linux/errno.h>
0 f: G# j4 c: m - #include <linux/types.h>( S4 L x8 f+ y5 {; R* v. T
- #include <linux/interrupt.h>
`7 T) P; W$ [4 f( F7 k/ \6 q - #include <asm/io.h>* ]7 d3 }$ ~0 `$ s; P& A
- #include <linux/moduleparam.h>3 M4 m0 ^9 [ S/ P( b4 h8 s3 o6 w
- #include <linux/sysctl.h>
8 x& X1 z8 y6 B - #include <linux/mm.h>) d& N% ]% t, I: l& ~7 n1 \
- #include <linux/dma-mapping.h>
* `+ |5 j; r6 w# l
U4 u Z" ?( [- #include <mach/memory.h>" ]' b3 u5 M1 ]# Z9 r+ U
- #include <mach/hardware.h>6 Z* w/ _% r3 t) H( S# W, x
- #include <mach/irqs.h>9 b0 B' w) B$ o
- #include <asm/hardware/edma.h>
! _3 H4 W% Q. q1 d4 w
! B# C: V! d1 ~3 o; k, m- #undef EDMA3_DEBUG
) X+ s6 u& b. @ a( f( U2 d) k - /*#define EDMA3_DEBUG*/) N; m* { v$ P. a, P
- ( P* v8 e( H0 W8 i; I
- #ifdef EDMA3_DEBUG
5 m/ r2 R# H, m+ d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 m; r" X, c2 Y. {2 h8 P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" g" V0 I4 C- C. n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 W" Q7 f5 |. R8 Q) ]. z* ]5 m
- #else E: ]; [- u \( j
- #define DMA_PRINTK( x... )
% t% Y. t% h+ O! A - #define DMA_FN_IN
. n( i5 u O4 v1 Z: z6 p - #define DMA_FN_OUT
( D; X8 L6 `$ t v - #endif/ \0 A3 o" h0 {; l4 I6 |2 g4 y6 {
3 N. M1 A1 R. ^7 h% R; j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! q: n) }: i+ M9 X5 d5 Q0 V8 I ]! T - #define STATIC_SHIFT 33 l" M( I/ m. B) |4 x
- #define TCINTEN_SHIFT 20
" V8 t9 k6 B* b1 P2 a- _8 e - #define ITCINTEN_SHIFT 21
) G2 u h, O7 d# f3 g3 L - #define TCCHEN_SHIFT 22
1 f2 n6 O r8 }* n- d `, _. s - #define ITCCHEN_SHIFT 23
# Q J0 Y5 W4 w _- Z - ; J* ?' ~* z$ n7 l9 I2 i* s
- static volatile int irqraised1 = 0;
2 r7 P/ a4 g+ p* n/ } m9 k2 e Q - static volatile int irqraised2 = 0;
" }' M5 I1 q+ M4 H$ v - 0 I9 q( O0 Y1 u" ~/ n. c$ q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ }. O- m' P, m) t- T# N! X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! }$ r/ p3 A% m: c3 i7 I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
@! F3 W( H! @* X8 m B( B - 8 Q4 Y9 X- O v8 e
- dma_addr_t dmaphyssrc1 = 0;
) D- K. X" T. C3 o6 U - dma_addr_t dmaphyssrc2 = 0;
) i% @8 r0 F- _9 K - dma_addr_t dmaphysdest1 = 0;
7 a& |8 ~5 w% B. C3 b - dma_addr_t dmaphysdest2 = 0;4 _' B. s7 E3 g8 |- b) p/ A. q
- 0 P; T$ v) X7 T
- char *dmabufsrc1 = NULL;5 S: n7 L1 |, _0 ~! Y/ C' K% x7 ?
- char *dmabufsrc2 = NULL;
% U- X& `# S' r# g! V8 ^3 M! M% | - char *dmabufdest1 = NULL;
; E W% G$ A/ {6 x - char *dmabufdest2 = NULL;7 \6 N" }5 X K7 e
- + S, R. t% a1 T
- static int acnt = 512;
* W1 O- ?) q% M" a4 y- b ^ - static int bcnt = 8;
8 p# c1 @1 Y" @ o - static int ccnt = 8;" m1 i- t( }, v8 z5 y
- 5 Q: |& o& p& z1 C- Z; {, G" }6 h
- module_param(acnt, int, S_IRUGO);6 B4 M; S' u3 F( H/ g7 f/ b
- module_param(bcnt, int, S_IRUGO);2 j. X( T/ N) y5 ~5 z
- module_param(ccnt, int, S_IRUGO);
复制代码
V9 I( i7 t, j2 d
* M4 F! N5 {) y6 o 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 Y% n& u5 s; d* w8 U3 U( A w8 t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: B& M$ g: n; S" r- V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# h' r# R3 R* S& r2 u& W D4 @8 U* k& C
$ V# X3 N; x5 o: y5 [ |
|