|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* _" Z) O0 J0 J& p' d- [code]EDMA sample test application
) M e* f" E" S0 l. U2 { - /*% y; m. V! p3 L) P
- * edma_test.c
* t) N! ]' B; N - *
% j) c( i! O" _6 [7 I - * brief EDMA3 Test Application
; q# C, m7 u9 Y; M - *
7 f; k9 o* H7 J- \ - * This file contains EDMA3 Test code.. U: U6 j4 r% }/ q
- *
2 f1 [6 h- I. V+ ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ u3 R M& v# a# a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# B" O; q; b5 j7 I {, _6 d
- * TO CHANGE.
: r% E4 o# O- l& P3 e - *
8 t$ h$ X9 V1 n: N3 J8 q$ v' X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 @) o2 _& C3 \' X/ V! h
- *
7 g; e) |9 o4 c. K* K z5 x# M" N - * This program is free software; you can redistribute it and/or; A0 H; p5 C2 [! K% d* e' E7 P7 M/ ]
- * modify it under the terms of the GNU General Public License as
3 c+ ^. E8 x- P* } - * published by the Free Software Foundation version 2.
/ [! t/ {' {# V! `7 y9 | - *
# q+ L( n4 H. F# S' ^, @7 E9 z' | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" _/ E1 V, Q9 A( o" q o% b
- * kind, whether express or implied; without even the implied warranty3 l3 m5 Y" _+ D: K6 O! O1 q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( {& P7 f0 p/ S6 M. e' n - * GNU General Public License for more details.
6 X% v0 @$ X' X) h) o' o - */# R8 O. c& T* T# ^" |5 X
. R. E3 n3 k* a* A0 ~+ F9 U# `3 i- #include <linux/module.h>
4 x3 r1 [9 W- L - #include <linux/init.h>1 ^% R* e% y2 v
- #include <linux/errno.h>
2 c0 ~: \; J( p0 n0 I+ N9 _ - #include <linux/types.h>! ^& X4 y2 ^6 l# y) i' E" c$ w7 P
- #include <linux/interrupt.h>
. l' q2 c3 ^& ] - #include <asm/io.h>
$ P8 V. L3 |6 S3 U2 t - #include <linux/moduleparam.h>
$ m% L2 N; ?3 U& C2 [" `2 `8 ] - #include <linux/sysctl.h>
$ T7 @$ M9 `2 k - #include <linux/mm.h>
$ T4 M1 z+ Y, D! c% @, P - #include <linux/dma-mapping.h> k3 h+ M( @ m) G. K; i P
4 b, W3 v8 i! W5 B- #include <mach/memory.h>- Z) r0 \3 \) t: E
- #include <mach/hardware.h>
3 u: p$ ~! f9 e2 A - #include <mach/irqs.h>: [/ c1 Q$ S M- V1 z
- #include <asm/hardware/edma.h># Z$ [# I+ y9 R! m
- + Q1 y7 M. A. P* {% M1 l- f: i& \/ ^
- #undef EDMA3_DEBUG
( q0 D# }0 s) j& A3 n+ I - /*#define EDMA3_DEBUG*/# A( y* U& `% ^& B- j( k
- 0 _5 {5 m _9 K) `$ e2 A- W
- #ifdef EDMA3_DEBUG' K: |5 E* u% [2 i+ {; }( C. E3 o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ p- \, V4 n( T$ o% E. \4 S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& e" z# C9 x- w6 F - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ a1 {8 r9 u( ?! v) i' q - #else
$ ?$ h0 \' o% }/ h& K$ H - #define DMA_PRINTK( x... )
( h; l* k6 T) H% B% M( h0 _ - #define DMA_FN_IN X8 ~+ e* J2 U3 ]% K
- #define DMA_FN_OUT: M% ~3 X* O! s$ q4 Q
- #endif
8 M9 C! T6 m& ]" _( K+ [* P - : T3 l: D% ]2 K |
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 b5 v' A. f" B4 I
- #define STATIC_SHIFT 31 d, ^* q5 W# x) ~# k- I
- #define TCINTEN_SHIFT 20
8 M3 {5 A8 f& U$ | - #define ITCINTEN_SHIFT 21% M) w# B: W2 o) o
- #define TCCHEN_SHIFT 22
# S" l5 o9 u2 H( B4 @0 V6 Y - #define ITCCHEN_SHIFT 237 H4 ^: w$ t+ m3 h6 H( m
- 3 F) }# R+ l' |, q0 n+ G" a( \
- static volatile int irqraised1 = 0;5 R6 s0 O" @: x5 g# f: P/ t* s3 u8 h
- static volatile int irqraised2 = 0;' e- s# q3 F. X x0 f
1 z" A0 P- _& t7 P. d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ p: o7 Y% Z- V% Z _! X2 A3 f* h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" R4 |% j5 f0 k& ^% l. A1 }# A' D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! A( }) G. T2 Z: Q- w P- X8 r
: D& w! _$ D( I9 k. _( w- r- dma_addr_t dmaphyssrc1 = 0; Y- \ ]; ~! f3 D5 R) D
- dma_addr_t dmaphyssrc2 = 0;6 r* V0 x: L0 a% T
- dma_addr_t dmaphysdest1 = 0;
* l, |2 d: L4 d7 L' T; j+ d - dma_addr_t dmaphysdest2 = 0;
( y& f( D, _; s - % f* b8 Q2 z: w4 [% b; `: C
- char *dmabufsrc1 = NULL;
! J; h" E4 g) y8 h - char *dmabufsrc2 = NULL;
0 C7 x5 w! r% c2 j. i0 r, R - char *dmabufdest1 = NULL;
) ^+ L. i- ~" ]$ B - char *dmabufdest2 = NULL;# x9 C; k) a( N, A
- , k- e' E( C4 ?7 K
- static int acnt = 512;4 I/ S- n p+ c1 C' G
- static int bcnt = 8;
; o/ J [" u4 U$ V4 G' D - static int ccnt = 8;/ Y% _5 I' T2 c( _5 F
- 5 f5 V0 k# ^( E, C( s( f
- module_param(acnt, int, S_IRUGO);1 ^7 K. {% ?0 J5 F7 z5 }5 V( Z) j
- module_param(bcnt, int, S_IRUGO);
7 T' K I( Q3 ` - module_param(ccnt, int, S_IRUGO);
复制代码 ; X- U' ^0 ?" S' Y* W7 E7 D% ~
( V( l: I G8 V- G; U k" z n 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. T/ U9 O! I; t% s6 ^+ w s5 v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& o( P6 S. i2 o, q5 E; K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ k6 m* U. p3 F
9 Y3 B- F" l; m, |+ G( Y7 s
! i7 j2 M+ X( ]+ V0 G |
|