2 * Copyright 2013 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 process(PROC_MEMX, #memx_init, #memx_recv)
29 /******************************************************************************
31 *****************************************************************************/
38 #define handler(cmd,hdr,len,func) /*
46 handler(ENTER , 0x0000, 0x0000, #memx_func_enter)
48 handler(LEAVE , 0x0000, 0x0000, #memx_func_leave)
49 handler(WR32 , 0x0000, 0x0002, #memx_func_wr32)
50 handler(WAIT , 0x0004, 0x0000, #memx_func_wait)
51 handler(DELAY , 0x0001, 0x0000, #memx_func_delay)
52 handler(VBLANK, 0x0001, 0x0000, #memx_func_wait_vblank)
53 handler(TRAIN , 0x0000, 0x0000, #memx_func_train)
56 .equ #memx_func_size #memx_func_next - #memx_func_head
57 .equ #memx_func_num (#memx_func_tail - #memx_func_head) / #memx_func_size
73 /******************************************************************************
75 *****************************************************************************/
79 // $r15 - current (memx)
80 // $r4 - packet length
81 // $r3 - opcode desciption
84 #if NVKM_PPWR_CHIPSET == GT215
87 imm32($r6, 0xfffffffc)
94 imm32($r7, ~0x00000aa2);
99 imm32($r7, ~0x00000001)
110 mov $r6 NV_PPWR_OUTPUT_SET_FB_PAUSE
111 nv_iowr(NV_PPWR_OUTPUT_SET, $r6)
112 memx_func_enter_wait:
113 nv_iord($r6, NV_PPWR_OUTPUT)
114 and $r6 NV_PPWR_OUTPUT_FB_PAUSE
115 bra z #memx_func_enter_wait
117 nv_iord($r6, NV_PPWR_TIMER_LOW)
118 st b32 D[$r0 + #memx_ts_start] $r6
123 // $r15 - current (memx)
124 // $r4 - packet length
125 // $r3 - opcode desciption
128 nv_iord($r6, NV_PPWR_TIMER_LOW)
129 st b32 D[$r0 + #memx_ts_end] $r6
131 mov $r6 NV_PPWR_OUTPUT_CLR_FB_PAUSE
132 nv_iowr(NV_PPWR_OUTPUT_CLR, $r6)
133 memx_func_leave_wait:
134 nv_iord($r6, NV_PPWR_OUTPUT)
135 and $r6 NV_PPWR_OUTPUT_FB_PAUSE
136 bra nz #memx_func_leave_wait
138 #if NVKM_PPWR_CHIPSET == GT215
141 imm32($r6, 0xffffffcc)
146 imm32($r7, 0x00000001)
156 imm32($r7, 0x00000aa2);
163 #if NVKM_PPWR_CHIPSET < GF119
166 // $r15 - current (memx)
167 // $r4 - packet length
168 // +00: head to wait for vblank on
169 // $r3 - opcode desciption
171 memx_func_wait_vblank:
172 ld b32 $r6 D[$r1 + 0x00]
174 bra z #memx_func_wait_vblank_head0
176 bra z #memx_func_wait_vblank_head1
177 bra #memx_func_wait_vblank_fini
179 memx_func_wait_vblank_head1:
181 bra #memx_func_wait_vblank_0
183 memx_func_wait_vblank_head0:
186 memx_func_wait_vblank_0:
187 nv_iord($r6, NV_PPWR_INPUT)
189 bra nz #memx_func_wait_vblank_0
191 memx_func_wait_vblank_1:
192 nv_iord($r6, NV_PPWR_INPUT)
194 bra z #memx_func_wait_vblank_1
196 memx_func_wait_vblank_fini:
202 // XXX: currently no-op
204 // $r15 - current (memx)
205 // $r4 - packet length
206 // +00: head to wait for vblank on
207 // $r3 - opcode desciption
209 memx_func_wait_vblank:
217 // $r15 - current (memx)
218 // $r4 - packet length
221 // $r3 - opcode desciption
224 ld b32 $r6 D[$r1 + 0x00]
225 ld b32 $r5 D[$r1 + 0x04]
229 bra nz #memx_func_wr32
234 // $r15 - current (memx)
235 // $r4 - packet length
240 // $r3 - opcode desciption
243 nv_iord($r8, NV_PPWR_TIMER_LOW)
244 ld b32 $r14 D[$r1 + 0x00]
245 ld b32 $r13 D[$r1 + 0x04]
246 ld b32 $r12 D[$r1 + 0x08]
247 ld b32 $r11 D[$r1 + 0x0c]
254 // $r15 - current (memx)
255 // $r4 - packet length
257 // $r3 - opcode desciption
260 ld b32 $r14 D[$r1 + 0x00]
267 // $r15 - current (memx)
268 // $r4 - packet length
269 // $r3 - opcode desciption
272 #if NVKM_PPWR_CHIPSET == GT215
273 // $r5 - outer loop counter
274 // $r6 - inner loop counter
275 // $r7 - entry counter (#memx_train_head + $r7)
279 // Read random memory to wake up... things
285 memx_func_train_loop_outer:
293 memx_func_train_loop_inner:
307 imm32($r8, 0x80003002)
310 imm32($r14, 0x100560)
311 imm32($r13, 0x80000000)
313 imm32($r11, 0x001e8480)
316 // $r5 - inner inner loop counter
319 imm32($r9, 0x8300ffff)
320 memx_func_train_loop_4x:
321 imm32($r10, 0x100080)
323 imm32($r11, 0xffffffdf)
327 imm32($r10, 0x10053c)
328 imm32($r8, 0x80003002)
331 imm32($r14, 0x100560)
332 imm32($r13, 0x80000000)
334 imm32($r11, 0x00002710)
342 bra l #memx_func_train_loop_4x
344 add b32 $r10 $r7 #memx_train_head
345 st b32 D[$r10 + 0] $r9
350 bra l #memx_func_train_loop_inner
355 bra l #memx_func_train_loop_outer
362 // $r15 - current (memx)
363 // $r14 - sender process name
364 // $r13 - message (exec)
365 // $r12 - head of script
366 // $r11 - tail of script
375 // fetch the packet header
381 // execute the opcode handler
383 mulu $r3 #memx_func_size
384 ld b32 $r5 D[$r3 + #memx_func_head + #memx_func]
387 // keep going, if we haven't reached the end
389 bra l #memx_exec_next
391 // send completion reply
392 ld b32 $r11 D[$r0 + #memx_ts_start]
393 ld b32 $r12 D[$r0 + #memx_ts_end]
395 nv_iord($r11, NV_PPWR_INPUT)
403 // $r15 - current (memx)
404 // $r14 - sender process name
411 bra e #memx_info_train
414 mov $r12 #memx_data_head
415 mov $r11 #memx_data_tail - #memx_data_head
419 mov $r12 #memx_train_head
420 mov $r11 #memx_train_tail - #memx_train_head
428 // $r15 - current (memx)
429 // $r14 - sender process name
435 cmp b32 $r13 MEMX_MSG_EXEC
437 cmp b32 $r13 MEMX_MSG_INFO
443 // $r15 - current (memx)