|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . H Z0 U m, E+ N. o
- [code]EDMA sample test application
: t/ r y5 @. J3 M) w - /*. A% g8 K, Z. L4 ]# }* t! ]
- * edma_test.c
* O0 }( `: v* r F7 Z - *
8 ]3 Q/ F/ ^5 r - * brief EDMA3 Test Application; F# u" n* B `8 W4 X( E: Y' e
- *
5 U* p6 \" s2 T+ h1 e' R; D, c5 U% n - * This file contains EDMA3 Test code.
5 J7 ^; L# m. H; Z. w7 T2 y5 A - *
$ `' |2 \9 S! J# k' Q% _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ O7 w% R6 I) H4 }3 ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; }6 J6 L. }0 g# z8 F+ E+ @4 Q( H4 p - * TO CHANGE.
) y9 |3 U" Y" {2 L4 E4 q - * B9 {6 w9 U( Z, E
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" ? l" u8 k |: ]
- *
5 c0 T+ b9 p% s( i, C - * This program is free software; you can redistribute it and/or8 x! ]; Q' T+ k1 w5 H: d s0 C
- * modify it under the terms of the GNU General Public License as
; V2 L1 `. h& O) a2 d" } - * published by the Free Software Foundation version 2.3 L$ \4 F t4 N9 t7 _
- *4 _# o) b- b; a2 P, s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 ^: ~# `: v- R$ B - * kind, whether express or implied; without even the implied warranty
7 ]/ Z) D; e! r - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the d' G$ }1 {5 M
- * GNU General Public License for more details.
2 {6 C( ]& q4 {" a' H3 \3 P - */
- M4 o1 Q. Q7 F/ m) s& W
, M& }' z7 @- I) P- #include <linux/module.h>
8 F! X4 e, _) a/ P - #include <linux/init.h>3 ~( x2 D% d. X* h) J
- #include <linux/errno.h> n" @3 j) Y% {
- #include <linux/types.h>3 F0 c- n* r( [. R
- #include <linux/interrupt.h>% w& J1 O: ^) `, M) x+ ~
- #include <asm/io.h>
3 v5 I! b1 L0 Q- J7 a- E% g, ] - #include <linux/moduleparam.h>+ B+ g: W; r9 n1 z5 x
- #include <linux/sysctl.h>4 ~; @2 I" v; \* K# V& Q3 X/ o+ A
- #include <linux/mm.h>
! D* K7 @/ V) Y+ a( F9 X. s2 u - #include <linux/dma-mapping.h>
) y- [' x, J3 w0 @: H2 o
/ z- B* Y" C! d1 g N- #include <mach/memory.h>
. t; s/ @/ S; Q9 _ - #include <mach/hardware.h>
$ B" w3 }; A9 Y" J - #include <mach/irqs.h>& ^ A& j" l% R3 h+ I* M, D2 E8 i( |# D
- #include <asm/hardware/edma.h>
# G4 t1 d h- i
& ]/ j) {1 k( P8 C- #undef EDMA3_DEBUG
2 L0 f4 a" |0 e" O" a; h - /*#define EDMA3_DEBUG*/7 a( L; Y" ]9 ?+ |" X2 n8 M
- ! O% N& I) l7 `/ G
- #ifdef EDMA3_DEBUG6 O* ^% w o: W! @* Y% `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 }; E* h, \$ }. G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' B% t/ c' Q6 q7 z5 u; ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* `# X6 q* b4 `1 j! y8 }6 T3 M
- #else
7 T; k1 p) @- p- J" B1 x. p6 { - #define DMA_PRINTK( x... )+ `( a5 l+ v( D
- #define DMA_FN_IN
& X% L" \. ^( I* {# ~( G1 Y - #define DMA_FN_OUT
. W: }3 I' k7 {7 D" a - #endif9 X( s) R3 V5 v% f* j' H0 p/ G
- % N* f6 K: C7 e% p9 m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). K; h0 z' Y8 t) S2 c% u1 u5 m; C: P
- #define STATIC_SHIFT 3
5 M% ~, L8 } p( I- u) \0 G% T - #define TCINTEN_SHIFT 20 I, p# q0 u# [! O. r) F
- #define ITCINTEN_SHIFT 21- A0 w9 }! {3 d. V) j+ A, \
- #define TCCHEN_SHIFT 22
( |0 L7 q, K& e% a2 b; Y; V: x" L7 U! Z - #define ITCCHEN_SHIFT 23
: m" b8 L& g- S. V - 3 j2 e F. `. F! c( w! H
- static volatile int irqraised1 = 0;
6 }- m# F& P" L N$ G - static volatile int irqraised2 = 0;; [& h' a6 u6 ~
( Q8 R' p4 ?+ R, r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: f: ?, m4 S y6 |. w' U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 J7 j( g9 A8 t3 W; G7 `2 ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 g5 N* [% z) J9 f/ d! f, m/ K - ) e7 r5 y4 t/ v
- dma_addr_t dmaphyssrc1 = 0;+ ~ K- ]5 G4 }, n O
- dma_addr_t dmaphyssrc2 = 0;
7 S# Z/ ~5 R# Z/ { - dma_addr_t dmaphysdest1 = 0;8 l# W2 p, ^' ^6 A9 X& \8 n2 U
- dma_addr_t dmaphysdest2 = 0;
2 y& I' \) s% Q
! B8 X9 ?1 w% z1 }- char *dmabufsrc1 = NULL;
$ @% u; V; J% c& A% L - char *dmabufsrc2 = NULL;
" H% S4 X$ I; N# y$ _# ]( w - char *dmabufdest1 = NULL;
; d+ ~* U3 d2 I( k# _ - char *dmabufdest2 = NULL;
5 ]/ I2 t; t( z' H5 p% @5 p - - |+ T7 }$ w5 h" {( \2 \& o
- static int acnt = 512;
) Y% ~! M6 ?5 N% f - static int bcnt = 8;
8 X5 C4 P- Z) C - static int ccnt = 8;
! }1 J8 s" W( X; l" |' Y2 Q, L5 R - / [" g6 b3 ?; N
- module_param(acnt, int, S_IRUGO);
/ j* ?: r! Z- Z# l3 ]) q! w/ | - module_param(bcnt, int, S_IRUGO);
6 |. J5 v! [' M* h/ U - module_param(ccnt, int, S_IRUGO);
复制代码 $ c+ C7 [3 w: H
. o* H. w' _1 c3 F9 @9 k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% P O% T, ?0 j+ J) P& `, M$ E4 r# U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 p+ _" X/ d1 \# i+ [" G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, t9 |, ?* S3 ]% ?* e: I0 A
4 _' ?* W1 D7 x& u, U
9 z+ X* ~2 Q% s7 `& z |
|