mirror of
https://github.com/open-goal/jak-project
synced 2026-05-31 17:32:51 -04:00
c811778d00
* add reset-here to clear coloring at entry to rlet * update doc
99 lines
2.7 KiB
Common Lisp
99 lines
2.7 KiB
Common Lisp
|
|
(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~%")
|
|
(process-deactivate)
|
|
)
|
|
(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))
|
|
(process-deactivate)
|
|
)
|
|
'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)
|
|
)
|
|
)
|
|
|
|
(process-deactivate)
|
|
)
|
|
|
|
(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
|
|
) |