|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: f" Q6 O9 m* [, |/ q; ?- [code]EDMA sample test application! r- n) d& z* ?: `" M8 I# K8 A
- /*
3 a9 d4 j! g# |& @0 ^ q/ W - * edma_test.c7 m9 b& s H" {2 y) X* V+ f
- *: F$ i. F3 T* Q/ B; D
- * brief EDMA3 Test Application ?: [/ E0 Y4 x
- *! S( \1 \5 O1 L4 I0 z& w- }
- * This file contains EDMA3 Test code.7 D5 c7 g9 v/ Y N( d% v; _
- *
* t$ ~0 M9 A8 U1 w) ?9 d5 @: I - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" a) F0 [3 P' s5 m9 G4 Y) ^$ g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 z, W' `/ m# v) S `7 {
- * TO CHANGE.
- i2 h8 {0 x- F- e+ l - *2 [- N y, b i, p( {2 j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ I& V( D# L* j5 K: m/ y
- *
. ]& L! g6 u/ Q - * This program is free software; you can redistribute it and/or% ~' ^* ?7 |5 |- ]6 [1 y
- * modify it under the terms of the GNU General Public License as) |4 ^, W' T7 } q
- * published by the Free Software Foundation version 2.
0 X6 U7 U E0 p - *
$ [8 ]. H. A: G7 p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( y4 S' e1 s' L
- * kind, whether express or implied; without even the implied warranty
, ^! W9 |: U+ [+ |' `5 m# [' a4 ^7 D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# f% [0 i+ v2 d% O; a2 s - * GNU General Public License for more details.7 j. w0 c/ \4 Z/ f& C! E
- */
% B! y! l7 k2 B( W8 X9 d1 |
2 E6 G6 [. j9 y1 B# b, Q; G- #include <linux/module.h>$ }9 `% o5 }7 T0 L( a. J, J. d
- #include <linux/init.h>
1 u, n/ d5 o9 j4 j - #include <linux/errno.h>8 T" E" B7 q0 t h6 x
- #include <linux/types.h>6 R3 G( Y( m# g9 w: ] ?
- #include <linux/interrupt.h>6 R9 i9 m: z. \ R; H- b. g3 I) _
- #include <asm/io.h># o4 L% f$ n0 Y! S) `: ~+ ^
- #include <linux/moduleparam.h>
& N- X# T$ b, s0 p7 a - #include <linux/sysctl.h>5 U6 w) X% H$ d
- #include <linux/mm.h>
5 u$ a- ?" U5 w( G' w( l, X - #include <linux/dma-mapping.h>0 r8 f- N2 `4 R4 r# {
9 k2 h( S1 E7 n% L6 u( ]6 V# n- #include <mach/memory.h>* a; M$ z% _; d
- #include <mach/hardware.h>
: p! ?$ s6 z9 Q- I' v- | Z2 B - #include <mach/irqs.h>
2 U4 S* M) ]# D# {1 M# v/ w - #include <asm/hardware/edma.h>
4 `3 [8 n% p0 j; v8 q, w - " q# R: y$ @" }* g! J3 \% s
- #undef EDMA3_DEBUG
8 K1 _/ x) t" s* q5 ?/ K$ K - /*#define EDMA3_DEBUG*/
/ t4 K6 |+ D b5 K - 7 T% \4 P5 J7 A( Q) [
- #ifdef EDMA3_DEBUG0 ?% y" l4 X, O- u N$ B: H1 Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): l/ a: ?' W+ ]! n/ E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ [" Z+ b( y, K: c7 f) W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, P- _5 Z" e2 b8 y# [ - #else) Z4 ?' M- v/ Z/ I: c. H
- #define DMA_PRINTK( x... )
$ o8 O: c; y2 r R! i5 \ M0 H- y& @ - #define DMA_FN_IN" _! h; r# w5 \; [- [) ~
- #define DMA_FN_OUT" A# H% |) Z8 d' C# [
- #endif
* t& n6 x9 u" r& H - " b/ D V5 z8 ]3 f* r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 U4 v W [6 k K
- #define STATIC_SHIFT 3; y; b4 m$ K h. o
- #define TCINTEN_SHIFT 20
9 k, o4 J& M) X - #define ITCINTEN_SHIFT 21+ n2 h" x5 E# B5 Y# q, t
- #define TCCHEN_SHIFT 22) k, ?0 j1 Q( o5 l$ E3 ?- g, |0 r
- #define ITCCHEN_SHIFT 23
5 j8 y d" v6 ^: W# m u) q! N* e - 4 f# W% S; F# n1 h1 d* X. ?
- static volatile int irqraised1 = 0;2 u2 N2 Y ~( T% q1 {
- static volatile int irqraised2 = 0;
; X+ i. i( G; o2 _" \ - ; r$ F3 c: {) k2 R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 B" t2 d# Z+ C& a8 f; F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 t2 r) g0 X1 M2 l1 i1 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, o5 ^- Q, G5 s1 r" x
0 s9 G! e0 O1 H9 g; U4 k6 L" l. n- dma_addr_t dmaphyssrc1 = 0;5 Y! ^' [& X( Z
- dma_addr_t dmaphyssrc2 = 0;# p- u0 F1 C. L v
- dma_addr_t dmaphysdest1 = 0;# Z0 Y+ O# E A$ Q
- dma_addr_t dmaphysdest2 = 0;
" A1 \9 N2 a" ?; j! u
" p. }3 B- P k: U% O$ S4 X5 u4 \- char *dmabufsrc1 = NULL;
! e3 g/ z* \) n8 V( m - char *dmabufsrc2 = NULL;5 f3 ?, T# C8 Z R/ x
- char *dmabufdest1 = NULL;
& d+ N7 P$ K6 T - char *dmabufdest2 = NULL;
1 H) |1 X0 m" |2 t, v. \
2 I0 U# w5 _. u5 h& U- static int acnt = 512;
, G( U- K# I# s/ h5 s: Y - static int bcnt = 8;) K8 `( g0 [' Z+ Q
- static int ccnt = 8;
5 g! T0 ?+ g7 ]% [ - : i# t* i4 ~' K4 ?: i! S; ]
- module_param(acnt, int, S_IRUGO);. a5 O2 u# H+ j+ Y5 L
- module_param(bcnt, int, S_IRUGO);
* }, l0 H* w$ g% p7 X" I - module_param(ccnt, int, S_IRUGO);
复制代码 " W! {3 I9 c( x$ ^4 @: a1 \: b" C$ o
9 ^3 w0 s& ]) V! O7 g2 ~, G2 p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
|. J& q4 k- @7 d# Y; u8 i% `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 u* t4 ^0 A2 J. u# `+ m$ b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. l/ l. I- E0 C, l2 Z; \
) X4 ^3 ^4 Z9 T# I0 F
. Q# d. y5 P2 E; l |
|