|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' i* W g: D/ f8 D
- [code]EDMA sample test application
6 F/ ~1 m( h4 O" d$ X4 z - /*
, S- ]0 C* ]9 O4 W1 T( V - * edma_test.c$ q' g0 c' k1 o+ u% V
- *' A6 O7 }; M0 w! w
- * brief EDMA3 Test Application/ @7 y: f7 C1 V8 s% R9 M6 J2 |
- *
& n7 t( X1 e- a) `8 e7 ~! C' {4 g - * This file contains EDMA3 Test code.
2 t% A' f/ z) ~8 Y+ w - *
0 n7 p9 i& [$ p& T# t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& b) ~- n5 {2 A6 \2 g$ O# E* O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; I3 U+ E' ]3 d, C7 { - * TO CHANGE.
) x2 S8 x+ d; u+ D6 l - *
4 L. c7 B, T/ n% L6 T3 V8 c. r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 U' N7 a' U) Y, g6 d8 B) J - *
- e2 {$ B* K) M) Z- q6 G3 X - * This program is free software; you can redistribute it and/or
& ~+ b- C$ E, r - * modify it under the terms of the GNU General Public License as1 v5 \% l, R1 Y6 p: J2 ^
- * published by the Free Software Foundation version 2.
* E" F* c3 S( N+ }, Q/ r - *; o- ~/ X% k% G6 T; j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( u5 `- n" {( b3 G* k& T - * kind, whether express or implied; without even the implied warranty: d4 Y0 Z% n! X& B# k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; b& ^/ Q! J+ f. y, _: U! w
- * GNU General Public License for more details.$ P& } W. A& l7 y4 Y3 D- G
- */8 b+ x5 W& z6 R$ b0 m3 z7 h* q. b
$ M' X9 p- [5 s, I( A- #include <linux/module.h>" g! d9 [$ w# l2 {, B
- #include <linux/init.h>* }% y5 ?9 P/ | {' n8 y
- #include <linux/errno.h>
. \- a- h0 r' j - #include <linux/types.h>- T* ], w4 {) ]0 g' a
- #include <linux/interrupt.h>
p+ x7 a" ]8 ` - #include <asm/io.h>8 o( X. H9 S6 n4 R4 |/ v0 }5 R" i
- #include <linux/moduleparam.h>) T! L1 X- W# O% K. o* W, {1 u
- #include <linux/sysctl.h># h: m9 a+ U2 `9 t$ E3 ~
- #include <linux/mm.h>
& ~! A( U. G. K: ? J - #include <linux/dma-mapping.h>
N: A1 G' g; r - " a5 |9 {* |* O
- #include <mach/memory.h>
) ?5 Y: O. X: [ - #include <mach/hardware.h>
$ ~ g$ ^5 ^1 p9 e - #include <mach/irqs.h>
- @" _% D) Q! c/ j3 `! c2 w - #include <asm/hardware/edma.h>. a3 X! \4 U% \- @0 Y. [
& g% H0 y, T0 g* X# z' h5 H- #undef EDMA3_DEBUG
L! I2 R* C4 P, S- b" j3 W - /*#define EDMA3_DEBUG*/
B$ \9 T( b! T6 H F1 B2 h! W
) i. V( M/ l) n8 x8 R- #ifdef EDMA3_DEBUG
& T! P$ {7 O g2 z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 i! U8 R: A, i8 r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 m7 [, X. [- C* A0 v3 s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- l$ W# D) @/ T7 n8 \
- #else2 g/ |, `7 X& Q1 a' Z8 \
- #define DMA_PRINTK( x... )% c0 x3 M5 D9 j i
- #define DMA_FN_IN
& V# L) ^1 b, L( E- J" z B# k0 V8 t - #define DMA_FN_OUT
3 w7 G, C0 S" A - #endif
6 ]/ S6 [) f/ ?
# y% X9 P- Y8 F- [/ x% V D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# l; @9 l4 _- U" A
- #define STATIC_SHIFT 3' D5 ]5 L$ A4 x' P+ c$ ^! Q' @
- #define TCINTEN_SHIFT 208 h2 c5 |3 V1 X7 [
- #define ITCINTEN_SHIFT 21
# D; @+ r) n9 ~% Q% e8 \ - #define TCCHEN_SHIFT 22- F C% n4 o4 p% ?' c' g
- #define ITCCHEN_SHIFT 23
/ s8 r( A" f- t; U' `! l6 I9 m( p
X& a: ~4 o B. Z- static volatile int irqraised1 = 0;1 p6 M! E* h% \
- static volatile int irqraised2 = 0;7 @) H! g( t5 J" J. W
# w# z4 }3 J( r$ L2 M% n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 K8 `& H% ?0 _1 u: I% g& U4 k3 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ e' ^3 w, b5 U: S# O7 b P6 _# T
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 D! e( v4 I; Y4 s# {# N, }
- 6 u: l* d Z0 Z# ^, X: E3 ^
- dma_addr_t dmaphyssrc1 = 0;- ^( O8 O- S( J0 R; B" t
- dma_addr_t dmaphyssrc2 = 0;
) q6 V; a- w" [) F# c - dma_addr_t dmaphysdest1 = 0;5 e7 @3 V9 P8 j3 k' f6 g
- dma_addr_t dmaphysdest2 = 0;
* ]+ {, X M0 F& v3 w s$ V - . a6 ]/ P7 |. y7 g5 ?$ N+ `) ^
- char *dmabufsrc1 = NULL;
7 R. `; n5 {& Y6 y4 Y( P - char *dmabufsrc2 = NULL;. ?# a" \" m s; t9 f
- char *dmabufdest1 = NULL;
/ U. T7 x& ^$ P - char *dmabufdest2 = NULL;
- F M9 R; r5 ]1 _) H
) m8 C5 [! \" Y9 p4 W+ u# W% ]1 K6 y- static int acnt = 512;
) E& J/ v7 K4 R& y9 G4 r - static int bcnt = 8;2 }# ~( K: S) ~0 A
- static int ccnt = 8;
) V" L+ _0 {/ {! ~6 t2 h% G
8 y% Z- ?0 }# ]- module_param(acnt, int, S_IRUGO);
$ d# n$ b) g; [, X0 s - module_param(bcnt, int, S_IRUGO);
: V: s; Z" O7 g4 m6 ^: G* T - module_param(ccnt, int, S_IRUGO);
复制代码 t3 R, r- s' U) R9 a; [
* w' `4 q0 x/ z# a( ^' E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ g6 A; _$ Q/ r+ n# _% @. q, s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; W1 w. d& f2 ^8 I$ K' V: D3 d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ Z8 g% Q. K/ \/ \1 s
6 K1 b1 }- g1 p% _: U+ l$ n: t! v# z6 b6 E! g
|
|