|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 `, }. J% Q$ k, n! A
- [code]EDMA sample test application
6 e* B; w/ B7 f" ?8 d) y5 | - /*1 T5 `8 \, n1 ^" s0 D" f% z3 B
- * edma_test.c
2 z* U% O) k3 E2 X$ e/ J5 e - *# q8 j4 _3 B$ K( {9 ~ @* \0 T( y7 T
- * brief EDMA3 Test Application
, w6 P% z) [) [4 H: T7 w, A$ ` - *
4 `6 ~" d) s' N2 A1 T U# d - * This file contains EDMA3 Test code.4 c) u l( l% F8 C& D
- */ f2 x2 o S; b; h( @; v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 U& E2 n6 G( ?$ \: d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 n9 k$ s; {, O
- * TO CHANGE.- _ E& v; H1 i. j l0 t- m) y3 T) U
- *- K0 ?' |( g8 t* s+ h$ {. A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: w3 O1 i9 l( T2 M. J8 C% a3 r
- *
; Y, q! M) s' U' K: x - * This program is free software; you can redistribute it and/or8 f: u9 A: ]3 j p9 |
- * modify it under the terms of the GNU General Public License as+ F7 F. \- ^7 D: v; a. n
- * published by the Free Software Foundation version 2.( B: S5 J# y3 S" r& E) P
- *3 q7 P5 g; p2 E, y% P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 E5 L4 l* S6 b* I3 Y& a! x - * kind, whether express or implied; without even the implied warranty! Y+ f# ]4 X* r' m3 b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ k7 ~$ p$ k* }6 ~) t7 |
- * GNU General Public License for more details.3 h( M& q& `; B
- */
7 W: n& |8 t3 `( a( K1 y" J- v6 N
1 ~. r4 a- y0 L& ?1 \, G5 ~- #include <linux/module.h>
6 L) N* e6 P: o/ [& l% s - #include <linux/init.h>0 N$ o" P' r+ Z$ w' a% [* d
- #include <linux/errno.h>
; A% | [4 j. c' @* ?, k: j - #include <linux/types.h>7 O8 [. f% L; O2 l% U" j1 ]6 H
- #include <linux/interrupt.h>
+ v- c5 j: d( a- O4 l" n - #include <asm/io.h> A9 K* R: s" p
- #include <linux/moduleparam.h>$ c- f8 u7 \$ S+ Z! X
- #include <linux/sysctl.h>, T! Q' H* i6 E, F! p4 M
- #include <linux/mm.h>
+ G3 N/ w! g" P& u# p - #include <linux/dma-mapping.h>0 N4 b0 K e4 W
- ! ~8 F4 W- i+ R; G
- #include <mach/memory.h>
! A4 @& \7 Q" J" K B# s5 v ~ - #include <mach/hardware.h>
+ {8 q) h7 k3 u$ { - #include <mach/irqs.h>
3 }5 z* j" e3 e+ { - #include <asm/hardware/edma.h>
- z5 t9 }0 m, d- A1 N: B7 A
2 ?3 T7 S6 U/ R& ]5 w2 o/ T- #undef EDMA3_DEBUG
- ~2 r6 o9 Q' l - /*#define EDMA3_DEBUG*/& z4 `9 {* f) `# b/ `
7 @" ?2 r" F% `2 q/ i- #ifdef EDMA3_DEBUG0 u+ k+ s9 o7 u _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ r. N2 B( q7 A$ \; I: N6 B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 b4 K5 A3 C6 d; D2 l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 J1 f& `8 e) L s
- #else
3 K. _/ i7 Z0 t. A5 g6 S, U - #define DMA_PRINTK( x... )" Z* y3 Z. {% j4 |6 _# ]1 t" e
- #define DMA_FN_IN7 s4 h( m6 V& `0 A" {3 R7 p1 _- k
- #define DMA_FN_OUT9 j3 f( s8 o4 _) b
- #endif5 I1 t4 Y% a. u0 K$ ~
- ; j$ p: B; @1 |* Y' ?8 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* X$ O- ~. S& ~9 s, W$ b: u
- #define STATIC_SHIFT 3/ d2 C' R; M( y3 v5 m. x, L
- #define TCINTEN_SHIFT 20
' g4 s! P8 p; A& V q - #define ITCINTEN_SHIFT 21
' k* R, C0 f, c8 m7 s" H; ~* R - #define TCCHEN_SHIFT 226 J2 j; `$ D; m4 F B
- #define ITCCHEN_SHIFT 233 `, ~7 v0 G* y% j( o e
) A. L6 w7 A2 B0 H2 z2 {# ~- x; P- static volatile int irqraised1 = 0;& N9 F4 m9 m( t. w7 P {/ ^& I
- static volatile int irqraised2 = 0;
# K7 H& ?) e0 t8 Q! t+ t B: T9 x - # ^! k2 X5 J; o* R, y2 I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 w7 M) U+ ^* e) D, x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- \. g* J# F( x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 h/ \; |" c, V( F6 p9 F - ( d2 V! e; t; E4 v! H
- dma_addr_t dmaphyssrc1 = 0;
% d n' c( a6 j( E - dma_addr_t dmaphyssrc2 = 0;) L) x: _+ m* m9 T* a' P
- dma_addr_t dmaphysdest1 = 0;8 }9 \! }$ n, u0 C2 v
- dma_addr_t dmaphysdest2 = 0;
6 ~- J& r4 R! ] - ) m, M0 o) S1 `! z% y% k
- char *dmabufsrc1 = NULL;, k/ c/ E' ?7 a r' d
- char *dmabufsrc2 = NULL;3 W0 \' x: L2 r- ], A8 m- I' E9 i
- char *dmabufdest1 = NULL;6 S; p) W! ]2 V6 h5 q
- char *dmabufdest2 = NULL;* z* \8 W# A, t U5 ]
- ) }+ f( J& h9 }! g: F
- static int acnt = 512;- o" m, |$ ?! z) s6 N w
- static int bcnt = 8;
2 t& q6 B4 F, o E - static int ccnt = 8;
c% ~/ m1 s( \- w ^; R - 2 d, ~' n: \/ [0 W4 D8 o% n9 c
- module_param(acnt, int, S_IRUGO);
" @4 V" {, X! e9 x- i$ W5 }5 V P6 l - module_param(bcnt, int, S_IRUGO);/ i6 Q8 g9 } _) j3 E4 ]! D5 s% b
- module_param(ccnt, int, S_IRUGO);
复制代码
2 Z" t! b) u, y- S+ R
! V: @/ B3 C7 k6 M! A6 O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. W" {- Z1 ~8 o; X% v3 I
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 e- K, K! [8 v+ D) {2 p& Y0 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 i9 k) u# P6 Q. J- t
9 g1 M& I# s) ]! C/ {
1 ^3 ?( W% o( v% X! t, ^* Y( l, \ |
|