gs: regs.lisp

the GS's general registers as an ISA: addresses, fields, semantics.

0/1 a fixed bit, name a field,   a bit the decoder ignores

TRXPOS source

Transfer rectangles' corners and the direction of a local copy

Address0x51
6362616059585756555453525150494847464544434241403938373635343332
dirdsaydsax
313029282726252423222120191817161514131211109876543210
ssayssax
(defgsreg TRXPOS #x51 ((ssax 0 11) (ssay 16 11) (dsax 32 11) (dsay 48 11) (dir 59 2))
  "Transfer rectangles' corners and the direction of a local copy")

TRXREG source

Transfer rectangle size

Address0x52
6362616059585756555453525150494847464544434241403938373635343332
rrh
313029282726252423222120191817161514131211109876543210
rrw
(defgsreg TRXREG #x52 ((rrw 0 12) (rrh 32 12))
  "Transfer rectangle size")

TRXDIR source

Transfer activation: 0 host to local, 1 local to host, 2 local to local, 3 none

Address0x53
313029282726252423222120191817161514131211109876543210
xdir
(defgsreg TRXDIR #x53 ((xdir 0 2))
  "Transfer activation: 0 host to local, 1 local to host, 2 local to local, 3 none"
  (gs-xfer-start g xdir))

HWREG source

Transfer data, host to local

Address0x54
(defgsreg HWREG #x54 ()
  "Transfer data, host to local"
  (gs-hwreg g value))

SIGNAL source

SIGNAL event: SIGLBLID's signal id under the mask, CSR.SIGNAL

Address0x60
6362616059585756555453525150494847464544434241403938373635343332
idmsk
313029282726252423222120191817161514131211109876543210
id
(defgsreg SIGNAL #x60 ((id 0 32) (idmsk 32 32))
  "SIGNAL event: SIGLBLID's signal id under the mask, CSR.SIGNAL"
  (let* ((old (aref (gsm-priv g) 24))
         (sig (logior (logand (ldb (byte 32 0) old) (wrap 32 (lognot idmsk))) (logand id idmsk))))
    (setf (aref (gsm-priv g) 24) (logior (logand old #xFFFFFFFF00000000) sig)))
  (gs-event g 0))

FINISH source

FINISH event: CSR.FINISH once drawing is done (at once here)

Address0x61
(defgsreg FINISH #x61 ()
  "FINISH event: CSR.FINISH once drawing is done (at once here)"
  (gs-event g 1))

LABEL source

SIGLBLID's label id under the mask

Address0x62
6362616059585756555453525150494847464544434241403938373635343332
idmsk
313029282726252423222120191817161514131211109876543210
id
(defgsreg LABEL #x62 ((id 0 32) (idmsk 32 32))
  "SIGLBLID's label id under the mask"
  (let ((old (aref (gsm-priv g) 24)))
    (setf (aref (gsm-priv g) 24)
          (logior (logand old #xFFFFFFFF)
                  (ash (logior (logand (ash old -32) (wrap 32 (lognot idmsk))) (logand id idmsk)) 32)))))

Other definitions

(defmacro defgsreg) source
(defmacro defgsreg (name addresses fields &rest doc-and-body)
  (let* ((addresses (if (listp addresses) addresses (list addresses)))
         (doc (if (stringp (car doc-and-body)) (car doc-and-body) ""))
         (body (if (stringp (car doc-and-body)) (cdr doc-and-body) doc-and-body)))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       (setq *gs-regs* (append (remove ',name *gs-regs* :key #'car)
                               (list '(,name ,addresses ,fields ,doc ,body))))
       ',name)))
(defmacro greg) source
(defmacro greg (name &optional (ctx 0))
  (let ((as (gs-reg-addresses name)))
    (unless as (error "no GS register ~A" name))
    (if (cdr as)
        `(aref (gsm-reg g) (+ ,(first as) ,ctx))
        `(aref (gsm-reg g) ,(first as)))))
(defun gs-event) source
(defun gs-event (g bit)
  "the SIGNAL (BIT 0) or FINISH (1) event: its CSR bit; a machine reads CSR and IMR for the interrupt"
  (declare (type gsm g) (type (unsigned-byte 8) bit))
  (setf (gsm-csr g) (logior (gsm-csr g) (ash 1 bit)))
  (setf (gsm-events g) (wrap 32 (+ (gsm-events g) 1)))
  nil)
(defmacro define-gs-write) source
(defmacro define-gs-write ()
  `(defun gs-write (g addr value)
     "write VALUE to the general register at ADDR: store it, then its semantics"
     (declare (type gsm g) (type (unsigned-byte 8) addr) (type (unsigned-byte 64) value))
     (setf (aref (gsm-reg g) (logand addr #x7F)) value)
     (case addr
       ,@(loop for r in *gs-regs* append (gs-reg-case-clause r))
       (otherwise (setf (gsm-unknown g) (wrap 32 (+ (gsm-unknown g) 1)))))
     nil))

Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.