|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 e* p5 B& A; g& }6 J5 f- [code]EDMA sample test application
0 U$ Q4 e1 G9 M$ I' Q. W - /*
$ J! G0 j1 b/ V - * edma_test.c, T1 [" X/ Y! k& w l* O
- *
& n; {9 p2 P) y3 J - * brief EDMA3 Test Application
Y$ D: S9 ^* q" B1 O/ | e% P - *
" R8 a: r; g4 K - * This file contains EDMA3 Test code.
8 B5 V9 I/ \* D% N7 W* {: F! c - *( C. m" l8 ?7 T x! z) X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: z8 K# l' G- F Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. n+ {( X9 s. {' N7 z" Q8 ^ - * TO CHANGE.; \. K8 R4 V1 W. D/ U, L* W
- *
( Z- m. N( j9 A3 y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 l2 _* w' ^: |" ?+ J
- *
! Z9 @5 ~' L1 C) W9 W9 [$ i - * This program is free software; you can redistribute it and/or+ ~, c/ C$ I2 R, w0 f
- * modify it under the terms of the GNU General Public License as$ D/ ^% c, _0 f7 E! Y% ^: h
- * published by the Free Software Foundation version 2.
' ?8 B6 Y) h/ r+ A - *0 z- A/ ?5 @1 K( v* x2 J o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 x) X% Z- I' `5 J$ a, o3 O
- * kind, whether express or implied; without even the implied warranty: d( F3 k1 @; j2 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 K. k: v8 q' k0 U' V/ E - * GNU General Public License for more details.
1 q' W `9 `! K% ^7 Y: q4 Q V - *// s' F$ O5 k9 A! W1 O7 q; ?3 s
% E& B+ H5 p: U6 Y: ~& m3 o, z- #include <linux/module.h> v1 U- C& }6 y1 \$ I+ G
- #include <linux/init.h>4 G* @* @* w5 P) v9 s7 k W
- #include <linux/errno.h>
0 ~$ y# D; p8 p: R+ f - #include <linux/types.h>* O9 C+ t$ q/ z7 i
- #include <linux/interrupt.h>
* l& N% i' a' @6 \ - #include <asm/io.h>
D* \/ G. M4 |7 @9 j1 P2 h6 Y - #include <linux/moduleparam.h>
% h9 T/ d! j# u9 T' L1 \ - #include <linux/sysctl.h>
! ]( E& A+ \6 _. n/ N6 V' E - #include <linux/mm.h>; n/ B5 C9 ]. V) Q
- #include <linux/dma-mapping.h>2 r8 _) d8 _& y+ Q; _& V4 \2 W
- , ~$ {0 r# Y0 |# N. z; X9 ?# [. J5 v
- #include <mach/memory.h>
# s/ [5 o8 Y3 l9 g7 L - #include <mach/hardware.h> L; A# F3 ], g4 @
- #include <mach/irqs.h>& f. b. K* X: I( q6 W m2 J
- #include <asm/hardware/edma.h>3 t4 E$ [) Q( N. N
- & ?; g3 I& P( ~3 Y+ c e8 Q! M
- #undef EDMA3_DEBUG
7 O6 \3 d' U7 L2 N% _5 M# s# ` - /*#define EDMA3_DEBUG*/
+ c8 ]) I4 G' s3 G* g+ ` - ) g/ \) v) f6 z' T
- #ifdef EDMA3_DEBUG0 L/ z2 ]- Q" J' a8 Y0 D0 R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 x6 Y0 {! [4 [8 {: z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ J' t, ]$ h4 I; b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( I8 p2 i- B9 T* G! m
- #else
+ r5 h/ I% R3 p, u9 Y0 e; j% p! b - #define DMA_PRINTK( x... )# o1 ~1 Y" L3 @
- #define DMA_FN_IN
3 k! W6 `' z; w - #define DMA_FN_OUT
! t/ S# N- [" p" f - #endif
* s& l2 r0 @' K
: @5 C% h9 [7 Q9 c% Z# K# R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( i! u' j7 A9 h* | - #define STATIC_SHIFT 3
2 d7 }# S9 Q/ |( z7 N - #define TCINTEN_SHIFT 20; e8 p8 i$ S( [3 n, k3 y& r! Y
- #define ITCINTEN_SHIFT 21
6 s; V1 i! X- K' h; \7 l- i/ P - #define TCCHEN_SHIFT 22
) L! ^- b3 h. A2 x" N% O - #define ITCCHEN_SHIFT 23
& b- ^: ^; ]/ t4 x/ l - # Y& P- \" [+ d( P
- static volatile int irqraised1 = 0;/ H1 ^6 z' U) x2 o9 F+ G3 v
- static volatile int irqraised2 = 0;! U1 a6 v/ D1 r* Q1 q1 y' E
; N B8 K" q) U7 `) E b! x4 }3 ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* M9 \; @( P W6 f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
c8 C: c$ n( l. I* t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 K$ b& X1 a0 U: K4 [8 @( I0 i
* v- t( S, U' d6 K" W0 O3 w3 N- dma_addr_t dmaphyssrc1 = 0;
, w9 x& Z. `$ U( S, v - dma_addr_t dmaphyssrc2 = 0;
7 b! z4 H) }1 K9 N - dma_addr_t dmaphysdest1 = 0;
& Z3 @; i# g) w) M3 n0 f7 p2 k& z - dma_addr_t dmaphysdest2 = 0;( |2 N3 E9 b t( _! }) n+ ]) R
0 ]6 g; T7 _* w. A* {- char *dmabufsrc1 = NULL;- @/ G7 F+ d+ o' o5 k; d, q
- char *dmabufsrc2 = NULL;( l" D8 R$ }$ \' V! S9 F
- char *dmabufdest1 = NULL;( P. T. c0 y9 |" S
- char *dmabufdest2 = NULL;
0 q% S- _ G* Y1 N, \' O' P8 b
3 X- s' H' K* M( ], M$ I1 z- static int acnt = 512;( Q: j% r3 M' ]: H
- static int bcnt = 8;
( u, W) f2 P4 `! i* V - static int ccnt = 8;* Y( q$ Y8 _ Z
2 B; y0 a- k' A- v- module_param(acnt, int, S_IRUGO);
/ Q8 h/ f# P4 Z1 h' Q# m - module_param(bcnt, int, S_IRUGO);3 ^3 `0 _- R( A. u, O6 [: a
- module_param(ccnt, int, S_IRUGO);
复制代码
8 Z* Y! [% u! ]/ s) K$ o1 v5 a0 t$ r5 L2 y* [3 A6 q# q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 T5 V- p4 _$ d* Q; |! rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. O7 C5 _. l' h0 O0 U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, z y% o- [" m" K0 M+ Z( I( a3 j9 S
3 F7 t2 _ U0 E" f* L |
|