RTEMS 6.1-rc2
Loading...
Searching...
No Matches
alt_dma_program.h
Go to the documentation of this file.
1
7/******************************************************************************
8 *
9 * Copyright 2013 Altera Corporation. All Rights Reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO
27 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33 * OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37#ifndef __ALT_DMA_PROGRAM_H__
38#define __ALT_DMA_PROGRAM_H__
39
40#include "hwlib.h"
41#include "alt_dma_common.h"
42
43#ifdef __cplusplus
44extern "C"
45{
46#endif /* __cplusplus */
47
78#define ALT_DMA_PROGRAM_CACHE_LINE_SIZE (32)
79
86#define ALT_DMA_PROGRAM_CACHE_LINE_COUNT (16)
87
101#ifndef ALT_DMA_PROGRAM_PROVISION_BUFFER_SIZE
102#define ALT_DMA_PROGRAM_PROVISION_BUFFER_SIZE (ALT_DMA_PROGRAM_CACHE_LINE_SIZE * ALT_DMA_PROGRAM_CACHE_LINE_COUNT)
103#endif
104
110typedef struct ALT_DMA_PROGRAM_s
111{
112 uint32_t flag;
113
114 uint16_t buffer_start;
115 uint16_t code_size;
116
117 uint16_t loop0;
118 uint16_t loop1;
119
120 uint16_t sar;
121 uint16_t dar;
122
123 /*
124 * Add a little extra space so that regardless of where this structure
125 * sits in memory, a suitable start address can be aligned to the cache
126 * line stride while providing the requested buffer space.
127 */
130}
132
138{
141
144
149
171{
177
184
191
199
212
224
236
250
286 uint32_t current, uint32_t * progress);
287
310 ALT_DMA_PROGRAM_REG_t reg, uint32_t val);
311
334// Assembler Syntax: DMAADDH <address_register>, <16-bit immediate>
336 ALT_DMA_PROGRAM_REG_t addr_reg, uint16_t val);
337
357// Assembler Syntax: DMAADNH <address_register>, <16-bit immediate>
359 ALT_DMA_PROGRAM_REG_t addr_reg, uint16_t val);
360
371// Assembler Syntax: DMAEND
373
388// Assembler Syntax: DMAFLUSHP <peripheral>
390 ALT_DMA_PERIPH_t periph);
391
412// Assembler Syntax: DMAGO <channel_number>, <32-bit_immediate> [, ns]
414 ALT_DMA_CHANNEL_t channel, uint32_t val,
416
427// Assembler Syntax: DMAKILL
429
446// Assembler Syntax: DMALD[S|B]
449
470// Assembler Syntax: DMALDP<S|B> <peripheral>
473
489// Assembler Syntax: DMALP [<LC0>|<LC1>] <loop_iterations>
491 uint32_t iterations);
492
513// Assembler Syntax: DMALPEND[S|B]
516
528// Assembler Syntax: DMALPFE
530
550// Assembler Syntax: DMAMOV <destination_register>, <32-bit_immediate>
552 ALT_DMA_PROGRAM_REG_t chan_reg, uint32_t val);
553
564// Assembler Syntax: DMANOP
566
577// Assembler Syntax: DMARMB
579
594// Assembler Syntax: DMASEV <event_num>
596 ALT_DMA_EVENT_t evt);
597
613// Assembler Syntax: DMAST[S|B]
616
637// Assembler Syntax: DMASTP<S|B> <peripheral>
640
651// Assembler Syntax: DMASTZ
653
673// Assembler Syntax: DMAWFE <event_num>[, invalid]
675 ALT_DMA_EVENT_t evt, bool invalid);
676
698// Assembler Syntax: DMAWFP <peripheral>, <single|burst|periph>
701
712// Assembler Syntax: DMAWMB
714
761/*
762 * Source Address {Fixed,Incrementing}
763 */
765#define ALT_DMA_CCR_OPT_SAF (0 << 0)
767#define ALT_DMA_CCR_OPT_SAI (1 << 0)
769#define ALT_DMA_CCR_OPT_SA_DEFAULT ALT_DMA_CCR_OPT_SAI
770
771/*
772 * Source burst Size (in bits)
773 */
775#define ALT_DMA_CCR_OPT_SS8 (0 << 1)
777#define ALT_DMA_CCR_OPT_SS16 (1 << 1)
779#define ALT_DMA_CCR_OPT_SS32 (2 << 1)
781#define ALT_DMA_CCR_OPT_SS64 (3 << 1)
783#define ALT_DMA_CCR_OPT_SS128 (4 << 1)
785#define ALT_DMA_CCR_OPT_SS_DEFAULT ALT_DMA_CCR_OPT_SS8
786
787/*
788 * Source burst Length (in transfer(s))
789 */
791#define ALT_DMA_CCR_OPT_SB1 (0x0 << 4)
793#define ALT_DMA_CCR_OPT_SB2 (0x1 << 4)
795#define ALT_DMA_CCR_OPT_SB3 (0x2 << 4)
797#define ALT_DMA_CCR_OPT_SB4 (0x3 << 4)
799#define ALT_DMA_CCR_OPT_SB5 (0x4 << 4)
801#define ALT_DMA_CCR_OPT_SB6 (0x5 << 4)
803#define ALT_DMA_CCR_OPT_SB7 (0x6 << 4)
805#define ALT_DMA_CCR_OPT_SB8 (0x7 << 4)
807#define ALT_DMA_CCR_OPT_SB9 (0x8 << 4)
809#define ALT_DMA_CCR_OPT_SB10 (0x9 << 4)
811#define ALT_DMA_CCR_OPT_SB11 (0xa << 4)
813#define ALT_DMA_CCR_OPT_SB12 (0xb << 4)
815#define ALT_DMA_CCR_OPT_SB13 (0xc << 4)
817#define ALT_DMA_CCR_OPT_SB14 (0xd << 4)
819#define ALT_DMA_CCR_OPT_SB15 (0xe << 4)
821#define ALT_DMA_CCR_OPT_SB16 (0xf << 4)
823#define ALT_DMA_CCR_OPT_SB_DEFAULT ALT_DMA_CCR_OPT_SB1
824
825/*
826 * Source Protection
827 */
829#define ALT_DMA_CCR_OPT_SP(imm3) ((imm3) << 8)
831#define ALT_DMA_CCR_OPT_SP_DEFAULT ALT_DMA_CCR_OPT_SP(0)
832
833/*
834 * Source cache
835 */
837#define ALT_DMA_CCR_OPT_SC(imm4) ((imm4) << 11)
839#define ALT_DMA_CCR_OPT_SC_DEFAULT ALT_DMA_CCR_OPT_SC(0)
840
841/*
842 * Destination Address {Fixed,Incrementing}
843 */
845#define ALT_DMA_CCR_OPT_DAF (0 << 14)
847#define ALT_DMA_CCR_OPT_DAI (1 << 14)
849#define ALT_DMA_CCR_OPT_DA_DEFAULT ALT_DMA_CCR_OPT_DAI
850
851/*
852 * Destination burst Size (in bits)
853 */
855#define ALT_DMA_CCR_OPT_DS8 (0 << 15)
857#define ALT_DMA_CCR_OPT_DS16 (1 << 15)
859#define ALT_DMA_CCR_OPT_DS32 (2 << 15)
861#define ALT_DMA_CCR_OPT_DS64 (3 << 15)
863#define ALT_DMA_CCR_OPT_DS128 (4 << 15)
865#define ALT_DMA_CCR_OPT_DS_DEFAULT ALT_DMA_CCR_OPT_DS8
866
867/*
868 * Destination Burst length (in transfer(s))
869 */
871#define ALT_DMA_CCR_OPT_DB1 (0x0 << 18)
873#define ALT_DMA_CCR_OPT_DB2 (0x1 << 18)
875#define ALT_DMA_CCR_OPT_DB3 (0x2 << 18)
877#define ALT_DMA_CCR_OPT_DB4 (0x3 << 18)
879#define ALT_DMA_CCR_OPT_DB5 (0x4 << 18)
881#define ALT_DMA_CCR_OPT_DB6 (0x5 << 18)
883#define ALT_DMA_CCR_OPT_DB7 (0x6 << 18)
885#define ALT_DMA_CCR_OPT_DB8 (0x7 << 18)
887#define ALT_DMA_CCR_OPT_DB9 (0x8 << 18)
889#define ALT_DMA_CCR_OPT_DB10 (0x9 << 18)
891#define ALT_DMA_CCR_OPT_DB11 (0xa << 18)
893#define ALT_DMA_CCR_OPT_DB12 (0xb << 18)
895#define ALT_DMA_CCR_OPT_DB13 (0xc << 18)
897#define ALT_DMA_CCR_OPT_DB14 (0xd << 18)
899#define ALT_DMA_CCR_OPT_DB15 (0xe << 18)
901#define ALT_DMA_CCR_OPT_DB16 (0xf << 18)
903#define ALT_DMA_CCR_OPT_DB_DEFAULT ALT_DMA_CCR_OPT_DB1
904
905/*
906 * Destination Protection
907 */
909#define ALT_DMA_CCR_OPT_DP(imm3) ((imm3) << 22)
911#define ALT_DMA_CCR_OPT_DP_DEFAULT ALT_DMA_CCR_OPT_DP(0)
912
913/*
914 * Destination Cache
915 */
917#define ALT_DMA_CCR_OPT_DC(imm4) ((imm4) << 25)
919#define ALT_DMA_CCR_OPT_DC_DEFAULT ALT_DMA_CCR_OPT_DC(0)
920
921/*
922 * Endian Swap size (in bits)
923 */
925#define ALT_DMA_CCR_OPT_ES8 (0 << 28)
927#define ALT_DMA_CCR_OPT_ES16 (1 << 28)
929#define ALT_DMA_CCR_OPT_ES32 (2 << 28)
931#define ALT_DMA_CCR_OPT_ES64 (3 << 28)
933#define ALT_DMA_CCR_OPT_ES128 (4 << 28)
935#define ALT_DMA_CCR_OPT_ES_DEFAULT ALT_DMA_CCR_OPT_ES8
936
938#define ALT_DMA_CCR_OPT_DEFAULT \
939 (ALT_DMA_CCR_OPT_SB1 | ALT_DMA_CCR_OPT_SS8 | ALT_DMA_CCR_OPT_SAI | \
940 ALT_DMA_CCR_OPT_SP(0) | ALT_DMA_CCR_OPT_SC(0) | \
941 ALT_DMA_CCR_OPT_DB1 | ALT_DMA_CCR_OPT_DS8 | ALT_DMA_CCR_OPT_DAI | \
942 ALT_DMA_CCR_OPT_DP(0) | ALT_DMA_CCR_OPT_DC(0) | \
943 ALT_DMA_CCR_OPT_ES8)
944
953#ifdef __cplusplus
954}
955#endif /* __cplusplus */
956
957#endif /* __ALT_DMA_PROGRAM_H__ */
enum ALT_DMA_PERIPH_e ALT_DMA_PERIPH_t
enum ALT_DMA_CHANNEL_e ALT_DMA_CHANNEL_t
enum ALT_DMA_EVENT_e ALT_DMA_EVENT_t
enum ALT_DMA_SECURITY_e ALT_DMA_SECURITY_t
ALT_STATUS_CODE alt_dma_program_update_reg(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_REG_t reg, uint32_t val)
Definition: alt_dma_program.c:187
ALT_STATUS_CODE alt_dma_program_DMANOP(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:764
enum ALT_DMA_PROGRAM_INST_MOD_e ALT_DMA_PROGRAM_INST_MOD_t
ALT_STATUS_CODE alt_dma_program_DMAGO(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_CHANNEL_t channel, uint32_t val, ALT_DMA_SECURITY_t sec)
Definition: alt_dma_program.c:355
ALT_STATUS_CODE alt_dma_program_validate(const ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:117
ALT_STATUS_CODE alt_dma_program_DMALPEND(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_INST_MOD_t mod)
Definition: alt_dma_program.c:574
ALT_STATUS_CODE alt_dma_program_DMASTZ(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:933
ALT_STATUS_CODE alt_dma_program_DMAFLUSHP(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PERIPH_t periph)
Definition: alt_dma_program.c:325
ALT_STATUS_CODE alt_dma_program_DMAWFP(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PERIPH_t periph, ALT_DMA_PROGRAM_INST_MOD_t mod)
Definition: alt_dma_program.c:1003
ALT_STATUS_CODE alt_dma_program_DMAEND(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:300
ALT_STATUS_CODE alt_dma_program_DMAKILL(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:415
ALT_STATUS_CODE alt_dma_program_DMAADDH(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_REG_t addr_reg, uint16_t val)
Definition: alt_dma_program.c:222
ALT_STATUS_CODE alt_dma_program_DMALD(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_INST_MOD_t mod)
Definition: alt_dma_program.c:437
ALT_DMA_PROGRAM_REG_e
Definition: alt_dma_program.h:138
ALT_STATUS_CODE alt_dma_program_DMAST(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_INST_MOD_t mod)
Definition: alt_dma_program.c:849
ALT_STATUS_CODE alt_dma_program_DMASEV(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_EVENT_t evt)
Definition: alt_dma_program.c:808
ALT_DMA_PROGRAM_INST_MOD_e
Definition: alt_dma_program.h:171
ALT_STATUS_CODE alt_dma_program_init(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:80
ALT_STATUS_CODE alt_dma_program_DMAADNH(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_REG_t addr_reg, uint16_t val)
Definition: alt_dma_program.c:261
ALT_STATUS_CODE alt_dma_program_DMAMOV(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_REG_t chan_reg, uint32_t val)
Definition: alt_dma_program.c:703
ALT_STATUS_CODE alt_dma_program_progress_reg(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_REG_t reg, uint32_t current, uint32_t *progress)
Definition: alt_dma_program.c:147
struct ALT_DMA_PROGRAM_s ALT_DMA_PROGRAM_t
ALT_STATUS_CODE alt_dma_program_DMASTP(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_INST_MOD_t mod, ALT_DMA_PERIPH_t periph)
Definition: alt_dma_program.c:889
ALT_STATUS_CODE alt_dma_program_DMALDP(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_PROGRAM_INST_MOD_t mod, ALT_DMA_PERIPH_t periph)
Definition: alt_dma_program.c:477
ALT_STATUS_CODE alt_dma_program_uninit(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:98
ALT_STATUS_CODE alt_dma_program_DMALP(ALT_DMA_PROGRAM_t *pgm, uint32_t iterations)
Definition: alt_dma_program.c:521
ALT_STATUS_CODE alt_dma_program_DMALPFE(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:672
ALT_STATUS_CODE alt_dma_program_DMARMB(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:786
ALT_STATUS_CODE alt_dma_program_DMAWMB(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:1050
enum ALT_DMA_PROGRAM_REG_e ALT_DMA_PROGRAM_REG_t
#define ALT_DMA_PROGRAM_PROVISION_BUFFER_SIZE
Definition: alt_dma_program.h:102
ALT_STATUS_CODE alt_dma_program_DMAWFE(ALT_DMA_PROGRAM_t *pgm, ALT_DMA_EVENT_t evt, bool invalid)
Definition: alt_dma_program.c:955
#define ALT_DMA_PROGRAM_CACHE_LINE_SIZE
Definition: alt_dma_program.h:78
ALT_STATUS_CODE alt_dma_program_clear(ALT_DMA_PROGRAM_t *pgm)
Definition: alt_dma_program.c:103
@ ALT_DMA_PROGRAM_REG_SAR
Definition: alt_dma_program.h:140
@ ALT_DMA_PROGRAM_REG_CCR
Definition: alt_dma_program.h:146
@ ALT_DMA_PROGRAM_REG_DAR
Definition: alt_dma_program.h:143
@ ALT_DMA_PROGRAM_INST_MOD_BURST
Definition: alt_dma_program.h:190
@ ALT_DMA_PROGRAM_INST_MOD_SINGLE
Definition: alt_dma_program.h:183
@ ALT_DMA_PROGRAM_INST_MOD_PERIPH
Definition: alt_dma_program.h:196
@ ALT_DMA_PROGRAM_INST_MOD_NONE
Definition: alt_dma_program.h:176
int32_t ALT_STATUS_CODE
Definition: hwlib.h:60
Definition: alt_dma_program.h:111