|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- ^2 g0 l2 E1 y: s( W- [code]EDMA sample test application
$ m. d/ Z% J3 c) X9 p$ ] - /*0 W3 x3 L; s8 o5 f4 G' I3 X; I
- * edma_test.c
. C+ [$ @3 T. W Y9 S2 @: Z l - *
8 U6 T8 u/ j$ o* M. E - * brief EDMA3 Test Application
, J, B! e H! N4 q* G - *
3 L7 {0 V; S6 S0 S# _1 k - * This file contains EDMA3 Test code.
$ S" J" Y/ n1 Z$ [/ X- ? U: ^ - *0 n3 G. k. r& W. l) j
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 e5 W4 u7 u8 }8 H! I& d0 s
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% L" _* u9 R. u! L
- * TO CHANGE.7 f8 ?! I7 V2 f1 d$ v1 X. X$ V
- *
" ?, P5 x" ^* |' S2 E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ d! w$ H3 q+ ?( l# B3 U - *
, \& ]6 S. ^: r7 U+ O - * This program is free software; you can redistribute it and/or: i0 j# R9 A4 [' M
- * modify it under the terms of the GNU General Public License as
1 y" W" {% ] Y0 R& W$ L# m - * published by the Free Software Foundation version 2.) o, Y% h4 k3 L0 b! z. D" C
- *- f1 X y4 W4 K9 b1 }) S3 ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 C, k7 \" U6 W1 X, ~8 f( x2 ^% F - * kind, whether express or implied; without even the implied warranty) P! G# ?& B+ S# e3 X7 y9 _$ I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 T8 e; I$ Z' k) M: t2 l - * GNU General Public License for more details.
0 r" @- g! e2 x' I& K$ q& ^4 v - */8 F+ ]$ E# q" R* A& S! z+ K7 q" D3 D
( j: |( y. f7 f' v# l2 l0 |- #include <linux/module.h># p$ `1 q3 l ~4 m/ @; \
- #include <linux/init.h>
- U# y& K% K5 U V - #include <linux/errno.h>
9 F: h. K1 s( @. ~% q - #include <linux/types.h>
6 V o6 Z* B6 u8 o% S% d) o - #include <linux/interrupt.h>" s) Z' G1 |" t/ l% G6 y2 e& |
- #include <asm/io.h>
^# ]9 W/ f0 p- @6 m6 [% N6 h6 ~7 E - #include <linux/moduleparam.h>) D3 a! N( Z* M( D: V6 |/ V# W
- #include <linux/sysctl.h>; s6 U' P6 o# c) @, B+ C5 T" |
- #include <linux/mm.h>+ p7 y o2 N8 M0 D$ @
- #include <linux/dma-mapping.h>
& ?; } C' M3 E& X' V7 P. g' M - 1 l1 a: P1 B0 z$ }
- #include <mach/memory.h>
; W6 W" U8 S& Z G w7 L7 K( N - #include <mach/hardware.h>6 @3 O1 I3 E2 c) O* Y: u4 F e* O
- #include <mach/irqs.h>
, }0 E7 C( Y- p - #include <asm/hardware/edma.h>' y4 I2 T! E$ ?1 y
- / o! `7 O( H, ?# m4 t, r" m/ {) B" |
- #undef EDMA3_DEBUG
( I# Y) A0 S( k/ t4 `) Z - /*#define EDMA3_DEBUG*/+ O% [7 ~; Q! y e& s7 G# [
- 3 Q, K4 y* s' L6 B! @3 k0 i' W) Y
- #ifdef EDMA3_DEBUG
0 S% }0 s. S, y0 }1 u8 D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# F: r/ X9 X5 Z; b J$ x
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 B$ c, @4 j" n! i0 n6 h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 f6 d" T N; R4 j
- #else
3 S/ v2 j0 J% m! A - #define DMA_PRINTK( x... )
" R4 n* Q" M: V - #define DMA_FN_IN8 U) b3 L0 U: R$ @+ ?, Z
- #define DMA_FN_OUT
8 ]$ C& n$ ~5 Q: `7 {. L - #endif& O, q# z8 _8 E, B) o u% Y5 T) B
+ g; d5 ?( X, z1 P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; Q" x& j0 g6 r' }1 q! ] - #define STATIC_SHIFT 3. v7 Q Y8 w3 F5 I$ d, F
- #define TCINTEN_SHIFT 20 I7 Q7 z3 R% @: ]$ H
- #define ITCINTEN_SHIFT 21+ V, u4 ~* B; p5 r
- #define TCCHEN_SHIFT 22
/ I* n2 A) p( {8 F3 A - #define ITCCHEN_SHIFT 23: o: J3 T+ g9 w2 N9 J$ |, p# |
- $ v, X i8 c7 f! E& U U
- static volatile int irqraised1 = 0;
' H( ?. W* [% f, W. u/ W - static volatile int irqraised2 = 0;
* s8 H; c9 w. F7 S9 }7 M - ( U* {. a3 s3 b8 B' `- {: C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ q2 _& J/ c' g% S. Z: n) H7 q( B - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 g% n2 Y2 t: y) J' B! o& V" i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 ]. u% b- C& k/ s4 X
' y- H! g0 H/ v( H8 L- dma_addr_t dmaphyssrc1 = 0;* j/ K: |* `* x
- dma_addr_t dmaphyssrc2 = 0;
) v5 @: A) k6 L. _ - dma_addr_t dmaphysdest1 = 0;5 X9 f, a" T, ^$ { l) G7 t
- dma_addr_t dmaphysdest2 = 0;
! [5 X& r1 V5 C* D8 S - _% y& D c, k2 }) `+ w8 F
- char *dmabufsrc1 = NULL;( N4 E9 Y* P) T) o+ [+ b
- char *dmabufsrc2 = NULL;* r, x. \( o- W7 P
- char *dmabufdest1 = NULL;2 P, Q M7 h- J" {- s3 M9 y3 I
- char *dmabufdest2 = NULL;
, J( l$ Y& V3 @. {1 c3 q
& X) L4 l: `) h- h( ?* `1 t* v- static int acnt = 512;
; l& V% I+ D- x, ?# l - static int bcnt = 8;; m% F) |% g! F, e9 V1 g
- static int ccnt = 8;
& j% w3 p, L; T - 9 T% z/ B; e1 `
- module_param(acnt, int, S_IRUGO);
% N. @- K @0 P0 u - module_param(bcnt, int, S_IRUGO);
& Y' N2 o( t; m( E4 z, R - module_param(ccnt, int, S_IRUGO);
复制代码 . v* ?- Q& ?$ }' T
1 }# R5 f0 J! r1 r3 y" m# h) c 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 Q4 t+ w+ Z( V1 A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 S L) H: c p, h! {% x. L3 C3 ]0 Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ s3 |+ C: ]- R. o: x
) b6 n7 w @0 o5 a/ T! ]
. ~5 p+ _. u$ p4 F# ]$ z" K% B& c |
|