|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / y9 P5 p- v4 w4 T/ b1 T! }, _
- [code]EDMA sample test application
0 C6 h, y( P9 E4 E& V7 h* Z - /*
4 W# u8 O$ F; I0 ?! [ A" B - * edma_test.c
% Y, g' U* g% q2 { e - *
! D, c6 `: o3 f7 S P- K - * brief EDMA3 Test Application- S) d2 W- _# f! w0 R; G8 F6 ]
- *4 I6 P D* ^& i# X2 V" {9 y
- * This file contains EDMA3 Test code.
7 x) @' t2 T7 H( q. t6 O - *
" M1 b, V: {. W1 M* ?7 h, }/ ~. Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' r5 S* ^% `7 _7 A, M/ w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, `& U1 r9 f) q+ N& k - * TO CHANGE.7 Q: F4 @+ C6 A9 D! p
- *6 e4 r) P3 f. F& O% `- i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# C0 p& ^3 k1 Z9 Q5 y7 \; D3 b
- *0 T, H% ?, f; O. c
- * This program is free software; you can redistribute it and/or
; R0 m4 r6 m+ w2 l* z - * modify it under the terms of the GNU General Public License as
|" `* N4 X- h7 c6 t& P8 |, f. M - * published by the Free Software Foundation version 2.
8 y8 x3 x7 I* T - *
6 H; D! _$ T# U: y7 V4 {& b - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# L8 O4 Z: \/ C - * kind, whether express or implied; without even the implied warranty! Z2 Q+ j, d; c1 K3 U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( ]4 ?7 [0 q) e& L - * GNU General Public License for more details.) B9 `1 K$ z* o# k, L
- */' V% E) b6 ^8 v6 ?9 U
3 Q2 Y# U% b# W0 R. t' \7 m- #include <linux/module.h>, f# T' b9 ^$ D) p7 S$ W
- #include <linux/init.h>0 N* S" n) Y- y" j0 Z2 C
- #include <linux/errno.h>
! }4 f g, ]6 O9 d" V: ^1 K6 a8 Y; P5 [ - #include <linux/types.h>
t& s) `7 v. V4 O. x0 U8 X) T/ L - #include <linux/interrupt.h>
9 T$ d3 n# A9 C7 l0 a7 Q - #include <asm/io.h>4 n: O k8 p- }- j( d5 u
- #include <linux/moduleparam.h>* @' z( _: ]& G
- #include <linux/sysctl.h>
$ s5 ?! M. M% A- {0 g. w - #include <linux/mm.h>. Z! K& S( ], T% ?! |7 m6 Z4 s( ?! L# l
- #include <linux/dma-mapping.h>$ s3 R; Y9 _% V4 _% {2 k1 D
; F$ d5 U! H3 Q0 `" D$ _- #include <mach/memory.h>
/ V( U/ F4 Z, y6 @' i - #include <mach/hardware.h>
' U( @& d% p: {# A2 M# ] - #include <mach/irqs.h>
2 r- C% k. _3 N2 z/ B - #include <asm/hardware/edma.h>
& L& @. D+ M0 t o$ c
0 ~2 r5 d, V" I& @- #undef EDMA3_DEBUG& \ b3 F; V1 ? r: k0 F) P4 X: U
- /*#define EDMA3_DEBUG*/" E; ^8 G. c3 w; `2 m
$ p7 X( J6 L: y& i3 w# s- #ifdef EDMA3_DEBUG
5 w9 [4 t! o; L+ @4 \" M - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). |$ _+ y \9 x- a0 E& d8 c# S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" v | d4 n; j4 _- t8 S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
]/ s6 A( X: s9 K3 B - #else1 J+ {! Z% }& G% a4 X
- #define DMA_PRINTK( x... )$ ~* i* k$ p/ U, M2 t0 e: N V* g7 `
- #define DMA_FN_IN- f2 R n9 C/ _
- #define DMA_FN_OUT
- `) D9 m, F' y7 U% a0 E - #endif
; h) Y& X: V$ c- J' z
7 \( I% a' A7 t9 Y( @) _5 `$ j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 t" @3 W! u) m. T6 ?
- #define STATIC_SHIFT 3
$ ]9 d1 w6 h$ I' P& r - #define TCINTEN_SHIFT 20+ Y9 i8 v8 J, Y- Q- }. F4 M9 F3 `
- #define ITCINTEN_SHIFT 21
: `8 o7 `6 C8 Y: y5 d6 n - #define TCCHEN_SHIFT 22
- \3 M8 ?/ A: v' p6 g( g- y0 J; e' s- P - #define ITCCHEN_SHIFT 23" C# g# \$ T$ U/ L0 Z* c
- ' l" D% B( N: n D/ L5 i, N& p
- static volatile int irqraised1 = 0;7 t+ B/ h8 X: ] R) L
- static volatile int irqraised2 = 0;
5 U, C0 m' @5 y1 n" d/ I
% z* w2 I! c/ n; w1 R& T0 D* j/ J0 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' s5 S" e/ _3 C" \' C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L3 w) W- ?, {5 D' j2 l8 X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 u: v& p; r( k* L, o - ! Y; E) w; k x. ^' m# T
- dma_addr_t dmaphyssrc1 = 0;
- m8 t' |# j* r( q. o# F - dma_addr_t dmaphyssrc2 = 0;* a. c2 u1 L7 {& j8 ?
- dma_addr_t dmaphysdest1 = 0;
! z3 g* L" @+ r6 A( X# Q s - dma_addr_t dmaphysdest2 = 0;' K7 e; F! q3 n" z( I4 I! o
- . N! K9 w! ? L- K8 Y# P
- char *dmabufsrc1 = NULL;
) b% a3 S; ?: y( k+ a5 V0 K - char *dmabufsrc2 = NULL;0 W, t; [/ h* [, n- p
- char *dmabufdest1 = NULL;
5 _. r0 ^1 v& G. u: t - char *dmabufdest2 = NULL;
: ~; ~( ~1 Q1 V$ O9 W" D
b3 n y+ R$ ~+ l& e- static int acnt = 512;
4 b. I0 P! p# P* k. o, c - static int bcnt = 8;7 x6 u9 r. t- q( a
- static int ccnt = 8;
/ K/ m) u) }7 Z$ n
. L: |: ?( k; \, T F) z; B7 o" n- module_param(acnt, int, S_IRUGO);! r& k! x0 h" G6 `2 ~
- module_param(bcnt, int, S_IRUGO);: [: D; n) F# O5 S' d9 I$ C
- module_param(ccnt, int, S_IRUGO);
复制代码 * J: ?' z4 i7 L8 Z+ }$ {9 p
4 k2 D+ K& r6 e8 A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 l& x2 g- W- t9 X/ I7 g& rarm-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 w1 B& p) C4 D* J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" c8 M. o4 R4 Q9 j! p! R6 R' I# i @: v! H$ S
6 @: R* n. q" R3 `2 t |
|