|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : D# Q$ g: `5 Y$ J" C/ M
- [code]EDMA sample test application
6 X* ~, W& {6 O4 U( _6 r t/ r - /*# |& y5 S/ f D5 ?
- * edma_test.c
, i Q; {' b+ p# e - *
: E% e& A& t4 b! e; j, C - * brief EDMA3 Test Application
6 R' q/ v; S# D6 N - *
1 @5 Z/ w, s. y3 t- z0 T o# d - * This file contains EDMA3 Test code.
2 C4 d) |, Y, j - *
8 `( K! |# N1 z7 M* u5 v) ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% E7 w$ A4 ~8 L8 [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; r' b+ v5 U$ I5 o* F - * TO CHANGE.- x- A1 V+ _0 y9 F0 }
- *
' Y: C9 B; }) e- K7 v0 |7 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ I8 j, B: H! c; g$ e; e - *
$ b2 r" W. ~4 R; c - * This program is free software; you can redistribute it and/or
0 I {( p1 W \# r5 R; i - * modify it under the terms of the GNU General Public License as0 O6 m' x. L1 G8 i
- * published by the Free Software Foundation version 2.
5 M) D, J7 ]/ Q: ~ s8 F: u - *% Q" P8 V- ^' |: Y& u% |5 P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 H6 z4 C7 F3 q
- * kind, whether express or implied; without even the implied warranty
8 y( w# ?8 ^' p0 k5 g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 Q/ M& w7 w8 d' b - * GNU General Public License for more details.% v. U# f& S3 {2 l0 [- ]+ X |
- */+ D2 Z: E" T5 Y6 x7 X
- * e7 \0 @' w" {8 D( K/ }3 e
- #include <linux/module.h>
/ r+ \5 `; n& y0 f/ b- F; {) h; Q" R - #include <linux/init.h>' }$ Q2 F& {3 {& \8 E
- #include <linux/errno.h>
5 B( H& |7 ~- E+ j$ F, ] ?3 A - #include <linux/types.h>' d0 P- j$ R- `+ T4 p
- #include <linux/interrupt.h>8 l3 G, T. U3 |
- #include <asm/io.h>; R2 f8 ?7 Z0 m8 H: \( n/ g1 `3 M
- #include <linux/moduleparam.h>& R; E' X! H/ C. i/ |# E- N/ F8 _
- #include <linux/sysctl.h>, S' Q* F; B( Y/ a+ ?/ Q/ n
- #include <linux/mm.h>8 m8 t( {% k8 p1 f5 S/ v
- #include <linux/dma-mapping.h>: p. i4 p8 A( ^+ D0 a
- % k! w2 v% U% ]! z S
- #include <mach/memory.h>
2 |* x+ [ G" o: l/ | - #include <mach/hardware.h>
/ q8 S" A1 C5 J% m! s8 Y - #include <mach/irqs.h>+ m& S: j4 T4 k# F- k; D
- #include <asm/hardware/edma.h>% ^4 i/ H* Z9 G* l+ z+ J, R
- B/ A. P9 C! M" G, X5 ~' P
- #undef EDMA3_DEBUG* y. z2 |) @- \# ]# R* {4 S& X
- /*#define EDMA3_DEBUG*/
8 e+ n+ @4 b, E5 K; H5 e" a - * B+ b6 f$ s, f. u
- #ifdef EDMA3_DEBUG
; w. v- E5 G! R& T - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ q/ z# v- p3 c/ ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). K% c; r) s+ }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% N0 t( r7 k6 }0 _ W2 u - #else" Y* z) x; [" }6 J: X8 P. ?. @
- #define DMA_PRINTK( x... )* }% R+ E5 u; ? U& j6 K$ V
- #define DMA_FN_IN3 {, c5 u. U' n! f- V6 ?
- #define DMA_FN_OUT
: m# W5 I) |6 V3 w2 }2 K6 L% [ - #endif
+ ~1 N% {" _+ `( J8 T7 k, T
1 S$ N/ f" [: _/ }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! O0 a) ]) [: @' _
- #define STATIC_SHIFT 3. z1 g4 }( H" \1 m! b8 Z2 M
- #define TCINTEN_SHIFT 20
1 r. P8 o+ s! Y$ L4 a8 @5 s - #define ITCINTEN_SHIFT 21% _3 Q/ ], ~' \" W* q
- #define TCCHEN_SHIFT 22- K; N) \% H9 _' g, v- Y
- #define ITCCHEN_SHIFT 23/ l2 `7 @7 ]3 h& m9 _+ @8 O
% }6 S; X. _3 N5 W( A3 l, M- static volatile int irqraised1 = 0;
, i; Q6 y, C2 P2 B - static volatile int irqraised2 = 0;8 @" ]9 }! O& } L$ Y% V/ {
- ! S- k+ W* ^, ]$ _" I9 ?( f5 r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( `& g4 T9 j- V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' k- { G6 L4 L7 ^3 j' l' l' A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 W' M, ~2 j. R8 g/ e5 v$ y; t' @
0 `; l% b2 m$ @" X7 Z* L- dma_addr_t dmaphyssrc1 = 0;0 ^4 x0 v0 q/ h$ @. z2 i4 P) |
- dma_addr_t dmaphyssrc2 = 0;$ `2 {: D4 u! |* V2 [
- dma_addr_t dmaphysdest1 = 0;/ [% t( q% }; |8 U- E
- dma_addr_t dmaphysdest2 = 0;
& ?4 I. q' I# r8 ]& q
3 i, m% [) a. t3 T G- char *dmabufsrc1 = NULL;
8 w4 Q# |& R6 Y1 H. h - char *dmabufsrc2 = NULL;4 G8 x' }* A. T3 ]& d3 ]
- char *dmabufdest1 = NULL;
$ r& c+ N' y/ J" q - char *dmabufdest2 = NULL;
8 q- h$ u2 p# a$ @4 \1 x6 Z+ { - / V1 w X4 s, p2 k3 f. U
- static int acnt = 512;
/ u2 F. ]3 n9 A# `: t, `& {+ \ - static int bcnt = 8;
! J2 Q! _' j. ?! F( L - static int ccnt = 8;
- C8 y9 N( D! B6 n3 Y( J0 K: K6 k$ ^
' F* u+ w% s9 P$ |3 v' z- module_param(acnt, int, S_IRUGO);2 n' J# X, `( r! M' t; x6 J `2 O! e4 T
- module_param(bcnt, int, S_IRUGO);7 N4 y. I3 Y; ~" ?
- module_param(ccnt, int, S_IRUGO);
复制代码
9 ^& r4 o" I' l# |
0 e2 b; j# s- X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 n& K8 ?+ ?- l& Y7 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& |& c+ I: Q" n5 b: y6 } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" m9 p7 h6 w2 p( t6 P$ {- E/ X% w! o2 p! U! u! t4 k
2 S% ?+ ^/ I, R6 f% U6 n* w
|
|