|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 N5 _% v: @/ F( r
- [code]EDMA sample test application) V% i/ d( {: X, L; i
- /*
9 X! ?. R" v8 F/ } - * edma_test.c* m; p* I6 j; x6 V( ?! j
- *
6 @' I1 i' ~* K# I5 _/ Z - * brief EDMA3 Test Application# x$ @$ {% V' i1 d% g4 S
- *% n* \, Y) S( E1 N
- * This file contains EDMA3 Test code.( G& ? V" U, w
- *
# m$ t0 o3 I6 M- b& y3 U0 S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- u5 w1 _9 I) ?3 f& ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 S2 f! s. |4 U" e. N5 a+ }) G/ G
- * TO CHANGE.
. `$ R. B) B9 p) B - *" e2 f3 s! W! B! Q+ T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 B) N3 W* A; {( _ - *& ~' q( {' M3 R/ y: M1 E! m$ s
- * This program is free software; you can redistribute it and/or6 f% D7 Q; D% H5 J* P6 G8 P
- * modify it under the terms of the GNU General Public License as' A7 e, m8 ]5 h8 X. G+ H
- * published by the Free Software Foundation version 2.
+ b, N8 \5 V. Z0 U+ _( e# @, K# P - *
' T3 {. t+ I2 W/ V! Z: ?# V$ M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 R+ O: z# S& _ - * kind, whether express or implied; without even the implied warranty* H" z8 G- ]; E d$ H' F. H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& y1 Q% `' t! d8 Z: Y8 j - * GNU General Public License for more details.
, U$ S- L5 h I - */7 \! A- _! d& O
- ( Z' p6 @ H. y* Z& A3 D7 }
- #include <linux/module.h>6 L2 d/ S! K0 }- g0 E2 N( D
- #include <linux/init.h>) |0 z! {- {( }& T6 B
- #include <linux/errno.h>2 B1 h! `: M$ q, y5 n
- #include <linux/types.h>8 e5 e* \3 P% I; e8 @5 d
- #include <linux/interrupt.h>$ B' `% n( P0 d9 O' k+ P
- #include <asm/io.h>
& n. H8 h$ h7 ?- i - #include <linux/moduleparam.h>/ z) l" i/ O2 x8 n$ f9 \
- #include <linux/sysctl.h>9 P. C2 N, r' z, W9 ~+ c2 @* Q
- #include <linux/mm.h>
$ V1 Z& O( V, k4 `7 I - #include <linux/dma-mapping.h>( ~# c1 ?2 {0 P% t$ ]$ B1 A
6 D6 z+ ~+ {; s) v5 e/ z. I- #include <mach/memory.h>' g* F% x0 V/ S' T
- #include <mach/hardware.h>
$ u6 y. K8 @, a; B - #include <mach/irqs.h>5 p' k) S' S, p# c
- #include <asm/hardware/edma.h>
* m: ]/ G5 v- J B$ N4 v* i! M' H
* b+ ?; I" d. n- #undef EDMA3_DEBUG
% m1 W' g# g: R5 E4 U. ?7 I - /*#define EDMA3_DEBUG*/
* _ D/ L3 Z2 D# i- j: H
( P ~3 `3 E; [0 \. p7 `1 d; C- #ifdef EDMA3_DEBUG% @, q0 |7 O0 f( E6 o# H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% B- S/ z8 {6 |& o! ]# E$ s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 P+ x& h, g' }6 G0 A {; v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 f# `, Q7 H, v' R. D0 p4 D
- #else6 q& B; ?" |0 t% T0 F
- #define DMA_PRINTK( x... )
% Y' a3 d) p! j# y \ - #define DMA_FN_IN# n5 I; ?. g) L* \( Q6 c9 n
- #define DMA_FN_OUT
: A* c, p: U; w% [ - #endif& e1 q5 I2 ?. ?
- V4 i3 l" k. a& ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ L: v6 s+ Y: ~* }# \% S4 |. B - #define STATIC_SHIFT 3
; V4 w9 O- I/ q; X3 E - #define TCINTEN_SHIFT 20
; _; r& y: h9 t# v, H- V5 W - #define ITCINTEN_SHIFT 21
B3 L1 w! Z* |& { - #define TCCHEN_SHIFT 229 J$ z c) Z8 i# {4 e* ~% s1 s* y
- #define ITCCHEN_SHIFT 23& ~- w$ w' x; Q
4 y+ Y. X/ _" D" g _- static volatile int irqraised1 = 0;( e0 N! G! ?! b% Q5 M
- static volatile int irqraised2 = 0;
4 l0 O7 D# a. M8 u
/ ]5 \8 L% U+ f! {" G- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ A. u8 `5 A# T- e0 {7 w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& U7 S# C. I; L: [6 b3 \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ M% j0 e) I. g2 _+ x8 ^
- # u7 _# B6 {* I$ G
- dma_addr_t dmaphyssrc1 = 0;6 {5 ] B& u5 f! W0 g
- dma_addr_t dmaphyssrc2 = 0;% C% R; Q `9 j: a) F/ N$ r5 c
- dma_addr_t dmaphysdest1 = 0;
7 G+ ^. I. ]/ Z; X# z" M# P - dma_addr_t dmaphysdest2 = 0;7 t9 V. [4 x2 c9 H/ i. V% |
- ( G5 F8 x0 w, z1 G
- char *dmabufsrc1 = NULL;
& _' Z4 s2 r& K3 e) I. X - char *dmabufsrc2 = NULL;
" h# c4 a4 K0 I u - char *dmabufdest1 = NULL;
0 c# \* M0 D+ G: f6 Z7 c - char *dmabufdest2 = NULL;
. F# V! O9 ^6 Y. D - # d$ u0 u# y0 i9 l4 V& J
- static int acnt = 512;$ y1 v6 x" H7 r% N: F6 p' e' \, h! @4 v
- static int bcnt = 8;1 E) M/ e% o6 p/ N+ B- x2 w/ a% q2 }
- static int ccnt = 8;, ~. r! O# S& q% U4 g( D
- 4 s/ V m5 n" v: r1 ~9 J+ b
- module_param(acnt, int, S_IRUGO);5 K. N5 W) @# b0 ^! u' W, Z
- module_param(bcnt, int, S_IRUGO);5 s$ Z) P; g; i4 O) z8 R
- module_param(ccnt, int, S_IRUGO);
复制代码 . ~3 }2 p3 S! W& W) n! ]( ]
8 v! w+ J' n1 z! T0 d5 d2 m3 r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. b) q" S. ~6 W* T* 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" i$ j* X9 ?5 ~) w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 h7 N: U/ S0 ], _8 f+ W! s
" E V* W( V* L
7 L7 k$ ^# C, J5 u* B |
|