|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . J Q) E# x- m8 t0 w( {$ e# @
- [code]EDMA sample test application$ g( t/ A# p# Q" r2 R
- /*6 r; i, i$ w0 m. r: H& K/ o
- * edma_test.c
" S6 A0 i5 |( G1 z - *
8 b, A: S- j) t, T. c6 H- ~ - * brief EDMA3 Test Application, a, Q. Y, ^$ T- V9 [' k) m% j) W
- *
, Y! l5 L0 n& d - * This file contains EDMA3 Test code.7 Y( {8 P Y! ~* h6 W5 [
- *
1 f( m3 ]6 q; m# M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 G, @8 ^/ p; W& A3 @4 J, r' ^5 G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# o7 @" x' s7 X g' R
- * TO CHANGE.
3 V0 w0 n" U2 \( ]& ^# V, J! H( J - *
! ~) `+ ?% n# l: N3 \5 q1 s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; u9 d- L3 F0 l( k+ M x
- *
- B; [) Y+ U9 E4 f8 `6 ~ - * This program is free software; you can redistribute it and/or
0 v( f% h# p* g2 L& x - * modify it under the terms of the GNU General Public License as
2 J' v( M6 q/ o - * published by the Free Software Foundation version 2.
_$ x: ?3 ^- A/ i' U - */ Z1 @; ^8 T0 S4 u) O1 c6 S
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! p$ `0 M! W' t1 X; R3 P8 J - * kind, whether express or implied; without even the implied warranty
v! w3 ]* l" h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! l# q, V' k+ P9 ]9 I- p* U1 J - * GNU General Public License for more details.
1 ], r7 A8 p: \2 U - */
: ~+ J( q t9 N# e. Y
& |9 H4 }/ Q# r3 W9 L6 |4 \/ ?& e- #include <linux/module.h>
( [+ D h7 X4 Q- A, _ - #include <linux/init.h>
8 H" l, ~+ h$ F - #include <linux/errno.h>
* {% f" y0 g) c! w: [ - #include <linux/types.h>- m! f7 k& R+ s$ n
- #include <linux/interrupt.h>$ x' t a. c9 F1 x0 _4 ?+ ^' i# J/ U" S
- #include <asm/io.h>) r3 p" u; h0 ~! X/ @( s
- #include <linux/moduleparam.h>
5 y) Y6 J+ X7 U' s: _ A4 S$ l7 ~ - #include <linux/sysctl.h>4 D5 } u+ Y' w0 j; X
- #include <linux/mm.h>& `6 h T4 u0 C. M+ N% h8 F( c
- #include <linux/dma-mapping.h>7 Q* i- `) ^6 Q g
$ h+ o; C7 x l- #include <mach/memory.h>) {% h7 V- e/ M: a$ ~
- #include <mach/hardware.h>8 Q' ^0 k) h+ k
- #include <mach/irqs.h>
; c' z2 E% o& s: T9 S$ b8 ~$ `6 F - #include <asm/hardware/edma.h>$ [, G# j* D4 w7 V% t8 x9 g
- ; j4 N/ ]8 @0 A3 T0 ~
- #undef EDMA3_DEBUG
, s& Y7 r* |0 ^, C* m9 Q# i8 I, q - /*#define EDMA3_DEBUG*/
' U$ S( L! r" x# D5 O
0 C0 u+ b4 N1 w- #ifdef EDMA3_DEBUG# g: N' a- ]* z9 {
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ t+ i3 r+ R7 ~% _! K" T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; {, g' ?0 B- ]2 d! H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ ^) w- S; s3 e. m* i - #else$ L$ {4 X6 x+ w" ?9 z( N4 Z
- #define DMA_PRINTK( x... )! g3 u0 [6 h. _3 v- z( D& f
- #define DMA_FN_IN
4 ^8 {* C: I, P - #define DMA_FN_OUT
& b5 a! t( V% f6 d I - #endif3 b* Y! c7 J7 y$ i
- 8 X. n$ \. `0 y+ \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; H" w6 X" _8 _# P - #define STATIC_SHIFT 3# x( q6 W/ M" n! `, D# n$ T
- #define TCINTEN_SHIFT 20
/ M; W* U) f0 @1 X7 j2 h - #define ITCINTEN_SHIFT 210 g; b8 d4 D; R) |1 v# `
- #define TCCHEN_SHIFT 22- G8 Y, m2 C3 c, |; w
- #define ITCCHEN_SHIFT 23& S6 m* r# r) W: c) E
" K/ t. Q: K) f% ]- static volatile int irqraised1 = 0;" v2 X/ s4 G7 L! @
- static volatile int irqraised2 = 0;* y0 \+ T# D: e' C& n6 F; r
9 {/ G8 N! b6 d3 K, _+ C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ?3 U& [1 p8 ]% K& |5 @! \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 |4 o, Z' O( m1 V" P0 H- G) P. j6 r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 r; J/ e- x d$ \7 G. b
+ `6 B4 z3 h# n0 p* E$ x- dma_addr_t dmaphyssrc1 = 0;1 X. o C: y2 V8 `* h
- dma_addr_t dmaphyssrc2 = 0;7 k y) R9 i. C+ F% t# |2 I
- dma_addr_t dmaphysdest1 = 0;
7 k: X3 O a1 T9 N - dma_addr_t dmaphysdest2 = 0;
( [% q; D1 X' ^6 h
% D0 }6 U% ~- B V2 w- char *dmabufsrc1 = NULL;' d% L8 j6 n4 q- Z
- char *dmabufsrc2 = NULL;
9 l( u3 R; a2 N- O; [; G% Y - char *dmabufdest1 = NULL;3 D; g" z& ~9 b; i- P9 ]+ A. k; ^
- char *dmabufdest2 = NULL;
0 g i3 ]) r9 t8 g1 E9 E - ) F" Y7 ?; g+ b0 j. E) V6 B& ^
- static int acnt = 512;) d3 {- w$ j9 v* n3 k
- static int bcnt = 8;! n5 b$ ?8 D0 l6 E$ q! e3 t
- static int ccnt = 8;
. i5 V# j) ]' y - 1 }" Y0 c$ i; X, W6 @0 d
- module_param(acnt, int, S_IRUGO);3 A- J# S! B# j3 Q7 O% x/ _! n
- module_param(bcnt, int, S_IRUGO);1 t! Q7 B: E% [& y8 S
- module_param(ccnt, int, S_IRUGO);
复制代码 $ D4 z7 {% Z ^ b+ T& W
9 j, O( H4 ?6 Y+ y' F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ D+ |/ Q/ X- m6 e8 x% j
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# N4 i) I; ^( t% J g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
?; Z- V/ B% ^8 |0 u# b
/ |% r- d* H2 e+ S' T k: A; n* E* c
( ]# j9 f5 G: E* _4 q$ `' Z% h |
|