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 ; scheduler.h: defines and macros for ICSS-G port scheduler
57 ; v0.1
58 ; Notes: runs on RTU
59 ;-----------------------------------------------------------
61 ;----------------------
62 ; utility: cleanup tx
63 ;----------------------
64 CLEANUP_TX .macro slot ; {{{1
65 TM_DISABLE
66 PAGE_RESTORE2 slot, 32
67 ;r7-r8 = descriptor
68 add r0.b0, r8.b3, BP_SLOT0_PRU
69 CEIL64 r18.w0,r8.w0
70 BUFP_PUSH r0, r18.w0
71 TM_ENABLE
72 .endm
74 ;==============================
75 ; STATE 00 state entry point ;STATE_00_EP {{{1
76 ;=============================
77 ; use r2-r9
78 ; step on r18-r20
79 ; preserve r20 in r0 temp
80 STATE_00_EP .macro
81 .newblock
82 SCHED_CHECK_DMA ;see if we can complete previous dma(s)
83 ;(1) preemption not allowed, so we can ping pong dmas
84 ;see if ok to start DMA
85 qbbs $1, GRrtu.flags, f_dmau
86 qbbs done?, GRrtu.flags, f_dma0
87 jmp $2
88 $1: qbbs done?, GRrtu.flags, f_dma1
89 $2:
90 ;check if we need to send TX_TS here
91 qbbc $4, GRrtu.flags, f_tstx_ready
92 ldi32 r10, FW_CONFIG + TX_TS_BASE
93 lbbo &r2, r10, 0, 16
94 set r4.t0
95 SEND_TXTS_PKT
96 clr GRrtu.flags, GRrtu.flags, f_tstx_ready
97 ;ok to start
98 $4:
99 and GRrtu.spare, GRrtu.qmask, GRrtu.pqmap
100 lmbd GRrtu.spare, GRrtu.spare,1
101 qbeq done?, GRrtu.spare, 32
102 ;GRrtu.spare holds portq # 7-0
103 add r9, GRrtu.spare, MQ_SLOT0_RTU
104 TM_DISABLE
105 MQ_POP r9, qempty_exit?
106 qbne $3, MQ_CNT, 0
107 clr GRrtu.pqmap, GRrtu.pqmap, GRrtu.spare
108 $3: ; non_empty00
109 TM_ENABLE
110 ;r7-r8 = descriptor
111 mov r0, r20
113 ;popped packet, decide which dma to use
114 qbbs use_dma1?, GRrtu.flags, f_dmau
115 ;use dma0 (unit0)
116 set GRrtu.flags, GRrtu.flags, f_dmau
117 set GRrtu.flags, GRrtu.flags, f_dma0
118 XFR2VBUS_ISSUE_READ_AUTO_64_CMD XFR2VBUS_XID_READ0, r7, ADDR_HI
119 clr r8.t20
120 mov r20, r0
121 mov r2, r8
122 RTU_IPC_TX_CH0_PPKT
124 PAGE_SAVE2 SCHED_MAIN
125 jmp done?
127 use_dma1?:
128 ;use dma1 (unit1)
129 clr GRrtu.flags, GRrtu.flags, f_dmau
130 XFR2VBUS_ISSUE_READ_AUTO_64_CMD XFR2VBUS_XID_READ1, r7, ADDR_HI
131 set r8.t20
132 set GRrtu.flags, GRrtu.flags, f_dma1
133 mov r20, r0
134 mov r3, r8
135 RTU_IPC_TX_CH0_EPKT
136 PAGE_SAVE2 SCHED_MAIN2
137 jmp done?
139 qempty_exit?: ;shouldn't get here if our bitmap is always consistent..
140 TM_ENABLE
141 clr GRrtu.pqmap, GRrtu.pqmap, GRrtu.spare
142 done?:
143 .endm
145 ;=====================================
146 ; SCHED_CHECK_DMA {{{1
147 ; utility -> check for dma completion
148 ;=====================================
149 SCHED_CHECK_DMA .macro
150 ; we need to decide which dma we want to check first if the both
151 ; packer are completed together
152 qbbs $2, GRrtu.flags, f_dmau
154 ; dma0 was used first, so let's see if we need to clean it first
155 qbbc $1, GRrtu.flags, f_tx0_complete
156 ; clean DMA0
157 clr GRrtu.flags, GRrtu.flags, f_tx0_complete
158 clr GRrtu.flags, GRrtu.flags, f_dma0
159 CLEANUP_TX SCHED_MAIN
160 $1:
161 qbbc done?, GRrtu.flags, f_tx1_complete
162 ; clean DMA1
163 clr GRrtu.flags, GRrtu.flags, f_tx1_complete
164 clr GRrtu.flags, GRrtu.flags, f_dma1
165 CLEANUP_TX SCHED_MAIN2
166 qba done?
167 $2:
168 ; dma0 was used first, so let's see if we need to clean it first
169 qbbc $3, GRrtu.flags, f_tx1_complete
170 ; clean DMA1
171 clr GRrtu.flags, GRrtu.flags, f_tx1_complete
172 clr GRrtu.flags, GRrtu.flags, f_dma1
173 CLEANUP_TX SCHED_MAIN2
174 $3:
175 qbbc done?, GRrtu.flags, f_tx0_complete
176 ; clean DMA0
177 clr GRrtu.flags, GRrtu.flags, f_tx0_complete
178 clr GRrtu.flags, GRrtu.flags, f_dma0
179 CLEANUP_TX SCHED_MAIN
181 done?:
182 .endm