|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - P: V1 M! Q; Q i0 F
- [code]EDMA sample test application
7 }& a& |7 k, T6 V$ o7 i0 [$ H - /*9 S6 V s4 u9 u6 V9 n( H( u
- * edma_test.c
2 ~6 m7 t4 b- }, G2 ^' C - *- Z. N% K0 T% G3 H
- * brief EDMA3 Test Application
0 k8 A) S4 s2 L& f: T - *
/ J( T( q8 m9 T0 i8 ~# U* q - * This file contains EDMA3 Test code. B8 j" N- f) @6 _9 K
- *6 c( O5 F+ f( [5 L& U* b% F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 U9 n. ]$ Z5 z( e+ g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 O+ G0 D) z- g7 j* s# a! a: ?
- * TO CHANGE.# v# n2 F z" A; m* D
- *
. f3 j, B5 q- F4 i/ e; b) H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 `% S& B5 Z1 E1 D, a3 f
- *
+ s+ S! {& S' X - * This program is free software; you can redistribute it and/or
( u/ h: m' J1 |: n" h1 b - * modify it under the terms of the GNU General Public License as4 } @) U" l8 j& N0 P
- * published by the Free Software Foundation version 2.
* J! Y9 ?; Z/ J; l) e9 v( } - *
7 p1 Y4 ^; C( C9 @, b( U G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. }# r$ H% Y0 U
- * kind, whether express or implied; without even the implied warranty
3 @6 m+ |0 q m1 @# B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( B. F6 j5 X5 k$ g
- * GNU General Public License for more details.
' n2 [; W$ g2 E& j2 f' f2 i - */
6 W9 y6 ~4 ~7 I% }* Z
" z$ u" A$ `7 y" T* K- #include <linux/module.h>/ G4 a, ]. r( d9 ?% M) P
- #include <linux/init.h>
" V N$ b9 c1 X! G) n - #include <linux/errno.h>$ S: N. k; [/ Q5 b
- #include <linux/types.h>4 Q W1 K5 N( k" M5 G; ^0 \
- #include <linux/interrupt.h>' g# l1 Z9 S, p' h, p& u
- #include <asm/io.h>
" X% M; s6 ^6 u9 |+ v - #include <linux/moduleparam.h>' n" L: V/ ]' i8 g) x
- #include <linux/sysctl.h>$ X! S! z# q. }) z* S/ i
- #include <linux/mm.h>
, c. ]- B w1 l0 _ - #include <linux/dma-mapping.h>" O9 E0 f" T# v% @, B
1 u: m1 ]! t6 ^& Z( r/ Y% L0 Z- #include <mach/memory.h>
0 M; b. d* F; L7 T - #include <mach/hardware.h>
! {" }8 \+ \# L7 F, {. X* p - #include <mach/irqs.h>
7 Z0 n, I+ e' L7 v/ F - #include <asm/hardware/edma.h>
, ~$ g. H) K- V) o - ' M/ ~7 A/ C& K2 d/ ^
- #undef EDMA3_DEBUG
$ C, ?- y7 C/ ]8 C S - /*#define EDMA3_DEBUG*/
* G$ g( U0 N1 G. R9 `
* U2 E, M/ t5 y$ K' _' }$ d- #ifdef EDMA3_DEBUG
$ H0 [+ x ?5 S7 x9 m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 `% w0 B! Y- O/ p2 ? - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 N( b& d$ p% {. v3 i* d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ i$ c+ L3 s3 a- L+ y. _/ U - #else7 x6 @+ ~! j2 L8 A. a6 J8 s
- #define DMA_PRINTK( x... )
5 x# s8 ?5 t6 J0 Q" g; q" i2 f - #define DMA_FN_IN7 k( B2 p, w: S% v6 ]' H! W
- #define DMA_FN_OUT: @' A) R8 \0 ^ h9 I- Y
- #endif
$ p: b. `2 V& F4 C - 2 G3 u8 D' t, A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 C' Q6 P- Q3 m# f/ ~# H3 [
- #define STATIC_SHIFT 3
# ~2 Y5 r: w0 v% G3 H) F - #define TCINTEN_SHIFT 20
* u) ^& |$ |8 |. K% H( E2 r - #define ITCINTEN_SHIFT 21
- V7 Z' P" I& N+ {$ u% S2 a4 d2 x - #define TCCHEN_SHIFT 22; P/ }# A# Q1 s+ O0 e9 }- P! a; b
- #define ITCCHEN_SHIFT 23% A9 A j1 y4 H8 ~' q7 @# L( ^
" t% z5 Y9 a+ S; x. }( m- static volatile int irqraised1 = 0;
- j1 R! S! }" h% } - static volatile int irqraised2 = 0;
3 R8 W( A. K+ m2 }) Z - / L7 E1 ]2 F/ M G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 ^* I& y, G# B* A/ Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 n5 \, i" D: D* j& t+ Y8 m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& y4 ^4 ~; N; o+ g$ P) S
3 A# R% R' V$ n E' r7 g- dma_addr_t dmaphyssrc1 = 0;
3 F9 W3 a* l$ S& c5 f! Y" z6 o - dma_addr_t dmaphyssrc2 = 0;
V: f, i1 {. H: [ s: z$ q - dma_addr_t dmaphysdest1 = 0;
6 U5 [8 L: q. v - dma_addr_t dmaphysdest2 = 0;. [ M" s: o6 {& l$ \; W
; x, U f4 {0 M8 n$ Y% i- Z- char *dmabufsrc1 = NULL;' {) A+ {8 g! C6 w$ I: v
- char *dmabufsrc2 = NULL;
# G, U, y( ?8 v @+ S% i - char *dmabufdest1 = NULL;
* e* v& m d* v# f7 x l5 b - char *dmabufdest2 = NULL;3 y; ^# R4 }# y) |8 K% q* g
- ) T, w4 {4 P4 q8 k
- static int acnt = 512;# H0 Q0 G: y& u" c2 }! O
- static int bcnt = 8;
/ h @3 s" c: D c5 D: } - static int ccnt = 8;8 E- V5 c" l" C/ G; V/ t
0 Z( f7 u3 p$ I( E- module_param(acnt, int, S_IRUGO);
8 ]. z- s# N3 w4 s# K' W D$ D/ G - module_param(bcnt, int, S_IRUGO);, Z5 f6 O4 b/ R$ {/ j! G4 O! C
- module_param(ccnt, int, S_IRUGO);
复制代码 : ^+ ?8 l1 Z$ \, q
/ x) ^ x/ M X) S) c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: P8 `0 J Y# E0 m4 larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 r. Y/ ^- T# s, W" v# `* j' x0 \& p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ H8 m4 u7 Y) J' p7 b
3 ]; s( T# J, ~6 X- Z7 |
6 k7 ^4 t4 e4 Y, b |
|