|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . Q2 C% v* A" X( k: \. n
- [code]EDMA sample test application
7 d( y& z# J$ u: G+ k. o5 F - /*
7 C$ |- I4 l: R6 _ - * edma_test.c
8 k" S" ^( i* K, P9 H' r - *! ^( v" R# y5 ^ m
- * brief EDMA3 Test Application
; v) \* x+ H9 L - *0 Z. G6 l+ y. v/ Q% Z
- * This file contains EDMA3 Test code.
$ Y7 l. i7 i7 u' } - *" X" n C9 a- ~6 r9 V" m
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ U8 e2 V6 o5 h; X. g% @/ t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( J& R7 b6 n- Z: n. v4 A
- * TO CHANGE.5 {3 @( ?3 Y0 m3 U6 U0 F) @
- *
8 d" \% i4 U6 f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" u4 H9 N( a) A9 N8 i - *
! H/ b$ z q" l" ?7 l, r- J - * This program is free software; you can redistribute it and/or
4 v- b0 p4 \* K- Q# v - * modify it under the terms of the GNU General Public License as
9 q$ z E6 `5 E% Z e3 B0 i - * published by the Free Software Foundation version 2.
0 [$ j- ^: `% {& l; c% S% Y/ s% r- X - *
3 U) o5 A: @, i. i# x' u8 E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any* s4 m* Q u$ s+ O& j) q3 L% R. s
- * kind, whether express or implied; without even the implied warranty
3 _# J* s9 J1 m8 t# O- C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- X, P8 c4 v, j" z
- * GNU General Public License for more details.2 ?( L6 n9 J$ [( q. K2 P
- */
& L3 f; r% [ r+ J1 t
; V5 ?, a5 p- T5 W$ I2 `) a' j$ n- #include <linux/module.h>
`; t1 e1 P5 h/ W - #include <linux/init.h>
/ T' A0 a; a0 N; T5 Y8 X1 M. _/ c - #include <linux/errno.h>6 b/ I) P& v$ Z2 ?8 S* T. i
- #include <linux/types.h>
|- t1 {2 q; A' N( q3 v/ T - #include <linux/interrupt.h>
2 z2 B e' d* T - #include <asm/io.h>
5 ]: H7 {; [+ |' w* l0 E" J( C - #include <linux/moduleparam.h>, n3 M4 _2 j; g/ H
- #include <linux/sysctl.h>% C4 R1 I F( G& c) x {
- #include <linux/mm.h>
, p% B. t: s- b/ j1 K5 t - #include <linux/dma-mapping.h>
G) g% j: P2 G) J8 ] - 0 a/ b, [/ M/ ?* c. z0 t2 t& l
- #include <mach/memory.h>
2 E0 A ]) E# x8 u8 A - #include <mach/hardware.h>
8 U3 n }' ?, @9 C0 L* d - #include <mach/irqs.h>- T# v! J* U6 }7 _ a
- #include <asm/hardware/edma.h>
3 [1 z. y- H- [! E) Q$ h8 c0 d( P
( q& a! N6 Q# C9 K! @0 Z- #undef EDMA3_DEBUG
' m6 I! k4 K' Z8 o7 g3 ] - /*#define EDMA3_DEBUG*/9 f& {& H H# M9 P
- : b3 u- H+ T0 t, ~
- #ifdef EDMA3_DEBUG* }: B6 e; T+ s5 H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" G0 @- b' Q+ I) s5 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- D8 m9 C, t6 `5 U) d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 a+ l# N3 H* r5 v4 d! ]- A/ n' v } - #else
5 S7 G7 o. U- R - #define DMA_PRINTK( x... )0 G( E2 S# q+ r) i
- #define DMA_FN_IN, M D7 ~7 w4 t- I$ k
- #define DMA_FN_OUT' Y4 s4 W0 I8 j3 J/ @: O) q; N+ D
- #endif- p, _( K/ m T( y
- & l+ |; ?6 [. f0 ^' a9 ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: ?/ v0 X+ T4 n: V7 Y; v - #define STATIC_SHIFT 3
1 ~" F0 n3 o9 Z& O0 p5 H2 ^ - #define TCINTEN_SHIFT 20
* m. r \3 }/ l' Y - #define ITCINTEN_SHIFT 21% q! h; C+ v! }% U) @
- #define TCCHEN_SHIFT 22- h; `, F9 g$ q4 T) F
- #define ITCCHEN_SHIFT 23, e7 |1 d4 s% G* Y" e" C$ q
7 y; ], m2 j# l0 }: _# {! E- static volatile int irqraised1 = 0;
+ y0 ?( D! O/ A1 J! b, E! K - static volatile int irqraised2 = 0;
. e# u/ t% d1 m- d! ~ - 5 y2 W0 t: ~3 D
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 h; x$ P7 e9 M# p: O2 {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 l5 E8 k. }9 x0 z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 b/ X' e/ E* w
- 9 _2 ^& m8 |, B7 V8 w+ J- x3 P
- dma_addr_t dmaphyssrc1 = 0;. |7 M2 G" W z, P: \/ [0 x. ]
- dma_addr_t dmaphyssrc2 = 0;) q. J8 K3 n5 Z2 L2 r) w' L
- dma_addr_t dmaphysdest1 = 0;
7 }; ]) W# ?/ G - dma_addr_t dmaphysdest2 = 0;' _) _2 Q' c1 ~+ i% h$ ?
4 u7 G7 e' D E8 m- char *dmabufsrc1 = NULL;' {2 @' H* r, m0 `3 M
- char *dmabufsrc2 = NULL;; M; q: o% c( R2 B" r
- char *dmabufdest1 = NULL;3 l. c, p# }. G
- char *dmabufdest2 = NULL;/ o6 v& ] K" f2 ?) j
- - ]; [ X) p6 ~/ F& T, }
- static int acnt = 512;
- `3 J0 Z# G* r: k# Y0 k - static int bcnt = 8;
; N5 @! J- P2 b8 E8 C* ?2 ~. w - static int ccnt = 8;
* H, n5 u3 f. Y; h$ u2 Z
) |9 R$ g7 s' Z ~/ E0 G6 }2 v- module_param(acnt, int, S_IRUGO);% F( O' J! t' }+ P3 y
- module_param(bcnt, int, S_IRUGO);
7 X, |' z- `7 D0 ^6 c - module_param(ccnt, int, S_IRUGO);
复制代码 - B+ m: e+ M* r! G6 ?7 ^; X
% K* d8 Y: p! c 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 v. B- T7 D( b' V+ G
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, D2 h/ W# Y# T1 w% M- H$ ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 h" O# V* t1 s
% L; L8 E9 L& `( C, U
/ b8 ?7 V1 P) _6 v |
|