Files
jak-project/goal_src/jak1/kernel/pskernel.gc
ManDude cd68cb671e deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code:
- the decompiler will no longer emit the `offset-assert`,
`method-count-assert`, `size-assert` and `flag-assert` parameters. There
are extremely few cases where having this in the decompiled code is
helpful, as the types there come from `all-types` which already has
those parameters. This also doesn't break type consistency because:
  - the asserts aren't compared.
- the first step of the test uses `all-types`, which has the asserts,
which will throw an error if they're bad.
- the decompiler won't emit the `heap-base` parameter unless necessary
now.
- the decompiler will try its hardest to turn a fixed-offset field into
an `overlay-at` field. It falls back to the old offset if all else
fails.
- `overlay-at` now supports field "dereferencing" to specify the offset
that's within a field that's a structure, e.g.:
```lisp
(deftype foobar (structure)
  ((vec    vector  :inline)
   (flags  int32   :overlay-at (-> vec w))
   )
  )
```
in this structure, the offset of `flags` will be 12 because that is the
final offset of `vec`'s `w` field within this structure.
- **removed ID from all method declarations.** IDs are only ever
automatically assigned now. Fixes #3068.
- added an `:overlay` parameter to method declarations, in order to
declare a new method that goes on top of a previously-defined method.
Syntax is `:overlay <method-name>`. Please do not ever use this.
- added `state-methods` list parameter. This lets you quickly specify a
list of states to be put in the method table. Same syntax as the
`states` list parameter. The decompiler will try to put as many states
in this as it can without messing with the method ID order.

Also changes `defmethod` to make the first type definition (before the
arguments) optional. The type can now be inferred from the first
argument. Fixes #3093.

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-10-30 03:20:02 +00:00

129 lines
3.8 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; 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)
)