mirror of
https://github.com/open-goal/jak-project
synced 2026-07-10 23:22:17 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
132 lines
3.9 KiB
Common Lisp
132 lines
3.9 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "KERNEL.CGO")
|
|
|
|
(require "kernel/gcommon.gc")
|
|
|
|
;; name: pskernel.gc
|
|
;; name in dgo: pskernel
|
|
;; dgos: KERNEL
|
|
|
|
#|
|
|
pskernel.gc contains a bunch of utilities for poking around the PS2's kernel.
|
|
These are unused in the retail game, and wouldn't be "safe" to use on a retail console,
|
|
as later console revisions may have different memory layout of the BIOS. I suspect this
|
|
was used for the purposes of debugging and handling crashes.
|
|
They took over syscall 102 to access memory inside the kernel.
|
|
|
|
There's an error message:
|
|
"I CANNOT CONTINUE TO LOAD GOAL, BECAUSE THE KERNEL VERSION HAS CHANGED~%"
|
|
"~%Alternatively, try removing pskernel.gc and debug-handlers.gc from project.cl, do an (lg) and then (:r) again~%"
|
|
|
|
My theory is that debug-handlers.gc held crash handlers, and on load would install them using functions defined in pskernel.gc.
|
|
In the retail game, they removed debug-handlers, but not pskernel.
|
|
|
|
In the PC port, all of these functions are just stubs.
|
|
|#
|
|
|
|
;; map of the kernel's memory.
|
|
(deftype lowmemmap (structure)
|
|
((irq-info-stack uint32)
|
|
(irq2-info-stack uint32)
|
|
(kernel-copy-fn uint32)
|
|
(kernel-write-fn uint32)
|
|
(r1-save uint128)
|
|
(last-time uint32)
|
|
(high-time uint32)
|
|
(dma-status uint32)
|
|
(dma-qnext uint32)
|
|
(dma-qwc uint32)
|
|
(dma-tnext uint32)
|
|
(dma-stack0 uint32)
|
|
(dma-stack1 uint32)
|
|
(kernel-read-fn uint32)
|
|
)
|
|
)
|
|
|
|
(defmacro nyi-break (name)
|
|
`(begin
|
|
(format 0 "~A is not implemented!~%" (quote ,name))
|
|
(break)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
(defun kernel-copy-function (unused source dest size)
|
|
"Copy size words from source to dest. The a0 argument is ignored.
|
|
Uses registers a0, a1, a2, a3"
|
|
(nyi-break kernel-copy-function)
|
|
)
|
|
|
|
(defun kernel-copy-to-kernel-ram ()
|
|
"Does a syscall 102. This is CpuConfig on released PS2 BIOSes.
|
|
I'm guessing this somehow calls kernel-copy-function"
|
|
(nyi-break kernel-copy-to-kernel-ram)
|
|
)
|
|
|
|
(defun kernel-write-function (unused source dest)
|
|
"Writes a single word to the destination"
|
|
(nyi-break kernel-write-function)
|
|
)
|
|
|
|
(defun kernel-write ()
|
|
"Does a syscall 102. I'm guessing this somehow calls kernel-write-function."
|
|
(nyi-break kernel-write)
|
|
)
|
|
|
|
(defun kernel-read-function (unused source)
|
|
"Read a single word (signed) from source"
|
|
(nyi-break kernel-read-function)
|
|
)
|
|
|
|
(defun kernel-read ()
|
|
"Does a syscall 102. I'm guessing this somehow calls kernel-read-function"
|
|
(nyi-break kernel-read)
|
|
)
|
|
|
|
(defun kernel-check-hardwired-addresses ()
|
|
"Checks a bunch of stuff in the kernel using kernel-read.
|
|
If the memory layout isn't what it expects, it prints an error and crashes."
|
|
(nyi-break kernel-check-hardwired-addresses)
|
|
)
|
|
|
|
(defun install-default-debug-handler (handler)
|
|
"Installs the given handler as the debug handler 1 through 13.
|
|
Uses the install-debug-handler function defined in kmachine.cpp"
|
|
(nyi-break install-default-debug-handler)
|
|
)
|
|
|
|
(defun return-from-exception (regs)
|
|
"Restore the registers and eret."
|
|
(nyi-break return-from-exception)
|
|
)
|
|
|
|
(defun kernel-set-exception-vector ()
|
|
"Use syscall 13/syscall 14 to set exception handlers"
|
|
(nyi-break kernel-set-exception-vector)
|
|
)
|
|
|
|
(defun kernel-set-interrupt-vector ()
|
|
"Use syscall 15 to set an interrupt handler"
|
|
(nyi-break kernel-set-interrupt-vector)
|
|
)
|
|
|
|
(defun kernel-set-level2-vector ()
|
|
"Set some handler by writing directly to kernel memory. Not sure what this is."
|
|
(nyi-break kernel-set-level2-vector)
|
|
)
|
|
|
|
(defun deinstall-debug-handler ()
|
|
"Set the kernel exception handler back to the default?"
|
|
(nyi-break deinstall-debug-handler)
|
|
)
|
|
|
|
(defun deinstall-debug-handlers ()
|
|
"Set a bunch of excpetion handlers back to the default?"
|
|
(nyi-break deinstall-debug-handlers)
|
|
)
|
|
|
|
(defun resend-exception ()
|
|
"I think this was to return from a GOAL crash handler back to the EE kernel's crash handler."
|
|
(nyi-break resend-exception)
|
|
) |