|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( Y' Z, m3 Q0 S( b5 P1 s
- [code]EDMA sample test application
9 o" Q7 V" n" _+ Y6 a+ t - /*
& \! i7 R1 X2 U R! {9 I - * edma_test.c" J- Q2 N) k- O j" f$ _
- *
1 v) u3 Q, Q3 ?+ p, n9 ^4 U* x6 R - * brief EDMA3 Test Application
4 k. I; J7 _, D! [4 S x, C! A: G' ?+ Z - *
+ L. T4 |6 z& a1 F0 c- C: w - * This file contains EDMA3 Test code.! M# V4 T% u& i! ^; u% v6 W( ?
- *
" p" _: S! O- T3 K. I - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* u/ N; y4 l2 r& V0 U7 E( q3 s
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, u& d X) E# i9 j# d - * TO CHANGE.! F: K: u; R6 h/ R/ V5 H$ H2 K/ k
- *
' p9 f9 [+ G' u2 k+ o$ U1 o! V7 t - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 S2 W- F3 R5 o) p# `3 j. B" B - *+ m0 Q2 p/ R0 t+ R/ M7 ?
- * This program is free software; you can redistribute it and/or- t" @: r) Y: B* n2 `- x* L
- * modify it under the terms of the GNU General Public License as2 V7 i" L9 f0 y8 u4 G
- * published by the Free Software Foundation version 2.* @5 B# Y' p! G( d4 f G, q8 {. Y
- *8 }/ t2 f+ T0 t
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 `, {# ?1 x8 X/ ~7 X- d8 t - * kind, whether express or implied; without even the implied warranty" ?9 A h. }2 D. _8 y) L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& T& E) L+ ^0 r7 [& u
- * GNU General Public License for more details.
$ E, t: U) q. H - */4 j9 J5 g( o0 P) i; F7 p7 K: v% H
- 1 w. z. L, _' d" G4 F
- #include <linux/module.h>0 H" J# b0 j) l& D- x' m
- #include <linux/init.h>: R/ ?7 Y) J$ x6 c5 B
- #include <linux/errno.h>( z+ H# U3 X* \1 g$ \& }+ q6 p. v
- #include <linux/types.h>
# w5 z- e1 b4 b K/ F/ | - #include <linux/interrupt.h>
A& m8 Z) r( T) T8 H& S0 u) R) K" Q - #include <asm/io.h>
2 b$ U m4 F. Z3 j - #include <linux/moduleparam.h>1 p; H# P0 e h% v) H
- #include <linux/sysctl.h>
! n$ g3 D7 F( x% J, E, ~$ V( \8 R- F* B - #include <linux/mm.h>
4 t3 n7 f9 [2 V6 ~ - #include <linux/dma-mapping.h># n8 l/ S4 A4 N
- 7 G0 n' r8 S9 _* W, L2 {' ?9 P
- #include <mach/memory.h>- b& V5 R4 B+ @* P& p2 D
- #include <mach/hardware.h>
+ ^; N! `: d. Q% K! r/ P - #include <mach/irqs.h>
8 V+ r& ]8 g, \( C9 B2 y: t - #include <asm/hardware/edma.h>6 q- p8 N4 f9 l
! E( N5 `3 ^# Y" d5 b" o- #undef EDMA3_DEBUG: V9 J- R3 M. i. R% j. J! O. ^
- /*#define EDMA3_DEBUG*/
" r1 k& A9 X" i$ {0 }1 i) t - 2 G- B z1 Z/ h; h3 W4 g) h9 J
- #ifdef EDMA3_DEBUG
" H, n0 Z* ~$ X7 C7 V' a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' v2 k0 I; `# K4 ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 [- n F- @% a, ]: ^6 f2 A7 w8 A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) ` V. _& \; r$ g0 x: S
- #else3 {2 k" b4 f5 J6 T
- #define DMA_PRINTK( x... ). Z' T0 g& o+ ?% D- g ]
- #define DMA_FN_IN
- F, t' r6 L7 X4 j% W9 q4 U1 o" ^ - #define DMA_FN_OUT
5 Q; [8 y" k- A - #endif/ [! A( I+ M1 P o5 |; Q' H
- & c( \& w4 E, f5 g* O2 ~2 W b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. f5 T+ }5 \* @3 E, ^" ` - #define STATIC_SHIFT 3
- x" i& z5 x* P - #define TCINTEN_SHIFT 20
|1 e6 h2 a8 N4 _8 @' o - #define ITCINTEN_SHIFT 21
7 z) Y4 U4 H" H: w9 c4 r - #define TCCHEN_SHIFT 22
, b/ g* ^, @0 }) E - #define ITCCHEN_SHIFT 23$ Y; J2 R- H$ [; n/ \
7 P+ G Y4 R0 ]/ f3 D- static volatile int irqraised1 = 0;
: m A, _* J) {* h7 q) p - static volatile int irqraised2 = 0;1 `/ E; j/ d: [) Z) {5 N& c" }; W
9 ?) J& i8 p% X! F' r: [% u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 I J+ g( Z i# [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ?) f% y0 B! Y+ E4 X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( \, W$ u }* \% S+ {4 U$ c
- & |5 W* J; N# C& e. [& R# p/ t
- dma_addr_t dmaphyssrc1 = 0;- _& K% D8 w" y! Y( z- u
- dma_addr_t dmaphyssrc2 = 0;
+ J6 W9 U2 \* N. l p3 } r - dma_addr_t dmaphysdest1 = 0;
6 H8 H" M2 x% c* `+ L9 L - dma_addr_t dmaphysdest2 = 0;5 Q4 {+ T, R( G1 c3 k, r& y
# r% }$ v. @: |0 O4 q- char *dmabufsrc1 = NULL;+ r0 j2 a5 Z) |# G4 A6 `
- char *dmabufsrc2 = NULL;
8 l6 G1 j" h! D, |( M$ W - char *dmabufdest1 = NULL; W) l \! z; w% w: ^
- char *dmabufdest2 = NULL;
4 Z1 N( o1 o0 ?& T+ p9 Y* [
$ g2 i- c* k) T4 [( ^% Q. L9 p" ?- static int acnt = 512;6 ^8 c0 X/ V% v! O8 X0 Q3 M
- static int bcnt = 8;& e. ?8 f- ^5 `: O
- static int ccnt = 8;, N# M: L% d1 H
- , y8 z+ a( K/ p# u8 w# Y
- module_param(acnt, int, S_IRUGO);! w# v {3 t8 U
- module_param(bcnt, int, S_IRUGO);
2 x! f1 L8 s) b- d! [: m; u - module_param(ccnt, int, S_IRUGO);
复制代码
9 C$ @- k$ C9 K6 n- H
O& O# ?/ x, s( t; L8 L 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# d1 a( D3 k8 s5 Q& m! |! _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ f c! s0 B+ h" G8 ~+ n# a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 ~$ `+ q. ?7 G( Z/ p
$ ^; C2 F* t: x; Z0 z3 f6 h0 p) g2 v" k3 b) v2 w
|
|