|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - {" w3 g6 K% u, {% U
- [code]EDMA sample test application
9 |% X1 Q+ d' @2 a6 z3 B3 x - /*9 X3 C- b2 h& o" A8 ~
- * edma_test.c
) A I& m; ~# _' B7 m! W- |3 ^0 y - *
. h u( A& ]: a5 H( U# z: \4 X; V7 v - * brief EDMA3 Test Application$ `) J: N$ A9 E) w' E& l
- *3 r9 {, U4 G: d0 a9 {+ c3 J
- * This file contains EDMA3 Test code., s, \+ z; z# c. W, W
- *
' s/ K6 w1 H0 B; V4 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 L$ o' @ ~, N3 D6 ?0 a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; n% W, `2 N+ A# w: i# l; K: J5 z
- * TO CHANGE.8 B$ E8 H+ c: H) O: V, O
- *
0 Y* e. ? R5 \: ]) L+ r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 }1 a! g1 B5 \% U - *6 Q. c$ F% m/ G% x5 P
- * This program is free software; you can redistribute it and/or9 I) Q2 { g; \3 ~% ]6 Z( o
- * modify it under the terms of the GNU General Public License as
P+ r0 f0 t M - * published by the Free Software Foundation version 2.) e U1 A% k1 ~- y
- *$ i- o1 g3 s9 n+ M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 P% T; d/ `* \% _8 E' u - * kind, whether express or implied; without even the implied warranty
6 U, @' {6 ~$ A' y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( w8 W9 U! N2 [0 Q) V8 s
- * GNU General Public License for more details.. \% y1 A: I. p0 y+ ?) ?1 V
- */
$ a- ^; c. u- B. U - 1 h" w+ O0 `3 `3 `, U( W, v
- #include <linux/module.h>
- I, L! T1 W# g - #include <linux/init.h>
`+ l/ [; u# m7 }3 f - #include <linux/errno.h>9 [& k4 S% |1 t! Z! g2 F
- #include <linux/types.h>
% R: E' @4 W5 h# l6 I% `6 f# s - #include <linux/interrupt.h>0 g' C# S8 P2 R8 P2 P
- #include <asm/io.h>
$ [" L/ [; k9 C& A% I- g. l - #include <linux/moduleparam.h>* a& U+ D3 t7 e
- #include <linux/sysctl.h>
; R: ~1 f% c% d3 w5 U2 }8 c0 _ - #include <linux/mm.h>
- q5 P8 k( w, L- d - #include <linux/dma-mapping.h>) B4 a8 p0 |, G
% ?, x, ~( b$ _' d' G x- #include <mach/memory.h>2 F2 v h- C; [( i( L
- #include <mach/hardware.h>: f/ Q7 z' E& v3 G
- #include <mach/irqs.h>
4 N5 v3 U+ Y' k% |! q. ~* g3 j$ G, S* ^8 l - #include <asm/hardware/edma.h>
( s; v0 c$ K! G+ x: R1 y% D - 3 p, y2 k3 E8 O- H3 ]/ V; n
- #undef EDMA3_DEBUG1 y7 M" L8 g2 l0 A7 v9 h+ e
- /*#define EDMA3_DEBUG*/! F6 }2 M( v$ q4 c& `
0 t/ T) h9 a. ?5 |/ N* b$ G3 E% Z, g- #ifdef EDMA3_DEBUG
, U: E5 T' E! k$ V8 t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- ]1 M S& q. G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 D" C% l5 R$ u- m% ~( ]" n: ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% B6 ~8 X6 Q0 x; l - #else
$ M x3 u8 P0 M1 e) S - #define DMA_PRINTK( x... )
2 W. w( `& A& M6 d. f0 h - #define DMA_FN_IN
4 z! ?* _: O' W- N2 X3 ~/ X - #define DMA_FN_OUT
* f- P% t: n7 R- ?: u - #endif8 ]$ I) V1 f8 L5 v4 |6 A& _
- ' G& ~- `9 _& S1 A% Q+ B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 ?- c' s. k0 ~" g; J$ N8 m - #define STATIC_SHIFT 3- Q4 X+ f; z0 K8 B r- D& L! ~6 B' U
- #define TCINTEN_SHIFT 20
( _4 q0 c! H& d/ G# ? - #define ITCINTEN_SHIFT 21
! I) B0 k+ h& |0 x; i9 ]7 \9 a3 j - #define TCCHEN_SHIFT 22
) e( `1 c) M( s) E - #define ITCCHEN_SHIFT 232 a$ p: {) _5 Y+ i1 Z
- 0 Q- U8 K( b; s( \" j
- static volatile int irqraised1 = 0;# T* O- z* V; H. _# v; y: n: \
- static volatile int irqraised2 = 0;
- d0 C$ u1 U) m2 u- b
& z6 U2 C: a( S y( [$ Y2 Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ s, `1 y; X8 M- v- W/ L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 y. ^" y) G7 K5 ]/ A' ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; p2 P) K, a- \" h U9 ~) \% [ - - A/ s# g. q6 ^. m: n
- dma_addr_t dmaphyssrc1 = 0;" z- T+ m4 i* b
- dma_addr_t dmaphyssrc2 = 0;( V: f3 q. _8 j
- dma_addr_t dmaphysdest1 = 0;
+ H, I; e4 P- t0 v( _/ N+ u( z3 ? - dma_addr_t dmaphysdest2 = 0;0 U# c# B5 ?: y) l3 f# x& x: v
4 g1 s( a+ r) x& x! B5 W- char *dmabufsrc1 = NULL;1 ~! @& J8 v0 O4 Y" |3 Z. X- |1 y- n
- char *dmabufsrc2 = NULL;
% b- w; M1 }0 T: R B7 L8 c- l* e - char *dmabufdest1 = NULL;+ `1 v, I( I7 k) l) F, S
- char *dmabufdest2 = NULL;% y) I! m: A# d9 z
$ b) Z5 F' I) k5 e' S- \; F2 v- static int acnt = 512;3 J$ [! ], W" \, E
- static int bcnt = 8;) E- E, z: t* s
- static int ccnt = 8;
& ]9 n7 u0 J# E
0 i& o5 c m( g7 @5 R- module_param(acnt, int, S_IRUGO); K) h" A9 L8 o# S4 Y# j
- module_param(bcnt, int, S_IRUGO);, p$ T+ A) n- `& D! ]2 C0 O
- module_param(ccnt, int, S_IRUGO);
复制代码
5 \, G$ a2 W& f4 F
" o p" C2 b+ f; }8 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( D. u3 E, w1 T$ @2 ~1 U3 q# K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 B. k) M, e0 a; V7 v) S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 s/ x9 W! _: {; r+ H v2 t' ?$ R3 o# U
: g( O3 |0 ^/ J! D; s( V+ r+ U4 W6 m! N$ K( k. m L( Z5 Q
|
|