|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: c6 c3 t9 B' Q9 X0 i! ]. a6 s- [code]EDMA sample test application
! ]) k% j' |! d! ]% L- u, Q - /*
% G8 F2 A G3 t - * edma_test.c0 u5 j; e: h. w* \+ @
- *
( V4 x5 a/ [$ f1 V( } - * brief EDMA3 Test Application
/ e% A% }& G; H6 O0 ?# {5 r0 n( g - *" i( P- g) |! l$ x7 d
- * This file contains EDMA3 Test code.5 B3 G# A1 u/ J& f4 J3 W
- *; W: ?+ m' q5 T' W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 `" M! U( Q/ I, E. v8 s+ w - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 x5 ~' {9 K A* L' ?! T- ]
- * TO CHANGE.
5 U! ^* f3 d ~! {' G" ^# i - *0 p/ v) b4 w9 b7 Z' Y7 A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- \9 Y6 Z% `; L$ Z: ` - *7 N) f) E* I* y( d2 e- D
- * This program is free software; you can redistribute it and/or
$ N" n6 r$ f# i - * modify it under the terms of the GNU General Public License as0 ~ f; T% f* ~5 j' _4 v& q8 o8 T
- * published by the Free Software Foundation version 2.
# _' y( i) o) o' I; o - *4 I8 o+ E8 k' v$ k# G4 c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* }8 ^0 a' B! |# y4 e" o8 s4 K8 f - * kind, whether express or implied; without even the implied warranty
6 X) ?3 j; [; c; R" Q: h/ t; T' i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 q/ a6 O7 ^% }/ X4 q7 H - * GNU General Public License for more details.# I, E7 L; B( v
- */
- {! p1 A. F$ @5 H6 ^1 S4 t" _5 j! U - + k/ }( f) Y9 E$ s0 Z0 Z
- #include <linux/module.h># s# f& u. i) [4 z& S
- #include <linux/init.h>8 O" l6 D* f. y( g
- #include <linux/errno.h>, {, ^4 ^/ M4 |/ S
- #include <linux/types.h>! `3 M! T7 H, e' U
- #include <linux/interrupt.h>/ ~' i M- u; T4 L3 x8 H; ~/ j
- #include <asm/io.h>" W) Z/ w/ @ k
- #include <linux/moduleparam.h>2 |' ~2 W$ U3 {
- #include <linux/sysctl.h>
- B( R" ]: w) G* q4 X0 I/ r, q - #include <linux/mm.h>! e5 b( F4 J$ z6 Z
- #include <linux/dma-mapping.h>
& p) |4 ^( y2 ]8 I0 V* c& C) ~ - . }! t7 M# ^1 Z0 U5 ]$ }' |& u
- #include <mach/memory.h>
* y* p/ y+ k; w/ C) T) c+ } - #include <mach/hardware.h>
, N# d$ p9 ?. q- ~ - #include <mach/irqs.h>
: c3 q/ c4 \0 u1 j9 u. f - #include <asm/hardware/edma.h>
; ~! `( c% O8 ?; j, K/ M: W* j - o2 P0 t5 R& E0 H$ o' |1 M4 D. c$ P
- #undef EDMA3_DEBUG
+ m& L" d% [+ d& q1 f" k% A - /*#define EDMA3_DEBUG*/
* R8 d m1 b2 d n2 f- \ - ' i5 U1 r8 _- M
- #ifdef EDMA3_DEBUG+ L7 M; Z$ {! S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 P; U$ q: K5 l; S( ?* Q7 Q. G0 U/ `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 i% N* c$ m D; x2 g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( e3 I* v& E6 ^! `9 J
- #else, M$ j$ z) s8 d& E/ W; N$ M
- #define DMA_PRINTK( x... )0 P: {- M- p: C
- #define DMA_FN_IN
" l4 C3 C8 S( ` - #define DMA_FN_OUT4 z$ ?, k4 ~6 y
- #endif
; L7 `+ }2 z/ B) E+ F& S! K
! D0 ?& o% N$ Q' `! X( S' r- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 }) b! ^- w& j
- #define STATIC_SHIFT 3
( k8 f& W! a& l# q4 B( \* y2 h - #define TCINTEN_SHIFT 20- O2 B+ @; A5 K0 n. W; P7 b
- #define ITCINTEN_SHIFT 216 r. |' o* `( E5 R1 `
- #define TCCHEN_SHIFT 22
; z6 P* `2 V2 N, _7 Q - #define ITCCHEN_SHIFT 23* }* t* y$ L0 A; G# b3 t. V; `
2 [4 R5 ?& P5 y1 {9 D0 }! z" P" g- static volatile int irqraised1 = 0;" r$ z4 ?; x8 h" J1 K
- static volatile int irqraised2 = 0;, W) r! Z) [5 p& g1 q2 k
- 2 U4 ]* Z" W, F. j, W& S, }1 `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ @0 \) Y4 O6 f& r2 E7 X( \9 s. ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 z2 e' K1 e# ~7 k: y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" i* O1 `+ V9 f# G/ ^" C
- * t! z' P' n9 G
- dma_addr_t dmaphyssrc1 = 0;
7 ~0 F1 ?5 F: f - dma_addr_t dmaphyssrc2 = 0;$ F4 P2 e, U" i: H# ~2 M
- dma_addr_t dmaphysdest1 = 0;9 V" a& Y) D$ `& ?7 r
- dma_addr_t dmaphysdest2 = 0;2 n& L- B" A# Z
5 d, Q. F: Y, w3 [, `% g- char *dmabufsrc1 = NULL;
. y+ b. F4 a' B; z t: g - char *dmabufsrc2 = NULL;2 x- g+ K, j3 j' `9 G
- char *dmabufdest1 = NULL;. T5 _, h8 I/ }; b' X# P& b
- char *dmabufdest2 = NULL;. e \ ]8 K4 I7 k- d7 {
% l5 o& O. \" v- static int acnt = 512;
& d, h0 Y$ V. \8 u2 g. u6 v1 h - static int bcnt = 8;
5 _9 |% F* O$ V0 }" k: H0 P" _ - static int ccnt = 8;, H$ G! U/ W2 D' ]3 b
5 N7 w3 e- x/ U& Q" N5 c" T) o- module_param(acnt, int, S_IRUGO);. I, \! V$ S6 B0 u6 M3 C' e
- module_param(bcnt, int, S_IRUGO);
( j/ n$ r' w9 u' A8 N5 \ - module_param(ccnt, int, S_IRUGO);
复制代码
3 N3 Y, v& k# H5 x8 x% R/ D
2 L. H8 h/ P8 S8 \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& P7 h0 M( e8 h4 {8 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 M/ O/ i/ p$ m* t p( _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& D S; c* P' }2 p4 H# t6 x
4 v! @+ A7 k; Y4 c5 h
2 Z0 l9 O; `: m% S0 b |
|