|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ A. F& _6 w* s% b0 g8 F- [code]EDMA sample test application. }. B* h3 c, X+ ]8 z
- /*
( g1 ~; J+ }& m% r - * edma_test.c+ x' q0 j. _: b3 g
- *6 R8 e! O5 A4 }2 o8 F/ C
- * brief EDMA3 Test Application; q3 |' {9 }' A
- *
4 g ^4 A, _" F" |! f2 I& `- B, [+ t - * This file contains EDMA3 Test code.: k! q2 j; v4 }
- *( I1 F' u i$ G/ u0 x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% o6 d6 Q; r$ ~2 a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* I9 w; z- D2 f% } D$ z- H, X4 y - * TO CHANGE.
5 y2 I+ _7 i) ?4 u - *
4 b- p- ?9 ^5 r% N7 H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 J0 ~; Z6 [# l" i/ ~2 g6 n6 i D+ i - *
6 |/ k! Q" Q& B( C" [2 N# { - * This program is free software; you can redistribute it and/or
/ p P' C) c+ x: t) W3 r, i. S) R& J - * modify it under the terms of the GNU General Public License as
) n0 h/ b8 i& E: E2 r- M' {2 H - * published by the Free Software Foundation version 2.
6 ]; ^: Z- m" U! B - *' ^4 l4 p0 A7 H/ X2 g& M4 I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
O8 z6 W) f5 w9 O( o - * kind, whether express or implied; without even the implied warranty
3 F! m! \" y* D+ V" ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; |$ [9 r4 B9 c0 v8 j9 h - * GNU General Public License for more details.
- ^3 L! J6 `7 E$ Z c0 q - */
4 Z. y8 F' r5 `; J9 R
+ ^+ g7 K$ @* X6 m4 h- #include <linux/module.h>0 A3 g2 [4 r0 n% e7 r) n
- #include <linux/init.h>$ ~! @# V3 r3 f9 b) \" E/ T1 C
- #include <linux/errno.h>
$ F+ }5 W& ]% V' h3 T7 @ - #include <linux/types.h>
0 {% z/ _( @, W; k* _* f0 v- x' ` - #include <linux/interrupt.h>
' p. b* \% j4 e8 R B- ]0 W$ P6 ?0 o - #include <asm/io.h> c& a1 x8 R# b2 B5 w9 |& i
- #include <linux/moduleparam.h>% L$ b U4 N! A; e
- #include <linux/sysctl.h>
8 `2 n6 B* T- |' f% s$ i - #include <linux/mm.h>2 N/ g4 g8 G8 u; B5 d7 Q$ {
- #include <linux/dma-mapping.h>
3 c/ `4 |. B; M
! c# U! m5 b F/ n- #include <mach/memory.h>8 a, L" N4 F% _4 z6 q7 }3 r
- #include <mach/hardware.h>( g$ ?: H; n6 r2 _' Z6 |
- #include <mach/irqs.h> G2 z! M" R Q2 s7 z# n
- #include <asm/hardware/edma.h> z9 e( ~# P' b7 p+ {
- " _8 i6 g! s8 O
- #undef EDMA3_DEBUG
8 m8 B* n- N3 _/ [! L& t% z" y - /*#define EDMA3_DEBUG*/
0 F0 a# q8 W4 g' }% b - 7 U3 q# d+ w3 i
- #ifdef EDMA3_DEBUG# y/ `- G" ]. R" P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% o/ m. ^' U+ o! y& N- s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 L, u) R3 [( u# q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* F, g q; m, \3 E, {' Y
- #else1 f I \: j7 b; l% g: g
- #define DMA_PRINTK( x... )
7 s+ q) N: C/ D3 x - #define DMA_FN_IN
& x8 u7 w1 g" p! v! `& C) r - #define DMA_FN_OUT
8 ~; e7 e( ~6 h - #endif; {; j% c4 Q) K
9 D) a7 |& U( @ j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 q, {# k' x5 W- a - #define STATIC_SHIFT 3
2 p0 D9 k; g+ p; c3 c9 {( f3 d+ X - #define TCINTEN_SHIFT 20
7 r2 J& v+ m# H+ @8 D# \ - #define ITCINTEN_SHIFT 21
$ U, ~7 O9 n6 |0 g! }, H; h - #define TCCHEN_SHIFT 22
) Y5 u8 u$ }7 \8 i. t' { - #define ITCCHEN_SHIFT 23
: D9 d8 X* c; m- R3 b- A D K - ) z5 P6 S+ o0 p9 \- R7 U4 |8 C
- static volatile int irqraised1 = 0;- M) b, l3 o% A& S
- static volatile int irqraised2 = 0;
- P* }' `8 K% v7 w/ G# S# K* R( _
7 G4 M5 p' ]% o, Y1 m) e+ q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 {1 q L1 v5 C4 y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 x5 r: N( S' j' Z2 U$ \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# B9 d, K- ~' M4 F9 x- B+ W( P" W
1 [; _) I+ N2 Z3 s. B1 _/ q3 L4 Z- dma_addr_t dmaphyssrc1 = 0;1 k1 [* [- y8 G9 _! e9 ?5 L
- dma_addr_t dmaphyssrc2 = 0;& h/ g" |& Z( h O
- dma_addr_t dmaphysdest1 = 0;: U. g# c# v3 v: @
- dma_addr_t dmaphysdest2 = 0;
* f% q* K! C& \8 l. X. F4 G8 P - : N* {9 Y, G1 p. S$ n5 p
- char *dmabufsrc1 = NULL;6 A+ q- }$ r9 O T! E2 X! ]
- char *dmabufsrc2 = NULL;
4 p" T# _$ x# N - char *dmabufdest1 = NULL;* ?& C: \5 t! d" E& I) T9 m/ y
- char *dmabufdest2 = NULL;7 J9 q% {( T$ y* q- N" _+ T; L* Y
Y8 s1 v+ p4 M L- static int acnt = 512;
5 S; n) t7 ^% C9 A. N& E- } - static int bcnt = 8;7 h) t7 @8 Z3 e$ O
- static int ccnt = 8;
+ E! K/ Z# d, s( C7 m) c
6 u0 V# X" a% N1 \$ P- module_param(acnt, int, S_IRUGO);# r8 U8 N* W9 L+ q/ }
- module_param(bcnt, int, S_IRUGO);
4 y1 S6 I& ]- ]$ j9 H4 o1 [ - module_param(ccnt, int, S_IRUGO);
复制代码
$ H5 u% k' Z4 P. z# Z+ v! P, Y, \2 D# ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( M& P. p. k1 T: E! v2 H9 m W, A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ O0 H) n: k6 Q4 L6 G$ V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, p, f. W+ p/ s Q; Y' V! ]& ?% V: e, `+ }, {7 m- c
% ~2 Y% K1 }8 W- G# `8 y5 E6 z
|
|