Types
dgo-file: basicsource
Types
vec4s: uint128source
Functions
ash(value: int, shift-amount: int) => intsource
Arithmetic shift value by shift-amount.
A positive shift-amount will shift to the left and a negative will shift to the right.
assoc(item: object, alist: object) => objectsource
Is there an entry with key item in the association list alist?
Returns the key-value pair.
assoce(item: object, alist: object) => objectsource
Is there an entry with key item in the association list alist?
Returns the key-value pair.
Treats a key of 'else like an else case
basic-type?(obj: basic, parent-type: type) => symbolsource
Is obj of type parent-type?
Note: this will return #f if you put a parent-type of object.
Only use this with types that are fully defined.
breakpoint-range-set!(a0: uint, a1: uint, a2: uint) => intsource
Sets some debug register (COP0 Debug, dab, dabm) to break on memory access.
This is not supported in OpenGOAL.
delete!(item: object, lst: object) => pairsource
Remove the first occurance of item from lst (where item is actual a pair in the list)
delete-car!(item: object, lst: object) => objectsource
Remove the first first occurance of an element from the list where (car elt) is item.
false-func() => symbolsource
Return false
find-parent-method(child-type: type, method-id: int) => functionsource
Search the type tree for a parent type with a different method
from the child, for the given method ID.
DANGER: only call this if you expect to find something.
There are no method-table range checks, so it may run off the end
of a method table and return junk
identity(x: object) => objectsource
Function which returns its input. The first function of the game!
This will not preserve the upper 64-bits of a 128-bit value.
insert-cons!(kv: object, alist: object) => pairsource
Update an association list to have the given (key . value) pair kv.
If it already exists in the list, remove it.
DANGER: this function allocates memory on the global heap.
mem-copy!(dst: pointer, src: pointer, size: int) => pointersource
Memory copy. Not a very efficient optimization, but has no restrictions.
Increasing address copy.
mem-or!(dst: pointer, src: pointer, size: int) => pointersource
Set the dst to (logior dst src) byte by byte.
Not very efficient.
mem-set32!(dst: pointer, size: int, value: int) => pointersource
Normal memset, but by 32-bit word.
NOTE: argument order is swapped from C
member(obj: object, lst: object) => objectsource
Is obj in the list lst? Returns pair with obj as its car, or #f if not found.
mod(a: int, b: int) => intsource
Compute mod. It does what you expect for positive numbers. For negative numbers, nobody knows what to expect.
This is a 32-bit operation. It uses an idiv on x86 and gets the remainder.
nassoc(item-name: string, alist: object) => objectsource
Is there an entry named item-name in the association list alist?
Checks name with nmember or name= so you can have multiple keys.
Returns the ([key|(key..)] . value) pair.
nassoce(item-name: string, alist: object) => objectsource
Is there an entry named item-name in the association list alist?
Checks name with nmember for multiple keys or name= for single.
Allows else as a single key that always matches
nmember(obj: basic, lst: object) => objectsource
Is obj in the list lst? Check with the name= function.
print-tree-bitmask(bits: int, count: int) => symbolsource
Print out a single entry for a process tree 'tree' diagram
qmem-copy->!(dst: pointer, src: pointer, size: int) => pointersource
Memory copy by quadword (16-bytes). More efficient, but has restrictions:
- dst and src should be 16-byte aligned.
- size in bytes will be rounding up to nearest 16-bytes
- Descending address copy
qmem-copy<-!(dst: pointer, src: pointer, size: int) => pointersource
Memory copy by quadword. More efficient, but has restrictions:
- dst and src should be 16-byte aligned.
- size in bytes will be rounded up to 16-bytes
- Ascending address copy.
quad-copy!(dst: pointer, src: pointer, qwc: int) => nonesource
Optimized memory copy. The original is pretty clever, but this isn't.
rem(a: int, b: int) => intsource
Compute remainder (32-bit). It is identical to mod. It uses a idiv and gets the remainder
sort(lst: pair, compare-func: function) => pairsource
Sort a list, using compare-func to compare elements.
The comparison function can return either an integer or a true/false.
For integers, use a positive number to represent first > second
Ex: (sort lst -) will sort in ascending order
For booleans, you must explicitly use TRUE and not a truthy value.
Ex: (sort my-list (lambda ((x int) (y int)) (< x y))) will sort ascending.
NOTE: if you use an integer, don't accidentally return TRUE.
type-type?(child-type: type, parent-type: type) => symbolsource
Is child-type a child (or equal to) parent-type?
It is safe to use this on a type that is not fully set up,
but in this case it will return #f.
valid?(obj: object, expected-type: type, name: basic, allow-false: basic, print-dest: object) => symbolsource
Check if the given object is valid. This will work for structures, pairs, basics, bintegers, symbols, and types.
If you set expected-type to #f, it just checks for a 4-byte aligned address that's in GOAL memory.
If you're checking a structure, set expected-type to structure. This requires 16-byte alignment
Note: packed inline structures in arrays or fields will not pass this check.
Otherwise, set it to the type you expect. More specific types will pass.
If allow-false is #t, a #f will always pass. Otherwise, #f will fail (unless you're looking for a symbol).
Use allow-false if you want to allow a 'null' reference.
The name is only used when printing out an error if the check fails.
Use a name of #f to suppress error prints.
Variables
*print-column*: bintegersource
*trace-list*: pairsource
BASIC_OFFSET: unknownsource
BIG_MEMORY: unknownsource
BINTEGER_OFFSET: unknownsource
const END_OF_MEMORY: unknownsource
PAIR_OFFSET: unknownsource
PC_BIG_MEMORY: unknownsource
PC_PROFILER_ENABLE: unknownsource
SYM_TO_STRING_OFFSET: unknownsource
Types
catch-frame: stack-framesource
cpu-thread: threadsource
dead-pool: process-treesource
Fields
type: type
name: basic
mask: process-mask
parent: pointer
brother: pointer
child: pointer
ppointer: pointer
self: process-tree
Methods
get-process(obj: dead-pool, type-to-make: type, stack-size: int) => processsource
Get a process from this dead pool of the given type.
return-process(obj: dead-pool, proc: process) => nonesource
Return a process to its pool once you are done with it.
dead-pool-heap: dead-poolsource
Fields
type: type
name: basic
mask: process-mask
parent: pointer
brother: pointer
child: pointer
ppointer: pointer
self: process-tree
allocated-length: int32
compact-time: uint32
compact-count-targ: uint32
compact-count: uint32
fill-percent: float
first-gap: dead-pool-heap-rec
first-shrink: dead-pool-heap-rec
heap: kheap
alive-list: dead-pool-heap-rec
last: dead-pool-heap-rec
dead-list: dead-pool-heap-rec
process-list: dead-pool-heap-rec
Methods
compact(obj: dead-pool-heap, count: int) => nonesource
Do heap compaction. The count argument tells us how much work to do.
If the heap is very full we will automatically do more work than requested.
shrink-heap(obj: dead-pool-heap, proc: process) => dead-pool-heapsource
Shrink the heap of a process.
This resizes the process heap to be the exact size it is currently using.
churn(obj: dead-pool-heap, count: int) => nonesource
Mess with the heap
memory-used(obj: dead-pool-heap) => intsource
Get the amount of memory used. This includes gaps between processes.
memory-total(obj: dead-pool-heap) => intsource
Get the total amount of memory for processes
gap-size(obj: dead-pool-heap, rec: dead-pool-heap-rec) => intsource
Determine the size between the given process and the next process or end of the heap.
If you give the first rec, it will given the gap between the beginning of the heap and the next process.
gap-location(obj: dead-pool-heap, rec: dead-pool-heap-rec) => pointersource
Get the gap after the given process.
If root of the alive list is given, will give the first gap between the heap and the first process.
If there is no gap, may point to the next process. Not 16-byte aligned.
find-gap(obj: dead-pool-heap, rec: dead-pool-heap-rec) => dead-pool-heap-recsource
Start at the given record and find the closest gap after it. Returns the rec
which has the gap after it. If no gaps, returns the last rec.
find-gap-by-size(obj: dead-pool-heap, size: int) => dead-pool-heap-recsource
Find a gap which will fit at least size bytes. Returns the rec for the proc before the gap.
Will return a #f rec if there's no gap big enough.
memory-free(obj: dead-pool-heap) => intsource
Get the total memory free.
compact-time(obj: dead-pool-heap) => uintsource
Access the compact time field.
dead-pool-heap-rec: structuresource
event-message-block: structuresource
handle: uint64source
kernel-context: basicsource
process: process-treesource
Fields
type: type
name: basic
mask: process-mask
parent: pointer
brother: pointer
child: pointer
ppointer: pointer
self: process-tree
pool: dead-pool
status: basic
pid: int32
main-thread: cpu-thread
top-thread: thread
entity: entity-actor
state: state
trans-hook: function
post-hook: function
event-hook: function
allocated-length: int32
next-state: state
heap-base: pointer
heap-top: pointer
heap-cur: pointer
stack-frame-top: stack-frame
connection-list: connectable
stack: uint8
States
dead-state: TODO
empty-state: TODO
process-tree: basicsource
Fields
type: type
name: basic
mask: process-mask
parent: pointer
brother: pointer
child: pointer
ppointer: pointer
self: process-tree
Methods
activate(obj: process, dest: process-tree, name: basic, stack-top: pointer) => process-treesource
Activate a process! Put it on the given active tree and set up the main thread.
deactivate(obj: eco-pill) => nonesource
init-from-entity!(obj: basebutton, arg0: entity-actor) => nonesource
run-logic?(obj: money) => symbolsource
process-tree-method-13: unknown
protect-frame: stack-framesource
stack-frame: basicsource
state: protect-framesource
Fields
type: type
name: symbol
next: stack-frame
exit: function
code: function
trans: function
post: function
enter: function
event: function
thread: basicsource
Fields
type: type
name: basic
process: process
previous: thread
suspend-hook: function
resume-hook: function
pc: pointer
sp: pointer
stack-top: pointer
stack-size: int32
Methods
stack-size-set!(this: thread, stack-size: int) => nonesource
Set the backup stack size of a thread. This should only be done on the main-thread.
This should be done immediately after allocating the main-thread.
Users can do this if they want a larger or smaller backup stack than the default.
thread-suspend(unused: cpu-thread) => nonesource
Suspend the thread and return to the kernel.
thread-resume(thread-to-resume: cpu-thread) => nonesource
Resume a suspended thread. Call this from the kernel only.
This is also used to start a thread initialized with set-to-run.
As a result of MIPS/x86 differences, there is a hack for this.
Variables
*gtype-basic-offset*: unknownsource
*irx-major-version*: unknownsource
*irx-minor-version*: unknownsource
*kernel-major-version*: unknownsource
*kernel-minor-version*: unknownsource
*scratch-memory-top*: unknownsource
*tab-size*: unknownsource
const DPROCESS_STACK_SIZE: unknownsource
INVALID_HANDLE: unknownsource
KERNEL_DEBUG: unknownsource
PROCESS_CLEAR_MASK: unknownsource
PROCESS_HEAP_MULT: unknownsource
PROCESS_HEAP_SIZE: unknownsource
PROCESS_STACK_SAVE_SIZE: unknownsource
PROCESS_STACK_SIZE: unknownsource
Functions
change-brother(arg0: process-tree, arg1: process-tree) => objectsource
Unused, and wrong.
It seems like this was written when processes store process-trees, not (pointer process-tree).
change-parent(obj: process-tree, new-parent: process-tree) => process-treesource
Make obj a child of new-parent
execute-process-tree(obj: process-tree, func: function, context: kernel-context) => objectsource
Like iterate, but also requires that prevent-from-run's mask doesn't block, and that run-logic?
is true in order to call the function.
inspect-process-heap(obj: process) => symbolsource
Inspect the heap of a process.
inspect-process-tree(obj: process-tree, level: int, mask: int, detail: symbol) => process-treesource
Debug print a pocess-tree
iterate-process-tree(obj: process-tree, func: function, context: kernel-context) => objectsource
Call func on all processes that aren't a process-tree. If func returns 'dead, stop.
The kernel-context is ignored.
kernel-dispatcher() => objectsource
Run the kernel!
This is the entry point from C++ to GOAL.
kill-by-name(name: object, pool: process-tree) => symbolsource
Call deactivate on all process with the given name.
kill-by-type(type: object, pool: process-tree) => symbolsource
Call deactivate on all processes with the given type
kill-not-name(name: object, pool: process-tree) => symbolsource
Call deactivate on all processes that don't match the name
kill-not-type(type: object, pool: process-tree) => symbolsource
Call deactivate on all prcesses that don't match the given type
load-package(package: string, allocation: kheap) => pairsource
Load a Package from a CGO/DGO
previous-brother(proc: process-tree) => objectsource
Get the process p where (-> p brother) is proc. Unused
process-by-name(name: object, pool: process-tree) => processsource
Look up a process in the given pool by name
process-count(this: process-tree) => intsource
Count number of processes in the given tree using iterate-process-tree
process-not-name(name: object, pool: process-tree) => processsource
Look up a process with not the given name.
reset-and-call(obj: thread, func: function) => objectsource
Make the given thread the top thread, reset the stack, and call the function.
Sets up a return trampoline so when the function returns it will return to the
kernel context. Will NOT deactivate on return, so this is intended for temporary threads.
NOTE: this should only be done from the kernel, running on the
kernel's stack.
return-from-thread() => nonesource
Context switch to the saved kernel context now.
This is intended to be jumped to with the ret instruction (return trampoline)
at the end of a normal function, so this should preserve rax.
To make sure this happens, all ops should be asm ops and we should have no
GOAL expressions.
return-from-thread-dead() => nonesource
Like return from thread, but we clean up our process with deactivate first.
The return register is not preserved here, instead we return the value of deactivate
run-function-in-process(obj: process, func: function, a0: object, a1: object, a2: object, a3: object, a4: object, a5: object) => objectsource
Switch to the given process and run the function. This is used to initialize a process.
The function will run until it attempts to change state. At the first attempt to change state,
this function will return. The idea is that you use this when you want to initialize a process NOW.
This will then return the value of the function you called!
search-process-tree(obj: process-tree, func: function) => process-treesource
Find the first process which func return true on. Won't find process-tree's (by mask)
set-to-run(thread: cpu-thread, func: function, a0: object, a1: object, a2: object, a3: object, a4: object, a5: object) => pointersource
Set the given thread to call the given function with the given arguments next time it resumes.
Only for main threads.
Once the function returns, the process deactivates.
set-to-run-bootstrap() => nonesource
This function is a clever hack.
To reset a thread to running a new function, we stash the arguments as saved registers.
These are then restored by thread-resume on the next run of the kernel.
This stub remaps these saved registers to argument registers.
It also creates a return trampoline to return-from-thread-dead, so if the main thread returns, the
process is properly cleaned up by deactivate.
stream<-process-mask(arg0: object, arg1: process-mask) => process-masksource
throw-dispatch(obj: catch-frame, value: object) => nonesource
Throw the given value to the catch frame.
Only can throw a 64-bit value. The original could throw 128 bits.
unload-package(package: string) => pairsource
Mark a package as unloaded, if it was loaded previously
Variables
*dead-pool-list*: pairsource
*deci-count*: intsource
*dram-stack*: pointersource
*fake-scratchpad-data*: pointersource
*fake-scratchpad-stack*: pointersource
*global-search-name*: basicsource
*irx-version*: bintegersource
*kernel-boot-level*: symbolsource
*kernel-boot-mode*: symbolsource
*kernel-dram-stack*: unknownsource
*kernel-packages*: pairsource
*kernel-version*: bintegersource
*master-mode*: symbolsource
*pause-lock*: symbolsource
*use-old-listener-print*: symbolsource
*vis-boot*: basicsource
const dead-state: statesource
entity-deactivate-handler: functionsource
Functions
enter-state(arg0: object, arg1: object, arg2: object, arg3: object, arg4: object, arg5: object) => objectsource
Make the process stored in pp enter the state in pp next-state
inherit-state(child: state, parent: state) => statesource
Copy handler functions from parent to child
looping-code() => symbolsource
Loop.
send-event-function(proc: process-tree, msg: event-message-block) => objectsource
Function to send an event to a process. Please use the send-event macros when possible
Functions
append-character-to-string(str: string, char: uint8) => intsource
Append char to the end of the given string.
cat-string<-string(a: string, b: string) => stringsource
Append b to a. No length checks
cat-string<-string_to_charp(a: string, b: string, end-ptr: pointer) => pointersource
Append b to a, using chars of b up to (and including) the one pointed to by end-ptr,
or, until the end of b, whichever comes first.
catn-string<-charp(a: string, b: pointer, len: int) => stringsource
Append b to a, exactly len chars
charp-basename(charp: pointer) => pointersource
Like basename in C
charp<-string(dst: pointer, src-string: string) => intsource
Copy a GOAL string into a character array.
copy-charp<-charp(dst: pointer, src: pointer) => pointersource
C string copy.
copy-string<-string(dst: string, src: string) => stringsource
Copy data from one string to another, like strcpy
copyn-string<-charp(str: string, charp: pointer, len: int) => stringsource
Copy data from a charp to a GOAL string. Copies len chars, plus a null.
copyn-string<-string(dst: string, src: string, len: int) => stringsource
Copy len bytes of data from one string to another, like strncpy
name=(arg0: basic, arg1: basic) => symbolsource
Do arg0 and arg1 have the same name?
This can use either strings or symbols
string->float(str: string) => floatsource
Convert a string to a float, but it is not implemented.
string->int(str: string) => intsource
String to int. Supports binary, hex, and decimal. Negative is implemented for decimal and hex
But I think it's broken?
string-cat-to-last-char(base-str: string, append-str: string, char: uint) => pointersource
Append append-str to the end of base-str, up to the last occurance of char in append-str
string-charp=(str: string, charp: pointer) => symbolsource
Is the data in str equal to the C string charp?
string-downcase(in: string, out: string) => stringsource
Lowercase the given string.
string-get-arg!!(a-str: string, arg: string) => symbolsource
Get the first argument from a whitespace separated list of arguments.
The arguments can be in quotes or not.
Removes argument from arg string, sucks up white space before the next one
Outputs argument to a-str.
string-get-flag!!(result: pointer, in: string, first-flag: string, second-flag: string) => symbolsource
string-get-float!!(arg0: pointer, arg1: string) => symbolsource
string-get-int32!!(arg0: pointer, arg1: string) => symbolsource
Get an int32 from a list of arguments
string-skip-to-char(str: pointer, char: uint) => pointersource
Return pointer to first instance of char in C string, or to the null terminator if none
string-skip-whitespace(arg0: pointer) => pointersource
Skip over spaces, tabs, r's and n's
string-strip-leading-whitespace!(str: string) => symbolsource
Remove whitespace at the front of a string
string-strip-trailing-whitespace!(str: string) => symbolsource
Remove whitespace at the end of a string
string-strip-whitespace!(arg0: string) => symbolsource
Remove whitespace at the beginning and end of a string
string-suck-up!(str: string, location: pointer) => symbolsource
Remove character between the start of string and location.
The char pointed to by location is now the first.
string-upcase(in: string, out: string) => stringsource
Uppercase the given string.
string<-charp(str: string, charp: pointer) => stringsource
Copy all chars from a char* to a GOAL string.
Does NO length checking.
string=(str-a: string, str-b: string) => symbolsource
Does str-a hold the same data as str-b?.
If either string is null, returns #f.
substring!(dst: string, src: string, start: int, end: int) => stringsource
Copy the specified substring to dst. Returns an empty string if invalid indices are given.
Variables
*debug-draw-pauseable*: symbolsource
*string-tmp-str*: stringsource
*temp-string*: stringsource
*temp-string2*: stringsource
Types
lowmemmap: structuresource
Fields
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
Functions
deinstall-debug-handler() => nonesource
Set the kernel exception handler back to the default?
deinstall-debug-handlers() => nonesource
Set a bunch of excpetion handlers back to the default?
install-default-debug-handler(handler: object) => nonesource
Installs the given handler as the debug handler 1 through 13.
Uses the install-debug-handler function defined in kmachine.cpp
kernel-check-hardwired-addresses() => nonesource
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.
kernel-copy-function(unused: object, source: object, dest: object, size: object) => nonesource
Copy size words from source to dest. The a0 argument is ignored.
Uses registers a0, a1, a2, a3
kernel-copy-to-kernel-ram() => nonesource
Does a syscall 102. This is CpuConfig on released PS2 BIOSes.
I'm guessing this somehow calls kernel-copy-function
kernel-read() => nonesource
Does a syscall 102. I'm guessing this somehow calls kernel-read-function
kernel-read-function(unused: object, source: object) => nonesource
Read a single word (signed) from source
kernel-set-exception-vector() => nonesource
Use syscall 13/syscall 14 to set exception handlers
kernel-set-interrupt-vector() => nonesource
Use syscall 15 to set an interrupt handler
kernel-set-level2-vector() => nonesource
Set some handler by writing directly to kernel memory. Not sure what this is.
kernel-write() => nonesource
Does a syscall 102. I'm guessing this somehow calls kernel-write-function.
kernel-write-function(unused: object, source: object, dest: object) => nonesource
Writes a single word to the destination
resend-exception() => nonesource
I think this was to return from a GOAL crash handler back to the EE kernel's crash handler.
return-from-exception(regs: object) => nonesource
Restore the registers and eret.