|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) k: S+ Z' L8 u' o" i) L2 e- [code]EDMA sample test application
, s7 o5 o! C$ p7 v* K - /*" a# M+ s/ g, g% f! D- R0 ~$ D
- * edma_test.c
& P& N! |) f7 H9 B* z1 P, I - *
) r" q. x3 g7 y4 { - * brief EDMA3 Test Application
) b' V! I2 J3 _2 ^0 {; Q9 G8 Z - *
6 u: [% S! D6 B - * This file contains EDMA3 Test code., O1 y' s5 ]9 l7 m
- *5 R% h: C: ?8 D4 h, I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& _2 I- k$ I9 O% |' D/ t6 x! {+ a# U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# c) `. P0 {9 }# H7 Y
- * TO CHANGE.
$ g! a4 S( p2 h - *# {: k6 x- R" x6 m; ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 f c0 X; R, {( R) u; A3 L9 b - *
% `9 \' A) P3 N; Z2 T# s) x - * This program is free software; you can redistribute it and/or
4 G1 M) I% v. z$ P F - * modify it under the terms of the GNU General Public License as
# F0 @* n) m" M, O; G% h - * published by the Free Software Foundation version 2.! E8 b! l; e) C! ~9 \" D
- *
4 e8 o7 n |) r- D, e, ~0 U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! |9 I) X- [, L$ I - * kind, whether express or implied; without even the implied warranty% i0 i! c( X% V' @6 c% r. \
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. ?. R/ h" N2 V$ |
- * GNU General Public License for more details.
/ N: W4 Q8 Q( k; Y1 q - */! K' c1 @, K/ ~3 U* v2 k( K
- 8 }/ ~6 G" v. t: j2 d+ ]8 V' k
- #include <linux/module.h>8 ], A+ n" D o
- #include <linux/init.h>
; U# f! {) ^" c8 q5 g& ?+ n - #include <linux/errno.h>
2 I# a& `7 J. t+ Q/ T+ q* v - #include <linux/types.h>% ^% T& h% ?+ a* c; h2 q# E
- #include <linux/interrupt.h>1 [4 n3 E( i) X/ T% o* {
- #include <asm/io.h>2 R, }% a# ^8 l0 t
- #include <linux/moduleparam.h>
2 i" A @0 {2 L6 Q2 g4 H0 c& c - #include <linux/sysctl.h>
- B) }* F' w0 a2 n# k( @6 O - #include <linux/mm.h>& \+ V0 l" C! V" W, C' ^: v, j8 o
- #include <linux/dma-mapping.h>
~' K9 D* G5 Z
T! C. L/ x C- #include <mach/memory.h>
. S6 [/ h( E+ ?4 E4 [# N6 } - #include <mach/hardware.h>6 m4 _& I( z# \2 y/ A2 q' z9 A6 v# R p
- #include <mach/irqs.h>
0 ^) q' N- D5 {' R - #include <asm/hardware/edma.h>% L, J$ c0 O$ y9 C$ |
- & J' n! t. P& w
- #undef EDMA3_DEBUG
9 y' \+ q4 c3 B - /*#define EDMA3_DEBUG*/
( Z% ?( L/ Z) } ]8 A. F! K% V
5 [& v5 F8 C! o5 {+ h- #ifdef EDMA3_DEBUG% w1 u9 G. ]4 j" G. Q0 B
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. K; p( x# i5 l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" z5 ]# m" E- V. Q# {8 r$ g
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: U$ \% s/ E- ?: L5 Y" m5 e - #else
- ] T( R2 j5 E) y3 e - #define DMA_PRINTK( x... )& j' j- y" w5 U1 }& a- {
- #define DMA_FN_IN( U. V) ?, {" G
- #define DMA_FN_OUT b. [3 b3 n8 V) B7 c
- #endif
) e% G: ]# W8 ~, x
: Q7 x; n8 Q% S# T4 G1 C5 S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 i4 S$ z+ Z6 I1 x7 C& Z
- #define STATIC_SHIFT 3
. n2 s: B/ o+ Z* w; z - #define TCINTEN_SHIFT 20/ y, R' i! r; ?3 H% G
- #define ITCINTEN_SHIFT 21 _4 F1 T9 |7 [- H9 f, a7 j
- #define TCCHEN_SHIFT 22
* ^# Q1 t/ v2 x( j2 y( A2 h0 r - #define ITCCHEN_SHIFT 23% `+ Z3 v0 F' U) ^5 {
- ) }% c4 @5 M" l9 B! C* b: w, ^
- static volatile int irqraised1 = 0;0 B- m# H+ J/ r& B- f3 T" _
- static volatile int irqraised2 = 0;0 x* V6 J4 z5 Y' j# W* i- t! i
$ f; s: s0 J4 c/ V- `3 ?. E1 O) W+ f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 j$ p) e2 W4 P' { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 d9 R* L/ r$ |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 g+ y+ c. H' S8 g7 f @1 n - $ @2 u2 X7 k% B, z2 V# B0 I6 L A
- dma_addr_t dmaphyssrc1 = 0;8 { Q# L/ O/ ?% q# ?
- dma_addr_t dmaphyssrc2 = 0;
8 W) n& T/ G+ U7 C0 L$ k - dma_addr_t dmaphysdest1 = 0;& K. g. W0 @; {* b0 a+ k: ~7 O7 p7 V! A
- dma_addr_t dmaphysdest2 = 0;7 c# d8 f5 D- w, [
- 2 Y- E) W* k8 ]) O
- char *dmabufsrc1 = NULL;* V7 z3 J7 A1 g1 ~5 r7 @
- char *dmabufsrc2 = NULL;
, T+ z+ L" q7 e, T$ M - char *dmabufdest1 = NULL;2 K2 P# N- _+ ]6 k
- char *dmabufdest2 = NULL;2 c* B% Y: e% Y4 _
# T* A4 o; Y& w0 K0 [$ J- static int acnt = 512;. e' [& L4 X: Z/ w- |
- static int bcnt = 8;
" e* i/ x3 R3 J' e1 { - static int ccnt = 8;
5 U6 P2 I9 ]" K- B7 m* {8 I9 G - 8 y$ j. U' ]. I; o+ N
- module_param(acnt, int, S_IRUGO);0 _8 B6 L5 {1 _5 k' n9 w5 W9 a
- module_param(bcnt, int, S_IRUGO);6 C/ `4 S; N |' v( z
- module_param(ccnt, int, S_IRUGO);
复制代码 , S( y' ]% v; c, V8 [; E2 ]
$ f' J% D' x( `' y. Q' w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. p4 `$ s' [3 J H4 i$ I. \3 z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 `; d) v5 o; s- U0 M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 z/ Y3 q# r; p2 W* b4 j2 v, `
7 L5 U) G) h; M7 d& |" w t1 V# _( ^, f1 V
|
|