|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& A+ i/ O6 F8 {6 N3 z- [code]EDMA sample test application
( _0 j5 f2 E) s- \ c - /*; @3 G) S& L6 J5 G
- * edma_test.c
1 w7 |' d$ k' ^+ k - *
% v/ n( y. L/ Y5 z' E* Q. K8 k/ O7 T6 g - * brief EDMA3 Test Application3 `( S' X. P& H6 F; G% E
- *$ B& Z) z9 [! H8 ]$ H( ]+ X! z% h: z
- * This file contains EDMA3 Test code.; k5 @7 D1 s( t2 J; Y2 p* }7 K
- *3 {2 C+ L" Y1 ?
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 @3 l# v0 v8 G. f" O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( _4 R3 j* f- E) Y& F- S - * TO CHANGE.' N: [/ O7 X( W7 M
- *+ i& d4 Z1 I: f# T& n9 C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; {% t" G( e+ y+ _7 L' l1 ` - *9 |: `5 F: L* e0 |! \) Y- C
- * This program is free software; you can redistribute it and/or
- l: o' w, e6 m5 B) }5 {7 d) C - * modify it under the terms of the GNU General Public License as
7 A- G0 v! |! m" w. w' Y - * published by the Free Software Foundation version 2.2 g* V# P% Y! l' @6 G
- *2 M* Y1 @! X+ x: T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& l" a" x2 T& m7 x, @4 i - * kind, whether express or implied; without even the implied warranty
$ l; E& q/ L* ?+ M; p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ C0 o& w6 N% ]/ e& k' p! z5 J. x
- * GNU General Public License for more details.
8 \3 S0 R9 g' u4 `& a6 j - */
2 u8 o2 e. r$ p7 p) R" u/ x
0 |' g Z4 i1 l' i! T4 Q" ` \3 V- #include <linux/module.h>, d* c/ d0 j- ]' l( ?7 S/ R
- #include <linux/init.h>& Q0 ^* X4 r2 f W" \7 c
- #include <linux/errno.h>
: i9 H6 u0 R [9 J) j# k$ ?2 G - #include <linux/types.h>
9 L% Y8 H) ^0 J p0 W - #include <linux/interrupt.h>
. n, V, ^/ b9 @' T) ^. O5 i - #include <asm/io.h>6 a1 Z6 ^ G% f
- #include <linux/moduleparam.h>9 p- W4 }3 F& u6 l3 f" y0 Z
- #include <linux/sysctl.h>
) G$ S( z2 u9 ^7 N- z7 X( P. F - #include <linux/mm.h>; Z9 l' e& f$ H" b9 C$ f7 K
- #include <linux/dma-mapping.h>
' B: z* l9 a1 {1 g' n8 U
" n, [! _+ m# Y9 [- #include <mach/memory.h>4 H/ K1 ~" V6 i9 c3 I0 {
- #include <mach/hardware.h>
0 j9 c) Z$ a8 B% i$ C! @ - #include <mach/irqs.h>& e1 _. v+ ^1 d+ }; J4 o! Z
- #include <asm/hardware/edma.h>4 L, E% D9 _/ T7 {
- / l* R/ ~4 G4 n, ~# M( n+ J- ?
- #undef EDMA3_DEBUG! z6 p! f; Z" W3 g% _6 v) I
- /*#define EDMA3_DEBUG*/6 _- B3 G6 y' {" ~- e) d# K% u
. Y8 W1 W0 S+ z. a1 T, j d, J5 Q- O- #ifdef EDMA3_DEBUG8 j9 I! O' R. d. V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ T4 Q1 F1 o+ Z- Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 F* I# t0 m4 k9 {; [+ }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ {2 y9 y/ Y* C% E4 q - #else
& D6 V7 C6 V _+ G - #define DMA_PRINTK( x... )& x |) D7 ^7 { g: }
- #define DMA_FN_IN
# ]1 R, d( f" j! f% O" U - #define DMA_FN_OUT
# p2 |, F$ |- h5 k - #endif8 U9 @7 h& u2 y
- , x$ x) F# L9 ~& P- i6 {% h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" u9 M- H4 m9 w/ h4 [" i - #define STATIC_SHIFT 3
; l/ v0 V5 S1 f7 q/ |1 _( l. A - #define TCINTEN_SHIFT 20
9 l3 L& S3 h5 A: [6 n - #define ITCINTEN_SHIFT 21$ O4 Z0 ]- b; W' ~
- #define TCCHEN_SHIFT 22
% D9 C9 G# i* f( X( z - #define ITCCHEN_SHIFT 23
. C! B6 x& {1 `7 n8 K7 B - & Z" }& h" M5 O6 H9 p
- static volatile int irqraised1 = 0;% F1 E2 N& T2 d2 ]8 v
- static volatile int irqraised2 = 0;
2 Y1 S$ H7 c3 e3 M" P
: E2 c9 d" n1 E% K5 F' {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ P( U% p9 D* t9 c
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" L+ ^6 L/ ~/ l7 t3 a* l* C8 t
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! K$ s- ] z" Q5 I; _ - ; D8 T5 v- e e$ \* I
- dma_addr_t dmaphyssrc1 = 0;
: k9 h$ Z/ F' a4 K ]/ F2 V - dma_addr_t dmaphyssrc2 = 0;( S' J7 f6 A8 A! u- M
- dma_addr_t dmaphysdest1 = 0;$ y. N& d7 Z( g" G7 S4 m8 X
- dma_addr_t dmaphysdest2 = 0;, K' {' \5 c! l" m% |( |4 C
' b- y+ H9 ]2 i/ `1 {+ l: {- char *dmabufsrc1 = NULL;
W- `! t( ]3 a- c - char *dmabufsrc2 = NULL;
6 P0 X% F8 \6 ~! O# Q- e1 n0 z% \ - char *dmabufdest1 = NULL;
$ H7 W3 _( l! Z) _% N+ U - char *dmabufdest2 = NULL;
+ w' {4 q6 j- ^( [; ^3 e1 M
' _# Y: G; t. S- static int acnt = 512;/ [# f3 q4 F" ]) \% S
- static int bcnt = 8;# l0 X' w0 e% g+ f
- static int ccnt = 8;
0 [! u, R; H! J4 Y# R
$ h2 X! A5 Z$ R! ~9 E! }& V- module_param(acnt, int, S_IRUGO);) k' k0 Z/ [. `! k
- module_param(bcnt, int, S_IRUGO);
+ K' x1 I( i! O1 [* E& j) t - module_param(ccnt, int, S_IRUGO);
复制代码
! N3 u( U5 |5 m7 w6 ]5 {
! T' ?! G) V1 t/ P4 i1 P' X2 T: I9 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 i% Q, C4 c, x% Q* r! iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- a; E5 S# i8 b* b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 A; e, o# }- A
8 b$ s: K a' h$ a0 g5 K6 M
3 D" L% B: S' X- E1 N( D |
|