ScarletNX / xspe models / rsx
rsx: nv406e.lisp
NV406E (the channel's DMA class): reference, semaphores; and the GCM driver methods.
NV406E_SET_REFERENCE source
(defmethod-rsx NV406E_SET_REFERENCE #x0050 (value)
"the value at REF of the control registers (once everything before is done)"
(mem-write 32 (+ (rsx-control rsx) 8) value))
NV406E_SEMAPHORE_ACQUIRE source
(defmethod-rsx NV406E_SEMAPHORE_ACQUIRE #x0068 (value)
(unless (= (mem-read 32 (rsx-semaphore-406e rsx)) value)
(setf (rsx-status rsx) +rsx-blocked+)))
NV406E_SEMAPHORE_RELEASE source
(defmethod-rsx NV406E_SEMAPHORE_RELEASE #x006C (value)
(mem-write 32 (rsx-semaphore-406e rsx) value))
GCM_DRIVER_QUEUE source
(defmethod-rsx GCM_DRIVER_QUEUE (#xE940 8 4) (value i)
"queue display buffer VALUE for a flip of head I: the head's flip flags get
bit 30 (queued) and bit VALUE (none for VALUE >= 32), as a PS3 shows"
(unless (= (rsx-driver-info rsx) 0)
(let ((a (+ (rsx-driver-info rsx) rsx-driver-head-flags (* rsx-driver-head-size i))))
(mem-write 32 a (logior (mem-read 32 a) #x40000000 (if (< value 32) (ash 1 value) 0))))))
GCM_FLIP_HEAD source
(defmethod-rsx GCM_FLIP_HEAD (#xE920 2 4) (value i)
"flip head I to display buffer VALUE (bits 0..2)"
(rsx-flip rsx value))
GCM_FLIP_COMMAND source
(defmethod-rsx GCM_FLIP_COMMAND #xFEAC (value)
"the flip that cellGcmSetFlipCommand writes: display buffer VALUE"
(rsx-flip rsx value))
Other definitions
(defun rsx-semaphore-406e) source
(defun rsx-semaphore-406e (rsx)
(declare (type rsx rsx))
(rsx-address rsx (reg NV406E_SET_CONTEXT_DMA_SEMAPHORE) (reg NV406E_SEMAPHORE_OFFSET)))
(defun rsx-flip) source
(defun rsx-flip (rsx buffer)
"show display buffer BUFFER: the flip is done, label 1 (what cellGcmSetWaitFlip
waits on) is cleared, the flip handler is owed a call, the presenter is told"
(declare (type rsx rsx) (type u32 buffer))
(setf (rsx-flip-buffer rsx) (ldb (byte 3 0) buffer)
(rsx-flips rsx) (wrap 32 (+ (rsx-flips rsx) 1))
(rsx-flip-status rsx) 0
(rsx-flip-handlers rsx) (wrap 32 (+ (rsx-flip-handlers rsx) 1)))
(unless (= (rsx-label-base rsx) 0)
(dotimes (i 4)
(mem-write 32 (+ (rsx-label-base rsx) #x10 (* 4 i)) 0)))
(rsx-event rsx +rsx-event-flip+))
(defconstant rsx-driver-head-flags) source
(defconstant rsx-driver-head-flags #x10C0)
(defconstant rsx-driver-head-size) source
(defconstant rsx-driver-head-size #x40)