|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % e. Z4 Y0 ?9 E9 E; I
- [code]EDMA sample test application
4 [' ?5 o; y; K$ R8 \* A! q - /*. T# q# ]7 a5 \$ w+ I- T
- * edma_test.c2 F7 {, l4 L% H- Z$ ?
- */ g# C9 R' Y& t. P$ O
- * brief EDMA3 Test Application
- I! k8 g% A& C4 D6 b - *
0 k. K: G% j( {2 K8 Q* q5 g - * This file contains EDMA3 Test code.
5 E4 y" r* n% W6 a1 C r - *
2 y* d7 _* }2 U. X0 B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 C- c, k5 v8 g9 l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* J; ^! s5 _$ ~. l' }+ Z: J - * TO CHANGE.
( ^2 X: l8 L: G6 M: B3 T) K - *& {. Z9 D* O2 S0 a) I0 c
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# m5 p. D; d, L& A3 D% B( {9 s- t - *
2 {- ^- @0 d) v. E - * This program is free software; you can redistribute it and/or
2 Y7 ^3 t3 H8 @% ] - * modify it under the terms of the GNU General Public License as3 c0 ?# |2 n% e! A
- * published by the Free Software Foundation version 2.9 I. W5 e3 q& a+ L1 k& o4 R( ]$ J
- *
+ F1 g' ]: q& B; U4 Z. l3 B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 v7 e8 I9 I/ D3 F y7 L
- * kind, whether express or implied; without even the implied warranty" i0 F9 G5 e, i& G
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 U! k7 V U, ^: o% h& y9 G4 T
- * GNU General Public License for more details.. j5 G5 F% y/ v2 v/ }) A1 w! G
- */ T1 i/ e* b: T3 Q$ O" i Q
- 6 n7 V! ^( X" B; W
- #include <linux/module.h>
0 Z- m) D# W* t2 ?* V$ g) G - #include <linux/init.h>2 ~8 j/ F' Q' p( D8 q1 F
- #include <linux/errno.h>
0 Q% |" V; ~. K - #include <linux/types.h>) T, D- A/ E5 s4 V4 I; u, e
- #include <linux/interrupt.h>; l- o2 {4 n+ `2 f& @- ?% `
- #include <asm/io.h>
! t1 Z2 D- H4 R4 R$ M a+ S, s - #include <linux/moduleparam.h>
: ^+ a4 E; X8 \( g' c) R; ~2 w - #include <linux/sysctl.h>. n2 T7 g7 f$ K g2 p) L; R
- #include <linux/mm.h>
$ N. U( K: }3 W3 {8 `0 H/ P - #include <linux/dma-mapping.h>
: d1 L% z: [- ?) |0 ` - , a' P8 i1 Z }! r
- #include <mach/memory.h># l: y) N/ f5 L/ j
- #include <mach/hardware.h>0 {2 H5 e [& i4 Q# A1 w
- #include <mach/irqs.h>: n! N: W+ s8 y- s w
- #include <asm/hardware/edma.h>
% V! p; ] @/ A j: K1 L% C) ^( x - 9 q$ k- p9 P9 P. u$ A5 f/ `
- #undef EDMA3_DEBUG
' e; R2 ?, a' _ - /*#define EDMA3_DEBUG*/& Y6 E* u$ J# o1 b6 [
- 4 Q1 C/ i! ?# N1 W
- #ifdef EDMA3_DEBUG
0 @* q' m' `9 F" O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 l% ]+ U3 h( i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! t' Z: r3 U$ K* Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 @4 f& E& e" J: Q) x$ ]% a( y
- #else- O/ s! h( @, H5 R# ] Q5 W3 d
- #define DMA_PRINTK( x... )
0 R8 H2 n, q2 q" g& a* D - #define DMA_FN_IN
# {% e0 i% @' X" G' |' m& c6 _/ g - #define DMA_FN_OUT% T% \+ y$ Y2 C
- #endif# n& l' v/ Y; {2 `! L6 F8 j
/ R' f/ l# ?% L* M" c! p- m, e6 E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. J u+ e8 y/ `3 e0 l - #define STATIC_SHIFT 3' q. _7 K: \" n- P- @1 D7 [) P( b
- #define TCINTEN_SHIFT 203 d8 S% Q( h! b4 z8 b8 F. U
- #define ITCINTEN_SHIFT 21
4 r* C l* m& r9 e - #define TCCHEN_SHIFT 22# [; q: B' {' Z& g' H
- #define ITCCHEN_SHIFT 23' a8 H& [: X+ {# d3 O2 r
- 8 e# K/ J6 ^. q/ d# W4 m
- static volatile int irqraised1 = 0;
! ?. M6 o; ~% K8 t - static volatile int irqraised2 = 0;
3 i' ~9 B& G! L/ P2 |1 O8 ^& p- R - + }0 U" `1 Y8 n/ G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! R$ J2 O% \ b) k0 N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ K e: N0 q- i0 M" q: j' f) _" {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ C# `. h* o7 ` n+ C# M, s& V
* s* o7 o* S) v- dma_addr_t dmaphyssrc1 = 0;- B( |- n9 P! B/ c k# M
- dma_addr_t dmaphyssrc2 = 0;4 I! W* M \* ~- \
- dma_addr_t dmaphysdest1 = 0;- J" |7 Y0 B7 b
- dma_addr_t dmaphysdest2 = 0;; G: C" U3 s) p9 @% M8 e
- - _( i& [0 L' D* A* B+ E
- char *dmabufsrc1 = NULL;
% D& o5 I7 W* B# l$ [9 [0 W - char *dmabufsrc2 = NULL;
* s" e+ C! C9 u8 M& V - char *dmabufdest1 = NULL;$ m! x) H# e- Y5 l. w
- char *dmabufdest2 = NULL;
, D2 H( T% {+ ?. W* k
$ {5 Y" \6 H$ {0 H3 P) `4 l- static int acnt = 512;
' j3 \1 X" T7 b" ]' q0 Q" a - static int bcnt = 8;! d" u( D2 A4 @* D
- static int ccnt = 8;* M# I7 q) f/ o6 ~# T4 f
- ! T# m) u0 i$ m
- module_param(acnt, int, S_IRUGO);
+ X# e6 G+ X7 s2 ?, z5 s( } - module_param(bcnt, int, S_IRUGO);) i- @& r) S. P. O* O; i
- module_param(ccnt, int, S_IRUGO);
复制代码 4 f- I0 ?8 k) s' H5 j0 }
. I# k+ o+ D' ~" B' ^$ z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ m1 G( c' D/ K, Z V3 W/ m3 Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 y+ p5 ~+ ]% J) F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. m/ r: Q1 j& g0 H1 v8 f0 \
& @6 N5 @' i1 e3 j
; T7 t) s, g6 i. {/ m8 J |
|