|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ e* M' m' j7 H- [code]EDMA sample test application
% V, N5 W( L- q! _ - /*8 @" |1 S1 _9 ^$ _. I
- * edma_test.c
8 g9 E% [9 ]- {! T - *
/ s" w5 B7 v' J5 T, i8 | - * brief EDMA3 Test Application; `* d- }4 C7 t4 b
- *
2 A; L: Z% _2 z7 p7 a - * This file contains EDMA3 Test code.
8 ]2 ~/ Q* c$ y$ k' ^8 B - *; u; L' Z$ `7 V: s5 {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ w0 ]9 d; o. d) S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# X# z, z$ e8 ^) Z% G9 X: X
- * TO CHANGE.5 j4 p3 q2 ?" u0 \9 b
- *; K9 H6 O& {# y; X' m* U- `" t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" }4 N8 m4 \5 g( V* E% N6 s
- *! m/ }% M5 v- f! P+ `/ n) j
- * This program is free software; you can redistribute it and/or; c9 D* x, K9 x
- * modify it under the terms of the GNU General Public License as
! F9 A+ B" ~4 s5 q0 F" s - * published by the Free Software Foundation version 2.
) n0 L* h$ M$ F3 k+ e; N - *3 D* {, n3 J P1 w; s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 i; ~! ]% m+ o# w - * kind, whether express or implied; without even the implied warranty8 b& d1 s* _' y2 Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; y( h. w* u! e o- M$ y0 z, m# x- A; } - * GNU General Public License for more details." y# e9 u: {. |$ r' {
- */
$ T+ O' Z' j! v - 1 L9 T7 |# m l8 g
- #include <linux/module.h>) p$ k* w# Q- x( m# L8 p
- #include <linux/init.h>
6 \7 g2 K) r5 g - #include <linux/errno.h>
8 U- i0 ?+ |' L# A( Z - #include <linux/types.h>1 r4 |% b B8 K: j' x
- #include <linux/interrupt.h>; _2 ^- v0 O5 P5 l S
- #include <asm/io.h>, [- ?9 M4 ]" ?1 T7 h
- #include <linux/moduleparam.h>0 A/ S* T* i6 c0 a$ w k" H
- #include <linux/sysctl.h>" V- b" O( f- P# w* ~
- #include <linux/mm.h>
" ]! P1 Q+ K) r& x/ K - #include <linux/dma-mapping.h>
' E0 \$ v3 z# e5 m' ^ - ! U; x1 w" E& H; R" t$ E3 ~
- #include <mach/memory.h>
* i! h& c$ i X8 E3 O - #include <mach/hardware.h>% B2 s8 U) n! k- t2 b1 o
- #include <mach/irqs.h>( P) R' Y( e) i( `' G Z; h. V; F, z
- #include <asm/hardware/edma.h>
4 N* j/ M" @" @8 e
6 `$ ]6 m: K; C, w- #undef EDMA3_DEBUG
8 q, V8 Y2 M; I5 _% } - /*#define EDMA3_DEBUG*/2 T& ` D$ u. r4 o" z, n8 T
- 0 D( ~# Z/ _* ~" q" }$ T3 w
- #ifdef EDMA3_DEBUG, @1 D E' z( c
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! ~2 Q! k4 o' j: m+ n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 _1 V9 C- f. |* `8 j% t. i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) |1 @, e% p/ v( H3 p
- #else
: J, y. M; G! H$ J+ v - #define DMA_PRINTK( x... )
* s% K; h+ K( S5 M9 Q1 V+ W - #define DMA_FN_IN
+ _2 D$ u# N' f - #define DMA_FN_OUT. h+ c+ c3 |! a& S! R$ z7 m
- #endif( X% A0 r1 h$ Q4 P! Y
- . ~- J8 x9 |: c+ H# C0 R3 h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. |; g$ w* |- e, D5 Q! ? - #define STATIC_SHIFT 3) m% y( |9 R- p: _+ B5 s0 P
- #define TCINTEN_SHIFT 20+ W8 j) S. K1 g0 t$ C! ?0 |* Z' P
- #define ITCINTEN_SHIFT 21
( b$ D) D. @& M9 J) X0 l - #define TCCHEN_SHIFT 22
* M5 O X3 y7 v. e/ y - #define ITCCHEN_SHIFT 23! a' K4 j+ g9 n G. d5 r1 N6 [8 X& W8 y) \
- [$ t; X B: N5 a0 M. _- static volatile int irqraised1 = 0;
1 ]6 _* X+ P" j b7 d, j - static volatile int irqraised2 = 0;* R0 P2 I! T: K. X# F
& B' [7 o0 X' |4 M. t: q7 f3 A$ k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 [( g" u5 e0 b5 H0 }) W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ h* T) d, p+ ~' \- U6 _% [: q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; r2 N9 s: W* I/ v5 j5 D x
- ; d: T( k8 B& b2 x+ n9 m3 d
- dma_addr_t dmaphyssrc1 = 0;
+ w+ e7 s' S1 J$ P" b - dma_addr_t dmaphyssrc2 = 0;+ i' b. ^; R1 u m2 g* L
- dma_addr_t dmaphysdest1 = 0;0 u" B" B$ \+ u: |& D1 D0 [. x
- dma_addr_t dmaphysdest2 = 0;
! ]* a% W9 C) P
7 N" E$ g) ?* C6 S- char *dmabufsrc1 = NULL;
- D) I; q1 V; z- l - char *dmabufsrc2 = NULL;& L7 U5 m# [) P% I- `2 X4 h' F* w
- char *dmabufdest1 = NULL;" C! r1 k. ^! |. q% m$ Q
- char *dmabufdest2 = NULL;
; ?9 `- F9 k+ x# Z# d# P
' m6 }0 v P7 b- L3 J- static int acnt = 512;1 G% L1 F/ w1 @. T2 p- O& f
- static int bcnt = 8;1 ~2 t! h9 A4 {7 S6 B
- static int ccnt = 8;
6 p% K+ J$ I6 P1 F2 j \
& d' \- h- t9 R+ a1 l- module_param(acnt, int, S_IRUGO);
' s {. u' O1 i9 h - module_param(bcnt, int, S_IRUGO);
) f. w4 [: K3 ` |2 v7 M+ m - module_param(ccnt, int, S_IRUGO);
复制代码 D0 d4 a3 t! [! u# i2 e
) J. U( R' h ] 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 e9 m' q5 a# W' ]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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
R% u. t" A, x* S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; s6 e9 X2 C4 s. N' g4 c. \% L1 W2 u
& a7 t& C; c( u$ z' D- w0 F2 J3 K
|
|