mirror of
https://github.com/open-goal/jak-project
synced 2026-08-03 00:47:12 -04:00
ba919a069c
* temp * run function in process test * windows debug * debug * update * update * again * update * fix same bug in debugger
137 lines
3.7 KiB
Common Lisp
137 lines
3.7 KiB
Common Lisp
; (defun get-saved-regs ((dest (pointer uint64)))
|
|
; (rlet ((s0 :reg rbx :type uint)
|
|
; (s1 :reg rbp :type uint)
|
|
; (s2 :reg r10 :type uint)
|
|
; (s3 :reg r11 :type uint)
|
|
; (s4 :reg r12 :type uint))
|
|
; (set! (-> dest 0) s0)
|
|
; (set! (-> dest 1) s1)
|
|
; (set! (-> dest 2) s2)
|
|
; (set! (-> dest 3) s3)
|
|
; (set! (-> dest 4) s4)
|
|
|
|
; )
|
|
; )
|
|
|
|
(defmacro with-named-reg-vars-check (&rest body)
|
|
`(let ((one 1)
|
|
(two 2)
|
|
(three 3)
|
|
(four 4)
|
|
(five 5)
|
|
(six 6)
|
|
(seven 7)
|
|
(eight 8)
|
|
(nine 9))
|
|
,@body
|
|
(format 0 "~d ~d ~d ~d ~d ~d " one two three four five six)
|
|
(format 0 "~d ~d ~d~%" seven eight nine)
|
|
)
|
|
|
|
)
|
|
|
|
(defun deactivate-myself ()
|
|
"Deactivate the current process. A workaround because rlet isn't working well."
|
|
(rlet ((pp :reg r13 :type process))
|
|
(deactivate pp)
|
|
)
|
|
)
|
|
|
|
(defun target-function ((a0 uint) (a1 uint) (a2 uint) (a3 uint) (a4 uint) (a5 uint))
|
|
(format #t "TARGET FUNCTION ~D ~D ~D~%" a0 a1 a2)
|
|
(format #t "~D ~D ~D~%" a3 a4 a5)
|
|
|
|
(let ((stack-arr (new 'stack 'array 'uint8 12)))
|
|
(format #t "Stack Alignemnt ~D/16~%" (logand 15 (the uint stack-arr)))
|
|
)
|
|
|
|
(dotimes (i 10)
|
|
(format #t "proc1: ~D~%" i)
|
|
(when (> i 4)
|
|
(format #t "DEACTIVATE PROC 1~%")
|
|
(deactivate-myself)
|
|
)
|
|
(suspend)
|
|
)
|
|
)
|
|
|
|
(define-extern recurse (function int (pointer int32) int))
|
|
(defun recurse ((i int) (ptr (pointer int32)))
|
|
(if (> i 0)
|
|
(recurse (- i 1) ptr)
|
|
(suspend)
|
|
)
|
|
(set! (-> ptr) (+ (-> ptr) 1))
|
|
1
|
|
)
|
|
|
|
(defun target-function-2 ()
|
|
(let ((stack-var (new 'stack 'array 'int32 1)))
|
|
(set! (-> stack-var) 0)
|
|
(countdown (i 10)
|
|
(format #t "proc2: ~D~%" (-> stack-var))
|
|
(recurse 5 stack-var)
|
|
)
|
|
)
|
|
|
|
)
|
|
|
|
(defun kernel-test ()
|
|
(define test-process (get-process *nk-dead-pool* process 1024))
|
|
|
|
(activate test-process *active-pool* 'test-proc *kernel-dram-stack*)
|
|
|
|
|
|
(set-to-run (-> test-process main-thread)
|
|
target-function
|
|
1 2 3 4 5 6
|
|
)
|
|
|
|
(define test-process-2 (get-process *nk-dead-pool* process 1024))
|
|
(activate test-process-2 *active-pool* 'test-2 *kernel-dram-stack*)
|
|
(set-to-run (-> test-process-2 main-thread)
|
|
target-function-2
|
|
0 0 0 0 0 0)
|
|
0
|
|
)
|
|
|
|
(defun init-child-proc (a0 a1 a2 a3 a4 a5)
|
|
(format #t "Args: ~D ~D ~D~%" a0 a1 a2)
|
|
(format #t "~D ~D ~D~%" a3 a4 a5)
|
|
(let ((stack-arr (new 'stack 'array 'uint8 12)))
|
|
(format #t "Stack Alignemnt ~D/16~%" (logand 15 (the uint stack-arr)))
|
|
)
|
|
(if (eq? a0 (the int 0))
|
|
(deactivate-myself)
|
|
)
|
|
'init-child-proc-result
|
|
)
|
|
|
|
|
|
(defun initializer-process-function (a0)
|
|
(let ((child-proc (get-process *nk-dead-pool* process 1024)))
|
|
;; let's go
|
|
(activate child-proc *active-pool* 'child-proc *kernel-dram-stack*)
|
|
(let ((result (run-function-in-process child-proc init-child-proc a0 2 3 4 5 6)))
|
|
(format #t "run-function-in-process result: ~A~%" result)
|
|
)
|
|
)
|
|
|
|
(deactivate-myself)
|
|
)
|
|
|
|
(defun kernel-test-2 ()
|
|
(define initalizer-process (get-process *nk-dead-pool* process 1024))
|
|
(activate initalizer-process *active-pool* 'initializer-proc *kernel-dram-stack*)
|
|
(set-to-run (-> initalizer-process main-thread)
|
|
initializer-process-function
|
|
0 0 0 0 0 0
|
|
)
|
|
(define initalizer-process-2 (get-process *nk-dead-pool* process 1024))
|
|
(activate initalizer-process-2 *active-pool* 'initializer-proc-2 *kernel-dram-stack*)
|
|
(set-to-run (-> initalizer-process-2 main-thread)
|
|
initializer-process-function
|
|
1 0 0 0 0 0
|
|
)
|
|
0
|
|
) |