|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 i9 a; X' j5 P; }; E: q
- [code]EDMA sample test application: c2 l* ^) r1 g) s" ]* \" e
- /*5 n" S' y6 m: K' v% k; V
- * edma_test.c
% C K7 K4 h/ E/ U1 ?( u( h2 F - *+ R5 G4 I+ Q# G# a
- * brief EDMA3 Test Application
1 J: W* y/ w( F- K; Z/ k" p - *3 ^$ V) S4 W- `7 e
- * This file contains EDMA3 Test code.7 \ A1 }, x6 m- `% A
- *; ^$ J/ \! \: t/ b. o7 {2 Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 V6 W( \* F9 |) a6 n/ i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& K; F4 Y' i9 \8 A0 q2 ^ - * TO CHANGE.6 }! T8 |; L' F, j% B/ F, i. K
- *6 {# V% i7 Z4 n0 c
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: p0 {0 j( ]( d; I9 K: `) A
- *: X; N ^9 D+ l7 ~
- * This program is free software; you can redistribute it and/or
7 [8 h, r* y6 Y# A% J) B& n - * modify it under the terms of the GNU General Public License as6 s* u) R% D w+ N+ q
- * published by the Free Software Foundation version 2.. d0 S0 x* ^, `0 L! [1 v" v
- *
6 D, Z f# y( I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, |1 T6 k- S. r9 [ - * kind, whether express or implied; without even the implied warranty9 r" E. F; \' [0 C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, h! o N) \+ @2 s# L# D( f
- * GNU General Public License for more details.
6 H: d+ |1 j6 { - */
; q% N0 b5 a+ m
/ }: O4 \9 R9 `2 y/ C9 M% S- #include <linux/module.h>' v6 ?% O0 Y! N, A
- #include <linux/init.h> l5 v! H& f h" G0 Y, ?8 k
- #include <linux/errno.h>
/ q- d1 h; c( L - #include <linux/types.h>
& y: S7 L i# f& `2 e. l k - #include <linux/interrupt.h>9 P: a8 L6 k4 l$ O
- #include <asm/io.h>
" {9 b0 P3 S* @2 j4 M - #include <linux/moduleparam.h>
7 B2 G/ i+ _( p9 \, |( k5 U" o - #include <linux/sysctl.h>4 ^& }8 n L( T% ], x4 p
- #include <linux/mm.h>) @0 Y4 S5 N, K1 v( V
- #include <linux/dma-mapping.h>
& Q8 g5 q6 d6 S9 |
8 y6 v4 Q0 ~! N# i, D1 V- #include <mach/memory.h>
4 [& o" q/ ?( u1 f( b4 l% R - #include <mach/hardware.h>8 m) Y* L- k0 B
- #include <mach/irqs.h>
% p' _& O8 W, @2 s3 }, P) X - #include <asm/hardware/edma.h>
. p) M4 U0 J7 j* P- _/ n9 A - _# K: R' E4 O9 T Z
- #undef EDMA3_DEBUG! q5 V' n C, B# K
- /*#define EDMA3_DEBUG*/+ y# g# R) |; w6 `6 d+ }1 Q
- 5 G* N( u; G& j: g4 J; E* T- T% L
- #ifdef EDMA3_DEBUG
0 X5 g4 \5 _: l: u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ P8 ?+ f$ m6 S, a$ c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
f& |' V* S0 g7 x9 a0 o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; s; n, x9 z8 {% V - #else
1 M8 W' ?, ^# m - #define DMA_PRINTK( x... )
" x' Q, P. s: y# k3 x - #define DMA_FN_IN5 W8 a, E* C8 s
- #define DMA_FN_OUT
- W5 k- |. X1 M0 h8 R) S' B - #endif! b! [, }9 L4 M" c6 i# S5 [
- ! r8 o3 f K' M N ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 k( @" P3 [( o - #define STATIC_SHIFT 3- P7 ]8 ~) ]% ]
- #define TCINTEN_SHIFT 20) M1 g( i E+ e6 Z1 {
- #define ITCINTEN_SHIFT 21
$ N+ M$ f9 O! M( I - #define TCCHEN_SHIFT 22
; D0 l T4 z; W5 c - #define ITCCHEN_SHIFT 23. f) F. b, B* X5 |9 H
- ; ], \" I; Y n. L0 E# u
- static volatile int irqraised1 = 0;9 y1 E# K, w8 L" t3 d. g- X$ [
- static volatile int irqraised2 = 0;
$ t1 h: s8 i7 L) T( Q- b6 Z - 2 w- s* G/ K& E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& w; P2 F+ q% \; j9 X# h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 T* \: e# A7 P) e8 Q4 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 X) B2 ^# n0 Q - 8 ^* a$ V! S4 g {$ {' r
- dma_addr_t dmaphyssrc1 = 0;1 n2 _& R x2 I" J2 a, j3 Z
- dma_addr_t dmaphyssrc2 = 0;9 G# ~7 K! o2 J$ e/ M
- dma_addr_t dmaphysdest1 = 0;2 M. z% x& D8 s( r! {* [% O
- dma_addr_t dmaphysdest2 = 0;1 ]; U# p8 Y) ?4 k/ w& N
- % d8 Q& l' ?3 \' z) V4 n
- char *dmabufsrc1 = NULL;; j9 L d0 M9 f1 Q
- char *dmabufsrc2 = NULL;! `0 W/ p. i/ }" o6 n' n/ d+ U
- char *dmabufdest1 = NULL;
" J" W4 @3 O6 C. ^& D3 ^ - char *dmabufdest2 = NULL;
- T( c+ N' O- I$ d/ F( |0 o/ [2 P
& r, l" ^5 H o% D- B% a- static int acnt = 512;& @) z5 Q; j- g
- static int bcnt = 8;
& e3 i- A5 G7 ]8 }; a$ m - static int ccnt = 8;6 s- O7 I6 O" G: y, N8 M
8 h" G% v* G* P T+ E `5 k- module_param(acnt, int, S_IRUGO);+ H% l0 y5 w" s0 }7 A3 j
- module_param(bcnt, int, S_IRUGO);
7 Z7 F6 @( H0 A7 B3 ` - module_param(ccnt, int, S_IRUGO);
复制代码 ( ~3 ~9 G! ]) O" r8 j
$ l* r. _# E. F+ S$ Z" j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 Q, m. G0 c1 s, O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- `) j7 I" D0 k" _! U4 N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) N* z! _5 V8 g) t( u5 U$ F
# T3 S8 o3 b0 U7 x) c5 Q+ `
5 d+ i5 m! g# `. n/ ^
|
|