1 ;
2 ; TEXAS INSTRUMENTS TEXT FILE LICENSE
3 ;
4 ; Copyright (c) 2018-2019 Texas Instruments Incorporated
5 ;
6 ; All rights reserved not granted herein.
7 ;
8 ; Limited License.
9 ;
10 ; Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
11 ; license under copyrights and patents it now or hereafter owns or controls to
12 ; make, have made, use, import, offer to sell and sell ("Utilize") this software
13 ; subject to the terms herein. With respect to the foregoing patent license,
14 ; such license is granted solely to the extent that any such patent is necessary
15 ; to Utilize the software alone. The patent license shall not apply to any
16 ; combinations which include this software, other than combinations with devices
17 ; manufactured by or for TI (“TI Devices”). No hardware patent is licensed hereunder.
18 ;
19 ; Redistributions must preserve existing copyright notices and reproduce this license
20 ; (including the above copyright notice and the disclaimer and (if applicable) source
21 ; code license limitations below) in the documentation and/or other materials provided
22 ; with the distribution.
23 ;
24 ; Redistribution and use in binary form, without modification, are permitted provided
25 ; that the following conditions are met:
26 ; No reverse engineering, decompilation, or disassembly of this software is
27 ; permitted with respect to any software provided in binary form.
28 ; Any redistribution and use are licensed by TI for use only with TI Devices.
29 ; Nothing shall obligate TI to provide you with source code for the software
30 ; licensed and provided to you in object code.
31 ;
32 ; If software source code is provided to you, modification and redistribution of the
33 ; source code are permitted provided that the following conditions are met:
34 ; Any redistribution and use of the source code, including any resulting derivative
35 ; works, are licensed by TI for use only with TI Devices.
36 ; Any redistribution and use of any object code compiled from the source code
37 ; and any resulting derivative works, are licensed by TI for use only with TI Devices.
38 ;
39 ; Neither the name of Texas Instruments Incorporated nor the names of its suppliers
40 ; may be used to endorse or promote products derived from this software without
41 ; specific prior written permission.
42 ;
43 ; DISCLAIMER.
44 ;
45 ; THIS SOFTWARE IS PROVIDED BY TI AND TI’S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED
46 ; WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
47 ; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI’S
48 ; LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
50 ; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 ; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 ;-------------------------------------
56 ;File: tx.h
57 ;Purpose: tx defines & macros
58 ;--------------------------------------
60 ;for TX_Q
61 ; see bsram_pru.h for slot/size
63 ;macros to end tx
65 ;end w/ CRC
66 END_TX_CRC .macro
67 ldi r31.w2, 0x2c00 ; (TX_EOF + TX_CRC_HI + TX_CRC_LO)
68 .endm
70 ;#define END_TX_NOCRC mov r31.w2, 0x2000 ; (TX_EOF )
72 ;end w/o crc
73 END_TX_NOCRC .macro
74 set r31.t29;tx.eof
75 .endm
77 ;end with M-crc (ie preempt this pkt)
78 END_TX_MCRC .macro
79 ldi r18, 0x80
80 xout 40, &r18, 4
81 .endm
83 ;macro to start Preemptible frame TX
84 TX_START_PRE .macro
85 ldi r18, 0x20;preempt 2
86 xout 40, &r18, 4;set tx fifo mode (premptable, start of frame)
87 .endm
89 ;macros @start to ADDTAG (preempt/no preempt)
90 ADDTAG .macro
91 and r0, r18, r18
92 ldi r18, 1;bit 1 insert tag
93 xout 40, &r18, 4
94 and r18, r0, r0
95 .endm
97 ;macros @start to REMTAG (preempt/no preempt)
98 REMTAG .macro
99 and r0, r18, r18
100 ldi r18, 4;bit 2=remove
101 xout 40, &r18, 4
102 and r18, r0, r0
103 .endm
105 ;super macro to to start of tx frame setup
106 SOP_TAG_STUFF .macro ret_label
107 qbbc chk_rem_tag2?, TxRegs.ds_flags, 1 ;r_desc.f_desc_add_vtag
108 ;todo: write vlan tag to insert into register
109 ldi r18, 1 ;bit 1 insert tag
110 xout 40, &r18, 4
111 jmp ret_label
112 chk_rem_tag2?:
113 qbbc ret_label, TxRegs.ds_flags, 2 ; r_desc.f_desc_rem_vtag
114 ldi r18, 4 ;bit 2=remove
115 xout 40, &r18, 4
116 .endm
118 ;same but for preeptible packet
119 SOP_TAG_STUFF_PP .macro r_desc, ret_label
120 qbbc chk_rem_tag2?, TxRegs.ds_flags, 1 ;r_desc.f_desc_add_vtag
121 ;todo: write vlan tag to insert into register
122 ldi r18, 0x21 ;bit 1 insert PP tag
123 xout 40, &r18, 4
124 jmp ret_label
125 chk_rem_tag2?:
126 qbbc no_tag?, TxRegs.ds_flags, 2 ;r_desc.f_desc_rem_vtag
127 ldi r18, 0x24;bit 2=remove
128 xout 40, &r18, 4 ; remove PP tag
129 jmp ret_label
130 no_tag?:
131 TX_START_PRE
132 .endm
134 ;-------------------------------------
135 ;basic macro to set up TX task from BG
136 ; v2 -> use descriptor from RTU-IPC
137 ; !! before start of tx
138 ; must be run in task disabled state!!
139 ; r_d MUST BE < r10
140 ; note, now only d1 is needed
141 ;------------------------------------
142 TX_TASK_INIT2_shell .macro r_d
143 flip_tx_r10_r23
144 ;do tx init
145 TX_TASK_INIT2 r_d
146 flip_tx_r10_r23
147 .endm
149 ;main macro to initialize TX from s&f IPC 'queue'
150 ; r_d holds descriptor
151 TX_TASK_INIT2 .macro r_d
153 ;temporary
154 mov TxRegs.ds_flags, r_d.w2 ;descriptor2(flags, etc)
155 mov GRegs.tx.b.len, r_d.w0 ;save length we are expecting to transmit
157 ;start things off
158 ;set TX fifo mode according to TX_D1 flags.. todo
159 .if $isdefed("VLAN_ENABLED")
160 SOP_TAG_STUFF load_fifo?
161 .endif
162 load_fifo?:
163 ldi GRegs.tx.b.state, TX_S_ACTIVE
164 TX_FILL_FIFO XFR2VBUS_XID_READ0
165 .endm
168 FROM_DMA_TO_TXL2 .macro runit
169 XFR2VBUS_WAIT4READY runit
170 XFR2VBUS_READ64_RESULT runit
171 $1: xin TXL2, &r19, 4
172 qbne $1, r19.b2, 0
173 xout TXL2, &r2, 64
174 .endm
176 LAST_DMA_TO_TXL2 .macro runit
177 XFR2VBUS_WAIT4READY runit
178 XFR2VBUS_CANCEL_READ_AUTO_64_CMD (runit)
179 nop
180 XFR2VBUS_READ64_RESULT (runit)
181 BN_TX_N GRegs.tx.b.len
182 .endm
183 ;------------------------------------
184 ;basic macro for TX fifo filling from MSMC
185 ; portQ
186 ; MUST RUN from TX task register state
187 ;---------------------------------------
188 TX_FILL_FIFO .macro runit
189 .newblock
190 ;read in data (now in r2 -r17) [note: on eop some of this may be garbage]
191 qbbs $2, TxRegs.ds_flags, 4 ; TxRegs.ds_flags.f_desc_read_unit
192 qbge $4, GRegs.tx.b.len, 64
193 FROM_DMA_TO_TXL2 runit
194 jmp $3
195 $2: qbge $5, GRegs.tx.b.len, 64
196 FROM_DMA_TO_TXL2 (runit + 1)
197 $3: sub GRegs.tx.b.len, GRegs.tx.b.len, 64
198 jmp $9
200 $4: LAST_DMA_TO_TXL2 runit
201 SPIN_TOG_LOCK_LOC PRU_RTU_EOD_P_FLAG
202 jmp $6
203 $5: LAST_DMA_TO_TXL2 (runit + 1)
204 SPIN_TOG_LOCK_LOC PRU_RTU_EOD_E_FLAG
205 $6: ;close out tx
206 qbbs $7, TxRegs.ds_flags, 0 ;f_desc_do_crc
207 set r31, r31, 29 ;tx.eof
208 jmp $8
210 $7: or r31.b3, r31.b3, 0x2c
211 $8: ldi GRegs.tx.b.state, TX_S_W_EOF
212 $9:
213 .endm